--- source_files: - Common/DTS.CommonCore/Classes/DASFactory/TemperatureConfig.cs - Common/DTS.CommonCore/Classes/DASFactory/TMSNConfig.cs - Common/DTS.CommonCore/Classes/DASFactory/ATDStagger.cs generated_at: "2026-04-16T02:41:35.863754+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "b5e818821adb9531" --- # DASFactory ## Documentation: DASFactory Configuration Classes --- ### 1. Purpose This module provides strongly-typed configuration classes for DASFactory subsystems, encapsulating low-level data structures used for communication with hardware devices. Specifically, `TemperatureConfig` manages temperature/humidity logging channel selection and timing, `TMNSConfig` encapsulates TMNS (Telemetry Network Service) streaming parameters, and `ATDStagger` (currently commented out) was designed to serialize device command execution to avoid communication bottlenecks. These classes replace raw arrays with named fields and helper methods to improve maintainability, type safety, and clarity in configuration serialization/deserialization workflows. --- ### 2. Public Interface #### `TemperatureConfig` - **`public ushort LogEnable { get; set; }`** Enables/disables logging (non-zero = enabled). - **`public ushort LogIntervalSec { get; set; }`** Logging interval in seconds. - **`public ushort Channels { get; set; }`** Bitfield representing enabled channels (16-bit value). Setting updates internal `BitArray`; reading converts `BitArray` to `ushort`. - **`public const ushort Reserved = 0;`** Reserved field value (always 0). - **`public bool MCUTemp { get; set; }`** Gets/sets the On-Board MCU Temperature channel (bit 0 of `_channels`). - **`public bool OnBoardHumidity { get; set; }`** Gets/sets the On-Board Humidity channel (bit 1 of `_channels`). - **`public bool EnvironmentalCh1 { get; set; }`** Gets/sets Environmental Channel 1 (bit 2 of `_channels`). - **`public bool EnvironmentalCh2 { get; set; }`** Gets/sets Environmental Channel 2 (bit 3 of `_channels`). - **`public bool EnvironmentalCh3 { get; set; }`** Gets/sets Environmental Channel 3 (bit 4 of `_channels`). - **`public bool EnvironmentalCh4 { get; set; }`** Gets/sets Environmental Channel 4 (bit 5 of `_channels`). - **`public ushort[] ToUShortArray()`** Returns `[LogEnable, LogIntervalSec, Channels, Reserved]` in that order. - **`public TemperatureConfig()`** Default constructor. - **`public TemperatureConfig(ushort[] ushortArray)`** Constructor from `ushort[]`. Reads indices 0–2; missing indices default to `0`. Does *not* initialize `Reserved`. - **`public int[] GetChannelsArray()`** Returns list of bit indices where `_channels` is set (e.g., `[0,2,4]` if MCUTemp, Ch1, Ch3 enabled). - **`public S6DBDiagnosticChannelList[] GetMeasurementChannels()`** Maps enabled channels to corresponding `S6DBDiagnosticChannelList` enum values (e.g., `DiagMcuTemperature`, `DiagEnv_1_Temperature`, etc.). - **`public TempLogChannelBits GetChannelBitForDiagChannel(S6DBDiagnosticChannelList ch)`** Maps a `S6DBDiagnosticChannelList` value to its corresponding `TempLogChannelBits` enum. Throws `NullReferenceException` if not found. #### `TMNSConfig` - **`public uint TMNS_PCMSubFrameId { get; set; }`** TMNS PCM sub-frame ID. - **`public uint TMNS_MsgId { get; set; }`** TMNS message ID. - **`public uint TMNS_PCMMinorPerMajor { get; set; }`** TMNS PCM minor-per-major setting. - **`public uint TMNS_TMATSPortNumber { get; set; }`** TMNS TMATS port number. - **`public uint IENAUDP_PortNumber { get; set; }`** IENA UDP source port number. - **`public uint TMNS5, TMNS6, TMNS7 { get; set; }`** Reserved fields (5–7). - **`public enum Fields { ... }`** Ordered list of field indices: `TMNS_PCMSubFrameID`, `TMNS_MsgId`, `TMNS_PCMMinorPerMajor`, `TMNS_TMATSPortNumber`, `IENAUDP_PortNumber`, `TMNS5`, `TMNS6`, `TMNS7`. - **`public TMNSConfig()`** Default constructor; initializes `_values` array to length 8 with zeros. - **`public TMNSConfig(uint[] parameters)`** Constructor from `uint[]`. Copies up to 8 values; missing indices default to `0`. - **`public TMNSConfig(string parameters)`** Constructor from comma-separated string (e.g., `"(1,2,3)"`). Parses `uint` values; invalid tokens default to `0`. - **`public void SetValue(Fields field, uint value)`** Sets `_values[(int)field]`. - **`public uint GetValue(Fields field)`** Returns `_values[(int)field]`. - **`public uint[] ToUintArray()`** Returns a copy of `_values`. - **`public string ToCSVString()`** Returns string in format `"(x,y,z,...)"`. - **`public static bool IsCh10(UDPStreamProfile profile)`** Returns `true` if `profile` is one of the CH10 variants. - **`public static bool IsIENA(UDPStreamProfile profile)`** Returns `true` if `profile == UDPStreamProfile.IENA_PTYPE_STREAM`. - **`public static bool IsTMNS(UDPStreamProfile profile)`** Returns `true` if `profile` is `TMNS_PCM_STANDARD` or `TMNS_PCM_SUPERCOM`. - **`public static bool IsUART(UDPStreamProfile profile)`** Returns `true` if `profile == UDPStreamProfile.UART_STREAM`. #### `ATDStagger` *(commented out)* - **No public interface is active** — the entire class is commented out. The source includes only historical comments and implementation notes. No runtime behavior can be documented. --- ### 3. Invariants - **`TemperatureConfig`** - `_channels` is always a 16-bit `BitArray` (2 bytes), initialized to `0x0000`. - `Channels` property setter always replaces `_channels` with a new `BitArray` constructed from the `ushort`’s bytes. - `LogEnable`, `LogIntervalSec`, and `Channels` are the only fields populated from `ushort[]` constructor; `Reserved` is ignored in constructor. - `GetChannelBitForDiagChannel` throws `NullReferenceException` (not `KeyNotFoundException`) if the key is missing — a bug in implementation. - **`TMNSConfig`** - `_values` is always exactly 8 elements long (matching `Fields` enum count). - `ToUintArray()` returns a *copy*, not a reference. - `ToCSVString()` always includes parentheses and commas, even for empty/zero values. - **`ATDStagger`** - *N/A* — class is commented out; no invariants apply. --- ### 4. Dependencies - **`TemperatureConfig`** - **Imports**: `DTS.Common.Enums.DASFactory` (for `DFConstantsAndEnums`, `TempLogChannelBits`), `System`, `System.Collections`, `System.Collections.Generic`. - **Uses**: `BitConverter`, `BitArray`. - **Depends on**: `TempLogChannelBits` and `S6DBDiagnosticChannelList` enums (defined in `DTS.Common.Enums.DASFactory` and `DTS.Common.Enums`, respectively — not shown). - **Used by**: Likely consumed by firmware/hardware communication layers to configure logging; inferred from usage of `ToUShortArray()` and `GetMeasurementChannels()`. - **`TMNSConfig`** - **Imports**: `DTS.Common.Enums`, `System`, `System.Linq`, `System.Text`. - **Uses**: `UDPStreamProfile` enum (from `DTS.Common.Enums` — not shown). - **Depends on**: `UDPStreamProfile` for `IsCh10`, `IsIENA`, `IsTMNS`, `IsUART` methods. - **Used by**: Likely used by telemetry configuration modules (e.g., FWTU, DP — mentioned in summary). - **`ATDStagger`** - **Imports**: `DTS.Common.Interface.DASFactory`, `DTS.Common.Utilities.Logging`, `System`, `System.Collections.Generic`, `System.Data`, `System.Linq`. - **Uses**: `IDASCommunication`, `ICommunication`, `APILogger`, `IDbCommand`. - **Depends on**: Database schema (`[DataPro].[dbo].[DAS]` table with columns `SerialNumber`, `PositionOnDistributor`, `PositionOnChain`, `Port`, `ParentDAS`), and `IsSlice6Distributor()` extension method. - **Used by**: Service execution logic (not visible in source). --- ### 5. Gotchas - **`TemperatureConfig`** - `Reserved` is a `const`, but the `ushort[]` constructor does *not* read index 3 — `Reserved` is always `0` regardless of input. - `GetChannelBitForDiagChannel` throws `NullReferenceException` instead of `KeyNotFoundException` — misleading and non-idiomatic. - `Channels` setter uses `BitConverter.ToUInt16(bytes, 0)` — assumes little-endian platform (standard on .NET, but not guaranteed by spec). - `GetUShort` silently defaults to `0` for out-of-bounds indices — may hide configuration errors. - **`TMNSConfig`** - `ToCSVString()` always includes parentheses — callers expecting bare comma-separated values may need to strip them. - String constructor allows `(1,2,3)` but does *not* validate length — extra tokens are ignored, missing tokens default to `0`. - `IsCh10`, `IsIENA`, etc., are `static` and operate on `UDPStreamProfile` — not directly tied to `TMNSConfig` instance state. - **`ATDStagger`** - Entire class is commented out — do not use. Historical comments suggest it was intended for ATD device sequencing but was never enabled. - Logic for assigning devices to ports (e.g., "even if we end up talking to 4 devices on one port it’ll be better...") is heuristic and not guaranteed optimal. - **All Classes** - No validation on `LogIntervalSec` (e.g., no minimum/maximum checks). - No thread-safety guarantees beyond `lock` usage in `ATDStagger` (which is commented out). `TemperatureConfig` and `TMNSConfig` are not thread-safe. - **None identified from source alone** for `ATDStagger` — class is inactive. ---