Reference Subarray Component Manager

This module models component management for CSP subelement observation devices.

class FakeCspSubarrayComponent(*args: Any, **kwargs: Any)

A fake component for the component manager to work with.

NOTE: There is usually no need to implement a component object. The “component” is an element of the external system under control, such as a piece of hardware or an external service. In the case of a subarray device, the “component” is likely a collection of Tango devices responsible for monitoring and controlling the various resources assigned to the subarray. The component manager should be written so that it interacts with those Tango devices. But here, we fake up a “component” object to interact with instead.

It supports the configure`, scan, end_scan, end, abort, obsreset and restart methods. For testing purposes, it can also be told to simulate a spontaneous state change via simulate_power_state and simulate_fault methods.

When one of these command methods is invoked, the component simulates communications latency by sleeping for a short time. It GenericBaseComponentManager then returns, but simulates any asynchronous work it needs to do by delaying updating task and component state for a short time.

Initialise a new instance.

Parameters:
  • time_to_return – the amount of time to delay before returning from a command method. This simulates latency in communication.

  • time_to_complete – the amount of time to delay before the component calls a task callback to let it know that the task has been completed

  • power – initial power state of this component

  • fault – initial fault state of this component

  • resourced – initial resourced state of this component

  • configured – initial configured state of this component

  • scanning – initial scanning state of this component

  • obsfault – initial obsfault state of this component

  • kwargs – additional keyword arguments

property config_id: str

Return the unique id of this configuration.

Returns:

a unique id

property scan_id: int

Return the unique id of this scan.

Returns:

a unique id

property last_scan_configuration: str

Return the last programmed configuration.

Returns:

a JSON formatted string

property assigned_resources: List

Return the list of assigned resources IDs.

Returns:

a list of str

assign(resources: set[int], task_callback: Callable | None, task_abort_event: Event) None

Assign resources.

Parameters:
  • resources – the resources to be assigned.

  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

release(resources: dict, task_callback: Callable | None, task_abort_event: Event) None

Release resources.

Parameters:
  • resources – resources to be released

  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

release_all(task_callback: Callable | None, task_abort_event: Event) None

Release all resources.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

configure(configuration: Any, task_callback: Callable | None, task_abort_event: Event) None

Configure the component.

Parameters:
  • configuration – the configuration to be configured

  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

deconfigure(task_callback: Callable | None, task_abort_event: Event) None

Deconfigure this component.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

scan(scan_id: int, task_callback: Callable | None, task_abort_event: Event) None

Start scanning.

Parameters:
  • scan_id – unique ID of this scan

  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

end_scan(task_callback: Callable | None, task_abort_event: Event) None

End scanning.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

simulate_scan_stopped() None

Tell the component to simulate spontaneous stopping its scan.

simulate_obsfault(obsfault: bool) None

Tell the component to simulate (or stop simulating) an obsfault.

Parameters:

obsfault – whether an obsfault has occurred

obsreset(task_callback: Callable | None, task_abort_event: Event) None

Reset an observation that has faulted or been aborted.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

restart(task_callback: Callable | None, task_abort_event: Event) None

Restart the component after it has faulted or been aborted.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • task_abort_event – a threading.Event that can be checked for whether this task has been aborted.

class ReferenceCspSubarrayComponentManager(*args: Any, **kwargs: Any)

A component manager for SKA CSP subelement observation Tango devices.

The current implementation is intended to * illustrate the model * enable testing of the base classes

It should not generally be used in concrete devices; instead, write a subclass specific to the component managed by the device.

Initialise a new ReferenceCspSubarrayComponentManager instance.

Parameters:
  • logger – the logger for this component manager to log with

  • communication_state_callback – callback to be called when the state of communications with the component changes

  • component_state_callback – callback to be called when the state of the component changes

start_communicating() None

Establish communication with the component, then start monitoring.

stop_communicating() None

Break off communication with the component.

simulate_communication_failure(fail_communicate: bool) None

Simulate (or stop simulating) a failure to communicate with the component.

Parameters:

fail_communicate – whether the connection to the component is failing

property power_state: PowerState

Power mode of the component.

This is just a bit of syntactic sugar for self.component_state[“power”].

Returns:

the power mode of the component

property fault_state: bool

Whether the component is currently faulting.

Returns:

whether the component is faulting

off(task_callback: Callable | None = None) tuple[TaskStatus, str]

Turn the component off.

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

standby(task_callback: Callable | None = None) tuple[TaskStatus, str]

Put the component into low-power standby mode.

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

on(task_callback: Callable | None = None) tuple[TaskStatus, str]

Turn the component on.

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

reset(task_callback: Callable | None = None) tuple[TaskStatus, str]

Reset the component (from fault state).

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

assign(task_callback: Callable | None = None, **kwargs: Any) tuple[TaskStatus, str]

Assign resources to the component.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • kwargs – keyword arguments to the command

Returns:

task status and a human-readable status message

release(task_callback: Callable | None = None, **kwargs: Any) tuple[TaskStatus, str]

Release resources from the component.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • kwargs – keyword arguments to the command

Returns:

task status and a human-readable status message

release_all(task_callback: Callable | None = None) tuple[TaskStatus, str]

Release all resources.

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

configure(task_callback: Callable | None = None, **kwargs: Any) tuple[TaskStatus, str]

Configure the component.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • kwargs – keyword arguments to the command

Returns:

task status and a human-readable status message

deconfigure(task_callback: Callable | None = None) tuple[TaskStatus, str]

Deconfigure this component.

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

scan(task_callback: Callable | None = None, **kwargs: Any) tuple[TaskStatus, str]

Start scanning.

Parameters:
  • task_callback – a callback to be called whenever the status of this task changes.

  • kwargs – keyword arguments to the command

Returns:

task status and a human-readable status message

end_scan(task_callback: Callable | None = None) tuple[TaskStatus, str]

End scanning.

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

obsreset(task_callback: Callable | None = None) tuple[TaskStatus, str]

Deconfigure the component but do not release resources.

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

restart(task_callback: Callable | None = None) tuple[TaskStatus, str]

Tell the component to restart.

It will return to a state in which it is unconfigured and empty of assigned resources.

Parameters:

task_callback – a callback to be called whenever the status of this task changes.

Returns:

task status and a human-readable status message

property config_id: str

Return the configuration id.

Returns:

the configuration id.

property scan_id: int

Return the scan id.

Returns:

the scan id.

property last_scan_configuration: str

Return the configuration id.

Returns:

the configuration id.

property assigned_resources: List[str]

Return the list of assigned resources.

Returns:

a list of strings with the FQDNs of the assigned resources