MbusDataTableInterfacewriteCoilsTable Method |
Override this method to implement a Data Provider
function to write Coils.
Namespace:
FieldTalk.Modbus.Slave
Assembly:
FieldTalk.Modbus.Slave (in FieldTalk.Modbus.Slave.dll) Version: 2.11.0-eval+eb1ecbe71c969eff5d7c05d58da16dade0474678
Syntaxprotected 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
)
Parameters
- startRef
- Type: SystemInt32
Start register (Range: 1 - 65536) - bitArr
- Type: SystemBoolean
Buffer which contains the received data
(Length: 0 - 2000). Each char repesents one coil!
Return Value
Type:
Boolean true indicates a successful access. The Server Engine will send a
positive reply to the master.
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
Remarks
When a slave receives a write request for the 0:00000 data table it
calls this method to pass the data to the application.
Required:
No
Default Implementation:
Returns false which indicates to Server Engine that this address range is
unsupported.
Examples
A simple implementation which holds the boolean application data in
an array of bool call bitData could be:
protected override int writeCoilsTable(Int32 startRef, bool[] bitArr)
{
startRef--;
if (startRef + bitArr.Length > localCoils.Length)
return false;
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
startRef -= 1
If startRef + bitArr.Length > localCoils.Length Then
Return False
End If
For i As Integer = 0 To bitArr.Length - 1
localCoils(startRef + i) = bitArr(i)
Next i
Return True
End FunctionNo code example is currently available or this language may not be supported.
See Also