David's Astronomy Pages
Notes - Session 1390 (2026-01-13 )

 
Bullet Session Aims & Highlights
 - Observing Result
 - Night Summary Plot
 - Session Event Log
Bullet Operational Issues
- Critical Issues (0),  Major Issues (0),  Minor Issues (3),  Small Defects (3),  Continuous Improvement (7)
- Figures (0)
   
Bullet Images from 2026-01-13  >>           
   
2026-01-14
Bullet AstroMain - Refactoring Obs Manager's State Machine
   

Session Aims & Highlights (2026-01-13)

Main aims

  1. Targets.  Acquire images of a selection of variable stars, nearby stars, comets & deep sky targets as allowed by sky conditions.
  2. AstroMain. Check overall stability and capability of AstroMain 3.80 following significant sofftware changes since the previous session at end of Dec 2025.
  3. ObsComm.  Carry out first live Observatory session using new ObsComm UDP communication between AstroMain, AstroPlan and AstroObsCam
  4. Active Session Pipeline. Carry out first live Observatory session using AstroMain's new Create/Reopen Session pipeline

 Equipment & Software

Highlights

NotesNotes

Summary Plots & Logs

Observing Plan
Image
  
Observing Result
Image
   
Image
 
Dome & Scope Slewing Performance
Image
  
Slew/Centering Performance
Image
  
Guiding Performance
Image
  
Sky Conditions (Locate Frames)
Image 
  
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)
Image   
  
Actual Weather vs Pre-Session Weather Forecast
Image
Image
 
