--- 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 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 lines, ref int currentLine, ref List errors, TSFFile tsf, TSFSystemDescription system)` Parses the *Rack Information* section. Adds `ReadTSFError` entries to the `errors` list on failure. - **`TSFModuleInformationSection`** - `public void ReadFrom(List lines, ref int currentLine, ref List 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 lines, ref int currentLine, ref List 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.