--- source_files: - Common/DTS.Common.DataModel/ApplicationProperties.cs - Common/DTS.Common.DataModel/CollectDataProcess.cs - Common/DTS.Common.DataModel/SysBuiltObjectType.cs - Common/DTS.Common.DataModel/DataModelSettings.cs - Common/DTS.Common.DataModel/DataFiles.cs - Common/DTS.Common.DataModel/ChannelRepresentation.cs - Common/DTS.Common.DataModel/DASFactory.cs generated_at: "2026-04-17T15:32:07.033417+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "666ebf3a34293f35" --- # DTS.Common.DataModel Module Documentation ## 1. Purpose This module provides the core data model and application-wide state management for the DTS (Data Acquisition System) application. It contains global application properties, configuration settings, hardware abstraction representations, data file management, and device discovery orchestration. The module serves as the central hub connecting UI components to underlying hardware communication layers, test data storage, and ISO standard compliance data. --- ## 2. Public Interface ### ApplicationProperties (static class) Global application state container. | Property | Type | Description | |----------|------|-------------| | `CurrentUser` | `User` | The currently logged-in user. | | `DASFactory` | `DASFactory` | Factory instance for DAS device management. | | `CurrentView` | `User` | Current view context (distinct from CurrentUser). | | `IsoDb` | `ISO13499FileDb` | ISO 13499 database reference. | | `LicenseValidationResult` | `ValidationResult` | Result of license validation. | | `CanCurrentUserCommitChannelCodes` | `bool` | Permission flag for channel code commits. | --- ### DataModelSettings (static class) Application-wide configuration with default values. **Key Properties:** - `UseISOCodeForDiadem200` (bool, default: `false`) - `SampleRateAAFilterRatio` (byte, default: `5`) - `SupportedSquibFireModes` (string, default: `"CAP,CONSTANT"`) - `ShowCompactHardware` (bool, default: `true`) - `AllowedVoltageInsertionErrorPercent` (double, default: `1`) - `AllowedExcitationErrorPercent` (double, default: `2`) - `AllowedShuntErrorPercent` (double, default: `5`) - `AllowedGainErrorPercent` (double, default: `2`) - `AllowedGainErrorPercent_SLICE6andSLICE6A` (double, default: `5`) - `DownloadFolder` (string, default: `"..\\..\\Data"`) - `RequireXCrashCompatibilityForISOExports` (bool, default: `true`) - `SLICETurnOffAAFRealtime` (bool, default: `true`) - `ArmChecklistRequiredIfTOM` (bool, default: `true`) - `CheckUnitsIntervalMillisecond` (int, default: `50`) - `SemaphoreDelay` (double, default: `10`) - `SemaphoreSpots` (int, default: `3`) - `SLICEConcurrentSpots` (int, default: `999`) - `MulticastAutoDiscoveryReceiveTimeoutMS` (int, default: `1500`) - `LocalKeepAliveRetryIntervalMS` (uint, default: `1000`) - `LocalKeepAliveTimeOutMS` (uint, default: `5000`) - `RemoteKeepAliveRetryIntervalSeconds` (uint, default: `5`) - `RemoteKeepAliveSeconds` (uint, default: `60`) - `ReceiveBufferSizeBytes` / `SendBufferSizeBytes` (int, default: `65536`) - `HeartbeatAsyncConnectTimeoutMS` (int, default: `10000`) - `DefaultTDCSensorDatabaseFolder` / `DefaultTDCSensorDatabaseFile` (string defaults for sensor database) --- ### CollectDataProcess Represents a data collection process with visual properties. Inherits from `BasePropertyChanged`. ```csharp public CollectDataProcess(string name, Color color) ``` | Property | Type | Description | |----------|------|-------------| | `Name` | `string` | Process name (notifies property change). | | `BackgroundColor` | `Color` | Display color for the process. | | `IsEnabled` | `bool` | Enablement state. | --- ### SysBuiltObjectType Container for Dynamic Groups of a given test object type (Vehicle 1, Vehicle 2, Sled, etc.). ```csharp public SysBuiltObjectType(string testObjectType) ``` | Property | Type | Description | |----------|------|-------------| | `TestObject` | `MMETestObjects` | Resolved test object from `ApplicationProperties.IsoDb`. Setter stores `Test_Object` string internally. | | `ISOTestObjectType` | `string` | Returns `TestObject.Text_L1`. | **Methods:** - `ToString()` - Returns `TestObject.Text_L1`. --- ### DataFiles Metadata container for test data files. ```csharp public DataFiles(string expandCollapse, string testName, string id, string allOrROI, string lab, string customer, DateTime dateCreated, string description, string numberOfChannels, string testEngineer, bool isTSRAIR, string roiSuffix = "") ``` | Property | Type | Description | |----------|------|-------------| | `ExpandCollapse` | `string` | UI expansion state (`"+"`, `"-"`, or empty). | | `TestId` | `string` | Test identifier. | | `TestName` | `string` | Test name. | | `AllOrROI` | `string` | "All" or "ROI" designation. | | `Lab` / `Customer` / `TestEngineer` | `string` | Test metadata. | | `DateCreated` | `DateTime` | Creation timestamp. | | `Description` | `string` | Test description. | | `NumberOfChannels` | `string` | Channel count. | | `ROISuffix` | `string` | ROI suffix identifier. | | `DTSFile` | `string` | Location of DTS file (populated in export tab). | | `IsTSRAIR` | `bool` | TSR AIR test flag. | | `TestSelected` | `bool` | Selection state. | | `LongString` | `string` | Extended description. | --- ### DataFilesList Manages discovery and listing of test data files. Singleton pattern. ```csharp public static DataFilesList DataFileList { get; } // Singleton accessor ``` **Key Methods:** - `DataFiles[] GetAllFiles(string testName)` - Returns all data files for a given test name, recursively searching for folders containing both `.dts` and `.chn` files. - `DataFiles[] GetAllDataFiles()` - Returns top-level test folder summaries. - `DataFiles[] Contract(DataFiles df)` - Collapses expanded test entries in the list. - `DataFiles[] DataFiles` (property) - Gets/sets the current file list. **Private Methods:** - `string[] GetFoldersWithData(string folder)` - Recursively finds folders with both `.dts` and `.chn` files. - `bool GetTestInfo(string dtsFilePath, out string lab, out string customer, out string description, out string testEngineer, out DateTime dt, out string name)` - Parses test metadata from DTS file using streaming XML parsing. - `int GetFileCount(string binaryFolder, string testId)` - Counts test data sets in a binary folder. --- ### ChannelRepresentation Converts internal channel numbers to display-friendly representations for various hardware types. ```csharp public ChannelRepresentation(DASHardware h, DTS.DASLib.Service.DASChannel c, int startingChannelNumber) public ChannelRepresentation(HardwareChannel c, int startingChannelNumber, IDASHardware[] hardwares = null) ``` **Nested Enum:** ```csharp public enum ChannelTypeEnum { SQUIB, TOMDigital, DigitalInput, Other } ``` | Property | Type | Description | |----------|------|-------------| | `DASSerialNumber` | `string` | DAS device serial number. | | `SerialNumber` | `string` | Module serial number. | | `ChannelNumberString` | `string` | Formatted display string (e.g., "CH01", "SQ02"). | | `ChannelNumber` | `int` | Numeric channel number. | **Behavior:** Handles channel number conversion for hardware types including: - TDAS_Pro_Rack, TDAS_LabRack - SLICE variants (SLICE2_TOM, SLICE2_SLT, SLICE6_AIR, SLICE_PRO_CAN_FD, etc.) - G5VDS, G5INDUMMY - EMB devices (EMB_ANG_ARS, EMB_ATM, EMB_LIN_ACC_HI, EMB_LIN_ACC_LO) - TSR_AIR, TSR_AIR_RevB, DIR, DKR - SLICE6_AIR_TC (thermocouple handling) --- ### DASFactory Wrapper around `DTS.DASLib.DASFactory.DASFactory` for device discovery and management. ```csharp public DASFactory() // Constructor initializes semaphores, keep-alive settings, and performs initial refresh ``` **Events:** - `DASFactoryEventHandler OnDeviceArrived` - Fired when a device is discovered. - `DASFactoryEventHandler OnFactoryChanged` - Fired on device arrival, failure, or removal. - `DiscoveredDASEventHandler DiscoveredDAS` - Fired during discovery thread iterations. **Key Methods:** - `void StartMulticastAutoDiscovery()` / `void StopMulticastAutoDiscovery()` - Control auto-discovery process. - `IDiscoveredDevice[] GetDiscoveredDevices()` - Returns discovered devices. - `IDASFactory GetDASFactory()` - Returns underlying factory interface. - `void TakeOwnership()` - Takes ownership of devices. - `void DetachAllDevices(bool detachUSB = false)` - Detaches devices (USB detach conditional). - `void DisposeFactory()` - Disposes the underlying factory. - `void Refresh(bool wait)` - Refreshes device list; prevents overlapping refresh calls. - `List GetActiveDevices()` - Returns active DAS devices. - `string[] GetReportedConnections()` - Returns connections reported by ECM/SDB/S6DB. - `SortableBindingList AutoDiscoverMulticast()` - Performs multicast discovery. - `void DiscoveryThread(DFConstantsAndEnums.MultiCastDeviceClasses[] deviceFilter, CancellationToken ct, bool discoverParents = true)` - Background discovery thread. - `void AutoDiscoverIfNecessary()` - Runs auto-discovery for SLICE6/SLICE6Db downstream MAC addresses. - `void StartQATSListening()` / `void StopQATSListening()` / `void SendQATSRequest()` / `IUDPQATSEntry[] GetQATS()` - QATS (Query Arm Trigger Status) operations. **Static Methods:** - `bool IsStreaming(IDASCommunication das)` - Returns true if SLICE6 Air is streaming. - `bool IsInRealtime(IDASCommunication das)` - Returns true if unit is in realtime or streaming. - `bool AnyInRealtime(List das)` - Returns true if any unit is in realtime. **Properties:** - `TDASHostNames`, `SPFDHostNames`, `SDBHostNames` (string arrays) - Host name configurations. - `MulticastAutoDiscoveryReceiveTimeoutMS`, `MulticastAutoDiscoveryAddress`, `MulticastAutoDiscoveryPort`, `MulticastAutoDiscoveryResponsePort` - Multicast configuration. - `S6ConnectNewTimeout` (double) - SLICE6 connection timeout. --- ## 3. Invariants 1. **ApplicationProperties singleton state**: All properties are static and globally accessible; consumers must ensure thread-safe access patterns. 2. **DataFilesList singleton**: The `DataFileList` property uses lazy initialization and returns a single shared instance. 3. **DASFactory refresh concurrency**: The `_bInRefresh` flag guards against overlapping `Refresh()` calls. If `Refresh()` is called while already refreshing, the second call is silently ignored. 4. **ChannelRepresentation hardware type handling**: The `ConvertChannelNumbers` method must receive a valid `HardwareTypes` enum value; unhandled types fall through to a default case that uses the starting channel number directly. 5. **Data folder structure expectation**: `DataFilesList` expects a folder hierarchy of `TestName/TestId/Binary/[All|ROI]` for proper parsing of `AllOrROI` values. 6. **DTS file uniqueness**: `GetFileCount` and `GetAllFiles` assume exactly one `.dts` file per data folder; folders with zero or multiple DTS files are skipped. --- ## 4. Dependencies ### This module depends on: - `DTS.Slice.Users` - User types - `DTS.Common.Base` - `BasePropertyChanged` for INPC - `DTS.Common.ISO` - ISO 13499 database types (`ISO13499FileDb`, `MMETestObjects`) - `DTS.Common.Licensing.Messages` - `ValidationResult` - `DTS.Common.Enums.Hardware` - `HardwareTypes` enum - `DTS.Common.Enums.Sensors` - Sensor enums - `DTS.Common.Interface.DataRecorders` - `IDASHardware` - `DTS.Common.Interface.DASFactory` - `IDASFactory`, `IDiscoveredDevice` - `DTS.Common.Enums.DASFactory` - `DFConstantsAndEnums` - `DTS.Common.Converters` - `EnumDescriptionTypeConverter` - `DTS.Common.Constant.DASSpecific` - `SensorConstants` - `DTS.Common.SharedResource.Strings` - Localized strings - `DTS.Common.Utilities.Logging` - `APILogger` - `DTS.Common.Utils` - Utility functions - `DTS.Common.DataModel.Classes.TestTemplate` - `TSRAIRGoTestSetup` - `DTS.Serialization` - Serialization utilities - `DTS.DASLib.DASFactory` - Underlying DAS factory implementation - `DTS.DASLib.Service` - DAS channel types - `DTS.DASLib.Command` - Command infrastructure - `System.Windows.Media` - `Color` type ### What depends on this module: - Unclear from source alone; `ApplicationProperties` is a global state container likely used throughout the application. --- ## 5. Gotchas 1. **ApplicationProperties mutable global state**: All properties are get/set with no validation or change notification. Setting `CurrentUser`, `DASFactory`, or `IsoDb` to null could cause null reference exceptions in consumers like `SysBuiltObjectType.TestObject` which accesses `ApplicationProperties.IsoDb.GetTestObjectByIso()`. 2. **SysBuiltObjectType null handling**: The `TestObject` getter calls `IsoDb.GetTestObjectByIso(_testObject)` without null-checking `IsoDb`. If `ApplicationProperties.IsoDb` is null, this will throw. 3. **DASFactory TDASHostNames/SDBHostNames setters have side effects**: Setting these properties triggers refresh logic in the underlying factory. The setter includes a check to avoid redundant updates but only after checking `_bInRefresh` flag with conditional compilation logging. 4. **ChannelRepresentation casting without validation**: The constructor casts `c` to `DTS.DASLib.Service.AnalogInputDASChannel` without type checking when determining `DigitalInput` channel type. This could throw if `c` is not an `AnalogInputDASChannel`. 5. **DataFilesList.GetTestInfo XML parsing fragility**: The method manually constructs XML by appending `""` to incomplete tags. Malformed DTS files could cause `XElement.Parse` to throw. 6. **DASFactory.Refresh wait behavior**: When `wait` is `false`, the `_bInRefresh` flag is set to `false` inside the callback, but if the callback never fires (exception case), `_bInRefresh` remains `true`, blocking future refreshes. 7. **ChannelRepresentation.DoSquibConversion returns 0 for unexpected remainders**: Squib channel numbers with remainders 0, 2, 4, 6 return 0, which may represent an error state but is not documented. 8. **Conditional compilation LOG_DEBUG_REFRESH**: Debug logging for refresh overlap detection is controlled by `#define LOG_DEBUG_REFRESH` and is not compiled into release builds.