Files
DP44/enriched-qwen3-coder-next/Common/DTS.Common/Interface/TestSetups.md
2026-04-17 14:55:32 -04:00

94 lines
8.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
source_files:
- Common/DTS.Common/Interface/TestSetups/ITestSetupsView.cs
- Common/DTS.Common/Interface/TestSetups/ITestSetupsViewModel.cs
- Common/DTS.Common/Interface/TestSetups/ITestDASOrder.cs
- Common/DTS.Common/Interface/TestSetups/IROIPeriodChannelRecord.cs
- Common/DTS.Common/Interface/TestSetups/ITestSetupHardwareRecord.cs
- Common/DTS.Common/Interface/TestSetups/ITestSetupROIRecord.cs
- Common/DTS.Common/Interface/TestSetups/ICalculatedChannelRecord.cs
- Common/DTS.Common/Interface/TestSetups/IISFFile.cs
generated_at: "2026-04-16T03:02:46.464691+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "4654e7bd069055b4"
---
# TestSetups
## Documentation: TestSetups Module
---
### 1. Purpose
This module defines a set of interfaces and data contracts that model test setup configurations within the DTS (Data Acquisition and Test System) platform. It serves as the canonical abstraction layer for test setup metadata—including hardware composition (DAS units), regions of interest (ROIs), calculated channels, and ISF (Instrumented Sensor File) format specifications—enabling consistent data exchange between UI, business logic, and persistence layers. The interfaces are designed to support serialization, validation, and domain-specific operations (e.g., ordering DAS units, computing derived signals), forming the backbone of test setup management functionality.
---
### 2. Public Interface
#### Interfaces (All in `DTS.Common.Interface` or `DTS.Common.Interface.TestSetups` namespace)
| Interface | Signature | Description |
|-----------|-----------|-------------|
| `ITestSetupsView` | `interface ITestSetupsView : IBaseView` | Marker interface for the view layer associated with test setup UI. Inherits `IBaseView`. |
| `ITestSetupsViewModel` | `interface ITestSetupsViewModel : IBaseViewModel` | Marker interface for the view model layer associated with test setup UI. Inherits `IBaseViewModel`. |
| `ITestDASOrder` | `interface ITestDASOrder` | Enables ordering of DAS units within a test setup via the `DASIndex` property. |
| `IROIPeriodChannelRecord` | `interface IROIPeriodChannelRecord` | Represents a row in the `ROIPeriodChannels` database table. Maps a channel to a specific ROI. Properties: `TestSetupROIId`, `ChannelName`, `ChannelId`. |
| `ITestSetupHardwareRecord` | `interface ITestSetupHardwareRecord` | Represents a row in the test setup hardware configuration table. Properties: `DASId`, `TestSetupId`, `AddDAS`, `SamplesPerSecond`, `IsClockMaster`, `AntiAliasFilterRate`, `PTPDomainId`. |
| `ITestSetupROIRecord` | `interface ITestSetupROIRecord` | Represents a row in the `TestSetupROIs` database table. Defines a time interval (ROI) and metadata. Properties: `TestSetupROIId`, `TestSetupId`, `Suffix`, `ROIStart`, `ROIEnd`, `IsEnabled`, `IsDefault`. |
| `ICalculatedChannelRecord` | `interface ICalculatedChannelRecord` | Represents a calculated channel definition. Properties: `Name`, `TestSetupName`, `Id`, `Operation` (enum), `CalculatedValueCode`, `InputChannelIds` (array), `CFCForInputChannels`, `ChannelFilterClassForOutput`, `TestSetupId`, `ViewInRealtime`, `ClipLength`. |
| `IISFFile` | `interface IISFFile` | Models an ISF file structure (used for sensor metadata in test setups). Properties: `HeaderLine1`, `TestSetupName`, `NumberOfRecords`, `TestType`, `TestDivision`, `TCFile`, `HeaderLine2`, `HeaderLine3`, `Records`. Methods: `AddRecord`, `WriteToFile`, `AddSensors`. |
| `IISFSensorRecord` | `interface IISFSensorRecord` | Models a single sensor record within an ISF file (4 × 80-byte records). Provides typed access to fixed-width fields (e.g., `DataChannelNumber`, `Sensitivity`, `SerialNumber`, `EngineeringUnits`, `SensorType`, `C1``C3`, comments, etc.). Methods: `SetDataChannelNumber`, `SetCapacity`, `GetCapacity`, `SetSensitivity`, `GetSensitivity`, `SetBridgeResistance`, `SetC1`, `GetC1`, `SetC2`, `SetC3`, `SetSensorComment`, `Write`, `SetSensor`. |
#### Enumerations
| Enum | Values | Description |
|------|--------|-------------|
| `Operations` (in `ICalculatedChannelRecord`) | `SUM = 1`, `AVERAGE = 2`, `IRTRACC3D = 3`, `IRTRACC3D_ABDOMEN = 4`, `IRTRACC3D_LOWERTHORAX = 5`, `Resultant = 6`, `HIC = 7` | Defines supported operations for calculated channels. Each value has a `[DescriptionResource]` attribute for localization. |
| `ISFKnownChannelTypes` (in `IISFFile.ConstantsAndEnums`) | `VS`, `VU`, `SB`, `TI`, `TC`, `CT`, `XP`, `P4`, `VF`, `NB`, `EX` | Known channel type codes in ISF files. `TI`, `TC`, and `CT` are explicitly noted as non-analog. |
| `ConstantsAndEnums.RECORD_LENGTH` | `80` | Fixed record length (in bytes) for ISF file records. |
---
### 3. Invariants
- **`ITestDASOrder`**: `DASIndex` must be non-negative and unique per DAS unit within a test setup to ensure deterministic ordering.
- **`ITestSetupROIRecord`**: `ROIStart``ROIEnd`. `IsDefault` must be true for exactly one ROI per test setup (enforced by domain logic, not interface).
- **`ITestSetupHardwareRecord`**: `SamplesPerSecond` > 0; `AntiAliasFilterRate` ≥ 0; `PTPDomainId` ∈ [0, 255] (due to `byte` type).
- **`ICalculatedChannelRecord`**: `InputChannelIds` must be non-null and non-empty for operations requiring inputs (e.g., `SUM`, `AVERAGE`). `ClipLength` ≥ 0.
- **`IISFFile`**: `NumberOfRecords` must match the actual count of `Records`. `HeaderLine1`, `TestSetupName`, etc., must conform to fixed-width, fixed-position parsing rules (e.g., `TestSetupName` starts at char 7, length 8).
- **`IISFSensorRecord`**: All character arrays are fixed-length (per `RECORD_LENGTH = 80`). Field offsets are strictly defined (e.g., `Tag` at char 75, length 2). `SetSensorComment` must populate `CommentPart1`, `CommentPart2`, `CommentPart3` consistently.
- **`ISFKnownChannelTypes`**: `TI`, `TC`, and `CT` are non-analog; other types are analog. This distinction affects interpretation of calibration coefficients (`C1`, `C2`, `C3`).
---
### 4. Dependencies
#### Dependencies *of* this module:
- `DTS.Common.Base` (for `IBaseView`, `IBaseViewModel`)
- `System.ComponentModel` (for `TypeConverter` on `Operations`)
- `DTS.Common.Converters` (for `EnumDescriptionTypeConverter`)
- `DTS.Common.Interface.Sensors` (for `ISensorData` used in `IISFFile.AddSensors`)
- `DTS.Common.Enums.DASFactory.DFConstantsAndEnums` (for `DASFactory.DFConstantsAndEnums` namespace import in `ITestSetupHardwareRecord`)
#### Dependencies *on* this module:
- UI layer (via `ITestSetupsView`, `ITestSetupsViewModel`)
- Data persistence layer (maps `*Record` interfaces to database tables: `TestSetupROIs`, `ROIPeriodChannels`, calculated channels table)
- ISF file I/O layer (implements `IISFFile`, `IISFSensorRecord`)
- Signal processing layer (uses `ICalculatedChannelRecord` and `Operations` to configure channel calculations)
---
### 5. Gotchas
- **ISF Record Parsing**: Field positions and lengths in `IISFSensorRecord` are *hardcoded* (e.g., `Sensitivity` at char 42, length 11). Changing ISF spec requires updating all field accessors.
- **`Operations` Enum**: `IRTRACC3D_*` values imply 3D acceleration calculations (Thorax/Abdomen/LowerThorax); misuse may cause incorrect signal processing.
- **`ClipLength` Semantics**: Not all operations use `ClipLength`; its meaning is operation-specific (e.g., max over clip for `HIC`).
- **`Sensitivity` Units**: For polynomial calibrations, `Sensitivity` (c0) is stored as `/1000` of the actual value (see `ICalculatedChannelRecord` comments).
- **`UserIdSensorIDIsNotSpecified`**: A boolean flag in `IISFSensorRecord`; `true` means user ID is *not* specified (counterintuitive naming).
- **`NumberOfRecords` is Read-Only**: In `IISFFile`, `NumberOfRecords` is a read-only property; it must be updated internally by `AddRecord`.
- **No Validation in Interfaces**: All interfaces are pure contracts; validation rules (e.g., `ROIStart ≤ ROIEnd`) are enforced by consumers, not the interfaces themselves.
- **`ISFFile` Header Fields**: `HeaderLine2` and `HeaderLine3` are documented as unused; relying on them may introduce fragility.
None identified beyond those explicitly noted in source comments.