Command Context

This module provides a data class for command context where all the main features of a command during its execution are reported.

class ska_csp_lmc_common.observation.command_context.CommandContext(command_name: str, command_id: str | None = None, start_time: ~datetime.datetime = <factory>, previous_stable_state: ska_control_model.ObsState | None = None, planned_devices: list[str] = <factory>, planned_device_aliases: dict[str, str] = <factory>, command_outcome: ~ska_csp_lmc_common.commands.task_tracker.CommandOutcome | None = None, completion_time: ~datetime.datetime | None = None, refresh_attempted: bool = False, overridden_by: str | None = None, requested_obs_modes: tuple[ska_control_model.ObsMode, ...] = (), scan_schedule: ~ska_csp_lmc_common.observation.scan.schedule.ScanSchedule | None = None, semantics: ~ska_csp_lmc_common.observation.command_semantics.CommandSemantics | None = None)

Bases: object

Data structure that owns all the relevant information about commands execution.

command_name: str
command_id: str | None = None
start_time: datetime
previous_stable_state: ska_control_model.ObsState | None = None
planned_devices: list[str]
planned_device_aliases: dict[str, str]
command_outcome: CommandOutcome | None = None
completion_time: datetime | None = None
refresh_attempted: bool = False
overridden_by: str | None = None
requested_obs_modes: tuple[ska_control_model.ObsMode, ...] = ()
scan_schedule: ScanSchedule | None = None
semantics: CommandSemantics | None = None
class ska_csp_lmc_common.observation.command_context.CommandDeviceSelection(planned_devices: set[str] = <factory>, failed_devices: set[str] = <factory>, successful_devices: set[str] = <factory>, has_command_outcome: bool = False)

Bases: object

Devices associated with a command, grouped by command outcome.

The selection is based on the command plan and, when available, on the command outcome.

Field semantics:

  • planned_devices: Devices that were included in the command plan.

  • failed_devices: Planned devices that explicitly reported command failure. Failed devices are canonicalized against planned_devices before being stored here.

  • successful_devices: Devices whose command-driven transition should still be tracked by the policy.

    Before the command outcome is known, this is equal to planned_devices, because no device has reported failure yet.

    After the command outcome is known, this is equal to planned_devices - failed_devices.

    This field should not be interpreted as “devices that already reached the target observing state”. It only means “devices that did not report command failure and therefore remain relevant for transition tracking”.

  • has_command_outcome: Whether the command has already produced a terminal outcome.

planned_devices: set[str]
failed_devices: set[str]
successful_devices: set[str]
has_command_outcome: bool = False
property devices_to_track: set[str]

Return devices whose command-driven transition should be tracked.

Before the command outcome is known, all planned devices are tracked.

After the command outcome is known, devices that reported command failure are excluded, because command failure handling is performed by the command-aware policy using the command outcome summary.