PaSD bus simulator

This module provides a simulated component manager for the PaSD bus.

The components of a PaSD system all share the same multi-drop serial bus, and monitoring and control of those component is necessarily via that bus:

  • MccsAntenna instances use the bus to monitor and control their antennas;

  • MccsSmartbox instances use the bus to monitor and control their smartboxes (FNSC);

  • The MccsFndh instance uses the bus to monitor and control the FNPC

  • The MccsFncc instance uses the bus to monitor the FNCC

To arbitrate access and prevent collisions/congestion, the MccsPasdBus device is given exclusive use of the PaSD bus. All other devices can only communicate on the PaSD bus by proxying through MccsPasdBus.

To that end, MccsPasdBus needs a PasdBusComponentManager that talks to the PaSD bus using MODBUS-over-TCP.

The Pasd bus simulator class is provided below. To help manage complexity, it is composed of separate FNDH(FNPC) and FNCC simulators and a number of smartbox simulators, which in turn make use of port simulators. Only the PasdBusSimulator class should be considered public.

class BaseControllerSimulator(time_multiplier)

A base class for all the PaSD controllers’ simulators.

__init__(time_multiplier)

Initialise a new instance.

Parameters:

time_multiplier (int) – to differentiate uptime in test context without delays.

property uptime: list[int]

Return the uptime as an integer in seconds, or fractions of a second for tests.

Returns:

the uptime.

class FnccSimulator(time_multiplier, logger)

A simple simulator of a Field Node Communications Controller inside the FNDH.

This FNCC simulator will never be used as a standalone simulator. It will only be used as a component of a PaSD bus simulator.

__init__(time_multiplier, logger)

Initialise a new instance.

Parameters:
  • time_multiplier (int) – to differentiate uptime in test context without delays.

  • logger (Logger) – the logger object to use.

property chip_id: list[int]

Return the ID of the chip.

Returns:

the ID of the chip.

property cpu_id: list[int]

Return the ID of the CPU.

Returns:

the ID of the CPU.

property field_node_number: int

Return the field node number.

Returns:

the field node number.

property firmware_version: int

Return the firmware version.

Returns:

the firmware version.

property modbus_register_map_revision: int

Return the Modbus register map revision number.

Returns:

the Modbus register map revision number.

property pcb_revision: int

Return the PCB revision number.

Returns:

the PCB revision number.

property status: int

Return the status of the FNCC.

Returns:

an overall status.

property sys_address: int

Return the system address.

Returns:

the system address.

class FndhSimulator(time_multiplier, logger, instantiate_smartbox=None, delete_smartbox=None)

A simple simulator of a Field Node Peripheral Controller inside the FNDH.

This simulator will never be used as a standalone simulator. It will only be used as a component of a PaSD bus simulator.

__init__(time_multiplier, logger, instantiate_smartbox=None, delete_smartbox=None)

Initialise a new instance.

Parameters:
  • time_multiplier (int) – to differentiate uptime in test context without delays.

  • logger (Logger) – the logger object to use.

  • instantiate_smartbox (Optional[Callable[[int], Optional[bool]]]) – optional reference to PasdBusSimulator function.

  • delete_smartbox (Optional[Callable[[int], Optional[bool]]]) – optional reference to PasdBusSimulator function.

property chip_id: list[int]

Return the ID of the chip.

Returns:

the ID of the chip.

comms_gateway_temperature

Public attribute as _Sensor() data descriptor: int

property cpu_id: list[int]

Return the ID of the CPU.

Returns:

the ID of the CPU.

property firmware_version: int

Return the firmware version.

Returns:

the firmware version.

fncb_humidity

Public attribute as _Sensor() data descriptor: int

fncb_temperature

Public attribute as _Sensor() data descriptor: int

internal_ambient_temperature

Public attribute as _Sensor() data descriptor: int

property modbus_register_map_revision: int

Return the Modbus register map revision number.

Returns:

the Modbus register map revision number.

outside_temperature

Public attribute as _Sensor() data descriptor: int

panel_temperature

Public attribute as _Sensor() data descriptor: int

property pcb_revision: int

Return the PCB revision number.

Returns:

the PCB revision number.

property ports_power_control: list[bool]

Return the power control line state of each FNDH port.

Returns:

the power control line state of each FNDH port.

