SMART Box component manager

This module implements the component management for smartbox.

class SmartBoxComponentManager(logger, communication_state_callback, component_state_callback, attribute_change_callback, smartbox_nr, readable_name, port_count, pasd_fqdn, ports_with_antennas, antenna_names, fndh_port, masked_antennas=None, event_serialiser=None, _pasd_bus_proxy=None)

A component manager for MccsSmartBox.

This communicates via a proxy to a MccsPasdBus that talks to a simulator or the real hardware.

__init__(logger, communication_state_callback, component_state_callback, attribute_change_callback, smartbox_nr, readable_name, port_count, pasd_fqdn, ports_with_antennas, antenna_names, fndh_port, masked_antennas=None, event_serialiser=None, _pasd_bus_proxy=None)

Initialise a new instance.

Parameters:
  • logger (Logger) – a logger for this object to use

  • communication_state_callback (Callable[[CommunicationStatus], None]) – callback to be called when the status of the communications channel between the component manager and its component changes

  • component_state_callback (Callable[..., None]) – callback to be called when the component state changes

  • attribute_change_callback (Callable[..., None]) – callback to be called when a attribute of interest changes.

  • smartbox_nr (int) – the smartbox’s ID number.

  • readable_name (str) – the smartbox’s name

  • port_count (int) – the number of smartbox ports.

  • pasd_fqdn (str) – the fqdn of the pasdbus to connect to.

  • ports_with_antennas (list[int]) – list of ports which have antennas attached.

  • antenna_names (list[str]) – list of antenna names attached to ports.

  • fndh_port (int) – the fndh port to which this smartbox is attached.

  • masked_antennas (Optional[list[str]]) – list of antenna names whose ports should be masked.

  • event_serialiser (Optional[EventSerialiser]) – the event serialiser to be used by this object.

  • _pasd_bus_proxy (Optional[MccsDeviceProxy]) – a optional injected device proxy for testing

abort(task_callback=None)

Abort any in-flight tasks and propagate to the PaSD bus.

Parameters:

task_callback (Optional[Callable]) – notified of task progress.

Return type:

tuple[TaskStatus, str]

Returns:

tuple of TaskStatus and message.

cleanup()

Delete and clean up any remaining processes.

Return type:

None

do_off(task_callback=None, task_abort_event=None)

Turn the Smartbox off.

Parameters:
  • task_callback (Optional[Callable]) – Update task state, defaults to None

  • task_abort_event (Optional[Event]) – event set for an abort request

Raises:

ValueError – if no Pasdbus proxy

Return type:

None

do_on(task_callback=None, task_abort_event=None)

Turn the Smartbox on.

Parameters:
  • task_callback (Optional[Callable]) – Update task state, defaults to None

  • task_abort_event (Optional[Event]) – event set for an abort request

Raises:

ValueError – if no Pasdbus proxy

Return type:

None

do_standby(task_callback=None, task_abort_event=None)

Turn the Smartbox to standby.

Parameters:
  • task_callback (Optional[Callable]) – Update task state, defaults to None

  • task_abort_event (Optional[Event]) – event set for an abort request

Raises:

ValueError – if no Pasdbus proxy

Return type:

None

property port_mask: list[bool]

Getter for the port mask.

Returns:

list of masked ports on the smartbox.

set_antenna_masking(antenna_mask)

Update the masking status for specific antennas.

Antennas absent from the dict are left unchanged.

Parameters:

antenna_mask (dict[str, bool]) – mapping of antenna name to masked status (True = masked, False = unmasked).

Return type:

None

set_port_powers(json_argument, task_callback=None, task_abort_event=None)

Set port powers.

These ports will not have an antenna attached.

Parameters:
  • json_argument (str) – desired port powers of unmasked ports with smartboxes attached in json form.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

  • task_abort_event (Optional[Event]) – event set for an abort request

Return type:

tuple[ResultCode, str]

Returns:

the result code and a human-readable status message

start_communicating()

Establish communication.

Return type:

None

stop_communicating()

Stop communication with components under control.

Return type:

None

turn_off_port(port_number, task_callback, task_abort_event=None)

Turn a Port off.

This may or may not have a Antenna attached.

Parameters:
  • port_number (int) – (one-based) number of the port to turn off.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

  • task_abort_event (Optional[Event]) – event set for an abort request

Raises:

NotImplementedError – if no PaSD proxy is configured

Return type:

tuple[ResultCode, str]

Returns:

the result code and a human-readable status message

turn_on_port(port_number, task_callback, task_abort_event=None)

Turn a port on.

This may or may not have a Antenna attached.

Parameters:
  • port_number (int) – (one-based) number of the port to turn on.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

  • task_abort_event (Optional[Event]) – event set for an abort request

Raises:

NotImplementedError – if no PaSD proxy is configured

Return type:

tuple[ResultCode, str]

Returns:

the result code and a human-readable status message

write_attribute(attribute_name, value)

Request to write an attribute via the proxy.

Parameters:
  • attribute_name (str) – the name of the Tango attribute.

  • value (Any) – the value to write.

Return type:

None