MbusDataTableInterfacereadCoilsTable Method |
Namespace: FieldTalk.Modbus.Slave
protected virtual bool readCoilsTable( int startRef, bool[] bitArr )
Protected Overridable Function readCoilsTable ( startRef As Integer, <OutAttribute> bitArr As Boolean() ) As Boolean
protected: virtual bool readCoilsTable( int startRef, [InAttribute] [OutAttribute] array<bool>^ bitArr )
false indicates that access has been denied or is out of range. The Server Engine will reply to the master with an exception reply message
Required: No
Default Implementation: Returns false which indicates to Server Engine that this address range is unsupported.
protected override int readCoilsTable(Int32 startRef, bool[] bitArr) { // Adjust Modbus reference counting from 1-based to 0-based startRef--; // Validate range if (startRef + bitArr.Length > localCoils.Length) return false; // Copy registers from local data array to Modbus for (int i = 0; i < bitArr.Length; i++) bitArr[i] = localCoils[startRef + i]; return true; }
Protected Overrides Function readCoilsTable(ByVal startRef As Int32, ByVal bitArr() As Boolean) As Integer ' Adjust Modbus reference counting from 1-based to 0-based startRef -= 1 ' Validate range If startRef + bitArr.Length > localCoils.Length Then Return False End If ' Copy registers from local data array to Modbus For i As Integer = 0 To bitArr.Length - 1 bitArr(i) = localCoils(startRef + i) Next i Return True End Function
No code example is currently available or this language may not be supported.