power_module_temperature

Public attribute as _Sensor() data descriptor: int

psu48v_current

Public attribute as _Sensor() data descriptor: int

psu48v_temperature_2

Public attribute as _Sensor() data descriptor: int

psu48v_voltage_2

Public attribute as _Sensor() data descriptor: int

simulate_port_stuck_off(port_number, state=True)

Simulate port stuck off fault condition.

Parameters:
  • port_number (int) – number of the port for which a breaker trip will be simulated.

  • state (bool) – of simulating condition.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

simulate_port_stuck_on(port_number, state=True)

Simulate port stuck on fault condition.

Parameters:
  • port_number (int) – number of the port for which a breaker trip will be simulated.

  • state (bool) – of simulating condition.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

property sys_address: int

Return the system address.

Returns:

the system address.

turn_port_on(port_number, stay_on_when_offline=True)

Turn on a specified port.

Turning on an FNDH port while in ALARM is a no-op.

Parameters:
  • port_number (int) – number of the port to turn off

  • stay_on_when_offline (bool) – whether to remain on if the control system goes offline

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do

class PasdBusSimulator(pasd_configuration_path, station_label, logger, smartboxes_depend_on_attached_ports=False, time_multiplier=1000)

A stub class that provides similar functionality to a PaSD bus.

Many attributes are stubbed out:

  • The antennas are always online.

  • Voltages, currents and temperatures never change.

__init__(pasd_configuration_path, station_label, logger, smartboxes_depend_on_attached_ports=False, time_multiplier=1000)

Initialise a new instance.

Parameters:
  • pasd_configuration_path (str) – path to a PaSD configuration file.

  • station_label (str) – name of the station to which this PaSD belongs.

  • smartboxes_depend_on_attached_ports (bool) – enable instantiation/deleting of smartboxes when FNDH ports are turned on and off.

  • time_multiplier (int) – to differentiate uptime in test context without delays.

  • logger (Logger) – the logger object to use.

get_all_devices()

Return a dictionary of the FNDH, FNCC and Smartbox simulators.

Return type:

dict[int, PasdHardwareSimulator]

Returns:

a dictionary of simulators.

get_antenna_names_on_smartbox()

Return a list of lists of str for antenna names on each smartbox.

Return type:

list[list[str]]

Returns:

a list of lists of str for antenna names on each smartbox.

get_fncc()

Return only the FNCC simulator.

Return type:

FnccSimulator

Returns:

the FNCC simulator.

get_fndh()

Return only the FNDH simulator.

Return type:

FndhSimulator

Returns:

the FNDH simulator.

get_smartbox_attached_ports()

Return a list of FNDH port numbers each smartbox is attached to.

Return type:

list[int]

Returns:

a list of FNDH port numbers each smartbox is attached to.

get_smartbox_ports_connected()

Return a list of lists of bool for connected ports of each smartbox.

Return type:

list[list[bool]]

Returns:

a list of lists of bool for connected ports of each smartbox.

class PasdHardwareSimulator(ports, logger, time_multiplier)

A class that captures commonality between FNDH and smartbox simulators.

Both have a status that must be initialized and manage a set of ports - which can be switched on and off, locally forced, etc.

__init__(ports, logger, time_multiplier)

Initialise a new instance.

Parameters:
  • ports (Sequence[_FndhPortSimulator | _SmartboxPortSimulator]) – instantiated ports for the simulator.

  • time_multiplier (int) – to differentiate uptime in test context without delays.

  • logger (Logger) – the logger object to use.

property alarm_flags: int

Return the sensor alarm flags.

Returns:

the sensor alarm flags.

configure(ports_connected)

Configure the hardware.

Parameters:

ports_connected (list[bool]) – whether each port has something connected to it.

Raises:

ValueError – if the configuration doesn’t match the number of ports.

Return type:

None

initialize()

Initialize a FNDH/smartbox.

Request to transition the FNDH/smartbox’s status to “OK”.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

property led_pattern: int

Return the LED pattern name.

Returns:

the name of the LED pattern.

property port_forcings: list[str]

Return the forcing statuses of all ports.

Returns:

the forcing statuses of each port. “ON” means the port has been forced on. “OFF” means it has been forced off. “NONE” means it has not been forced.

property ports_connected: list[bool]

Return whether each port is connected.

