sgr_commhandler.driver.modbus.modbus_interface_async
Provides the Modbus interface implementation.
Attributes
Classes
Implements a data point of a Modbus interface. |
|
Implements a functional profile of a Modbus interface. |
|
Implements a Modbus device interface. |
Functions
|
Returns the selected slave address. |
|
Returns the selected slave address. |
|
Returns the byte order (endianness). |
|
returns the address offset. |
|
returns the selected ip address. |
|
returns the selected ip port. |
|
returns the selected serial port. |
|
returns the selected baudrate. |
|
returns the parity. |
|
Builds a data point of a Modbus interface. |
|
Checks if a data type is an integer. |
|
Checks if a data type is a floating point value. |
Module Contents
- sgr_commhandler.driver.modbus.modbus_interface_async.logger
- sgr_commhandler.driver.modbus.modbus_interface_async.get_rtu_slave_id(modbus_rtu)
Returns the selected slave address.
- Returns:
the slave ID
- Return type:
int
- Parameters:
modbus_rtu (sgr_specification.v0.product.modbus_types.ModbusRtu)
- sgr_commhandler.driver.modbus.modbus_interface_async.get_tcp_slave_id(modbus_tcp)
Returns the selected slave address.
- Returns:
the slave ID
- Return type:
int
- Parameters:
modbus_tcp (sgr_specification.v0.product.modbus_types.ModbusTcp)
- sgr_commhandler.driver.modbus.modbus_interface_async.get_endian(modbus)
Returns the byte order (endianness).
- Returns:
the byte order
- Return type:
BitOrder
- Parameters:
modbus (sgr_specification.v0.product.modbus_types.ModbusInterfaceDescription)
- sgr_commhandler.driver.modbus.modbus_interface_async.get_address_offset(modbus)
returns the address offset. is 0 by default and -1 when first register address is 1.
- Parameters:
modbus (sgr_specification.v0.product.modbus_types.ModbusInterfaceDescription)
- Return type:
int
- sgr_commhandler.driver.modbus.modbus_interface_async.get_tcp_address(modbus_tcp)
returns the selected ip address.
- Parameters:
modbus_tcp (sgr_specification.v0.product.modbus_types.ModbusTcp)
- Return type:
str
- sgr_commhandler.driver.modbus.modbus_interface_async.get_tcp_port(modbus_tcp)
returns the selected ip port.
- Parameters:
modbus_tcp (sgr_specification.v0.product.modbus_types.ModbusTcp)
- Return type:
int
- sgr_commhandler.driver.modbus.modbus_interface_async.get_rtu_serial_port(modbus_rtu)
returns the selected serial port.
- Parameters:
modbus_rtu (sgr_specification.v0.product.modbus_types.ModbusRtu)
- Return type:
str
- sgr_commhandler.driver.modbus.modbus_interface_async.get_rtu_baudrate(modbus_rtu)
returns the selected baudrate.
- Parameters:
modbus_rtu (sgr_specification.v0.product.modbus_types.ModbusRtu)
- Return type:
int
- sgr_commhandler.driver.modbus.modbus_interface_async.get_rtu_parity(modbus_rtu)
returns the parity.
- Parameters:
modbus_rtu (sgr_specification.v0.product.modbus_types.ModbusRtu)
- Return type:
str
- sgr_commhandler.driver.modbus.modbus_interface_async.build_modbus_data_point(data_point, functional_profile, interface)
Builds a data point of a Modbus interface.
- Parameters:
data_point (sgr_specification.v0.product.ModbusDataPoint)
functional_profile (sgr_specification.v0.product.ModbusFunctionalProfile)
interface (SGrModbusInterface)
- Return type:
- sgr_commhandler.driver.modbus.modbus_interface_async.is_integer_type(data_type)
Checks if a data type is an integer.
- Returns:
True if integer, False otherwise
- Return type:
bool
- Parameters:
data_type (Union[sgr_specification.v0.generic.base_types.DataTypeProduct, sgr_specification.v0.product.modbus_types.ModbusDataType, None])
- sgr_commhandler.driver.modbus.modbus_interface_async.is_float_type(data_type)
Checks if a data type is a floating point value.
- Returns:
True if integer, False otherwise
- Return type:
bool
- Parameters:
data_type (Union[sgr_specification.v0.generic.base_types.DataTypeProduct, sgr_specification.v0.product.modbus_types.ModbusDataType, None])
- class sgr_commhandler.driver.modbus.modbus_interface_async.ModbusDataPoint(dp_spec, fp_spec, interface)
Bases:
sgr_commhandler.api.data_point_api.DataPointProtocol[sgr_specification.v0.product.ModbusFunctionalProfile,sgr_specification.v0.product.ModbusDataPoint]Implements a data point of a Modbus interface.
- Parameters:
dp_spec (sgr_specification.v0.product.ModbusDataPoint)
fp_spec (sgr_specification.v0.product.ModbusFunctionalProfile)
interface (SGrModbusInterface)
- _interface
- _address: int = -1
- _data_type: sgr_specification.v0.product.modbus_types.ModbusDataType
- _size = 0
- _register_type: sgr_specification.v0.product.modbus_types.RegisterType
- async set_val(value)
- Parameters:
value (Any)
- async get_val(parameters=None, skip_cache=False)
- Parameters:
parameters (Optional[dict[str, str]])
skip_cache (bool)
- Return type:
Any
- class sgr_commhandler.driver.modbus.modbus_interface_async.ModbusFunctionalProfile(fp_spec, interface)
Bases:
sgr_commhandler.api.functional_profile_api.FunctionalProfile[sgr_specification.v0.product.ModbusFunctionalProfile]Implements a functional profile of a Modbus interface.
- Parameters:
fp_spec (sgr_specification.v0.product.ModbusFunctionalProfile)
interface (SGrModbusInterface)
- _interface
- _data_points
- get_data_points()
- Return type:
dict[tuple[str, str], sgr_commhandler.api.data_point_api.DataPoint]
- class sgr_commhandler.driver.modbus.modbus_interface_async.SGrModbusInterface(frame, sharedRTU=False)
Bases:
sgr_commhandler.api.device_api.SGrBaseInterfaceImplements a Modbus device interface.
- Parameters:
frame (sgr_specification.v0.product.DeviceFrame)
sharedRTU (bool)
- _client_wrapper: sgr_commhandler.driver.modbus.shared_client.ModbusClientWrapper = None
- byte_order
- address_offset = -1
- functional_profiles
- _device_id = ''
- __del__()
- is_connected()
- Return type:
bool
- async connect_async()
- async disconnect_async()
- async read_data(reg_type, address, size, data_type)
Reads data from the given Modbus address(es).
- Parameters:
reg_type (sgr_specification.v0.product.modbus_types.RegisterType)
address (int)
size (int)
data_type (sgr_specification.v0.product.modbus_types.ModbusDataType)
- Return type:
Any
- async write_data(reg_type, address, data_type, value)
Writes data to the given Modbus address(es).
- Parameters:
reg_type (sgr_specification.v0.product.modbus_types.RegisterType)
address (int)
data_type (sgr_specification.v0.product.modbus_types.ModbusDataType)
value (Any)
- set_slave_id(slave_id)
- Parameters:
slave_id (int)