init
This commit is contained in:
194
enriched-qwen3-coder-next/DataPRO/IService/Classes/Arm.md
Normal file
194
enriched-qwen3-coder-next/DataPRO/IService/Classes/Arm.md
Normal file
@@ -0,0 +1,194 @@
|
||||
---
|
||||
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 instance’s 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.
|
||||
125
enriched-qwen3-coder-next/DataPRO/IService/Classes/BaseInput.md
Normal file
125
enriched-qwen3-coder-next/DataPRO/IService/Classes/BaseInput.md
Normal file
@@ -0,0 +1,125 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/BaseInput/SLICEBaseInputValues.cs
|
||||
- DataPRO/IService/Classes/BaseInput/SLICE.Base.Input.Reader.cs
|
||||
- DataPRO/IService/Classes/BaseInput/BaseInputValues.cs
|
||||
generated_at: "2026-04-16T03:58:02.897735+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "371fccf4478077de"
|
||||
---
|
||||
|
||||
# Documentation: SLICE Base Input Module
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides data acquisition and status reporting for power-related inputs on SLICE-based hardware units. It enables reading raw diagnostic values (e.g., input voltage, battery voltage, temperature, charging status) via the `SLICEBaseInputReader` class and encapsulating them into a standardized data model (`BaseInputValues` and its SLICE-specific subclass `SLICEBaseInputValues`). The `SLICEBaseInputValues` subclass implements domain-specific logic to compute battery voltage status (e.g., `GREEN`, `YELLOW`, `RED`, `NOBATTERY`, `OFF`) based on battery voltage, input voltage, and charge capacity, while also handling device-specific behavior for backup power measurement and enablement.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `SLICEBaseInputValues` (inherits `BaseInputValues`)
|
||||
|
||||
- **`PossibleVoltageStatus` enum**
|
||||
Defines voltage status levels: `GREEN`, `YELLOW`, `RED`, `OFF`.
|
||||
*Note: This enum is declared but not used in the current implementation.*
|
||||
|
||||
- **`PossibleBatteryStatus` enum**
|
||||
Defines battery status levels: `GREEN`, `YELLOW`, `RED`, `NOBATTERY`, `OFF`.
|
||||
|
||||
- **`BatteryVoltageStatus` (override property)**
|
||||
*Read-only computed property.* Returns a string representation of `PossibleBatteryStatus` based on the following logic:
|
||||
- If `BatteryMilliVoltsValid` is `false`, returns `"NOBATTERY"`.
|
||||
- Else if `ChargeCapacityValid` is `true`:
|
||||
- `> 70%` → `"GREEN"`
|
||||
- `> 40%` → `"YELLOW"`
|
||||
- else → `"RED"`
|
||||
- Else if `InputMilliVoltsValid` is `true`, computes status using thresholds on `InputMilliVolts` and `BatteryMilliVolts` (see detailed logic in source).
|
||||
- Else → `"RED"`.
|
||||
*Write setter is a no-op; value is always regenerated on read.*
|
||||
|
||||
### `SLICEBaseInputReader`
|
||||
|
||||
- **Constructor**
|
||||
`SLICEBaseInputReader(ICommunication comm)`
|
||||
Initializes the reader with a communication interface (`ICommunication`). Throws no exceptions documented.
|
||||
|
||||
- **`InputMilliVolts` (virtual property)**
|
||||
Returns the input voltage in millivolts by querying the `MeasureBaseDiagnosticChannel` for `BaseDiagnosticChannelList.InputVoltage`. Multiplies raw measurement by `1000.0`.
|
||||
|
||||
- **`TemperatureC` (virtual property)**
|
||||
Returns the temperature in degrees Celsius by querying `MeasureBaseDiagnosticChannel` for `BaseDiagnosticChannelList.TemperatureC`.
|
||||
|
||||
- **`BatteryIsCharging` (property)**
|
||||
Returns `true` if the base unit’s charge status switch (via `QuerySwitchImmediate` for `Switches.BaseSwitches.ChargeStatus`) is set to `1`.
|
||||
|
||||
- **`DirectBackupMilliVolts` (virtual property)**
|
||||
Returns backup voltage in millivolts *without* enabling/disabling backup power. Returns `0D` if `ShouldMeasureBackupPower()` returns `false`.
|
||||
|
||||
- **`BackupMilliVolts` (property)**
|
||||
Returns backup voltage in millivolts *with* power management:
|
||||
- If `ShouldEnableBackupPower()` returns `true`, enables backup power, waits 1.5 seconds, reads via `DirectBackupMilliVolts`, then disables backup power in a `finally` block.
|
||||
- If `ShouldEnableBackupPower()` returns `false`, directly returns `DirectBackupMilliVolts`.
|
||||
|
||||
- **`ShouldEnableBackupPower()` (private method)**
|
||||
Returns `false` for SLICE6, SLICE2, and USB variants (`EthernetSlice6`, `EthernetSlice2`, `EthernetSlice6Air`, `EthernetSlice6AirBridge`, `EthernetTsrAir`, `WinUSBSlice6`, `CDCUSBSlice`); `true` otherwise.
|
||||
|
||||
- **`ShouldMeasureBackupPower()` (public method)**
|
||||
Returns `false` for SLICE6 and USB variants (`EthernetSlice6`, `EthernetSlice6Air`, `EthernetSlice6AirBridge`, `WinUSBSlice6`, `CDCUSBSlice`), `true` for `EthernetSlice2` and `EthernetTsrAir`, and defaults to `true` for other types.
|
||||
|
||||
- **`EnableBackupPower()` (private method)**
|
||||
Sends `SetSwitchImmediate` command to set `Switches.BaseSwitches.BackupPower` to `1`, but only if `ShouldEnableBackupPower()` returns `true`.
|
||||
|
||||
- **`DisableBackupPower()` (private method)**
|
||||
Sends `SetSwitchImmediate` command to set `Switches.BaseSwitches.BackupPower` to `0`, but only if `ShouldEnableBackupPower()` returns `true`.
|
||||
|
||||
### `BaseInputValues` (base class)
|
||||
|
||||
- **Properties**
|
||||
- `InputMilliVolts`, `InputVoltage` (both `double`)
|
||||
- `InputMilliVoltsValid` (virtual `bool`) — `true` if `InputMilliVolts` is within `(MinimumValidInputVoltage, MaximumValidInputVoltage)` (default: 6–16 V).
|
||||
- `MinimumValidInputVoltage`, `MaximumValidInputVoltage` (both `double`, default 6 and 16).
|
||||
- `BatteryMilliVolts`, `BatteryVoltage` (both `double`)
|
||||
- `BatteryMilliVoltsValid` (virtual `bool`) — `true` if `BatteryMilliVolts` is within `(MinimumValidBatteryVoltage, MaximumValidBatteryVoltage)` (default: 6–16 V).
|
||||
- `BatterySoC` (`double?`) — battery state of charge (percentage), `null` if not queried.
|
||||
- `MinimumValidBatteryVoltage`, `MaximumValidBatteryVoltage` (both `double`, default 6 and 16).
|
||||
- `BatteryIsCharging` (`bool`)
|
||||
- `TemperatureC` (`double`)
|
||||
- `BatteryVoltageStatus`, `InputVoltageStatus`, `StatusDisplayBattery`, `StatusDisplayInput` (all `string`, default `null`)
|
||||
- `BatteryVoltageStatusColor`, `InputVoltageStatusColor` (both `DFConstantsAndEnums.VoltageStatusColor`, default `null`)
|
||||
- `ChargeCapacity` (`double`, default `double.NaN`)
|
||||
- `ChargeCapacityValid` (`bool`) — `true` if `ChargeCapacity` is not `NaN`, and `0 < ChargeCapacity < 100`.
|
||||
|
||||
- **Constructors**
|
||||
- Default constructor.
|
||||
- Copy constructor: `BaseInputValues(IBaseInputValues copy)` — copies all properties from another `IBaseInputValues` instance.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- `BatteryVoltageStatus` in `SLICEBaseInputValues` is *always* computed on read and never settable; the setter is a no-op.
|
||||
- `InputMilliVoltsValid` and `BatteryMilliVoltsValid` depend on configurable min/max thresholds (default 6–16 V), but are validated against raw millivolt values.
|
||||
- `ChargeCapacityValid` requires `ChargeCapacity` to be in `(0, 100)` and not `NaN`.
|
||||
- `BackupMilliVolts` always disables backup power after measurement, regardless of success or failure, via `finally` block.
|
||||
- `ShouldEnableBackupPower()` and `ShouldMeasureBackupPower()` may differ in behavior (e.g., `EthernetTsrAir` returns `true` for `ShouldMeasureBackupPower()` but `false` for `ShouldEnableBackupPower()`).
|
||||
- Backup power is *not* enabled for SLICE6 or USB variants (`EthernetSlice6`, `EthernetSlice6Air`, `EthernetSlice6AirBridge`, `WinUSBSlice6`, `CDCUSBSlice`), per `ShouldEnableBackupPower()`.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Imports/Usings
|
||||
- `System.Threading` → used for `Thread.Sleep(1500)` in `BackupMilliVolts`.
|
||||
- `DTS.Common.Interface.DASFactory` → provides `ICommunication`, `MeasureBaseDiagnosticChannel`, `QuerySwitchImmediate`, `SetSwitchImmediate`, `Switches`, `MeasureBaseDiagnosticChannel.BaseDiagnosticChannelList`.
|
||||
- `DTS.DASLib.Command.SLICE` → provides SLICE-specific command types (`MeasureBaseDiagnosticChannel`, `QuerySwitchImmediate`, `SetSwitchImmediate`, `Switches`).
|
||||
- `DTS.Common.Enums.DASFactory` → provides `DFConstantsAndEnums.VoltageStatusColor`.
|
||||
- `DTS.Common.Interface.DASFactory.Diagnostics` → used via `IBaseInputValues`.
|
||||
|
||||
### Inferred Usage
|
||||
- `SLICEBaseInputReader` is used by higher-level services (e.g., `DiagnosticsService.Diagnose`) to populate `BaseInputValues` instances.
|
||||
- `SLICEBaseInputValues` is likely instantiated or assigned where SLICE-specific battery status logic is required.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`BatteryVoltageStatus` logic is complex and voltage-threshold-dependent**: The fallback logic for battery status when `ChargeCapacityValid` is `false` but `InputMilliVoltsValid` is `true` uses multiple nested `if` conditions with overlapping voltage ranges (e.g., `InputMilliVolts > 11000`, `> 9000`, `< 9`). This may be error-prone and could lead to unexpected status if input voltage is exactly at boundary values (e.g., `9000`, `11000`, `9000` mV).
|
||||
- **`BackupMilliVolts` has side effects**: It enables/disables backup power *even if the device does not support it* (guarded by `ShouldEnableBackupPower()`), but the 1.5-second delay (`Thread.Sleep`) may block the calling thread. This is not async-friendly.
|
||||
- **`ShouldEnableBackupPower()` vs `ShouldMeasureBackupPower()` divergence**: `EthernetTsrAir` is explicitly excluded from enabling backup power but *should* measure it — a subtle distinction that could cause confusion if not understood.
|
||||
- **`ChargeCapacityValid` excludes `0`**: A valid battery at 0% charge would be considered invalid (`ChargeCapacityValid = false`), potentially forcing fallback to voltage-based status even when charge data is present.
|
||||
- **No validation on `BatteryMilliVolts` vs `InputMilliVolts`**: The logic assumes `BatteryMilliVolts` is always ≤ `InputMilliVolts` when input is present, but no explicit checks exist.
|
||||
- **`InputMilliVoltsValid` uses `1000D * MinimumValidInputVoltage`**: This is redundant since `InputMilliVolts` is already in millivolts; could be simplified to `InputMilliVolts > MinimumValidInputVoltage * 1000`.
|
||||
155
enriched-qwen3-coder-next/DataPRO/IService/Classes/CAN.md
Normal file
155
enriched-qwen3-coder-next/DataPRO/IService/Classes/CAN.md
Normal file
@@ -0,0 +1,155 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/CAN/CANConfig.cs
|
||||
- DataPRO/IService/Classes/CAN/CANModuleConfig.cs
|
||||
generated_at: "2026-04-16T03:56:57.762497+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "49767c75e3daaeaa"
|
||||
---
|
||||
|
||||
# CAN
|
||||
|
||||
## Documentation: CAN Configuration Module (`DTS.DASLib.Service`)
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module provides XML-based serialization and deserialization for CAN (Controller Area Network) hardware configuration data in the DAS (Data Acquisition System) service layer. It enables persistent storage and retrieval of system-wide CAN module configurations (`CANConfig`) and per-module settings (`CANModuleConfig`), including channel definitions, recording parameters, and firmware metadata. The classes implement `IXmlSerializable` to support custom XML formatting, allowing configuration files to be stored in a human-readable and version-tolerant manner under the `DASConfigs` subdirectory relative to the executing assembly.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `CANConfig` class
|
||||
|
||||
- **`public Dictionary<string, CANModuleConfig> Modules { get; }`**
|
||||
Read-only dictionary mapping module serial numbers (string keys) to `CANModuleConfig` instances. Represents all configured CAN modules.
|
||||
|
||||
- **`public string FileName { get; }`**
|
||||
Full path to the XML file from which this `CANConfig` instance was loaded (or to which it will be written). Set only during construction.
|
||||
|
||||
- **`public CANConfig()`**
|
||||
Default constructor. Initializes an empty configuration with no modules or file association.
|
||||
|
||||
- **`public CANConfig(string fileName, bool deleteIfPresent)`**
|
||||
Constructor that attempts to load configuration from `fileName` (relative to `DASConfigs/` subdirectory). If `deleteIfPresent` is `true`, the file is deleted before loading (resulting in an empty config). If `false`, the file is read via `ReadXml`. Exceptions during file I/O or XML parsing are logged via `APILogger`.
|
||||
|
||||
- **`public void SetModule(CANModuleConfig module)`**
|
||||
Inserts or updates a module in the `_modules` dictionary using `module.SerialNumber` as the key. No validation beyond key existence.
|
||||
|
||||
- **`public CANModuleConfig GetModule(CANModuleConfig module)`**
|
||||
Returns the module stored under `module.SerialNumber`. If not present, inserts the provided `module` instance into the dictionary and returns it. *Note: This mutates the config even when the module is not yet known.*
|
||||
|
||||
- **`public XmlSchema GetSchema()`**
|
||||
Returns `null`. Required by `IXmlSerializable` but unused.
|
||||
|
||||
- **`public void ReadXml(XmlReader reader)`**
|
||||
Deserializes XML starting at `<CANConfig>` root. Reads a `<Modules>` section containing multiple `<CANModule>` elements. Each `<CANModule>` is deserialized into a `CANModuleConfig` and added via `SetModule`.
|
||||
|
||||
- **`public void WriteXml(XmlWriter writer)`**
|
||||
Serializes the configuration as `<CANConfig><Modules>...</Modules></CANConfig>`. Each `CANModuleConfig` is written via its own `WriteXml` method, with `writer.Flush()` called after writing the `<Modules>` start tag and after each module.
|
||||
|
||||
#### `CANModuleConfig` class
|
||||
|
||||
- **`public string SerialNumber { get; set; }`**
|
||||
Unique identifier for the CAN module (used as dictionary key in `CANConfig.Modules`).
|
||||
|
||||
- **`public string TestId { get; set; }`**
|
||||
Identifier for the test associated with this module.
|
||||
|
||||
- **`public string TestDescription { get; set; }`**
|
||||
Human-readable description of the test.
|
||||
|
||||
- **`public DFConstantsAndEnums.RecordingMode RecordingMode { get; set; }`**
|
||||
Recording mode enum (e.g., continuous, event-triggered). Defaults to `InvalidArmMode`.
|
||||
|
||||
- **`public float AAFilterRateHz { get; set; }`**
|
||||
Anti-aliasing filter rate in Hz. Default `0`.
|
||||
|
||||
- **`public double PreTriggerSeconds { get; set; }`**
|
||||
Duration (seconds) of data to capture *before* a trigger event. Default `0`.
|
||||
|
||||
- **`public double PostTriggerSeconds { get; set; }`**
|
||||
Duration (seconds) of data to capture *after* a trigger event. Default `0`.
|
||||
|
||||
- **`public string FirmwareVersion { get; set; }`**
|
||||
Firmware version string reported by the module.
|
||||
|
||||
- **`public UInt64? MaxEventStorageSpaceInBytes { get; set; }`**
|
||||
Optional maximum storage space (in bytes) for event-triggered recordings. Nullable; defaults to `0`.
|
||||
|
||||
- **`public int ModuleArrayIndex { get; set; }`**
|
||||
Index of the module in a logical array (e.g., for ordering). Default `0`.
|
||||
|
||||
- **`public string FileName { get; }`**
|
||||
Full path to the XML file from which this module config was loaded. Set only during construction.
|
||||
|
||||
- **`public CANModuleConfig()`**
|
||||
Default constructor. Initializes all properties to defaults.
|
||||
|
||||
- **`public CANModuleConfig(string fileName)`**
|
||||
Constructor that loads configuration from `fileName` (relative to `DASConfigs/`). Logs errors on failure.
|
||||
|
||||
- **`public void SetChannel(CANInputDASChannel channel)`**
|
||||
Inserts or updates a channel in the internal `_channels` dictionary using `channel.ModuleChannelNumber` as the key.
|
||||
|
||||
- **`public CANInputDASChannel GetChannel(CANInputDASChannel channel)`**
|
||||
Returns the channel stored under `channel.ModuleChannelNumber`. If not present, inserts the provided `channel` and returns it. *Note: Mutates config on miss.*
|
||||
|
||||
- **`public XmlSchema GetSchema()`**
|
||||
Returns `null`. Required by `IXmlSerializable` but unused.
|
||||
|
||||
- **`public void ReadXml(XmlReader reader)`**
|
||||
Deserializes XML starting at `<CANModule>`. Reads scalar properties (`SerialNumber`, `TestId`, etc.) and the `<Channels>` section. For `RecordingMode`, `AAFilterRateHz`, `PreTriggerSeconds`, `PostTriggerSeconds`, and `MaxEventStorageSpaceInBytes`, parsing errors are logged and defaults retained. `ModuleArrayIndex` is read via `ReadModuleArray`, which silently ignores errors (for backward compatibility with older config files).
|
||||
|
||||
- **`public void WriteXml(XmlWriter writer)`**
|
||||
Serializes the module as `<CANModule>...</CANModule>`. Writes all scalar properties and the `<Channels>` section. For each channel, calls `WriteElementStart`, `WriteXml`, and `WriteElementEnd` on the channel object.
|
||||
|
||||
- **`public virtual void WriteElementStart(XmlWriter writer)`**
|
||||
Writes `<CANModule xsi:type="...">` where `...` is the runtime type name (e.g., `CANInputDASChannel`). Allows polymorphic deserialization.
|
||||
|
||||
- **`public virtual void WriteElementEnd(XmlWriter writer)`**
|
||||
Writes `</CANModule>`.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **`SerialNumber` uniqueness**: Within a `CANConfig.Modules` dictionary, keys are `SerialNumber` strings. Duplicate keys are overwritten (not rejected).
|
||||
- **`ModuleChannelNumber` uniqueness**: Within a `CANModuleConfig._channels` dictionary, keys are `ModuleChannelNumber` integers. Duplicate keys are overwritten.
|
||||
- **XML structure**: `CANConfig` XML root is `<CANConfig>`, containing `<Modules>` with nested `<CANModule>` elements. `CANModuleConfig` XML root is `<CANModule>`.
|
||||
- **Backward compatibility**: `ReadModuleArray` silently ignores missing or malformed `ModuleArrayIndex` elements, assuming older config files may lack them.
|
||||
- **Default values**: All numeric/string properties have non-null defaults (e.g., `""` for strings, `0` for numerics, `InvalidArmMode` for `RecordingMode`). `MaxEventStorageSpaceInBytes` defaults to `0` (not `null`).
|
||||
- **File paths**: All file paths are constructed relative to the executing assembly’s directory, under `DASConfigs/<fileName>`.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
- **Internal dependencies**:
|
||||
- `DTS.Common.Utilities.Logging.APILogger` for error logging (used in constructors, `ReadXml`, `WriteXml`, and `ReadModuleArray`).
|
||||
- `DTS.Common.Enums.DASFactory.DFConstantsAndEnums.RecordingMode` enum (used in `RecordingMode` property).
|
||||
- `DASChannel` (base class) and `CANInputDASChannel` (concrete channel type) for channel storage and serialization. *Note: `DASChannel` is referenced but not defined in the provided sources.*
|
||||
|
||||
- **External dependencies**:
|
||||
- `System.Xml`, `System.Xml.Serialization`, `System.IO`, `System.Reflection` (standard .NET libraries).
|
||||
- File system access (for reading/writing XML files in `DASConfigs/`).
|
||||
|
||||
- **Depended upon by**:
|
||||
Unknown from source alone. Likely consumed by higher-level DAS service components (e.g., configuration managers, CAN interface drivers) that initialize or update CAN module settings.
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **`GetModule`/`GetChannel` mutate on miss**: Both methods add the provided module/channel to the internal dictionary if not found, which may be unintended (e.g., during read-only queries). Consider renaming or clarifying intent.
|
||||
- **No validation on `SerialNumber`/`ModuleChannelNumber`**: Duplicates are silently overwritten. No uniqueness enforcement beyond dictionary semantics.
|
||||
- **`ReadModuleArray` swallows errors**: The `catch` block in `ReadModuleArray` ignores all exceptions, potentially masking real issues (e.g., malformed XML). This is intentional for backward compatibility but may complicate debugging.
|
||||
- **`MaxEventStorageSpaceInBytes` range check is incomplete**: The condition `d >= 0 && d < ulong.MaxValue` allows `d == ulong.MaxValue`, but `Convert.ToUInt64(d)` will throw for `d == ulong.MaxValue` (since `double` may not represent it exactly). Should use `d <= ulong.MaxValue - 1` or similar.
|
||||
- **No `WriteXml` override for base `DASChannel`**: The `WriteXml` method iterates over `_channels.Values` as `DASChannel`, but only `CANInputDASChannel` is instantiated in `ReadXml`. If other `DASChannel` subclasses exist, `WriteElementStart`/`WriteElementEnd` must be overridden appropriately.
|
||||
- **Hardcoded path construction**: `Path.Combine(Path.GetDirectoryName(...), "DASConfigs", fileName)` assumes `DASConfigs` is a subdirectory of the assembly directory. May fail in non-standard deployment scenarios (e.g., single-file publish).
|
||||
- **No XML validation schema**: `GetSchema()` returns `null`, so no schema validation occurs during deserialization. Malformed XML may cause runtime errors or silent data loss.
|
||||
|
||||
None identified beyond the above.
|
||||
189
enriched-qwen3-coder-next/DataPRO/IService/Classes/Channels.md
Normal file
189
enriched-qwen3-coder-next/DataPRO/IService/Classes/Channels.md
Normal file
@@ -0,0 +1,189 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/Channels/OutputDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/AnalogOutputDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/DigitalOutputDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/InputDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/AnalogInputDASChannelComparer.cs
|
||||
- DataPRO/IService/Classes/Channels/TimestampDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/StreamInputDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/OutputTOMDigitalChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/CANInputDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/UARTInputDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/StreamOutputDASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/DASChannel.cs
|
||||
- DataPRO/IService/Classes/Channels/OutputSquibChannel.cs
|
||||
generated_at: "2026-04-16T04:00:36.696222+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "3f93d07c4af5eba3"
|
||||
---
|
||||
|
||||
# DAS Channel Classes Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module defines the class hierarchy for Data Acquisition System (DAS) channels, providing base and specialized classes for input and output channels used in the DTS DASLib.Service namespace. The classes model physical and logical channels in a DAS, supporting analog, digital, timestamp, CAN, UART, and streaming configurations. The hierarchy enables consistent channel management, serialization, and configuration across the system, with `DASChannel` as the root base class, `InputDASChannel` and `OutputDASChannel` as primary abstractions for directionality, and further derived classes for specific channel types (e.g., `AnalogInputDASChannel`, `CANInputDASChannel`, `OutputSquibChannel`). The module supports XML serialization for persistence and configuration, and includes validation logic via `IsConfigured()` overrides.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Base Classes
|
||||
|
||||
- **`DASChannel`**
|
||||
Abstract base class for all DAS channels. Implements `IXmlSerializable`.
|
||||
- `DASChannel(DASModule owner, int channelNumber)` – Constructor with owner module and channel number.
|
||||
- `DASChannel()` – Parameterless constructor.
|
||||
- `virtual bool IsConfigured()` – Returns `false` by default; overridden in derived classes to indicate configuration state.
|
||||
- `virtual void WriteXml(XmlWriter writer)` / `ReadXml(XmlReader reader)` – XML serialization/deserialization.
|
||||
- `virtual void WriteXmlCRC32(XmlWriter writer)` – CRC32-specific serialization (subset of `WriteXml`).
|
||||
- `virtual void HandleElement(XmlReader reader)` – Handles XML element parsing; can be overridden.
|
||||
- `bool CanReProgram()` – Returns `true` if the channel’s module supports reprogramming (IEPE/analog switching).
|
||||
- `int Number { get; }` – Stack channel number (0-based) relative to the DAS, computed via `OwningModule.OwningDAS.DASInfo.MapModuleArrayIndexAndChannelNum2DASChannel(...)`.
|
||||
- Key properties: `ModuleChannelNumber`, `AbsoluteDisplayOrder`, `OwningModule`, `UnitConverision`, `ConfigurationMode`, `DiagnosticsMode`, `IsoChannelName`, `UserCode`, `UserChannelName`, `SetupEID`, `DataCollectionEID`, `SensitivityUnits`, `AtCapacity`, `CapacityOutputIsBasedOn`, `QualificationSamples`, `LevelTriggerT0AdjustmentSamples`, `UserValue1/2/3`, `IdType`.
|
||||
|
||||
- **`InputDASChannel : DASChannel`**
|
||||
Base class for all input channels.
|
||||
- `InputDASChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `InputDASChannel()` – Parameterless constructor.
|
||||
|
||||
- **`OutputDASChannel : DASChannel`**
|
||||
Base class for all output channels.
|
||||
- `OutputDASChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `OutputDASChannel()` – Parameterless constructor.
|
||||
|
||||
### Derived Input Channel Classes
|
||||
|
||||
- **`AnalogInputDASChannel`** *(not shown in source)*
|
||||
Not present in provided files; assumed to exist as base for analog inputs (e.g., used by `AnalogInputDASChannelComparer`).
|
||||
|
||||
- **`AnalogInputDASChannelComparer : IEqualityComparer<AnalogInputDASChannel>`**
|
||||
Custom equality comparer for `AnalogInputDASChannel` instances.
|
||||
- `bool Equals(AnalogInputDASChannel x, AnalogInputDASChannel y)` – Returns `true` if channels match on:
|
||||
`ModuleChannelNumber`, `OwningModule.ModuleArrayIndex`, `OwningModule.OwningDAS.SerialNumber`, `AbsoluteDisplayOrder`, and `UnitConverision`.
|
||||
Includes null checks for objects, `OwningModule`, and `OwningDAS`; also validates `SerialNumber` is non-null/non-empty.
|
||||
- `int GetHashCode(AnalogInputDASChannel analog)` – Hash code computed from same fields as `Equals`, with fallback to `0` if `SerialNumber` is null/empty.
|
||||
|
||||
- **`TimestampDASChannel : InputDASChannel`**
|
||||
Channel for sample timestamps (RTC).
|
||||
- `TimestampDASChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `TimestampDASChannel()` – Parameterless constructor.
|
||||
- `override bool IsConfigured()` – Always returns `true`.
|
||||
- `override string ToString()` – Returns fixed string based on `ModuleType()` and `ModuleChannelNumber`:
|
||||
- `"MARKER"`, `"SECONDS_HIGH"`, `"SECONDS_LOW"` for `EmbeddedClockSecondsAndMarker`
|
||||
- `"NANOSECONDS_HIGH"`, `"NANOSECONDS_LOW"`, `"RESERVED"` for `EmbeddedClockNanosAndPad`
|
||||
- Otherwise: `ModuleChannelNumber.ToString()`.
|
||||
- Constants: `MARKER`, `SEC_H`, `SEC_L`, `NANOS_H`, `NANOS_L`, `RSVD`.
|
||||
|
||||
- **`StreamInputDASChannel : InputDASChannel`**
|
||||
Channel for streaming input settings.
|
||||
- `StreamInputDASChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `StreamInputDASChannel()` – Parameterless constructor.
|
||||
- `override bool IsConfigured()` – Returns `true` if `SerialNumber` is non-null/non-empty.
|
||||
- `override string ToString()` – Returns `"Stream{ModuleChannelNumber}"`.
|
||||
- `override void WriteXml(XmlWriter writer)` / `override void HandleElement(XmlReader reader)` – XML I/O for: `SerialNumber`, `HardwareChannelName`, `UDPAddress`.
|
||||
- Properties: `SerialNumber`, `HardwareChannelName`, `UDPAddress`.
|
||||
|
||||
- **`CANInputDASChannel : InputDASChannel`**
|
||||
Channel for CAN interface configuration.
|
||||
- `CANInputDASChannel(DASModule owner, int channelNumber)` – Constructor; initializes `SerialNumber` from `owner.SerialNumber()`.
|
||||
- `CANInputDASChannel()` – Parameterless constructor.
|
||||
- `override bool IsConfigured()` – Returns `true` if `SerialNumber` is non-null/non-empty.
|
||||
- `override string ToString()` – Returns `"CAN{ModuleChannelNumber}"`.
|
||||
- `override void WriteXml(XmlWriter writer)` / `override void HandleElement(XmlReader reader)` – XML I/O for: `SerialNumber`, `HardwareChannelName`, `IsFD`, `ArbBaseBitrate`, `ArbBaseSJW`, `DataBitrate`, `DataSJW`, `FileType`.
|
||||
- Properties: `SerialNumber`, `HardwareChannelName`, `IsFD`, `ArbBaseBitrate`, `ArbBaseSJW`, `DataBitrate`, `DataSJW`, `FileType`.
|
||||
|
||||
- **`UARTInputDASChannel : InputDASChannel`**
|
||||
Channel for UART interface configuration.
|
||||
- `UARTInputDASChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `UARTInputDASChannel()` – Parameterless constructor.
|
||||
- `override bool IsConfigured()` – Returns `true` if `SerialNumber` is non-null/non-empty.
|
||||
- `override string ToString()` – Returns `"UART{ModuleChannelNumber}"`.
|
||||
- `override void WriteXml(XmlWriter writer)` / `override void HandleElement(XmlReader reader)` – XML I/O for: `SerialNumber`, `HardwareChannelName`, `BaudRate`, `DataBits`, `StopBits`, `Parity`, `FlowControl`, `DataFormat`.
|
||||
Includes `try/catch` blocks for enum parsing with logging via `APILogger.Log`.
|
||||
- Properties: `SerialNumber`, `HardwareChannelName`, `BaudRate`, `DataBits`, `StopBits`, `Parity`, `FlowControl`, `DataFormat`.
|
||||
|
||||
### Derived Output Channel Classes
|
||||
|
||||
- **`AnalogOutputDASChannel : OutputDASChannel`**
|
||||
Base class for analog output channels.
|
||||
- `AnalogOutputDASChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `AnalogOutputDASChannel()` – Parameterless constructor.
|
||||
|
||||
- **`DigitalOutputDASChannel : OutputDASChannel`**
|
||||
Base class for digital output channels.
|
||||
- `DigitalOutputDASChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `DigitalOutputDASChannel()` – Parameterless constructor.
|
||||
|
||||
- **`StreamOutputDASChannel : OutputDASChannel`**
|
||||
Channel for streaming output settings.
|
||||
- `StreamOutputDASChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `StreamOutputDASChannel()` – Parameterless constructor.
|
||||
- `override bool IsConfigured()` – Returns `true` if `SerialNumber` is non-null/non-empty.
|
||||
- `override string ToString()` – Returns `"Stream{ModuleChannelNumber}"`.
|
||||
- `override void WriteXml(XmlWriter writer)` / `override void HandleElement(XmlReader reader)` – XML I/O for: `SerialNumber`, `HardwareChannelName`, `UDPProfileName`, `UDPTimeChannelId`, `UDPDataChannelId`, `IRIGTimeDataPacketIntervalMs`, `TMATSIntervalMs`, `UDPAddress`, `UDPTmNSConfig`.
|
||||
- Properties: `SerialNumber`, `HardwareChannelName`, `UDPProfileName`, `UDPTimeChannelId`, `UDPDataChannelId`, `IRIGTimeDataPacketIntervalMs`, `TMATSIntervalMs`, `UDPAddress`, `UDPTmNSConfig`.
|
||||
|
||||
- **`OutputTOMDigitalChannel : DigitalOutputDASChannel`**
|
||||
Base class for TOM (Test Output Module) digital channels (e.g., SQUIB-related).
|
||||
- `OutputTOMDigitalChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `OutputTOMDigitalChannel()` – Parameterless constructor.
|
||||
- `OutputTOMDigitalChannel(XmlReader reader)` – Constructor for deserialization.
|
||||
- `override bool IsConfigured()` – Returns `true` if `OutputMode != DigitalOutputModes.NONE` and `DigitalChannelDescription` is non-empty.
|
||||
- `override void WriteXml(XmlWriter writer)` / `override void WriteXmlCRC32(XmlWriter writer)` / `override void HandleElement(XmlReader reader)` – XML I/O for: `DelayMS`, `DurationMS`, `OutputMode`, `LimitDuration`, `DigitalChannelDescription`.
|
||||
- Properties: `OutputMode`, `DelayMS`, `LimitDuration`, `DurationMS`, `DigitalChannelDescription`, `LastModifiedBy`, `LastModified`, `LocalOnly`, `HardwareChannelName`, `Version`, `Date`.
|
||||
|
||||
- **`OutputSquibChannel : AnalogOutputDASChannel`**
|
||||
Channel for SQUIB (squib fire) output configuration. Implements `IComparable`.
|
||||
- `OutputSquibChannel(DASModule owner, int channelNumber)` – Constructor.
|
||||
- `OutputSquibChannel()` – Parameterless constructor.
|
||||
- `OutputSquibChannel(XmlReader reader)` – Constructor for deserialization.
|
||||
- `override bool IsConfigured()` – Returns `true` if `FireMode != SquibFireMode.NONE` and `SquibDescription` is non-empty.
|
||||
- `override string ToString()` – Returns `SquibDescription.Trim()` if non-empty; otherwise `base.ToString()`.
|
||||
- `int IComparable.CompareTo(object o)` – Compares by `SquibDescription`.
|
||||
- `override void WriteXml(XmlWriter writer)` / `override void WriteXmlCRC32(XmlWriter writer)` / `override void HandleElement(XmlReader reader)` – XML I/O for:
|
||||
`BypassCurrentFilter`, `BypassVoltageFilter`, `DelayMS`, `DurationMS`, `FireMode`, `ISOCode`, `MeasurementType`, `SquibDescription`, `ChannelId`, `ChannelName2`, `ChannelGroupName`, `HardwareChannelName`, `SquibFiredPassed`, `SquibFiredValid`, `SquibMeasuredOhms`, `SquibOutputCurrent`, `SquibToleranceHigh`, `SquibToleranceLow`, `LimitDuration`, `ScaleFactorMv`, `PreTestDataZeroLevelADC`, `SupportedSquibFireModes`, `SoftwareFilterFrequency`, `Sensor`, `SerialNumber`.
|
||||
- Properties: `SupportedSquibFireModes`, `Diagnostics`, `FireMode`, `MeasurementType`, `BypassCurrentFilter`, `BypassVoltageFilter`, `SquibToleranceLow`, `SquibToleranceHigh`, `SquibOutputCurrent`, `SquibMeasuredOhms`, `SquibFiredValid`, `SquibFiredPassed`, `DelayMS`, `DurationMS`, `SquibDescription`, `ISOCode`, `ChannelId`, `ChannelName2`, `HardwareChannelName`, `LimitDuration`, `ScaleFactorMv`, `PreTestDataZeroLevelADC`, `LocalOnly`, `LastModifiedBy`, `Sensor`, `SerialNumber`, `SoftwareFilterFrequency`.
|
||||
- Constants: `DEFAULT_MIN_FIRE_DURATION_MS`, `DEFAULT_MIN_FIRE_DELAY_MS`, `DEFAULT_DEFINEINTEST_FIRE_DELAY_FLAG`, `DEFAULT_MAX_FIRE_DURATION_MS`, `DEFAULT_MAX_FIRE_DELAY_MS`.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Channel Ownership**: Every channel instance has an `OwningModule` (set via constructor or deserialization). `DASChannel.Number` depends on `OwningModule.OwningDAS` being non-null and `DASInfo`/`Modules` being initialized.
|
||||
- **Serialization Consistency**: `WriteXml` and `ReadXml` must be symmetric; `HandleElement` implementations must handle all XML tags written by `WriteXml`.
|
||||
- **Configuration State**: `IsConfigured()` must be deterministic and based on concrete configuration data (e.g., presence of `SerialNumber`, non-`NONE` `FireMode`, etc.). Default implementation returns `false`.
|
||||
- **Equality Semantics**: `AnalogInputDASChannelComparer` enforces that equality is based on a composite key: channel number, module index, DAS serial number, display order, and unit conversion. `GetHashCode` must match `Equals`.
|
||||
- **Timestamp Channels**: `TimestampDASChannel.IsConfigured()` always returns `true`, indicating it is always considered configured.
|
||||
- **String Constants**: Tag names used in XML I/O (e.g., `SERIALNUMBER_TAG`, `DELAYMS_TAG`) are `private const string` and must match exactly between `WriteXml` and `HandleElement`.
|
||||
- **Enum Parsing Safety**: `UARTInputDASChannel` and `OutputSquibChannel` wrap enum parsing in `try/catch` blocks with logging to prevent deserialization failure.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Dependencies *of* this module:
|
||||
- **`DTS.DASLib.Service` namespace**:
|
||||
- `DASModule` (used in constructors and `OwningModule` property).
|
||||
- `DASInfo` (used in `DASChannel.Number` and `CanReProgram()`).
|
||||
- **External Libraries**:
|
||||
- `System`, `System.Xml`, `System.Collections.Generic`, `System.IO.Ports`, `System.Linq` (via LINQ in `AnalogInputDASChannelComparer`).
|
||||
- `DTS.Common.Enums.DASFactory` (`DFConstantsAndEnums`, `ModuleType`).
|
||||
- `DTS.Common.Enums` (`DigitalOutputModes`, `SquibFireMode`, `SquibMeasurementType`, `UartDataFormat`, `StopBits`, `Parity`, `Handshake`).
|
||||
- `DTS.Common.Interface.DASFactory.Config` (`IDASChannel`, `IEID`).
|
||||
- `DTS.Common.Interface.DASFactory.Diagnostics` (`IDiagnosticResult`).
|
||||
- `DTS.Common.Utilities.Logging` (`APILogger`).
|
||||
- `DTS.Common.Utilities` (`ArrayToString`).
|
||||
- `DTS.Common.Classes.Sensors` (`UDPStreamProfile`, `SensorConstants`).
|
||||
|
||||
### Dependencies *on* this module:
|
||||
- Any class that manages DAS channels (e.g., `DASModule`, `DAS`, `IDASCommunication`) depends on these channel types.
|
||||
- `AnalogInputDASChannelComparer` is explicitly noted as being used by `IDASCommunication` (per comment in source).
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **Typo in Property Name**: `UnitConverision` (instead of `UnitConversion`) is used consistently in `DASChannel` and XML I/O. This is likely a historical typo.
|
||||
- **`DASChannel.Number` May Throw**: The `Number` property can throw `ApplicationException` if `OwningModule`, `OwningDAS`, or `DASInfo` are null or improperly initialized.
|
||||
- **`CanReProgram()` Null Safety**: `CanReProgram()` performs multiple null checks; returns `false` if any link in the chain (`OwningModule`, `OwningDAS`, `DASInfo`, `Modules`) is null.
|
||||
- **`AnalogInputDASChannelComparer` Null Sensitivity**: `Equals` returns `false` if `OwningModule.OwningDAS.SerialNumber` is null/empty—even if other fields match. This may cause unexpected inequality for partially initialized channels.
|
||||
- **`OutputSquibChannel` Serialization of `ArticleId`**: In `WriteXmlCRC32` and `WriteXml`, `ArticleId` is written but ignored in `HandleElement` (commented as “why aren’t we using this id?”). This may indicate legacy or incomplete implementation.
|
||||
- **`TimestampDASChannel.ToString()` Relies on `ModuleType()`**: The `ToString()` override calls `OwningModule.ModuleType()`, but `ModuleType()` is not defined in the provided source—its implementation is assumed to be in `DASModule`.
|
||||
- **`OutputSquibChannel` Default Fire Delay Flag**: `DEFAULT_DEFINEINTEST_FIRE_DELAY_FLAG = -1` is a special sentinel value indicating delay must be defined in test setup; not documented in `IsConfigured()` or XML handling.
|
||||
- **`StreamOutputDASChannel.TMATSIntervalMs` Default**: Uses `StreamOutputRecord.DEFAULT_TMATS_INTERVAL_MS`, but `StreamOutputRecord` is not defined in the provided source.
|
||||
- **`AnalogInputDASChannel` Not Defined**: The comparer `AnalogInputDASChannelComparer` references `AnalogInputDASChannel`, but no such class is defined in the provided files—only `AnalogOutputDASChannel` is present. This suggests an omission or that `AnalogInputDASChannel` is defined elsewhere.
|
||||
- **`OutputTOMDigitalChannel` vs `OutputSquibChannel`**: Both are described as “base class for SQUIB channels” in comments, but `OutputSquibChannel` inherits from `AnalogOutputDASChannel`, while `OutputTOMDigitalChannel` inherits from `DigitalOutputDASChannel`. This may indicate
|
||||
@@ -0,0 +1,298 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/Diagnostics/OptimizationValues.cs
|
||||
- DataPRO/IService/Classes/Diagnostics/DiagnosticActions.cs
|
||||
- DataPRO/IService/Classes/Diagnostics/DiagnosticsResultActions.cs
|
||||
- DataPRO/IService/Classes/Diagnostics/DiagnosticsResult.cs
|
||||
generated_at: "2026-04-16T03:59:21.765469+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "3fe2b63623721951"
|
||||
---
|
||||
|
||||
# Documentation: Diagnostics Module
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides the data structures and utility methods required to configure, execute, and store diagnostic tests for DAS (Data Acquisition System) channels. It defines how diagnostic actions are specified (`DiagnosticsActions`), what results are collected from those actions (`DiagnosticsResult`), and how to persist or clear diagnostics data in memory and the database (`DiagnosticsResultActions`). Its role is to enable pre-recording validation of sensor and channel configuration by comparing measured diagnostic values (e.g., excitation voltage, offset, noise, shunt deflection) against expected hardware specifications, thereby supporting system integrity checks before data acquisition begins.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `DiagnosticsActions` class (`IDiagnosticActions` implementation)
|
||||
|
||||
- **`int DASChannelNumber { get; set; }`**
|
||||
Identifies the DAS channel (0-indexed globally across the DAS unit) for which these diagnostic instructions apply.
|
||||
|
||||
- **`bool MeasureExcitation { get; set; }`**
|
||||
If `true`, measure the excitation voltage applied to the sensor.
|
||||
|
||||
- **`bool MeasureOffset { get; set; }`**
|
||||
If `true`, measure the sensor’s offset from 0 (in mV); can be validated against `AnalogInputDASChannel` offset limits.
|
||||
|
||||
- **`bool CheckDigitalState { get; set; }`**
|
||||
If `true`, check the open/closed/high/low state of a digital input channel.
|
||||
|
||||
- **`bool MeasureInternalOffset { get; set; }`**
|
||||
If `true`, measure internal offset (likely ADC or front-end offset).
|
||||
|
||||
- **`bool RemoveOffset { get; set; }`**
|
||||
If `true`, instruct firmware to compensate for and remove the measured offset.
|
||||
|
||||
- **`bool MeasureNoise { get; set; }`**
|
||||
If `true`, measure noise floor as a percentage of full-scale reading.
|
||||
|
||||
- **`bool PerformShuntCheck { get; set; }`**
|
||||
If `true`, perform an emulated shunt-check test.
|
||||
|
||||
- **`bool SquibFireCheck { get; set; } = false`**
|
||||
If `true`, run a squib fire check on the channel.
|
||||
|
||||
- **`bool PerformVoltageInsertCheck { get; set; }`**
|
||||
If `true`, perform a voltage insertion gain check (SLICE Pro-specific).
|
||||
|
||||
- **`bool PerformCalSignalCheck { get; set; }`**
|
||||
If `true`, perform a calibration signal-check test.
|
||||
|
||||
- **`bool MeasureBridgeResistance { get; set; }`**
|
||||
If `true`, measure the bridge resistance of the sensor.
|
||||
|
||||
- **`DiagnosticsActions()`**
|
||||
Default constructor initializes all action flags to `false` and `DASChannelNumber` to `0`.
|
||||
|
||||
- **`bool AllActionsDisabled()`**
|
||||
Returns `true` if *none* of the diagnostic action flags are enabled.
|
||||
|
||||
- **`static void SetChannelDiagnosticActions(IDASCommunication unit, IDiagnosticActions[] actions, bool setInDb)`**
|
||||
Assigns the diagnostic action array to `unit.ChannelDiagnostics`. If `setInDb` is `true` and the database is connected, clears existing diagnostic actions for the record and inserts the new ones via `Diagnostics.InsertDiagnosticAction`.
|
||||
|
||||
### `DiagnosticsResult` class (`IDiagnosticResult` implementation)
|
||||
|
||||
- **`int DASChannelNumber { get; set; }`**
|
||||
The DAS channel number for which this result applies.
|
||||
|
||||
- **`int EventNumber { get; set; }`**
|
||||
The event number associated with this diagnostic result.
|
||||
|
||||
- **`double ScalefactorMilliVoltsPerADC { get; set; } = 1`**
|
||||
Mandatory scale factor to convert raw ADC counts to millivolts. Required for post-download data scaling.
|
||||
|
||||
- **`double ScalefactorEngineeringUnitsPerADC { get; set; } = 1`**
|
||||
Scale factor to convert ADC counts to engineering units.
|
||||
|
||||
- **`double ExpectedExcitationMilliVolts { get; set; }`**
|
||||
Factory-set expected excitation voltage (mandatory).
|
||||
|
||||
- **`short GetExpectedDataZeroLevelADC(ZeroMethodType zeroMethod)`**
|
||||
Returns the expected zero-level ADC value based on the zeroing method:
|
||||
- `ZeroMethodType.None`: returns `ZeroMVInADC`
|
||||
- Otherwise: uses `FinalOffsetADC` if non-null, else converts `MeasuredOffsetMilliVolts` to ADC using `ScalefactorMilliVoltsPerADC`, else returns `0`.
|
||||
|
||||
- **`double? MeasuredExcitationMilliVolts { get; set; }`**
|
||||
Measured excitation voltage (may be `null` if not measured; `0.0` in serialized data may indicate `null`).
|
||||
|
||||
- **`bool NegativeExcitation { get; set; }`**
|
||||
Flag indicating whether `MeasuredExcitationMilliVolts` was negative (legacy support for broken-sensor warnings).
|
||||
|
||||
- **`double? MeasuredOffsetMilliVolts { get; set; }`**
|
||||
Measured offset in mV (may be `null`).
|
||||
|
||||
- **`double? MeasuredInternalOffsetMilliVolts { get; set; }`**
|
||||
Measured internal offset in mV.
|
||||
|
||||
- **`double? MeasuredOffsetEngineeringUnits { get; set; }`**
|
||||
Measured offset in engineering units.
|
||||
|
||||
- **`double? AutoZeroPercentDeviation { get; set; }`**
|
||||
Deviation from zero after auto-zeroing (absolute value enforced on set). Reflects deviation in ADC counts (±5% check).
|
||||
|
||||
- **`short? FinalOffsetADC { get; set; }`**
|
||||
Offset remaining after firmware offset removal (if `RemoveOffset` was enabled).
|
||||
|
||||
- **`int? RemovedOffsetADC { get; set; }`**
|
||||
Amount of offset removed (in ADC counts).
|
||||
|
||||
- **`int? RemovedInternalOffsetADC { get; set; }`**
|
||||
Amount of internal offset removed.
|
||||
|
||||
- **`double? NoisePercentFullScale { get; set; }`**
|
||||
Noise floor as % of full-scale reading.
|
||||
|
||||
- **`bool ShuntDeflectionFailed { get; set; }`**
|
||||
`true` if shunt-check failed.
|
||||
|
||||
- **`bool CalSignalCheckFailed { get; set; }`**
|
||||
`true` if calibration signal check failed.
|
||||
|
||||
- **`double? MeasuredShuntDeflectionMv { get; set; }`**
|
||||
Measured shunt deflection in mV (if `PerformShuntCheck` was enabled).
|
||||
|
||||
- **`double? MeasuredCalSignalMv { get; set; }`**
|
||||
Measured calibration signal in mV.
|
||||
|
||||
- **`double? TargetCalSignalMv { get; set; }`**
|
||||
Expected calibration signal in mV.
|
||||
|
||||
- **`double? MeasuredDurationMS { get; set; }`**
|
||||
Measured squib fire duration (ms).
|
||||
|
||||
- **`double? MeasuredDelayMS { get; set; }`**
|
||||
Measured squib fire delay (ms).
|
||||
|
||||
- **`bool? SquibFirePassed { get; set; }`**
|
||||
`true` if squib fire test passed.
|
||||
|
||||
- **`bool? SquibDurationPassed { get; set; }`**
|
||||
`true` if squib duration passed.
|
||||
|
||||
- **`bool? SquibDelayPassed { get; set; }`**
|
||||
`true` if squib delay passed.
|
||||
|
||||
- **`double[] SquibFireCurrentData { get; set; }`**
|
||||
Raw current data from squib fire test.
|
||||
|
||||
- **`double[] SquibFireVoltageData { get; set; }`**
|
||||
Raw voltage data from squib fire test.
|
||||
|
||||
- **`double[] SquibFireTimeAxis { get; set; }`**
|
||||
Time axis (ms) for squib fire test.
|
||||
|
||||
- **`double SquibThreshold { get; set; }`**
|
||||
Squib fire threshold (likely current or voltage).
|
||||
|
||||
- **`double SquibVoltageScaler { get; set; }`**
|
||||
Voltage scaler used in squib test.
|
||||
|
||||
- **`double SquibCurrentScaler { get; set; }`**
|
||||
Current scaler used in squib test.
|
||||
|
||||
- **`double? TargetGain { get; set; }`**
|
||||
Expected gain (e.g., for voltage insertion check).
|
||||
|
||||
- **`double? MeasuredGain { get; set; }`**
|
||||
Measured gain.
|
||||
|
||||
- **`double? QueriedGain { get; set; }`**
|
||||
Gain value queried from firmware/config.
|
||||
|
||||
- **`double? TargetShuntDeflectionMv { get; set; }`**
|
||||
Expected shunt deflection in mV.
|
||||
|
||||
- **`double? BridgeResistance { get; set; }`**
|
||||
Measured bridge resistance in ohms (if `MeasureBridgeResistance` enabled).
|
||||
|
||||
- **`short ZeroMVInADC { get; set; } = 0`**
|
||||
ADC value corresponding to 0 mV input.
|
||||
|
||||
- **`short WindowAverageADC { get; set; } = short.MinValue`**
|
||||
Average ADC over the configured window. `short.MinValue` indicates uninitialized/invalid.
|
||||
|
||||
- **`bool DigitalInputActiveState { get; set; }`**
|
||||
Current active state of digital input (`true` = active/high, `false` = inactive/low).
|
||||
|
||||
### `DiagnosticsResultActions` static class
|
||||
|
||||
- **`static void ClearChannelDiagnosticsResults(IDASCommunication unit, bool bClearDb = true)`**
|
||||
Clears `unit.ChannelDiagnosticsResults` and `unit.ChannelDiagnostics` arrays. If `bClearDb` is `true` and DB is connected, clears diagnostics from the database.
|
||||
|
||||
- **`static void SetChannelDiagnosticsResults(IDASCommunication unit, IDiagnosticResult[] results, bool setInDb)`**
|
||||
Assigns `results` to `unit.ChannelDiagnosticsResults`. If `setInDb` is `true`, writes each result to the DB using type-specific methods:
|
||||
- `InsertDigitalDiagnosticResult` for digital channels
|
||||
- `InsertAnalogDiagnosticResult` for analog channels
|
||||
- `InsertSquibDiagnosticResult` for squib channels
|
||||
Channel type is determined via `unit.DASInfo.MapDASChannelNumber2ModuleArrayIndex` and `MapDASChannelNumber2ModuleChannelNumber`.
|
||||
|
||||
- **`private static void InsertDiagnosticsResultDigital(...)`**
|
||||
Writes digital diagnostic result to DB.
|
||||
|
||||
- **`private static void InsertDiagnosticsResultAnalog(...)`**
|
||||
Writes analog diagnostic result to DB (18 parameters).
|
||||
|
||||
- **`private static void InsertDiagnosticsResultsSquib(...)`**
|
||||
Writes squib diagnostic result to DB (14 parameters). Exceptions are silently swallowed.
|
||||
|
||||
### `OptimizationValues` class
|
||||
|
||||
- **`float TransferSpeed { get; set; }`**
|
||||
Holds a single float value representing transfer speed (likely for optimization tuning). No further behavior or usage context provided.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **`DiagnosticsActions.AllActionsDisabled()`** returns `true` only when *all* action flags are `false`.
|
||||
- Includes: `MeasureExcitation`, `MeasureOffset`, `RemoveOffset`, `MeasureNoise`, `PerformShuntCheck`, `MeasureBridgeResistance`, `PerformCalSignalCheck`, `PerformVoltageInsertCheck`, `MeasureInternalOffset`, `SquibFireCheck`, `CheckDigitalState`.
|
||||
|
||||
- **`DiagnosticsResult.ScalefactorMilliVoltsPerADC`** is mandatory for scaling raw ADC data to real-world voltages; no fallback is provided if missing.
|
||||
|
||||
- **`DiagnosticsResult.ZeroMVInADC`** defaults to `0`, and `WindowAverageADC` defaults to `short.MinValue` to indicate uninitialized/invalid state.
|
||||
|
||||
- **`DiagnosticsResult.AutoZeroPercentDeviation`** enforces non-negativity: setter applies `Math.Abs()`.
|
||||
|
||||
- **`DiagnosticsResult.GetExpectedDataZeroLevelADC()`** uses a priority order:
|
||||
`ZeroMethodType.None` → `ZeroMVInADC`;
|
||||
otherwise → `FinalOffsetADC` (if non-null) → `MeasuredOffsetMilliVolts` (converted) → `0`.
|
||||
|
||||
- **`DiagnosticsResultActions.SetChannelDiagnosticsResults()`** determines channel type via mapping and type-checks against `AnalogInputDASChannel` or `OutputSquibChannel`. If the channel is neither, no DB insertion occurs (no exception thrown, but no logging either).
|
||||
|
||||
- **Database writes** in `SetChannelDiagnosticActions` and `DiagnosticsResultActions` are guarded by `DASFactoryDb.DbWrapper.Connected` and `setInDb`/`bClearDb` flags. Exceptions during DB operations are logged via `APILogger.Log(ex)` (except squib result insertion, which silently swallows exceptions).
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Imports / External Types Used
|
||||
|
||||
- **`DTS.Common.Interface.DASFactory`**
|
||||
Provides `IDASCommunication`, `IDiagnosticActions`, `IDiagnosticResult`, `AnalogInputDASChannel`, `OutputSquibChannel`.
|
||||
|
||||
- **`DTS.Common.Interface.DASFactory.Diagnostics`**
|
||||
Defines `IOptimizationValues`, `IDiagnosticActions`, `IDiagnosticResult`.
|
||||
|
||||
- **`DTS.Common.Enums.Sensors`**
|
||||
Provides `ZeroMethodType` enum used in `GetExpectedDataZeroLevelADC`.
|
||||
|
||||
- **`DTS.Common.Utilities.Logging`**
|
||||
Provides `APILogger` for exception logging.
|
||||
|
||||
- **`DASFactoryDb.Diagnostics`**
|
||||
Provides `Diagnostics` class with methods:
|
||||
- `ClearDiagnosticActionsAllChannels`
|
||||
- `InsertDiagnosticAction`
|
||||
- `ClearExistingDiagnosticsAllChannels`
|
||||
- `InsertDigitalDiagnosticResult`
|
||||
- `InsertAnalogDiagnosticResult`
|
||||
- `InsertSquibDiagnosticResult`
|
||||
|
||||
- **`DASFactoryDb.DbWrapper`**
|
||||
Provides `Connected` property to check DB connectivity.
|
||||
|
||||
### Inferred Usage
|
||||
|
||||
- **Consumers**: Likely `DiagnosticsService` (referenced in `DiagnosticsResult` XML comments) and `ConfigureService` (for populating `AnalogInputDASChannel` specs).
|
||||
- **Dependencies on other modules**:
|
||||
- `DiagnosticsService` (for calibration/diagnostics execution)
|
||||
- `ConfigureService` (to populate sensor specs like offset limits in `AnalogInputDASChannel`)
|
||||
- `DASFactoryDb` (for persistence)
|
||||
- `APILogger` (for error logging)
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`MeasuredExcitationMilliVolts`, `MeasuredOffsetMilliVolts`, and other nullable fields**: A value of `0.0` read from event attributes may actually mean `null` (i.e., not measured). Callers must treat `0.0` as ambiguous and not assume it indicates a valid zero reading.
|
||||
|
||||
- **`WindowAverageADC` default value**: `short.MinValue` is used as a sentinel for uninitialized/invalid values. Code must check for this explicitly rather than assuming `0` is valid.
|
||||
|
||||
- **`AutoZeroPercentDeviation` setter**: Automatically applies `Math.Abs()`. Setting a negative value will silently flip the sign.
|
||||
|
||||
- **`DiagnosticsResultActions.SetChannelDiagnosticsResults()`**: If a channel is neither `AnalogInputDASChannel` nor `OutputSquibChannel`, no DB insertion occurs and no error is logged. This may silently skip unsupported channel types.
|
||||
|
||||
- **Squib result insertion**: Exceptions during `InsertSquibDiagnosticResult` are silently swallowed (no logging). This is explicitly noted in source comments as temporary.
|
||||
|
||||
- **`DiagnosticsActions.SetChannelDiagnosticActions()`**: Clears *all* existing diagnostic actions for the record *before* inserting new ones. If called with `actions == null`, it clears the DB but inserts nothing.
|
||||
|
||||
- **Channel mapping**: Relies on `unit.DASInfo.MapDASChannelNumber2ModuleArrayIndex` and `MapDASChannelNumber2ModuleChannelNumber`. Incorrect mapping could lead to DB writes to wrong channels or index-out-of-range errors.
|
||||
|
||||
- **`OptimizationValues`**: Only contains `TransferSpeed`. No usage context or integration points are visible in the provided source. Its purpose and consumers are unclear.
|
||||
|
||||
- **No validation in constructors**: `DiagnosticsActions` and `DiagnosticsResult` do not validate property values (e.g., negative `DASChannelNumber`, out-of-range `EventNumber`). Validation is deferred to downstream logic.
|
||||
|
||||
- **No thread-safety guarantees**: All methods are non-atomic and share mutable state (e.g., `unit.ChannelDiagnostics`, `unit.ChannelDiagnosticsResults`). Concurrent access may cause race conditions.
|
||||
|
||||
- **Legacy flag `NegativeExcitation`**: Introduced to preserve legacy TDC/TDAS behavior for broken-sensor warnings. Its presence suggests historical quirks in excitation reading that may affect interpretation of `MeasuredExcitationMilliVolts`.
|
||||
|
||||
None identified from source alone.
|
||||
144
enriched-qwen3-coder-next/DataPRO/IService/Classes/Download.md
Normal file
144
enriched-qwen3-coder-next/DataPRO/IService/Classes/Download.md
Normal file
@@ -0,0 +1,144 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/Download/UARTDownloadRequest.cs
|
||||
- DataPRO/IService/Classes/Download/DownloadRequest.cs
|
||||
- DataPRO/IService/Classes/Download/DownloadReport.cs
|
||||
generated_at: "2026-04-16T03:58:36.838770+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "6a51104a1281b13a"
|
||||
---
|
||||
|
||||
# Documentation: Download Request and Report Classes
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides data structures and static utility methods to configure and persist download requests and event metadata for a DAS (Data Acquisition System). It defines concrete implementations (`UARTDownloadRequest`, `DownloadRequest`, `DownloadReport`) of their corresponding interfaces (`IUARTDownloadRequest`, `IDownloadRequest`, `IDownloadReport`) used to specify *what* data to download from the DAS device and *which events* are present/already downloaded. The `SetWhatToDownload` and `SetEvent*` static methods in these classes synchronize request/report state with both the DAS communication layer (`IDASCommunication`) and a backing database via `DASFactoryDb.Download` functions.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `UARTDownloadRequest` class
|
||||
|
||||
- **`EventNumber`** (`ushort`): Gets or sets the event number from which to download UART data.
|
||||
- **`TotalByteCount`** (`ulong`): Gets or sets the total number of bytes in the UART stream.
|
||||
- **`TriggerByteCount`** (`ulong`): Gets or sets the byte offset within the stream where the trigger occurred.
|
||||
- **`FaultByteCount`** (`ulong`): Gets or sets the byte offset within the stream where a fault occurred.
|
||||
- **`StartTimestamp`** (`ulong`): Gets or sets the start timestamp of the UART stream.
|
||||
- **`EndTimestamp`** (`ulong`): Gets or sets the end timestamp of the UART stream.
|
||||
- **`BaudRate`** (`int`): Gets or sets the baud rate used during UART recording.
|
||||
|
||||
- **`SetWhatToDownload(IDASCommunication das, IUARTDownloadRequest request, bool bSetInDb)`** (`static void`):
|
||||
Assigns the provided `request` to `das.WhatUARTToDownload` (if `das` implements `IUARTDownload`). If `bSetInDb` is `true` and the database is connected, clears existing UART download requests for `das.RecordId`, then inserts the new request (or does nothing if `request` is `null`). Exceptions during DB insertion are logged via `APILogger.Log`.
|
||||
|
||||
### `DownloadRequest` class
|
||||
|
||||
- **`ALL_CHANNELS`** (`const byte`): Value `0xFF`; indicates all channels should be downloaded. *Currently the only supported value*.
|
||||
- **`EventNumber`** (`ushort`): Gets or sets the event number to download.
|
||||
- **`DASChannelNumber`** (`byte`): Gets or sets the channel number; must be `ALL_CHANNELS` (`0xFF`) per current implementation.
|
||||
- **`StartSample`** (`ulong`, `virtual`): Gets or sets the first sample index to download.
|
||||
- **`EndSample`** (`ulong`, `virtual`): Gets or sets the last sample index to download.
|
||||
- **`SamplesToSkip`** (`ulong`): Gets or sets subsampling factor. `0` or `1` means no subsampling; `n > 1` means every *n*th sample. *Invariant*: `(EndSample - StartSample + 1)` must be divisible by `SamplesToSkip`.
|
||||
- **`StartRecordTimestampSec`** (`double`): Gets or sets the integer seconds portion of the record start timestamp.
|
||||
- **`TriggerTimestampSec`** (`double`): Gets or sets the integer seconds portion of the trigger timestamp.
|
||||
- **`StartRecordTimestampNanoSec`** (`double`): Gets or sets the nanoseconds portion of the record start timestamp.
|
||||
- **`TriggerTimestampNanoSec`** (`double`): Gets or sets the nanoseconds portion of the trigger timestamp.
|
||||
- **`PTPMasterSync`** (`bool`): Gets or sets whether PTP master synchronization was used.
|
||||
|
||||
- **`SetWhatToDownload(IDASCommunication das, IDownloadRequest request, bool bSetInDb)`** (`static void`):
|
||||
Assigns `request` to `das.WhatToDownload`. Logs the request details if non-null. If `bSetInDb` is `true` and the database is connected, clears existing download requests for `das.RecordId`, then inserts the new request (or does nothing if `request` is `null`). Exceptions during DB insertion are logged via `APILogger.Log`.
|
||||
|
||||
### `DownloadReport` class
|
||||
|
||||
#### Nested Types
|
||||
|
||||
- **`EventInfo`** (`class`, implements `IEventInfo`):
|
||||
Represents metadata for a single event/test.
|
||||
- `Modules` (`IDASModule[]`): Array of modules involved in the event, indexed by `ModuleArrayIndex`.
|
||||
- `EventNumber` (`int`): Event number.
|
||||
- `TestGUID` (`Guid`): Event GUID.
|
||||
- `FaultFlags` (`ushort`): Fault flags.
|
||||
- `FaultFlagsEx` (`ushort`): Extended fault flags.
|
||||
- `ArmAttempts` (`byte`): Number of arm attempts.
|
||||
- `TestTime` (`DateTime`): Timestamp of the event.
|
||||
- `TestID` (`string`): Event ID string.
|
||||
- `Description` (`string`): Event description.
|
||||
- `HasBeenDownloaded` (`bool`): Whether the event has been downloaded.
|
||||
- `WasTriggered` (`bool`): Whether the event received a trigger.
|
||||
- `ClearFaults()` (`void`): Resets `FaultFlags` and `FaultFlagsEx` to `0`.
|
||||
- `EventInfo(EventInfo copy)` (`constructor`): Copies all fields from another `EventInfo`.
|
||||
|
||||
- **`UARTEventInfo`** (`class`, implements `IUARTEventInfo`):
|
||||
Represents metadata for a single UART event.
|
||||
- `EventNumber` (`ushort`): Event number.
|
||||
- `DataPresent` (`bool`): Whether UART data exists for this event.
|
||||
- `DataDownloaded` (`bool`): Whether UART data has been downloaded.
|
||||
- `TotalByteCount` (`ulong`): Total bytes of UART data.
|
||||
- `TriggerByteCount` (`ulong`): Byte offset of trigger.
|
||||
- `FaultByteCount` (`ulong`): Byte offset of fault.
|
||||
- `StartTimestamp` (`ulong`): UART stream start timestamp.
|
||||
- `EndTimestamp` (`ulong`): UART stream end timestamp.
|
||||
- `BaudRate` (`uint`): Baud rate during recording.
|
||||
|
||||
#### Instance Properties
|
||||
|
||||
- **`Events`** (`IEventInfo[]`): Array of all events on the DAS.
|
||||
- **`UARTEvents`** (`IUARTEventInfo[]`): Array of all UART events on the DAS.
|
||||
|
||||
#### Static Methods
|
||||
|
||||
- **`SetEventDownloadStatus(IDASCommunication das, bool[] status, bool bStoreInDb)`** (`static void`):
|
||||
Sets `das.EventDownloadedStatus` to `status`. If `bStoreInDb` and DB connected, clears and re-inserts status entries for `das.RecordId`. Logs exceptions.
|
||||
|
||||
- **`SetEventArmAttempts(IDASCommunication das, byte[] armAttempts, bool storeInDb)`** (`static void`):
|
||||
Sets `das.ArmAttempts` to `armAttempts`. Persists to DB if applicable.
|
||||
|
||||
- **`SetEventFaultFlags(IDASCommunication das, ushort[] faultFlags, bool storeInDb)`** (`static void`):
|
||||
Sets `das.FaultFlags` to `faultFlags`. Persists to DB if applicable.
|
||||
|
||||
- **`SetEventInfo(IDASCommunication das, IDownloadReport eventInfo, bool storeInDB)`** (`static void`):
|
||||
Sets `das.EventInfo` to `eventInfo`. Persists each `IEventInfo` in `eventInfo.Events` to DB by serializing `Modules` to XML and calling `Download.InsertEventInfo`. Logs exceptions.
|
||||
|
||||
- **`SetEventGuids(IDASCommunication das, Guid[] guids, bool storeInDb)`** (`static void`):
|
||||
Sets `das.EventGuids` to `guids`. Persists to DB if applicable.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **`DownloadRequest.DASChannelNumber`** must be `ALL_CHANNELS` (`0xFF`). Other values are unsupported per the class documentation.
|
||||
- **`DownloadRequest.SamplesToSkip`** must divide `(EndSample - StartSample + 1)` exactly. The code does not enforce this at runtime; violation would likely cause downstream errors.
|
||||
- **`DownloadRequest.SetWhatToDownload`** and **`UARTDownloadRequest.SetWhatToDownload`**:
|
||||
- If `bSetInDb` is `false` or `DASFactoryDb.DbWrapper.Connected` is `false`, no DB operations occur.
|
||||
- DB operations always clear *all* existing requests for `das.RecordId` before inserting the new one (or none if `request` is `null`).
|
||||
- **`DownloadReport.SetEventInfo`** serializes `eventInfo.Modules` to XML using `XmlWriter` with `ConformanceLevel.Document`. If any `IDASModule.WriteXml` implementation fails, the entire operation fails and is logged.
|
||||
- **`DownloadReport.EventInfo.ClearFaults()`** unconditionally sets both `FaultFlags` and `FaultFlagsEx` to `0`.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Internal Dependencies (from source)
|
||||
- **`DASFactoryDb.Download`**: Provides DB functions:
|
||||
- `ClearExistingUARTDownloadRequests`, `UARTDownloadRequestInsert`
|
||||
- `ClearExistingDownloadRequests`, `DownloadRequestInsert`
|
||||
- `ClearExistingEventDownloadStatus`, `InsertEventDownloadStatus`
|
||||
- `ClearExistingEventArmAttempts`, `InsertEventArmAttempts`
|
||||
- `ClearExistingFaultFlags`, `InsertEventFaultFlags`
|
||||
- `ClearExistingDownloadReports`, `InsertEventInfo`
|
||||
- `ClearExistingEventGuids`, `EventGuidInsert`
|
||||
- **`DASFactoryDb.DbWrapper`**: Provides `Connected` property and is used to gate DB operations.
|
||||
- **`DTS.Common.Interface.DASFactory`**: Defines `IDASCommunication`, `IDownloadRequest`, `IUARTDownloadRequest`, `IDownloadReport`, `IEventInfo`, `IUARTEventInfo`.
|
||||
- **`DTS.Common.Interface.DASFactory.Download`**: Defines `IUARTDownload` (used in `UARTDownloadRequest.SetWhatToDownload` to cast `das`).
|
||||
- **`DTS.Common.Interface.DownloadEvent`**: Defines `IEventInfo` (used in `DownloadReport.EventInfo`).
|
||||
- **`DTS.Common.Utilities.Logging`**: Provides `APILogger` for exception logging.
|
||||
|
||||
### External Dependencies (inferred)
|
||||
- **Database**: SQL Server (via `System.Data.SqlClient` and `SqlTypes` imports in `DownloadReport.cs`).
|
||||
- **XML serialization**: Uses `System.Xml` for `IDASModule.WriteXml` serialization.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`DownloadRequest.SamplesToSkip` validation is not enforced**: The code comments state `(EndSample - StartSample + 1)` must be a multiple of `SamplesToSkip`, but no runtime check exists. Invalid values may cause errors downstream.
|
||||
- **`UARTDownloadRequest.SetWhatToDownload` silently ignores non-`IUARTDownload` instances**: If `das` does not implement `IUARTDownload`, the method returns early without setting `WhatUARTToDownload` or logging.
|
||||
- **`DownloadReport.EventInfo` copy constructor performs shallow copy**: `Modules = copy.Modules` copies the array reference, not the elements. Modifying the array or its contents via one instance affects the other.
|
||||
- **`DownloadReport.SetEventInfo` serializes `Modules` to XML**: If any `IDASModule.WriteXml` implementation is buggy or writes invalid XML, the entire operation fails and is logged. No partial persistence occurs.
|
||||
- **`DownloadRequest.SetWhatToDownload` logs only when `request` is non-null**: If `request` is `null`, no log entry is made, even though `das.WhatToDownload` is set to `null`.
|
||||
- **`DownloadReport.UARTEventInfo.BaudRate` is `uint`, but `UARTDownloadRequest.BaudRate` is `int`**: Mismatched types may require conversion when copying data between them.
|
||||
- **DB operations are all-or-nothing per call**: Each `SetEvent*` method clears *all* existing DB records for its respective field before inserting new ones. This is not incremental and may cause data loss if called with incomplete arrays.
|
||||
- **`DownloadReport.SetEventDownloadStatus`, `SetEventArmAttempts`, `SetEventFaultFlags`, `SetEventGuids` do not validate array length**: Passing an array of incorrect length (e.g., mismatched with number of events) may cause DB inconsistencies or downstream errors.
|
||||
@@ -0,0 +1,83 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/InputRangeAttributes/GainDisabledAttribute.cs
|
||||
- DataPRO/IService/Classes/InputRangeAttributes/MaxInputRangeAttribute.cs
|
||||
- DataPRO/IService/Classes/InputRangeAttributes/GainAvailableUnmodifiedAttribute.cs
|
||||
- DataPRO/IService/Classes/InputRangeAttributes/MinInputRangeAttribute.cs
|
||||
- DataPRO/IService/Classes/InputRangeAttributes/FirmwareInputRangeAttribute.cs
|
||||
generated_at: "2026-04-16T03:57:34.431495+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "9e76f2c3f64de0c9"
|
||||
---
|
||||
|
||||
# InputRangeAttributes
|
||||
|
||||
## Documentation: Input Range Attribute Classes
|
||||
|
||||
### 1. Purpose
|
||||
This module defines a set of custom attribute classes used to annotate gain enumerations (likely in an input range configuration system) with metadata that controls gain behavior, availability, and interface constraints. Specifically, it enables fine-grained control over gain disablement, maximum/minimum input ranges (in mV), firmware-specific input ranges, and availability for unmodified hardware variants (e.g., Gen 3 SPS). These attributes are applied at compile-time via reflection and queried at runtime to enforce system-level constraints without hardcoding logic, supporting flexibility for calibration, hardware variants, and future tuning.
|
||||
|
||||
### 2. Public Interface
|
||||
All classes reside in the `DTS.DASLib.Service` namespace and derive from `System.Attribute`. Each provides a static method to query the attribute value from an enum field (passed as `object`), and a constructor to set the attribute’s value.
|
||||
|
||||
- **`GainDisabledAttribute`**
|
||||
- `GainDisabledAttribute(bool disabled)`
|
||||
Constructor. Sets `_bDisabled` to the provided value.
|
||||
- `static bool IsGainDisabled(object o)`
|
||||
Returns `true` if `o` is non-null, represents a valid enum field, and that field has a `GainDisabledAttribute` with `_bDisabled == true`. Returns `false` otherwise (including for `null`, missing members, or missing attribute).
|
||||
|
||||
- **`MaxInputRangeAttribute`**
|
||||
- `MaxInputRangeAttribute(double maxInputRangemV)`
|
||||
Constructor. Sets `_maximumInputRangemV` to the provided value (in mV).
|
||||
- `static double GetMaxInputRangemV(object o)`
|
||||
Returns `_maximumInputRangemV` if `o` is non-null, represents a valid enum field, and that field has a `MaxInputRangeAttribute`. Returns `0D` otherwise.
|
||||
|
||||
- **`GainAvailableUnmodifiedAttribute`**
|
||||
- `GainAvailableUnmodifiedAttribute(bool available)`
|
||||
Constructor. Sets `_bAvailable` to the provided value.
|
||||
- `static bool IsGainAvailableToUnmodified(object o)`
|
||||
Returns `false` only if `o` is non-null, represents a valid enum field, and that field has a `GainAvailableUnmodifiedAttribute` with `_bAvailable == false`. Returns `true` otherwise (including for `null`, missing members, or missing attribute).
|
||||
|
||||
- **`MinInputRangeAttribute`**
|
||||
- `MinInputRangeAttribute(double minInputRangemV)`
|
||||
Constructor. Sets `_minimumInputRangemV` to the provided value (in mV).
|
||||
- `static double GetMinInputRangemV(object o)`
|
||||
Returns `_minimumInputRangemV` if `o` is non-null, represents a valid enum field, and that field has a `MinInputRangeAttribute`. Returns `0D` otherwise.
|
||||
|
||||
- **`FirmwareInputRangeAttribute`**
|
||||
- `FirmwareInputRangeAttribute(double firmwareInputRangemV)`
|
||||
Constructor. Sets `_firmwareInputRangeAttribute` to the provided value (in mV).
|
||||
- `static double GetFirmwareInputRangemV(object o)`
|
||||
Returns `_firmwareInputRangeAttribute` if `o` is non-null, represents a valid enum field, and that field has a `FirmwareInputRangeAttribute`. Returns `0D` otherwise.
|
||||
|
||||
### 3. Invariants
|
||||
- All attributes are **optional** by design: if an enum field lacks a given attribute, default values apply (e.g., `IsGainDisabled` → `false`, `IsGainAvailableToUnmodified` → `true`, range getters → `0D`).
|
||||
- The static query methods assume the input `o` is an **enum value** (or `null`). They use `o.ToString()` to look up the corresponding `MemberInfo` via reflection (`GetMember(o.ToString())`).
|
||||
- Attribute values are **immutable** after construction (`_bDisabled`, `_maximumInputRangemV`, etc. are `readonly`).
|
||||
- Range values are interpreted as **millivolts (mV)**.
|
||||
- The `FirmwareInputRangeAttribute` is intended to represent a *firmware-selectable* range, possibly derived from neighboring gain steps (e.g., midpoint between adjacent gains), to avoid unintended gain-step changes during operation.
|
||||
|
||||
### 4. Dependencies
|
||||
- **Dependencies**:
|
||||
- `System` (for `Attribute`, `Type`, reflection APIs).
|
||||
- Implicit dependency on the *enum type(s)* that these attributes annotate (e.g., `InputRangeGain` or similar). These attributes are meaningless without such enums.
|
||||
- **Depended upon by**:
|
||||
- Unknown from source alone. Likely used by input configuration, calibration, or firmware interface modules that inspect gain enums at runtime via reflection (e.g., to determine valid ranges or skip disabled gains).
|
||||
- All attributes reference the same FogBugz ticket (`10080`), suggesting a shared context (likely gain/range configuration for a specific hardware platform).
|
||||
|
||||
### 5. Gotchas
|
||||
- **Reflection-based lookup is fragile**:
|
||||
- `GetMember(o.ToString())` assumes the enum field name matches `ToString()`. If the enum uses `Display` attributes or custom `ToString()` overrides, this may fail or return incorrect members.
|
||||
- If `o.ToString()` returns a non-field name (e.g., due to `Flags` enum formatting like `"A, B"`), `GetMember` may return an empty array → default values.
|
||||
- **`FirmwareInputRangeAttribute` field name typo**:
|
||||
- The private field is named `_firmwareInputRangeAttribute` (note: *Attribute* suffix), while the property/constructor parameter uses `firmwareInputRangemV`. This is likely a typo but is preserved as-is in the source.
|
||||
- **No validation of range values**:
|
||||
- No checks ensure `MinInputRangeAttribute` ≤ `MaxInputRangeAttribute`, or that `FirmwareInputRangeAttribute` lies between them. Consumers must enforce this.
|
||||
- **`0D` as sentinel value**:
|
||||
- A return value of `0D` from range getters could mean either: (a) the attribute is absent, or (b) the attribute was explicitly set to `0`. Ambiguity may cause misinterpretation.
|
||||
- **No documentation of enum usage**:
|
||||
- The source files do not show *how* these attributes are applied (e.g., `public enum Gain { [GainDisabled(true)] High = 3 }`). Without concrete examples, it is unclear if attributes are applied to fields, values, or types.
|
||||
- **No thread-safety guarantees**:
|
||||
- Reflection calls (`GetMember`, `GetCustomAttribute`) are not inherently thread-safe in older .NET versions, though modern runtimes typically handle this robustly. Not explicitly documented.
|
||||
- **None identified from source alone.**
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/PowerProInput/SLICE.PowerPro.Input.Reader.cs
|
||||
generated_at: "2026-04-16T03:57:12.321531+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "155f476d57ed5515"
|
||||
---
|
||||
|
||||
# PowerProInput
|
||||
|
||||
## 1. Purpose
|
||||
This module provides a concrete implementation of `SLICEBaseInputReader` for reading diagnostic inputs from a PowerPro device via the SLICE DAS (Data Acquisition System) infrastructure. It enables retrieval of key power-related diagnostic metrics—specifically input voltage, device temperature, and direct backup (battery) voltage—by executing synchronous measurements using the `MeasurePowerProDiagnosticChannel` command class. Its role is to abstract low-level communication details and expose standardized, type-safe properties for downstream system components (e.g., monitoring, diagnostics, or control logic) to consume real-time PowerPro hardware state.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `SLICEPowerProInputReader(ICommunication comm)`
|
||||
- **Type**: Constructor
|
||||
- **Behavior**: Initializes a new instance with the specified `ICommunication` interface (`_comm`) used for hardware interaction. Delegates to the base class constructor with the same `comm` instance.
|
||||
|
||||
### `override double InputMilliVolts { get; }`
|
||||
- **Type**: Read-only property
|
||||
- **Behavior**: Returns the PowerPro input voltage in millivolts. Internally creates a `MeasurePowerProDiagnosticChannel` instance, configures it to read `InputVoltage_A` on device group `0`, device ID `0`, executes a synchronous measurement, and returns `Measurement * 1000.0`.
|
||||
|
||||
### `override double TemperatureC { get; }`
|
||||
- **Type**: Read-only property
|
||||
- **Behavior**: Returns the PowerPro internal temperature in degrees Celsius. Internally creates a `MeasurePowerProDiagnosticChannel`, sets `Channel` to `TemperatureC`, configures device group and ID to `0`, executes a synchronous measurement, and returns `Measurement` directly.
|
||||
|
||||
### `override double DirectBackupMilliVolts { get; }`
|
||||
- **Type**: Read-only property
|
||||
- **Behavior**: Returns the direct backup (battery) voltage in millivolts. Internally creates a `MeasurePowerProDiagnosticChannel`, sets `Channel` to `BatteryVoltage`, configures device group and ID to `0`, executes a synchronous measurement, and returns `Measurement * 1000.0`.
|
||||
|
||||
> **Note**: All three properties override abstract members defined in the base class `SLICEBaseInputReader`. Each property performs a *synchronous* hardware read on every access.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Device targeting**: All measurements are hard-coded to `DeviceGroup = 0` and `DeviceID = 0`. No support for multi-device or configurable addressing is present.
|
||||
- **Unit consistency**:
|
||||
- `InputMilliVolts` and `DirectBackupMilliVolts` are returned in **millivolts** (i.e., `Measurement * 1000.0`).
|
||||
- `TemperatureC` is returned in **degrees Celsius** (i.e., raw `Measurement` value).
|
||||
- **Synchronous execution**: Every property getter performs a blocking `SyncExecute()` call; no async or buffered reads are used.
|
||||
- **Channel mapping**: Only three specific diagnostic channels are supported: `InputVoltage_A`, `TemperatureC`, and `BatteryVoltage`. Other channels in `PowerProDiagnosticChannelList` are not exposed via this class.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Dependencies *on* this module:
|
||||
- `SLICEBaseInputReader` (base class) — defines the abstract properties (`InputMilliVolts`, `TemperatureC`, `DirectBackupMilliVolts`) implemented here.
|
||||
- `ICommunication` — injected dependency for low-level hardware communication.
|
||||
- `MeasurePowerProDiagnosticChannel` — concrete command class from `DTS.DASLib.Command.SLICE` used to perform synchronous measurements.
|
||||
|
||||
### Dependencies *of* this module:
|
||||
- **External libraries**:
|
||||
- `DTS.Common.Interface.DASFactory` (for `ICommunication`)
|
||||
- `DTS.DASLib.Command.SLICE` (for `MeasurePowerProDiagnosticChannel`)
|
||||
- **Inferred callers**: Likely consumed by higher-level services (e.g., monitoring daemons, status reporters) that inherit from or use `SLICEBaseInputReader` polymorphically.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **Repeated hardware calls per property access**: Each property read triggers a *new* `MeasurePowerProDiagnosticChannel` instance and a full `SyncExecute()` round-trip to the device. This may cause performance issues if properties are accessed frequently (e.g., in tight loops or high-frequency telemetry). Caching is not implemented.
|
||||
- **Hard-coded device addressing**: All reads target `DeviceGroup = 0`, `DeviceID = 0`. If the PowerPro system supports multiple devices, this class cannot be used without modification.
|
||||
- **No error handling visible**: The source does not show explicit exception handling (e.g., for communication failures, invalid measurements). Failures in `SyncExecute()` or invalid `measure.Measurement` values may propagate unhandled exceptions.
|
||||
- **Unit ambiguity in base `Measurement`**: The raw `measure.Measurement` value’s unit (e.g., volts, °C) is assumed by context but not enforced by this class. Incorrect assumptions about the underlying `MeasurePowerProDiagnosticChannel`’s output units could lead to incorrect scaling.
|
||||
- **No thread-safety guarantees**: Since each property creates a new `MeasurePowerProDiagnosticChannel` and calls `SyncExecute()` on `_comm`, concurrent access to multiple properties *may* be safe *if* `_comm` is thread-safe, but this is not documented or verified in the source.
|
||||
|
||||
> **None identified from source alone.** *(Note: The above gotchas are inferred from observed patterns in the code, not explicit warnings.)*
|
||||
216
enriched-qwen3-coder-next/DataPRO/IService/Classes/SLICE.md
Normal file
216
enriched-qwen3-coder-next/DataPRO/IService/Classes/SLICE.md
Normal file
@@ -0,0 +1,216 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/SLICE/DASConfigurationEventArg.cs
|
||||
- DataPRO/IService/Classes/SLICE/SLICE6DB3.cs
|
||||
- DataPRO/IService/Classes/SLICE/S6DBConnectedDevice.cs
|
||||
- DataPRO/IService/Classes/SLICE/SLICEPRODB.cs
|
||||
- DataPRO/IService/Classes/SLICE/SLICE6AIRBR.cs
|
||||
- DataPRO/IService/Classes/SLICE/SLICE6AIRTC.cs
|
||||
generated_at: "2026-04-16T03:58:03.811712+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "4572c24a2832d452"
|
||||
---
|
||||
|
||||
# SLICE
|
||||
|
||||
**Documentation Page: SLICE DAS Device Implementations and Configuration Events**
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module provides concrete implementations of DAS (Data Acquisition System) device types for the SLICE family (SLICE6DB3, SLICEPRODB, SLICE6AIRBR, SLICE6AIRTC), each tailored to specific hardware capabilities and protocol support levels. It also defines `DASConfigurationArg`, a data carrier for the `DASConfigurationEvent`, enabling consumers to react to configuration read outcomes (e.g., blank configs, validation failures). These classes implement core DAS functionality—configuration, diagnostics, clock synchronization, and real-time streaming—while accounting for hardware-specific limitations and protocol versioning. The module serves as the runtime bridge between high-level service logic and low-level device communication, ensuring correct behavior per device variant.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `DASConfigurationArg`
|
||||
- **Namespace**: `DTS.DASLib.Service`
|
||||
- **Implements**: `IDASConfigurationArg`
|
||||
- **Purpose**: Encapsulates state passed during a `DASConfigurationEvent`.
|
||||
|
||||
| Member | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `DAS` | `IDASCommunication` | The DAS instance whose configuration event occurred. Read-only. |
|
||||
| `BlankConfigurationRead` | `bool` | `true` if the configuration loaded from disk was blank (e.g., empty filestore). Read-only. |
|
||||
| `ConfigurationFailedValidation` | `bool` | `true` if the loaded configuration failed validation. Read-only. |
|
||||
| **Constructor** | `DASConfigurationArg(IDASCommunication das, bool blankRead, bool failedValidation)` | Initializes the event args with the given state. |
|
||||
|
||||
#### `SLICE6DB3<T>`
|
||||
- **Namespace**: `DTS.DASLib.Service`
|
||||
- **Inherits**: `SLICE6DB<T>`
|
||||
- **Constraints**: `T : IConnection, new()`
|
||||
- **Purpose**: A limited SLICE6DB variant without PTP/IEEE 1588 support.
|
||||
|
||||
| Member | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `SetClockSyncConfig(ServiceCallback callback, object userData, ClockSyncProfile profile)` | `override void` | No-op; returns success immediately. Clock sync not supported. |
|
||||
| `GetClockSyncStatus(ServiceCallback callback, object userData)` | `override void` | No-op; returns success immediately. |
|
||||
| `SetPTPDomainID(ServiceCallback callback, object userData, byte domainID)` | `override void` | No-op; returns success immediately. PTP not supported. |
|
||||
| `GetPTPDomainID(ServiceCallback callback, object userData)` | `override void` | No-op; returns success immediately. |
|
||||
|
||||
#### `S6DBConnectedDevice`
|
||||
- **Namespace**: `DTS.DASLib.Service.Classes.SLICE`
|
||||
- **Implements**: `IDASConnectedDevice`
|
||||
- **Purpose**: Represents a device discovered on a SLICE6DB via `QAUTIL_QUERY_MAC_IP_TABLE`.
|
||||
|
||||
| Member | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `DeviceType` | `HardwareTypes` | Default `HardwareTypes.SLICE6_Base`; set to `HardwareTypes.SLICE6_AIR` if `SerialNumber` starts with `"S6A"`. Read-only. |
|
||||
| `Port` | `int` | 0-based port index. Valid only if ≥ 0. Default `-1`. |
|
||||
| `SpotOnPort` | `int` | 0-based position on the port/chain. Valid only if ≥ 0. Default `-1`. |
|
||||
| `PhysicalAddress` | `PhysicalAddress` | MAC address of the device. |
|
||||
| `IPAddress` | `string` | IP address reported by device. Default `""`. |
|
||||
| `SerialNumber` | `string` | Device serial number. Default `""`. |
|
||||
| `Location` | `string` | Device location string. Default `""`. |
|
||||
| `Version` | `string` | Device firmware version. Default `""`. |
|
||||
| **Constructor** | `S6DBConnectedDevice(int port, int spotOnPort, PhysicalAddress physicalAddress, string ipAddress, string serialNumber, string location, string version)` | Initializes all fields; updates `DeviceType` if `SerialNumber` starts with `"S6A"`. |
|
||||
|
||||
#### `SLICEPRODB<T>`
|
||||
- **Namespace**: `DTS.DASLib.Service`
|
||||
- **Inherits**: `SLICE6DB<T>`, implements `IDownloadActions`
|
||||
- **Constraints**: `T : IConnection, new()`
|
||||
- **Purpose**: SLICEPRO DB variant with limited protocol support (e.g., no MAC table query, no PTP).
|
||||
|
||||
| Member | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `QueryConnectedDevices()` | `override void` | No-op; sets `ConnectedDevices` to an empty array. |
|
||||
| `IsSlice6Distributor()` | `override bool` | Returns `false`. |
|
||||
| `IsBattery()` | `override bool` | Returns `true` (comment: “um maybe?”). |
|
||||
| `SupportsTimeSynchronization` | `override bool` | Returns `false`. |
|
||||
| `SupportsTemperatureCheck` | `protected override bool` | Returns `true`. |
|
||||
| `SupportsTiltCheck` | `protected override bool` | Returns `true`. |
|
||||
| `SupportsClockSyncCheck` | `protected override bool` | Returns `true`. |
|
||||
| `InitMinProto()` | `override void` | Populates `MinimumProtocols` dictionary with protocol version requirements. Key commands with `byte.MaxValue` are unsupported (e.g., `PTPSyncStatus`, `SetClockSyncConfig`, `QueryEthernetMacTable`). |
|
||||
| `MinimumProtocols` | `Dictionary<ProtocolLimitedCommands, byte>` | Inherited from base; set in `InitMinProto()`. |
|
||||
|
||||
#### `SLICE6AIRBR<T>`
|
||||
- **Namespace**: `DTS.DASLib.Service`
|
||||
- **Inherits**: `SLICE6_Base<T>`, implements `IAlignUDPToPPSAware`
|
||||
- **Constraints**: `T : IConnection, new()`
|
||||
- **Purpose**: SLICE6 AIR BR variant with PTP, UDP alignment, and full feature set.
|
||||
|
||||
| Member | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `AlignUDPToPPS` | `bool` | Property to configure UDP alignment to PPS. |
|
||||
| `SupportsRemoveLeapSeconds` | `override bool` | Returns `true`. |
|
||||
| `SupportsADCSamplesPerPacket` | `override bool` | Returns `true`. |
|
||||
| `RequiresNon0QualificationSamples` | `protected override bool` | Returns `true`. |
|
||||
| `GetRTChannelIndices(RealTimeAsyncPacket packet)` | `override byte[]` | Returns channel indices `[0x00..0x05]` (6 channels). |
|
||||
| `SetIsStreamingSupported(bool)` | `override void` | Sets `IsStreamingSupported = true`. |
|
||||
| `DASIndex` | `int` | Device order among multiple DAS units. Default `-1`. |
|
||||
| `InitMinProto()` | `override void` | Populates `SLICE6AIR_BR_MinimumProtocols` dictionary. Includes protocol versions for `UDPAlignOnPPS` (`UDPALIGNONPPS_PROTOCOL`) and `ADCSamplesPerPacket` (`ADC_SAMPLES_PER_PACKET_VER`). |
|
||||
| `MaxSampleRateHz` | `protected override uint` | Queries `MaximumSampleRate` system attribute; returns `50000` on error. |
|
||||
| `MakeConfigModuleFromInfoModule(InfoResult.Module)` | `override DASModule` | Creates `DASModule` with `AnalogInputDASChannel` (full/half bridge support) or `StreamOutputDASChannel`. |
|
||||
| `AsyncConfigure(object)` | `override void` | Full configuration flow: sets UDP/PPS, leap seconds, ADC samples/packet, resets event list, configures modules, stores attributes, and calls `RemainingConfigWork`. |
|
||||
| `GetIsStreaming()` | `override bool` | Returns `true` if `DASArmStatus.ReceivedInvalidModeDuringSetup` or `DASArmStatus.IsInRealtime`. |
|
||||
|
||||
#### `SLICE6AIRTC<T>`
|
||||
- **Namespace**: `DTS.DASLib.Service`
|
||||
- **Inherits**: `SLICE6_Base<T>`, implements `IAlignUDPToPPSAware`, `IDASReconfigure`, `ITCDiagnosticResults`, `IUARTDownloadActions`, `IUARTDownload`
|
||||
- **Constraints**: `T : IConnection, new()`
|
||||
- **Purpose**: SLICE6 AIR TC variant with thermocouple diagnostics, UART support, and PTP.
|
||||
|
||||
| Member | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `WhatUARTToDownload` | `IUARTDownloadRequest` | Request object for UART event download. |
|
||||
| `SetWhatUARTToDownload(IUARTDownloadRequest, bool)` | `void` | Delegates to `UARTDownloadRequest.SetWhatToDownload`. |
|
||||
| `BaudRate`, `DataBits`, `StopBits`, `Parity`, `FlowControl` | `uint` / `StopBits` / `Parity` / `Handshake` | UART settings. Populated by `AsyncGetUARTSettings`. |
|
||||
| `UARTDownload(ServiceCallback, object)` | `void` | Returns `"Not supported"` error. |
|
||||
| `QueryUARTDownload(ServiceCallback, object, int, TDASServiceSetupInfo)` | `void` | Launches `AsyncQueryUARTDownload`. |
|
||||
| `AsyncQueryUARTDownload(object)` | `protected virtual void` | Checks `IsCommandSupported(ProtocolLimitedCommands.QueryUARTDownload)`; errors if unsupported. |
|
||||
| `GetUARTSettings(ServiceCallback, object)` | `void` | Launches `AsyncGetUARTSettings`. |
|
||||
| `AsyncGetUARTSettings(object)` | `protected virtual void` | Queries `S6A_GpsCanUARTSettings` system attribute; populates UART fields. Handles retries (`PERMITTED_FAILURES`). |
|
||||
| `SetUARTSettings(ServiceCallback, object, uint, uint, uint, uint, uint)` | `void` | Launches `AsyncSetUARTSettings`. |
|
||||
| `AsyncSetUARTSettings(object)` | `protected virtual void` | Sets `S6A_GpsCanUARTSettings` system attribute. |
|
||||
| `TCDiagnosticResults` | `ITCDiagnosticResult[]` | Array of thermocouple diagnostic results. |
|
||||
| `ClearTCDiagnosticResults()` | `void` | Resets `TCDiagnosticResults` to empty array. |
|
||||
| `SetTCDiagnosticResults(ITCDiagnosticResult[])` | `void` | Sets `TCDiagnosticResults`. |
|
||||
| `InitializeTCDiagnostics()` | `private void` | Allocates 24 `TCDiagnosticResult` entries, one per channel. |
|
||||
| `AsyncDiagnosAndGetResults(object)` | `override void` | Initializes diagnostics, then calls `MeasureOffsets` and `MeasureShunts`. |
|
||||
| `MeasureShunts(SliceServiceAsyncInfo)` | `private bool` | Queries `QueryChannelShuntResults`; sets `ConnectionStatus` based on deflection values (`0` → `ModuleNotConnected`, `100` → `Connected`). |
|
||||
| `MeasureOffsets(SliceServiceAsyncInfo)` | `private bool` | Queries `RetrieveSampleAverage` (4000 samples); sets `CurrentReading` (scaled by `0.1`). |
|
||||
| `GetChannelName(int)` | `private string` | Returns `UserChannelName` or `IsoChannelName` for given channel index. |
|
||||
| `IsSlice6AirTc()` | `override bool` | Returns `true`. |
|
||||
| `GetMaxFileLengthTMATS()` | `override int` | Returns `MAX_TMATS_FILE_LENGTH` (32000). |
|
||||
| `AlignUDPToPPS` | `bool` | Property to configure UDP alignment to PPS. |
|
||||
| `SupportsRemoveLeapSeconds` | `override bool` | Returns `true`. |
|
||||
| `SupportsADCSamplesPerPacket` | `override bool` | Returns `true`. |
|
||||
| `RequiresNon0QualificationSamples` | `protected override bool` | Returns `true`. |
|
||||
| `GetRTChannelIndices(RealTimeAsyncPacket)` | `override byte[]` | Returns channel indices based on `_maxModuleCount`: 8, 16, or 24 channels. |
|
||||
| `GetRealtimeSamplesClass(ICommunication, bool)` | `override IGetRealtimeSamples` | Returns `RealtimeStreamingNextSamples` (signed data) if streaming supported. |
|
||||
| `SetIsStreamingSupported(bool)` | `override void` | Sets `IsStreamingSupported = true`. |
|
||||
| `InitMinProto()` | `override void` | Populates `SLICE6AIR_TC_MinimumProtocols` dictionary. Includes `GetUARTSettings`, `SetUARTSettings`, `AutoArmUDPSetting`. |
|
||||
| `GetConfigAttributes(ICommunication)` | `override ConfigAttributes` | Returns `S6ATCConfigAttributes` (bridge/AC-coupling NOOPs). |
|
||||
| `MakeConfigModuleFromInfoModule(InfoResult.Module)` | `override DASModule` | Creates `DASModule` with `AnalogInputDASChannel`, `StreamOutputDASChannel`, or `UARTInputDASChannel`. |
|
||||
| `AsyncConfigure(object)` | `override void` | Similar to `SLICE6AIRBR`, but includes `numUart` in `StoreConfigAttributes`. |
|
||||
| `GetIsStreaming()` | `override bool` | Same logic as `SLICE6AIRBR`. |
|
||||
| `GetStackChannelConfigTypes()` | `override int[]` | Queries `StackChannelConfigType` attribute; returns array of channel types or `[0]` on error. |
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **`DASConfigurationArg`**:
|
||||
- `BlankConfigurationRead` and `ConfigurationFailedValidation` are mutually independent; both may be `true` or `false`.
|
||||
- `DAS` is non-null at construction (enforced by caller).
|
||||
|
||||
- **`S6DBConnectedDevice`**:
|
||||
- `Port` and `SpotOnPort` are valid only when ≥ 0. Negative values indicate uninitialized state.
|
||||
- `DeviceType` is derived solely from `SerialNumber.StartsWith("S6A")`; no other logic modifies it.
|
||||
|
||||
- **`SLICE6DB3<T>`**:
|
||||
- All clock sync and PTP methods are no-ops; they never query the device or throw exceptions.
|
||||
- `SupportsTimeSynchronization` is always `false`.
|
||||
|
||||
- **`SLICEPRODB<T>`**:
|
||||
- `QueryConnectedDevices()` always sets `ConnectedDevices` to an empty array.
|
||||
- `IsSlice6Distributor()` is always `false`.
|
||||
- `IsBattery()` is hardcoded to `true`.
|
||||
- Protocol commands with `byte.MaxValue` in `MinimumProtocols` are unsupported and must not be invoked.
|
||||
|
||||
- **`SLICE6AIRBR<T>` / `SLICE6AIRTC<T>`**:
|
||||
- `GetIsStreaming()` relies on `DASArmStatus` flags (`ReceivedInvalidModeDuringSetup`, `IsInRealtime`); returns `false` if `DASArmStatus` is `null`.
|
||||
- `MaxSampleRateHz` caches the value after first query; errors default to `50000`.
|
||||
- `GetRTChannelIndices()` returns channel indices based on `_maxModuleCount` (0 → 8, 1 → 16, ≥2 → 24).
|
||||
- `AsyncConfigure` always calls `ResetEventListPriorToConfigure()` before configuration.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### Imports/Usings
|
||||
- **Common Infrastructure**:
|
||||
- `DTS.Common.Interface.DASFactory` (`IDASCommunication`, `IDASConfigurationArg`, `DASModule`, `DASChannel`, `DASInfo`, etc.)
|
||||
- `DTS.Common.Interface.Connection` (`IConnection`)
|
||||
- `DTS.Common.Interface.Communication` (`ICommunication`)
|
||||
- `DTS.Common.Enums.Hardware` (`HardwareTypes`)
|
||||
- `DTS.Common.Enums.Sensors` (`SensorConstants.BridgeType`)
|
||||
- `DTS.Common.Constant.DASSpecific` (e.g., `AttributeTypes`, `DFConstantsAndEnums`)
|
||||
- `DTS.Common.Utilities.Logging` (`APILogger`)
|
||||
- `DTS.DASLib.Command.SLICE` (e.g., `QuerySystemAttributeSLICE6`, `SetSystemAttributeSLICE6AIR`, `RetrieveSampleAverage`, `QueryChannelShuntResults`)
|
||||
|
||||
#### Inheritance Hierarchy
|
||||
- `SLICE6DB3<T>`, `SLICEPRODB<T>`, `SLICE6AIRBR<T>`, `SLICE6AIRTC<T>` all inherit from `SLICE6DB<T>` or `SLICE6_Base<T>`.
|
||||
- `SLICE6_Base<T>` likely inherits from a base `DAS` class implementing `IDASCommunication`.
|
||||
|
||||
#### Usage Inferred From Source
|
||||
- `SLICE6AIRBR<T>` and `SLICE6AIRTC<T>` are used for devices requiring advanced features (PTP, UDP alignment, thermocouple diagnostics).
|
||||
- `SLICE6DB3<T>` is used for devices without PTP.
|
||||
- `SLICEPRODB<T>` is used for battery-powered or simplified units.
|
||||
- `S6DBConnectedDevice` is populated by `QueryConnectedDevices()` in other classes (e.g., `SLICE6DB` base), though `SLICEPRODB` overrides it to do nothing.
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **`SLICEPRODB<T>.IsBattery()`**: Comment `//um maybe?` suggests uncertainty or incomplete validation. Verify behavior with hardware team.
|
||||
- **`SLICE6DB3<T>` Clock Sync Methods**: All clock sync/PTP methods are no-ops and silently succeed. Calling code must not assume actual configuration occurred.
|
||||
- **`S6DBConnectedDevice.DeviceType`**: Only updates to `SLICE6_AIR` if `SerialNumber.StartsWith("S6A")`; no other device type detection logic exists.
|
||||
- **`SLICE6AIRBR<T>.GetRTChannelIndices()`**: Returns only 6 channels (`0x00..0x05`), regardless of `_maxModuleCount`. This may be intentional for BR variant.
|
||||
- **`SLICE6AIRTC<T>.AsyncConfigure()`**: Includes `numUart` in `StoreConfigAttributes`, but `MakeConfigModuleFromInfoModule` creates `UARTInputDASChannel` only if `ModuleType.UART == configModule.ModuleType()`. Ensure `InfoResult.Module.TypeOfModule` is correctly set.
|
||||
- **`SLICE6AIRTC<T>.UARTDownload()`**: Explicitly returns `"Not supported"`; callers must check `WhatUARTToDownload` and use `QueryUARTDownload`/`GetUARTSettings` instead.
|
||||
- **`SLICE6AIRBR<T>`/`SLICE6AIRTC<T>` `MaxSampleRateHz`**: Caching may cause stale values if firmware changes dynamically. Re-query may be needed on reconnection.
|
||||
- **Protocol Versioning**: Commands with
|
||||
@@ -0,0 +1,110 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/SLICEService/SLICE Service.TriggerCheck.cs
|
||||
- DataPRO/IService/Classes/SLICEService/SLICE Service.cs
|
||||
- DataPRO/IService/Classes/SLICEService/SLICE Service.Public.cs
|
||||
generated_at: "2026-04-16T03:59:44.857737+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "358379cedd1a8fff"
|
||||
---
|
||||
|
||||
# Documentation: `Slice<T>` Trigger Check Module
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module implements the trigger check functionality for the `Slice<T>` DAS (Data Acquisition System) service class, providing asynchronous and synchronous methods to prepare, execute, and cancel hardware-level trigger and start-record integrity checks. It validates hardware input line states (e.g., short circuits on trigger/start inputs) before arming the system, and supports configurable polarity inversion for trigger and start signals. The module ensures safe pre-arm conditions by querying hardware via `InitializeHardwareLines` and reporting status via `ArmStatus`, while integrating with the broader `Slice<T>` service infrastructure for async callbacks and state management.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
The interface is implemented explicitly via `ITriggerCheckActions`. All methods follow an async pattern using `LaunchAsyncWorker` and `SliceServiceAsyncInfo` for callback reporting.
|
||||
|
||||
### `void ITriggerCheckActions.PreStartTriggerCheck(ServiceCallback callback, object userData)`
|
||||
- **Behavior**: Performs pre-startup configuration before trigger checks. If supported, sets `StartRecordPolarity` and `TriggerPolarity` attributes based on `InvertStart` and `InvertTrigger` properties using `SetSystemAttribute`. Logs exceptions but does not fail the operation on error.
|
||||
- **Async worker**: `AsyncPreStartTriggerCheck`
|
||||
|
||||
### `void ITriggerCheckActions.PostStartTriggerCheck(ServiceCallback callback, object userData)`
|
||||
- **Behavior**: No-op placeholder; immediately reports success. Presumably reserved for future or subclass use.
|
||||
|
||||
### `void ITriggerCheckActions.StartTriggerCheck(ServiceCallback callback, object userData)`
|
||||
- **Behavior**: Initiates the main trigger check sequence. Executes `AsyncStartTriggerCheck`, which:
|
||||
- Runs `InitializeHardwareLines` (if supported).
|
||||
- Checks for `TriggerInputShorted` or `StartRecordShorted` conditions; reports specific errors if detected.
|
||||
- Handles `CanceledException` and other exceptions via `info.Error`/`info.Cancel`.
|
||||
- **Async worker**: `AsyncStartTriggerCheck`
|
||||
|
||||
### `void ITriggerCheckActions.DoStartCheck(ServiceCallback callback, object userData)`
|
||||
- **Behavior**: Performs a *start-record-only* check. Executes `AsyncDoStartCheck`, which:
|
||||
- Queries hardware via `InitializeHardwareLines`.
|
||||
- Sets `ArmStatus.IsArmed = !ihl.TriggerInputShorted`
|
||||
- Sets `ArmStatus.IsRecording = ihl.StartRecordShorted`
|
||||
- Calls `SetDASArmStatus(status, true)` to persist status.
|
||||
- **Async worker**: `AsyncDoStartCheck`
|
||||
|
||||
### `void ITriggerCheckActions.DoTriggerCheck(ServiceCallback callback, object userData)`
|
||||
- **Behavior**: Performs a *full trigger check*. Executes `AsyncDoTriggerCheck`, which internally calls `DoTriggerCheckSync()`. Reports success/failure/cancel via `SliceServiceAsyncInfo`.
|
||||
|
||||
### `void ITriggerCheckActions.DoTriggerCheckSync()`
|
||||
- **Behavior**: Synchronous variant of `DoTriggerCheck`. Directly queries hardware via `InitializeHardwareLines` (no async wrapper), constructs an `ArmStatus` object with:
|
||||
- `IsTriggered = ihl.TriggerInputShorted`
|
||||
- `IsArmed = !ihl.TriggerInputShorted`
|
||||
- `IsTriggerShorted = ihl.TriggerInputShorted`
|
||||
- `IsStartShorted = ihl.StartRecordShorted`
|
||||
- Calls `SetDASArmStatus(status, true)` to update internal and persistent state.
|
||||
|
||||
### `void ITriggerCheckActions.CancelTriggerCheck(ServiceCallback callback, object userData)`
|
||||
- **Behavior**: Cancels any pending trigger check. Currently a no-op; reports success immediately via `AsyncCancelTriggerCheck`.
|
||||
|
||||
### Supporting Types (from `Slice<T>` base class)
|
||||
|
||||
#### `protected virtual void AsyncPreStartTriggerCheck(object asyncInfo)`
|
||||
- Actual worker method for `PreStartTriggerCheck`. Validates `asyncInfo` is `SliceServiceAsyncInfo`, configures polarity attributes if supported, logs exceptions, and calls `info.Success()`.
|
||||
|
||||
#### `protected virtual void AsyncStartTriggerCheck(object asyncInfo)`
|
||||
- Actual worker for `StartTriggerCheck`. Executes `InitializeHardwareLines`, checks for shorted inputs, and reports errors (`"TriggerInputShorted"`, `"StartInputShorted"`) or success.
|
||||
|
||||
#### `private void AsyncDoTriggerCheck(object asyncInfo)`
|
||||
- Wraps `DoTriggerCheckSync()` in async callback handling.
|
||||
|
||||
#### `private void AsyncDoStartCheck(object asyncInfo)`
|
||||
- Wraps synchronous start-check logic in async callback handling.
|
||||
|
||||
#### `private void AsyncCancelTriggerCheck(object asyncInfo)`
|
||||
- Wraps no-op cancellation logic.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Hardware Query Dependency**: Trigger checks rely on `InitializeHardwareLines` command support. If `IsCommandSupported(DFConstantsAndEnums.ProtocolLimitedCommands.InitHardwareInputLines)` returns `false`, the check is skipped (no error), but shorted-line detection is bypassed.
|
||||
- **Polarity Configuration**: `InvertStart` and `InvertTrigger` are only applied if `SupportsStartInversion()` and `SupportsTriggerInversion()` return `true`, respectively. Default implementations return `true`.
|
||||
- **State Consistency**: After `DoTriggerCheckSync` or `DoStartCheck`, `SetDASArmStatus(status, true)` is called, ensuring `DASArmStatus` reflects current hardware state. `IsArmed` is always `!ihl.TriggerInputShorted`.
|
||||
- **Error Reporting**: Shorted inputs (`TriggerInputShorted`, `StartRecordShorted`) result in immediate `info.Error()` with a literal string message; no exception is thrown.
|
||||
- **Callback Safety**: All async workers wrap callback invocations in `try/catch` blocks to prevent unhandled exceptions from crashing the worker thread.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Dependencies *on*:
|
||||
- `DTS.DASLib.Command.SLICE.InitializeHardwareLines` — for querying hardware input line states.
|
||||
- `DTS.DASLib.Command.SLICE.SetSystemAttribute` — for polarity configuration.
|
||||
- `DTS.Common.Interface.DASFactory.IArmStatusData` and `ArmStatus` — for status reporting.
|
||||
- `DTS.Common.Interface.Connection.IConnection` (via `Communication<T>`) — for transport.
|
||||
- `DTS.Common.Enums.DASFactory.DFConstantsAndEnums.ProtocolLimitedCommands` — to check command support.
|
||||
- `DTS.Common.Interface.DASFactory.IDASCommunication` — base interface.
|
||||
- `DTS.Common.Utilities.Logging.APILogger` — for error logging.
|
||||
- `SliceServiceAsyncInfo` — for async callback handling.
|
||||
|
||||
### Dependencies *of*:
|
||||
- This module is used by higher-level arming workflows (e.g., `IArmActions`, `IRealTimeActions`) to ensure safe pre-arm conditions.
|
||||
- Subclasses (`WinUSBSlice6Air`, `EthernetTsrAir`, etc.) inherit this behavior unless overridden.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`DoTriggerCheckSync` is synchronous but used in async wrappers**: `DoTriggerCheckSync()` performs blocking I/O; its async wrappers (`AsyncDoTriggerCheck`) do not offload the actual hardware query — only the callback dispatch. This may cause UI thread blocking if invoked on the UI thread.
|
||||
- **No cancellation support in hardware checks**: `AsyncStartTriggerCheck` and `AsyncDoStartCheck` catch `CanceledException`, but there is no mechanism to *cancel* a pending `InitializeHardwareLines.SyncExecute()` call — cancellation only affects post-query callback dispatch.
|
||||
- **Polarity inversion is hardware-dependent**: `SupportsStartInversion()` and `SupportsTriggerInversion()` are virtual and return `true` by default, but subclasses may override. If overridden to `false`, polarity settings are silently ignored.
|
||||
- **`PostStartTriggerCheck` is a stub**: Its implementation does nothing; relying on it for post-check cleanup may be unsafe.
|
||||
- **`DoStartCheck` conflates armed and recording states**: `IsArmed = !ihl.TriggerInputShorted`, but `IsRecording = ihl.StartRecordShorted`. This implies a device can be armed but *not* recording (e.g., trigger armed, start not yet pressed), which may be counterintuitive.
|
||||
- **`TriggerResult` is public but not populated**: The `ITriggerCheckResult TriggerResult` property is declared but never set by this module — callers must interpret `DASArmStatus` instead.
|
||||
- **No timeout configuration**: `SliceServiceAsyncInfo` has a `MaxTimeout` property, but it is never used or propagated to the underlying `SyncExecute()` calls — all hardware commands use fixed timeouts.
|
||||
- **`InvertStart`/`InvertTrigger` defaults to `false`**: If not explicitly set, polarity remains non-inverted. No validation ensures these are set consistently with hardware wiring.
|
||||
|
||||
None identified beyond those above.
|
||||
@@ -0,0 +1,333 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/TDAS Service/TDAS Service.cs
|
||||
- DataPRO/IService/Classes/TDAS Service/Public.cs
|
||||
- DataPRO/IService/Classes/TDAS Service/TriggerCheck.cs
|
||||
generated_at: "2026-04-16T03:58:51.683058+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "7b8b4e6a57d3d900"
|
||||
---
|
||||
|
||||
# TDAS Service Module Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
The `TDAS<T>` class is a core service implementation for the TDAS (Time-Domain Acquisition System) hardware family, providing a unified interface across multiple connection types (Ethernet, Serial) and hardware variants (G5, Rack, SIM, TOM, LabRack). It implements multiple interface contracts (`IDASCommunication`, `IConfigurationActions`, `IDiagnosticsActions`, `ITriggerCheckActions`, `IRealTimeActions`, `IArmActions`, `IDownloadActions`) to manage configuration, diagnostics, arming, triggering, real-time data streaming, and event downloading. The class acts as a bridge between high-level application logic and low-level hardware commands, encapsulating device-specific behavior (e.g., G5 vs. non-G5 modules) and maintaining runtime state (e.g., arming status, recording flags, diagnostic results). It inherits from `Communication<T>` and uses asynchronous workers via `ThreadPool.QueueUserWorkItem` for long-running operations, with callback-based progress and result reporting.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Core Properties
|
||||
|
||||
- **`bool IsEthernetDistributor()`**
|
||||
Returns `false`. Indicates this instance is not an Ethernet distributor.
|
||||
|
||||
- **`bool IsSlice6Distributor()`**
|
||||
Returns `false`. Indicates this instance is not a Slice6 distributor.
|
||||
|
||||
- **`bool IsBattery()`**
|
||||
Returns `false`. Indicates this instance is not a battery-powered device.
|
||||
|
||||
- **`bool IsTSRAIR()`**
|
||||
Returns `false`. Indicates this instance is not a TSRAIR device.
|
||||
|
||||
- **`bool IsSlice6Air()`**
|
||||
Returns `false`. Indicates this instance is not a Slice6 Air device.
|
||||
|
||||
- **`bool IsSlice6AirTc()`**
|
||||
Returns `false`. Indicates this instance is not a Slice6 Air TC device.
|
||||
|
||||
- **`bool IsScheduleEventCountSupported()`**
|
||||
Returns `false`. Schedule event counting is not supported.
|
||||
|
||||
- **`HardwareTypes GetHardwareType()`**
|
||||
Determines hardware type based on `SerialNumber` prefix:
|
||||
- `"5M"` → `G5INDUMMY` or `G5VDS` (depending on `G5Mode`)
|
||||
- `"DR"` → `TDAS_Pro_Rack`
|
||||
- `"SM"` → `SIM`
|
||||
- `"TOM"` → `TOM`
|
||||
- `"LR"` → `TDAS_LabRack`
|
||||
- Otherwise → `TDAS_Pro_Rack` (fallback)
|
||||
|
||||
- **`string SerialNumber`** *(inherited from `ICommunication`, overridden)*
|
||||
Device serial number used for identification and equality comparison.
|
||||
|
||||
- **`bool StartRecord`**
|
||||
Gets/sets whether recording has been started (protected setter).
|
||||
|
||||
- **`float InputLowVoltage`, `InputMediumVoltage`, `InputHighVoltage`**
|
||||
Input voltage thresholds.
|
||||
|
||||
- **`float BatteryLowVoltage`, `BatteryMediumVoltage`, `BatteryHighVoltage`**
|
||||
Battery voltage thresholds.
|
||||
|
||||
- **`double MinimumValidInputVoltage`, `MaximumValidInputVoltage`**
|
||||
Valid input voltage range.
|
||||
|
||||
- **`double MinimumValidBatteryVoltage`, `MaximumValidBatteryVoltage`**
|
||||
Valid battery voltage range.
|
||||
|
||||
- **`bool CheckAAF(float rate)`**
|
||||
Returns `true`. Anti-aliasing filter validation is not implemented for TDAS.
|
||||
|
||||
- **`ulong GetPhaseShiftSamples(uint ModuleIndex, double ActualSampleRate, uint HardwareAAF, ulong originalT0)`**
|
||||
Returns `0`. Phase shift is not known for TDAS modules.
|
||||
|
||||
### Configuration
|
||||
|
||||
- **`IConfigurationData ConfigData { get; set; }`**
|
||||
Holds configuration data for the device.
|
||||
|
||||
### Diagnostics
|
||||
|
||||
- **`IDiagnosticActions[] ChannelDiagnostics { get; set; }`**
|
||||
Diagnostic actions per channel.
|
||||
|
||||
- **`void SetChannelDiagnosticActions(IDiagnosticActions[] actions, bool setInDb = true)`**
|
||||
Sets channel diagnostic actions.
|
||||
|
||||
- **`IDiagnosticResult[] ChannelDiagnosticsResults { get; set; }`**
|
||||
Diagnostic results per channel.
|
||||
|
||||
- **`void ClearChannelDiagnosticsResults(bool bClearDb = true)`**
|
||||
Clears diagnostic results.
|
||||
|
||||
- **`void SetChannelDiagnosticsResults(IDiagnosticResult[] results, bool setInDb)`**
|
||||
Sets diagnostic results.
|
||||
|
||||
- **`IBaseInputValues BaseInput { get; set; }`**
|
||||
Base input values for diagnostics.
|
||||
|
||||
- **`IOptimizationValues OptimizationValues { get; set; }`**
|
||||
Optimization values for diagnostics.
|
||||
|
||||
- **`IDictionary<InputClockSource, bool> DASClockSyncStatus { get; set; }`**
|
||||
Clock synchronization status per source.
|
||||
|
||||
- **`bool ClockSyncInUTC { get; set; }`**
|
||||
Whether clock sync uses UTC.
|
||||
|
||||
- **`ClockSyncProfile DASClockSyncProfile { get; set; }`**
|
||||
Clock sync profile.
|
||||
|
||||
- **`byte PTPDomainID { get; set; }`**
|
||||
PTP domain ID.
|
||||
|
||||
- **`IArmCheckActions ArmCheckActions { get; set; }`**
|
||||
Arm check actions.
|
||||
|
||||
- **`IArmCheckResults ArmCheckResults { get; set; }`**
|
||||
Arm check results.
|
||||
|
||||
### Trigger Check
|
||||
|
||||
- **`void ITriggerCheckActions.PreStartTriggerCheck(ServiceCallback callback, object userData)`**
|
||||
No-op; immediately calls `callback` with success.
|
||||
|
||||
- **`void ITriggerCheckActions.PostStartTriggerCheck(ServiceCallback callback, object userData)`**
|
||||
No-op; immediately calls `callback` with success.
|
||||
|
||||
- **`void ITriggerCheckActions.StartTriggerCheck(ServiceCallback callback, object userData)`**
|
||||
Initiates trigger check asynchronously via `LaunchAsyncWorker`. Executes `AsyncStartTriggerCheck`.
|
||||
|
||||
- **`void ITriggerCheckActions.DoTriggerCheck(ServiceCallback callback, object userData)`**
|
||||
Performs trigger check asynchronously via `LaunchAsyncWorker`. Executes `AsyncDoTriggerCheck`.
|
||||
|
||||
- **`void ITriggerCheckActions.DoStartCheck(ServiceCallback callback, object userData)`**
|
||||
Performs start check asynchronously via `LaunchAsyncWorker`. Executes `AsyncDoStartCheck`.
|
||||
|
||||
- **`void ITriggerCheckActions.DoTriggerCheckSync()`**
|
||||
Throws `NotImplementedException` with message: `"DoTriggerCheckSync is not implemented for TDAS"`.
|
||||
|
||||
- **`void ITriggerCheckActions.CancelTriggerCheck(ServiceCallback callback, object userData)`**
|
||||
Cancels trigger check asynchronously via `LaunchAsyncWorker`. Executes `AsyncCancelTriggerCheck`.
|
||||
|
||||
### Arming
|
||||
|
||||
- **`bool GetIsInArm()`**
|
||||
Returns `DASArmStatus?.IsArmed ?? false`.
|
||||
|
||||
- **`bool GetIsInRealtime()`**
|
||||
Returns `DASArmStatus?.IsInRealtime ?? false`.
|
||||
|
||||
- **`bool GetIsStreaming()`**
|
||||
Returns `false`. Does not query hardware; only returns a flag.
|
||||
|
||||
- **`void SetInArm(bool WriteToDb)`**
|
||||
Sets `DASArmStatus.IsArmed = true`, optionally writes to DB.
|
||||
|
||||
- **`void SetInRealtime(bool WriteToDb, bool ExitRealtimeIfPossible)`**
|
||||
Sets `DASArmStatus.IsInRealtime = true`, optionally writes to DB.
|
||||
|
||||
- **`IArmStatusData DASArmStatus { get; set; }`**
|
||||
Current arming status.
|
||||
|
||||
- **`void SetDASArmStatus(IArmStatusData status, bool bSetInDb)`**
|
||||
Sets arming status and optionally writes to DB.
|
||||
|
||||
- **`void SetDASArmStatus()`**
|
||||
Sets current `DASArmStatus` to DB.
|
||||
|
||||
- **`DFConstantsAndEnums.CommandStatus AutoArmStatus { get; set; }`**
|
||||
Status of auto-arming.
|
||||
|
||||
### Downloading
|
||||
|
||||
- **`IDownloadRequest WhatToDownload { get; set; }`**
|
||||
Request specifying what to download.
|
||||
|
||||
- **`void SetWhatToDownload(IDownloadRequest request, bool bSetInDb = true)`**
|
||||
Sets download request.
|
||||
|
||||
- **`IDownloadReport EventInfo { get; set; }`**
|
||||
Event download report.
|
||||
|
||||
- **`void SetEventInfo(IDownloadReport eventInfo, bool bSetInDb = true)`**
|
||||
Sets event info.
|
||||
|
||||
- **`bool[] EventDownloadedStatus { get; set; }`**
|
||||
Download status per event.
|
||||
|
||||
- **`void SetEventDownloadStatus(bool[] status, bool storeInDb = true)`**
|
||||
Sets event download status.
|
||||
|
||||
- **`Guid[] EventGuids { get; set; }`**
|
||||
GUIDs for events.
|
||||
|
||||
- **`void SetEventGuids(Guid[] guids, bool storeInDb = true)`**
|
||||
Sets event GUIDs.
|
||||
|
||||
- **`uint[] IDownload.ExtendedFaultFlags1 { get; set; }`**
|
||||
Extended fault flags (explicit interface).
|
||||
|
||||
- **`uint[] IDownload.ExtendedFaultFlags2 { get; set; }`**
|
||||
Extended fault flags (explicit interface).
|
||||
|
||||
- **`uint[] IDownload.ExtendedFaultFlags3 { get; set; }`**
|
||||
Extended fault flags (explicit interface).
|
||||
|
||||
- **`uint[] IDownload.ExtendedFaultFlags4 { get; set; }`**
|
||||
Extended fault flags (explicit interface).
|
||||
|
||||
- **`void IDownload.SetExtendedFaultFlags(uint[][] flags)`**
|
||||
Sets extended fault flags.
|
||||
|
||||
- **`ushort[] FaultFlags { get; set; }`**
|
||||
Fault flags.
|
||||
|
||||
- **`void SetEventFaultFlags(ushort[] flags, bool storeInDb = true)`**
|
||||
Sets event fault flags.
|
||||
|
||||
- **`byte[] ArmAttempts { get; set; }`**
|
||||
Arm attempt counts.
|
||||
|
||||
- **`void SetEventArmAttemps(byte[] armAttempts, bool storeInDb = true)`**
|
||||
Sets event arm attempts.
|
||||
|
||||
### Information
|
||||
|
||||
- **`new IInfoResult DASInfo { get; set; }`**
|
||||
Device information (hides inherited `ICommunication.DASInfo`).
|
||||
|
||||
- **`void SetDASInfo(IInfoResult dasInfo, bool bSetInDb = true)`**
|
||||
Sets device info.
|
||||
|
||||
- **`void SetDASInfo()`**
|
||||
Sets device info (no DB write).
|
||||
|
||||
### Utility
|
||||
|
||||
- **`int NumberOfConfiguredChannels()`**
|
||||
Returns `ConfigData?.NumberOfConfiguredChannels() ?? 0`.
|
||||
|
||||
- **`int NumberOfChannels()`**
|
||||
Returns `ConfigData?.NumberOfChannels() ?? 0`.
|
||||
|
||||
- **`int CompareTo(IDASCommunication das)`**
|
||||
Compares `SerialNumber` lexicographically.
|
||||
|
||||
- **`bool DiagnosticsHasBeenRun { get; set; }`**
|
||||
Whether diagnostics have been run.
|
||||
|
||||
- **`bool ConfigureHasBeenRun { get; set; }`**
|
||||
Whether configuration has been run.
|
||||
|
||||
- **`override string ToString()`**
|
||||
Returns `SerialNumber` or `"Unknown DAS"`.
|
||||
|
||||
- **`override bool Equals(object right)`**
|
||||
Compares `SerialNumber` for equality (null-safe).
|
||||
|
||||
- **`override int GetHashCode()`**
|
||||
Returns hash of `SerialNumber` or `0`.
|
||||
|
||||
### Async Helper Classes
|
||||
|
||||
- **`class TDASDownloadServiceAsyncInfo`**
|
||||
Holds `TDASServiceAsyncInfo info` and `TDASServiceSetupInfo setupInfo`.
|
||||
|
||||
- **`class TDASServiceQueryConfigAsyncInfo : TDASServiceAsyncInfo`**
|
||||
Extends `TDASServiceAsyncInfo` with `bool ReadIds` property.
|
||||
|
||||
- **`class TDASServiceAsyncInfo`**
|
||||
Base async info class with:
|
||||
- `ServiceCallback callback`, `object userData`, `object functionData`
|
||||
- Methods: `Error(string, Exception)`, `Progress(int)`, `NewData(...)`, `Success()`, `Cancel()`
|
||||
|
||||
### Subclasses for Connection Types
|
||||
|
||||
- **`class EthernetTDAS : TDAS<EthernetConnection>`**
|
||||
TDAS using Ethernet connection.
|
||||
|
||||
- **`class SerialTDAS : TDAS<SerialConnection>`**
|
||||
TDAS using serial connection.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Connection Requirement**: All async operations (`StartTriggerCheck`, `DoTriggerCheck`, etc.) require `Connected == true`; otherwise, `NotConnectedException` is thrown.
|
||||
- **Hardware Type Determination**: `GetHardwareType()` relies solely on `SerialNumber` prefix; invalid prefixes default to `TDAS_Pro_Rack`.
|
||||
- **Arming State**: `DASArmStatus` must be initialized before use in arming/triggering methods; if `null`, a new `ArmStatus` is created and initialized.
|
||||
- **Module Iteration**: Trigger check operations iterate over `DASInfo.Modules`, skipping `EMPTYBANK` modules and applying G5-specific logic when `IsG5()` is true.
|
||||
- **G5 Module Handling**: For G5 devices (`SerialNumber.StartsWith("5M")`), only module index `0` is processed in trigger checks (other modules skipped).
|
||||
- **Phase Shift**: `GetPhaseShiftSamples` always returns `0`; no phase shift is applied.
|
||||
- **Equality**: Two `TDAS<T>` instances are equal if their `SerialNumber` values are equal (null/empty handled).
|
||||
- **Async Callback Safety**: All `TDASServiceAsyncInfo` callback methods (`Error`, `Success`, etc.) wrap callback invocations in `try/catch` to prevent unhandled exceptions from propagating.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Internal Dependencies (from source):
|
||||
- **`Communication<T>`**: Base class providing core communication functionality.
|
||||
- **`DTS.Common.ICommunication`**: Defines `ICommunication<T>`, `IInfoResult`, `IDownload`, etc.
|
||||
- **`DTS.Common.Interface.Connection`**: Defines `IConnection` (generic type constraint `T : IConnection, new()`).
|
||||
- **`DTS.Common.DASResource`**: Provides `Strings` (localized error messages).
|
||||
- **`DTS.Common.Utilities.Logging`**: Provides `APILogger`.
|
||||
- **`DTS.DASLib.Command.SLICE`**: Used in `TriggerCheck.cs` for `Command.TDAS.*` classes (e.g., `TestTrigger`, `QuerySerialNumber`, `TestAll`).
|
||||
- **`DTS.Common.Interface.DASFactory.*`**: Multiple interfaces (`IDiagnosticsActions`, `IConfigurationActions`, `IArmActions`, `IDownloadActions`, `ITriggerCheckActions`, `IArmStatusData`, `IDownloadRequest`, `IDownloadReport`, `IDiagnosticActions`, `IDiagnosticResult`, `IBaseInputValues`, `IOptimizationValues`, `IArmCheckActions`, `IArmCheckResults`, `IInfoResult`, `IConfigurationData`).
|
||||
- **`DTS.Common.Enums.*`**: Enums `HardwareTypes`, `DFConstantsAndEnums` (including `CommandStatus`, `ModuleType`, `VoltageStatusColor`, `ExcitationStatus`), `InputClockSource`, `ClockSyncProfile`.
|
||||
- **`DTS.DASLib.Service.Classes.Diagnostics`**: Provides `DiagnosticsActions`, `DiagnosticsResultActions`.
|
||||
|
||||
### External Dependencies:
|
||||
- **`System`**: Core types (`System.Collections.Generic`, `System.Threading`, `System.Windows.Forms`).
|
||||
- **`DTS.Common.SerialConnection`**: For `SerialConnection` type.
|
||||
|
||||
### Inferred Usage:
|
||||
- **Consumers**: Likely used by higher-level UI or orchestration layers (e.g., `DataPRO` application) to manage TDAS hardware.
|
||||
- **Dependents**: Classes implementing `IDASCommunication` or consuming `TDAS<T>` instances (e.g., configuration managers, diagnostic tools, download services).
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **`DoTriggerCheckSync` Not Implemented**: The method `ITriggerCheckActions.DoTriggerCheckSync()` throws `NotImplementedException` with a comment indicating it was intentionally left unimplemented for TDAS due to minimal impact of the original issue (ECM event line check). Using this method will crash at runtime.
|
||||
- **`IsG5()` Not Defined**: The method `IsG5()` is used in `TriggerCheck.cs` but is not defined in the provided source. It must be defined elsewhere (e.g., in `Communication<T>` or a partial class).
|
||||
- **`G5Mode` Property**: Used in `GetHardwareType()` but not defined in the provided source. Must be defined elsewhere.
|
||||
- **`Connected` Property**: Used in `LaunchAsyncWorker` and `CallSyncMethod` but not defined in the provided source. Must be defined in `Communication<T>`.
|
||||
- **`ServiceCallback` and `ServiceCallbackData`**: Types used for async callbacks but not defined in the provided source. Their structure (e.g., `CallbackStatus` enum, `AddSampleData` overloads) is inferred from usage.
|
||||
- **`TDASServiceSetupInfo` Type**: Referenced in `TDASDownloadServiceAsyncInfo` but not defined in the provided source.
|
||||
- **`IsG5()` Assumption**: The trigger check logic assumes `IsG5()` returns `true` for `"5M"` serials, but this is not explicitly stated.
|
||||
- **G5 Module Indexing**: In `AsyncStartTriggerCheck` and `AsyncCancelTriggerCheck`, G5 devices only process module index `0` (break after first non-empty module), but this is not documented in comments.
|
||||
- **`GetIsStreaming()` Always Returns `false`**: Despite the comment, it does not track streaming state dynamically.
|
||||
- **`SetInRealtime` Ignores `ExitRealtimeIfPossible`**: The parameter `ExitRealtimeIfPossible` is unused in the implementation.
|
||||
- **`SetEventArmAttemps` Typo**: Method name has typo (`SetEventArmAttemps` instead of `SetEventArmAttempts`).
|
||||
- **`TDASServiceAsyncInfo.NewData` Overloads**: Multiple overloads exist for `NewData`, but the `IList<short[][]>` overload hardcodes `sequenceNumber = 0` for all samples.
|
||||
- **`Equals`/`GetHashCode` on Null `SerialNumber`**: Two devices with `null`/empty `SerialNumber` are considered equal, which may be unintended.
|
||||
- **No-Op Trigger Check Pre/Post**: `PreStartTriggerCheck` and `PostStartTriggerCheck` do nothing—consumers may expect actual logic here.
|
||||
- **`StartRecord` Protected Setter**: Only settable internally; external code must use `SetInArm`/`SetInRealtime` to influence state.
|
||||
126
enriched-qwen3-coder-next/DataPRO/IService/Classes/TDAS.md
Normal file
126
enriched-qwen3-coder-next/DataPRO/IService/Classes/TDAS.md
Normal file
@@ -0,0 +1,126 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/IService/Classes/TDAS/TDASServiceSetupInfo.cs
|
||||
- DataPRO/IService/Classes/TDAS/TDASServiceSetupInfoLookup.cs
|
||||
- DataPRO/IService/Classes/TDAS/TDASConfig.cs
|
||||
- DataPRO/IService/Classes/TDAS/TDASModuleConfig.cs
|
||||
generated_at: "2026-04-16T03:59:19.825998+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "4eeb90f6bf6e5cce"
|
||||
---
|
||||
|
||||
# TDAS
|
||||
|
||||
## Documentation: TDAS Configuration and Setup Info Classes
|
||||
|
||||
### 1. Purpose
|
||||
This module provides data structures and configuration persistence for the TDAS (Test Data Acquisition System) service layer. It defines setup metadata (`TDASServiceSetupInfo`, `TDASServiceSetupInfoLookup`) used to configure acquisition parameters at runtime, and XML-serializable configuration classes (`TDASConfig`, `TDASModuleConfig`) that store per-module hardware and test settings to disk. These classes enable centralized management of DAS module configurations, channel definitions, and acquisition parameters across test sessions.
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `TDASServiceSetupInfo`
|
||||
- **Constructor**:
|
||||
`TDASServiceSetupInfo(string setupDescription, double? samplesPerSecond, float hardwareFilterRateHz, DFConstantsAndEnums.RecordingMode recordingMode, bool? checkoutMode)`
|
||||
Initializes a new instance with fixed (non-lookup) acquisition parameters. All parameters are required; `samplesPerSecond` and `checkoutMode` are nullable.
|
||||
|
||||
- **Properties**:
|
||||
- `string SetupDescription` – Human-readable description of the setup.
|
||||
- `double? SamplesPerSecond` – Fixed sample rate (Hz); nullable to allow optional specification.
|
||||
- `float HardwareFilterRateHz` – Hardware anti-aliasing filter rate in Hz (non-nullable).
|
||||
- `DFConstantsAndEnums.RecordingMode RecordingMode` – Recording mode enum value (e.g., continuous, triggered).
|
||||
- `bool? CheckoutMode` – Optional flag indicating whether the setup is for hardware checkout.
|
||||
|
||||
#### `TDASServiceSetupInfoLookup`
|
||||
- **Constructor**:
|
||||
`TDASServiceSetupInfoLookup(string setupDescription, Dictionary<string, double> sampleRateLookup, Dictionary<string, float> aafLookup, DFConstantsAndEnums.RecordingMode recordingMode, bool? checkoutMode)`
|
||||
Initializes a lookup-based setup info where sample rate and filter rate vary by DAS unit (identified by string key, likely serial number).
|
||||
|
||||
- **Properties**:
|
||||
- `string SetupDescription` – Same as above.
|
||||
- `Dictionary<string, double> SamplesPerSecondLookup` – Maps DAS identifier (e.g., serial number) to its sample rate.
|
||||
- `Dictionary<string, float> HardwareFilterRateHzLookup` – Maps DAS identifier to its hardware filter rate.
|
||||
- `DFConstantsAndEnums.RecordingMode RecordingMode` – Same as above.
|
||||
- `bool? CheckoutMode` – Same as above.
|
||||
|
||||
#### `TDASConfig`
|
||||
- **Constructor**:
|
||||
`TDASConfig()` – Default constructor.
|
||||
`TDASConfig(string fileName, bool deleteIfPresent)` – Loads config from `DASConfigs/<fileName>` (relative to executing assembly directory). If `deleteIfPresent` is `true`, deletes existing file before proceeding; otherwise, attempts to deserialize.
|
||||
|
||||
- **Properties**:
|
||||
- `Dictionary<string, TDASModuleConfig> Modules` – Read-only dictionary of modules keyed by serial number.
|
||||
- `string FileName` – Full path to the config file (read-only).
|
||||
|
||||
- **Methods**:
|
||||
- `void SetModule(TDASModuleConfig module)` – Adds or updates a module in `_modules` by `SerialNumber`.
|
||||
- `TDASModuleConfig GetModule(TDASModuleConfig module)` – Retrieves module by `SerialNumber`; if missing, adds the provided module and returns it.
|
||||
- `void ReadXml(XmlReader reader)` – Deserializes XML into `_modules` (expects `<TDASConfig><Modules>...</Modules></TDASConfig>` structure).
|
||||
- `void WriteXml(XmlWriter writer)` – Serializes `_modules` to XML.
|
||||
- `XmlSchema GetSchema()` – Returns `null` (per `IXmlSerializable` convention for schema-less types).
|
||||
|
||||
#### `TDASModuleConfig`
|
||||
- **Constructor**:
|
||||
`TDASModuleConfig()` – Default constructor.
|
||||
`TDASModuleConfig(string fileName)` – Loads module config from `DASConfigs/<fileName>`.
|
||||
|
||||
- **Properties**:
|
||||
- `string SerialNumber` – Unique identifier for the module.
|
||||
- `string TestId` – Test identifier string.
|
||||
- `string TestDescription` – Human-readable test description.
|
||||
- `DFConstantsAndEnums.RecordingMode RecordingMode` – Recording mode (default: `InvalidArmMode`).
|
||||
- `float AAFilterRateHz` – Anti-aliasing filter rate (default: `0`).
|
||||
- `double PreTriggerSeconds` – Pre-trigger hold time (default: `0`).
|
||||
- `double PostTriggerSeconds` – Post-trigger record time (default: `0`).
|
||||
- `string FirmwareVersion` – Module firmware version string.
|
||||
- `UInt64? MaxEventStorageSpaceInBytes` – Optional max storage for event data.
|
||||
- `int ModuleArrayIndex` – Zero-based index for module ordering (default: `0`).
|
||||
- `string FileName` – Full path to config file (read-only).
|
||||
- `Dictionary<int, DASChannel> Channels` – Internal dictionary of channels keyed by `ModuleChannelNumber` (not exposed directly; accessed via `SetChannel`/`GetChannel` overloads).
|
||||
|
||||
- **Methods**:
|
||||
- `void SetChannel(OutputTOMDigitalChannel channel)` / `SetChannel(OutputSquibChannel channel)` / `SetChannel(AnalogInputDASChannel channel)` – Adds or updates channel by `ModuleChannelNumber`.
|
||||
- `AnalogInputDASChannel GetChannel(AnalogInputDASChannel channel)` / `GetChannel(OutputSquibChannel channel)` / `GetChannel(OutputTOMDigitalChannel channel)` – Retrieves channel by `ModuleChannelNumber`; if missing, adds the provided channel and returns it.
|
||||
- `void ReadXml(XmlReader reader)` – Deserializes XML into module properties and channels. Handles legacy configs (e.g., missing `ModuleArrayIndex` element).
|
||||
- `void WriteXml(XmlWriter writer)` – Serializes module properties and channels to XML.
|
||||
- `XmlSchema GetSchema()` – Returns `null`.
|
||||
- `virtual void WriteElementStart(XmlWriter writer)` – Writes `<TDASModule xsi:type="...">` with concrete type.
|
||||
- `virtual void WriteElementEnd(XmlWriter writer)` – Closes the `<TDASModule>` element.
|
||||
|
||||
### 3. Invariants
|
||||
- **`TDASConfig`**:
|
||||
- `_modules` dictionary is keyed by `TDASModuleConfig.SerialNumber`; duplicates are overwritten by `SetModule`.
|
||||
- `FileName` is always an absolute path constructed relative to the executing assembly’s directory under `DASConfigs/`.
|
||||
- **`TDASModuleConfig`**:
|
||||
- `RecordingMode` defaults to `DFConstantsAndEnums.RecordingMode.InvalidArmMode` (invalid state); must be explicitly set to a valid mode.
|
||||
- `AAFilterRateHz`, `PreTriggerSeconds`, `PostTriggerSeconds` default to `0`.
|
||||
- `MaxEventStorageSpaceInBytes` is nullable; invalid values (negative or ≥ `ulong.MaxValue`) are logged and ignored.
|
||||
- `ModuleArrayIndex` defaults to `0`; invalid values (negative or ≥ `int.MaxValue`) are logged and ignored.
|
||||
- Channel dictionaries use `ModuleChannelNumber` as the key; duplicate channel numbers overwrite existing entries.
|
||||
- **XML Serialization**:
|
||||
- `TDASConfig` expects `<TDASConfig><Modules>...</Modules></TDASConfig>`.
|
||||
- `TDASModuleConfig` expects `<TDASModule>...</TDASModule>` with child elements in a fixed order (e.g., `SerialNumber`, `TestId`, `RecordingMode`, etc.).
|
||||
- Channel serialization uses `WriteElementStart`/`WriteElementEnd` to include `xsi:type` for polymorphic deserialization.
|
||||
|
||||
### 4. Dependencies
|
||||
- **Imports/Usings**:
|
||||
- `DTS.Common.DAS.Concepts` – Provides `DASChannel`, `AnalogInputDASChannel`, `OutputSquibChannel`, `OutputTOMDigitalChannel`.
|
||||
- `DTS.Common.Enums.DASFactory` – Provides `DFConstantsAndEnums.RecordingMode`.
|
||||
- `DTS.DASLib.Command.SLICE` – Referenced but not directly used in these classes (likely transitive dependency).
|
||||
- `DTS.Common.Utilities.Logging` – Provides `APILogger` for error logging during XML deserialization.
|
||||
- Standard .NET libraries: `System.Xml`, `System.IO`, `System.Collections.Generic`, `System`.
|
||||
- **Consumers**:
|
||||
- `TDASConfig` and `TDASModuleConfig` are used by the TDAS service layer to persist/load configurations.
|
||||
- `TDASServiceSetupInfo`/`TDASServiceSetupInfoLookup` are likely used by higher-level configuration or initialization logic (e.g., service startup, test setup UI).
|
||||
- XML serialization implies integration with external tools or UIs that read/write config files.
|
||||
|
||||
### 5. Gotchas
|
||||
- **`TDASServiceSetupInfoLookup` naming**: The constructor parameter `aafLookup` is named inconsistently with the property `HardwareFilterRateHzLookup`; this may cause confusion.
|
||||
- **`GetModule`/`GetChannel` behavior**: Both methods add the provided object to the dictionary if missing, which can silently mutate state. Callers must ensure the input object is fully initialized.
|
||||
- **XML deserialization robustness**:
|
||||
- `RecordingMode` and numeric fields (`AAFilterRateHz`, `PreTriggerSeconds`, etc.) use `try/catch` + `APILogger.Log` for errors, but silently default to `0`/`InvalidArmMode` on failure.
|
||||
- `ModuleArrayIndex` is wrapped in a `try/catch` block to handle legacy configs (missing element), but other elements lack this fallback.
|
||||
- **Path construction**: Config paths are hardcoded to `DASConfigs/` under the assembly directory; this may not work in all deployment scenarios (e.g., ClickOnce, containerized).
|
||||
- **Channel polymorphism**: `WriteElementStart` uses `GetType()` to write `xsi:type`, but `ReadXml` relies on the `type` attribute to deserialize into `OutputSquibChannel`, `OutputTOMDigitalChannel`, or `AnalogInputDASChannel`. Mismatched types in XML will cause silent fallback to `AnalogInputDASChannel`.
|
||||
- **No validation**: No validation is performed on `SetupDescription`, `SerialNumber`, or `TestId` (e.g., empty strings allowed).
|
||||
- **`SamplesPerSecond` vs `SamplesPerSecondLookup`**: The nullable `double?` in `TDASServiceSetupInfo` vs. `Dictionary<string, double>` in `TDASServiceSetupInfoLookup` suggests two distinct use cases (single rate vs. per-DAS rates), but the distinction is not enforced programmatically.
|
||||
Reference in New Issue
Block a user