This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
---
source_files:
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/UserISOUtility.cs
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/DigitalInputPopulateChannels.cs
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/SquibPopulateChannels.cs
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/AnalogPopulateChannels.cs
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/DASPopulateChannels.cs
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/DigitalOutputPopulateChannels.cs
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/SensorsPopulateChannels.cs
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/SummaryRowHelper.cs
- DataPRO/DataPRO/Controls/TestSetups/Import/Classes/GroupChannelHelper.cs
generated_at: "2026-04-16T04:20:26.330131+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "8f0536e102b7ae08"
---
# Documentation: Test Setup Import Channel Population Module
## 1. Purpose
This module handles the population and synchronization of channel models between hardware (DAS), sensors, and test setup group channels during test setup import. It bridges the gap between raw hardware channel data (`IDASHardware`, `IHardwareChannel`), sensor definitions (`SensorData`), and logical groupings in the test template (`TestTemplate.ChannelsForGroup`). The module ensures that hardware channels are correctly mapped to sensors and that channel-specific properties (e.g., ISO/user codes, squib/fire settings, digital output modes) are propagated to the appropriate logical channel representations. It supports multiple channel types—Analog, Digital Input, Digital Output, and Squib—via dedicated populate classes implementing shared interfaces.
## 2. Public Interface
### Static Classes
#### `UserCodeISOUtility`
- **`ShowUserCode()`** (`bool`)
Returns `true` if the current `ISOViewMode` setting is `ISOAndUserCode` or `UserCodeOnly`. Controls visibility of user-defined channel names/codes in UI.
- **`ShowISOCode()`** (`bool`)
Returns `true` if the current `ISOViewMode` setting is `ISOAndUserCode` or `ISOOnly`. Controls visibility of ISO-standard channel names/codes in UI.
### Classes Implementing `ISensorsPopulateChannels` and/or `IDASPopulateChannels`
#### `DigitalInputPopulateChannels`
- **Constructor**: Not exposed (no public constructor defined; relies on dependency injection or external instantiation).
- **`PopulateDASChannels(...)`** (`IEnumerable<DASChannelModel>`)
Filters hardware channels to those where `IsDigitalIn == true`, then delegates to `DASPopulateChannels`.
- **`PopulateSensorsChannels(...)`** (`IEnumerable<ChannelModel>`)
Filters sensors to those where `IsDigitalInput() == true`, then delegates to `SensorsPopulateChannels`.
#### `SquibPopulateChannels`
- **`PopulateDASChannels(...)`** (`IEnumerable<DASChannelModel>`)
Filters hardware channels to those where `IsSquib == true`, *excluding odd-numbered channels* (per `ch.IsSquib && 1 == ch.ChannelNumber % 2` check in `DASPopulateChannels`). Delegates to `DASPopulateChannels`.
- **`PopulateSensorsChannels(...)`** (`IEnumerable<ChannelModel>`)
Filters sensors to those where `IsSquib() == true`, then delegates to `SensorsPopulateChannels`.
#### `AnalogPopulateChannels`
- **Constructor**: `AnalogPopulateChannels(Dictionary<string, string> hardwareChannelIdToSensorId)`
Initializes with a mapping from hardware channel IDs to sensor EIDs.
- **`PopulateDASChannels(...)`** (`IEnumerable<DASChannelModel>`)
Filters hardware channels to those where `IsAnalog == true`, then delegates to `DASPopulateChannels`.
- **`PopulateSensorsChannels(...)`** (`IEnumerable<ChannelModel>`)
Filters sensors to those where `IsAnalog() == true`, then delegates to `SensorsPopulateChannels`.
#### `DigitalOutputPopulateChannels`
- **Constructor**: `DigitalOutputPopulateChannels(Dictionary<string, string> hardwareChannelIdToSensorId)`
Initializes with a mapping from hardware channel IDs to sensor EIDs.
- **`PopulateDASChannels(...)`** (`IEnumerable<DASChannelModel>`)
Filters hardware channels to those where `IsDigitalOut == true`. For each channel:
- If a mapping exists (`HardwareChannelIdToSensorId`), assigns `EID`.
- If a corresponding `IGroupChannel` exists (via `channelIdToGroupChannel`), copies digital output settings (`DigitalOutputMode`, `DigitalOutputDurationMs`, etc.) and creates/updates `ChannelModel`.
- Otherwise, creates a new `ChannelModel` with default digital output settings.
#### `DASPopulateChannels`
- **Constructor**: `DASPopulateChannels(Dictionary<string, string> hardwareChannelIdToSensorId, Predicate<IHardwareChannel> hardwareChannelFilter)`
Stores hardware channel filter and EID mapping.
- **`PopulateDASChannels(...)`** (`IEnumerable<DASChannelModel>`)
Iterates over DAS hardware (skipping SLICE Ethernet controllers), applies filter, and:
- Skips squib channels on odd channel numbers (`ch.IsSquib && 1 == ch.ChannelNumber % 2`).
- Creates `DASChannelModel` for each qualifying hardware channel.
- If `HardwareChannelIdToSensorId` contains the channel ID, assigns `EID`, then attempts to link to `IGroupChannel` via sensor lookup.
- Populates `channelIdToDASChannel` dictionary.
#### `SensorsPopulateChannels`
- **Constructor**: `SensorsPopulateChannels(Predicate<SensorData> channelTypeFilter)`
Stores sensor type filter.
- **`GetSensorToChannels(...)`** (`Dictionary<int, List<IGroupChannel>>`)
Returns group channels grouped by `SensorId`, removing channels with `SensorId == 0`.
- **`BuildHardwareLookup(...)`** (`void`)
Links `IGroupChannel.HardwareChannel` by matching `DASId` and `DASChannelIndex` to hardware.
- **`PopulateSensorsChannels(...)`** (`IEnumerable<ChannelModel>`)
Filters sensors using `_channelTypeFilter`, then builds assigned `ChannelModel`s for sensors with hardware channels, or unassigned models otherwise. Calls `SetPropertiesFromGroupChannel` to copy settings.
### Helper Classes
#### `SummaryRowHelper`
- **`GetSummaries(...)`** (`void`)
Populates `found`, `missing`, and `extra` lists based on comparison between test setup sensors and DAS hardware channels. Uses `GetFoundEids`, `GetSummaryRowFound`, `GetSummaryRowMissing`, and `GetSummaryRowExtraEids` internally. Includes logic to exclude TOM squib odd channels and handle missing sensor descriptions.
#### `GroupChannelHelper`
- **`UpdateGroupChannelsInTestTemplate(...)`** (`void`)
Synchronizes `IGroupChannel` instances in `TestTemplate.ChannelsForGroup` with `DASChannelModel`s from all channel types. Handles:
- Updating existing group channels with new sensor assignments.
- Removing group channels with no sensor.
- Creating new group channels for newly assigned sensors.
- Preserving hardware channel assignments from previous runs (FB 31874).
- Copying channel-specific properties (squib, digital output, analog, etc.) via `AssignProperties`.
## 3. Invariants
- **Hardware Channel Filtering**: Each `Populate*Channels` class enforces a specific filter on hardware channels (e.g., `IsAnalog`, `IsDigitalIn`, `IsSquib`, `IsDigitalOut`). Filters are applied in `DASPopulateChannels` and `DigitalOutputPopulateChannels`.
- **Squib Channel Exclusion**: For squib channels, odd-numbered channels (`ChannelNumber % 2 == 1`) are *always skipped* during DAS population (FB 43723).
- **EID Mapping**: `HardwareChannelIdToSensorId` is used to map hardware channels to sensor EIDs. If absent, no sensor assignment occurs.
- **Hardware Channel Uniqueness**: Each hardware channel ID maps to at most one `DASChannelModel` in `channelIdToDASChannel`.
- **Group Channel Consistency**: `GroupChannelHelper.UpdateGroupChannelsInTestTemplate` ensures that:
- Group channels with no hardware channel are removed *unless* they were pre-assigned (FB 31874).
- Sensor assignments are updated only if a valid `SerialNumber` exists in the `DASChannelModel`.
- Channel properties (e.g., `Range`, `Polarity`, `SquibFireMode`, `DigitalOutputMode`) are copied from `DASChannelModel` to `IGroupChannel`.
- **ISO/User Code Visibility**: `ShowUserCode()` and `ShowISOCode()` depend solely on `Common.SerializedSettings.ISOViewMode`, which must be set before calling.
## 4. Dependencies
### Imports/Usings (External)
- `DTS.Common.*`: Core enums (`IsoViewMode`, `Sensors.SensorConstants`), interfaces (`IDASHardware`, `IHardwareChannel`, `IGroupChannel`, `ISensorData`, `IDASCommunication`), classes (`ChannelRepresentation`, `DASHardware`, `GroupChannel`, `SummaryRow`), and utilities (`Logging.APILogger`, `SharedResource.Strings.StringResources`).
- `DTS.SensorDB`: `SensorData`, `DbOperations`.
- `DataPROWin7.DataModel`: `TestTemplate`, `ChannelModel`, `DASChannelModel`, `DASHardware`.
- `System.*`: LINQ, collections, predicates.
### Module Dependencies
- **Consumers**: Likely invoked during test setup import (e.g., `ImportObject`, `TestSetupImporter`).
- **Depends on**:
- `Common.SerializedSettings.ISOViewMode` (for `UserCodeISOUtility`).
- `TestTemplate.ChannelsForGroup` (for `GroupChannelHelper`).
- `Sensors()` and `TestSetups()` from `ImportObject` (for `SummaryRowHelper`).
- Hardware configuration (`IDASHardware`, `IDASCommunication`) from DAS devices.
## 5. Gotchas
- **Squib Odd-Channel Exclusion**: The `DASPopulateChannels.PopulateDASChannels` method *unconditionally skips* squib channels on odd channel numbers (`1 == ch.ChannelNumber % 2`). This is hardcoded and applies to all callers, not just `SquibPopulateChannels`. Ensure hardware configuration accounts for this.
- **SLICE Ethernet Controller Skipping**: `DASPopulateChannels` skips any DAS where `IsSLICEEthernetController == true`. This may cause channels on such devices to be silently ignored.
- **`HardwareChannelIdToSensorId` Requirement**: If this dictionary is empty or missing keys, `DASChannelModel.EID` will not be assigned, and sensor linking will fail.
- **`CleanSerialNumber` Logic**: `GroupChannelHelper.CleanSerialNumber` replaces test-specific serial numbers (e.g., `"TEST_SPECIFIC_ANALOG_SERIAL"`) with the constant string, but only if the input matches *exactly* the resource string value. This may cause mismatches if the constant is updated.
- **Digital Output Channel Assignment**: `DigitalOutputPopulateChannels` relies on `IGroupChannel.HardwareChannel` being pre-assigned (via `DASChannelIndex` and `DASId`) to link to existing group channels. If hardware channel assignment is missing, new group channels are created.
- **FB References**: Comments like `//FB 41819` refer to internal bug/feature numbers. These may be useful for historical context but are not self-documenting.
- **No Public Constructors**: `DigitalInputPopulateChannels`, `SquibPopulateChannels`, and `AnalogPopulateChannels` lack public constructors, implying instantiation is handled externally (e.g., via DI or factory). This is not explicit in the source.
- **Event Subscription**: `DigitalOutputPopulateChannels` subscribes to `DigitalOutputChannelChanged` on `DASChannelModel`. Ensure event handlers are cleaned up to avoid memory leaks if instances are reused.
- **`GetSummaries` Side Effects**: `GetSummaries` modifies `ref` lists (`found`, `missing`, `extra`) and uses `importObject.TestSetups().First()`—assumes at least one test setup exists.