Session Event Log
Time     Event Detail
18:04:44 Session Monitoring AutoStart monitoring for Live Session opportunity between 18:04 & 06:39
18:04:48 Session AutoStarting Session autostarting (18:04)
18:04:58 Session Created Session Created (Live, 2026-01-13 S01390)
18:05:01   CCDSoft Restarting CCDSoft being restarted (to set AutoSave No.)
18:05:20   Scope Switched On Telescope Power has been switched on via UPB Switch
18:07:08   Services Started Observatory Services started
18:07:19 Observatory (Auto) Observatory placed in Fully-Automated Mode
18:07:23 Session Pending Session pending (2026-01-13)
18:07:25 Session Initiating Session initiating (2026-01-13)
18:07:44   Camera1 Connected SBIG Camera connected (Set point -25°C)
18:07:47   Plan Requested Observing Plan requested from AstroPlan (1.46)
18:08:34   Plan Loaded Observing Plan loaded to queue (Plan ID: 1180)
18:08:43 Session Resumed Session Resumed (Live, 2026-01-13 S01390)
18:08:47   Telescope Connected Telescope connected (TheSky6)
18:09:14 Session Equilibration Session ready to Open Dome
18:10:00   Dome Opened Dome opened (Opening time 45s, Zigbee 41s)
18:10:02   Shutter Battery Shutter battery level has fallen below 88%
18:10:50 Session Running Session running
18:10:53   Queue Started Observing Queue started (42 targets selected)
18:10:57     Target Started (NrZen) Target started (Focus Field 2, HIP 9508)
18:11:12       Dome Unparked Dome unparked
18:15:26       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
18:18:00       Focusing Completed Foc1 AutoFocus Completed (Profile No 1, wide)
18:20:14       Focusing Completed Foc1 AutoFocus Completed (Profile No 1)
18:20:18       Focusing Started-Foc2 Foc2 Focusing Started (Secondary Scope, using ShCap)
18:22:16       Focusing Completed Foc2 AutoFocus Completed (Profile No 2, wide)
18:24:05       Focusing Completed Foc2 AutoFocus Completed (Profile No 2)
18:24:26     Target Completed (NrZen) Target completed (Focus Field 2, HIP 9508)
18:24:31     Target Started (1/42) Target started (1/42, Gliese 65)
18:30:07       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
18:37:00     Target Completed Target completed (1/42, Gliese 65)
18:37:12     Target Started (2/42) Target started (2/42, GCVS TT Ari)
18:40:52       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
18:43:37       Focusing Completed Foc1 AutoFocus Completed (Profile No 3)
18:50:05     Target Completed Target completed (2/42, GCVS TT Ari)
18:50:09     Target Started (3/42) Target started (3/42, AT2025adhw)
18:54:24       Focusing Skipped Foc1 focusing skipped - star is lost (TCF-LSI)
19:10:34     Target Completed Target completed (3/42, AT2025adhw)
19:12:28     Target Started (4/42) Target started (4/42, NGC 1325)
19:17:05       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
19:33:27     Target Completed Target completed (4/42, NGC 1325)
19:34:48     Target Started (5/42) Target started (5/42, UGCA 77)
19:38:46       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
19:55:25     Target Completed Target completed (5/42, UGCA 77)
19:57:08     Target Started (6/42) Target started (6/42, GSC 1224:29)
20:00:36       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
20:07:44     Target Completed Target completed (6/42, GSC 1224:29)
20:09:36     Target Started (7/42) Target started (7/42, NGC 1588 w/AT2025ajvt)
20:13:40       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
20:16:17       Focusing Completed Foc1 AutoFocus Completed (Profile No 4)
20:32:21     Target Completed Target completed (7/42, NGC 1588 w/AT2025ajvt)
20:32:25     Target Started (8/42) Target started (8/42, 240P/NEAT)
20:36:03       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
20:46:44     Target Completed Target completed (8/42, 240P/NEAT)
20:48:21     Target Started (9/42) Target started (9/42, AT2022vdr (CV))
20:51:51       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
20:54:40       Focusing Completed Foc1 AutoFocus Completed (Profile No 5)
21:00:45     Target Completed Target completed (9/42, AT2022vdr (CV))
21:00:49     Target Started (10/42) Target started (10/42, C/2022 N2 (PANSTARRS))
21:04:29       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
21:07:07       Focusing Completed Foc1 AutoFocus Completed (Profile No 6)
21:15:27     Target Completed Target completed (10/42, C/2022 N2 (PANSTARRS))
21:15:32     Target Started (11/42) Target started (11/42, NGC 1407)
21:22:04       Focusing Skipped Foc1 focusing skipped - star is lost (TCF-LSI)
21:33:20     Target Completed Target completed (11/42, NGC 1407)
21:33:24     Target Started (12/42) Target started (12/42, 61 Cyg)
21:36:33       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
21:38:49       Focusing Completed Foc1 AutoFocus Completed (Profile No 7)
21:40:51     Target Completed Target completed (12/42, 61 Cyg)
21:40:55     Target Started (13/42) Target started (13/42, GCVS BL Lac)
21:44:30       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
21:46:57       Focusing Completed Foc1 AutoFocus Completed (Profile No 8)
21:50:48     Target Completed Target completed (13/42, GCVS BL Lac)
21:50:53     Target Started (14/42) Target started (14/42, C/2022 E2 (ATLAS))
21:54:42       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
22:03:36     Target Completed Target completed (14/42, C/2022 E2 (ATLAS))
22:04:56     Target Started (15/42) Target started (15/42, M31 w/M31N 2025-10a?)
22:08:29       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
22:11:23       Focusing Completed Foc1 AutoFocus Completed (Profile No 9)
22:27:43     Target Completed Target completed (15/42, M31 w/M31N 2025-10a?)
22:27:47     Target Started (16/42) Target started (16/42, UGC 525 w/SN2025ahxd)
22:31:21       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
22:47:29     Target Completed Target completed (16/42, UGC 525 w/SN2025ahxd)
22:49:16     Target Started (17/42) Target started (17/42, GCVS DX Cnc)
22:53:01       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
22:58:42     Target Completed Target completed (17/42, GCVS DX Cnc)
23:00:29     Target Started (18/42) Target started (18/42, UGC 5381 w/SN2025ahep)
23:03:49       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
23:06:39       Focusing Completed Foc1 AutoFocus Completed (Profile No 10)
23:23:14     Target Completed Target completed (18/42, UGC 5381 w/SN2025ahep)
23:23:18     Target Started (19/42) Target started (19/42, NGC 3106 w/SN2025aauj)
23:26:38       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
23:42:46     Target Completed Target completed (19/42, NGC 3106 w/SN2025aauj)
23:44:49     Target Started (20/42) Target started (20/42, M99 w/AT2026X)
23:49:01       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
00:05:26     Target Completed Target completed (20/42, M99 w/AT2026X)
00:06:49     Target Started (21/42) Target started (21/42, WDS GRB 34)
00:11:16       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
00:13:46       Focusing Completed Foc1 AutoFocus Completed (Profile No 11)
00:15:59     Target Completed Target completed (21/42, WDS GRB 34)
00:16:02   Queue Aborted Job Queue aborted
00:16:16   Services Stopped Observatory Services stopped
00:18:57 Session Resumed Session Resumed (Live, 2026-01-13 S01390)
00:18:59   CCDSoft Restarting CCDSoft being restarted (to set AutoSave No.)
00:19:29   Obs.Manager Started Obs.Manager started
00:19:35   Services Started Observatory Services started
00:20:10   Camera1 Connected SBIG Camera connected (Set point -25°C)
00:20:28 Session Monitoring AutoStart monitoring for Live Session opportunity between 00:20 & 06:39
00:20:30 Observatory (AutoStart) Observatory placed in Auto-Start Mode
00:21:20 Session AutoStarting Session autostarting (00:21)
00:21:30 Session Resumed Session Resumed (Live, 2026-01-13 S01390)
00:22:16   Services Started Observatory Services started
00:22:27 Observatory (Auto) Observatory placed in Fully-Automated Mode
00:22:30 Session Pending Session pending (2026-01-13)
00:22:32 Session Initiating Session initiating (2026-01-13)
00:22:42   Camera1 Connected SBIG Camera connected (Set point -25°C)
00:22:54   Plan Loaded Observing Plan loaded to queue (Plan ID: 1180)
00:23:00 Session Resumed Session Resumed (Live, 2026-01-13 S01390)
00:23:04   Telescope Connected Telescope connected (TheSky6)
00:23:25 Session Running Session running
00:23:28   Queue Started Observing Queue started (21 targets selected)
00:23:31     Target Missed (22/42) Target's time slot was missed (22/42, GCVS HH And)
00:23:35     Target Started (23/42) Target started (23/42, AT2025aiov)
00:29:10       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
00:31:31       Focusing Completed Foc1 AutoFocus Completed (Profile No 14)
00:47:34     Target Completed Target completed (23/42, AT2025aiov)
00:47:38     Target Started (24/42) Target started (24/42, AT2025aglw)
00:51:43       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
00:54:28       Focusing Completed Foc1 AutoFocus Completed (Profile No 15)
01:10:47     Target Completed Target completed (24/42, AT2025aglw)
01:10:51     Target Started (25/42) Target started (25/42, AT2025agtl)
01:31:56     Target Completed Target completed (25/42, AT2025agtl)
01:32:00     Target Started (26/42) Target started (26/42, UGC 4316 w/SN2025advo)
01:36:02       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
01:38:43       Focusing Completed Foc1 AutoFocus Completed (Profile No 16)
01:54:45     Target Completed Target completed (26/42, UGC 4316 w/SN2025advo)
01:54:49     Target Started (27/42) Target started (27/42, GCVS SY Cnc)
01:57:57       Focusing Skipped Foc1 focusing skipped - star is too dim (TCF-LSI)
02:01:12     Target Completed Target completed (27/42, GCVS SY Cnc)
02:01:16     Target Started (28/42) Target started (28/42, AT2025ahjt (CV))
02:05:14       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
02:07:36       Focusing Completed Foc1 AutoFocus Completed (Profile No 17)
02:24:25     Target Completed Target completed (28/42, AT2025ahjt (CV))
02:24:29     Target Started (29/42) Target started (29/42, VV 410 w/SN2025hjz)
02:29:04       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
02:31:47       Focusing Completed Foc1 AutoFocus Completed (Profile No 18)
02:47:47     Target Completed Target completed (29/42, VV 410 w/SN2025hjz)
02:47:51     Target Started (30/42) Target started (30/42, 29P/Schwassmann-Wachmann)
02:52:12       Focusing Skipped Foc1 focusing skipped - star is lost (TCF-LSI)
03:07:53     Target Completed Target completed (30/42, 29P/Schwassmann-Wachmann)
03:07:57     Target Started (31/42) Target started (31/42, NGC 3962)
03:11:36       Focusing Started-Foc1 Foc1 Focusing Started (TCF-S)
03:14:12       Focusing Completed Foc1 AutoFocus Completed (Profile No 19)
03:30:29     Target Completed Target completed (31/42, NGC 3962)
03:30:33     Target Started (32/42) Target started (32/42, NGC 4039)
03:52:42       SoftSuspend Called Soft Suspend called due to Deteriorating Conditions (too few stars)
03:52:58     Target Completed Target completed (32/42, NGC 4039)
03:53:00   Queue Paused Queue paused for Session Suspension
03:53:02 Session Suspending Session suspending
03:53:52   Dome Closed Dome closed (Closing time 50s, Zigbee 44s)
03:53:53 Session Suspended Session suspended
04:10:41     Target Cancelled Target cancelled (33/42, UGCA 285) due to cloud
04:33:01     Target Cancelled Target cancelled (34/42, NGC 5049) due to cloud
04:55:01     Target Cancelled Target cancelled (35/42, MCG -3-34-59 w/SN2023gb) due to cloud
05:17:21     Target Cancelled Target cancelled (36/42, MCG +7-28-15 w/SN2025adje) due to cloud
05:30:47     Target Cancelled Target cancelled (37/42, T CrB) due to cloud
05:50:17     Target Cancelled Target cancelled (38/42, NGC 4653 w/SN2025mqc) due to cloud
06:12:37     Target Cancelled Target cancelled (39/42, CGCG 073-009 w/SN2024kbl) due to cloud
06:26:37     Target Cancelled Target cancelled (40/42, AT2025sdf (CV)) due to cloud
06:36:55     Target Cancelled Target cancelled (41/42, GCVS CY Lyr) due to cloud
07:07:16     Target Cancelled Target cancelled (42/42, M89) due to cloud
07:07:20   Queue Completed Job Queue completed
07:07:26 Session Closing Session closing
07:07:31   Dome Closed Dome already closed (closed at 03:53, closing time 50s, zigbee 44s)
07:08:21   Dome Parked Dome parked (parking time 41s), Az: 90.1 deg
07:08:55   Telescope Parked Telescope parked (parking time 29s total)
07:09:19   Telescope State Handbox reads 'Scope parked Turn scope off.'
07:10:22   Telescope Switched Off Telescope Power has been switched off via UPB Switch.
07:11:48   Services Stopped Night Services stopped
07:11:51 Session Finishing Session Finishing started (Create Fits Summary, Transfer Files)
07:13:18     Dome (Find Park) Find Park started (Search Az 88.0 to 92.0°, Step 0.2°, Narrow)
07:14:05     Dome Find Park found (Best Park Az 89.8°)
07:14:11     Dome Dome has been synced at park position (Az 90.0°, Adjustment: +0.1°)
07:14:13   Dome Parked Dome parked
07:16:46   Dome Charging Dome is parked and re-charging Ok (16mA)
07:16:48 Session Finished Session Finished
 
