This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
---
source_files:
- DataPRO/SensorDB/Properties/AssemblyInfo.cs
generated_at: "2026-04-16T04:03:36.727348+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "2773222b95668e80"
---
# Properties
## Documentation Page: `DataPRO.SensorDB` Assembly
### 1. Purpose
This module defines the `SensorDB` .NET assembly—a legacy component (copyright 2008) intended to encapsulate sensor-related data storage and retrieval functionality. Based solely on the provided file, the assembly serves as a foundational library with no exposed public API surface in the current source; its primary documented role is to provide versioning and COM interop metadata for internal use within the `DataPRO` system. The assembly is not visible to COM clients (`ComVisible(false)`), and its GUID (`6536b7c0-aa8b-4e96-8bf2-c4480ac3633f`) identifies its type library for potential future COM exposure.
### 2. Public Interface
**No public types, functions, classes, or methods are defined in this file.**
The file `AssemblyInfo.cs` contains only assembly-level attributes (metadata), not executable code or type declarations. Therefore, there are *no* public APIs documented here. Public interfaces (if any) would reside in other source files of the `SensorDB` project (e.g., `.cs` files in the `DataPRO/SensorDB` directory), which are not provided.
### 3. Invariants
- **Version consistency**: `AssemblyVersion` and `AssemblyFileVersion` are both set to `"1.06.0081"`, implying the assemblys runtime version and file version are identical.
- **COM visibility**: The assembly is explicitly marked non-`ComVisible`, ensuring its types are not exposed to COM by default.
- **Assembly identity**: The `Guid` attribute (`6536b7c0-aa8b-4e96-8bf2-c4480ac3633f`) uniquely identifies the type library for COM interop, should `ComVisible(true)` be enabled in the future.
- **Copyright integrity**: The `AssemblyCopyright` attribute is fixed to `"Copyright © 2008"` and should not be altered without legal review.
### 4. Dependencies
- **Dependencies**: This file depends solely on core .NET Framework assemblies:
- `System.Reflection`
- `System.Runtime.CompilerServices`
- `System.Runtime.InteropServices`
*(All standard .NET namespaces for assembly metadata.)*
- **Dependents**: Unknown from this file alone. The assembly is referenced as `SensorDB` (per `AssemblyTitle`), and its GUID suggests it may be consumed by COM-aware components (e.g., legacy VB6, C++/CLI, or scripting environments), but no explicit consumers are declared here.
### 5. Gotchas
- **No functional code**: This file is *purely metadata*; it does not implement any sensor database logic. Developers should not expect to find database operations, classes, or methods here.
- **Version format**: The version `"1.06.0081"` uses a non-standard format (likely `Major.Minor.Build` where `06` = minor version 6, `0081` = build 81). This may cause confusion if compared against semantic versioning (SemVer) expectations.
- **Hardcoded year**: The copyright year (`2008`) is static and may be outdated; verify if this reflects the last modification year or is intentionally preserved.
- **COM exposure risk**: While `ComVisible(false)` is set, any future change to `ComVisible(true)` (e.g., in another file) could expose internal types unexpectedly—ensure explicit `[ComVisible(false)]` on types if granular control is needed.
- **Missing documentation**: The `AssemblyDescription` and `AssemblyConfiguration` attributes are empty strings, indicating incomplete assembly metadata.

View File

