Reference Obs Component Manager

This module models component management for CSP subelement observation devices.

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

An example CSP subelement obs 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 can be directly controlled via configure(), scan(), end_scan(), go_to_idle(), abort() and reset() command methods.

For testing purposes, it can also be told to simulate an observation fault via simulate_obsfault() methods.

When a component changes state, it lets the component manager know by calling its component_unconfigured, component_configured, component_scanning, component_not_scanning and component_obsfault methods.

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

  • 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 configuration ID.

Returns:

the configuration ID.

property scan_id: int

Return the scan ID.

Returns:

the scan ID.

configure_scan(configuration_id: str, task_callback: Callable | None, task_abort_event: Event) None

Configure the component.

Parameters:
  • configuration_id – 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 – the unique id of the 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 an obsfault, or the absence of one.

Parameters:

obsfault – if true, simulate an obsfault; otherwise, simulate the absence of an obsfault.

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

Reset the observation 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 ReferenceCspObsComponentManager(*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 ReferenceCspObsComponentManager instance.

Parameters:
  • logger – a logger for this component manager

  • communication_state_callback – callback for communication state

  • component_state_callback – callback for component state

configure_scan(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. These will be the root keys defined by the command schema.

Returns:

task status and human-readable status message

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

Tell the component to deconfigure.

Parameters:

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

Returns:

task status and human-readable status messsage

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

Tell the component to start scanning.

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

  • kwargs – keyword arguments. These will be the root keys defined by the command schema.

Returns:

task status and human-readable status messsage

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

Tell the component to stop scanning.

Parameters:

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

Returns:

task status and human-readable status messsage

abort(task_callback: Callable | None = None) Tuple[TaskStatus, str]

Tell the component to stop scanning.

Parameters:

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

Returns:

task status and human-readable status messsage

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

Perform an obsreset on the component.

Parameters:

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

Returns:

task status and human-readable status messsage

property config_id: str

Return the configuration id.

Returns:

the configuration id.

property scan_id: int

Return the scan id.

Returns:

the scan id.