Files
DP44/enriched-qwen3-coder-next/Common/DTS.CommonCore/Constant.md

132 lines
9.2 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.CommonCore/Constant/XamlConstants.xaml.cs
- Common/DTS.CommonCore/Constant/DigitalInputs.cs
- Common/DTS.CommonCore/Constant/EmbeddedSensors.cs
- Common/DTS.CommonCore/Constant/Constants.cs
generated_at: "2026-04-16T02:15:13.844234+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "02cf11f3a90b1f89"
---
# Documentation: `DTS.Common.Constant` Namespace
## 1. Purpose
This module centralizes application-wide constants used across the DTS (Data Acquisition and Test System) platform. It consolidates magic numbers, thresholds, limits, and configuration flags—primarily for embedded sensor specifications, digital input behavior, XAML UI concerns, and general system behavior—into strongly-typed, versioned, and documented constants. This avoids duplication, improves maintainability, and ensures consistency between UI, firmware, and data processing layers. The constants are not dynamically loaded from storage; instead, they serve as static defaults or hard limits, with runtime values expected to be set separately via configuration or user input.
## 2. Public Interface
### `DTS.Common.Constant.XamlConstants`
- **Type**: `public partial class`
- **Details**: Empty class with no members exposed in the provided source. Likely a placeholder for XAML-specific constants (e.g., resource keys, UI layout values) that may be defined elsewhere (e.g., in partial class extensions or in XAML files). No behavior can be inferred from the current source.
### `DTS.Common.Constant.DigitalInputs`
- **Type**: `public static class`
- **Fields**:
- `public const double ConstantCurrentBreakPointDefault = 19005D;`
Default threshold (ADC count) for detecting a *Contact Closure* digital input transition (bit flips at ~19005).
- `public const double VoltageInputBreakPointDefault = 19661D;`
Default threshold (ADC count) for *Voltage Input* digital mode (1.5V with signal grounded).
- `public const bool DisplaySPDADCDefault = false;`
Default setting for whether to display SLICE Pro Digital ADC in UI.
- **Properties** (read-write, static, initialized from defaults):
- `public static double ConstantCurrentBreakPoint { get; set; }`
Current active threshold for contact-closure detection. *Not* queried from persistent storage; must be set externally.
- `public static double VoltageInputBreakPoint { get; set; }`
Current active threshold for voltage-input detection. *Not* queried from persistent storage; must be set externally.
- `public static bool DisplaySPDADC { get; set; }`
Current setting for SLICE Pro Digital ADC visibility. *Not* queried from persistent storage; must be set externally.
### `DTS.Common.Constant.EmbeddedSensors`
- **Type**: `public static class`
- **Fields**: All `public const double` or `public const int` values defining hardware limits and defaults for embedded sensors:
- **Inactivity/Timeout Limits**:
- `MotionDetectInactivitySMaximum = 300` (5 minutes)
- `MagnetTimeoutMsMaximum = 300000` (5 minutes)
- **Sensor Ranges** (e.g., accelerometer, gyroscope, humidity, pressure, temperature):
- `EmbeddedLowGLinearAccelerometerRange = 8`
- `EmbeddedHighGLinearAccelerometerRange = 400`
- `EmbeddedAngularAccelerometerRange = 2000`
- `EmbeddedAngularRateSensorRange = 2000`
- `HumidityMinimum = 10`, `HumidityMaximum = 100`
- `PressureMinimum = 5`, `PressureMaximum = 15`
- `TemperatureMinimum = 0`, `TemperatureMaximum = 65`
- **Timed Event Limits**:
- `TimedIntervalEventDurationMsMinimum = 30`, `Maximum = 300000`
- `TimedIntervalNumberOfEventsMaximum = 100`
- `IntervalBetweenEventStartsMinutesMaximum = 1440` (24 hours)
- **Sample Rate Limits** (per sensor type, min/max in Hz):
- e.g., `EmbeddedLowGLinearAccelerometerSampleRateMinimum = 1`, `Maximum = 6400`
- **Default Sample Rates** (all `int`):
- `DefaultEmbeddedLowGLinearAccelerometerSampleRate = 6400`
- `DefaultEmbeddedHighGLinearAccelerometerSampleRate = 5120`
- `DefaultEmbeddedAngularAccelerometerSampleRate = 1600`
- `DefaultEmbeddedAngularAccelerometerAndRateSensorSampleRate = 5120`
- `DefaultEmbeddedAtmosphericSensorSampleRate = 157`
### `DTS.Common.Constants`
- **Type**: `public static class`
- **Fields & Properties** (selected highlights):
- **Tags & Strings**:
- `ROI_TAG = "ROI"`, `ALL_TAG = "ALL"`, `USB = "USB"`, `DAS_CONFIGS = "DASConfigs"`, `REPORT_DIR_NAME = "Reports"`, etc.
- **Graph Auto-Zoom**:
- `GRAPH_MIN_AUTOZOOM = 0.01D` (1% full scale)
- `GRAPH_MAX_AUTOZOOM = 1.2D` (120% full scale)
- **Realtime Polling**:
- `CheckStatusLinesInRealtime = true` (static property, mutable)
- `UpdateIntervalRealtimeCharts = 100` (ms)
- **File/Storage**:
- `BACKUP_HEADER_EXTENSION = ".header.bak"`, `BACKUP_FILE_EXTENSION = ".bak"`, `TEMP_FILE_EXTENSION = ".tmp"`, `MAX_USER_CHANNEL_NAME_LENGTH = 100`
- **Data Formats & Protocols**:
- `XML_STORE_MAGIC_BYTES = {0xAA, 0x55, 0xA5, 0x5A}`
- `BITS_PER_MINOR_FRAME_S6A = 128`, `BITS_PER_MINOR_FRAME_TSRAIR = 320`
- `UDP_STREAMPROFILES_MAX = 15`, `UART_MODE_MAX_SAMPLERATE = 30000`
- `SLICE6AIR_STREAMING_DIGITAL_FILTERING_MAX_SAMPLERATE = 10000`
- `SLICE6AIR_STREAMING_DIGITAL_FILTERING_MAX_SAMPLERATE_20k = 20000`
- **Clock Sync Profiles** (read-only arrays of `ClockSyncProfile` enum):
- `MasterProfiles`, `SlaveProfiles`, `OnePPSOutProfiles` (see source for exact contents)
- **Recording Modes** (read-only array of `RecordingModes` enum):
- `NonStreamingRecordingModes` (e.g., `CircularBuffer`, `Recorder`, `Scheduled`, etc.)
- **NMEA Parsing**:
- `NMEA_GPRMC_HEADER = "$GPRMC"`, `NMEA_GPGGA_HEADER = "$GPGGA"`
+ Positional constants for fields (e.g., `NMEA_GPRMC_LAT_POSN = 3`)
- **Database Versioning**:
- `ROITables_DB_VERSION = 92`, `UNIX_EPOCH_TIME = 93`, `MULTIPLE_EVENT_UART_DB_VERSION = 96`, etc.
- **Miscellaneous**:
- `ADC_MIDPOINT = 32767` (16-bit midpoint)
- `PING_ICMP_TIMEOUT = 500` (ms, mutable static property)
- `EXECUTABLE_TIMEOUT = 30000` (ms)
- `MAX_VIEWER_POINTS = 45000000`
## 3. Invariants
- **Static Defaults Only**: All `static` properties (e.g., `DigitalInputs.ConstantCurrentBreakPoint`, `Constants.CheckStatusLinesInRealtime`) are initialized from `const` defaults but are *not* persisted or auto-loaded. Their values must be explicitly set by the application (e.g., via config file or UI) before use.
- **Hard Limits**: All `const` values in `EmbeddedSensors` represent *absolute hardware limits* (e.g., sensor ranges, max sample rates). Exceeding them may cause undefined behavior or device errors.
- **No Runtime Validation**: Constants are not validated at runtime; it is the callers responsibility to ensure values (e.g., sample rates, durations) fall within documented min/max bounds.
- **No Dynamic Configuration**: Constants are not read from storage (e.g., registry, config files). They are compile-time or static runtime defaults.
- **Versioning Semantics**: Database version constants (e.g., `ROITables_DB_VERSION`) indicate schema compatibility. Values are incremented only when breaking changes occur.
## 4. Dependencies
- **Imports/Usings**:
- `DTS.Common.Constant` namespace depends on `System.Collections.Generic` (used in `Constants.ExportNameFilters`).
- `Constants` references enums `ClockSyncProfile` and `RecordingModes` (from `DTS.Common.Enums`), implying a dependency on `DTS.Common.Enums`.
- **Consumers** (inferred from usage patterns):
- UI layer (e.g., `XamlConstants` likely used in XAML resource dictionaries).
- Data acquisition firmware/drivers (e.g., `EmbeddedSensors` for sensor configuration).
- Data processing pipelines (e.g., `Constants` for graph scaling, file I/O, NMEA parsing).
- Configuration management (e.g., `DigitalInputs` thresholds may be set via config).
- **No external libraries**: No third-party dependencies are evident from the source.
## 5. Gotchas
- **Mutable Static Properties**: Properties like `DigitalInputs.ConstantCurrentBreakPoint` and `Constants.CheckStatusLinesInRealtime` are *mutable statics*. Changes affect all consumers globally—this may cause race conditions in multi-threaded scenarios if not synchronized.
- **Ambiguous `XamlConstants`**: The `XamlConstants` class is empty in the provided source. Its purpose is unclear; it may be a placeholder or rely on partial class definitions not included here.
- **Threshold Units**: `DigitalInputs` thresholds are in *ADC counts*, not physical units (e.g., volts). Conversion requires knowledge of the ADC reference and scaling (not provided here).
- **Historical Comments**: Comments reference internal Jira cases (e.g., `http://manuscript.dts.local/f/cases/29416`) and legacy code moves (e.g., `FB 25526 Moved from SLICE6AIR`). These may become outdated and obscure the rationale for future maintainers.
- **Hardcoded Limits**: Values like `MAX_VIEWER_POINTS = 45000000` or `ALLOWED_DOWNLOAD_FILE_LENGTH = 260` may conflict with OS/file system constraints (e.g., Windows MAX_PATH), requiring validation at the call site.
- **No Validation on Constants**: There is no runtime enforcement of min/max bounds (e.g., setting `EmbeddedSensors.TimedIntervalEventDurationMsMinimum` to 20 would not fail). Invalid values may cause silent errors or device misbehavior.
None identified from source alone.