@@ -0,0 +1,190 @@
---
source_files:
- DataPRO/SensorDB/TDCINI/INIDataZeroTimeWindowSeconds.cs
- DataPRO/SensorDB/TDCINI/INISmartBatteryThresholds.cs
- DataPRO/SensorDB/TDCINI/INIViewerROI.cs
- DataPRO/SensorDB/TDCINI/TSFINIRegionOfInterest.cs
- DataPRO/SensorDB/TDCINI/TDCINIRS232Info.cs
- DataPRO/SensorDB/TDCINI/INIIIHSExport.cs
- DataPRO/SensorDB/TDCINI/INIRackInventory.cs
- DataPRO/SensorDB/TDCINI/TDCINIError.cs
- DataPRO/SensorDB/TDCINI/INIISOExportParameters.cs
generated_at: "2026-04-16T04:03:50.006519+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "e52e76ad1c9cbddd"
---
# INI File Parsing Helpers Documentation
## 1. Purpose
This module provides a set of helper classes for parsing structured sections from INI configuration files used by the SensorDB/TDCINI subsystem. Each class corresponds to a specific INI section (e.g., `DataZeroTimeWindow`, `SmartBatteryThresholds`, `ViewerROI`, `RS232`, `ROI`, `RackInventory`, `IIHSExport`, `ISOExportParameters`) and encapsulates the logic to deserialize a line (or multiple lines for `INIRackInventory`) into strongly-typed properties. These helpers are used during INI file loading to validate and populate configuration data, returning structured results and collecting errors via a shared `TDCINIError` mechanism.
## 2. Public Interface
### `INIDataZeroTimeWindowSeconds`
- **`double Start { get; set; }`**
Start time (in seconds) of the data zero window.
- **`double End { get; set; }`**
End time (in seconds) of the data zero window.
- **`bool ReadFrom(string line, ref List<TDCINIError> errors, int iCurrentLine)`**
Parses a comma-separated line (e.g., `"1.2,3.4"`) into `Start` and `End`. Returns `false` and adds an `INI_DataZeroTimeWindow_INVALID` error if the line does not contain exactly two valid doubles.
### `INISmartBatteryThresholds`
- **`int Yellow { get; set; }`**
Time in minutes for the yellow battery warning threshold.
- **`int Red { get; set; }`**
Time in minutes for the red battery warning threshold.
- **`bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)`**
Parses a comma-separated line (e.g., `"30,10"`) into `Yellow` and `Red`. Returns `false` and adds an `INI_SmartBatteryStatusThresholds` error if the line does not contain exactly two valid integers.
### `INIViewerROI`
- **`double XMin { get; set; }`**
Minimum X value (e.g., time or position) for the viewer region of interest.
- **`double XMax { get; set; }`**
Maximum X value for the viewer region of interest.
- **`bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)`**
Parses a comma-separated line (e.g., `"0.5,2.0"`) into `XMin` and `XMax`. Returns `false` and adds an `INI_ViewerROI_INVALID` error if parsing fails or the line does not contain exactly two values.
### `TSFINIRegionOfInterest`
- **`double StartSeconds { get; set; }`**
Start time (in seconds) of the ROI relative to T0.
- **`double EndSeconds { get; set; }`**
End time (in seconds) of the ROI relative to T0.
- **`bool ReadFrom(string line, int currentLine, ref List<TDCINIError> errors)`**
Parses a comma-separated line (e.g., `"0.0,10.5"`) into `StartSeconds` and `EndSeconds`. Returns `false` and adds an `INI_ROI_INVALID` error if parsing fails or the line does not contain exactly two values.
### `TDCINIRS232Info`
- **`int ComPortNumber { get; set; }`**
Communication port number.
- **`int MaxComSpeed { get; set; }`**
Maximum speed (e.g., baud rate) of the COM port.
- **`int MaxComPorts { get; set; }`**
Maximum number of COM ports supported.
- **`bool ReadFrom(string line, ref List<TDCINIError> errors)`**
Parses a comma-separated line (e.g., `"3,115200,4"`) into `ComPortNumber`, `MaxComSpeed`, and `MaxComPorts`. Returns `false` and adds an `INI_COMINFO_INVALID` error if parsing fails or the line does not contain exactly three values. Note: `curLine` is not passed in this method.
### `INIIIHSExport`
- **`bool ApplyROI { get; set; }`**
Whether to apply the ROI during IIHS export.
- **`double ROIStartSeconds { get; set; }`**
Start time (in seconds) of the ROI for IIHS export.
- **`double ROIEndSeconds { get; set; }`**
End time (in seconds) of the ROI for IIHS export.
- **`bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)`**
Parses a comma-separated line (e.g., `"Y,0.0,5.0"`) into `ApplyROI`, `ROIStartSeconds`, and `ROIEndSeconds`. `ApplyROI` is set based on tokens `"0"/"F"/"N"` (false) or `"1"/"T"/"Y"` (true). Returns `false` and adds an `INI_IIHSExport_INVALID` error on parse failure or invalid boolean token.
### `INIRackInventory`
- **`INIRackInfo[] Racks { get; set; }`**
Array of parsed rack entries.
- **`class INIRackInfo`**
Inner class representing a single rack entry:
- **`int Number { get; set; }`**
Rack number.
- **`string SerialNumber { get; set; }`**
Rack serial number.
- **`int Size { get; set; }`**
Rack size (e.g., U height).
- **`string IPAddress { get; set; }`**
Rack IP address.
- **`bool ReadFrom(string line, ref List<TDCINIError> errors)`**
Parses a comma-separated line (e.g., `"1,SN123,12,192.168.1.10"`) into the four fields. Returns `false` and adds `INI_RACKINVENTORY_INVALID` on failure.
- **`TSFRackDescription ToTSFRackDescription()`**
Converts the `INIRackInfo` to a `TSFRackDescription` object, trimming `SerialNumber`.
- **`bool ReadFrom(string[] lines, ref int iCurLine, ref List<TDCINIError> errors)`**
Parses multiple lines until a line starting with `"----"` is encountered. Populates the `Racks` array. Returns `false` on error or if `TDCINIFile.GetNextLine` returns `null`. Decrements `iCurLine` on successful completion.
### `INIISOExportParameters`
- **`bool AutomaticISOExportOnDownload { get; set; }`**
Whether to automatically export ISO on download.
- **`string MMEHeaderTemplateFilename { get; set; }`**
Filename for MME header template (may be empty).
- **`bool PromptUserForMMETemplateFilename { get; set; }`**
Whether to prompt user for MME template.
- **`string ChannelHeaderTemplateFilename { get; set; }`**
Filename for channel header template (may be empty).
- **`bool PromptUserForChannelHeaderFilename { get; set; }`**
Whether to prompt user for channel header template.
- **`FilterOutputOptions FilterOutput { get; set; }`**
Output filter option (`UnFiltered`, `Filtered`, or `PromptUser`).
- **`bool SuppressExportCompletionDialog { get; set; }`**
Whether to suppress the export completion dialog.
- **`string DummyTemplateFilename { get; set; }`**
Filename for dummy template (may be empty).
- **`bool PromptUserForDummyTemplateFilename { get; set; }`**
Whether to prompt user for dummy template.
- **`enum FilterOutputOptions`**
- `UnFiltered = 0`
- `Filtered = 1`
- `PromptUser = 2`
- **`bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)`**
Parses a comma-separated line with 9 tokens. Tokens 0, 2, 4, 6, and 8 are boolean-like (`"0"/"F"/"N"` → false, `"1"/"T"/"Y"` → true). Token 5 selects `FilterOutput`. Tokens 1, 3, and 7 are string filenames. Returns `false` and adds `INI_ISOEXPORTPARAMETERS_INVALID` on failure.
### `TDCINIError`
- **`enum INIErrors`**
Contains over 70 specific error codes (e.g., `INI_DataZeroTimeWindow_INVALID`, `INI_ROI_INVALID`, `INI_ISOEXPORTPARAMETERS_INVALID`). Full list provided in source.
- **`INIErrors Error { get; }`**
The error type.
- **`int Line { get; set; }`**
Line number in the INI file where the error occurred (default `-1` if not applicable).
- **`string ExtraInfo { get; }`**
Additional context (e.g., the invalid token or full line).
- **Constructors**
- `TDCINIError(INIErrors error)`
- `TDCINIError(INIErrors error, string extraInfo)`
- `TDCINIError(INIErrors error, string extraInfo, int currentLine)`
All initialize the respective fields.
## 3. Invariants
- **Line Format**: All `ReadFrom(string line, ...)` methods expect exactly the number of comma-separated tokens required for their respective sections (e.g., 2 for ROI sections, 3 for `TDCINIRS232Info`, 9 for `INIISOExportParameters`). Any deviation results in an error and `false` return.
- **Numeric Parsing**: All numeric fields are parsed using `double.TryParse(..., NumberStyles.Any, CultureInfo.InvariantCulture, ...)`. Parsing failures result in an error and `false` return.
- **Boolean Parsing**: Boolean values are parsed using a case-insensitive token check: `"0"`, `"F"`, `"N"``false`; `"1"`, `"T"`, `"Y"``true`. Any other token is invalid.
- **Error Accumulation**: Errors are appended to the caller-provided `List<TDCINIError> errors` and never thrown as exceptions. Parsing failure does not throw; it returns `false`.
- **RackInventory Termination**: `INIRackInventory.ReadFrom(string[] lines, ...)` stops parsing when encountering a line starting with `"----"`. This is a hard delimiter.
- **Line Number Handling**: For single-line parsers, `curLine` is passed to `TDCINIError` constructors. For multi-line `INIRackInventory`, `iCurLine` is decremented after parsing to account for the final `"----"` line.
## 4. Dependencies
- **Internal Dependencies**:
- `TDCINIError` (defined in same namespace) used for error reporting.
- `TSFRackDescription` referenced only in `INIRackInfo.ToTSFRackDescription()`; assumed to be defined elsewhere in the codebase.
- `TDCINIFile.GetNextLine(...)` used by `INIRackInventory.ReadFrom(string[] lines, ...)` to iterate over lines and report errors.
- **External Dependencies**:
- `System.Collections.Generic.List<T>`
- `System.Globalization.NumberStyles`
- `System.Globalization.CultureInfo`
- `System` core types (`string`, `int`, `double`, `bool`, `enum`)
- **Depended Upon**:
- These classes are likely consumed by a higher-level INI file parser (e.g., `TDCINIFile`) to populate configuration objects. The exact caller is not visible in the provided source.
## 5. Gotchas
- **Inconsistent `curLine` parameter**:
`TDCINIRS232Info.ReadFrom(...)` does **not** accept a `curLine` parameter, while all other `ReadFrom` methods do. This may lead to inconsistent error reporting (line number omitted for `TDCINIRS232Info` errors).
- **`INIRackInventory` mutates `iCurLine`**:
The `ReadFrom(string[] lines, ref int iCurLine, ...)` method decrements `iCurLine` at the end. Callers must be aware that after a successful call, `iCurLine` points to the line *before* the `"----"` delimiter, not after it.
- **Boolean token ambiguity**:
Boolean parsing accepts `"F"` and `"N"` for `false`, which may be non-intuitive (e.g., `"N"` for "No" vs `"F"` for "False"). Ensure INI files use consistent values.
- **No validation of logical constraints**:
None of the classes validate semantic constraints (e.g., `Start < End`, `Yellow > Red`, `XMin < XMax`). It is the callers responsibility to enforce such invariants.
- **`INIRackInfo.SerialNumber` is trimmed only in `ToTSFRackDescription()`**:
The raw `SerialNumber` property retains leading/trailing whitespace; trimming occurs only during conversion to `TSFRackDescription`. This may cause inconsistency if the property is used directly.
- **`ExtraInfo` in `TDCINIError` may contain partial tokens**:
For `INI_ViewerROI_INVALID` and `INI_ISOEXPORTPARAMETERS_INVALID`, the `ExtraInfo` field may be set to a single invalid token (e.g., `tokens[0]`) rather than the full line, while other errors use the full line. This inconsistency may complicate debugging.
- **No default values**:
Properties are uninitialized until `ReadFrom` succeeds. If `ReadFrom` fails, properties retain their default values (`0`, `false`, `null`, etc.), which may be misleading. Callers should not assume valid state on failure.
- **`INIRackInventory.Racks` setter creates a new list**:
The `Racks` property setter replaces the internal `_racks` list with a new `List<INIRackInfo>` constructed from the array. This may have performance implications for large rack lists and could break reference equality expectations.
None identified beyond the above.

