Source code for magscope.ipc_commands

from __future__ import annotations

from dataclasses import dataclass
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from magscope.scripting import ScriptStatus
    from magscope.settings import MagScopeSettings
    from magscope.utils import AcquisitionMode


@dataclass(frozen=True)
[docs] class Command: """Typed IPC payload sent between processes."""
@dataclass(frozen=True)
[docs] class QuitCommand(Command): """Request that all manager processes exit."""
@dataclass(frozen=True)
[docs] class SetSettingsCommand(Command):
[docs] settings: "MagScopeSettings"
@dataclass(frozen=True)
[docs] class UpdateSettingsCommand(Command):
[docs] settings: "MagScopeSettings"
@dataclass(frozen=True)
[docs] class UpdateTrackingOptionsCommand(Command):
[docs] value: dict
@dataclass(frozen=True)
[docs] class SetAcquisitionOnCommand(Command):
[docs] value: bool
@dataclass(frozen=True)
[docs] class WaitUntilAcquisitionOnCommand(Command):
[docs] value: bool
@dataclass(frozen=True)
[docs] class SetAcquisitionDirOnCommand(Command):
[docs] value: bool
@dataclass(frozen=True)
[docs] class SetAcquisitionModeCommand(Command):
[docs] mode: "AcquisitionMode"
@dataclass(frozen=True)
[docs] class SetAcquisitionDirCommand(Command):
[docs] value: str | None
@dataclass(frozen=True)
[docs] class UpdateBeadRoisCommand(Command): pass
@dataclass(frozen=True)
[docs] class LogExceptionCommand(Command):
[docs] process_name: str
[docs] details: str
@dataclass(frozen=True)
[docs] class StartupReadyCommand(Command):
[docs] process_name: str = "UIManager"
@dataclass(frozen=True)
[docs] class UpdateCameraSettingCommand(Command):
[docs] name: str
[docs] value: str
@dataclass(frozen=True)
[docs] class SetSimulatedFocusCommand(Command):
[docs] offset: float
@dataclass(frozen=True)
[docs] class MoveFocusMotorAbsoluteCommand(Command):
[docs] z: float
@dataclass(frozen=True)
[docs] class RequestFocusMotorLimitsCommand(Command): pass
@dataclass(frozen=True)
[docs] class ReportFocusMotorLimitsCommand(Command):
[docs] z_min: float
[docs] z_max: float
@dataclass(frozen=True)
[docs] class UpdateVideoBufferPurgeCommand(Command):
[docs] t: float
@dataclass(frozen=True)
[docs] class MoveBeadsCommand(Command):
[docs] moves: list[tuple[int, int, int]]
@dataclass(frozen=True)
[docs] class AddRandomBeadsCommand(Command):
[docs] count: int
[docs] seed: int | None = None
@dataclass(frozen=True)
[docs] class UpdateXYLockEnabledCommand(Command):
[docs] value: bool
@dataclass(frozen=True)
[docs] class UpdateXYLockIntervalCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class UpdateXYLockMaxCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class UpdateXYLockWindowCommand(Command):
[docs] value: int
@dataclass(frozen=True)
[docs] class UpdateZLockEnabledCommand(Command):
[docs] value: bool
@dataclass(frozen=True)
[docs] class UpdateZLockBeadCommand(Command):
[docs] value: int
@dataclass(frozen=True)
[docs] class UpdateZLockTargetCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class UpdateZLockIntervalCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class UpdateZLockMaxCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class UpdateZLockWindowCommand(Command):
[docs] value: int
@dataclass(frozen=True)
[docs] class UpdateScriptStatusCommand(Command):
[docs] status: "ScriptStatus"
@dataclass(frozen=True)
[docs] class UpdateScriptStepCommand(Command): """Report the currently executing script step to the GUI."""
[docs] current_step: int | None
[docs] total_steps: int
[docs] description: str | None
@dataclass(frozen=True)
[docs] class ShowMessageCommand(Command):
[docs] text: str
[docs] details: str | None = None
@dataclass(frozen=True)
[docs] class ShowErrorCommand(Command):
[docs] text: str
[docs] details: str | None = None
@dataclass(frozen=True)
[docs] class UpdateZLUTMetadataCommand(Command):
[docs] filepath: str | None = None
[docs] z_min: float | None = None
[docs] z_max: float | None = None
[docs] step_size: float | None = None
[docs] profile_length: int | None = None
@dataclass(frozen=True)
[docs] class LoadZLUTCommand(Command):
[docs] filepath: str
@dataclass(frozen=True)
[docs] class UnloadZLUTCommand(Command): """Clear the currently loaded Z-LUT."""
@dataclass(frozen=True)
[docs] class StartZLUTGenerationCommand(Command):
[docs] start_nm: float
[docs] step_nm: float
[docs] stop_nm: float
[docs] profiles_per_bead: int
@dataclass(frozen=True)
[docs] class CancelZLUTGenerationCommand(Command): pass
@dataclass(frozen=True)
[docs] class UpdateZLUTGenerationStateCommand(Command):
[docs] status: str
[docs] detail: str | None = None
[docs] running: bool = False
[docs] can_cancel: bool = False
[docs] phase: str = 'idle'
[docs] z_axis_min_nm: float | None = None
[docs] z_axis_max_nm: float | None = None
[docs] z_axis_descending: bool = False
@dataclass(frozen=True)
[docs] class UpdateZLUTGenerationProgressCommand(Command):
[docs] current_step: int
[docs] total_steps: int
[docs] capture_count: int
[docs] capture_capacity: int
[docs] motor_z_value: float | None = None
@dataclass(frozen=True)
[docs] class UpdateZLUTGenerationEvaluationCommand(Command):
[docs] active: bool
[docs] bead_ids: list[int]
[docs] selected_bead_id: int | None = None
@dataclass(frozen=True)
[docs] class SelectGeneratedZLUTBeadCommand(Command):
[docs] bead_id: int
@dataclass(frozen=True)
[docs] class SaveGeneratedZLUTCommand(Command):
[docs] filepath: str
[docs] bead_id: int
[docs] load_after_save: bool = True
@dataclass(frozen=True)
[docs] class CancelGeneratedZLUTEvaluationCommand(Command): pass
@dataclass(frozen=True)
[docs] class RequestProfileLengthCommand(Command): pass
@dataclass(frozen=True)
[docs] class ReportProfileLengthCommand(Command):
[docs] profile_length: int | None = None
@dataclass(frozen=True)
[docs] class RequestZLUTProfileLengthCommand(Command):
[docs] bead_ids: tuple[int, ...] = ()
[docs] bead_rois: tuple[tuple[int, int, int, int], ...] = ()
@dataclass(frozen=True)
[docs] class ReportZLUTProfileLengthCommand(Command):
[docs] profile_length: int | None = None
@dataclass(frozen=True)
[docs] class ClearPendingZLUTProfileLengthCommand(Command): pass
@dataclass(frozen=True)
[docs] class ArmZLUTSweepCaptureCommand(Command):
[docs] step_index: int
[docs] motor_z_value: float
[docs] remaining_profiles_per_bead: int
[docs] earliest_timestamp: float
[docs] bead_ids: tuple[int, ...] = ()
[docs] bead_rois: tuple[tuple[int, int, int, int], ...] = ()
@dataclass(frozen=True)
[docs] class DisarmZLUTSweepCaptureCommand(Command): pass
@dataclass(frozen=True)
[docs] class ZLUTSweepCaptureCompleteCommand(Command):
[docs] step_index: int
[docs] written_count: int
[docs] written_profiles_per_bead: int
[docs] error: str | None = None
@dataclass(frozen=True)
[docs] class RemoveBeadFromPendingMovesCommand(Command):
[docs] id: int
@dataclass(frozen=True)
[docs] class RemoveBeadsFromPendingMovesCommand(Command):
[docs] ids: list[int]
@dataclass(frozen=True)
[docs] class SetXYLockOnCommand(Command):
[docs] value: bool
@dataclass(frozen=True)
[docs] class ExecuteXYLockCommand(Command):
[docs] now: float | None = None
@dataclass(frozen=True)
[docs] class SetXYLockIntervalCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class SetXYLockMaxCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class SetXYLockWindowCommand(Command):
[docs] value: int
@dataclass(frozen=True)
[docs] class SetZLockOnCommand(Command):
[docs] value: bool
@dataclass(frozen=True)
[docs] class SetZLockBeadCommand(Command):
[docs] value: int
@dataclass(frozen=True)
[docs] class SetZLockTargetCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class SetZLockIntervalCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class SetZLockMaxCommand(Command):
[docs] value: float
@dataclass(frozen=True)
[docs] class SetZLockWindowCommand(Command):
[docs] value: int
@dataclass(frozen=True)
[docs] class GetCameraSettingCommand(Command):
[docs] name: str
@dataclass(frozen=True)
[docs] class SetCameraSettingCommand(Command):
[docs] name: str
[docs] value: str
@dataclass(frozen=True)
[docs] class LoadScriptCommand(Command):
[docs] path: str
@dataclass(frozen=True)
[docs] class StartScriptCommand(Command): """Start the currently loaded script."""
@dataclass(frozen=True)
[docs] class PauseScriptCommand(Command): """Pause the running script."""
@dataclass(frozen=True)
[docs] class ResumeScriptCommand(Command): """Resume a paused script."""
@dataclass(frozen=True)
[docs] class SleepCommand(Command):
[docs] duration: float
@dataclass(frozen=True)
[docs] class UpdateWaitingCommand(Command): """Signal that a wait condition has been satisfied."""