Files

190 lines
7.1 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
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-17T15:48:03.697947+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "507c2abf21a4f505"
---
# TDCINI Module Documentation
## 1. Purpose
This module provides a collection of helper classes for parsing configuration data from INI files within the `DTS.SensorDB.TDCINI` namespace. Each class corresponds to a specific INI section, responsible for deserializing comma-delimited text lines into strongly-typed properties. The module centralizes error handling through the `TDCINIError` class, enabling consistent validation and error reporting across all configuration sections.
---
## 2. Public Interface
### TDCINIError
Error container class for INI parsing failures.
**Properties:**
- `Error` (`INIErrors`) — The error type enum value
- `Line` (`int`) — Line number where error occurred (default: -1)
- `ExtraInfo` (`string`) — Additional context (e.g., the problematic line or token)
**Constructors:**
- `TDCINIError(INIErrors error)`
- `TDCINIError(INIErrors error, string extraInfo)`
- `TDCINIError(INIErrors error, string extraInfo, int currentLine)`
**Nested Enum:**
- `INIErrors` — Contains 60+ error codes including `INI_FILE_NOT_FOUND`, `INI_COMINFO_INVALID`, `INI_ROI_INVALID`, `INI_RACKINVENTORY_INVALID`, `INI_ISOEXPORTPARAMETERS_INVALID`, `INI_IIHSExport_INVALID`, etc.
---
### INIDataZeroTimeWindowSeconds
Parses the DataZeroTimeWindow section.
**Properties:**
- `Start` (`double`) — Start of data zero window
- `End` (`double`) — End of data zero window
**Methods:**
- `bool ReadFrom(string line, ref List<TDCINIError> errors, int iCurrentLine)` — Parses a comma-delimited line with exactly 2 double values. Returns `true` on success, `false` on failure.
---
### INISmartBatteryThresholds
Parses the SmartBatteryThreshold section.
**Properties:**
- `Yellow` (`int`) — Time in minutes for yellow battery warning
- `Red` (`int`) — Time in minutes for red battery warning
**Methods:**
- `bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)` — Parses a comma-delimited line with exactly 2 integer values.
---
### INIViewerROI
Parses the ViewerROI section.
**Properties:**
- `XMin` (`double`) — X minimum value
- `XMax` (`double`) — X maximum value
**Methods:**
- `bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)` — Parses a comma-delimited line with exactly 2 double values.
---
### TSFINIRegionOfInterest
Parses the RegionOfInterest section.
**Properties:**
- `StartSeconds` (`double`) — Start of ROI relative to T0
- `EndSeconds` (`double`) — End of ROI relative to T0
**Methods:**
- `bool ReadFrom(string line, int currentLine, ref List<TDCINIError> errors)` — Parses a comma-delimited line with exactly 2 double values.
---
### TDCINIRS232Info
Parses the RS232 section.
**Properties:**
- `ComPortNumber` (`int`) — Communication port number
- `MaxComSpeed` (`int`) — Maximum speed of COM port
- `MaxComPorts` (`int`) — Maximum number of ports
**Methods:**
- `bool ReadFrom(string line, ref List<TDCINIError> errors)` — Parses a comma-delimited line with exactly 3 integer values. Note: No line number parameter.
---
### INIIIHSExport
Parses the IIHS Export section.
**Properties:**
- `ApplyROI` (`bool`) — Whether to apply region of interest
- `ROIStartSeconds` (`double`) — Start of ROI in seconds
- `ROIEndSeconds` (`double`) — End of ROI in seconds
**Methods:**
- `bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)` — Parses a comma-delimited line with exactly 3 values. First token is parsed as boolean (accepts "0"/"F"/"N" for false, "1"/"T"/"Y" for true).
---
### INIISOExportParameters
Parses the ISO Export section.
**Properties:**
- `AutomaticISOExportOnDownload` (`bool`)
- `MMEHeaderTemplateFilename` (`string`)
- `PromptUserForMMETemplateFilename` (`bool`)
- `ChannelHeaderTemplateFilename` (`string`)
- `PromptUserForChannelHeaderFilename` (`bool`)
- `FilterOutput` (`FilterOutputOptions`) — Enum with values: `UnFiltered = 0`, `Filtered = 1`, `PromptUser = 2`
- `SuppressExportCompletionDialog` (`bool`)
- `DummyTemplateFilename` (`string`)
- `PromptUserForDummyTemplateFilename` (`bool`)
**Methods:**
- `bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)` — Parses a comma-delimited line with exactly 9 tokens. Boolean tokens accept "0"/"F"/"N" for false and "1"/"T"/"Y" for true.
---
### INIRackInventory
Parses the RackInventory section (multi-line).
**Nested Class: INIRackInfo**
- `Number` (`int`)
- `SerialNumber` (`string`)
- `Size` (`int`)
- `IPAddress` (`string`)
- `bool ReadFrom(string line, ref List<TDCINIError> errors)` — Parses single rack entry (4 tokens)
- `TSFRackDescription ToTSFRackDescription()` — Converts to `TSFRackDescription` object
**Properties:**
- `Racks` (`INIRackInfo[]`) — Array of rack information entries
**Methods:**
- `bool ReadFrom(string[] lines, ref int iCurLine, ref List<TDCINIError> errors)` — Reads multiple lines until a line starting with `"----"` is encountered. Decrements `iCurLine` before returning.
---
## 3. Invariants
- **Number parsing**: All numeric parsing uses `System.Globalization.NumberStyles.Any` with `CultureInfo.InvariantCulture` — INI files must use invariant culture formatting (period as decimal separator).
- **Delimiter**: All parsing uses comma (`,`) as the field delimiter via `line.Split(new char[] { ',' })`.
- **Token count validation**: Each parser enforces an exact token count; deviation results in failure.
- **Error accumulation**: The `errors` list passed by reference accumulates errors; callers must provide a non-null list.
- **Boolean encoding**: Boolean fields accept multiple string representations: `"0"`, `"F"`, `"N"``false`; `"1"`, `"T"`, `"Y"``true`.
- **FilterOutputOptions encoding**: Accepts string values `"0"`, `"1"`, `"2"` mapping to respective enum values.
- **RackInventory termination**: Multi-line rack inventory must terminate with a line starting with `"----"`.
---
## 4. Dependencies
**This module depends on:**
- `System`
- `System.Collections.Generic`
- `System.Globalization` (via `CultureInfo.InvariantCulture`)
- `System.Linq`
- `System.Text`
- `TDCINIFile` — Static method `GetNextLine` is called in `INIRackInventory.ReadFrom`
- `TSFRackDescription` — Referenced in `INIRackInventory.INIRackInfo.ToTSFRackDescription()`
**What depends on this module:**
- Not determinable from source alone; consumers would include any code parsing TDC INI configuration files.
---
## 5. Gotchas
1. **Inconsistent `ReadFrom` signatures**: The method signature varies across classes:
- `INIDataZeroTimeWindowSeconds.ReadFrom` takes `(string, ref List<TDCINIError>, int)` — line number is third parameter
- `TDCINARS232Info.ReadFrom` takes `(string, ref List<TDCINIError