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