IoT::Modbus

class ModbusMasterServerHelper

File Information

Library: IoT/Modbus
Package: Generated
Header: IoT/Modbus/ModbusMasterServerHelper.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.

Member Summary

Member Functions: createRemoteObject, enableEvents, registerObject, registerRemoteObject, shutdown, unregisterObject

Types Aliases

Service

using Service = IoT::Modbus::ModbusMaster;

Constructors

ModbusMasterServerHelper

ModbusMasterServerHelper();

Destructor

~ModbusMasterServerHelper

~ModbusMasterServerHelper();

Destroys the ModbusMasterServerHelper.

Member Functions

createRemoteObject static inline

static Poco::AutoPtr < IoT::Modbus::ModbusMasterRemoteObject > createRemoteObject(
    Poco::SharedPtr < IoT::Modbus::ModbusMaster > pServiceObject,
    const Poco::RemotingNG::Identifiable::ObjectId & oid
);

Creates and returns a RemoteObject wrapper for the given IoT::Modbus::ModbusMaster instance.

enableEvents static inline

static void enableEvents(
    const std::string & uri,
    const std::string & protocol
);

Enables remote events for the RemoteObject identified by the given URI.

Events will be delivered using the Transport for the given protocol. Can be called multiple times for the same URI with different protocols.

registerObject static inline

static std::string registerObject(
    Poco::SharedPtr < IoT::Modbus::ModbusMaster > pServiceObject,
    const Poco::RemotingNG::Identifiable::ObjectId & oid,
    const std::string & listenerId
);

Creates a RemoteObject wrapper for the given IoT::Modbus::ModbusMaster instance and registers it with the ORB and the Listener instance uniquely identified by the Listener's ID.

Returns the URI created for the object.

registerRemoteObject static inline

static std::string registerRemoteObject(
    Poco::AutoPtr < IoT::Modbus::ModbusMasterRemoteObject > pRemoteObject,
    const std::string & listenerId
);

Registers the given RemoteObject with the ORB and the Listener instance uniquely identified by the Listener's ID.

Returns the URI created for the object.

shutdown static

static void shutdown();

Removes the Skeleton for IoT::Modbus::ModbusMaster from the ORB.

unregisterObject static inline

static void unregisterObject(
    const std::string & uri
);

Unregisters a service object identified by URI from the ORB.

Securely control IoT edge devices from anywhere   Connect a Device