11 KiB
11 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:39:24.855976+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 3ac6639dcd230dd5 |
TDM Serialization Module Documentation
1. Purpose
This module provides serialization support for exporting test data to the TDM (Test Data Manager) CSV format, specifically targeting the CFC1000 specification. It enables conversion of internal Test objects into structured CSV files containing test metadata, channel headers, and sampled data, with support for time-range filtering (start/stop), subsampling, and optional filtering. The module exists to interface with external tools or systems (e.g., TTS, TEMA, TDAS) that consume TDM-formatted data, ensuring compatibility through precise adherence to the expected file structure and field semantics.
2. Public Interface
DTS.Serialization.TDM.File
File()
Constructor. Initializes the file type with the fixed format name"TDM CFC1000"(passed tobase("TDM CFC1000")).Exporter(property,IWriter<Test>)
Returns a lazily-initializedWriterinstance configured with thisFileinstance andDefaultEncoding. Sets theStartandStopproperties on the writer before returning.Start(property,double)
Gets/sets the start time (in seconds) for export filtering.Stop(property,double)
Gets/sets the stop time (in seconds) for export filtering.
DTS.Serialization.TDM.Writer
Writer(File fileType, int encoding)(internal constructor)
Initializes the writer with the specifiedFiletype and encoding.AllowTTSExportFiltering(property,bool, defaultfalse)
Controls whether filtered data export is enabled.Start,Stop(properties,double)
Get/set the time range (in seconds) to export. Rounded to 3 decimal places internally duringWrite.FilteredData(property,List<FilteredData>)
Holds precomputed filtered data (used whenAllowTTSExportFilteringistrue).Test(property,Test)
The test object being exported.IncrementLevel(property,ulong, read-only)
Controls granularity of progress updates during export (set dynamically based on estimated sample count).SubSampleInterval(property,ushort)
Subsampling factor applied during export.ExtensionPrefix(property,string, default"")
Optional string appended to the output filename before.csv.Write(string pathname, string id, string dataFolder, Test target, bool bFiltering, bool includeGroupNameInISOExport, FilteredData fd, Test.Module.Channel tmChannel, int channelNumber, BeginEventHandler, CancelEventHandler, EndEventHandler, TickEventHandler, ErrorEventHandler, CancelRequested, double minStartTime, int dataCollectionLength)
Primary export method. Serializes theTestto a CSV file atpathname. Performs rounding ofStart/Stopto 3 decimal places, computes progress increments, and invokesDoExport. Notable:pathnameis used as a directory; the actual file path isPath.Combine(pathname, Test.Id)with optional suffixes.DoExport(bool bFiltered, string pathname, double start, double stop, bool allowTTSFilteredExport)(private)
Core export logic: constructs the output filename, opens aStreamWriterwith UTF-8 encoding (or fallback), and writes test header, channel header, and channel data viaTestHeader.WriteTestHeader,ChannelHeader.WriteChannelHeaderToString, andChannelData.GenerateChannelData/WriteChannelData.Initialize(...)
Empty stub method (no-op). Present to satisfyIWriter<Test>interface but performs no initialization.
DTS.Serialization.TDM.TestHeader
WriteTestHeader(Writer writer, TextWriter tw, bool bFiltered, UInt16 subSampleInterval, ulong numSamples, int preTriggerSamples)
Writes the test header section to the CSV. Includes test ID, impact parameters (hardcoded to 0), date/time, device sections (dummies, barriers, groups), sample counts, sample rate, channel count, and description. Device section writing is partially implemented (dummies useUserValue3from first channel; barriers/groups are written as blank lines).
DTS.Serialization.TDM.ChannelHeader
WriteChannelHeaderToString(Writer writer, TextWriter tw, bool bFiltered, double start, double end)
Writes the channel header section (15 lines) to the CSV. For each non-squib-voltage channel, populates fields: DAS name, capacity, engineering units, sensor SN, sensitivity, excitation, min/max values (computed over requested range), Toyota calc fields (hardcoded), knee point (fromSoftwareFilter), data flag, channel code, and channel description. Squib voltage channels are skipped.
DTS.Serialization.TDM.TDMParameterDlg
TDMParameterDlg(string testName, double testStart, double testEnd)
Constructor. Initializes the dialog with test metadata. Sets default location toTDMFoldersetting +{testName}.csv. SetstbStart/tbStoptext to either provided values (converted to ms) or user defaults, enforcing min/max constraints fromtestStart/testEnd.FileName(property,string)
Gets the selected output file path fromtbLocation.Text.Start(property,double)
Gets the parsed start time in seconds (value intbStartis in ms, divided by 1000).Stop(property,double)
Gets the parsed stop time in seconds (value intbStopis in ms, divided by 1000).btnBrowse_Click
Opens aSaveFileDialogto select the output.csvfile.btnOK_Click
Validates inputs: parsestbStart/tbStopas doubles, checksStop > Start, ensures values are within[testStart*1000, testEnd*1000]ms range, saves settings, and setsDialogResult = OK.btnCancel_Click
SetsDialogResult = Canceland closes the dialog.
3. Invariants
- File format: Output is always a
.csvfile named{Test.Id}[optional suffix].csv. - Time units:
Start/StopinFile,Writer, andTDMParameterDlgproperties are in seconds, exceptTDMParameterDlgUI fields (tbStart,tbStop) which display and parse values in milliseconds. - Rounding:
StartandStoppassed toDoExportare rounded to 3 decimal places (milliseconds precision) before use. - Channel filtering: Squib voltage channels (
IsSquibVoltage() == true) are excluded from channel header and data export. - Sample bounds: Exported sample indices are clamped to
[StartRecordSampleNumber, StartRecordSampleNumber + NumberOfSamples)per module. Invalid ranges are silently adjusted. - Encoding: Output uses UTF-8 with BOM by default; falls back to
Encoding.Defaulton encoding errors. - Device section constraints:
TestHeaderenforcesMAX_DEVICE_LINES = 23total device lines (dummies, barriers, groups), with specific max counts (MAX_DUMMY_DISPLAY=16,MAX_BARRIER_DISPLAY=3,MAX_OLD_GROUP_LINES=4). Device lists are padded with empty lines to fill allocated space. - Progress reporting:
IncrementLevelis dynamically set to10,1000, or10000based on estimated sample count to ensure progress ticks fit withinuintlimits.
4. Dependencies
Internal Dependencies
DTS.Common.DAS.Concepts: ProvidesTest,Test.Module,Test.Module.Channel,Test.Module.AnalogInputChannel,FilteredData,DataScaler.DTS.Common.Utilities.Logging: ProvidesAPILogger.DTS.Common.Serialization: Base classesSerialization.File,Serialization.File.Writer<File>,IWriter<Test>, event handlers (BeginEventHandler,EndEventHandler,TickEventHandler,ErrorEventHandler,CancelEventHandler,CancelRequested).DTS.Common.Enums.Sensors:SensorConstants(e.g.,BridgeType.IEPE,BridgeType.DigitalInput).DTS.Common.Utilities:DescriptionAttributeCoder<T>.System: Core types (System.IO,System.Text,System.Linq,System.Globalization).System.Windows.Forms: Used byTDMParameterDlg(Form,SaveFileDialog,ErrorProvider,TableLayoutPanel,Button,TextBox,Label).
External Dependencies
- Settings: Relies on
Properties.Settings1.Default.TDMFolder,DefaultStart,DefaultStop. - File system: Requires write access to the output directory.
5. Gotchas
- Time unit confusion:
TDMParameterDlgUI uses milliseconds, butFile.Start/StopandWriter.Start/Stopuse seconds. Conversion is handled only inTDMParameterDlg'sStart/Stopproperties (divide ms by 1000). - Rounding hack:
Start/Stopare rounded to 3 decimal places inWriter.Writeto mitigate floating-point precision issues from SLICE/TDAS download discrepancies. This may alter user-specified ranges slightly. - Sample index calculation:
ChannelHeader.WriteChannelHeaderToStringcomputes sample indices usingTriggerSampleNumbers[0]andStartRecordSampleNumber. If these values are inconsistent across modules, sample ranges may be misaligned. - Device section underutilization:
TestHeader.WriteDeviceSectionwrites dummies/barrriers/groups but often leaves many lines blank (e.g., dummies use onlyUserValue3from first channel; barriers/groups are hardcoded to 0 count). This is noted as "not completely implemented equivalent to TDM". - Squib channel handling: Squib voltage channels are skipped entirely in export. Squib channels (non-voltage) are included but with hardcoded capacity (
10) and sensitivity (1). - Min/max calculation:
ChannelHeader.WriteChannelHeaderToStringcomputes min/max over the requestedstart/endrange. If the range extends beyond available data,IndexOutOfRangeExceptionis caught and logged, but min/max may be incomplete. - Encoding fallback: If
DefaultEncodingis invalid,Encoding.Defaultis used silently (after logging), which may cause non-ASCII characters to be mangled. - No-op
Initialize: TheWriter.Initializemethod is present but empty. Any initialization logic must be done elsewhere (e.g., inWrite). - Hardcoded values: Several fields are hardcoded (e.g., impact speed/weight = 0, capacity for squib = 10, cable multiplier = 1, excitation for digital = 1V). These may not match all TDM variants.
- Filename construction: Output filename is
Path.Combine(pathname, Test.Id), wherepathnameis treated as a directory. Ifpathnameis a file path, behavior is undefined (likely creates nested path).