File Information
Library: IoT/Modbus
Package: Generated
Header: IoT/Modbus/ModbusMasterEventDispatcher.h
Description
This class defines the interface for Modbus clients.
The interface supports two basic modes of operation:
- Asynchronous requests: One of the sendXXXRequest() methods is used to send a request to the device. The method returns as soon as the request has been queued to be sent over the wire (actual sending is done in a separate thread). The device's response, is reported asynchronously via an appropriate XXXResponseReceived event. Errors encountered during sending are reported via requestFailed. Modbus exception responses are reported via exceptionReceived. A timeout waiting for the response is reported via the timeout event.
- Synchronous requests: After sending the request, the method waits for the response from the device and directly returns it to the caller. In case no response is received within the specified timeout, a Poco::TimeoutException is thrown. If an exception message is received from the device, a ModbusException is thrown. If an incomplete or invalid message is received, a Poco::ProtocolException is thrown.
Note that asynchronous and synchronous (blocking) mode cannot be used simultaneously. Calling one of the asynchronous request methods will enable asynchronous mode. Calling one of the synchronous request methods will disable asynchronous mode. Switching to synchronous mode while a response to an asynchronous request is pending will lead to undefined results, including possible mismatch of requests and responses.
In asynchronous operation, requests are associated with a transaction ID, to tell apart multiple concurrent transactions. Transaction IDs are not guaranteed to be unique for subsequent requests. In fact, for Modbus RTU, which does not allow multiple simultaneous requests, the transaction ID will always be zero.
Inheritance
Direct Base Classes: Poco::RemotingNG::EventDispatcher
All Base Classes: Poco::RefCountedObject, Poco::RemotingNG::EventDispatcher
Member Summary
Member Functions: event__badFrameReceived, event__connectionStateChanged, event__error, event__exceptionReceived, event__maskWriteRegisterResponseReceived, event__readCoilsResponseReceived, event__readDiscreteInputsResponseReceived, event__readExceptionStatusResponseReceived, event__readFIFOQueueResponseReceived, event__readHoldingRegistersResponseReceived, event__readInputRegistersResponseReceived, event__readWriteMultipleRegistersResponseReceived, event__requestFailed, event__responseReceived, event__timeout, event__writeMultipleCoilsResponseReceived, event__writeMultipleRegistersResponseReceived, event__writeSingleCoilResponseReceived, event__writeSingleRegisterResponseReceived, remoting__typeId
Inherited Functions: accept, attributes, duplicate, protocol, referenceCount, release, removeEventFilter, setEventFilter, setEventFilterImpl, subscribe, transportForSubscriber, unsubscribe
Constructors
ModbusMasterEventDispatcher
ModbusMasterEventDispatcher(
IModbusMaster * pInterface,
const Poco::RemotingNG::Identifiable::ObjectId & objectId,
const std::string & protocol
);
Creates a ModbusMasterEventDispatcher.
Destructor
~ModbusMasterEventDispatcher
virtual ~ModbusMasterEventDispatcher();
Destroys the ModbusMasterEventDispatcher.
Member Functions
event__badFrameReceived
void event__badFrameReceived(
const void * pSender
);
event__connectionStateChanged
void event__connectionStateChanged(
const void * pSender,
const IoT::Modbus::ConnectionState & data
);
event__error
void event__error(
const void * pSender,
const std::string & data
);
event__exceptionReceived
void event__exceptionReceived(
const void * pSender,
const IoT::Modbus::ModbusExceptionMessage & data
);
event__maskWriteRegisterResponseReceived
void event__maskWriteRegisterResponseReceived(
const void * pSender,
const IoT::Modbus::MaskWriteRegisterResponse & data
);
event__readCoilsResponseReceived
void event__readCoilsResponseReceived(
const void * pSender,
const IoT::Modbus::ReadCoilsResponse & data
);
event__readDiscreteInputsResponseReceived
void event__readDiscreteInputsResponseReceived(
const void * pSender,
const IoT::Modbus::ReadDiscreteInputsResponse & data
);
event__readExceptionStatusResponseReceived
void event__readExceptionStatusResponseReceived(
const void * pSender,
const IoT::Modbus::ReadExceptionStatusResponse & data
);
event__readFIFOQueueResponseReceived
void event__readFIFOQueueResponseReceived(
const void * pSender,
const IoT::Modbus::ReadFIFOQueueResponse & data
);
event__readHoldingRegistersResponseReceived
void event__readHoldingRegistersResponseReceived(
const void * pSender,
const IoT::Modbus::ReadHoldingRegistersResponse & data
);
event__readInputRegistersResponseReceived
void event__readInputRegistersResponseReceived(
const void * pSender,
const IoT::Modbus::ReadInputRegistersResponse & data
);
event__readWriteMultipleRegistersResponseReceived
void event__readWriteMultipleRegistersResponseReceived(
const void * pSender,
const IoT::Modbus::ReadWriteMultipleRegistersResponse & data
);
event__requestFailed
void event__requestFailed(
const void * pSender,
const IoT::Modbus::RequestFailure & data
);
event__responseReceived
void event__responseReceived(
const void * pSender,
const IoT::Modbus::GenericMessage & data
);
event__timeout
void event__timeout(
const void * pSender,
const Poco::UInt16 & data
);
event__writeMultipleCoilsResponseReceived
void event__writeMultipleCoilsResponseReceived(
const void * pSender,
const IoT::Modbus::WriteMultipleCoilsResponse & data
);
event__writeMultipleRegistersResponseReceived
void event__writeMultipleRegistersResponseReceived(
const void * pSender,
const IoT::Modbus::WriteMultipleRegistersResponse & data
);
event__writeSingleCoilResponseReceived
void event__writeSingleCoilResponseReceived(
const void * pSender,
const IoT::Modbus::WriteSingleCoilResponse & data
);
event__writeSingleRegisterResponseReceived
void event__writeSingleRegisterResponseReceived(
const void * pSender,
const IoT::Modbus::WriteSingleRegisterResponse & data
);
remoting__typeId
virtual const Poco::RemotingNG::Identifiable::TypeId & remoting__typeId() const;