eta_nexus.nodes.node module
This module implements the node class, which is used to parametrize connections.
- class eta_nexus.nodes.node.MetaNode(name: str, bases: tuple, namespace: dict[str, Any], **kwargs: Any)[source]
Bases:
typeMetaclass to define all Node classes as frozen attr dataclasses.
- class eta_nexus.nodes.node.Node(name: str, url: str, protocol: str, *args: Any, **kwargs: Any)[source]
Bases:
objectThe node objects represents a single variable. Valid keyword arguments depend on the protocol.
- 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’.
- connection_identifier() str[source]
Unique identifier for the connection that is associated with the node (i.e. would be created by Connection.from_node())
- evolve(**kwargs: Any) Self[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.
- Parameters:
kwargs – Keyword arguments to change.
- Returns:
New instance of the node.
- as_dict(*, filter_none: bool = False, **kwargs: Any) dict[str, Any][source]
Return the attrs attribute values of node instance as a dict.
- Parameters:
filter_none – Filter none values, defaults to False
- Returns:
dict of attribute values
- as_tuple(*, filter_none: bool = False, **kwargs: Any) tuple[Any, ...][source]
Return the attrs attribute values of inst as a tuple.
- Parameters:
filter_none – Filter none values, defaults to False
- Returns:
tuple of attribute values
- classmethod from_dict(dikt: Sequence[Mapping] | Mapping[str, Any], *, fail: bool = True) list[Self][source]
Create nodes from a dictionary of node configurations. The configuration must specify the following fields for each node:
Code (or name), URL, Protocol (i.e. modbus or opcua or eneffco). The URL should be a complete network location identifier. Alternatively it is possible to specify the location in two fields: IP and Port. These should only contain the respective parts (as in only an IP address and only the port number). The IP-Address should always be given without scheme (https://).
For local nodes no additional fields are required.
For Modbus nodes the following additional fields are required:
ModbusRegisterType (or mb_register), ModbusSlave (or mb_slave), ModbusChannel (or mb_channel).
For OPC UA nodes the following additional fields are required:
Identifier.
For Eneffco nodes the code field must be present.
For EntsoE nodes the endpoint field must be present.
- Parameters:
dikt – Configuration dictionary.
fail – Set this to false, if you would like to log errors instead of raising them.
- Returns:
List of Node objects.
- classmethod from_excel(path: Path, sheet_name: str, *, fail: bool = True) list[Self][source]
Method to read out nodes from an Excel document. The document must specify the following fields:
Code, IP, Port, Protocol (modbus or opcua or eneffco).
For Modbus nodes the following additional fields are required:
ModbusRegisterType, ModbusByte, ModbusChannel.
For OPC UA nodes the following additional fields are required:
Identifier.
For Eneffco nodes the Code field must be present.
The IP-Address should always be given without scheme (https://).
- Parameters:
path – Path to Excel document.
sheet_name – name of Excel sheet, which will be read out.
fail – Set this to false, if you would like to log errors instead of raising them.
- Returns:
List of Node objects.