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.
- 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.
- 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.
- comms_gateway_temperature
Public attribute as _Sensor() data descriptor: int
- 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 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.
- simulate_port_stuck_on(port_number, state=True)
Simulate port stuck on fault condition.
- 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.
- 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:
- Returns:
a dictionary of simulators.
- get_antenna_names_on_smartbox()
Return a list of lists of str for antenna names on each smartbox.
- get_fncc()
Return only the FNCC simulator.
- Return type:
- Returns:
the FNCC simulator.
- get_fndh()
Return only the FNDH simulator.
- Return type:
- Returns:
the FNDH simulator.
- get_smartbox_attached_ports()
Return a list of FNDH port numbers each smartbox is attached to.
- 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.
- 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:
- initialize()
Initialize a FNDH/smartbox.
Request to transition the FNDH/smartbox’s status to “OK”.
- 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.
- reset_warnings()
Reset the sensor warning flags.
- set_led_pattern(service_pattern)
Set the LED pattern.
- simulate_port_forcing(forcing)
Simulate local forcing of a port.
- simulate_port_over_current(port_number, state=True)
Simulate a port breaker trip.
- 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.
- turn_port_on(port_number, stay_on_when_offline=True)
Turn on a specified port.
- 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.
- 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
- 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.
- 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.
- set_sys_address(address)
Set the system address.
- simulate_breaker_trip(port_number)
Simulate a port breaker trip.