Library: IoT/Modbus
Package: Generated
Header: IoT/Modbus/ModbusMasterRemoteObject.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 sent over the wire. The device's response is reported asynchronously via an appropriate XXXResponseReceived 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: IModbusMaster, Poco::RemotingNG::RemoteObject
All Base Classes: IModbusMaster, Poco::OSP::Service, Poco::RefCountedObject, Poco::RemotingNG::Identifiable, Poco::RemotingNG::RemoteObject
Member Summary
Member Functions: event__badFrameReceived, event__exceptionReceived, event__maskWriteRegisterResponseReceived, event__readCoilsResponseReceived, event__readDiscreteInputsResponseReceived, event__readExceptionStatusResponseReceived, event__readFIFOQueueResponseReceived, event__readHoldingRegistersResponseReceived, event__readInputRegistersResponseReceived, event__readWriteMultipleRegistersResponseReceived, event__responseReceived, event__timeout, event__writeMultipleCoilsResponseReceived, event__writeMultipleRegistersResponseReceived, event__writeSingleCoilResponseReceived, event__writeSingleRegisterResponseReceived, maskWriteRegister, readCoils, readDiscreteInputs, readExceptionStatus, readFIFOQueue, readHoldingRegisters, readInputRegisters, readWriteMultipleRegisters, remoting__enableEvents, remoting__enableRemoteEvents, remoting__hasEvents, remoting__typeId, reset, sendMaskWriteRegisterRequest, sendReadCoilsRequest, sendReadDiscreteInputsRequest, sendReadExceptionStatusRequest, sendReadFIFOQueueRequest, sendReadHoldingRegistersRequest, sendReadInputRegistersRequest, sendReadWriteMultipleRegistersRequest, sendRequest, sendWriteMultipleCoilsRequest, sendWriteMultipleRegistersRequest, sendWriteSingleCoilRequest, sendWriteSingleRegisterRequest, writeMultipleCoils, writeMultipleRegisters, writeSingleCoil, writeSingleRegister
Inherited Functions: duplicate, isA, maskWriteRegister, mutex, readCoils, readDiscreteInputs, readExceptionStatus, readFIFOQueue, readHoldingRegisters, readInputRegisters, readWriteMultipleRegisters, referenceCount, release, remoting__enableEvents, remoting__enableRemoteEvents, remoting__getURI, remoting__hasEvents, remoting__objectId, remoting__setURI, remoting__typeId, reset, sendMaskWriteRegisterRequest, sendReadCoilsRequest, sendReadDiscreteInputsRequest, sendReadExceptionStatusRequest, sendReadFIFOQueueRequest, sendReadHoldingRegistersRequest, sendReadInputRegistersRequest, sendReadWriteMultipleRegistersRequest, sendRequest, sendWriteMultipleCoilsRequest, sendWriteMultipleRegistersRequest, sendWriteSingleCoilRequest, sendWriteSingleRegisterRequest, type, writeMultipleCoils, writeMultipleRegisters, writeSingleCoil, writeSingleRegister
Types Aliases
Ptr
using Ptr = Poco::AutoPtr < ModbusMasterRemoteObject >;
Constructors
ModbusMasterRemoteObject
ModbusMasterRemoteObject(
const Poco::RemotingNG::Identifiable::ObjectId & oid,
Poco::SharedPtr < IoT::Modbus::ModbusMaster > pServiceObject
);
Creates a ModbusMasterRemoteObject.
Destructor
~ModbusMasterRemoteObject
virtual ~ModbusMasterRemoteObject();
Destroys the ModbusMasterRemoteObject.
Member Functions
maskWriteRegister
virtual void maskWriteRegister(
Poco::UInt8 slaveAddress,
Poco::UInt16 outputAddress,
Poco::UInt16 andMask,
Poco::UInt16 orMask
);
Sends a Mask Write register request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
readCoils
virtual std::vector < bool > readCoils(
Poco::UInt8 slaveAddress,
Poco::UInt16 startingAddress,
Poco::UInt16 nOfCoils
);
Sends a Read Coils request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
See also: IoT::Modbus::IModbusMaster::readCoils()
readDiscreteInputs
virtual std::vector < bool > readDiscreteInputs(
Poco::UInt8 slaveAddress,
Poco::UInt16 startingAddress,
Poco::UInt16 nOfInputs
);
Sends a Read Discrete Inputs request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
readExceptionStatus
virtual Poco::UInt8 readExceptionStatus(
Poco::UInt8 slaveAddress
);
Sends a Read Exception Status request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
readFIFOQueue
virtual std::vector < Poco::UInt16 > readFIFOQueue(
Poco::UInt8 slaveAddress,
Poco::UInt16 fifoPointerAddress
);
Sends a Read FIFO Queue request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
readHoldingRegisters
virtual std::vector < Poco::UInt16 > readHoldingRegisters(
Poco::UInt8 slaveAddress,
Poco::UInt16 startingAddress,
Poco::UInt16 nOfRegisters
);
Sends a Read Holding Registers request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
readInputRegisters
virtual std::vector < Poco::UInt16 > readInputRegisters(
Poco::UInt8 slaveAddress,
Poco::UInt16 startingAddress,
Poco::UInt16 nOfRegisters
);
Sends a Read Input Registers request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
readWriteMultipleRegisters
virtual std::vector < Poco::UInt16 > readWriteMultipleRegisters(
Poco::UInt8 slaveAddress,
Poco::UInt16 writeStartingAddress,
std::vector < Poco::UInt16 > writeValues,
Poco::UInt16 readStartingAddress,
Poco::UInt8 nOfReadRegisters
);
Sends a Read/Write Multiple registers request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
remoting__enableEvents
virtual std::string remoting__enableEvents(
Poco::RemotingNG::Listener::Ptr pListener,
bool enable = bool (true)
);
remoting__enableRemoteEvents
virtual void remoting__enableRemoteEvents(
const std::string & protocol
);
remoting__hasEvents
virtual bool remoting__hasEvents() const;
remoting__typeId
virtual const Poco::RemotingNG::Identifiable::TypeId & remoting__typeId() const;
reset
virtual void reset();
Resets the connection to the bus or device.
See also: IoT::Modbus::IModbusMaster::reset()
sendMaskWriteRegisterRequest
virtual Poco::UInt16 sendMaskWriteRegisterRequest(
const IoT::Modbus::MaskWriteRegisterRequest & request
);
Sends a Mask Write Register request.
A response from the device will be reported via the maskWriteRegisterResponseReceived event.
Returns the transaction ID for the request.
sendReadCoilsRequest
virtual Poco::UInt16 sendReadCoilsRequest(
const IoT::Modbus::ReadCoilsRequest & request
);
Sends a Read Coils request.
A response from the device will be reported via the readCoilsResponseReceived event.
Returns the transaction ID for the request.
sendReadDiscreteInputsRequest
virtual Poco::UInt16 sendReadDiscreteInputsRequest(
const IoT::Modbus::ReadDiscreteInputsRequest & request
);
Sends a Read Discrete Inputs request.
A response from the device will be reported via the readDiscreteInputsResponseReceived event.
Returns the transaction ID for the request.
sendReadExceptionStatusRequest
virtual Poco::UInt16 sendReadExceptionStatusRequest(
const IoT::Modbus::ReadExceptionStatusRequest & request
);
Sends a Read Exception Status request.
A response from the device will be reported via the readExceptionStatusResponseReceived event.
Returns the transaction ID for the request.
sendReadFIFOQueueRequest
virtual Poco::UInt16 sendReadFIFOQueueRequest(
const IoT::Modbus::ReadFIFOQueueRequest & request
);
Sends a Read FIFO Queue request.
A response from the device will be reported via the readFIFOQueueResponseReceived event.
Returns the transaction ID for the request.
sendReadHoldingRegistersRequest
virtual Poco::UInt16 sendReadHoldingRegistersRequest(
const IoT::Modbus::ReadHoldingRegistersRequest & request
);
Sends a Read Holding Registers request.
A response from the device will be reported via the readHoldingRegistersResponseReceived event.
Returns the transaction ID for the request.
sendReadInputRegistersRequest
virtual Poco::UInt16 sendReadInputRegistersRequest(
const IoT::Modbus::ReadInputRegistersRequest & request
);
Sends a Read Input Registers request.
A response from the device will be reported via the readInputRegistersResponseReceived event.
Returns the transaction ID for the request.
sendReadWriteMultipleRegistersRequest
virtual Poco::UInt16 sendReadWriteMultipleRegistersRequest(
const IoT::Modbus::ReadWriteMultipleRegistersRequest & request
);
Sends a Read Write Multiple Registers request.
A response from the device will be reported via the readWriteMultipleRegistersResponseReceived event.
Returns the transaction ID for the request.
sendRequest
virtual Poco::UInt16 sendRequest(
const IoT::Modbus::GenericMessage & message
);
Sends a generic Modbus message.
The caller is responsible for correct formatting of the messages's data field.
This can be used to send Modbus requests not directly supported by the ModbusMaster interface.
A response from the device will be reported via the responseReceived event or a more specific event if the response message type is supported.
Returns the transaction ID for the request.
sendWriteMultipleCoilsRequest
virtual Poco::UInt16 sendWriteMultipleCoilsRequest(
const IoT::Modbus::WriteMultipleCoilsRequest & request
);
Sends a Write Multiple Coils request.
A response from the device will be reported via the writeMultipleCoilsResponseReceived event.
Returns the transaction ID for the request.
sendWriteMultipleRegistersRequest
virtual Poco::UInt16 sendWriteMultipleRegistersRequest(
const IoT::Modbus::WriteMultipleRegistersRequest & request
);
Sends a Write Multiple Registers request.
A response from the device will be reported via the writeMultipleRegistersResponseReceived event.
Returns the transaction ID for the request.
sendWriteSingleCoilRequest
virtual Poco::UInt16 sendWriteSingleCoilRequest(
const IoT::Modbus::WriteSingleCoilRequest & request
);
Sends a Write Single Coil request.
A response from the device will be reported via the writeSingleCoilResponseReceived event.
Returns the transaction ID for the request.
sendWriteSingleRegisterRequest
virtual Poco::UInt16 sendWriteSingleRegisterRequest(
const IoT::Modbus::WriteSingleRegisterRequest & request
);
Sends a Write Single Register request.
A response from the device will be reported via the writeSingleRegisterResponseReceived event.
Returns the transaction ID for the request.
writeMultipleCoils
virtual void writeMultipleCoils(
Poco::UInt8 slaveAddress,
Poco::UInt16 outputAddress,
std::vector < bool > values
);
Sends a Write Multiple Coils request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
writeMultipleRegisters
virtual void writeMultipleRegisters(
Poco::UInt8 slaveAddress,
Poco::UInt16 outputAddress,
std::vector < Poco::UInt16 > values
);
Sends a Write Multiple Registers request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
writeSingleCoil
virtual void writeSingleCoil(
Poco::UInt8 slaveAddress,
Poco::UInt16 outputAddress,
bool value
);
Sends a Write Single Coils request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
writeSingleRegister
virtual void writeSingleRegister(
Poco::UInt8 slaveAddress,
Poco::UInt16 outputAddress,
Poco::UInt16 value
);
Sends a Write Single Register request to the device and waits for the response.
Throws a Poco::TimeoutException if the device does not respond within the specified timeout. Throws a ModbusException if the device responds with an exception message.
event__badFrameReceived
void event__badFrameReceived();
event__exceptionReceived
void event__exceptionReceived(
const IoT::Modbus::ModbusExceptionMessage & data
);
event__maskWriteRegisterResponseReceived
void event__maskWriteRegisterResponseReceived(
const IoT::Modbus::MaskWriteRegisterResponse & data
);
event__readCoilsResponseReceived
void event__readCoilsResponseReceived(
const IoT::Modbus::ReadCoilsResponse & data
);
event__readDiscreteInputsResponseReceived
void event__readDiscreteInputsResponseReceived(
const IoT::Modbus::ReadDiscreteInputsResponse & data
);
event__readExceptionStatusResponseReceived
void event__readExceptionStatusResponseReceived(
const IoT::Modbus::ReadExceptionStatusResponse & data
);
event__readFIFOQueueResponseReceived
void event__readFIFOQueueResponseReceived(
const IoT::Modbus::ReadFIFOQueueResponse & data
);
event__readHoldingRegistersResponseReceived
void event__readHoldingRegistersResponseReceived(
const IoT::Modbus::ReadHoldingRegistersResponse & data
);
event__readInputRegistersResponseReceived
void event__readInputRegistersResponseReceived(
const IoT::Modbus::ReadInputRegistersResponse & data
);
event__readWriteMultipleRegistersResponseReceived
void event__readWriteMultipleRegistersResponseReceived(
const IoT::Modbus::ReadWriteMultipleRegistersResponse & data
);
event__responseReceived
void event__responseReceived(
const IoT::Modbus::GenericMessage & data
);
event__timeout
void event__timeout(
const Poco::UInt16 & data
);
event__writeMultipleCoilsResponseReceived
void event__writeMultipleCoilsResponseReceived(
const IoT::Modbus::WriteMultipleCoilsResponse & data
);
event__writeMultipleRegistersResponseReceived
void event__writeMultipleRegistersResponseReceived(
const IoT::Modbus::WriteMultipleRegistersResponse & data
);
event__writeSingleCoilResponseReceived
void event__writeSingleCoilResponseReceived(
const IoT::Modbus::WriteSingleCoilResponse & data
);
event__writeSingleRegisterResponseReceived
void event__writeSingleRegisterResponseReceived(
const IoT::Modbus::WriteSingleRegisterResponse & data
);