CVB++ 14.0
MethodNode Class Reference

An OPCUA method node object to call remote procedures. More...

#include <cvb/opcua/method_node.hpp>

Inherits BaseNode.

Public Member Functions

EventCookie RegisterCallback (std::function< void()> handler)
 Registers a callback for the method node. More...
 
void UnregisterCallback (EventCookie eventCookie)
 Unregisters a callback for the method node. More...
 
void AddArgument (const Cvb::String &Name, OpcUa::ArgumentType inOutType, const Cvb::String &defaultValue)
 Adds an argument of type 'Cvb::String' to the method node. See class description for details. More...
 
void AddArgument (const Cvb::String &Name, OpcUa::ArgumentType inOutType, double defaultValue)
 Adds an argument of type 'double' to the method node. See class description for details. More...
 
void AddArgument (const Cvb::String &Name, OpcUa::ArgumentType inOutType, std::int64_t defaultValue)
 Adds an argument of type 'std::int64_t' to the method node. See class description for details. More...
 
std::vector< OpcUa::MethodNodeArgumentInputArguments ()
 Returns all registered input arguments. See class description for details. More...
 
std::vector< OpcUa::MethodNodeArgumentOutputArguments ()
 Returns all registered output arguments. See class description for details. More...
 
void Call () const
 Starts execution of the given method node on the server. See class description for details.
 
- Public Member Functions inherited from BaseNode
void * Handle () const noexcept
 Returns C-API style handle to BaseNode Object. More...
 
OpcUa::NodeIDPtr NodeID () const
 Returns the OPCUA NodeID of an OPCUA BaseNode object. More...
 
String BrowseName () const
 Returns the browse name of an OPCUA BaseNode object. More...
 
std::vector< NodeIDPtrBrowse (const BrowseFilter &filter) const
 "Browse" all referenced BaseNodes of this BaseNode. More...
 
String DisplayName () const
 Returns the humanreadable name of a node. More...
 
OpcUa::NodeClass NodeClass () const
 Returns the NodeClass of an OPCUA BaseNode object. More...
 
OpcUa::ConnectionStatus ConnectionStatus () const
 Returns the ConnectionStatus of an OPCUA BaseNode object. More...
 
OpcUa::Access Access () const
 Returns the Access right to an OPCUA BaseNode object. More...
 
String Description () const
 Returns the description OPCUA BaseNode object. More...
 
void AddReference (const OpcUa::BaseNode &destination, const ReferenceType reference, ReferenceDirection direction) const
 Adds a Reference to the OPCUA node. More...
 
std::int64_t GetAttributeAsInt (AttributeID attributeID) const
 Return specific Information about a Opcua::BaseNode. More...
 
void SetAttributeAsInt (AttributeID attributeID, std::int64_t value)
 Set specific Information about a Opcua::BaseNode. More...
 
double GetAttributeAsFloat (AttributeID attributeID) const
 Return specific Information about a Opcua::BaseNode. More...
 
void SetAttributeAsFloat (AttributeID attributeID, double value)
 Set specific Information about a Opcua::BaseNode. More...
 
String GetAttributeAsString (AttributeID attributeID) const
 Return specific Information about a Opcua::BaseNode. More...
 
void SetAttributeAsString (AttributeID attributeID, const String &value)
 Set specific Information about a Opcua::BaseNode. More...
 

Static Public Member Functions

static MethodNodePtr Create (const std::uint16_t namespaceIndex, const Cvb::String &name, const OpcUa::NodeID &parentNodeID)
 Creates an OPCUA method node object. More...
 

Detailed Description

An OPCUA method node object to call remote procedures.

It provides an interface for calling functions/methods on the OPCUA server.

Note
MethodNodes (may) have input and output arguments. The generals step are ...
  1. On the server side: MethodNode is created and added to the server
  2. On the server side: The desired amount of arguments are added via MethodNode::AddArgment (for input and output). This "defines" the argments.
  3. On the server side: A callback is set. This is later called by the client via MethodNode::Call.
  4. On the client side: The client application retrieves the MethodNode and retrieves the argments via MethodNode::InputArguments
  5. On the client side: The client application sets the input arguments to the desired value and then calls MethodNode::Call.
  6. On the server side: The callback is triggered.
    1. The server application (inside the callback) retrieves the input arguments (MethodNode::InputArguments) and does whatever the callback is supposed to do.
    2. The server application (still inside the callback) set the output arguments (MethodNode::OutputArguments).
  7. The client application retrieves the output arguments.
For details also refer to the OPCUA specification Part 5:
https://opcfoundation.org/developer-tools/specifications-unified-architecture/part-5-information-model/

Member Function Documentation

◆ AddArgument() [1/3]

void AddArgument ( const Cvb::String Name,
OpcUa::ArgumentType  inOutType,
const Cvb::String defaultValue 
)
inline

Adds an argument of type 'Cvb::String' to the method node. See class description for details.

Parameters
[in]NameName of the argument.
[in]inOutTypeDefines whether the argument is input or output.
[in]defaultValueInitial value of the argument.
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ AddArgument() [2/3]

void AddArgument ( const Cvb::String Name,
OpcUa::ArgumentType  inOutType,
double  defaultValue 
)
inline

Adds an argument of type 'double' to the method node. See class description for details.

Parameters
[in]NameName of the argument.
[in]inOutTypeDefines whether the argument is input or output.
[in]defaultValueInitial value of the argument.
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ AddArgument() [3/3]

void AddArgument ( const Cvb::String Name,
OpcUa::ArgumentType  inOutType,
std::int64_t  defaultValue 
)
inline

Adds an argument of type 'std::int64_t' to the method node. See class description for details.

Parameters
[in]NameName of the argument.
[in]inOutTypeDefines whether the argument is input or output.
[in]defaultValueInitial value of the argument.
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ Create()

MethodNodePtr Create ( const std::uint16_t  namespaceIndex,
const Cvb::String name,
const OpcUa::NodeID parentNodeID 
)
inlinestatic

Creates an OPCUA method node object.

Parameters
[in]namespaceIndexNamespace index of the node
[in]nameName of the node
[in]parentNodeIDBaseNode id of the parent node (the method node will be registered as a child of this node)
Returns
the method node
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ InputArguments()

std::vector< OpcUa::MethodNodeArgument > InputArguments ( )

Returns all registered input arguments. See class description for details.

Returns
InputArguments
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ OutputArguments()

std::vector< OpcUa::MethodNodeArgument > OutputArguments ( )

Returns all registered output arguments. See class description for details.

Returns
OutputArguments
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ RegisterCallback()

EventCookie RegisterCallback ( std::function< void()>  handler)
inline

Registers a callback for the method node.

Note
This is a server only mechanic and only available after adding the node to a server.
Pass a c11 style lambda for accessing data
Parameters
[in]handlerThe callback
Returns
A cookie for callback deregistering
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ UnregisterCallback()

void UnregisterCallback ( EventCookie  eventCookie)
inline

Unregisters a callback for the method node.

Note
This is a server only mechanic and only available after adding the node to a server.
Parameters
[in]eventCookieThe callback cookie
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.