--- source_files: - Common/DTS.Common.DataModel/Classes/Diagnostics/Diagnostics.cs generated_at: "2026-04-16T03:34:15.620410+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "9ad8e7542b559d55" --- # Diagnostics **Documentation Page: `Diagnostics` Class (`DataPROWin7.DataModel.Classes.Diagnostics`)** --- ### 1. **Purpose** The `Diagnostics` class orchestrates the initialization and configuration of Data Acquisition System (DAS) hardware and associated channels for diagnostic testing. It handles the transition from test setup definition to a state where DAS units are ready for real-time data collection or diagnostics execution. Specifically, it queries DAS configurations, validates hardware/sensor compatibility, synchronizes test setup metadata (e.g., XML export to DAS and local storage), and prepares channel-level configurations (analog, CAN, squib, TOM digital) for diagnostics. It serves as the central coordinator between the high-level test template and low-level DAS communication interfaces. --- ### 2. **Public Interface** #### `public class LevelTriggerCapableChannel` Encapsulates level-triggering configuration for a single hardware channel, enabling conversion to/from ISO-level `LevelTriggerChannel` objects. - **`public LevelTriggerCapableChannel(HardwareChannel hwch, SensorData sd, SensorCalibration sc, IGroup group, IGroupChannel groupChannel)`** Constructor. Initializes the channel with hardware, sensor, calibration, and group context. Stores calibration on `sd`. - **`public HardwareChannel HardwareChannel { get; }`** Immutable reference to the underlying hardware channel. - **`public string DASOrModuleSerialNumber { get; }`** Returns the DAS serial number for most hardware types, but returns the *module* serial number for `TDAS_Pro_Rack` and `TDAS_LabRack`. - **`public double LessThanValue { get; private set; }`** Threshold value for "less than" triggering (EU). - **`public double GreaterThanValue { get; private set; }`** Threshold value for "greater than" triggering (EU). - **`public bool IsLessThanThresholdEnabled { get; set; }`** Enables/disables the "less than" threshold. Updates `_testSetupLevelTrigger` if present. - **`public bool IsGreatherThanThresholdEnabled { get; set; }`** Enables/disables the "greater than" threshold. Updates `_testSetupLevelTrigger` if present. - **`public double InsideUpperBoundValue`, `InsideLowerBoundValue`, `OutsideUpperBoundValue`, `OutsideLowerBoundValue { get; private set; }`** Bound values for window-based triggering. - **`public DTS.Common.ISO.LevelTriggerChannel ToISOLevelTriggerChannel()`** Constructs and returns an ISO `LevelTriggerChannel` object, applying special handling for TSRAIRGo high-G sensors (e.g., disabling thresholds by default). - **`public void FromISOLevelTriggerChannel(DTS.Common.ISO.LevelTriggerChannel channel)`** Populates internal state from an ISO `LevelTriggerChannel`. Sets `_testSetupLevelTrigger` reference. --- #### `public class Diagnostics` - **`public bool Reset(TestTemplate currentTest, List dasList, Dictionary dasSampleRateList, DASHardware[] hardware, StatusHelpers.SetProgressValueDelegate setProgressFunction, User currentUser)`** Performs initial reset steps: marks all DAS as unclean, attempts partial configuration query (with timeout), and returns `false` if no data has ever been downloaded (`DataNeverDownloaded(dasList)`). Does *not* perform full diagnostics. - **`public void ContinueReset(TestTemplate currentTest, List dasList, Dictionary dasSampleRateList, DASHardware[] hardware, StatusHelpers.SetProgressValueDelegate setProgressFunction, User currentUser)`** Continues reset: calls `UpdateConfigAndPrepareForDiagnostics`, then `RunDiagnostics`. (Note: `RunDiagnostics` is not defined in this file—its implementation is external.) --- #### `public static bool SortOutConfigAnalog(...)` - **`public static bool SortOutConfigAnalog(AnalogInputDASChannel dasChannel, string key, int moduleChannelNumber, IDASCommunication das, DASHardware h, IDASModule mod, SortOutConfigParams soParams, ReportErrorsDelegate ReportErrors = null)`** Configures an `AnalogInputDASChannel` using test setup metadata (sensor, calibration, group channel). Handles: - Excitation, coupling, filter bypass, zero point, sensitivity, linearization, IEPE mode, trigger thresholds (via `LevelTriggerCapableChannel`), and more. - Special logic for TSRAIR low-G (AC coupling), non-linear calibrations, and IEPE channels. - Reports errors via `ReportErrors` if IEPE state mismatch cannot be reprogrammed. - Returns `false` if no valid calibration found. --- #### `public static void SortOutConfigCAN(...)` - **`public static void SortOutConfigCAN(IDASChannel c, int moduleChannelNumber, SortOutConfigParams soParams)`** Configures a `CANInputDASChannel` with CAN-specific parameters (FD, bitrate, SJW, file type) from the first channel in `soParams.TestTemplate.ChannelsForGroup`. --- #### `public static void SortOutConfigSquib(...)` - **`public static void SortOutConfigSquib(ref int currentChannelIdx, IDASModule mod, string key, ref int moduleChannelNumber, IDASChannel c, IDASCommunication das, SortOutConfigParams soParams)`** Configures a squib pair (voltage and current channels) from test setup. Handles fire delay/duration, tolerance, output current, filter bypass, and channel naming (`.1`/`.2` suffix handling). Requires both VO and CU channels. --- #### `public static void SortOutConfigTOMDigitalChannel(...)` - **`public static void SortOutConfigTOMDigitalChannel(IDASChannel c, string key, int moduleChannelNumber, SortOutConfigParams soParams)`** Configures an `OutputTOMDigitalChannel` with delay, duration, limit duration, and output mode from test setup. --- #### `public static void SortOutConfig(...)` - **`public static void SortOutConfig(TestTemplate currentTest, List ldas, bool clearDiagnostics, DASHardware[] allHardware, User currentUser)`** Top-level configuration entry point. Orchestrates channel ordering, DAS-specific configuration (`SortOutConfigDAS`), and sets DAS order indices for TMATS support. --- #### `public static void SortOutConfigDAS(...)` - **`public static void SortOutConfigDAS(IDASCommunication das, User currentUser, SortOutConfigParams soParams, ReportErrorsDelegate reportErrors = null)`** Applies `SortOutConfig*` methods to each channel in a DAS’s module configuration. Handles clock, UART, stream in/out, and normal modes. Sets module-level properties (AA filter rate, pre/post-trigger, recording mode, sample rate, etc.). Disables channels not in the test. --- ### 3. **Invariants** - **`LevelTriggerCapableChannel`**: - `IsLessThanThresholdEnabled` and `IsGreatherThanThresholdEnabled` default to `true` and `false`, respectively. - For TSRAIRGo high-G sensors (`SensorConstants.IsTSRAirHighGChannel`), thresholds are *disabled by default* in `ToISOLevelTriggerChannel`, and `TriggerOutsideBounds` is forced `true` if the sensor is high-G. - `_testSetupLevelTrigger` is only updated when set via `FromISOLevelTriggerChannel`. - **`Diagnostics`**: - `Reset` *must* be called before `ContinueReset`; `ContinueReset` assumes partial configuration (via `Reset`) has occurred. - `SortOutConfigAnalog` requires a valid `SensorCalibration` (`sc`) matching the sensor’s supported excitation; otherwise, it returns `false`. - Squib configuration (`SortOutConfigSquib`) requires *both* voltage and current output channels to exist in the DAS module (throws `NotSupportedException` otherwise). - IEPE status mismatch between sensor and DAS channel is only auto-corrected if `CanReProgram()` returns `true`; otherwise, errors are reported and the channel may be left in an invalid state. --- ### 4. **Dependencies** #### **Imports / Dependencies Used** - `DataPROWin7.Common`, `DTS.Common.*` (core data model, enums, utilities, logging, hardware interfaces) - `DTS.DASLib.Service.ConfigurationService` (for `GetConfiguration`, `StoreTestSetupXML`) - `DTS.Slice.Users.UserSettings`, `DTS.Common.Constant.DASSpecific`, `DTS.Common.DAS.Concepts.*` - `DTS.Common.Interface.*` (e.g., `IDASCommunication`, `IDASModule`, `IGroup`, `IGroupChannel`) - `DTS.Slice.Users.User`, `DTS.Common.Interface.Sensors.AnalogDiagnostics` - `DTS.Slice.Users.UserSettings`, `DTS.Common.SharedResource.Strings` - `DataPROWin7.DataModel.Classes.Hardware`, `DTS.Common.Classes.*`, `DTS.Slice.*` #### **Key External Components** - `ConfigurationService`: Used for querying DAS configuration and storing test setup XML. - `SensorConstants`, `SensorCalibration`, `MeasurementUnitList`, `SerializedSettings`, `APILogger`, `Defaults`, `ExportTestSetup`. - `DASHardware`, `HardwareChannel`, `AnalogInputDASChannel`, `CANInputDASChannel`, `OutputSquibChannel`, `OutputTOMDigitalChannel`, `IDASCommunication`. #### **Depended Upon By** - Likely called by higher-level test orchestration (e.g., `TestTemplate.RunDiagnostics`, `TestSetupBuilder`). - `LevelTriggerCapableChannel` is used internally in `SortOutConfigAnalog` to map test-level level triggers to DAS channel properties. --- ### 5. **Gotchas** - **Timeout Handling**: `QueryConfigurationPartial` uses a hardcoded 150-second timeout for TSRAIRGo (`TSRAIRGO_QUERYCONFIG_TIMEOUT = 150000 ms`); other systems use `SerializedSettings.ResolveChannels_SLICE_QueryConfigTimeoutSec * 1000`. Timeout exceptions are logged and rethrown. - **IEPE Mismatch**: If `dasChannel.IEPEChannel` differs from `sensor.Bridge == IEPE`, and `CanReProgram()` is `false`, errors are reported via `ReportErrors`, but the method does *not* return `false`—execution continues, potentially leaving the channel misconfigured. - **Non-Linear Calibration Logic**: The `bUseNonLinear` flag logic is complex: - Uses non-linear calibration if `!sc.NonLinear || !sc.LinearAdded || CalibrationBehaviors.LinearIfAvailable != TestTemplate.CalibrationBehavior`. - Zero point and sensitivity calculations differ for linear vs. non-linear calibrations. - Special handling for `IRTraccCalculationType.IRTraccCalFactor` and `Polynomial`. - **Squib Channel Naming**: Squib current channel description suffix `.1` is replaced with `.2`, and `ChannelName2` is updated accordingly. - **TSRAIRGo High-G Sensors**: Thresholds are disabled by default in `ToISOLevelTriggerChannel`, and `TriggerOutsideBounds` is forced `true` if the sensor is high-G—even if `channel.TriggerOutsideBounds` is `false`. - **`Reset` Returns `false` on `DataNeverDownloaded`**: This check is not defined in the source file—behavior is inferred from usage. Its implementation is unknown. - **`SortOutConfigAnalog` Does Not Short-Circuit on Failure**: If calibration lookup fails, it logs and returns `false`, but the caller (`SortOutConfigDAS`) continues to the next channel (per comment: *"for instance if we fail to sort out this channel because of support excitation you still want to go onto the next channel"*). - **`SortOutConfigDAS` Disables Channels Not in Test**: If a DAS is not in `soParams`, *all* its channels are disabled via `DisableChannel(c)`. The `DisableChannel` method is not defined in this file. - **`ExportCurrentTestSetupFields` Clears Groups**: A temporary `TestTemplate` is created with `Groups.Clear()` before exporting DAS/Fields-only XML—this may affect downstream logic if `currentTest` is reused. - **`LevelTriggerCapableChannel` Constructor Parameter Order**: The constructor order is `(HardwareChannel, SensorData, SensorCalibration, IGroup, IGroupChannel)`. `IGroup` is unused in the constructor body (per source), but included—could be legacy or for future use. - **`DiagnosticsMode` Handling**: For analog channels, `DiagnosticsMode` is taken directly from `sensor.DiagnosticsMode`. For squib/TOM digital, it is *hardcoded to `false`*. - **`SortOutConfigParams` Incomplete Source**: The class definition is truncated mid-method (`SetHard...`). Full behavior of `SetHard*` methods is unknown. - **`RunDiagnostics` Not Defined**: `ContinueReset` calls `RunDiagnostics`, but its implementation is not in this file—behavior is undefined here. --- *End of Documentation.*