11 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T03:40:00.442802+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | abee1ca96445ca58 |
RDF.File Module Documentation
1. Purpose
This module implements serialization and deserialization logic for Toyota RDF (Rack Data Format) files—a proprietary binary file format used to export test data from DTS systems for Toyota compliance. It defines the File class (a concrete implementation of Serialization.File) that represents an RDF file and its associated metadata, and the nested Writer class responsible for writing test data (Test) to disk in the RDF format. The module supports filtering, linearization, and ISO-compliant naming conventions, and is tightly coupled with ISO test plan metadata and DAS hardware configuration.
2. Public Interface
DTS.Serialization.RDF.File
-
Constructor
public File(Common.ISO.TestPlan plan)
Initializes a newFileinstance with the providedTestPlan. Callsbase("RDF")to set the format name. -
Properties
public static string Extension => ".001"
Returns the fixed file extension for RDF files.public bool UseZeroForUnfiltered { get; set; } = false
Controls whether unfiltered data points are written as zero (instead of original ADC values) during export.public bool FilteredExport { get; set; } = false
Enables filtering of data during export (behavior depends on downstreamWriterlogic).public IWriter<Test> Exporter { get; }
Lazily constructs and returns aWriterinstance, passingUseZeroForUnfiltered,FilteredExport, and_testPlanto it. SetsWriter.WriterParent = thisto enable access to EU data.
-
EU Data Accessors (override)
public override void SetEUData(string channelID, FilteredData fd)
Stores filtered EU data for a channel in the internal_EUUnfilteredDataForLinearizedChannelsdictionary.public override FilteredData GetEUData(string channelID)
Retrieves stored EU data for a givenchannelID.
DTS.Serialization.RDF.File.Writer
-
Constructor
internal Writer(File fileType, int encoding)
Internal constructor; initializes baseWriter<File>with the parentFileand encoding. -
Properties
public File WriterParent { get; set; }
Reference to the parentFileinstance (used to access EU data).public TestPlan TestPlan { get; set; }
ISOTestPlanused for metadata (e.g., test object numbering).public string ExtensionPrefix { get; set; } = string.Empty
Optional prefix appended to the filename before the.001extension.public bool UseZeroForUnfiltered { get; set; }
Mirrors the parentFile.UseZeroForUnfiltered.public bool FilteredExport { get; set; }
Mirrors the parentFile.FilteredExport.public bool UseIsoCodeForDiadem200 { get; set; }
Unused in current implementation (commented out in usage).
-
Methods
-
public void Write(string pathname, string id, Test test, bool bFiltering, bool includeGroupNameInISOExport, double minStartTime, int dataCollectionLength)
Convenience overload ofWrite(...)with simplified parameters; delegates to the full 18-parameter overload withnullfor optional event handlers and data folder. -
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)
Primary export method.- Validates/normalizes
id: strips" RunTest"or" Checkout"suffixes if present; falls back totest.Idifidlacks these suffixes. - Truncates
idtoMAX_TEST_NAME_LENGTH(8 chars) implicitly via filename construction. - Writes RDF file to
{pathname}/{id}.001. - Calls
WriteTestInfo(...)andWriteChannelInfo(...)to serialize headers and data. - Handles exceptions via event handlers or rethrows.
- Validates/normalizes
-
public void Initialize(...)
Empty stub; no-op. -
protected void WriteTestInfo(BinaryWriter fileWriter, Test test, string testId, TickEventHandler tickEventHandler, string dataFolder)
Writes an 80-byte header record containing:testId(padded/truncated to 8 chars)- Number of files (hardcoded to
"1") - File number (
" 1") - Number of channels (
test.Channels.Count, left-padded to 3 chars) - Timestamp (MM, DD, YY, HH, MM)
- 53 bytes of padding.
-
protected void WriteChannelInfo(BinaryWriter fileWriter, Test test, string testId, TickEventHandler tickEventHandler, string dataFolder, CancelRequested cancelRequested, string pathName, TestPlan testPlan)
Writes per-channel headers and ADC data.- Sorts channels by
AbsoluteDisplayOrder, then byToString(). - Computes homogenized time range (
dMaxStarttodMinEnd) across all channels to align samples. - For each channel:
- Writes channel metadata (5-char channel number, DAS channel ID, subchannel, scaling samples, pre-trigger samples, sample rate, zero level, calibration points, resolution, rack/module serials).
- Conditionally writes
.linor.digfiles for non-linear/digital channels. - Writes 16-bit ADC data (centered at 32767) for all samples in the homogenized range, excluding the last 2 samples (to match TDC RDF behavior).
- Special handling for:
- Squib channels (
I/Csuffixes). - Slice modules (channel numbering adjusted).
- Digital inputs (on/off thresholding).
- Non-linear channels (scaled via
nonLinearScaleFactor). - Naturally inverted scales (e.g., SPS/SLS modules without linearization).
- Squib channels (
- Sorts channels by
-
private double[] GetEUData(Test.Module.Channel channel)
Retrieves EU data forchannelviaWriterParent.GetEUData(channel.ChannelId).Data. -
private static string GetRackSerialNumber(string serialNumber, string baseSerialNumber)
Returns last 4 chars ofserialNumberorbaseSerialNumber, left-padded to 5 chars;"EMPTY"if null/whitespace. -
private static bool IsSlice(string sn)
Returnstrueifsnstarts with"SPS","SPT","SPD","BA","SLT","SLS", or"SLD". -
private bool HasNaturallyInvertedScaleFactor(Test.Module.Channel channel)
Returnstruefor SPS/SLS analog channels without a valid linearization formula and not digital. -
private static int DisplayOrderComparer(object x, object y)
Compares twoTest.Module.Channelinstances byAbsoluteDisplayOrder, then byToString(). -
public string GetTestObjectNumber(string isocode, TestPlan plan)
Returns 1-based index of theTestObjectinplan.ISOTestObjectsmatching theTestObjectcharacter fromisocode.
-
-
Private Helper Methods (non-public)
CreateLinearizedData(...): Writes.linfiles with EU data (ASCII CSV).CreateDigitizedData(...): Writes.digfiles with EU data (ASCII CSV).CreateLinearizedDataCSV(...): Writes.csvfiles for debugging (ADC, mV, EU columns).Create3DIRTraccDataCSV(...): Commented out; legacy debugging utility.
3. Invariants
-
Filename constraints
- RDF files must end with
.001. - Test name (
id) is truncated to exactly 8 characters (viaPadRight/SubstringinWriteTestInfo). idmust contain" RunTest"or" Checkout"suffix to be accepted; otherwise,test.Idis used (per FB8419/36769).
- RDF files must end with
-
Data alignment
- All channels are exported with a common time range (
dMaxStarttodMinEnd), ensuring identical sample counts per channel. - The last 2 samples are always omitted from the final binary output (to match TDC behavior), regardless of
dataCollectionLength.
- All channels are exported with a common time range (
-
Channel ordering
- Channels are sorted by
AbsoluteDisplayOrderbefore serialization.
- Channels are sorted by
-
ADC centering
- All ADC values are written as 16-bit unsigned integers centered at
DTS.Common.Constants.ADC_MIDPOINT(32767).
- All ADC values are written as 16-bit unsigned integers centered at
-
Calibration points
- Cal point 1 is always
+0.000E+000. - Cal point 2 is
MidpointDeflection(70% ofADC_MIDPOINT) scaled to EU, with special handling for digital inputs, squibs, and non-linear channels.
- Cal point 1 is always
4. Dependencies
Dependencies of this module:
DTS.Common.ISO.TestPlan(for test metadata, ISO code parsing, test object numbering).DTS.Common.DAS.Concepts.DataScaler(for scaling ADC → mV → EU).DTS.Common.Enums.Sensors.SensorConstants(forBridgeTypeconstants likeDigitalInput,IEPE).DTS.Common.Utilities.Logging.APILogger(for exception logging).DTS.Serialization.Test,Test.Module.Channel,FilteredData,IWriter<Test>(serialization contracts).System.IO,System.Text,System.Globalization(standard .NET I/O and formatting).
Dependencies on this module:
- Any code requiring RDF export (e.g., test export workflows, ISO compliance tools).
- Likely consumed via
File.Exporterto serializeTestinstances.
5. Gotchas
-
Sample count discrepancy:
The last 2 samples are always omitted from the binary output (hardcoded in loops:iPt <= endSample - 2). This is intentional to match TDC RDF exports, but may cause off-by-two discrepancies with raw data downloads. -
Test name normalization:
idis only accepted if it ends with" RunTest"or" Checkout"; otherwise,test.Idis used. This may cause unexpected filename changes ifidis not properly suffixed. -
Channel numbering quirks:
- Slice modules require manual channel offset (
+ module.Number * 3). - Squib channels use
I/Csuffixes (current/indication) and require even/odd channel number adjustment.
- Slice modules require manual channel offset (
-
Naturally inverted scales:
For SPS/SLS modules without linearization, the ADC data is inverted (dataPoint *= -1) andZeroMvInADCis negated if non-zero. This is non-obvious and may cause misalignment if not handled consistently. -
Digital input handling:
Digital channels use a threshold-based on/off conversion (5 EU per ADC step), but the logic does not inspectDigitalMode(e.g.,CCNO,HighToLow)—it assumes a simple threshold. This may misrepresent edge-triggered inputs. -
EU data dependency:
GetEUDatarelies on_EUUnfilteredDataForLinearizedChannelsbeing pre-populated viaSetEUData. If not,KeyNotFoundExceptionmay occur. -
Unused properties:
UseIsoCodeForDiadem200andExtensionPrefixare defined but not meaningfully used in the current implementation. -
Legacy debugging code:
Create3DIRTraccDataCSVis commented out but retained in source—do not assume active functionality. -
Error handling:
Exceptions during export are logged viaAPILoggerand rethrown (or dispatched viaerrorEventHandler). This dual behavior may cause duplicate logging if handlers are registered.