PaSD bus Modbus API
This module provides a Modbus API to the PaSD bus.
- class PasdBusModbusApi(simulators, logger)
A Modbus API for a PaSD bus simulator.
- class PasdBusModbusApiClient(host, port, logger_object, timeout, enable_logging=False, log_file_dir=None)
A client class for a PaSD (simulator or h/w) with a Modbus API.
- __init__(host, port, logger_object, timeout, enable_logging=False, log_file_dir=None)
Initialise a new instance.
- Parameters:
host (
str) – the host IP address for the PaSDport (
int) – the PaSD portlogger_object (
Logger) – the logger to usetimeout (
float) – the timeout period in secondsenable_logging (
Optional[bool]) – True if pymodbus logging is to be enabledlog_file_dir (
Optional[str]) – the directory to create the log file if required
- execute_command(device_id, name, *args)
Execute a command and return the results.
- read_attributes(device_id, *names)
Read attribute values from the server.
Note these must be stored in contiguous Modbus registers in the h/w.
- reset_connection()
Reset the connection to the device.
Re-create the Modbus client to ensure the transaction manager is properly reset.
- Return type:
- write_attribute(device_id, name, *values)
Write a new attribute value.
PaSD bus register map
This module provides a register mapping utility for the PaSD bus.
- class DesiredPowerEnum(value)
Enum type for the DSON and DSOFF attributes.
Note that DevEnum types must start at 0 and increment by 1.
- class PasdBusAttribute(address, count, conversion_function=<bound method PasdConversionUtility.default_conversion of <class 'ska_low_pasd_driver.pasd_bus_conversions.PasdConversionUtility'>>, writable=False)
Class representing a Modbus attribute stored on a Smartbox or FNDH.
This stores the starting register address and count (number of registers) containing this attribute, and a conversion function used to convert the raw register value into engineering units / status strings for read operations.
It is also used to store the value to be written to the register for command operations.
- __init__(address, count, conversion_function=<bound method PasdConversionUtility.default_conversion of <class 'ska_low_pasd_driver.pasd_bus_conversions.PasdConversionUtility'>>, writable=False)
Initialise a new instance.
- convert_value(values)
Execute the attribute’s conversion function on the supplied value.
Convert the raw register value(s) into a meaningful value
- convert_write_value(values)
Execute the attribute’s conversion function on the supplied value.
Convert the desired user value into a raw register value
- class PasdBusPortAttribute(address, count, desired_info=<PortStatusBits.NONE: 0>)
Class representing the power status for one or more ports.
- __init__(address, count, desired_info=<PortStatusBits.NONE: 0>)
Initialise a new instance.
- Parameters:
address (
int) – starting register addresscount (
int) – number of registers containing the port datadesired_info (
PortStatusBits) – port status attribute of interest if reading status (must match member of PortStatusBits)
- class PasdBusRegisterInfo(register_map, number_of_sensors=0, first_sensor_register=0, number_of_extra_sensors=0, first_extra_sensor_register=0, number_of_ports=0, starting_port_register=0)
Hold register information for a PaSD device.
- __init__(register_map, number_of_sensors=0, first_sensor_register=0, number_of_extra_sensors=0, first_extra_sensor_register=0, number_of_ports=0, starting_port_register=0)
- class PasdBusRegisterMap(revision_number=1)
A register mapping utility for the PaSD.
- __init__(revision_number=1)
Initialize a new instance.
- Parameters:
revision_number (
int) – Modbus register map revision number, if known (this will be set later after interrogating the h/w)
- get_attribute_names(device_id, addresses)
Map a list of register numbers to attribute names.
- get_attributes(device_id, attribute_names)
Map a list of attribute names to PasdAttribute objects.
- Raises:
PasdBusRequestError – If attributes do not match register map or non-contiguous set of registers requested
- Parameters:
- Return type:
- Returns:
A dictionary mapping attribute names to PasdAttributes, inserted in Modbus address order
- get_attributes_from_address_and_count(device_id, first_address, count)
Map initial register address and count to attributes.
- Parameters:
- Return type:
- Returns:
A dictionary of the corresponding string attribute names and attribute instances
- get_command(device_id, command_string, arguments)
Get a PasdBusAttribute object for the specified command.
- Parameters:
- Return type:
- Returns:
PasdBusAttribute object populated with converted value ready to send over Modbus
- Raises:
PasdBusRequestError – if the given string does not match any command or the arguments are invalid
- get_writable_attribute(device_id, attribute_name, write_values)
Return a PasdAttribute object for a writable object.
- Raises:
PasdBusRequestError – If a non-existing or non-writable register is requested
- Parameters:
- Return type:
- Returns:
A PasdAttribute object for this attribute
- exception PasdBusRequestError(error, *args)
Exception to be raised for invalid PaSD bus requests.
- __init__(error, *args)
Initialize new instance.
- Parameters:
error (
RequestErrors) – type of PaSD bus request error.args (
Any) – attributes, command or other arguments in the request.
- class PasdCommandStrings(value)
Enum type for PaSD command strings.
- class PortDesiredStateOffline(value)
Port desired state when device is offline.
- class PortDesiredStateOnline(value)
Port desired state when device is online.
- class PortOverride(value)
Port override for field maintenance.
- class PortStatusBits(value)
Enum type for PDOC/FEM port status bits.
Corresponds to register bit names in PaSD firmware description document.
- class RequestErrors(value)
Type of PaSD bus request errors.
PaSD bus conversions
This module provides scaling and other conversion functions for the PaSD.
- class FnccStatusMap(value)
Enum type for FNCC health status strings.
- class FndhAlarmFlags(value)
Enum type for the FNDH alarm/warning flags.
- class FndhStatusMap(value)
Enum type for FNDH health status strings.
- class LedServiceMap(value)
Enum type for the service LED (MSB in SYS_LIGHTS register).
- class LedStatusMap(value)
Enum type for the status LED (LSB in SYS_LIGHTS_REGISTER).
- class PasdConversionUtility
Conversion utility to provide scaling functions for PaSD registers.
The following methods each accept and return a list of values to simplify the calling code.
- classmethod convert_chip_id(value_list, inverse=False)
Convert the raw register values to a string chip id.
- classmethod convert_cpu_id(value_list, inverse=False)
Convert a number of raw register values to a CPU ID.
- classmethod convert_firmware_version(value_list, inverse=False)
Convert the raw register values to a string firmware version.
- classmethod convert_fncc_status(value_list, inverse=False)
Convert the raw register value to a string status.
- classmethod convert_fndh_alarm_status(value_list, inverse=False)
Convert the alarm and warning flag registers to strings.
- Parameters:
- Return type:
- Returns:
string describing the parameters that have triggered the alarm or warning.
- classmethod convert_fndh_status(value_list, inverse=False)
Convert the raw register value to a string status.
- classmethod convert_led_status(value_list, inverse=False)
Convert the raw register value to LED status strings.
- classmethod convert_smartbox_alarm_status(value_list, inverse=False)
Convert the alarm and warning flag registers to strings.
- Parameters:
- Return type:
- Returns:
string describing the parameters that have triggered the alarm or warning.
- classmethod convert_smartbox_status(value_list, inverse=False)
Convert the raw register value to a string status.
- classmethod convert_uptime(value_list, inverse=False)
Convert the raw register values to an uptime in seconds.
- classmethod default_conversion(values, inverse=False)
Return the supplied raw value(s) with no conversion.
- classmethod scale_48vcurrents(value_list, inverse=False)
Convert raw register value(s) to Amps.
For now, raw values are hundredths of an Amp, positive only.
- Parameters:
- Raises:
ValueError – if value_list is None
- Return type:
- Returns:
list of output_values
- classmethod scale_signed_16bit(value_list, inverse=False)
Convert raw register value(s) to deg C.
For now, raw values are hundredths of a deg C, as a signed 16-bit integer value
- Parameters:
- Raises:
ValueError – if value_list is None
- Return type:
- Returns:
value in deg C (if inverse=False), or raw value as an unsigned 16 bit integer
- classmethod scale_volts(value_list, inverse=False)
Convert raw register value(s) to Volts.
For now, raw values are hundredths of a volt, positive only.
- Parameters:
- Raises:
ValueError – if value_list is None
- Return type:
- Returns:
output_values in Volts
- class SmartboxAlarmFlags(value)
Enum type for the Smartbox alarm/warning flags.
- class SmartboxStatusMap(value)
Enum type for SmartBox health status strings.