David's Astronomy Pages
|
Notes (S1389) |
Notes Main |
Home Page |
Notes (S1391) |
|
|
Session Aims & Highlights |
| - Observing Result - Night Summary Plot - Session Event Log |
|
|
|
Operational Issues |
| - Critical Issues (0),
Major Issues (0),
Minor Issues (3),
Small Defects (3), Continuous Improvement
(7) |
|
| - Figures (0) | |
![]() |
Images from 2026-01-13 >> |
| 2026-01-14 | |
|---|---|
![]() |
AstroMain - Refactoring Obs Manager's State Machine |
Main aims
Equipment & Software
Highlights
Summary Plots & Logs
Observing Plan ![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Observing Result |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dome & Scope Slewing Performance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Slew/Centering Performance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Guiding Performance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sky Conditions (Locate Frames) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Night Sky Summary Plot Top axis: Sky Brightness at Zenith (in ADU/s) Lefthand axis: Local Time (hh LT). Righthand axis: Sun Altitude (degs) Note: The NorthCam Star Count line is unreliable and should be ignored (The AstroNorthCam 'Find' Star method is producing many false positives from clouds) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Actual Weather vs Pre-Session Weather Forecast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Session Event Log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Session Alerts & Alarms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Back to Top
GetObjectFoldersList()
GetSharpCapFoldersList()
PageBuilder.SetupSession()-
Should SelectNightServices have a Title() above it.
-
Should SharpCap be promoted from SubTitle to Title
-
The line 'Fully Automated' is unnecessary in view of the
following 'Observatory Mode' block
-
Add a Title above AutoRestart's call to Start NightServices.
Still to do:
- How can the 'Operation.... Ok Completed (110s)
line better express the block that
it is measuring
the duration of, e.g by removing Tab2 ?
- The lines 'Checking ASCOM Scope..' & 'TurnOff Tracking; seem
out of place or are not titled. - introduce "(ok)" message type
and make row green during FinaliseLogs process (if not already done)
-
change "ObsMonitor has resumed", "UI has resumed" message to use
"(ok)" keyword
- set LAN, Router Ping timeouts to "(warn)" Set
Ping success again to "(ok)"
- change "Object is currently in
use elsewhere" exception from "(error)" to "(warn)"
- include
'first successful CCD GetProperty request following a prior time'
message with "(ok)" keyword
- suppress logging of
GreenhouseEvents during Live Sessions
- change "FailSafeLink"
failures from "(fail)" to "(warn)"
- change
"ReadLastMagRecords" failures from "(fail)" to "(warn)"
-
change "CalculateImageShift" failures (nInventory=0) from "(fail)" to
"(warn)"
- when starting session change "Start AstroMain"
to "Report AstroMain"
- add header for Program Versions
List
- add logging of AutoWaiting Progression
Still to do:
- consider
reducing threshold for ObsManager is frozen to include case which were
previously 'pending'
- review handling of PHD2.GetlockPosition
exception : "conversion "null" to 'Double' - when Finalising Log, use AddComment
("Finalise Trace File" for the trace file version of the log file
-
include 'General' in message "Closing Files for 'General/Live/Test'
Session 2026-01-14"
- swap the order of 'Delaying Autostart
Unable to begin..' and 'Current Conditions' Back to Top Issue, Back to Top
Over an extended period, the Observatory Manager (ObsManager) has undergone a major internal redesign focused on improving clarity, reliability, and long-term maintainability. The original control logic, built up over many years, worked well but had evolved into a large collection of conditional blocks and interdependent flags. This made the system harder to reason about, especially in safety-critical areas such as weather handling, suspension, and shutdown.
To address this, the entire session-control architecture has been re-implemented using a clear, explicit state machine. The goal was not to change behaviour, but to make the behaviour transparent, traceable, and future-proof. The new design preserves the operational rules of the legacy system while giving the codebase a modern, readable structure.
Before any refactoring, the legacy control flow was carefully mapped and documented. All session states and transitions were identified, and the following areas were analysed in depth:
This analysis ensured that the new state machine would be behaviour-preserving and safe, with no loss of subtle legacy behaviour.
The new architecture is built around a simple principle: each session state has a single, dedicated handler responsible for its own behaviour. A central dispatcher routine, StateMachineStep, routes control to the appropriate handler based on the current SessionState. This makes the control flow explicit and easy to follow.
Key design choices include:
The StateMachineStep routine now uses a Select Case structure to delegate to state-specific handlers, for example:
Sub StateMachineStep()
Select Case SessionState
Case SessionState.Manual
' No handler for Manual
Case SessionState.AutoWaiting
handleAutowaiting()
Case SessionState.AutoStarting
handleAutoStarting()
Case SessionState.Pending
handlePending()
Case SessionState.Initiating
handleInitiating()
Case SessionState.Starting
handleStarting()
Case SessionState.Equilibrating
handleEquilibrating()
Case SessionState.Running
handleRunning()
Case SessionState.Suspending
handleSuspending()
Case SessionState.Suspended
handleSuspended()
Case SessionState.Resuming
handleResuming()
Case SessionState.Continuing
handleContinuing()
Case SessionState.Closing
handleClosing()
Case SessionState.Finishing
handleFinishing()
Case SessionState.Finished
handleFinished()
Case SessionState.Stopped
handleStopped()
Case SessionState.Undefined
' No handler for Undefined
End Select
End Sub
This dispatcher acts as a readable map of the entire session lifecycle.
The Running state is the most complex and safety-critical part of the system. It has been refactored into a clear monitoring loop that:
The top-level structure of handleRunning now looks like:
Sub handleRunning()
Dim Reason As Integer
gObsManagerSection = "Running"
Try
If jobPause = True Then jobPause = False
handleRunningReportWeatherChanges()
handleRunningCheckSoftSuspendTrigger(Reason)
If PendingToO > 0 Then
gObsManagerSection = "Running - Handling Pending ToO Targets"
HandleToO()
End If
If bHardSuspend Or bSoftSuspend Then
gObsManagerSection = "Running - Handling Suspension Calls"
If bSuspendOk Then
handleRunningSoftSuspendReasonCorrection(Reason)
SetState_Suspending()
Exit Sub
Else
If bHardSuspend Then
handleRunningHardSuspendEscalation()
End If
If bSoftSuspend And bUnderOutageManagement <> True Then
handleRunningSoftSuspendCancellation(Reason)
End If
End If
End If
gObsManagerSection = "Running - Check for Frozen Job Queue"
If bFrozenJobQueue Then
handleRunningFrozenQueue()
End If
Catch ex As Exception
WriteLogFileRecord(szTargetName + " (Manager)", "Alert", "(error)", "Exception",
"Exception in SM: handleRunning()")
WriteLogFileRecord(szTargetName + " (Manager)", "Alert", "(error)", "Exception",
ex.Message)
End Try
End Sub
Each helper routine encapsulates a single responsibility, making the Running state easier to understand and maintain.
The shutdown sequence has been carefully refactored into clear, staged handlers for:
Each stage uses a consistent StageResult pattern (Proceed, Break) and has concise comments describing its purpose. The behaviour matches the legacy implementation exactly.
The Stopped state is a terminal state that coincides with the stopping of the main ObsManager loop. Its handler is intentionally minimal:
Sub handleStopped()
gObsManagerSection = "Stopped"
Try
ReportComment(Tab2 + "SessionState = Stopped")
Catch ex As Exception
WriteLogFileRecord(szTargetName + " (Manager)", "Alert", "(error)", "Exception",
"Exception in SM: handleStopped")
WriteLogFileRecord(szTargetName + " (Manager)", "Alert", "(error)", "Exception",
ex.Message)
End Try
End Sub
Because the main loop stops when entering Stopped, this message is emitted at most once.
To allow safe migration, a configuration flag controls whether the new state machine or the legacy logic is used:
If bUseStateMachine Then
StateMachineStep()
Else
' Legacy control path (series of If...End If blocks)
End If
This allows the new architecture to be tested in real conditions while retaining the ability to revert instantly to the legacy behaviour.
The new state machine has been validated through:
All observed behaviour matches the legacy system, with improved clarity and traceability in the code.
This refactor represents a significant architectural improvement to the Observatory Manager. The system is now clearer, safer, and easier to maintain, while preserving the behaviour that users rely on. The new state machine provides a solid foundation for future enhancements without compromising operational stability.
The main session states handled by the state machine are:
Each state has a corresponding handler routine, except Manual and Undefined, which intentionally have no automated behaviour.
Key helper routines used within handleRunning include:
These routines encapsulate:
Suspension behaviour is governed by the following flags and conditions:
High-level rules:
Each state handler that performs non-trivial work is wrapped in a Try/Catch block. Exceptions are logged using WriteLogFileRecord with sufficient context to diagnose issues without crashing the main loop. This is particularly important in long-running automation where robustness is critical.
The boolean flag bUseStateMachine controls whether the new state machine or the legacy control path is used. This allows:
Back to Top
| This Web Page: | Notes - Session 1390 (2026-01-13) |
| Last Updated : | 2026-03-04 |
| Site Owner : | David Richards |
| Home Page : | David's Astronomy Web Site |