8.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-17T15:42:08.031759+00:00 | zai-org/GLM-5-FP8 | 1 | ef0e1195e993a581 |
Documentation: Export Module
1. Purpose
This module provides data export functionality for test configurations. ExportHeader represents a selectable column header for export operations, implementing property change notification for UI binding. ExportTestSetup is a static utility class that aggregates test-related entities (tests, groups, sensors, hardware, calibrations, and ISO details) into dictionaries and serializes them to XML format for file export or data transfer.
2. Public Interface
ExportHeader Class
Namespace: DataPROWin7.DataModel.Classes.Export
Implements: IExportHeader
| Member | Signature | Description |
|---|---|---|
| Constructor | ExportHeader() |
Initializes a new instance with default values. |
| Constructor | ExportHeader(string headerName) |
Initializes with the specified headerName. |
| Constructor | ExportHeader(string headerName, bool isSelected) |
Initializes with headerName and isSelected state; chains to the headerName constructor. |
| Property | string HeaderName { get; set; } |
Gets or sets the header name; raises PropertyChanged on set. |
| Property | bool IsSelected { get; set; } |
Gets or sets selection state; defaults to false; raises PropertyChanged on set. |
| Event | PropertyChangedEventHandler PropertyChanged |
Event raised when a property value changes. |
| Method | void OnPropertyChanged(string propertyName = null) |
Protected method that invokes the PropertyChanged event. |
ExportTestSetup Class
Namespace: DataPROWin7.DataModel.Classes
Modifiers: public static
| Method | Signature | Description |
|---|---|---|
| PrepareForExport | void PrepareForExport(DataModel.TestTemplate t, Dictionary<string, DataModel.TestTemplate> includedTests, Dictionary<string, IGroup> includedGroups, Dictionary<string, DataModel.DASHardware> includedDAS, Dictionary<string, SensorData> includedSensors, HashSet<int> sensorsAlreadyAdded, Dictionary<string, SensorModel> includedSensorModels, Dictionary<string, SensorCalibration[]> includedCalibration, Dictionary<string, DTS.Common.ISO.CustomerDetails> includedCustomerDetails, Dictionary<string, DTS.Common.ISO.TestEngineerDetails> includedTestEngineerDetails, Dictionary<string, DTS.Common.ISO.LabratoryDetails> includedLabDetails, bool savingRunningTest, bool savingTTSImport) |
Populates the provided dictionaries with all entities referenced by the test template t, including sensors, hardware, groups, calibrations, and ISO-related details. Handles embedded and non-embedded groups. |
| ExportToFile | string ExportToFile(Dictionary<string, DataModel.TestTemplate> includedTests, Dictionary<string, IGroup> includedGroups, Dictionary<string, DataModel.DASHardware> includedDAS, Dictionary<string, SensorData> includedSensors, Dictionary<string, SensorModel> includedSensorModels, Dictionary<string, SensorCalibration[]> includedCalibration, Dictionary<string, DTS.Common.ISO.CustomerDetails> includedCustomerDetails, Dictionary<string, DTS.Common.ISO.TestEngineerDetails> includedTestEngineerDetails, Dictionary<string, DTS.Common.ISO.LabratoryDetails> includedLabDetails, Dictionary<string, DTS.Slice.Users.User> includedUsers, Dictionary<string, string> includedGlobalSettings, string exportFile, string originalImportFile, bool bUseFirstUseDate = true) |
Serializes all provided dictionaries to XML format using TopLevelFields enum ordering. Returns the XML string; writes to exportFile if non-null. Returns empty string on exception. |
| PrepareForExportFields | void PrepareForExportFields(DataModel.TestTemplate t, Dictionary<string, DataModel.TestTemplate> includedTests, Dictionary<string, DataModel.DASHardware> includedDAS) |
Simplified preparation that only extracts tests and DAS hardware; does not process sensors, calibrations, or ISO details. Removes DAS entries from t.DASSampleRateList if not in includedDAS. |
| ExportToFileFields | string ExportToFileFields(Dictionary<string, DataModel.TestTemplate> includedTests, Dictionary<string, DataModel.DASHardware> includedDAS, string originalImportFile) |
Simplified export that only writes DASList and TestSetups elements to XML. Returns empty string on exception. |
3. Invariants
- Dictionary Key Uniqueness: All
included*dictionary parameters must use unique keys appropriate to their type (e.g.,SerialNumberfor sensors/hardware,Namefor tests/groups/customers). - Thread Affinity:
PrepareForExportandPrepareForExportFieldsaccessApplication.Current.Dispatcherfor retrieving non-embedded groups; they handle both UI thread and background thread scenarios viaCheckAccess()andManualResetEvent. - Sensor Deduplication:
sensorsAlreadyAdded(aHashSet<int>) is used to prevent duplicate sensor entries across multiple groups or channels within a single export operation. - Calibration Exclusion: Sensors flagged as
IsTestSpecificDigitalOutput,IsTestSpecificSquib, orIsTestSpecificDigitalInare excluded fromincludedCalibrationbut still added toincludedSensors. - XML Element Ordering:
ExportToFileandExportToFileFieldsiterate overTopLevelFieldsenum values, ensuring consistent element ordering in output XML. - Static Group Validation: If an embedded group's
StaticGroupIdreferences a non-existent or mismatched static group,embeddedGroup.StaticGroupIdis set tonulland processing continues.
4. Dependencies
Imports (this module depends on):
| Namespace | Purpose |
|---|---|
DTS.Common.Interface.ExportData |
IExportHeader interface |
DTS.Common.Interface.Groups.GroupList |
IGroup, IGroupListViewModel |
DTS.SensorDB |
SensorsCollection, SensorData, SensorCalibration, SensorModel, SensorModelCollection |
DTS.Common.Interface.Sensors |
ISensorData |
DTS.Common.Interface.Channels |
IGroupChannel |
DTS.Common.Interface.DataRecorders |
IDASHardware |
DTS.Common.Storage |
DbOperations |
DTS.Common.ISO |
CustomerDetails, TestEngineerDetails, LabratoryDetails, Hardware |
DTS.Common.Utils |
FileUtils |
DTS.Common.Utilities.Logging |
APILogger |
DTS.Common.Enums.DBExport |
TopLevelFields enum |
DTS.Slice.Users |
User class |
Prism.Ioc |
ContainerLocator |
Unity |
IUnityContainer |
System.Windows |
Application for dispatcher access |
System.Xml |
XmlWriter for XML serialization |
System.ComponentModel |
INotifyPropertyChanged pattern |
Dependents (inferred):
- Callers of
ExportTestSetup.PrepareForExport*andExportTestSetup.ExportToFile*methods (exact modules unclear from source alone). - Consumers of
ExportHeaderfor UI data binding scenarios.
5. Gotchas
-
Unused Parameter: The
savingRunningTestparameter inPrepareForExportis never referenced in the method body. Its intended purpose is unclear from source alone. -
Dispatcher Blocking: Both
PrepareForExportandPrepareForExportFieldsuseManualResetEvent.WaitOne()to block when called from a non-UI thread while waiting for dispatcher operations. This could cause deadlocks if the UI thread is blocked waiting on the calling thread. -
Namespace Mismatch: The namespace
DataPROWin7.DataModel.Classes.ExportandDataPROWin7.DataModel.Classessuggests legacy naming (referencing "Win7") that may not reflect current platform targets. -
Partial Export Handling:
ExportToFileFieldsdoes not write to a file despite acceptingoriginalImportFile; it only returns the XML string. Contrast withExportToFilewhich writes toexportFilewhen non-null. -
Null Return Ambiguity:
GetDASreturnsnullif no matching DAS is found indasList. Callers do not appear to null-check the result before accessing properties (e.g.,h.SerialNumber), which could causeNullReferenceException. -
Early Exit in PrepareForExport: The method returns early if
!savingTTSImport, skipping the final loop that adds all sensors with calibrations. This conditional behavior may be unexpected. -
Empty Calibration Handling: When
SensorCalibration.GetCalibrationsBySerialNumberreturns null or empty, the sensor is still added toincludedSensorsbut calibration data is omitted. ATrace.WriteLinediagnostic is emitted in one code path but not others.