8.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||
|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:38:52.973808+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 75e43dc7ec17e504 |
SoMat
SoMat Serialization Module Documentation
1. Purpose
This module implements serialization of Test objects (from DTS.Serialization.Test) into a proprietary text-based format compatible with Diadem (a data analysis and reporting tool from National Instruments). It generates a single .txt file containing structured metadata (test header, channel definitions) followed by tab-delimited numeric data arrays. The module is part of the DTS.Serialization.SoMat namespace and serves as a concrete implementation of a file writer for SoMat-formatted output, primarily used for exporting test data for post-processing or reporting.
2. Public Interface
DTS.Serialization.SoMat.File
-
File()
Parameterless constructor. Initializes the baseSerialization.Filewith the string"SoMat"as the format name. -
static string Extension
Returns the file extension for SoMat files:".txt". -
IWriter<Test> Exporter
Lazily-initialized property that returns anIWriter<Test>instance (SoMat.File.Writer) usingDefaultEncoding. Throws anExceptionwith inner exception if writer instantiation fails.
DTS.Serialization.SoMat.File.Writer
-
internal Writer(File fileType, int encoding)
Internal constructor; initializes the baseWriter<File>with the providedfileTypeandencoding. -
void Write(string pathname, string id, Test test, bool bFiltering, bool includeGroupNameInISOExport, double minStartTime, int dataCollectionLength)
ThrowsNotSupportedException— this overload is explicitly unsupported. -
void Write(string pathname, string id, string dataFolder, Test test, bool bFiltering, bool includeGroupNameInISOExport, FilteredData fd, Test.Module.Channel tmChannel, int channelNumber, BeginEventHandler beginEventHandler, CancelEventHandler cancelEventHandler, EndEventHandler endEventHandler, TickEventHandler tickEventHandler, ErrorEventHandler errorEventHandler, CancelRequested cancelRequested, double minStartTime, int dataCollectionLength)
Writes a SoMat file topathname.- Constructs a
SoMatTestHeaderusingtestandFilteredData[](fromFilteredDataproperty). - Serializes header and channel metadata to the file.
- Writes
"DM_Start=\r\n"as a data section marker. - Iterates over sample indices up to
maxSamples(max across all modules), writing one row per sample with tab-separated values (formatted as"0.00000E+00"), one column per channel. - Invokes event handlers (
beginEventHandler,tickEventHandler,endEventHandler,errorEventHandler) for progress and error reporting. - Logs exceptions via
APILogger.Log. - Throws exceptions if no
errorEventHandleris provided.
- Constructs a
-
FilteredData[] FilteredData
Property to set/get theFilteredData[]array used during serialization. Required before calling the multi-parameterWritemethod.
DTS.Serialization.SoMat.SoMatTestHeader
-
SoMatTestHeader(Test test, FilteredData[] filteredData)
Constructor that populates header fields fromtestandfilteredData.TestTitle←test.IdRunDateTime← formattedtest.InceptionDateOperator← current Windows user name (falls back to empty string on failure)NumLogChannels←test.Channels.Count(capped byfilteredData.Length)NumDataModes←1(hardcoded)- Populates
_channelslist by constructingSoMatChannelobjects.
-
void Serialize(StreamWriter sw)
Writes header fields inDM_-prefixed key=value format tosw, followed by a blank line.
DTS.Serialization.SoMat.SoMatChannel
-
SoMatChannel(Test.Module.Channel channel, int logicalChannel, FilteredData filteredData, int moduleArrayIndex, int numChannelsPerModule, DateTime inceptionDateTime)
Constructor that initializes channel metadata fromchannel,filteredData, and test context.LogicalChannel←logicalChannelChanName←channel.ChannelDescriptionString(viaAnalogInputChannel)NumDataPoints←channel.ParentModule.NumberOfSamplesSampleRate,TimeBase,MaxValue,MinValue,UserMax,UserMin,ElapsedTime,AcquisitionRate,RTCStart,RTCEnd,PhysicalChannelNumbercomputed from module/channel/test data.AxisUnitsDim2←engineeringUnits.TrimEnd()AxisLabelDim2,DescDim2←channel.SerialNumber
-
void Serialize(StreamWriter sw)
Writes channel metadata inDM_-prefixed key=value format (plus legacy2100_andHDWParams/CALParams/DGParamskeys) tosw, followed by a blank line.
3. Invariants
- File extension: All output files use
.txt. - Data format: Data section begins with
"DM_Start=\r\n"and consists of rows of tab-separated floating-point values in scientific notation ("0.00000E+00"). - Channel ordering: Channels are serialized in the order of
test.Channels, with indeximapped tofilteredData[i]. - Physical channel numbering:
PhysicalChannelNumber = 1 + moduleArrayIndex * numChannelsPerModule + aic.Number, wherenumChannelsPerModule = 3(hardcoded inSoMatChannelconstructor). - Header consistency:
NumLogChannelsinSoMatTestHeadermatches the number ofSoMatChannelobjects serialized. - Time base: If
TimeOfFirstSampleValidis false,TimeBaseis computed as(StartRecordSampleNumber - TriggerSampleNumbers[0]) / SampleRateHz. - Data mode:
NumDataModesis always1;DataModeTypeis always"TIMHIS".
4. Dependencies
Internal Dependencies (from source):
DTS.Serialization.Test(namespaceDTS.Serialization) — core test model.DTS.Serialization.SoMat.FilteredData— assumed to be a type with adouble[] Dataproperty (used inSoMatChannelandWriter.Write).DTS.Serialization.SoMat.Test.Module.Channel,Test.Module.AnalogInputChannel,Test.Module— test model subtypes.DTS.Common.Utilities.Logging.APILogger— for logging exceptions.System.IO.StreamWriter,System.Text.Encoding,System.Security.Principal.WindowsIdentity,System.Linq,System.Windows.Forms.Application(forDoEvents()).
External Dependencies:
- Diadem compatibility: Output format is designed for consumption by Diadem (per
Writersummary). - Windows-specific: Uses
WindowsIdentity.GetCurrent()for operator name.
Dependencies on this module:
DTS.Serialization.Testconsumers (e.g., test export pipelines) likely depend onSoMat.File.Exporterto generate.txtfiles.
5. Gotchas
- Unsupported
Writeoverload: The 7-parameterWritemethod throwsNotSupportedException. Only the 17-parameter overload is functional. - Hardcoded
numChannelsPerModule = 3: InSoMatChannelconstructor,numChannelsPerModuleis passed as3. This may be incorrect if modules have varying channel counts. FilteredDatamust be set manually: TheWriter.FilteredDataproperty must be assigned before callingWrite; otherwise,FilteredDataisnull, causing aNullReferenceExceptionduring header construction.TimeBasefallback logic: WhenTimeOfFirstSampleValidis false,TriggerSampleNumbers[0]is used. IfTriggerSampleNumbersis empty orStartRecordSampleNumberis invalid, this may produce incorrect or NaN values.- Encoding: Uses
Encoding.Default(ANSI code page) for file writing — may cause issues with non-ASCII characters. - Event handler requirements: If
errorEventHandlerisnulland an exception occurs, the exception is rethrown. Otherwise, it is suppressed and only passed toerrorEventHandler. DM_Startmarker: The"DM_Start=\r\n"line is written before data rows, but no corresponding"DM_Stop"or end marker is present.NumDataModeshardcoded: Always1, regardless of actual data modes in the test.PhysicalChannelNumberassumes fixednumChannelsPerModule: Calculation may be incorrect ifnumChannelsPerModulediffers from 3 in practice.- No validation of
filteredData.Lengthvstest.Channels.Count: TheSoMatTestHeaderconstructor silently truncates to the smaller of the two counts.
None identified beyond these.