basic_robotics.interfaces.opc_bridge module

Handle communication with OPC Unified Automation Protocol.

class basic_robotics.interfaces.opc_bridge.OPCUA_Endpoint(name: str, opc_path, client_ref: opcua.Client)[source]

Bases: CommsObject

Create a new OPCUA Endpoint.

__init__(name: str, opc_path, client_ref: opcua.Client)[source]

Initialize a new OPCUA Endpoint.

Parameters:
  • name (str) – endpoint name

  • opc_path (list[str]) – endpoint path from root node

  • client_ref (Client) – reference to OPCUA Client

getData() → any[source]

Receive data.

Returns:

Any – Message Data

sendData(data: any) → bool[source]

Send data.

Parameters:

data – data to be sent

Returns:

bool – message send success

class basic_robotics.interfaces.opc_bridge.OPCUA_Client(end_point: str)[source]

Bases: Comms

Wrap a OPCUA Client object to be compatible with Basic-Robotics Communications.

__init__(end_point: str) → OPCUA_Client[source]

Create a new OPCUA_Client.

Parameters:

end_point (str) – OPC Server URL

Returns:

OPCUA_Client – New OPCUA_Client

setSecurity(security_policy: str, cert_file: str, private_key_file: str, server_certificate_file: str = None, mode: str = 'SignAndEncrypt') → None[source]

Set Security Settings for OPC Client.

if the client is already open, this function will close the client, apply settings, and then reopen the client connection. :param security_policy: security policy path :type security_policy: str :param cert_file: certificate path :type cert_file: str :param private_key_file: private key path :type private_key_file: str :param server_certificate_file: server certificate path. Defaults to None. :type server_certificate_file: str, optional :param mode: policy mode. Sign or SignAndEncrypt. Defaults to SignAndEncrypt. :type mode: str, optional

newComPort(name: str, type: str, *args, **kwargs) → None[source]

Create a new named comm port and adds it to the register.

Parameters:
  • name – String - name to identify new port

  • type – String - type of port “UDP” or “Serial” or “OPCEndpoint”

  • args – Optional - List of arguments specific to comm port

addEndpoint(reference_name: str, opc_path)[source]

Add an OPC Endpoint.

Parameters:
  • reference_name (str) – easy reference name for the opc endpoint.

  • opc_path ([str]]) – opc path to the endpoint from the root node.

openCom(name: str = 'OPC') → bool[source]

Open either a specific Com port, or the OPC Client itself.

Parameters:

name (str, optional) – com port to open. Defaults to “OPC”.

Returns:

bool – Success of Closing the Channel

closeCom(name: str = 'OPC') → bool[source]

Close either a specific Com port, or the OPC Client itself.

Parameters:

name (str, optional) – Com port to close. Defaults to “OPC”.

Returns:

bool – Success of Closing the Channel