Scan Schedule
Scheduling model for Scan command observation-state evaluation.
This module defines the temporal model used to interpret Scan commands that
include scheduling metadata such as start_time and/or duration.
The schedule is used by the observation policy to derive the current scan phase from the current time. This allows CSP.LMC to distinguish between:
legacy scans, where no scheduling metadata is provided;
scans scheduled to start at a future
start_time;scans with a fixed
duration;scans with both
start_timeandduration.
ScanSchedule intentionally stores only the scheduling information derived
from the Scan command payload. Runtime information, such as the command
invocation time, is supplied separately when evaluating the phase. This keeps
payload-level metadata separated from command-context metadata.
- class ska_csp_lmc_common.observation.scan.schedule.ScanSchedule(scheduled_start: datetime | None = None, duration_s: float | None = None, start_transition_grace_s: float = 1.0, end_early_tolerance_s: float = 0.5, grace_after_end_s: float = 1.0)
Bases:
objectScheduling metadata extracted from a Scan command payload.
ScanSchedulerepresents the optional timing information supplied with a Scan command. It does not represent the command invocation time. When a duration is provided without an explicitstart_time, the effective start is resolved later fromCommandContext.start_time.- Parameters:
scheduled_start – Optional operational scan start time extracted from the Scan command
start_timefield. It isNonewhen no explicitstart_timeis provided; in duration-only scans, the effective start is resolved fromCommandContext.start_time.duration_s – Optional scan duration in seconds, extracted from the Scan command
durationfield.start_transition_grace_s – Grace period, in seconds, allowed after the effective scan start for subsystems to transition to
SCANNING.grace_after_end_s – Grace period, in seconds, allowed after the effective scan end for subsystems to return to
READY.
- effective_start(command_start_time: datetime) datetime
Return the effective start time for this scan.
If the Scan command payload contains
start_time, that value is used. Otherwise, the command invocation time from the command context is used. This supports theduration-only case, where the scan is treated as starting immediately when the Scan command is accepted or registered by CSP.LMC.- Parameters:
command_start_time – Command invocation time stored in the
CommandContext.- Returns:
The effective scan start time.
- effective_end(command_start_time: datetime) datetime | None
Return the effective end time for this scan, if duration is set.
If no duration is provided, the scan has no scheduled end and must be ended by
EndScan.- Parameters:
command_start_time – Command invocation time stored in the
CommandContext. It is used as the effective start when the payload does not containstart_time.- Returns:
The effective scan end time, or
Nonewhen the scan has no duration.
- classmethod from_scan_command(argin: dict[str, Any]) ScanSchedule | None
Create a scan schedule from the Scan command payload.
The method reads only payload-level scheduling metadata:
start_time: optional operational scan start time;duration: optional scan duration in seconds.
If neither field is present, the method returns
Noneto indicate legacy Scan behaviour.When
durationis provided withoutstart_time, the scan is treated as starting immediately when the Scan command is registered by CSP.LMC. This method still storesscheduled_start=Nonein that case: the effective start time is resolved later fromCommandContext.start_timewhen evaluating the schedule phase. This keeps explicit payload scheduling separated from runtime command-context metadata.- Parameters:
argin – Scan command input payload.
- Returns:
A
ScanSchedulewhen scheduling metadata is present, otherwiseNone.