FieldTalk Modbus® Slave Library
C++ Editions
FOCUS Software Engineering

Main Page | Modules | Class Hierarchy | Class List | Class Members | Related Pages

MbusDataTableInterface Class Reference
[Data Provider]

List of all members.

Detailed Description

This class defines the interface between a Modbus slave Server Engine and your application. Descendants of this class are referred to as Data Providers.

To create an application specific Data Provider derive a new class from MbusDataTableInterface and override the required data access methods.

See also:
MbusSlaveServer

Server Functions common to all Protocol Flavours


Data Access Methods for Table 4:00000 (Holding Registers)

Data Access Methods to support read and write of output registers (holding registers) in table 4:00000.

This table is accessed by the following Modbus functions:

  • Modbus function 16 (10 hex), Preset Multiple Registers/Write Multiple Registers
  • Modbus function 3 (03 hex), Read Holding Registers/Read Multiple Registers
  • Modbus function 6 (06 hex), Preset Single Register/Write Single Register.
  • Modbus function 22 (16 hex), Mask Write Register.
  • Modbus function 23 (17 hex), Read/Write Registers.


virtual int readHoldingRegistersTable (int startRef, short regArr[], int refCnt)
 Override this method to implement a Data Provider function to read Holding Registers.
virtual int writeHoldingRegistersTable (int startRef, const short regArr[], int refCnt)
 Override this method to implement a Data Provider function to write Holding Registers.

Data Access Methods for Table 3:00000 (Input Registers)

Data Access Methods to support read of input registers in table 3:00000.

This table is accessed by the following Modbus functions:

  • Modbus function 4 (04 hex), Read Input Registers.

Note:
Input registers cannot be written


virtual int readInputRegistersTable (int startRef, short regArr[], int refCnt)
 Override this method to implement a Data Provider function to read Input Registers.

Data Access Methods for Table 0:00000 (Coils)

Data Access Methods to support read and write of discrete outputs (coils) in table 0:00000.

This table is accessed by the following Modbus functions:

  • Modbus function 1 (01 hex), Read Coil Status/Read Coils.
  • Modbus function 5 (05 hex), Force Single Coil/Write Coil.
  • Modbus function 15 (0F hex), Force Multiple Coils.


virtual int readCoilsTable (int startRef, char bitArr[], int refCnt)
 Override this method to implement a Data Provider function to read Coils.
virtual int writeCoilsTable (int startRef, const char bitArr[], int refCnt)
 Override this method to implement a Data Provider function to write Coils.

Data Access Methods for Table 1:00000 (Input Discretes)

Data Access Methods to support read discrete inputs (input status) in table 1:00000.

This table is accessed by the following Modbus functions:

  • Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes.

Note:
Input Discretes cannot be written


virtual int readInputDiscretesTable (int startRef, char bitArr[], int refCnt)
 Override this method to implement a Data Provider function to read Coils.

Data Access Synchronisation Functions

Implementation of these functions may only be required in multithreaded applications, if you are running the server loop in a separate thread and in addition require data consistency over a block of Modbus registers.

Data consistency within a single register is always maintained if the code executes on a 16-bit or 32-bit machine, because the CPU is accessing these data types atomically.

virtual void lock ()
 You can override this method to implement a semaphore locking mechanism to synchronise data access.
virtual void unlock ()
 You can override this method to implement a semaphore un-locking mechanism to synchronise data access.

Auxiliary Functions

virtual void timeOutHandler ()
 Override this method to implement a function to handle master poll time-outs.
virtual char readExceptionStatus ()
 Override this method to implement a function with reports the eight exception status coils (bits) within the slave device.