MbusDataTableInterfacewriteCoilsTable Method |
Namespace: FieldTalk.Modbus.Slave
protected virtual bool writeCoilsTable( int startRef, bool[] bitArr )
Protected Overridable Function writeCoilsTable ( startRef As Integer, bitArr As Boolean() ) As Boolean
protected: virtual bool writeCoilsTable( int startRef, 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 writeCoilsTable(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 Modbus to local data block for (int i = 0; i < bitArr.Length; i++) localCoils[startRef + i] = bitArr[i]; return true; }
Protected Overrides Function writeCoilsTable(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 Modbus to local data block For i As Integer = 0 To bitArr.Length - 1 localCoils(startRef + i) = bitArr(i) Next i Return True End Function
No code example is currently available or this language may not be supported.