CVBpy 14.0
MethodNode Class Reference

Represents an OPCUA method node. More...

Inherits BaseNode.

Public Member Functions

None add_argument (self, str name, int in_out_type, int data_type, Union[str, int, float] default_value)
 Adds an argument to the method. More...
 
None call (self)
 Starts execution of the method on the server. More...
 
None create (int namespace_index, str name, cvb.opcua.NodeID parent_node_id)
 Creates an OPCUA method object. More...
 
None deregister_callback (self, cvb.EventCookie event_cookie)
 Deregisters a callback. More...
 
List[cvb.opcua.MethodNodeArgumentinput_arguments (self)
 Returns all registered input arguments. More...
 
List[cvb.opcua.MethodNodeArgumentoutput_arguments (self)
 Returns all registered output arguments. More...
 
cvb.EventCookie register_read_callback (self, Callable[[Any], Any] callback)
 Registers a callback for the call/execute operations. More...
 
- Public Member Functions inherited from BaseNode
List[cvb.opcua.NodeIDbrowse (self, cvb.opcua.BrowseFilter filter_options)
 Enumerates the child nodes present in the OPCUA server. More...
 
Union[int, float, str] get_attribute (self, int attribute_id)
 Gets specific information about this node. More...
 
cvb.opcua.NodeID node_id (self)
 Gets the OPCUA node ID of this node. More...
 
None set_attribute (self, int attribute_id, Union[int, float, str] value)
 Sets specific information about this node. More...
 

Additional Inherited Members

- Properties inherited from BaseNode
 access = property
 int: Gets access rights to this node (see cvb.opcua.Access).
 
 browse_name = property
 str: Gets the browse name of this node.
 
 connection_status = property
 int: Gets connection status of this node (see cvb.opcua.ConnectionStatus).
 
 description = property
 str: Gets description of this node.
 
 display_name = property
 str: Gets the human-readable name of this node.
 
 node_class = property
 int: Gets OPCUA node class of this node (see cvb.opcua.NodeClass).
 

Detailed Description

Represents an OPCUA method node.

It provides an interface for calling functions/methods on the OPCUA server. It may have input and output arguments. A typical usage consists of the following steps:

  1. On the server-side: A MethodNode is created and added to the server.
  2. On the server-side: The desired amount of arguments is added via the MethodNode.add_argument method for input and output. This 'defines' the arguments.
  3. On the server-side: A callback is set. This is later called by the client via the call method.
  4. On the client-side: The client application retrieves the MethodNodes and retrieves the arguments via the MethodNode.input_arguments method.
  5. On the client-side: The client application sets the input arguments to the desired value and then calls the MethodNode.call method.
  6. On the server-side: The callback is triggered. 6.a. The server application, inside the callback, retrieves the input arguments by using the MethodNode.input_arguments method and does whatever the callback is supposed to do. 6.b. The server application, still inside the callback, sets the output arguments by calling the MethodNode.output_arguments method.
  7. The client application retrieves the output arguments.

Member Function Documentation

◆ add_argument()

None add_argument (   self,
str  name,
int  in_out_type,
int  data_type,
Union[str, int, float]  default_value 
)

Adds an argument to the method.

Parameters

name : str Name of the argument.

in_out_type : int The argument an output/input argument.

data_type : int Data format of the argument.

default_value : Union[str, int, float] Default of the argument.

◆ call()

None call (   self)

Starts execution of the method on the server.

See class description for details.

◆ create()

None create ( int  namespace_index,
str  name,
cvb.opcua.NodeID  parent_node_id 
)

Creates an OPCUA method object.

Parameters

namespace_index : int String literal for a non-localized, human-readable name of an OPCUA node.

name : str String literal for non-localized, human-readable name of the OPCUA node.

parent_node_id : cvb.opcua.NodeID OPCUA node ID of the parent to which the OPCUA node to be created belongs.

◆ deregister_callback()

None deregister_callback (   self,
cvb.EventCookie  event_cookie 
)

Deregisters a callback.

The usage of lambdas for data access is highly recommended. Note: The callback MUST be deregistered, otherwise internal object handles will not be closed.

Parameters

event_cookie : cvb.EventCookie Event cookie, obtained from registering the listener.

◆ input_arguments()

List[cvb.opcua.MethodNodeArgument] input_arguments (   self)

Returns all registered input arguments.

See class description for details.

Returns

List[cvb.opcua.MethodNodeArgument] All registered input arguments.

◆ output_arguments()

List[cvb.opcua.MethodNodeArgument] output_arguments (   self)

Returns all registered output arguments.

See class description for details.

Returns

List[cvb.opcua.MethodNodeArgument] All registered output arguments.

◆ register_read_callback()

cvb.EventCookie register_read_callback (   self,
Callable[[Any], Any]  callback 
)

Registers a callback for the call/execute operations.

The usage of lambdas for data access is highly recommended. Note: The callback MUST be deregistered, otherwise internal object handles will not be closed.

Parameters

callback : Callable[[Any], Any] A callable as a callback to be registered.

Returns

cvb.EventCookie Cookie for unregistering the callback.