Files
DP44/docs/ai/Common/DTS.Common.DataModel/Classes/Diagnostics.md

240 lines
9.7 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common.DataModel/Classes/Diagnostics/Diagnostics.cs
generated_at: "2026-04-17T15:43:31.698963+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "7b5c8f5df247c453"
---
# Documentation: Diagnostics Module
## 1. Purpose
This module manages diagnostic operations and hardware configuration for Data Acquisition System (DAS) devices in a test environment. It handles the complete lifecycle of test setup configuration including: exporting test setups to XML, storing configurations on DAS hardware, configuring individual channel types (analog, squib, TOM digital, CAN), managing level trigger settings, and preparing hardware for diagnostic runs. The module serves as the bridge between test template definitions and the actual hardware configuration required to execute tests.
---
## 2. Public Interface
### Class: `LevelTriggerCapableChannel`
A wrapper class for managing level trigger configuration on hardware channels.
**Constructor:**
```csharp
public LevelTriggerCapableChannel(
HardwareChannel hwch,
SensorData sd,
SensorCalibration sc,
IGroup group,
IGroupChannel groupChannel)
```
**Properties:**
| Property | Type | Description |
|----------|------|-------------|
| `HardwareChannel` | `HardwareChannel` | Read-only access to the underlying hardware channel |
| `DASOrModuleSerialNumber` | `string` | Returns module serial number for TDAS_Pro_Rack/TDAS_LabRack, otherwise hardware serial number |
| `LessThanValue` | `double` | Threshold value for "less than" trigger (default: 0D) |
| `GreaterThanValue` | `double` | Threshold value for "greater than" trigger (default: 0D) |
| `IsLessThanThresholdEnabled` | `bool` | Enables/disables less-than threshold trigger |
| `IsGreatherThanThresholdEnabled` | `bool` | Enables/disables greater-than threshold trigger (note: typo in property name) |
| `InsideUpperBoundValue` | `double` | Upper bound for inside-window trigger |
| `InsideLowerBoundValue` | `double` | Lower bound for inside-window trigger |
| `OutsideUpperBoundValue` | `double` | Upper bound for outside-window trigger |
| `OutsideLowerBoundValue` | `double` | Lower bound for outside-window trigger |
**Methods:**
```csharp
public DTS.Common.ISO.LevelTriggerChannel ToISOLevelTriggerChannel()
```
Converts this configuration to an ISO-compatible `LevelTriggerChannel` object. TSR Air High G channels receive special handling for trigger enablement.
```csharp
public void FromISOLevelTriggerChannel(DTS.Common.ISO.LevelTriggerChannel channel)
```
Populates this object's properties from an ISO `LevelTriggerChannel`. TSR Air High G channels have inverted logic for threshold enablement.
---
### Class: `Diagnostics`
Main class for diagnostic operations and configuration management.
**Constructor:**
```csharp
public Diagnostics()
```
**Public Methods:**
```csharp
public bool Reset(
DataModel.TestTemplate currentTest,
List<IDASCommunication> dasList,
Dictionary<string, int> dasSampleRateList,
DASHardware[] hardware,
StatusHelpers.SetProgressValueDelegate setProgressFunction,
DTS.Slice.Users.User currentUser)
```
Initiates a reset operation. Marks all DAS as unclean, attempts partial connection, and returns `true` if data has never been downloaded, `false` otherwise.
```csharp
public void ContinueReset(
DataModel.TestTemplate currentTest,
List<IDASCommunication> dasList,
Dictionary<string, int> dasSampleRateList,
DASHardware[] hardware,
StatusHelpers.SetProgressValueDelegate setProgressFunction,
DTS.Slice.Users.User currentUser)
```
Continues the reset process by updating configuration and running diagnostics.
```csharp
public static void SortOutConfig(
DataModel.TestTemplate currentTest,
List<IDASCommunication> ldas,
bool clearDiagnostics,
DASHardware[] allHardware,
DTS.Slice.Users.User currentUser)
```
Main configuration orchestration method. Sets DAS order indices, builds channel lookups, and configures all DAS devices.
```csharp
public static void SortOutConfigDAS(
IDASCommunication das,
DTS.Slice.Users.User currentUser,
SortOutConfigParams soParams,
ReportErrorsDelegate reportErrors = null)
```
Configures a single DAS device, iterating through all modules and channels.
```csharp
public static bool SortOutConfigAnalog(
AnalogInputDASChannel dasChannel,
string key,
int moduleChannelNumber,
IDASCommunication das,
DASHardware h,
IDASModule mod,
SortOutConfigParams soParams,
ReportErrorsDelegate ReportErrors = null)
```
Configures analog input channels. Returns `false` if calibration cannot be found. Sets extensive properties including sensitivity, engineering units, excitation, level triggers, and IEPE configuration.
```csharp
public static void SortOutConfigCAN(
IDASChannel c,
int moduleChannelNumber,
SortOutConfigParams soParams)
```
Configures CAN input channels with FD settings, bitrates, and file type.
```csharp
public static void SortOutConfigSquib(
ref int currentChannelIdx,
IDASModule mod,
string key,
ref int moduleChannelNumber,
IDASChannel c,
IDASCommunication das,
SortOutConfigParams soParams)
```
Configures squib output channels. Handles both Voltage (VO) and Current (CU) channels as a pair. Throws `NotSupportedException` if both channels are not present.
```csharp
public static void SortOutConfigTOMDigitalChannel(
IDASChannel c,
string key,
int moduleChannelNumber,
SortOutConfigParams soParams)
```
Configures TOM digital output channels with delay, duration, and output mode settings.
**Delegate:**
```csharp
public delegate void ReportErrorsDelegate(List<string> errors);
```
---
### Class: `SortOutConfigParams` (nested in `Diagnostics`)
Parameter container for configuration operations.
**Public Members:**
| Member | Type | Description |
|--------|------|-------------|
| `TestTemplate` | `DataModel.TestTemplate` | The test template being configured |
| `FilterLookup` | `Dictionary<string, double>` | Lookup for filter settings |
| `AllHardware` | `DASHardware[]` | Array of all hardware (setter appears truncated) |
**Methods:**
```csharp
public int GetHardwareChannelToAbsoluteDisplayOrderCount()
public bool ContainsHardwareChannelDisplayOrder(string key)
public int GetHardwareChannelAbsoluteDisplayOrder(string key)
public int GetMaxAbsoluteDisplayOrder()
public void AddGroupChannels(IGroupChannel[] channels)
public void SetAbsoluteDisplayOrderFromIndex(string key, IGroupChannel ch)
public HardwareChannel GetHardwareChannel(string key)
```
---
## 3. Invariants
1. **Channel Key Format**: Channel keys are constructed as `"{DASId}_{ChannelNumber}"` and must be unique within a test setup.
2. **Squib Channel Pairing**: Squib channels must exist as adjacent pairs (Voltage then Current). The method throws `NotSupportedException` with message "require both VO and CU channels" if the second channel is missing.
3. **Calibration Requirement**: `SortOutConfigAnalog` returns `false` if no valid calibration can be found for the sensor's supported excitation types.
4. **TSR Air High G Special Handling**:
- Greater-than and less-than threshold triggers are always disabled for TSR Air High G channels
- Trigger outside bounds is always enabled for TSR Air High G channels
5. **IEPE Configuration**: If a channel's IEPE status disagrees with the sensor's bridge type, the system attempts to reprogram the DAS. If reprogramming fails, errors are reported via the `ReportErrors` delegate.
6. **DAS Inclusion**: DAS devices not part of the current test have all their channels disabled via `DisableChannel()`.
---
## 4. Dependencies
**This module depends on:**
- `DTS.Common.Classes.Hardware` - `DASHardware`, `HardwareChannel`
- `DTS.Common.Interface.DASFactory` - `IDASCommunication`, `IDASModule`, `IDASChannel`
- `DTS.Common.Interface.Channels` - Channel interfaces
- `DTS.Common.Interface.Groups.GroupList` - `IGroup`, `IGroupChannel`
- `DTS.DASLib.Service` - `ConfigurationService`, `ServiceBase`
- `DTS.Common.Utilities.Logging` - `APILogger`
- `DTS.Slice.Users.UserSettings` - `SerializedSettings`, `Defaults`
- `DTS.SensorDB` - `SensorData`, `SensorCalibration`, `SensorModel`
- `DTS.Common.Classes.Sensors` - Sensor-related classes
- `DTS.Common.Classes.Groups` - `GroupChannel`
- `DTS.Common.Enums` - Various enumerations
- `DTS.Common.ISO` - ISO-related data structures
- `DataPROWin7.Common` - `StatusHelpers`, `ExportTestSetup`
**What depends on this module:**
- Cannot be determined from source alone (no callers visible in this file)
---
## 5. Gotchas
1. **Typo in Property Name**: `IsGreatherThanThresholdEnabled` contains a typo ("Greather" instead of "Greater"). This is part of the public API and cannot be changed without breaking compatibility.
2. **TSR Air Go Timeout**: The constant `TSRAIRGO_QUERYCONFIG_TIMEOUT` is set to 150000ms (2.5 minutes), which is significantly longer than standard query timeouts.
3. **Legacy TOM Filter Behavior**: When `SerializedSettings.UseLegacyTOMCFC` is true and sample rate exceeds `TestObjectHelper.TDC_LEGACY_TOM_CUTOFF_SPS`, squib channels use a hardcoded legacy filter frequency (`TestObjectHelper.TDC_LEGACY_TOM_HIGH_FILTER`).
4. **Filter Class ISO Default**: If `sensor.FilterClassIso` is `"?"`, it is silently replaced with `"P"` (Prefiltered > CFC 1000).
5. **Squib Description Suffix Handling**: If a squib description ends with ".1", the paired current channel's description is modified to end with ".2".
6. **Non-Linear Calibration Gain Selection**: For non-linear sensors, the code performs "guesswork" to select an appropriate input range, explicitly noting in comments that it ignores "a whole bunch of problems, like negative or inverted outputs."
7. **File Truncated**: The source file is truncated mid-method (`SetHard...`), indicating there may be additional public members not visible in the provided source.