10 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T03:39:24.624240+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 7db16756696bba31 |
FIAT_ASC.File Module Documentation
1. Purpose
This module provides serialization support for exporting test data to the FIAT ASC (Automotive Signal Converter) format, a CSV-based file format used in automotive testing environments. It defines the DTS.Serialization.FIAT_ASC.File class, which represents a FIAT .asc file and encapsulates the logic for exporting Test objects to disk. The module handles per-channel file generation, data scaling/linearization, subsampling, filtering, progress reporting, cancellation support, and disk space validation prior to export. It is part of the broader DTS (Data Transfer System) serialization framework and integrates with existing channel, module, and test abstractions.
2. Public Interface
DTS.Serialization.FIAT_ASC.File
-
public bool UseFlatExportFolders { get; set; } = false;
Controls whether exported channel files are placed directly in the target directory (true) or in a subfolder (false). Note: This property is set on theFileinstance but is only applied when initializing theExporter. -
public File()
Default constructor. Initializes the base class with"ASC"as the format identifier. -
public static string Extension => ".asc";
Returns the file extension used by this format (.asc). -
public IWriter<Test> Exporter { get; }
Lazily initializes and returns anIWriter<Test>instance (FIAT_Asc.File.Writer) configured with the currentFileinstance andDefaultEncoding. The writer’sUseFlatExportFolderproperty is set fromUseFlatExportFolders. Throws a wrapped exception if initialization fails.
DTS.Serialization.FIAT_ASC.File.Writer
-
internal Writer(File fileType, int encoding)
Internal constructor. Initializes the writer with the owningFileinstance and encoding index. SetsWriterParenttofileType. -
internal File WriterParent { get; }
Reference to the owningFileinstance. -
public event BeginEventHandler OnBegin;
Event raised when a write operation starts. Payload includes total expected ticks. -
public event EndEventHandler OnEnd;
Event raised when a write operation completes (successfully or not). -
public event TickEventHandler OnTick;
Event raised periodically during export to report progress. Payload is a percentage (0–100). -
public event CancelEventHandler OnCancel;
Event raised if the write operation is cancelled. -
public event ErrorEventHandler OnError;
Event raised when a fatal error occurs during export. -
public Dictionary<string, FilteredData> FilteredChannelData { get; set; }
Gets or sets a dictionary mapping channel IDs to pre-filtered data (FilteredData). Used when exporting filtered data instead of raw ADC values. -
public void Write(string pathname, string id, Test test, bool bFiltering, bool includeGroupNameInISOExport, double minStartTime, int dataCollectionLength)
Convenience overload ofWrite(...). Delegates to the full signature with most parameters set tonullor defaults. Writes one.ascfile per channel intest.Channels, each named after the channel’s description or ISO name. -
public 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)
Main export method. Writes one.ascfile per channel intest.Channels. For each channel:- Creates the target directory if missing.
- Generates a channel-specific filename using
channel.ChannelName2,AIC.Description, or fallbacks. - Writes a header (start time, sample interval, sample count) followed by data rows.
- Applies scaling, linearization, subsampling (if
SubSampleInterval > 1), and filtering (ifFilteredistrue). - Dispatches progress ticks every
DataSamplesPerTick(1000) samples. - Supports cancellation via
cancelRequested. - Validates disk space before writing via
VerifyExportedFileWillFitOnDisk. - Raises
OnBegin,OnTick,OnEnd,OnCancel, andOnErrorevents.
-
public void Initialize(...)
Empty stub method. No-op. -
public double Start { get; set; } = 0D;
Start time (in seconds) relative to the test’s global trigger time. Used to clip data export. -
public double Stop { get; set; } = 0D;
Stop time (in seconds) relative to the test’s global trigger time. Used to clip data export. Default value of0Dlikely means "no clipping" or "use full data", but behavior depends on downstream logic. -
public ushort SubSampleInterval { get; set; } = 1;
Subsampling factor. When> 1, data is decimated usingNHTSASubSample<T>before export. -
public bool Filtered { get; set; } = true;
Iftrue, usesFilteredChannelDatafor export; otherwise, uses rawPersistentChannelInfo.Data.
3. Invariants
- File naming: Each channel is written to a separate file named after
channel.ChannelName2(orAIC.DescriptionforAnalogInputChannel), with invalid path characters (\,/) replaced by_. Extension is.asc. - Data format: Each
.ascfile begins with two header lines:startTime sampleInterval(both formatted as"F8", i.e., 8 decimal places).sampleCount(integer).
- Sample rate: All channels in a single
Writecall are assumed to share the same sample rate (sampleRate) for time alignment, though per-channel metadata (ChannelWithMeta) stores individual rates. - Time alignment: Data is aligned to a global
minStartTimecomputed across channels. Missing data at a given time index is written asNaN. - Scaling: Data is converted to engineering units (EU) using
DataScaler, which applies linearization, offset, scaling factors, IEPE, digital mode, etc. - Subsampling: Applied before export if
SubSampleInterval > 1, regardless ofFilteredflag. Modifieschannel.PersistentChannelInfo.DataorfilteredData[channel.ChannelId].Datain-place. - Disk space:
VerifyExportedFileWillFitOnDiskis called before writing. It estimates file size by subsampling the data and compares against available disk space. ThrowsUserExceptionif insufficient space. - Cancellation: The
cancelRequesteddelegate is checked at multiple points (header computation, disk space check, data loop). If true, writing stops early andOnCancelis raised.
4. Dependencies
Dependencies of this module:
- Core abstractions:
DTS.Serialization.Test,Test.Module,Test.Module.Channel,AnalogInputChannelDTS.Serialization.File(base class)IWriter<Test>interface
- Data structures:
FilteredData(type not shown; assumed to containdouble[] Data)ChannelWithMeta(type not shown; assumed to hold channel, scaler, sample rate, start time)DataScaler(type not shown; handles EU conversion)NHTSASubSample<T>(type not shown; performs decimation)
- Utilities:
DTS.Common.Utilities.FileUtils.GetEncodingDTS.Common.Utilities.Logging.APILoggerDTS.Common.DAS.Concepts.Sensors.SensorConstants(forBridgeType)DTS.Common.DAS.Concepts.Sensors.ZeroMethodTypeDiskUtility.GetDiskFreeSpaceEx,GetHumanReadableBytesSystem.IO.Path,Directory,FileStream,StreamWriterSystem.Text.Encoding
- Event handlers:
BeginEventHandler,EndEventHandler,TickEventHandler,CancelEventHandler,ErrorEventHandler(types not shown; assumed delegate signatures)CancelRequesteddelegate (returnsbool)
Dependencies on this module:
- Likely consumed by higher-level export services (e.g.,
TestSerializer, UI export dialogs) that instantiateFIAT_ASC.Fileand callExporter.Write(...). - Not directly referenced in source, but implied by
IWritable<Test>interface implementation.
5. Gotchas
Stop = 0Dbehavior: TheStopproperty defaults to0D. Its semantics are unclear—likely means "no clipping" (use full data), but this must be verified againstChannelWithMeta.GetMinStopTimelogic.- In-place data modification: Subsampling modifies
channel.PersistentChannelInfo.DataorfilteredData[...]in-place. This may cause side effects if the sameTestobject is reused. Filteredflag default:Filtereddefaults totrue, meaning the writer expectsFilteredChannelDatato be populated. If not,NaNvalues will be written for missing entries.UseFlatExportFoldernot used inWrite: TheUseFlatExportFolderproperty onWriteris set only duringExporterinitialization. TheWrite(...)method ignores it and always writes directly todestFolder(derived frompathname).Initializeis a no-op: TheInitialize(...)method has no implementation. Its purpose is unclear.ISOViewModefallback: Channel name resolution falls back to ISO/user code modes only ifOriginalChannelNameis null/empty. This is explicitly noted as a workaround for SQUIB channel issues.VerifyExportedFileWillFitOnDisksubsampling heuristic: The disk space check subsamples data (segmentSize = dataCollectionLength / 2000000) to avoid expensive computation. This may underestimate file size for small datasets.DataSamplesPerTickhard-coded: Progress ticks are dispatched every 1000 samples. This may be too coarse/fine for some use cases.System.Windows.Forms.Application.DoEvents(): Used in the data loop to keep UI responsive. This implies a dependency on WinForms and may cause reentrancy issues if not handled carefully.NUMBER_FORMAT = "F8": All numeric output uses 8 decimal places. This may cause precision issues or large file sizes for high-resolution data.FilteredChannelDatakeying: Useschannel.ChannelIdas the dictionary key. Ensure channel IDs are stable and unique across tests.