8.1 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T02:08:30.752253+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | ce57e1c33a0387ff |
Documentation: EQX Test Setup Parser Module
1. Purpose
This module provides parsing logic for EQX files that contain test setup information (i.e., groupings of sensors into test groups and assignment to a test template). It is part of the DTS.Common.Import namespace and is specifically responsible for interpreting group-to-sensor mappings defined in an EQX file, constructing TestTemplate, static IGroup, and SensorData objects accordingly, and integrating them into the ImportObject. It depends on prior parsing of sensor and calibration data (handled by EQXSensorsParser) and uses EQXGroupImport to implement group creation logic. The parser aborts the import if the EQX file lacks test setup data (e.g., no GroupNameTestObjectLookup).
2. Public Interface
EQXTestSetupParser class
Constructor
public EQXTestSetupParser(
IImportNotification importNotification,
EqxImportOptions eqxImportOptions,
IGroupImport groupImport,
EquipmentExchange.EQXSensorDatabase eqxSensorDatabase,
bool createDynamicGroups)
Initializes the parser with dependencies required for parsing and group creation.
importNotification: Used for reporting errors and progress.eqxImportOptions: Configuration options for EQX import.groupImport: Implementation ofIGroupImport(typicallyEQXGroupImport) for group creation logic.eqxSensorDatabase: Pre-populated sensor database fromEQXSensorsParser.createDynamicGroups: Flag indicating whether dynamic groups should be created (iffalse, static groups are created).
Override Method
public override void Parse(ref ImportObject importObject)
Main entry point for parsing test setup data from the EQX file.
- Validates
FileNameandimportObject(throwsArgumentNullExceptionifimportObjectisnull). - Checks for presence of test setup data in
sensorImportData.GroupNameTestObjectLookup; if missing, adds a critical error and aborts. - Assigns group-to-object and group-to-sensor lookups from the database to
importObject. - Extracts setup name from XML using
ParseSetupName, falls back to file name. - Skips if a test setup with the same name already exists in
importObject. - Calls
FixCalibrationsto ensure sensors use the correct calibration from import. - Delegates group creation to
AssignGroupsToTestSetup. - Cleans sensor data placeholders, clears existing sensors, adds cleaned sensors, and adds the resulting
TestTemplateand static groups toimportObject. - Sets
importObject.TestSetupImportFileFormat.
Private Helper Methods
private void FixCalibrations(ImportObject importObject)
For each sensor in importObject, retrieves calibrations via CalibrationLookup(sensor.SerialNumber), sorts them, and assigns the first (earliest) calibration to sensor.Calibration. Logs exceptions via APILogger.
private Tuple<TestTemplate, List<IGroup>, List<SensorData>> AssignGroupsToTestSetup(
TestTemplate testTemplate,
ImportObject importObject,
Dictionary<string, List<string>> groupNameSensorListLookup,
IGroupImport groupImport,
IImportNotification importNotification)
Implements the group assignment logic (moved here per FB 36879).
- Reverses channel order using
GroupHelper.ReverseChannelOrder. - Calls
groupImport.GetGroupSensorLookupto buildgroupSensorLookup. - Normalizes sensor IDs via
GroupHelper.NormalizeSensorIds. - Re-applies
FixCalibrations(to revert potential calibration resets from normalization). - Calls
groupImport.CreateGroups(...)to generate groups and test setup. - Returns
Tuple<TestTemplate, List<IGroup>, List<SensorData>>, ornullon failure (with error reported viaimportNotification). - Returns
nullfortestTemplate/staticGroupsifgroupImport.CreateGroupsreturnsnull.
private string ParseSetupName(string filename)
Parses the <SetupName> value from the first <Fields> element under <Sensors> in the EQX XML file. Returns empty string on any failure (including missing element or XML parse error).
3. Invariants
importObjectmust be non-null at start ofParse; otherwise,ArgumentNullExceptionis thrown.GroupNameTestObjectLookupmust be non-null and non-empty insensorImportData; otherwise, a critical error is added and parsing aborts.- Calibrations must be sorted before selecting the first one in
FixCalibrations; sorting is performed explicitly. - Sensors are cleared and re-added after cleaning (
GroupHelper.CleanUneededSensorDataPlaceHolder) to ensure consistency. - Test setup name uniqueness is enforced: if a test setup with the same name already exists in
importObject.TestSetups(), the method returns early without modifying the object. EQXGroupImport.CreateGroupsmay returnnull, in which caseAssignGroupsToTestSetupreturns a tuple ofnullvalues and no groups/test setup are added.
4. Dependencies
Dependencies of this module:
EQXSensorsParser: Must run first to populateImportObject.Sensors(),ImportObject.CalibrationsLookup(), andEquipmentExchange.EQXSensorDatabase(viaEQXSensorDatabase.Read).EquipmentExchange.EQXSensorDatabase: Must be pre-populated with sensor, calibration, and group mapping data from the EQX file.IGroupImport: Typically implemented byEQXGroupImport; providesGetGroupSensorLookupandCreateGroups.GroupHelper: Used forReverseChannelOrder,NormalizeSensorIds, andCleanUneededSensorDataPlaceHolder.DbOperations: Referenced indirectly (e.g.,GetChannelSettingDefaults,TagsGet, etc.) viaEQXGroupImportandEQXSensorsParser.APILogger: Used for logging failures inFixCalibrations.StringResources: Used for error messages (e.g.,Import_EQXFileNotForTestSetup).
Dependencies on this module:
EQXSensorsParser: Must be invoked beforeEQXTestSetupParserto ensure sensor and calibration data are available.ImportObjectconsumers: Any downstream logic that consumesTestTemplate,StaticGroups, orSensorsafter import will depend on this parser’s output.
5. Gotchas
- Calibration resets after normalization:
GroupHelper.NormalizeSensorIdsmay reset sensor calibrations;FixCalibrationsis called twice (before and after normalization) to mitigate this (see FB 44105 comment inAssignGroupsToTestSetup). - Setup name extraction is fragile:
ParseSetupNamesilently returnsstring.Emptyon any XML parsing error or missing<SetupName>element. - No overwrite of existing test setups: If a test setup with the same name already exists,
Parsereturns early without warning or modification (only silent skip). - Group creation may silently fail: If
groupImport.CreateGroupsthrows or returnsnull,AssignGroupsToTestSetupreturnsnulland no groups/test setup are added, but only the exception message is reported viaimportNotification.ReportErrors(no additional context). ImportCreateDynamicGroupsflag is not used directly in this class: It is passed toEQXGroupImport.CreateGroupsviaEQXTestSetupParserconstructor, but the flag is stored as a property inEQXSensorsParser, notEQXTestSetupParser.- Excitation errors are computed but not reported:
EQXSensorsParser.GetExcitationErrors()collects errors but theTODO Report the errorscomment indicates they are not currently surfaced (only inEQXSensorsParser, not here). SensorDatais modified in-place:FixCalibrationsmutatessensor.Calibrationdirectly; callers must be aware of side effects.- No handling of duplicate sensor serial numbers: If duplicate serial numbers exist in the import, behavior is undefined (e.g.,
sensorLookupinEQXGroupImportwill only retain the last one).