View File

@@ -0,0 +1,109 @@
---
source_files:
- DataPRO/SensorDB/TDM/TDMCSVImport.cs
generated_at: "2026-04-16T04:04:16.780744+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "c16790456aa03ce4"
---
# TDMCSVImport Documentation
## 1. Purpose
The `TDMCSVImport` class provides logic for importing sensor configuration data from a CSV file into the systems internal `SensorData` representation. It parses CSV rows (one per sensor) using a predefined set of column labels, maps string values to strongly-typed enums and properties, and constructs a fully initialized `SensorData` object. This module serves as the ingestion layer for legacy TDM (Test Data Manager) CSV exports, supporting a wide range of sensor types (full/half bridge, voltage, IRTRACC, potentiometers, angular rate sensors), calibration parameters, zeroing methods, filtering options, and Toyota-specific calculations. It is part of the `DTS.SensorDB.TDM` namespace and is used in contexts where CSV-based sensor metadata must be ingested into the sensor database.
## 2. Public Interface
### `public static TAGS LabelToTag(string label)`
- **Signature**: `public static TAGS LabelToTag(string label)`
- **Behavior**: Converts a CSV column header string (e.g., `"Serial No"`, `"Filter Type"`) into the corresponding `TAGS` enum value. Throws `NotSupportedException` if the label is unrecognized.
- **Note**: This is the only public method in the class.
### Nested Types (used internally)
The following enums are declared as `private` but are essential to understanding the mapping logic:
- **`MeasurementTypes`**: Internal enum representing sensor measurement types (e.g., `MEASTYPE_FULLBRIDGE`, `MEASTYPE_IRTRACC`, `MEASTYPE_ARS_ANGLE`). Used to determine bridge type and calibration behavior.
- **`FilterTypes`**: Internal enum representing filter types (e.g., `FILTERTYPE_CFC60`, `FILTERTYPE_FIR100`, `FILTERTYPE_USEFREQ`). Maps to `FilterClassType` or `FilterClass` constructor overloads.
- **`ZeroMethods`**: Internal enum representing zeroing strategies (`ZMETHOD_PREZERO`, `ZMETHOD_AVGTIME`, `ZMETHOD_EQUALS0MV`).
- **`TAGS`**: Public enum listing all supported CSV column labels (e.g., `SENSOR_CSV_LABEL_SERIAL_NO`, `SENSOR_CSV_LABEL_FILTER_TYPE`). Includes an `UNKNOWN` entry for unrecognized columns.
### Private Helper Methods (not part of public interface, but documented for completeness)
- `private static MeasurementTypes LabelToMeasurementType(string label)`
Converts CSV string labels (e.g., `"Full Bridge"`) to `MeasurementTypes`.
- `private static string MeasurementTypeToLabel(MeasurementTypes mt)`
Converts `MeasurementTypes` back to CSV labels.
- `private static string TagToLabel(TAGS tag)`
Converts `TAGS` enum to CSV column header strings.
### `public static DTS.SensorDB.SensorData GetSensor(...)`
- **Signature**:
```csharp
public static DTS.SensorDB.SensorData GetSensor(
string[] tokens,
TAGS[] tagOrder,
ref List<string> errors,
Dictionary<string, string> sensorTypeToDimension)
```
- **Behavior**: Parses a single CSV row (`tokens`) using the column order specified in `tagOrder`. Populates a new `SensorData` instance with values from the row. Errors encountered during parsing (e.g., invalid numbers, unrecognized labels) are appended to the `errors` list. The `sensorTypeToDimension` dictionary maps sensor type strings (e.g., `"Accelerometer"`) to physical dimension strings (e.g., `"Acceleration"`), which are used to set `sd.PhysicalDimension`.
Key behaviors:
- Trims and normalizes string tokens (removes leading `=`, surrounding quotes).
- Handles date parsing for `"Calibration Date"` (supports `/` or `-` separators).
- Defaults excitation voltage to 5V if `0` is provided in CSV.
- Sets `sd.UUID = sd.SerialNumber`.
- Applies default values for missing `Capacity` (→ 1) and `DisplayUnit` (→ `"g"`), logging warnings.
- For `MEASTYPE_IRTRACC`, sets `NonLinear = true` and configures non-linear calibration parameters.
- Maps `FilterTypes.FILTERTYPE_FIR100` to `CFC180` with a warning (unsupported).
- Stores Toyota calculation strings (`calc1`, `calc2`, `calc3`) concatenated into `sd.UserValue3`.
## 3. Invariants
- **`SensorData` must always be initialized**: A new `SensorData` and `SensorCalibration` are created unconditionally at the start of `GetSensor`.
- **`Bridge` type is always set**: Based on `MeasurementType`, `sd.Bridge` is assigned one of `FullBridge`, `HalfBridge_SigPlus`, or (implicitly) defaults to one of these.
- **`Calibration.Records.Records[0]` is always populated**: The first calibration record is always initialized and updated with sensitivity, units, and other fields.
- **`DisplayUnit` and `EngineeringUnits` are always set**: If missing in CSV, defaults to `"g"` and applies to all calibration records (per FB16398).
- **`Capacity` is always ≥ 1**: If `Capacity < 1`, it is set to `1` and a warning is logged.
- **`UUID` is always set to `SerialNumber`**: `sd.UUID = sd.SerialNumber` is applied unconditionally.
- **Filter is always assigned**: Even if `FILTERTYPE_FIR100` is unsupported, a fallback filter (`CFC180`) is assigned.
- **`Invert`, `Shunt`, `RemoveOffset` are always set**: Boolean fields default to `false` if parsing fails, but are never left uninitialized.
## 4. Dependencies
### Module Dependencies (from `using` directives and type references):
- `DTS.Common.Classes.Sensors` — Provides `SensorData`, `SensorCalibration`, `SensorConstants`.
- `DTS.Common.DAS.Concepts` — Provides `ExcitationVoltageOptions`, `Test.Module.Channel.Sensor.GetExcitationVoltageEnumFromMagnitude`.
- `DTS.Common.Enums`, `DTS.Common.Enums.Sensors` — Provides `NonLinearStyles`, `ShuntMode`, `ZeroMethodType`, `SensorConstants.SensUnits`.
- `System`, `System.Collections.Generic`, `System.Linq`, `System.Text` — Standard .NET types.
### External Dependencies (inferred):
- `DTS.SensorDB.SensorData` — The primary output type; implies a dependency on the `DTS.SensorDB` assembly.
- `FilterClass` and `FilterClassType` — Used to instantiate filters; implies a dependency on a filtering subsystem.
- `InitialOffsets`, `InitialOffset` — Used for zeroing; implies a dependency on zeroing-related types.
### Inbound Dependencies:
- This module is used by callers that provide CSV rows and a `sensorTypeToDimension` mapping (likely derived from a sensor type catalog).
- Requires `SensorData` and related types to be fully defined and compatible with the properties being set.
### Outbound Dependencies:
- None explicitly declared beyond the above; this module is a leaf in the data ingestion pipeline.
## 5. Gotchas
- **`FILTERTYPE_FIR100` is unsupported**: The code maps it to `CFC180` and logs a warning, but this may cause unexpected filter behavior if FIR100 was intended.
- **Zeroing parameters are only applied to `Methods[0]`**: `ZeroTimeStartMsec`, `ZeroTimeEndMsec`, and `ZeroInitialEU` only populate the first zero method (`Methods[0]`). If multiple zero methods are expected, this may be incomplete.
- **`Range_3` is commented out**: The `SENSOR_CSV_LABEL_RANGE_3` case is present but commented out; it does not set `sd.Capacity` despite the comment suggesting it might.
- **Excitation voltage `0` is treated as 5V**: This is explicitly handled as a special case for “Voltage Insertion” mode, but may be non-obvious to callers.
- **Date parsing is fragile**: Supports only `MM/DD/YYYY` or `YYYY-MM-DD` formats; other formats (e.g., `DD/MM/YYYY`) will fail unless the CSV uses unambiguous separators or ISO 8601.
- **`UNKNOWN` tag is silently ignored**: Any CSV column not in `TAGS` is mapped to `TAGS.UNKNOWN` and skipped.
- **`UserValue1`/`UserValue2`/`UserValue3` are repurposed**: `JCODE` → `UserValue1`, `CODE` → `UserValue2`, and concatenated Toyota calcs → `UserValue3`. This may conflict with other uses of these fields elsewhere.
- **`SensorType` validation is dictionary-dependent**: If `sensorTypeToDimension` does not contain the provided sensor type string, an error is logged but `PhysicalDimension` remains unset (defaulting to `null` or empty).
- **No validation of `SensitivityUnits` consistency**: The code sets `IsProportional` based on units, but does not validate whether the combination of `SensitivityUnits`, `BridgeType`, and `MeasurementType` is physically meaningful.
- **`RemoveOffset` parsing is case-insensitive but not robust**: Accepts `"1"/"T"/"Y"` and `"0"/"F"/"N"` but not `"true"/"false"` or `"yes"/"no"` explicitly.
- **`Invert` parsing is case-insensitive but limited**: Accepts `"0"/"F"/"N"` and `"1"/"Y"/"T"` but not `"true"/"false"`.
None identified beyond those listed above.

