simulation

SimModeCMBase Class

class ska_mid_cbf_fhs_common.testing.simulation.SimModeCMBase(*args: Any, attr_change_callback: Callable[[str, Any], None] | None = None, attr_archive_callback: Callable[[str, Any], None] | None = None, **kwargs: Any)[source]

Bases: TaskExecutorComponentManager

A base class for FHS device simulation mode component managers. FHS device instances can make use component managers that inherit from this class and FhsSimMode-derived mixins to simulate their own behaviour.

SimModeCMBase-derived simulation mode component managers should initialize to default behaviour and supply an interface matching the one expected of the genuine component manager that is being replaced; property getter methods are used to return attribute_overrides values instead of expected attributes, and functools.partial is used to override LRC submit_task methods with sim_command, which submits a generic LRC task that pulls from command_overrides values to generate expected behaviour.

Initialize default attribute and command overrides.

Requires only logger, communication_state_callback and component_state_callback arguments for BaseComponentManager initialization.

get_attribute_override(attr_name)[source]

Return specified attribute override from queue

Parameters:

attribute – specified attribute to return the value of

get_command_override(command)[source]

Return specified command override from queue

Parameters:

command – specified command to return the value of

is_sim_command_allowed(command_name: str) bool[source]

Check if the simulated command is allowed.

Parameters:

command_name (str) – name of the command to be simulated

Returns:

True if the simulated command is allowed or allowance is not specified, otherwise False.

Return type:

bool

sim_command(*args: Any, task_callback: Callable, command_name: str, **kwargs: Any) tuple[TaskStatus, str][source]

Submit simulated command operation method to task executor queue. Along with the submitted _sim_command thread, provides the ability to modify LRC behaviour asynchronously to the device, thus approaching a truer, more tunable simulation of LRCs.

Parameters:
  • task_callback (Callable) – Callback function to update task status

  • command_name (str) – name of the command to be simulated

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

Return type:

tuple[TaskStatus, str]

start_communicating(*args, **kwargs) None[source]

Simulate basic start_communicating behaviour. Updates communication state and power state.

stop_communicating(*args, **kwargs) None[source]

Simulate basic stop_communicating behaviour. Updates communication state and power state.

update_default_attributes()[source]

Rebuild attribute queue_dict using command_overrides value

update_default_commands()[source]

Rebuild command queue_dict using command_overrides value

SimModeObsCMBase Class

class ska_mid_cbf_fhs_common.testing.simulation.SimModeObsCMBase(*args: Any, **kwargs: Any)[source]

Bases: SimModeCMBase

A base class for FHS observing device simulation mode component managers.

Initialize default obs device attribute and command overrides.

abort_commands(task_callback: TaskCallbackType | None = None) tuple[TaskStatus, str][source]

Abort all tasks queued & running.

Parameters:
  • task_callback (TaskCallbackType | None, optional) – callback to be called whenever the status

  • None. (of the task changes. Default is)

is_sim_command_allowed(command_name: str) bool[source]

Check if the simulated command is allowed. Adds ObsState checks.

Parameters:

command_name (str) – name of the command to be simulated

Returns:

True if the simulated command is allowed or allowance is not specified, otherwise False.

Return type:

bool

FhsSimMode Class

class ska_mid_cbf_fhs_common.testing.simulation.FhsSimMode(self: tango._tango.Device_6Impl, klass: tango._tango.DeviceClass, name: str, description: str = 'A Tango device', state: tango._tango.DevState = <DevState.UNKNOWN: 13>, status: str = 'Not initialised')[source]

Bases: Device

A base simulation mode mixin class for Mid.CBF FHS devices.

Adds the simOverrides attribute which allows for overriding device behaviour when in simulation mode when used alongside SimModeCMBase-derived component managers.

TangoClassClass

alias of FhsSimModeClass

TangoClassName = 'FhsSimMode'
simOverrides

Attribute value overrides (JSON dict)

FhsObsSimMode Class

class ska_mid_cbf_fhs_common.testing.simulation.FhsObsSimMode(self: tango._tango.Device_6Impl, klass: tango._tango.DeviceClass, name: str, description: str = 'A Tango device', state: tango._tango.DevState = <DevState.UNKNOWN: 13>, status: str = 'Not initialised')[source]

Bases: FhsSimMode

A base simulation mode mixin class for Mid.CBF FHS observing devices.

TangoClassClass

alias of FhsObsSimModeClass

TangoClassName = 'FhsObsSimMode'
simOverrides

Attribute value overrides (JSON dict)