OpcUa Connection
OpcUaConnection
- class eta_utility.connectors.OpcUaConnection(url: str, usr: str | None = None, pwd: str | None = None, *, nodes: Nodes[NodeOpcUa] | None = None, key_cert: KeyCertPair | None = None, **kwargs: Any)[source]
- The OPC UA Connection class allows reading and writing from and to OPC UA servers. Additionally, it implements a subscription method, which reads continuously in a specified interval. - Parameters:
- url – URL of the OPC UA Server. 
- usr – Username in OPC UA for login. 
- pwd – Password in OPC UA for login. 
- nodes – List of nodes to use for all operations. 
 
 - classmethod from_ids(ids: Sequence[str], url: str, usr: str | None = None, pwd: str | None = None) OpcUaConnection[source]
- Initialize the connection object from an OPC UA protocol through the node IDs. - Parameters:
- ids – Identification of the Node. 
- url – URL for connection. 
- usr – Username in OPC UA for login. 
- pwd – Password in OPC UA for login. 
 
- Returns:
- OpcUaConnection object. 
 
 - read(nodes: NodeOpcUa | Nodes[NodeOpcUa] | None = None) pd.DataFrame[source]
- Read some manually selected values from OPC UA capable controller. - Parameters:
- nodes – Single node or list/set of nodes to read from. 
- Returns:
- pandas.DataFrame containing current values of the OPC UA-variables. 
- Raises:
- ConnectionError – When an error occurs during reading. 
 
 - write(values: Mapping[NodeOpcUa, Any]) None[source]
- Writes some manually selected values on OPC UA capable controller. - Parameters:
- values – Dictionary of nodes and data to write {node: value}. 
- Raises:
- ConnectionError – When an error occurs during reading. 
 
 - create_nodes(nodes: Nodes[NodeOpcUa]) None[source]
- Create nodes on the server from a list of nodes. This will try to create the entire node path. - Parameters:
- nodes – List or set of nodes to create. 
- Raises:
- ConnectionError – When an error occurs during node creation. 
 
 - delete_nodes(nodes: Nodes[NodeOpcUa]) None[source]
- Delete the given nodes and their parents (if the parents do not have other children). - Parameters:
- nodes – List or set of nodes to be deleted. 
- Raises:
- ConnectionError – If deletion of nodes fails. 
 
 - subscribe(handler: SubscriptionHandler, nodes: NodeOpcUa | Nodes[NodeOpcUa] | None = None, interval: TimeStep = 1) None[source]
- Subscribe to nodes and call handler when new data is available. Basic architecture of the subscription is the client- server communication via subscription notify. This function works asynchronously. Subscriptions must always be closed using the close_sub function (use try, finally!). - Parameters:
- nodes – Single node or list/set of nodes to subscribe to. 
- handler – SubscriptionHandler object with a push method that accepts node, value pairs. 
- interval – Interval for receiving new data. It is interpreted as seconds when given as an integer. 
 
 
 
NodeOpcUa
- class eta_utility.connectors.node.NodeOpcUa(name: str, url: str, protocol: str, *args: Any, **kwargs: Any)[source]
- Node for the OPC UA protocol. - opc_id_type: str
- Type of the OPC UA Node ID Specification. 
 - opc_name: str
- Name of the OPC UA Node. 
 - evolve(**kwargs: Any) Node[source]
- Returns a new node instance by copying the current node and changing only specified keyword arguments. - This allows for seamless node instantiation with only a few changes. - Adjusted attributes handling according to OpcUa node instantiation logic as in ‘__attrs_post_init__’. - Parameters:
- kwargs – Keyword arguments to change. 
- Returns:
- New instance of the node. 
 
 - name: str
- Name for the node. 
 - url: str
- URL of the connection. 
 - url_parsed: ParseResult
- Parse result object of the URL (in case more post-processing is required). 
 - dtype: Callable | None
- Data type of the node (for value conversion). Note that strings will be interpreted as utf-8 encoded. If you do not want this behaviour, use ‘bytes’.