Reads from analog, encoder, digital and/or other inputs immediately.

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

Syntax

Visual Basic (Declaration)
Public Sub Read ( _
	analogChannels As Integer(), _
	encoderChannels As Integer(), _
	digitalChannels As Integer(), _
	otherChannels As Integer(), _
	analogVoltages As Double(), _
	encoderCounts As Integer(), _
	digitalBits As SByte(), _
	otherValues As Double() _
)
C#
public void Read(
	int[] analogChannels,
	int[] encoderChannels,
	int[] digitalChannels,
	int[] otherChannels,
	double[] analogVoltages,
	int[] encoderCounts,
	sbyte[] digitalBits,
	double[] otherValues
)
Visual C++
public:
void Read(
	array<int>^ analogChannels, 
	array<int>^ encoderChannels, 
	array<int>^ digitalChannels, 
	array<int>^ otherChannels, 
	array<double>^ analogVoltages, 
	array<int>^ encoderCounts, 
	array<signed char>^ digitalBits, 
	array<double>^ otherValues
)
JavaScript
function read(analogChannels, encoderChannels, digitalChannels, otherChannels, analogVoltages, encoderCounts, digitalBits, otherValues);

Parameters

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

An array containing the numbers of the analog input channels to be read. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc. If no analog input channels are to be read then set this parameter to NoChannels or nullptr.

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

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

An array containing the numbers of the encoder input channels to be read. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc. If no encoder input channels are to be read then set this parameter to NoChannels or nullptr.

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

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

An array containing the numbers of the digital input channels to be read. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc. If no digital input channels are to be read then set this parameter to NoChannels or nullptr.

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

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

An array containing the numbers of the other input channels to be read. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc. If no other input channels are to be read then set this parameter to NoChannels or nullptr.

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

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

An array for receiving the voltage values read from the analog inputs. Each element in the analogVoltages array corresponds to the same element in the analogChannels array. Hence, there must be as many elements in the analogVoltages array as there are analog channels.

If no analog input channels are being read then this parameter may be set to NoDoubleBuffer or nullptr.

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

An array for receiving the count values read from the encoder inputs. Each element in the encoderCounts array corresponds to the same element in the encoderChannels array. Hence, there must be as many elements in the encoderCounts array as there are encoder channels.

If no encoder input channels are being read then this parameter may be set to NoIntegerBuffer or nullptr.

digitalBits
Type: array< System..::.SByte >[]()[]

An array for receiving the binary values read from the digital inputs. Each element in the digitalBits array corresponds to the same element in the digitalChannels array. Hence, there must be as many elements in the digitalBits array as there are digital channels.

If no digital input channels are being read then this parameter may be set to NoBooleanBuffer or nullptr.

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

An array for receiving the values read from the other inputs. Each element in the otherValues array corresponds to the same element in the otherChannels array. Hence, there must be as many elements in the otherValues array as there are other channels.

If no other input channels are being read then this parameter may be set to NoDoubleBuffer or nullptr.

Remarks

The Read method reads from the specified input channels immediately. The method does not return until the data has been read.

Warning

Many cards allow the digital I/O lines to be programmed as inputs or outputs. The digital I/O lines are configured as inputs or outputs using the SetDigitalDirections(array<Int32>[]()[], array<Int32>[]()[]) method. All the channels which will be used as digital inputs or outputs must be configured accordingly using this function. Failure to configure the digital I/O may result in the Read(array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Double>[]()[], array<Int32>[]()[], array<SByte>[]()[], array<Double>[]()[]) method failing to read the digital I/O as expected.

Examples

This example illustrates how to read inputs immediately. It reads analog channels 0-1, encoder input channels 0-1 and digital input channels 0-3. Exceptions are ignored for simplicity.
C# Copy Code
int []    analogChannels  = { 0, 1 };
int []    encoderChannels = { 0, 1 };
int []    digitalChannels = { 0, 1, 2, 3 };

double [] analogBuffer  = new double [analogChannels.Length];
int []    encoderBuffer = new int    [encoderChannels.Length];
sbyte []  digitalBuffer = new sbyte  [digitalChannels.Length];

card.Read(analogChannels, encoderChannels, digitalChannels, nullptr,
          analogBuffer, encoderBuffer, digitalBuffer, nullptr);
Visual Basic Copy Code
Dim analogChannels() As Integer = {0, 1}
Dim encoderChannels() As Integer = {0, 1}
Dim digitalChannels() As Integer = {0, 1, 2, 3}

Dim analogBuffer(analogChannels.Length - 1) As Double
Dim encoderBuffer(encoderChannels.Length - 1) As Integer
Dim digitalBuffer(digitalChannels.Length - 1) As SByte

card.Read(analogChannels, encoderChannels, digitalChannels, Hil.NoChannels, _
          analogBuffer, encoderBuffer, digitalBuffer, Hil.NoDoubleBuffer)
Visual C++ Copy Code
array<int>^    analogChannels  = { 0, 1 };
array<int>^    encoderChannels = { 0, 1 };
array<int>^    digitalChannels = { 0, 1, 2, 3 };

array<double>^ analogBuffer  = gcnew array<double>(analogChannels->Length);
array<int>^    encoderBuffer = gcnew array<int>(encoderChannels->Length);
array<char>^   digitalBuffer = gcnew array<char>(digitalChannels->Length);

card->Read(analogChannels, encoderChannels, digitalChannels, nullptr,
          analogBuffer, encoderBuffer, digitalBuffer, nullptr);

Exceptions

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

See Also