Command Context Builder
Builders for observation command contexts.
This module defines the protocol used to build a CommandContext and
provides a first hard-coded implementation.
The current implementation derives command semantics directly in Python.
In a later phase, this builder can be replaced by one that loads and
compiles semantics from YAML, while preserving the same runtime contract:
the policy receives a fully populated CommandContext with a compiled
semantic summary attached.
- class ska_csp_lmc_common.observation.command_context_builder.CommandContextBuilder(*args, **kwargs)
Bases:
ProtocolProtocol for building command contexts.
A builder is responsible for creating a
CommandContextfor a command execution, including the command semantic summary that will be consumed later by the observation policy.This abstraction allows the source of semantics to vary independently from the rest of the system. For example, semantics may be hard-coded or compiled from a YAML description.
- build(obs_state_model, *, task_name: str, command_id: str, planned_devices: list[str], planned_device_aliases: dict[str, str] | None = None, requested_obs_modes: tuple[ska_control_model.ObsMode, ...] = ()) CommandContext
Build a command context for a specific command execution.
- Parameters:
obs_state_model – Observation state model used to retrieve the previous stable state.
task_name – Name of the command being executed.
command_id – Unique identifier of the command instance.
planned_devices – Devices involved in the command plan.
requested_obs_modes – Requested observation modes, if any.
- Returns:
A fully populated command context.
- class ska_csp_lmc_common.observation.command_context_builder.HardCodedCommandContextBuilder
Bases:
objectHard-coded implementation of the command context builder.
This implementation derives command semantics directly from Python logic. It is intended as a first step before replacing it with a YAML-based builder in the future.
- build(obs_state_model, *, task_name: str, command_id: str, planned_devices: list[str], planned_device_aliases: dict[str, str] | None = None, requested_obs_modes: Sequence[ska_control_model.ObsMode] | None = None, scan_schedule: ScanSchedule | None = None) CommandContext
Build a command context with hard-coded semantics.
- Parameters:
obs_state_model – Observation state model used to retrieve the previous stable state.
task_name – Name of the command being executed.
command_id – Unique identifier of the command instance.
planned_devices – Devices involved in the command plan.
requested_obs_modes – Requested observation modes, if any.
- Returns:
A fully populated command context.
- ska_csp_lmc_common.observation.command_context_builder.build_configure_semantics(obs_modes: tuple[ska_control_model.ObsMode, ...], target_obsstate: ska_control_model.ObsState, planned_devices: Iterable[str]) CommandSemantics
Build Configure semantics for the current observation context.
The resolved family rules follow these principles:
CBF is always core.
PST is primary for pulsar timing without imaging, and commensal when pulsar timing is combined with imaging.
PSS is primary for search or transient modes without imaging, and commensal when those modes are combined with imaging.
Families not present in the command plan are omitted.
- ska_csp_lmc_common.observation.command_context_builder.resolve_scan_family_rules(obs_modes: tuple[ska_control_model.ObsMode, ...], planned_devices: Iterable[str]) dict[str, FamilyRule]
Resolve scan family rules for the current observation context.
- ska_csp_lmc_common.observation.command_context_builder.build_scan_semantics(obs_modes: tuple[ska_control_model.ObsMode, ...], target_obsstate: ska_control_model.ObsState, planned_devices: Iterable[str]) CommandSemantics
Build resolved Scan semantics for the current observation context.
- ska_csp_lmc_common.observation.command_context_builder.build_assign_semantics(target_obsstate: ska_control_model.ObsState, planned_devices: Iterable[str]) CommandSemantics
Build resolved Assign semantics.
- ska_csp_lmc_common.observation.command_context_builder.build_gotoidle_semantics(target_obsstate: ska_control_model.ObsState, planned_devices: Iterable[str]) CommandSemantics
Build resolved Assign semantics.
- ska_csp_lmc_common.observation.command_context_builder.build_release_semantics(target_obsstate: ska_control_model.ObsState, planned_devices: Iterable[str]) CommandSemantics
Build resolved Assign semantics.
- ska_csp_lmc_common.observation.command_context_builder.build_command_semantics(task_name, target_obsstate: ska_control_model.ObsState, planned_devices: Iterable[str]) CommandSemantics
Build resolved Assign semantics.