RTClient#

class RTClient(opts, namespace)[source]#

Bases: object

Real Time Client. The RTClient class extends do-mpc by an easy to setup OPC UA client.

Note

The RTClient class main purpose is to setup an OPC UA client inside the do_mpc.opcua.RTBase class.

Configuration and setup:

Configuring and setting up the RTClient client involves the following steps:

  1. Use do_mpc.opcua.ClientOpts dataclass to specify client name as well as IP adress and port for the target server.

  2. Use the do_mpc.opcua.Namespace dataclass to setup the namespace stored in the RTClient instance.

  3. Initiate the RTClient instance with instances of do_mpc.opcua.ClientOpts and do_mpc.opcua.Namespace.

  4. Connect the RTClient to the taget server with connect()

Note

Remember to disconnect the RTClient class afterwards with disconnect()

Parameters:
  • opts (ClientOpts) – Client options.

  • namespace (Namespace) – Namespace draft stored in RTClient.

Methods#

add_namespace_url#

add_namespace_url(self, url)#

This method is used to add an OPC UA namespace index to the stored namespace.

Parameters:

url (int) – The OPC UA namespace index.

Return type:

None

connect#

connect(self)#

Connects the client to the target server.

Return type:

None

disconnect#

disconnect(self)#

Disconnects the client from the target server.

Return type:

None

readData#

readData(self, tag)#

Reads a variable from the target server.

Parameters:

tag (str) – The node ID of the target variable on the OPC UA server.

Returns:

float – The value stored on the target server.

writeData#

writeData(self, tag, dataVal)#

Overwrites a variable on the target server.

Parameters:
  • tag (str) – The node ID of the target variable on the OPC UA server.

  • dataVal (list) – The value written to the specified node ID

Return type:

None