Files
DP44/enriched-qwen3-coder-next/DataPRO/IService/Classes/Arm.md
2026-04-17 14:55:32 -04:00

194 lines
10 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
source_files:
- DataPRO/IService/Classes/Arm/ArmCheckActions.cs
- DataPRO/IService/Classes/Arm/ArmCheckResults.cs
- DataPRO/IService/Classes/Arm/ArmStatus.cs
generated_at: "2026-04-16T03:59:53.800390+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "51c3cf5ed1e74c4d"
---
# Arm
## Documentation: ARM Status and Pre-Arm Checks Module
---
### 1. Purpose
This module provides data structures and utilities for managing the **ARM state** of a Data Acquisition System (DAS) unit and for configuring/collecting **pre-arm diagnostic checks**. It enables the system to track real-time operational status (e.g., armed, triggered, faulted, recording) via `ArmStatus`, and to define and store results of diagnostic checks (e.g., battery voltage, sensor IDs, squib resistance) via `ArmCheckActions` and `ArmCheckResults`. It serves as the core data layer for the `ArmingService`, supporting safe arming workflows and post-test diagnostics.
---
### 2. Public Interface
#### `ArmCheckActions`
- **`bool PerformBatteryVoltageCheck { get; set; }`**
Flag indicating whether to perform a battery voltage diagnostic check.
- **`bool PerformInputVoltageCheck { get; set; }`**
Flag indicating whether to perform an input voltage diagnostic check.
- **`bool PerformSensorIdCheck { get; set; }`**
Flag indicating whether to verify sensor EIDs.
- **`bool PerformEventLineCheck { get; set; }`**
Flag indicating whether to check for shorts on the event line.
- **`bool PerformSquibResistanceCheck { get; set; }`**
Flag indicating whether to measure squib resistance.
- **`bool PerformTiltSensorCheck { get; set; }`**
Flag indicating whether to perform tilt sensor diagnostics.
- **`bool PerformTemperatureCheck { get; set; }`**
Flag indicating whether to perform temperature diagnostics.
- **`bool PerformClockSyncCheck { get; set; }`**
Flag indicating whether to verify clock synchronization status.
- **`ArmCheckActions()`**
Constructor initializes all check flags to `false`.
#### `ArmCheckResults`
- **`Dictionary<int, string[]> SensorIds { get; set; }`**
Maps channel index (int) to an array of sensor EIDs (strings) read from that channel.
- **`Dictionary<int, double> SquibResistances { get; set; }`**
Maps channel index (int) to measured squib resistance (Ω).
- **`double?[] BatteryVoltage { get; set; }`**
Array of optional battery voltage readings (mV), supporting multiple batteries per module (e.g., TDAS Pro rack).
- **`double? InputVoltage { get; set; }`**
Optional input voltage reading (mV).
- **`bool? StartLineShorted { get; set; }`**
Optional result indicating if the start line is shorted.
- **`bool? EventLineShorted { get; set; }`**
Optional result indicating if the event line is shorted.
- **`short[] TiltSensorDataPre { get; set; }`**
Raw pre-check tilt sensor ADC values.
- **`double[] TiltDegrees { get; set; }`**
Tilt angles (degrees) computed from `TiltSensorDataPre`.
- **`Dictionary<byte, short[]> IndexedTiltSensorDataPre { get; set; } = new Dictionary<byte, short[]>();`**
Indexed raw tilt data (key = device/module index).
- **`Dictionary<byte, double[]> IndexedTiltDegrees { get; set; } = new Dictionary<byte, double[]>();`**
Indexed tilt angles (key = device/module index).
- **`float[] TemperaturesPre { get; set; }`**
Raw temperature sensor readings (likely ADC counts or mV).
- **`double[] Gains { get; set; }`**
Channel gains used during diagnostics.
- **`double[] ZeroData { get; set; }`**
Zero-offset calibration data.
- **`IDictionary<InputClockSource, bool> InputClockLocks { get; set; }`**
Maps clock source type (`InputClockSource`) to lock status (`true` = locked).
#### `ArmStatus`
- **`bool ReceivedInvalidModeDuringSetup { get; set; } = false;`**
Indicates if `InvalidMode` error was received during setup; used as a heuristic to detect streaming mode.
- **`void ClearTriggerCheckStatus()`**
Resets trigger-related flags: `IsTriggered`, `IsArmed`, `IsRecording`, `IsTriggerShorted`, `IsStartShorted`.
- **`ArmStatus()`**
Default constructor.
- **`ArmStatus(IArmStatusData status)`**
Copy constructor from `IArmStatusData` interface; copies all properties.
- **`bool IsArmed { get; set; }`**
True if DAS is currently armed.
- **`bool IsTriggered { get; set; }`**
True if DAS has sensed a trigger event.
- **`bool IsTriggerShorted { get; set; }`**
True if trigger line is shorted *during trigger check only*.
- **`bool IsStartShorted { get; set; }`**
True if start line is shorted *during trigger check only*.
- **`bool IsRecording { get; set; }`**
True if DAS is currently recording samples.
- **`bool IsFaulted { get; set; }`**
True if DAS has faulted.
- **`bool IsInRealtime { get; set; }`**
True if DAS is in real-time mode.
- **`bool IsInFlashWrite { get; set; }`**
True if DAS is in flash write mode (G5).
- **`bool IsUndefined { get; set; }`**
True if `ARM STAT READ` returned no data.
- **`bool IsInPostTestDiagnostics { get; set; }`**
True if DAS is running post-test diagnostics.
- **`double TimeRemainingSeconds { get; set; }`**
Estimated seconds remaining in recording.
- **`double PercentComplete { get; set; }`**
Flash write progress percentage.
- **`ulong TotalSamples { get; set; }`**
Total samples to be recorded in the test.
- **`ulong CurrentSample { get; set; }`**
Current sample index being recorded.
- **`uint SampleRate { get; set; }`**
Current sample rate (Hz).
- **`double? InputMilliVolts { get; set; }`**
Input voltage (mV); auto-converts values > 100,000 from µV to mV.
- **`double? BatteryMilliVolts { get; set; }`**
Battery voltage (mV); auto-converts values > 100,000 from µV to mV.
- **`int? EventNumber { get; set; }`**
Current event number being recorded.
- **`ushort? MaxEventsPossible { get; set; }`**
Maximum number of events supported by the device (per issue #26817).
- **`int RecordingMode { get; set; }`**
Numeric recording mode identifier.
- **`string FaultMessage { get; set; }`**
Human-readable fault description (if any).
- **`bool IsRearming { get; set; }`**
True if DAS is in rearming state.
- **`bool HasBeenRecording { get; set; }`**
True if DAS has ever recorded during the current session.
- **`double? TimeLeftInArm { get; set; }`**
Time remaining in armed state (seconds).
- **`static void SetArmStatus(IDASCommunication unit, IArmStatusData status, bool bSetInDb)`**
Assigns `status` to `unit.DASArmStatus`. If `bSetInDb` is true and DB is connected, persists status to `ARM.SetArmStatus` stored procedure; logs exceptions via `APILogger`.
---
### 3. Invariants
- **`InputMilliVolts` and `BatteryMilliVolts`**:
Values > 100,000 are *always* divided by 1,000 to convert from µV to mV. Null values remain null.
- **`TimeLeftInArm`**:
No conversion is applied—values are stored directly as `double`.
- **`ClearTriggerCheckStatus()`**:
Only resets trigger-related flags (`IsTriggered`, `IsArmed`, `IsRecording`, `IsTriggerShorted`, `IsStartShorted`). Does *not* affect `IsFaulted`, `IsRecording`, or other non-trigger flags.
- **`ArmCheckActions`**:
All check flags default to `false`; no validation ensures at least one check is enabled.
- **`ArmCheckResults.SensorIds`**:
Key is channel index (0-based), value is array of EIDs (strings) per channel.
- **`ArmStatus.SetArmStatus(...)`**:
Does *not* throw exceptions; failures in DB persistence are silently logged via `APILogger`.
---
### 4. Dependencies
#### Imports/Usings
- `DTS.Common.Interface.DASFactory.Diagnostics` → Provides `IArmCheckActions`, `IArmCheckResults`, `IArmStatusData`.
- `DTS.Common.Interface.DASFactory` and `DTS.Common.Interface.DASFactory.ARM` → Provides `IDASCommunication`, `IArmStatusData`, `InputClockSource`.
- `DTS.Common` → Provides logging utilities (e.g., `APILogger`).
- `DASFactoryDb.ARM` → Provides `ARM.SetArmStatus(...)` stored procedure.
- `System.Collections.Generic`, `System` → Standard .NET types.
#### Dependencies *on* this module
- `ArmingService.GetArmStatus(...)` (referenced in `ArmStatus` summary) — *not shown in source*, but implied to be the primary consumer of `ArmStatus`.
- Any code performing pre-arm diagnostics — uses `ArmCheckActions` to configure checks and `ArmCheckResults` to store results.
- Database layer — calls `ARM.SetArmStatus(...)` via `ArmStatus.SetArmStatus(...)`.
#### Dependencies *of* this module
- `DASFactoryDb.DbWrapper.Connected` — checked before DB writes.
- `APILogger` — used for exception logging in `SetArmStatus`.
---
### 5. Gotchas
- **`InputMilliVolts`/`BatteryMilliVolts` unit conversion**:
Values > 100,000 are assumed to be in µV and converted to mV. If a value is legitimately > 100,000 mV (e.g., 120,000 mV = 120 V), it will be *incorrectly* divided to 120 mV. This is likely a legacy assumption for µV inputs.
- **`IsTriggerShorted` vs `IsTriggered`**:
`IsTriggerShorted` is *only* set during `TriggerCheck`, while `IsTriggered` is set in many contexts. Confusing the two may lead to incorrect logic (e.g., mistaking a trigger event for a line short).
- **`ReceivedInvalidModeDuringSetup` heuristic**:
Used to detect streaming mode, but this is not a guaranteed or documented protocol behavior—may break if firmware changes.
- **`ArmCheckResults.SensorIds` key type**:
Key is `int` (channel index), but no validation ensures keys are non-negative or contiguous.
- **`IndexedTiltSensorDataPre`/`IndexedTiltDegrees`**:
Key is `byte` (device/module index), but no documentation clarifies how indices are assigned or whether duplicates are possible.
- **`SetArmStatus(...)` silently swallows DB errors**:
Exceptions during DB persistence are logged but do *not* propagate—callers may assume persistence succeeded.
- **`ArmStatus` copy constructor does not guard against null `status`**:
While it returns early on null, it does *not* clear the current instances properties—only copies non-null values from `status`.
- **No validation in `ArmCheckActions`**:
It is possible to configure *no* checks (all flags `false`), which may lead to unsafe arming if not handled upstream.
None identified beyond the above.