Files
DP44/docs/ai/Common/DTS.Common.Serialization/RDF.md
2026-04-17 14:55:32 -04:00

7.1 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.Common.Serialization/RDF/RDF.File.cs
Common/DTS.Common.Serialization/RDF/RDF.File.Writer.cs
2026-04-17T15:42:21.831959+00:00 zai-org/GLM-5-FP8 1 0c02ee86055c6c96

RDF File Serialization Module Documentation

1. Purpose

This module provides serialization of test data to RDF (Representation Data Format) files, a binary format designed for Toyota CSV file compatibility. It handles the export of Test objects containing channel data, converting ADC values, scaling factors, and metadata into a structured binary format with fixed-width fields. The module supports various sensor types including analog inputs, digital inputs, IEPE sensors, and squib channels, with special handling for linearized and non-linear data.


2. Public Interface

DTS.Serialization.RDF.File (Partial Class)

Inherits: Serialization.File, IWritable<Test>

Constructor

public File(Common.ISO.TestPlan plan)

Initializes an RDF file instance with the specified test plan.

Constants

public const string SUFFIX_RUNTEST = " RunTest";
public const string SUFFIX_CHECKOUT = " Checkout";
public const int MAX_TEST_NAME_LENGTH = 8;

Properties

public static string Extension => ".001";
public bool UseZeroForUnfiltered { get; set; }
public bool FilteredExport { get; set; }
public IWriter<Test> Exporter { get; }
  • Extension returns the hardcoded file extension ".001"
  • Exporter lazily instantiates a Writer instance, configuring it with TestPlan, UseZeroForUnfiltered, and FilteredExport values

Methods

public override void SetEUData(string channelID, FilteredData fd);
public override FilteredData GetEUData(string channelID);

Manages EU (Engineering Units) data storage in an internal dictionary _EUUnfilteredDataForLinearizedChannels.


DTS.Serialization.RDF.File.Writer (Nested Class)

Inherits: Writer<File>, IWriter<Test>

Constructor

internal Writer(File fileType, int encoding)

Internal constructor; instances are obtained via File.Exporter.

Properties

public File WriterParent { get; set; }
public TestPlan TestPlan { get; set; }
public string ExtensionPrefix { get; set; }
public bool UseIsoCodeForDiadem200 { get; set; }
public bool UseZeroForUnfiltered { get; set; }
public bool FilteredExport { get; set; }

Methods

public void Write(string pathname, string id, Test test, bool bFiltering,
    bool includeGroupNameInISOExport, double minStartTime, int dataCollectionLength)

Simplified overload that delegates to the full Write method with null parameters.

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)

Writes the test to disk as an RDF file. Creates the directory if needed, normalizes the test ID by removing SUFFIX_RUNTEST or SUFFIX_CHECKOUT suffixes, and writes test info and channel info via BinaryWriter.

public void Initialize(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)

Empty implementation (no-op).

public string GetTestObjectNumber(string isocode, TestPlan plan)

Returns the 1-based index of the test object matching the ISO code's test object character.


3. Invariants

  • Test ID Length: Test IDs are truncated or padded to exactly MAX_TEST_NAME_LENGTH (8 characters) in the output file.
  • File Extension: Output files always use the .001 extension.
  • Channel Ordering: Channels are sorted by AbsoluteDisplayOrder before writing.
  • ADC Centering: ADC values are centered at DTS.Common.Constants.ADC_MIDPOINT (32767) in the binary output.
  • Sample Alignment: All channels are homogenized to share the same time range (max start time to min end time across all channels).
  • Suffix Removal: SUFFIX_RUNTEST and SUFFIX_CHECKOUT are stripped from test IDs before file naming.
  • File Number: The file number field is always written as "1".

4. Dependencies

This Module Depends On:

  • System, System.Globalization, System.IO, System.Linq, System.Text (BCL)
  • DTS.Common.DAS.Concepts (for DataScaler, NonLinearStyles)
  • DTS.Common.Utilities.Logging (for APILogger)
  • DTS.Common.ISO (for TestPlan, IsoCode)
  • DTS.Common.Enums.Sensors (for SensorConstants.BridgeType)
  • DTS.Serialization (base classes Serialization.File, Writer<T>, IWriter<T>, Test, FilteredData)
  • Common.ISO.TestPlan (constructor parameter type)
  • Common.Constants.ADC_MIDPOINT (constant reference)

What Depends On This Module:

  • Not determinable from source alone.

5. Gotchas

  1. Sample Count Discrepancy: Two samples are removed from the end of each channel's data during export. Comments indicate this is to match TDC RDF export behavior, noting "TDC appears to be miscounting by 1 sample" and "DataPRO download appears to download 1 extra sample."

  2. Trigger Sample Hack: There is an acknowledged "hack" in the time range calculation when TotalSamplesRecorded is less than TriggerSampleNumber. The comment states this case was worked around specifically for RDF export without modifying core data structures.

  3. Empty Initialize Method: The Initialize method has no implementation, which may indicate incomplete interface compliance or deprecated functionality.

  4. Slice System Channel Numbering: Channels from Slice systems (identified by serial prefixes "SPS", "SPT", "SPD", "BA", "SLT", "SLS", "SLD") have their channel numbers offset by ParentModule.Number * 3 to convert to DAS order (1-18).

  5. Naturally Inverted Scale Factors: Channels from modules with serial number prefixes "SPS" or "SLS" that are analog and non-linearized have their scale factors and data inverted.

  6. Squib Channel Naming: Squib channels use a decorator suffix ("I" for indication, "C" for current) appended to the channel number in the DAS Channel field.

  7. Digital Input Threshold: Digital input on/off detection uses a simple threshold comparison (eu != 0), with a comment noting this may need refinement based on DigitalMode (CCNO/CCNC/LowToHigh/HighToLow).

  8. Debug Output Files: Methods CreateLinearizedData, CreateLinearizedDataCSV, and CreateDigitizedData create auxiliary files (.lin, .csv, .dig) alongside the main RDF output for debugging non-linear channels.