8.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T04:00:35.991960+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | dc1b1b8c07850591 |
States
Documentation: StateMachine States Module
1. Purpose
This module defines the concrete state implementations for the DAS (Data Acquisition System) service state machine. Each class represents a terminal or selector state in the state transition graph, encapsulating entry actions and transition logic. The states manage transitions between operational modes such as hardware discovery, configuration, arming, real-time acquisition, and data download. The module serves as the behavioral core of the state machine, where transitions are determined by runtime status flags and configuration parameters.
2. Public Interface
All classes inherit from DASState (or DASStateSelector for selector states) in the DTS.DASLib.Service.StateMachine namespace. Only Realtime, ConfigureStart, RealtimeStart, Configure, Diagnose, DownloadStart, and HardwareDiscoveryStart are public; the rest are internal.
Terminal States (non-selector, inherit DASState)
-
public class Realtime : DASState
Represents the active real-time acquisition state. ReturnsState.Realtimevia theStateproperty. No custom entry action. -
internal class Arm : DASState
Represents the armed (ready but not yet acquiring) state. ReturnsState.Arm. -
internal class Arming : DASState
Represents the transitional arming state. ReturnsState.Arming. -
internal class Download : DASState
Represents the data download state. ReturnsState.Download. -
internal class HardwareDiscovery : DASState
Represents the hardware discovery state. ReturnsState.HardwareDiscovery. -
internal class Prepare : DASState
Represents the prepare state. OverridesOnEntryto invokePrepareDASFactory, which detaches all devices and clears host name arrays inDASFactory(if non-null). ReturnsState.Prepare.
Selector States (inherit DASStateSelector)
-
public class ConfigureStart : DASStateSelector
Entry action:ApplyConfig, which callsStatus.ConfigureStatus.ApplyConfig().
Selector logic: Always returnsStates.Instance.Diagnose.
ReturnsState.ConfigureStart. -
public class RealtimeStart : DASStateSelector
Entry action:Start, which callsStatus.RealtimeStatus.StartRealtime().
Selector logic:- If
Status.RealtimeStatus.CouldNotStartRealtimeis true → returnsStates.Instance.RealtimeStart(retry loop). - Else → returns
States.Instance.Realtime.
ReturnsState.RealtimeStart.
- If
-
public class Configure : DASStateSelector
Selector logic:AllowApplyConfig()currently always returnstrue(placeholder logic).- If true → returns
States.Instance.ConfigureStart. - Else → returns
States.Instance.Configure(self-loop).
ReturnsState.Configure.
-
public class Diagnose : DASStateSelector
Selector logic:- Returns
States.Instance.RealtimeStartif either:
(a)Status.DiagnoseParams.ProceedToRealtimeWhenDone && Status.DiagnoseParams.AllUnitsPassedDiagnostic, or
(b)Status.DiagnoseParams.ProceedToRealtimeWhenDone && !Status.DiagnoseParams.RequireAllUnitsPassDiagnostic. - Else → returns
States.Instance.Diagnose(self-loop).
ReturnsState.Diagnose.
- Returns
-
public class DownloadStart : DASStateSelector
Entry action:Start, which callsStatus.DownloadStatusInfo.Download().
Selector logic:- Returns
States.Instance.PrepareifCanTransitToPrepare()is true:
Status.DownloadParams.ProceedWhenDone && (Status.DownloadStatusInfo.AllDASFinished || !Status.DownloadParams.RequireAllDASFinish). - Else → returns
States.Instance.Download(self-loop).
ReturnsState.DownloadStart.
- Returns
-
public class HardwareDiscoveryStart : DASStateSelector
Entry action:Start, which calls eitherRequeryDevice()orPing()onStatus.HardwareDiscoveryStatusInfo, depending on whetherStatus.HardwareDiscoveryParams.RequeryDeviceis non-null.
Selector logic (evaluated in order):CanTransitToDownload()→ returnsStates.Instance.DownloadCanTransitToConfigure()→ returnsStates.Instance.ConfigureCanTransitToArm()→ returnsStates.Instance.Arm- Else → returns
States.Instance.HardwareDiscovery(self-loop)
Where: CanTransitToConfigure():Status.HardwareDiscoveryParams.ProceedWhenDone && (Status.HardwareDiscoveryStatusInfo.AllDASFound || !Status.HardwareDiscoveryParams.RequireAllDASFound)CanTransitToArm():Status.HardwareDiscoveryParams.ProceedWhenDone && Status.HardwareDiscoveryStatusInfo.SomeUnitsInArmStateCanTransitToDownload():CanTransitToConfigure() && Status.HardwareDiscoveryParams.GoToDownload
ReturnsState.HardwareDiscoveryStart.
3. Invariants
- Every state class must override the
Stateproperty to return its correspondingStateenum value (e.g.,State.Prepare,State.Realtime). - Selector states (
DASStateSelectorsubclasses) must implementStateSelector()to return anIDASState(typically viaStates.Instance.<StateName>). - Terminal states (
DASStatesubclasses) may optionally overrideOnEntryto define entry behavior; if not overridden, no entry action is executed. - The
OnEntryaction (if present) must callOnEnterState()as its first operation (observed inPrepare,ConfigureStart,RealtimeStart,DownloadStart,HardwareDiscoveryStart). - Transition decisions in selector states are based solely on
Status.*properties andStatus.*Paramsconfiguration objects. - No state class performs side effects outside of
OnEntryorStateSelector().
4. Dependencies
-
Internal dependencies (from source):
DASStateandDASStateSelectorbase classes (not shown, but implied by inheritance).Stateenum (used inStateproperty overrides).States.Instancesingleton (used to reference other states, e.g.,States.Instance.Diagnose).Statusobject with nested properties:ConfigureStatus,RealtimeStatus,DiagnoseParams,DownloadStatusInfo,DownloadParams,HardwareDiscoveryParams,HardwareDiscoveryStatusInfo.
DASFactory(used inPrepare.PrepareDASFactory(); assumed to be a member of the baseDASStateclass or accessible viathis).
-
External dependencies (inferred):
Systemand related namespaces (e.g.,System.Threading.Tasks).- Likely depends on a larger
DTS.DASLib.Serviceassembly containingStatus,States, and base state classes.
5. Gotchas
- Incomplete logic in
Configure.AllowApplyConfig(): Currently always returnstrue; no actual validation of channel resolution or placement is implemented despite comments indicating intent. - Selector state ordering matters: In
HardwareDiscoveryStart, transitions are evaluated in a specific order (Download → Configure → Arm → self-loop). Changing this order could alter behavior. - Self-loops may cause infinite loops: States like
Configure,Diagnose,Download, andHardwareDiscoverycan loop to themselves if conditions are not met; external triggers or status changes are required to exit. - Ambiguous
DASFactoryusage:PrepareDASFactory()referencesDASFactorywithout clear scoping—assumed to be a member of the base class, but not declared in the provided source. - No explicit error handling: Entry actions (e.g.,
StartRealtime(),Download()) may throw exceptions; no try/catch is visible in the source. RealtimeStartselector logic may retry indefinitely: IfCouldNotStartRealtimeremains true, the state machine will loop back toRealtimeStartwithout backoff or failure reporting.RequeryDevice()vsPing()behavior: The conditionnull != Status.HardwareDiscoveryParams.RequeryDevicesuggestsRequeryDeviceis a delegate or method group, but its type and semantics are not evident from this file.