File Information
Library: IoT/Modbus/Device
Package: Device
Header: IoT/Modbus/Device/ModbusDeviceHandler.h
Description
This class defines the interface for Modbus devices.
The interface is used for both RTU and TCP connections.
For every defined function code there is a corresponding handler method. In case of an unknown function code, a generic otherFunction() method is provided.
The response object is pre-initialized with the correct function code, device address and transaction ID, so the handler method only needs to fill in the message-specific information.
A handler method can return an exception message by throwing a ModbusException with an appropriate function and exception code.
Inheritance
Known Derived Classes: AbstractModbusDeviceHandler
Member Summary
Member Functions: idle, maskWriteRegister, otherFunction, readCoils, readDiscreteInputs, readExceptionStatus, readFIFOQueue, readHoldingRegisters, readInputRegisters, readWriteMultipleRegisters, writeMultipleCoils, writeMultipleRegisters, writeSingleCoil, writeSingleRegister
Constructors
ModbusDeviceHandler
Creates a ModbusDeviceHandler.
Destructor
~ModbusDeviceHandler
virtual ~ModbusDeviceHandler();
Destroys the ModbusDeviceHandler.
Member Functions
idle
virtual bool idle(
Poco::Timespan idleTime
) = 0;
Called repeatedly when no other request is there to handle.
If the method returns false, the Modbus connection will be closed.
maskWriteRegister
virtual void maskWriteRegister(
const MaskWriteRegisterRequest & request,
MaskWriteRegisterResponse & response
) = 0;
Handles a Mask Write Register request.
otherFunction
virtual void otherFunction(
const GenericMessage & request,
GenericMessage & response
) = 0;
Handles any function code not covered by the other handler methods.
readCoils
virtual void readCoils(
const ReadCoilsRequest & request,
ReadCoilsResponse & response
) = 0;
Handles a Read Coils request.
readDiscreteInputs
virtual void readDiscreteInputs(
const ReadDiscreteInputsRequest & request,
ReadDiscreteInputsResponse & response
) = 0;
Handles a Read Discrete Inputs request.
readExceptionStatus
virtual void readExceptionStatus(
const ReadExceptionStatusRequest & request,
ReadExceptionStatusResponse & response
) = 0;
Handles a Read Exception Status request.
readFIFOQueue
virtual void readFIFOQueue(
const ReadFIFOQueueRequest & request,
ReadFIFOQueueResponse & response
) = 0;
Handles a Read FIFO Queue request.
readHoldingRegisters
virtual void readHoldingRegisters(
const ReadHoldingRegistersRequest & request,
ReadHoldingRegistersResponse & response
) = 0;
Handles a Read Holding Registers request.
readInputRegisters
virtual void readInputRegisters(
const ReadInputRegistersRequest & request,
ReadInputRegistersResponse & response
) = 0;
Handles a Read Input Registers request.
readWriteMultipleRegisters
virtual void readWriteMultipleRegisters(
const ReadWriteMultipleRegistersRequest & request,
ReadWriteMultipleRegistersResponse & response
) = 0;
Handles a Read Write Multiple Registers request.
writeMultipleCoils
virtual void writeMultipleCoils(
const WriteMultipleCoilsRequest & request,
WriteMultipleCoilsResponse & response
) = 0;
Handles a Write Multiple Coils request.
writeMultipleRegisters
virtual void writeMultipleRegisters(
const WriteMultipleRegistersRequest & request,
WriteMultipleRegistersResponse & response
) = 0;
Handles a Write Multiple Registers request.
writeSingleCoil
virtual void writeSingleCoil(
const WriteSingleCoilRequest & request,
WriteSingleCoilResponse & response
) = 0;
Handles a Write Single Coil request.
writeSingleRegister
virtual void writeSingleRegister(
const WriteSingleRegisterRequest & request,
WriteSingleRegisterResponse & response
) = 0;
Handles a Write Single Register request.