Returns:

whether each port is connected.

property ports_desired_power_when_offline: list[DesiredPowerEnum]

Return the desired power of each port when the device is offline.

That is, for each port, should it remain powered if the control system goes offline?

Returns:

the desired power of each port when the device is offline

property ports_desired_power_when_online: list[DesiredPowerEnum]

Return the desired power of each port when the device is online.

That is, for each port, should it be powered if the control system is online?

Returns:

the desired power of each port when the device is online

property ports_power_sensed: list[bool]

Return the actual sensed power state of each port.

Returns:

the actual sensed power state of each port.

reset_alarms()

Reset the sensor alarm flags.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

reset_warnings()

Reset the sensor warning flags.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

set_led_pattern(service_pattern)

Set the LED pattern.

Parameters:

service_pattern (int) – the LED pattern to be set.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

simulate_port_forcing(forcing)

Simulate local forcing of a port.

Parameters:

forcing (Optional[bool]) – the new forcing status of the port. True means the port has been forced on. False means it has been forced off. None means it has not been forced.

Return type:

list[Optional[bool]]

Returns:

whether successful, or None if there was nothing to do.

simulate_port_over_current(port_number, state=True)

Simulate a port breaker trip.

Parameters:
  • port_number (int) – number of the port for which a breaker trip will be simulated.

  • state (bool) – of simulating condition.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

property status: int

Return the status of the controller.

Returns:

an overall status. See FndhStatusMap and SmartboxStatusMap for details.

turn_port_off(port_number)

Turn off a specified port.

Parameters:

port_number (int) – number of the port to turn off

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do

turn_port_on(port_number, stay_on_when_offline=True)

Turn on a specified port.

Parameters:
  • port_number (int) – number of the port to turn off

  • stay_on_when_offline (bool) – whether to remain on if the control system goes offline

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do

property warning_flags: int

Return the sensor warning flags.

Returns:

the sensor warning flags.

class SmartboxSimulator(time_multiplier, address=1, logger=<RootLogger root (WARNING)>)

A simulator for a Field Node SMART Box Controller.

__init__(time_multiplier, address=1, logger=<RootLogger root (WARNING)>)

Initialise a new instance.

Parameters:
  • time_multiplier (int) – to differentiate uptime in test context without delays.

  • address (int) – to set as default system address.

  • logger (Logger) – the logger object to use.

property chip_id: list[int]

Return the chip ID.

Returns:

the chip ID.

property cpu_id: list[int]

Return the CPU ID.

Returns:

the CPU ID.

fem_ambient_temperature

Public attribute as _Sensor() data descriptor: int

fem_case_temperature_2

Public attribute as _Sensor() data descriptor: int

property fem_current_trip_thresholds: list[int]

Return the current trip threshold for each smartbox port.

Returns:

the current trip threshold for each smartbox port.

fem_heatsink_temperature_2

Public attribute as _Sensor() data descriptor: int

property firmware_version: int

Return the firmware version.

Returns:

the firmware version.

input_voltage

Public attribute as _Sensor() data descriptor: int

property modbus_register_map_revision: int

Return the Modbus register map revision number.

Returns:

the Modbus register map revision number.

property pcb_revision: int

Return the PCB revision number.

Returns:

the PCB revision number.

pcb_temperature

Public attribute as _Sensor() data descriptor: int

property port_breakers_tripped: list[bool]

Return whether each port has had its breaker tripped.

Returns:

whether each port has had its breaker tripped

property ports_current_draw: list[int]

Return the current being drawn from each smartbox port.

Returns:

the current being drawn from each smartbox port.

power_supply_output_voltage

Public attribute as _Sensor() data descriptor: int

power_supply_temperature

Public attribute as _Sensor() data descriptor: int

reset_port_breaker(port_number)

Reset a tripped port breaker.

Parameters:

port_number (int) – number of the port whose breaker should be reset.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

set_sys_address(address)

Set the system address.

Parameters:

address (int) – the system address to be set - must be in range from 1 to 99.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

simulate_breaker_trip(port_number)

Simulate a port breaker trip.

Parameters:

port_number (int) – number of the port for which a breaker trip will be simulated.

Return type:

Optional[bool]

Returns:

whether successful, or None if there was nothing to do.

property sys_address: int

Return the system address.

Returns:

the system address.