Reads the specified number of samples from the other input channels and writes the specified number of samples to the other output channels at the indicated sampling rate.

Namespace:  Quanser.Hardware
Assembly:  Quanser.Hardware.Hil (in Quanser.Hardware.Hil.dll)

Syntax

Visual Basic (Declaration)
Public Sub ReadOtherWriteOtherBuffer ( _
	clock As Hil..::.Clock, _
	frequency As Double, _
	numSamples As Integer, _
	inputChannels As Integer(), _
	outputChannels As Integer(), _
	inputBuffer As Double(), _
	outputBuffer As Double() _
)
C#
public void ReadOtherWriteOtherBuffer(
	Hil..::.Clock clock,
	double frequency,
	int numSamples,
	int[] inputChannels,
	int[] outputChannels,
	double[] inputBuffer,
	double[] outputBuffer
)
Visual C++
public:
void ReadOtherWriteOtherBuffer(
	Hil..::.Clock clock, 
	double frequency, 
	int numSamples, 
	array<int>^ inputChannels, 
	array<int>^ outputChannels, 
	array<double>^ inputBuffer, 
	array<double>^ outputBuffer
)
JavaScript
function readOtherWriteOtherBuffer(clock, frequency, numSamples, inputChannels, outputChannels, inputBuffer, outputBuffer);

Parameters

clock
Type: Quanser.Hardware..::.Hil..::.Clock

The clock used to time the operation. Note that some clocks allow faster sampling rates than others. See the Hil..::.Clock enumeration for more information on clocks.

Select a board type to the list for board-specific details: .

frequency
Type: System..::.Double

The frequency in Hertz at which to read from the other input channels and write to the other output channels. For example, if frequency is set to 1000, then the ReadOtherWriteOtherBuffer method will read all the input channels and write all the output channels every millisecond.

numSamples
Type: System..::.Int32

The number of samples to generate. Each "sample" consists of all the other input channels and all the other output channels specified. For example, if frequency is set to 1000 and numSamples is set to 5000, then the ReadOtherWriteOtherBuffer method will return after 5 seconds, having read 5000 samples and written 5000 samples. If three input channels have been selected, then the inputBuffer will contain 15,000 elements. If two output channels have been selected, then the outputBuffer must contain 10,000 elements.

inputChannels
Type: array< System..::.Int32 >[]()[]

An array containing the numbers of the other input channels from which to read. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc.

Select a board type to the list for board-specific details: .

outputChannels
Type: array< System..::.Int32 >[]()[]

An array containing the numbers of the other output channels to which to write. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc.

Select a board type to the list for board-specific details: .

inputBuffer
Type: array< System..::.Double >[]()[]

An array for receiving the values read from the other inputs. The array must contain inputChannels.Length * numSamples elements. The array is organized as a linear array of samples, with each sample consisting of a group of channels. For example, if other input channels 0, 1 and 3 are being read, than the data appears in the array as follows, where the numbers correspond to channel numbers:

0 1 3 0 1 3 ...
outputBuffer
Type: array< System..::.Double >[]()[]

An array containing the values to write to the other outputs. The array must contain outputChannels.Length * numSamples elements. The array must be organized as a linear array of samples, with each sample consisting of a group of channels. For example, if other output channels 0, 1 and 3 are being written, than the data must appear in the array as follows, where the numbers correspond to channel numbers:

0 1 3 0 1 3 ...

Remarks

The ReadOtherWriteOtherBuffer method reads the specified number of samples from the other input channels and writes to the specified other output channels at the given sampling rate in a single method call. Each sampling instant, the write operation occurs immediately following the read operation. Since the read-write operation occurs at the lowest level the read and write occur virtually concurrently. The method does not return until all the data has been read and written. This method is particularly useful for system identification since the read and write operations are synchronized. In particular, the value read in one sampling instant is the result of the write operation in the previous sampling instant.

Examples

This example illustrates how to read and write other outputs at a specified rate, in one operation. It reads 5000 samples from other input channels 0-3 and writes at the same time to other output channels 0-1 at 1 kHz. The call to ReadOtherWriteOtherBuffer does not return until all the samples have been read and written, 5 seconds later. One Hertz sine waves are written to the outputs, with amplitudes of 7, 8, 9 and 10 respectively. Exceptions are ignored for simplicity.
C# Copy Code
int []    inputChannels  = { 0, 1, 2, 3 };
int []    outputChannels = { 0, 1 };
double    frequency      = 1000;
int       samples        = 5000;
double [] inputBuffer    = new double [samples * inputChannels.Length];
double [] outputBuffer   = new double [samples * outputChannels.Length];
double    time;
int       s, c;

for (s = 0; s < samples; s++) {
   time = s / frequency;
   for (c = 0; c < outputChannels.Length; c++) {
       outputBuffer[s * outputChannels.Length + c] = (c + 7.0) * Math.sin(2 * Math.PI * time);
   }
}
   
card.ReadOtherWriteOtherBuffer(Hil.Clock.Hardware0, frequency, samples,
    inputChannels, outputChannels, 
    inputBuffer, outputBuffer);
Visual Basic Copy Code
Dim inputChannels() As Integer = {0, 1, 2, 3}
Dim outputChannels() As Integer = {0, 1}
Dim frequency As Double = 1000
Dim samples As Integer = 5000
Dim inputBuffer(samples * inputChannels.Length - 1) As Double
Dim outputBuffer(samples * outputChannels.Length - 1) As Double
Dim time As Double
Dim s As Integer
Dim c As Integer

For s = 0 To samples
   time = s / frequency
   For c = 0 To outputChannels.Length
       outputBuffer(s * outputChannels.Length + c) = (c + 7.0) * Math.sin(2 * Math.PI * time)
   Next
Next

card.ReadOtherWriteOtherBuffer(Hil.Clock.Hardware0, frequency, samples, _
    inputChannels, outputChannels, _
    inputBuffer, outputBuffer)
Visual C++ Copy Code
array<int>^    inputChannels  = { 0, 1, 2, 3 };
array<int>^    outputChannels = { 0, 1 };
double         frequency      = 1000;
int            samples        = 5000;
array<double>^ inputBuffer    = gcnew array<double>(samples * inputChannels->Length);
array<double>^ outputBuffer   = gcnew array<double>(samples * outputChannels->Length);
double         time;
int            s, c;

for (s = 0; s < samples; s++) {
   time = s / frequency;
   for (c = 0; c < outputChannels->Length; c++) {
       outputBuffer[s * outputChannels->Length + c] = (c + 7.0) * Math::sin(2 * Math::PI * time);
   }
}
   
card->ReadOtherWriteOtherBuffer(Hil::Clock::Hardware0, frequency, samples,
    inputChannels, outputChannels, 
    inputBuffer, outputBuffer);

Exceptions

ExceptionCondition
Quanser.Hardware..::.HilException If the read or write cannot be performed then an exception is thrown. This situtation typically arises if the board does not support other inputs or outputs or the hardware resources required are in use by a task.

See Also