285 lines
9.5 KiB
Markdown
285 lines
9.5 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- Common/DTS.Common.Import/ImportError.cs
|
||
|
|
- Common/DTS.Common.Import/ParseProcessor.cs
|
||
|
|
- Common/DTS.Common.Import/TsetSetupImportSensorInfo.cs
|
||
|
|
- Common/DTS.Common.Import/CsvUtil.cs
|
||
|
|
- Common/DTS.Common.Import/ImportNotification.cs
|
||
|
|
- Common/DTS.Common.Import/XMLParseProcessor.cs
|
||
|
|
- Common/DTS.Common.Import/CalibrationImport.cs
|
||
|
|
- Common/DTS.Common.Import/GroupHelper.cs
|
||
|
|
- Common/DTS.Common.Import/ImportObject.cs
|
||
|
|
generated_at: "2026-04-17T15:32:34.821158+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "148f67b9afc6f9fe"
|
||
|
|
---
|
||
|
|
|
||
|
|
# DTS.Common.Import Module Documentation
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module provides the core infrastructure for importing test configuration data into the DTS system. It handles parsing of CSV and XML files containing sensor definitions, calibrations, test setups, groups, hardware configurations, and related metadata. The module centralizes all imported data through the `ImportObject` container, provides progress notification via `IImportNotification`, and includes utilities for calibration processing and group management.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### ImportError.cs
|
||
|
|
|
||
|
|
**Enum: `ImportSeverityError`**
|
||
|
|
```csharp
|
||
|
|
public enum ImportSeverityError
|
||
|
|
{
|
||
|
|
Critical,
|
||
|
|
Error,
|
||
|
|
Warning,
|
||
|
|
Info
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Class: `ImportError`**
|
||
|
|
```csharp
|
||
|
|
public string Message { get; set; }
|
||
|
|
public ImportSeverityError Severity { get; set; }
|
||
|
|
public bool ContinueImportOnError { get; set; } = true; // defaults to true
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ParseProcessor.cs
|
||
|
|
|
||
|
|
**Class: `ParseProcessor`**
|
||
|
|
|
||
|
|
Constructor:
|
||
|
|
```csharp
|
||
|
|
public ParseProcessor(ImportObject importObject, IEnumerable<string> fileNames, IEnumerable<IParseVariant> parseVariants)
|
||
|
|
```
|
||
|
|
|
||
|
|
Methods:
|
||
|
|
```csharp
|
||
|
|
public ImportObject Process()
|
||
|
|
```
|
||
|
|
Iterates through all file names and parse variants, invoking `variant.Parse(ref _importObject)` for each combination. Returns the modified `ImportObject`.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### TsetSetupImportSensorInfo.cs
|
||
|
|
|
||
|
|
**Class: `TsetSetupImportSensorInfo`** (sealed)
|
||
|
|
|
||
|
|
Constructors:
|
||
|
|
```csharp
|
||
|
|
public TsetSetupImportSensorInfo(string serialNumber, string isoCode, string isoChannelName,
|
||
|
|
string userCode, string userChannelName, string dasSerialNumber, int dasChannelIdx)
|
||
|
|
|
||
|
|
public TsetSetupImportSensorInfo(string serialNumber, string isoCode)
|
||
|
|
```
|
||
|
|
|
||
|
|
Properties (all read-only except `GroupType`):
|
||
|
|
```csharp
|
||
|
|
public string IsoCode { get; }
|
||
|
|
public string IsoChannelName { get; }
|
||
|
|
public string UserCode { get; }
|
||
|
|
public string UserChannelName { get; }
|
||
|
|
public string SerialNumber { get; }
|
||
|
|
public string GroupType { get; set; } // read-write
|
||
|
|
public string DASSerialNumber { get; }
|
||
|
|
public int DASChannelIndex { get; }
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### CsvUtil.cs
|
||
|
|
|
||
|
|
**Static Class: `CsvUtil`**
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static CsvReader CreateCsvReader(string filename)
|
||
|
|
```
|
||
|
|
Creates a `CsvReader` using `CultureInfo.InvariantCulture` with a `StreamReader` for the given filename.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static List<string> ReadFields(CsvReader csvReader, bool readNextLine = true)
|
||
|
|
```
|
||
|
|
Reads fields from the CSV reader. If `readNextLine` is true, calls `csvReader.Read()` first. Returns a list of trimmed field values from all columns (index 0 to `ColumnCount - 1`).
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ImportNotification.cs
|
||
|
|
|
||
|
|
**Class: `ImportStatus`**
|
||
|
|
```csharp
|
||
|
|
public string Status { get; set; }
|
||
|
|
public PossibleStatus PossibleStatus { get; set; }
|
||
|
|
public ImportExtraStatus ExtraStatus { get; set; }
|
||
|
|
```
|
||
|
|
|
||
|
|
**Interface: `IImportNotification`**
|
||
|
|
```csharp
|
||
|
|
Action ImportDone { get; }
|
||
|
|
Action<List<string>> ReportErrors { get; }
|
||
|
|
Action<double> SetProgress { get; }
|
||
|
|
Action<ImportStatus> SetStatus { get; }
|
||
|
|
```
|
||
|
|
|
||
|
|
**Class: `ImportNotification`** (implements `IImportNotification`)
|
||
|
|
|
||
|
|
Constructors:
|
||
|
|
```csharp
|
||
|
|
public ImportNotification(Action<List<string>> reportErrors, Action<ImportStatus> setStatus,
|
||
|
|
Action<double> setProgress, Action importDone)
|
||
|
|
|
||
|
|
public ImportNotification() // creates no-op handlers for all actions
|
||
|
|
```
|
||
|
|
|
||
|
|
Properties:
|
||
|
|
```csharp
|
||
|
|
public Action<List<string>> ReportErrors { get; private set; }
|
||
|
|
public Action<ImportStatus> SetStatus { get; private set; }
|
||
|
|
public Action<double> SetProgress { get; private set; }
|
||
|
|
public Action ImportDone { get; private set; }
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### XMLParseProcessor.cs
|
||
|
|
|
||
|
|
**Class: `XMLParseProcessor`**
|
||
|
|
|
||
|
|
Constructor:
|
||
|
|
```csharp
|
||
|
|
public XMLParseProcessor(ImportObject importObject, IImportNotification importNotification,
|
||
|
|
IEnumerable<string> fileNames, Func<bool> isCancelled, bool skipNormalizing)
|
||
|
|
```
|
||
|
|
|
||
|
|
Properties:
|
||
|
|
```csharp
|
||
|
|
public List<IUIItems> UIItems { get; set; }
|
||
|
|
```
|
||
|
|
|
||
|
|
Methods:
|
||
|
|
```csharp
|
||
|
|
public ImportObject Process()
|
||
|
|
```
|
||
|
|
Processes XML files using parsers created by `XmlParserFactory`. Sets status to `ImportExtraStatus.ReadingXML`, calculates progress based on items completed vs. total items to complete.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### CalibrationImport.cs
|
||
|
|
|
||
|
|
**Class: `CalibrationImport`** (implements `ICalibrationImport`)
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public SensorCalibration CheckForExcitationCalibration(SensorCalibration sc, double sensitivity,
|
||
|
|
ExcitationVoltageOptions.ExcitationVoltageOption excitation, string EU)
|
||
|
|
```
|
||
|
|
Checks if the first calibration record has the specified excitation; if not, adds a new `CalibrationRecord` with the given parameters.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public SensorCalibration AddLinearCalRecordIfNeeded(SensorCalibration sc, bool savedIsProportional, bool savedRemoveOffset)
|
||
|
|
```
|
||
|
|
If `sc.Records.Records` has exactly one entry, adds a second linear calibration record and restores `IsProportional` and `RemoveOffset` flags.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public SensorCalibration AddLinearZeroMethodIfNeeded(SensorCalibration sc, ZeroMethodType zeroMethodType,
|
||
|
|
double zeroMethodStart, double zeroMethodEnd)
|
||
|
|
```
|
||
|
|
If `sc.ZeroMethods.Methods` has exactly one entry, adds a second `ZeroMethod` with the specified parameters.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### GroupHelper.cs
|
||
|
|
|
||
|
|
**Static Class: `GroupHelper`**
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static IGroup CreateEmptyGroup()
|
||
|
|
```
|
||
|
|
Returns a new `GroupList.Model.Group(true)`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static void GetTestSensorParameters(out string isoCode, out string isoChannelName,
|
||
|
|
out string userCode, out string userChannelName, ParseParameters pp, SensorData sd,
|
||
|
|
out string dasSerialNumber, out int dasChannelIdx)
|
||
|
|
```
|
||
|
|
Extracts sensor parameters, preferring values from `ParseParameters` dictionaries when available.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static IReadOnlyDictionary<string, int> GetDAS(
|
||
|
|
Dictionary<string, List<TsetSetupImportSensorInfo>> groupSensorLookupgroupSensorLookup,
|
||
|
|
DASHardware[] allDAS)
|
||
|
|
```
|
||
|
|
Builds a lookup dictionary mapping DAS serial numbers to DAS IDs.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static int? GetGroupId(TestTestObject testObject, Dictionary<string, int> groupIdMapping,
|
||
|
|
List<TestObject> groupList)
|
||
|
|
```
|
||
|
|
Finds the group ID for a test object by traversing group relationships.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static List<string> ReverseChannelOrder(TestTemplate testTemplate,
|
||
|
|
Dictionary<string, string> sensorGroupNameLookup, List<SensorData> sensors)
|
||
|
|
```
|
||
|
|
Returns a reversed list of channel order strings in format `{testTemplate.Name}_{groupName}_{comment}`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static List<SensorData> CleanUneededSensorDataPlaceHolder(
|
||
|
|
Dictionary<string, List<SensorCalibration>> calibrationLookup, List<SensorData> sensorList)
|
||
|
|
```
|
||
|
|
Removes sensor data entries that are ISO-channel-only placeholders or have invalid default calibrations.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public static List<SensorData> NormalizeSensorIds(List<SensorData> sensorList)
|
||
|
|
```
|
||
|
|
Normalizes sensor database IDs: existing sensors get their real IDs; new sensors get negative IDs (-2, -3, etc.).
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ImportObject.cs
|
||
|
|
|
||
|
|
**Class: `ImportObject`**
|
||
|
|
|
||
|
|
This is the central data container for imports. Key properties and methods:
|
||
|
|
|
||
|
|
**Properties:**
|
||
|
|
```csharp
|
||
|
|
public ImportFormats SourceFormat { get; set; } = ImportFormats.NOT_SPECIFIED;
|
||
|
|
public ImportFileFormat TestSetupImportFileFormat { get; set; } = ImportFileFormat.NoTestSetup;
|
||
|
|
```
|
||
|
|
|
||
|
|
**Format Detection:**
|
||
|
|
```csharp
|
||
|
|
public ImportFileFormat GetImportFileFormat()
|
||
|
|
public static ImportFileFormat GetImportFileFormat(int testSetupCount)
|
||
|
|
```
|
||
|
|
Returns `SingleTestSetup`, `MultipleTestSetup`, or `NoTestSetup` based on test setup count.
|
||
|
|
|
||
|
|
**Error Management:**
|
||
|
|
```csharp
|
||
|
|
public void ClearErrors()
|
||
|
|
public void AddErrors(IEnumerable<ImportError> d)
|
||
|
|
public void AddError(ImportError d)
|
||
|
|
public IEnumerable<ImportError> Errors()
|
||
|
|
```
|
||
|
|
|
||
|
|
**Data Collections (Add/Get methods for each):**
|
||
|
|
- `Calibrations()` / `AddCalibration(SensorCalibration)` / `AddCalibrations(IEnumerable<SensorCalibration>)`
|
||
|
|
- `TestSetups()` / `AddTestSetup(TestTemplate)` / `AddTestSetups(IEnumerable<TestTemplate>)` / `ClearTestSetups()`
|
||
|
|
- `Sensors()` / `AddSensor(SensorData)` / `AddSensors(IEnumerable<SensorData>)` / `ClearSensors()`
|
||
|
|
- `Groups()` / `AddGroup(TestObject)` / `AddGroups(IEnumerable<TestObject>)`
|
||
|
|
- `GroupTemplates()` / `AddGroupTemplate(TestObjectTemplate)` / `AddGroupTemplates(IEnumerable<TestObjectTemplate>)`
|
||
|
|
- `Hardware()` / `AddHardware(DASHardware)` / `AddHardwareList(IEnumerable<DASHardware>)`
|
||
|
|
- `CustomChannels()` / `AddCustomChannel(MMEPossibleChannels)` / `AddCustomChannels(IEnumerable<MMEPossibleChannels>)`
|
||
|
|
- `Users()` / `AddUser(User)` / `AddUsers(IEnumerable<User>)`
|
||
|
|
- `CustomerDetails()` / `LabDetails()` / `TestEngineerDetails()`
|
||
|
|
- `StaticGroups()` / `AddStaticGroup(IGroup)` / `AddStaticGroups(IEnumerable<IGroup>)`
|
||
|
|
- `SensorModels()` / `AddSensorModel(SensorModel)` / `AddSensorModels(IEnumerable<SensorModel>)`
|
||
|
|
- Various MME-related collections: `PhysicalDimensions()`, `CustomPositions()`, `CustomFilterClasses()`, `CustomFineLoc1s()`, `CustomFineLoc2s()`, `CustomFineLoc3s()`, `Directions()`, `CustomMainLocations()`, `TestObjects()`
|
||
|
|
|
||
|
|
**Lookup Dictionaries:**
|
||
|
|
```csharp
|
||
|
|
public void AssignSensorLookup(Dictionary<string, SensorData> sensorLookup)
|
||
|
|
public void AddSensorLookup(string serial, SensorData sensorData)
|
||
|
|
public Sensor
|