Session Alerts & Alarms
Time     Type       Name Detail
18:10:00 Yellow Alert Shutter Battery Shutter battery level has fallen below 88%
18:12:25 Green Clear Shutter Battery Shutter battery level has climbed above 95%
07:16:46 Green Clear Dome Charging Dome is parked and re-charging Ok (16mA)
 

Back to Top


Operational Issues (2026-01-13 S1390)

[ Prev | Next ]

Critical Issues

Major Issues

Minor Issues

Small Defects

Continuous Improvement

[ Prev | Next ]

Back to Top Issue,  Back to Top


2026-01-14


AstroMain - Refactoring ObsManager's State Machine

Introduction

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.

Objectives


Analysis Phase

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.

Design Approach

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:


Implementation Highlights

1. State Machine Dispatcher

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.

2. Refactored Running State

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.

3. Closing, Finishing, and Finished Pipelines

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.

4. Stopped State

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.

5. Dual-Path Architecture

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.


Testing and Validation

The new state machine has been validated through:

All observed behaviour matches the legacy system, with improved clarity and traceability in the code.


Conclusion

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.


Technical Appendix

A. State Overview

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.

B. Running State Helper Routines

Key helper routines used within handleRunning include:

These routines encapsulate:

C. Suspension Logic Summary

Suspension behaviour is governed by the following flags and conditions:

High-level rules:

D. Error Handling

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.

E. Migration Control Flag

The boolean flag bUseStateMachine controls whether the new state machine or the legacy control path is used. This allows:

Back to Top