Documentation

Data Provider

A Data Provider acts as an agent between your Application and the Server Engine.

Modbus Slave classes collaboration diagram

After instantiating a Server Engine class of any protocol flavour, you have to associate it with a Data Provider by calling addDataTable and passing a reference of the Data Provider object.

MbusRtuSlaveProtocol mbusServer = new MbusRtuSlaveProtocol();
MyDatatable dataTable = new MyDatatable();
mbusServer.addDataTable(1, dataTable);

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

A minimal Data Provider which realises a Modbus slave with read access to holding registers would be:

class MyDatatable: MbusDataTableInterface
{
    // Override readHoldingRegistersTable method:
    protected override bool readHoldingRegistersTable(Int32 startRef, Int16[] regArr)
    {
        ... your application specific implementation
    }
}