MbusDataTableInterfacereadHoldingRegistersTable Method |
Namespace: FieldTalk.Modbus.Slave
protected 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 )
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: Yes
Default Implementation: Returns false which indicates to Server Engine that this address range is unsupported.
protected override int readHoldingRegistersTable(Int32 startRef, Int16[] regArr) { // Adjust Modbus reference counting from 1-based to 0-based startRef--; // Validate range if (startRef + regArr.Length > localRegisters.Length) return false; // Copy registers from local data array to Modbus 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 ' Adjust Modbus reference counting from 1-based to 0-based startRef = startRef - 1 ' Validate range If startRef + regArr.Length > localRegisters.Length Then Return False End If ' Copy registers from local data array to Modbus For i = 0 To regArr.Length - 1 regArr(i) = localRegisters(startRef + i) Next Return True End Function
No code example is currently available or this language may not be supported.