eta_nexus.nodes.modbus_node module

This module implements the node class, which is used to parametrize connections.

eta_nexus.nodes.modbus_node.bitarray_to_registers(bits: list[int | bool]) list[int][source]

Convert a list of bits into a list of 16 bit ‘bytes’.

class eta_nexus.nodes.modbus_node.ModbusNode(name: str, url: str, protocol: str, *args: Any, **kwargs: Any)[source]

Bases: Node

Node for the Modbus protocol.

mb_slave: int | None

Modbus Slave ID

mb_register: str

Modbus Register name. One of input, discrete_input, coils and holding. Note that only coils and holding can be written to.

mb_channel: int

Modbus Channel (Address of the value)

mb_bit_length: int

Length of the value in bits (default 32). This determines, how much data is read from the server. The value must be a multiple of 16.

mb_byteorder: str

Byteorder of values returned by modbus

mb_wordorder: str

Wordorder of values returned by modbus

decode_modbus_value(value: Sequence[int]) Any[source]

Decode incoming modbus values.

Strings are always decoded as utf-8 values. If you do not want this behaviour, specify ‘bytes’ as the data type for the Node.

Parameters:

value – Current value to be decoded

Returns:

Decoded value as the Node’s data type.

encode_bits(value: Primitive) list[int][source]

Encode python data type to modbus value. This means an array of bytes to send to a modbus server.

Parameters:

value – Current value to be decoded into float.

Returns:

Decoded value as a python type.