12 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T04:03:50.006519+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 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") intoStartandEnd. Returnsfalseand adds anINI_DataZeroTimeWindow_INVALIDerror 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") intoYellowandRed. Returnsfalseand adds anINI_SmartBatteryStatusThresholdserror 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") intoXMinandXMax. Returnsfalseand adds anINI_ViewerROI_INVALIDerror 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") intoStartSecondsandEndSeconds. Returnsfalseand adds anINI_ROI_INVALIDerror 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") intoComPortNumber,MaxComSpeed, andMaxComPorts. Returnsfalseand adds anINI_COMINFO_INVALIDerror if parsing fails or the line does not contain exactly three values. Note:curLineis 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") intoApplyROI,ROIStartSeconds, andROIEndSeconds.ApplyROIis set based on tokens"0"/"F"/"N"(false) or"1"/"T"/"Y"(true). Returnsfalseand adds anINI_IIHSExport_INVALIDerror 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. Returnsfalseand addsINI_RACKINVENTORY_INVALIDon failure.TSFRackDescription ToTSFRackDescription()
Converts theINIRackInfoto aTSFRackDescriptionobject, trimmingSerialNumber.
bool ReadFrom(string[] lines, ref int iCurLine, ref List<TDCINIError> errors)
Parses multiple lines until a line starting with"----"is encountered. Populates theRacksarray. Returnsfalseon error or ifTDCINIFile.GetNextLinereturnsnull. DecrementsiCurLineon 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, orPromptUser).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 FilterOutputOptionsUnFiltered = 0Filtered = 1PromptUser = 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 selectsFilterOutput. Tokens 1, 3, and 7 are string filenames. Returnsfalseand addsINI_ISOEXPORTPARAMETERS_INVALIDon 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-1if 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 forTDCINIRS232Info, 9 forINIISOExportParameters). Any deviation results in an error andfalsereturn. - Numeric Parsing: All numeric fields are parsed using
double.TryParse(..., NumberStyles.Any, CultureInfo.InvariantCulture, ...). Parsing failures result in an error andfalsereturn. - 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> errorsand never thrown as exceptions. Parsing failure does not throw; it returnsfalse. - 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,
curLineis passed toTDCINIErrorconstructors. For multi-lineINIRackInventory,iCurLineis 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 inINIRackInfo.ToTSFRackDescription(); assumed to be defined elsewhere in the codebase.TDCINIFile.GetNextLine(...)– used byINIRackInventory.ReadFrom(string[] lines, ...)to iterate over lines and report errors.
-
External Dependencies:
System.Collections.Generic.List<T>System.Globalization.NumberStylesSystem.Globalization.CultureInfoSystemcore 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.
- These classes are likely consumed by a higher-level INI file parser (e.g.,
5. Gotchas
-
Inconsistent
curLineparameter:
TDCINIRS232Info.ReadFrom(...)does not accept acurLineparameter, while all otherReadFrommethods do. This may lead to inconsistent error reporting (line number omitted forTDCINIRS232Infoerrors). -
INIRackInventorymutatesiCurLine:
TheReadFrom(string[] lines, ref int iCurLine, ...)method decrementsiCurLineat the end. Callers must be aware that after a successful call,iCurLinepoints to the line before the"----"delimiter, not after it. -
Boolean token ambiguity:
Boolean parsing accepts"F"and"N"forfalse, 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 caller’s responsibility to enforce such invariants. -
INIRackInfo.SerialNumberis trimmed only inToTSFRackDescription():
The rawSerialNumberproperty retains leading/trailing whitespace; trimming occurs only during conversion toTSFRackDescription. This may cause inconsistency if the property is used directly. -
ExtraInfoinTDCINIErrormay contain partial tokens:
ForINI_ViewerROI_INVALIDandINI_ISOEXPORTPARAMETERS_INVALID, theExtraInfofield 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 untilReadFromsucceeds. IfReadFromfails, properties retain their default values (0,false,null, etc.), which may be misleading. Callers should not assume valid state on failure. -
INIRackInventory.Rackssetter creates a new list:
TheRacksproperty setter replaces the internal_rackslist with a newList<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.