Reads from digital inputs and writes to digital outputs immediately.

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

Syntax

Visual Basic (Declaration)
Public Sub ReadDigitalWriteDigital ( _
	inputChannels As Integer(), _
	outputChannels As Integer(), _
	inputBits As SByte(), _
	outputBits As SByte() _
)
C#
public void ReadDigitalWriteDigital(
	int[] inputChannels,
	int[] outputChannels,
	sbyte[] inputBits,
	sbyte[] outputBits
)
Visual C++
public:
void ReadDigitalWriteDigital(
	array<int>^ inputChannels, 
	array<int>^ outputChannels, 
	array<signed char>^ inputBits, 
	array<signed char>^ outputBits
)
JavaScript
function readDigitalWriteDigital(inputChannels, outputChannels, inputBits, outputBits);

Parameters

inputChannels
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.

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

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

An array containing the numbers of the digital output channels to be written. 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: .

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

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

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

An array containing the binary values to write to the digital outputs. Each element in the outputBits array corresponds to the same element in the outputChannels array. Hence, there must be as many elements in the outputBits array as there are channels.

Remarks

The ReadDigitalWriteDigital method reads from the specified digital input channels and writes to the specified digital output channels immediately, in a single method call. 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 the data has been read and written.

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 ReadDigitalWriteDigital(array<Int32>[]()[], array<Int32>[]()[], array<SByte>[]()[], array<SByte>[]()[]) method failing to read or write the digital I/O as expected.

Examples

This example illustrates how to read digital inputs and write digital outputs immediately, in a single operation. It reads digital input channels 0-3 and writes 1 and 0 to digital output channels 5 and 7 respectively. Exceptions are ignored for simplicity.
C# Copy Code
int []    inputChannels  = { 0, 1, 2, 3 };
int []    outputChannels = { 5, 7 };

sbyte [] inputBuffer    = new sbyte [inputChannels.Length];
sbyte [] outputBuffer   = { 1, 0 };

card.ReadDigitalWriteDigital(inputChannels, outputChannels, inputBuffer, outputBuffer);
Visual Basic Copy Code
Dim inputChannels() As Integer = {0, 1, 2, 3}
Dim outputChannels() As Integer = {5, 7}

Dim inputBuffer(inputChannels.Length - 1) As SByte
Dim outputBuffer() As SByte = {1, 0}

card.ReadDigitalWriteDigital(inputChannels, outputChannels, inputBuffer, outputBuffer)
Visual C++ Copy Code
array<int>^    inputChannels  = { 0, 1, 2, 3 };
array<int>^    outputChannels = { 5, 7 };

array<char>^ inputBuffer    = gcnew array<char>(inputChannels->Length);
array<char>^ outputBuffer   = { 1, 0 };

card->ReadDigitalWriteDigital(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 this method.

See Also