Scan Events¶
The typed event hierarchy emitted by the scan engine. Every state transition, every device command, every error, and every dialog request is delivered as an instance of one of these classes through the on_event callback registered with ScanManager.
The narrative description of when each event fires and how to consume them lives at Architecture — Event vocabulary. This page is the formal API.
ScanState¶
The lifecycle states a scan can be in. Inherits str so values serialise naturally to JSON and log messages.
Bases: str, Enum
Lifecycle state of a scan.
Inherits str so values serialise naturally to JSON / log messages.
Attributes:
| Name | Type | Description |
|---|---|---|
IDLE |
|
|
INITIALIZING |
|
|
RUNNING |
|
|
PAUSED_ON_ERROR |
|
|
STOPPING |
|
|
DONE |
|
|
ABORTED |
|
Attributes¶
Base event¶
Base class for all scan events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
float
|
Wall-clock time of the event in seconds since the epoch
( |
time()
|
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
float
|
|
Lifecycle events¶
Bases: ScanEvent
Emitted at every :class:ScanState transition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ScanState
|
The state transitioned to. |
IDLE
|
total_shots
|
int
|
Total number of shots in the scan ( |
0
|
Attributes:
| Name | Type | Description |
|---|---|---|
state |
ScanState
|
|
total_shots |
int
|
|
timestamp |
float
|
|
Step progress¶
Bases: ScanEvent
Emitted at the start and completion of each scan step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_index
|
int
|
Zero-based index of the current step. |
0
|
total_steps
|
int
|
Total number of steps in the scan. |
0
|
shots_completed
|
int
|
Cumulative shots logged across all completed steps so far.
Together with |
0
|
phase
|
Literal['started', 'completed']
|
|
'started'
|
Attributes:
| Name | Type | Description |
|---|---|---|
step_index |
int
|
|
total_steps |
int
|
|
shots_completed |
int
|
|
phase |
Literal['started', 'completed']
|
|
timestamp |
float
|
|
Device command outcomes¶
Bases: ScanEvent
Emitted for every device command issued by the scan engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str
|
Device name (e.g. |
''
|
variable
|
str
|
Variable name (e.g. |
''
|
outcome
|
Literal['sent', 'accepted', 'rejected', 'failed', 'timeout']
|
Result of the command attempt.
|
'sent'
|
Attributes:
| Name | Type | Description |
|---|---|---|
device |
str
|
|
variable |
str
|
|
outcome |
Literal['sent', 'accepted', 'rejected', 'failed', 'timeout']
|
|
timestamp |
float
|
|
Errors and restore failures¶
Bases: ScanEvent
Emitted when the engine encounters a recoverable or fatal error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable description of what went wrong. |
''
|
recoverable
|
bool
|
|
True
|
exc
|
Optional[BaseException]
|
Originating exception, if available. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
message |
str
|
|
recoverable |
bool
|
|
exc |
Optional[BaseException]
|
|
timestamp |
float
|
|
Bases: ScanEvent
Emitted once per device that could not be restored after a scan.
The GUI accumulates these and shows a single warning dialog on the
ScanLifecycleEvent(DONE) transition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str
|
Device name that failed to restore. |
''
|
message
|
str
|
Description of the failure (exception message or context). |
''
|
Attributes:
| Name | Type | Description |
|---|---|---|
device |
str
|
|
message |
str
|
|
timestamp |
float
|
|
Dialog requests¶
Bases: ScanEvent
Carries a device-error dialog request across the worker→consumer boundary.
In Block 6 this event is emitted but the GUI still drains dialog_queue
as before. In Block 7 the GUI callback receives this event and posts it
to the Qt main thread via QMetaObject.invokeMethod; dialog_queue
is removed at that point.
The consumer must call request.response_event.set() after writing
the user's choice into request.abort[0]; the worker thread is
blocking on request.response_event.wait().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Optional[DialogRequest]
|
The :class: |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
request |
Optional[DialogRequest]
|
|
timestamp |
float
|
|