9.3 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T14:08:49.625344+00:00 | zai-org/GLM-5-FP8 | 1 | e94d77a26e8f0798 |
Module Documentation: DTS.Common.Import
1. Purpose
The DTS.Common.Import namespace provides the infrastructure for parsing and importing test configuration data (sensors, calibrations, test setups, hardware) from external files (CSV, XML) into the application's internal object model. It defines a centralized data container (ImportObject), processors for handling file parsing workflows (ParseProcessor, XMLParseProcessor), and various utility classes for data transformation and error reporting during the import process.
2. Public Interface
Classes
ImportObject
The central state container for an import operation. It holds all imported entities and lookup mappings.
- Properties:
ImportFormats SourceFormat: Gets or sets the format of the source file.ImportFileFormat TestSetupImportFileFormat: Gets or sets the file format type (Single, Multiple, No Test Setup).
- Methods:
IEnumerable<ImportError> Errors(): Returns the list of import errors.void AddError(ImportError d),void AddErrors(IEnumerable<ImportError> d): Appends errors to the collection.void ClearErrors(): Clears the error list.void ClearSensors(): Clears the sensor list.void ClearTestSetups(): Clears the test setup list.ImportFileFormat GetImportFileFormat(): Determines the file format based on the count of test setups.- Add/Get methods for collections:
Sensors,Calibrations,TestSetups,Groups,GroupTemplates,Hardware,Users,CustomerDetails,LabDetails,TestEngineerDetails,CustomChannels,PhysicalDimensions,Positions,Directions,FilterClasses,MainLocations,FineLoc1s/2s/3s,TestObjects,SensorModels,StaticGroups.- Pattern:
void Add[Entity](T item),void Add[Entity]List(IEnumerable list),IEnumerable Get[Entity]().
- Pattern:
- Lookup Management:
void AssignSensorLookup(Dictionary<string, SensorData> sensorLookup)void AssignCalibrationLookup(Dictionary<string, List<SensorCalibration>> calibrationLookup)void AssignSensorGroupNameLookup(Dictionary<string, string> sensorGroupNameLookup)void AssignOldSensorDatabaseIdToNew(Dictionary<int, int> oldSensorDatabaseIdToNew)- Corresponding
Add...andGet...methods for these lookups.
IReadOnlyDictionary<int, ISensorData> GetSensorLookup(): Constructs a lookup dictionary keyed byDatabaseIdfrom the current sensors list.
ParseProcessor
Orchestrates parsing using a list of file names and IParseVariant implementations.
- Constructor:
ParseProcessor(ImportObject importObject, IEnumerable<string> fileNames, IEnumerable<IParseVariant> parseVariants) - Methods:
ImportObject Process(): Iterates through_fileNamesand_parseVariants, executingvariant.Parse(ref _importObject)for each.
XMLParseProcessor
Orchestrates XML parsing with progress notification and cancellation support.
- Constructor:
XMLParseProcessor(ImportObject importObject, IImportNotification importNotification, IEnumerable<string> fileNames, Func<bool> isCancelled, bool skipNormalizing) - Properties:
List<IUIItems> UIItems: Gets or sets UI items used by the parser factory.
- Methods:
ImportObject Process(): Iterates files, sets status, creates parsers viaXmlParserFactory, executes parsing, and notifies progress.
ImportNotification & IImportNotification
Provides callback delegates for reporting import status and progress.
- Interface
IImportNotification:Action ImportDoneAction<List<string>> ReportErrorsAction<double> SetProgressAction<ImportStatus> SetStatus
- Class
ImportNotification:- Constructors: Default (no-op delegates), Parameterized (accepts specific
Actiondelegates).
- Constructors: Default (no-op delegates), Parameterized (accepts specific
CalibrationImport
Implements ICalibrationImport to manipulate sensor calibration data.
- Methods:
SensorCalibration CheckForExcitationCalibration(SensorCalibration sc, double sensitivity, ExcitationVoltageOptions.ExcitationVoltageOption excitation, string EU): Adds a calibration record if the excitation differs from the first record.SensorCalibration AddLinearCalRecordIfNeeded(SensorCalibration sc, bool savedIsProportional, bool savedRemoveOffset): Adds a linear calibration record if only one record exists.SensorCalibration AddLinearZeroMethodIfNeeded(SensorCalibration sc, ZeroMethodType zeroMethodType, double zeroMethodStart, double zeroMethodEnd): Adds a zero method if only one exists.
CsvUtil
Static utility for CSV file handling.
- Methods:
static CsvReader CreateCsvReader(string filename): Creates aCsvReaderusingCultureInfo.InvariantCulture.static List<string> ReadFields(CsvReader csvReader, bool readNextLine = true): Reads fields from the current/next line into a trimmed string list.
GroupHelper
Static utility methods for group and sensor data manipulation during import.
- Methods:
static IGroup CreateEmptyGroup(): Returns a newGroupList.Model.Group.static void GetTestSensorParameters(...): Resolves sensor parameters (ISO code, channel names, etc.) usingParseParametersoverrides.static IReadOnlyDictionary<string, int> GetDAS(...): Maps DAS serial numbers to DAS IDs.static List<SensorData> CleanUneededSensorDataPlaceHolder(...): Removes sensors with specific prefixes or invalid calibrations.static List<SensorData> NormalizeSensorIds(List<SensorData> sensorList): Assigns temporary negative IDs to new sensors or existing DB IDs.
ImportError
Represents a single error or warning during import.
- Properties:
string MessageImportSeverityError Severitybool ContinueImportOnError(default:true)
ImportStatus
Represents the current status of the import operation.
- Properties:
string Status,PossibleStatus PossibleStatus,ImportExtraStatus ExtraStatus.
TsetSetupImportSensorInfo
Sealed class holding sensor mapping details for test setup imports.
- Constructors: Accepts full details or partial (serial number, ISO code).
- Properties:
SerialNumber,IsoCode,IsoChannelName,UserCode,UserChannelName,DASSerialNumber,DASChannelIndex,GroupType.
Enums
ImportSeverityError:Critical,Error,Warning,Info.
3. Invariants
- ImportError Defaults: By default,
ImportError.ContinueImportOnErroristrue. - ID Normalization: In
GroupHelper.NormalizeSensorIds, new sensors (not found inSensorsCollection) are assigned temporary negative IDs starting at -2 (-1 is reserved for "no sensor"). - Progress Calculation: In
XMLParseProcessor, progress is calculated as a ratio of total imported items (Calibrations + Sensors + Groups, etc.) toitemsToComplete. Progress is capped at 1.0. - CSV Reading:
CsvUtil.ReadFieldsalways trims whitespace from retrieved fields. - ImportObject References:
ParseProcessorandXMLParseProcessorpassImportObjectby reference (ref) toIParseVariant.Parse, suggesting the object instance itself might be swapped or modified in place by parsers.
4. Dependencies
Internal Dependencies
DTS.Common.Import.Interfaces: Used byParseProcessorandGroupHelper(IParseVariant,ParseParameters).DTS.Common.Import.Enums: Used byImportNotificationandXMLParseProcessor(PossibleStatus,ImportExtraStatus).DTS.Common.Utils: Used byXMLParseProcessor(specificallyXmlParserFactoryandXMLUtils).DTS.Common.Classes.Sensors: Used forSensorCalibration,CalibrationRecord,ZeroMethod.DTS.Common.Enums: Used forExcitationVoltageOptions,ZeroMethodType.DTS.Common.Interface.Sensors: Used forISensorData,ICalibrationRecord.DTS.SensorDB: Used forSensorData,DASHardware,SensorsCollection,SensorCalibrationList.DataPROWin7.DataModel: Used forTestTemplate,TestObject,TestObjectTemplate.DTS.Slice.Users: Used forUserclass.DTS.Common.ISO: Used forCustomerDetails,TestEngineerDetails,LabratoryDetails.
External Dependencies
CsvHelper: Used inCsvUtilfor CSV parsing.
5. Gotchas
- Potential Bug in
ImportObject.AssignSensorModelLookup: The method accepts aDictionary<string, List<SensorCalibration>>argument namedcalibrationLookupbut ignores it completely, initializing_sensorModelLookupto an empty dictionary instead. This appears to be a copy-paste error. - Silent Failures in
ImportObject.GetSensorLookup: If duplicate sensors (sameDatabaseId) are found, the method writes toSystem.Diagnostics.Trace.WriteLinerather than throwing an