MbusDataTableInterfacereadHoldingRegistersTable Method |
Override this method to implement a Data Provider
function to read Holding Registers.
Namespace:
FieldTalk.Modbus.Slave
Assembly:
FieldTalk.Modbus.Slave (in FieldTalk.Modbus.Slave.dll) Version: 2.11.0-eval+eb1ecbe71c969eff5d7c05d58da16dade0474678
Syntaxprotected virtual bool readHoldingRegistersTable(
int startRef,
short[] regArr
)
Protected Overridable Function readHoldingRegistersTable (
startRef As Integer,
<OutAttribute> regArr As Short()
) As Boolean
protected:
virtual bool readHoldingRegistersTable(
int startRef,
[InAttribute] [OutAttribute] array<short>^ regArr
)
Parameters
- startRef
- Type: SystemInt32
Start register (Range: 1 - 65536) - regArr
- Type: SystemInt16
Buffer which has to be filled with the reply data (Length: 0 - 125)
Return Value
Type:
Boolean true indicates a successful access and that valid
reply data is contained in regArr. The Server Engine will
reply the data passed in regArr 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 poll request for the 4:00000 data
table it calls this method to retrieve the data.
Required:
Yes
Default Implementation:
Returns false which indicates to Server Engine that this address range is
unsupported.
Examples A simple implementation which holds the application data in an array
of Int16 called localRegisters could be:
protected override int readHoldingRegistersTable(Int32 startRef, Int16[] regArr)
{
startRef--;
if (startRef + regArr.Length > localRegisters.Length)
return false;
for (int i = 0; i < regArr.Length; i++)
regArr[i] = localRegisters[startRef + i];
return true;
}Protected Overrides Function readHoldingRegistersTable(ByVal startRef As Int32, ByVal regArr() As Int16) As Integer
Dim i As Integer
startRef = startRef - 1
If startRef + regArr.Length > localRegisters.Length Then
Return False
End If
For i = 0 To regArr.Length - 1
regArr(i) = localRegisters(startRef + i)
Next
Return True
End FunctionNo code example is currently available or this language may not be supported.
See Also