View File

@@ -0,0 +1,147 @@
---
source_files:
- DataPRO/SensorDB/TSF/TSFChannel.cs
- DataPRO/SensorDB/TSF/G5DigitalInputChannelTSFEntry.cs
- DataPRO/SensorDB/TSF/TSFCalculatedChannelEntry.cs
- DataPRO/SensorDB/TSF/TSFTCFSection.cs
- DataPRO/SensorDB/TSF/TSFSquibFireEntry.cs
- DataPRO/SensorDB/TSF/TSFDigitalChannel.cs
- DataPRO/SensorDB/TSF/TSFDIMEntry.cs
- DataPRO/SensorDB/TSF/TSFSensorEntry.cs
- DataPRO/SensorDB/TSF/TSFCalibrationInformation.cs
- DataPRO/SensorDB/TSF/TSFSamplingInformationSection.cs
- DataPRO/SensorDB/TSF/TSFModuleDescription.cs
- DataPRO/SensorDB/TSF/TSFOutputChannelDescription.cs
- DataPRO/SensorDB/TSF/TSFInputChannelDescription.cs
- DataPRO/SensorDB/TSF/TSFRackInformationSection.cs
- DataPRO/SensorDB/TSF/TSFSystemDescription.cs
- DataPRO/SensorDB/TSF/TSFModuleInformationSection.cs
generated_at: "2026-04-16T04:04:16.473755+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "a6520f9b14ea109d"
---
# TSF Channel and Section Documentation
## 1. Purpose
This module provides data structures and parsing logic for reading and representing data from TSF (Test System Format) files, which are configuration and metadata files used in the SensorDB system. It defines channel entry classes (e.g., `TSFSensorEntry`, `TSFSquibFireEntry`, `TSFTOMDigitalOutputChannel`, `G5DigtalInputChannelTSFEntry`, `TSFDIMEntry`, `TSFCalculatedChannelEntry`) that model different physical and logical channel types found in TSF files, and section-handling classes (e.g., `TSFSamplingInformationSection`, `TSFRackInformationSection`, `TSFModuleInformationSection`, `TSFTCFSection`) that parse specific TSF file sections. The `TSFChannel` base class adds a `TestChannelNumber` field to all channel types, enabling unified indexing of channels that may lack an inherent data channel number in the raw TSF format.
## 2. Public Interface
### Abstract Base Class
- **`TSFChannel`**
- `public const int NOT_ASSIGNED = -1`
- `public int TestChannelNumber { get; set; }`
A user-assigned channel index used to unify indexing across channel types that may not have a data channel number in the TSF.
### Channel Entry Classes (inherit `TSFChannel`)
- **`TSFSensorEntry`**
- Properties: `DataChan`, `Rack`, `Module`, `Chan`, `Description`, `SerialNumber`, `OffsetLow`, `OffsetHigh`, `RemoveOffset`, `CalMode`, `CalStep`, `ShuntValue`, `ProportionalToExcitation`, `Sensitivity`, `Gain`, `ExtVolt`, `EU`, `Filter`, `Invert`, `ZeroRef`, `DesiredMaxRange`, `CommentField`, `CalDate`, `Offset`, `InitialEU`, `SensorId`, `ISOCode`, `IRTRACCexponent`, `SensorCategory`, `DesiredMaxRangeScaling`, `C0``C6`
- Represents analog sensor channels from the *Start Sensor Channel Information* section.
- **`TSFSquibFireEntry`**
- Properties: `Rack`, `Module`, `Chan`, `Description`, `Id`, `Type`, `Current`, `Delay`, `DurationOn`, `Duration`, `OhmLow`, `OhmHigh`, `ISOcode`
- Represents squib fire channels from the TOM Squib Fire Channels section.
- **`TSFTOMDigitalOutputChannel`**
- Properties: `Rack`, `Module`, `Chan`, `Type` (`DigitalOutputTypes` enum: `NONE`, `FiveVLH`, `FiveVHL`, `CCNO`, `CCNC`), `Delay`, `DurationOn`, `Duration`, `Description`
- `public static DigitalOutputModes GetDigitalOutputMode(DigitalOutputTypes outputType)`
Maps internal `DigitalOutputTypes` to `DTS.Common.Enums.DigitalOutputModes`.
- Represents digital output channels in the TOM Digital Channels section.
- **`G5DigtalInputChannelTSFEntry`**
- Properties: `DataChan`, `Rack`, `Module`, `Chan`, `Descripton` *(note typo)*, `ISOCode`, `Scale`, `Invert`
- Represents G5 digital input channels.
- **`TSFDIMEntry`**
- Properties: `DataChan`, `Rack`, `Module`, `Chan`, `Description`, `SerialNumber`, `Mode`, `Inverted`, `EID`, `FileName`, `Scale`, `FilterMode`, `FilterThreshold`, `ISOCode`, `CableTest`
- Represents DIM (Data Input Module) entries; currently unused in DataPRO.
- **`TSFCalculatedChannelEntry`**
- Properties: `Chan`, `Description`, `ProcessType`, `FirstChan`, `SecondChan`, `ThirdChan`, `Value`, `EU`, `ExpMaxRange`, `Progress2`, `Progress3`
- Represents calculated channel entries; currently unused in DataPRO.
### Section Parsing Classes
- **`TSFSamplingInformationSection`**
- Constructor: `TSFSamplingInformationSection(List<string> lines, ref int currentLine)`
Parses the *Sampling Information* section. Throws `EndOfStreamException` or `InvalidDataException` on malformed input.
- Properties: `SampleRateHz`, `PreTriggerSeconds` (always positive), `PostTriggerSeconds` (always positive), `AAF`, `PostCalTimeSeconds`
- **`TSFRackInformationSection`**
- `public TSFRackDescription[] Racks { get; set; }`
- `public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors, TSFFile tsf, TSFSystemDescription system)`
Parses the *Rack Information* section. Adds `ReadTSFError` entries to the `errors` list on failure.
- **`TSFModuleInformationSection`**
- `public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors, TSFSystemDescription system, TSFRackInformationSection rackSection)`
Parses the *Module Information* section. Adds `ReadTSFError` entries to the `errors` list on failure. Populates module info on the matching `TSFRackDescription`.
- **`TSFTCFSection`**
- Properties: `TCFPath`
- `public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors)`
Parses the *TCF Info* section. Adds `ReadTSFError` entries to the `errors` list on failure.
- **`TSFCalibrationInformation`**
- Properties: `Version`, `Parent` (`TSFChannelDescription`), `Source`, `CRC32`, `CalibrationValid`, `CalPass`, `CalGainErrorPercent`, `CalShuntErrorPercent`, `CalMeasuredScaleFactorMV`, `CalExcitationVolts`, `CalChannelOffsetADC`, `CalChannelZeroADC`, `CalNaturalSensorOffsetMV`, `CalNaturalFloorADC`, `CalInputRangeMV`, `CalNoiseFloorADC`, `CalNoiseAtRangeADC`
- Constructors: default and copy constructor (`TSFCalibrationInformation(TSFCalibrationInformation copy, TSFChannelDescription channel)`)
- **`TSFSystemDescription`**
- Properties: `Version`, `SystemState`, `Source`, `CRC32`, `HardwareDescriptionValid`, `HWSIMCount`, `HWTOMCount`, `HWG5Count`, `HWAnalogChannelCount`, `HWSquibChannelCount`, `HWDigitalOutputChannelCount`, `HWDigitalInputChannelCount`, `HWRackCount`, `HWRack[]`, `TestDescriptionValid`, `TestSampleRate`, `TestPreTriggerSeconds`, `TestPostTriggerSeconds`, `TestConfigurationId`, `TestArmMode`, `TestAdjustibleAAFilter`, `TestCapacitorDischargeFrequency`, `TestModifiedDateTime`, `TestTZeroOffset`, `TestLTOffset`, `SystemInfoValid`, `SysArmStatus`, `SysLowPowerDetected`, `SysTriggerFaultDetected`, `SysStartRecordDected`
- Represents static and runtime system-level metadata.
- **`TSFModuleDescription`**
- Properties: `Version`, `Type`, `Parent` (`TSFRackDescription`), `Source`, `Slot`, `CRC32`, `HardwareInfoValid`, `HWSerialNumber`, `HWTOMTriggerType`, `HWRackPosition`, `HWChannelCount`, `HWChannelList[]`, `DownloadDescriptionValid`, `DownloadTriggerDetected`, `DownloadDataFlag`, `DownloadBeginSeconds`, `DownloadEndSeconds`, `ModuleBatteryVolts`
- Represents module-level metadata.
- **`TSFInputChannelDescription`**
- Properties: `Version`, `Parent` (`TSFChannelDescription`), `Source`, `CRC32`, `AnalogInfoValid`, `AnalogChannelType`, `AnalogChannelFilterMode`, `AnalogChannelOffsetMode`, `AnalogChannelShuntMode`, `AnalogExcitationVoltage`, `AnalogGain`, `AnalogShuntResistanceOhms`, `AnalogShuntEmulationOhms`, `AnalogShuntEU`, `AnalogSensitivity`, `AnalogSensitivityUnits`, `AnalogEULabel`, `AnalogInvertData`, `DigitalInfoValid`, `RealtimeInfoValid`, `UseForRealtime`, `RealtimeADC[]`, `RealtimeSamples`
- Represents input channel metadata (mostly HLAPI-derived, sparsely used).
- **`TSFOutputChannelDescription`**
- Properties: `Version`, `Parent` (`TSFChannelDescription`), `Source`, `CRC32`, `SquibInfoValid`, `SquibFireMode`, `SquibMeasurementType`, `SquibBypassCurrentFilter`, `SquibBypassVoltageFilter`, `SquibToleranceLow`, `SquibToleranceHigh`, `SquibOutputCurrent`, `DigitalInfoValid`, `DigitalOutputMode`, `SquibMeasurementValid`, `SquibMeasuredOhms`, `SquibFireValid`, `SquibFirePassed`, `CommonInfoValid`, `CommonDelayMS`, `CommonDurationMS`
- Represents output channel metadata (mostly HLAPI-derived, sparsely used).
## 3. Invariants
- **`TSFChannel.TestChannelNumber`** is initialized to `TSFChannel.NOT_ASSIGNED` (`-1`) and may be set to any `int`, including negative values.
- **`TSFSamplingInformationSection`** always stores `PreTriggerSeconds` and `PostTriggerSeconds` as absolute (positive) values, regardless of sign in the TSF file.
- **`TSFSquibFireEntry.Id`** setter normalizes `"none"` (case-insensitive) to an empty string.
- **`TSFSensorEntry.SensorId`** setter normalizes `"none"` (case-insensitive) to an empty string.
- **Section parsing methods** (`ReadFrom`) assume the `currentLine` index points to the start of the section header. They increment `currentLine` as they parse and expect the section to be well-formed.
- **`TSFRackInformationSection.ReadFrom`** skips invalid rack entries (e.g., empty serial number, invalid rack index, mismatched test type) and logs errors, but continues parsing.
- **`TSFModuleInformationSection.ReadFrom`** expects each module line to contain at least 7 comma-separated tokens; otherwise, it logs an error and skips the line.
## 4. Dependencies
### Internal Dependencies (from source)
- **`DTS.SensorDB` namespace** is used throughout.
- **`DTS.Common.Enums`** is used in `TSFTOMDigitalOutputChannel` (`DigitalOutputModes`).
- **`DTS.Common.Classes.Sensors`** is used in `TSFSensorEntry` (`TDCSensorCategory`).
- **`ReadTSFError`** is used in `ReadFrom` methods of `TSFRackInformationSection`, `TSFModuleInformationSection`, and `TSFTCFSection`.
- **`TSFFile`** is used in `TSFRackInformationSection.ReadFrom` (`GetICrashBarrierType()`).
- **`TSFRackDescription`** is used in `TSFRackInformationSection`, `TSFModuleInformationSection`, `TSFModuleDescription`, `TSFInputChannelDescription`, `TSFOutputChannelDescription`, and `TSFCalibrationInformation`.
- **`TSFChannelDescription`** is used in `TSFCalibrationInformation`, `TSFInputChannelDescription`, and `TSFOutputChannelDescription`.
### External Dependencies
- `System.Collections.Generic`, `System.Linq`, `System.Text`, `System.Globalization`, `System.IO` (standard .NET libraries).
### Inferred Usage
- These classes are used by higher-level TSF parsing logic (e.g., `TSFFile` class, referenced in `TSFRackInformationSection.ReadFrom`) to populate system, rack, module, and channel metadata.
- `TSFChannel` and its derived types are likely used in conjunction with `TSFChannelDescription`, `TSFRackDescription`, and `TSFModuleDescription` to represent the full channel hierarchy.
## 5. Gotchas
- **Typo in property name**: `G5DigtalInputChannelTSFEntry.Descripton` (missing 'i') instead of `Description`.
- **Case sensitivity in `Id`/`SensorId` normalization**: `TSFSquibFireEntry.Id` and `TSFSensorEntry.SensorId` setters convert `"none"` (case-insensitive) to `""`, but other values are not normalized.
- **`TSFRackInformationSection.ReadFrom`** has commented-out parsing code for additional fields (e.g., `rackIsoObject`, `iRackIsoPosition`), suggesting incomplete or deprecated functionality.
- **`TSFModuleInformationSection.ReadFrom`** uses `line.Contains("End Module Information")` to detect section end, which is fragile if the header text appears elsewhere in a line.
- **`TSFChannelDescription` is referenced but not defined in the provided source**, so its structure and relationship to the channel entry classes (`TSFSensorEntry`, etc.) are unclear.
- **`TSFInputChannelDescription.RealtimeADC`** uses a `lock` for thread-safety, but no other properties in the codebase show similar patterns—this may indicate legacy or incomplete threading support.
- **`TSFTOMDigitalOutputChannel.GetDigitalOutputMode`** maps `DigitalOutputTypes` to `DigitalOutputModes`, but the source does not define the target enum (`DigitalOutputModes`), so its exact mapping and behavior are inferred only from the `switch`.
- **`TSFSystemDescription` fields are marked as "sparsely used" or "not really used"** in comments, suggesting potential dead code or incomplete implementation.
- **`TSFModuleDescription` comment warns: "we may want to remove these HLAPI derived classes soon"**, indicating technical debt.