IDigitalIoDevice
Interface for digital I/O device drivers. Provides methods for reading and writing digital bit values.
Namespace: DeviceBase
Inheritance
This interface extends IDevice.
Methods
GetDigitalInputBit
Reads the current state of a digital input channel.
bool GetDigitalInputBit(int channel);
Parameters:
channel— The channel number.
Returns: true if the input is high, false if low.
SetDigitalOutputBit
Sets the state of a digital output channel.
void SetDigitalOutputBit(int channel, bool value);
Parameters:
channel— The channel number.value—trueto set high,falseto set low.
GetDigitalOutputBit
Gets the current state of a digital output channel.
bool GetDigitalOutputBit(int channel);
Parameters:
channel— The channel number.
Returns: true if the output is high, false if low.
Usage Example
IDigitalIoDevice digitalDevice = ...;
// Initialize device
digitalDevice.Init(config);
// Read digital input
bool sensorState = digitalDevice.GetDigitalInputBit(0);
// Set digital output
digitalDevice.SetDigitalOutputBit(1, true);
// Read back output state
bool outputState = digitalDevice.GetDigitalOutputBit(1);
// Dispose when done
digitalDevice.Dispose();
Remarks
- Digital I/O operates with boolean values representing on/off or high/low states.
- Input channels are typically read-only from sensors or switches.
- Output channels can be set and read back for verification.