File Information
Library: IoT/OPC
Package: BasicClient
Header: IoT/OPC/BasicClient.h
Description
This class provides a basic OPC client implementation.
Inheritance
Direct Base Classes: Poco::RefCountedObject
All Base Classes: Poco::RefCountedObject
Member Summary
Member Functions: call, connect, connected, createClient, disconnect, forEach, initLogger, readAccessLevel, readArrayDimensions, readBrowseName, readDataType, readDescription, readDisplayName, readEventNotifier, readExecutable, readHistorizing, readInverseName, readIsAbstract, readMinimumSamplingInterval, readNoLoops, readNodeClass, readNodeId, readSymmetric, readUserAccessLevel, readUserExecutable, readUserWriteMask, readValue, readValueRank, readWriteMask, resolveName, resolvePath, serverURI, state, writeAccessLevel, writeArrayDimensions, writeBrowseName, writeDataType, writeDescription, writeDisplayName, writeEventNotifier, writeExecutable, writeHistorizing, writeInverseName, writeIsAbstract, writeMinimumSamplingInterval, writeNoLoops, writeNodeClass, writeNodeId, writeSymmetric, writeUserAccessLevel, writeUserExecutable, writeUserWriteMask, writeValue, writeValueRank, writeWriteMask
Inherited Functions: duplicate, referenceCount, release
Nested Classes
struct Config
Types
ForEachCallback
typedef std::function < void (const NodeId &, bool, const NodeId &)> ForEachCallback;
Callback for forEach.
Ptr
typedef Poco::AutoPtr < BasicClient > Ptr;
Constructors
BasicClient
BasicClient(
const std::string & serverURI
);
Creates an unconnected BasicClient with the given URI and default configuration.
BasicClient
BasicClient(
const Config & config
);
Creates an unconnected BasicClient with the given configuration.
Destructor
~BasicClient
~BasicClient();
Disconnects and destroys the BasicClient.
Member Functions
call
std::vector < Variant > call(
const NodeId & objectId,
const NodeId & methodId,
const std::vector < Variant > & args
);
Calls the method specified by methodId on the object specified by objectId, using the given arguments.
Throws an OPCException if the method cannot be called.
connect
void connect();
Connects to the server.
connected
bool connected() const;
Returns true if the client is connected to the server.
disconnect
void disconnect();
Disconnects from the server.
forEach
void forEach(
const NodeId & parentNodeId,
const ForEachCallback & callback
);
Invokes the given callback function for each child node of the node with the given parentNodeId.
The function must have the following signature:
void callback(const NodeId& childId, bool isInverse, const NodeId& referenceTypeId);
readAccessLevel
Poco::UInt8 readAccessLevel(
const NodeId & nodeId
);
Reads and returns the Access Level attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readArrayDimensions
std::vector < Poco::UInt32 > readArrayDimensions(
const NodeId & nodeId
);
Reads and returns the Array Dimensions attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readBrowseName
QualifiedName readBrowseName(
const NodeId & nodeId
);
Reads and returns the Browse Name attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readDataType
NodeId readDataType(
const NodeId & nodeId
);
Reads and returns the Data Type attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readDescription
LocalizedText readDescription(
const NodeId & nodeId
);
Reads and returns the Description attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readDisplayName
LocalizedText readDisplayName(
const NodeId & nodeId
);
Reads and returns the Display Name attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readEventNotifier
Poco::UInt8 readEventNotifier(
const NodeId & nodeId
);
Reads and returns the Event Notifier attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readExecutable
bool readExecutable(
const NodeId & nodeId
);
Reads and returns the Executable attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readHistorizing
bool readHistorizing(
const NodeId & nodeId
);
Reads and returns the Historizing attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readInverseName
LocalizedText readInverseName(
const NodeId & nodeId
);
Reads and returns the Inverse Name attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readIsAbstract
bool readIsAbstract(
const NodeId & nodeId
);
Reads and returns the Is Abstract attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readMinimumSamplingInterval
double readMinimumSamplingInterval(
const NodeId & nodeId
);
Reads and returns the Minimum Sampling Interval attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readNoLoops
bool readNoLoops(
const NodeId & nodeId
);
Reads and returns the No Loops attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readNodeClass
NodeClass readNodeClass(
const NodeId & nodeId
);
Reads and returns the Node Class attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readNodeId
NodeId readNodeId(
const NodeId & nodeId
);
Reads the Node ID attribute of the node identified by nodeId and converts it to stringified NodeId representation.
Throws an OPCException if the attribute cannot be read.
readSymmetric
bool readSymmetric(
const NodeId & nodeId
);
Reads and returns the Symmetric attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readUserAccessLevel
Poco::UInt8 readUserAccessLevel(
const NodeId & nodeId
);
Reads and returns the User Access Level attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readUserExecutable
bool readUserExecutable(
const NodeId & nodeId
);
Reads and returns the User Executable attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readUserWriteMask
Poco::UInt32 readUserWriteMask(
const NodeId & nodeId
);
Reads and returns the User Write Mask attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readValue
Variant readValue(
const NodeId & nodeId
);
Reads and returns the Value attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readValueRank
Poco::Int32 readValueRank(
const NodeId & nodeId
);
Reads and returns the Value Rank attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
readWriteMask
Poco::UInt32 readWriteMask(
const NodeId & nodeId
);
Reads and returns the Write Mask attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be read.
resolvePath
NodeId resolvePath(
const std::string & path,
const NodeId & root = NodeId ()
);
Resolves a path consisting of slash-separated browse names to the NodeId of the resulting node, starting from the given root nodeId. The root NodeId can be null. In this case, the path must start with a slash, which references the root node.
Example: Resolving the path "/" with a null root returns the NodeId of the Root Folder (ns=0;i=84). Resolving the path "/Objects/Server" returns the NodeId of the Server object (ns=0;i=2253).
If the path cannot be resolved, throws a PathNotFoundException.
Note that resolving a path is an expensive operation, requiring multiple calls to the OPC-UA server. Paths should be resolved only once per session, and the returned NodeId should be used for subsequent operations.
serverURI
const std::string & serverURI() const;
Returns the server URI.
state
ClientState state() const;
Returns the client state.
writeAccessLevel
void writeAccessLevel(
const NodeId & nodeId,
Poco::UInt8 accessLevel
);
Writes the Access Level attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeArrayDimensions
void writeArrayDimensions(
const NodeId & nodeId,
const std::vector < Poco::UInt32 > & arrayDimensions
);
Writes the Array Dimensions attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeBrowseName
void writeBrowseName(
const NodeId & nodeId,
const QualifiedName & qualifiedName
);
Writes the Browse Name attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeDataType
void writeDataType(
const NodeId & nodeId,
const NodeId & dataTypeId
);
Writes Data Type attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeDescription
void writeDescription(
const NodeId & nodeId,
const LocalizedText & description
);
Writes the Description attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeDisplayName
void writeDisplayName(
const NodeId & nodeId,
const LocalizedText & displayName
);
Writes the Display Name attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeEventNotifier
void writeEventNotifier(
const NodeId & nodeId,
Poco::UInt8 eventNotifier
);
Writes the Event Notifier attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeExecutable
void writeExecutable(
const NodeId & nodeId,
bool executable
);
Writes the Executable attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeHistorizing
void writeHistorizing(
const NodeId & nodeId,
bool historizing
);
Writes the Historizing attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeInverseName
void writeInverseName(
const NodeId & nodeId,
const LocalizedText & inverseName
);
Writes the Inverse Name attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeIsAbstract
void writeIsAbstract(
const NodeId & nodeId,
bool isAbstract
);
Writes the Is Abstract attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeMinimumSamplingInterval
void writeMinimumSamplingInterval(
const NodeId & nodeId,
double minimumSamplingInterval
);
Writes the Minimum Sampling Interval attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeNoLoops
void writeNoLoops(
const NodeId & nodeId,
bool noLoops
);
Writes the No Loops attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeNodeClass
void writeNodeClass(
const NodeId & nodeId,
const NodeClass & nodeClass
);
Writes the Node Class attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeNodeId
void writeNodeId(
const NodeId & nodeId,
const NodeId & newNodeId
);
Writes the Node ID attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeSymmetric
void writeSymmetric(
const NodeId & nodeId,
bool symmetric
);
Writes the Symmetric attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeUserAccessLevel
void writeUserAccessLevel(
const NodeId & nodeId,
Poco::UInt8 userAccessLevel
);
Writes the User Access Level attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeUserExecutable
void writeUserExecutable(
const NodeId & nodeId,
bool userExecutable
);
Writes the User Executable attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeUserWriteMask
void writeUserWriteMask(
const NodeId & nodeId,
Poco::UInt32 userWriteMask
);
Writes the User Write Mask attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeValue
void writeValue(
const NodeId & nodeId,
const Variant & value
);
Writes the Value attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeValueRank
void writeValueRank(
const NodeId & nodeId,
Poco::Int32 valueRank
);
Writes the Value Rank attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
writeWriteMask
void writeWriteMask(
const NodeId & nodeId,
Poco::UInt32 writeMask
);
Writes the Write Mask attribute of the node identified by nodeId.
Throws an OPCException if the attribute cannot be written.
createClient
static UA_Client * createClient(
const Config & config
);
initLogger
void initLogger();
resolveName
NodeId resolveName(
const NodeId & base,
const std::string & browseName
);
resolvePath
NodeId resolvePath(
const NodeId & base,
std::string::const_iterator begin,
std::string::const_iterator end
);