8.8 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-17T15:37:12.585375+00:00 | zai-org/GLM-5-FP8 | 1 | 1f5b2482ec8c69d4 |
Documentation: DTS.Serialization.IRIGCH10
1. Purpose
This module provides serialization support for the IRIG 106 Chapter 10 (CH10) data format, enabling both parsing of CH10 binary files and writing new CH10 files from test data. It handles packet-level parsing with CRC validation, real-time UDP multicast stream decoding for live data acquisition, and TMATS (Telemetry Attributes Transfer Standard) document generation. The module supports both PCM and Analog data formats for export operations.
2. Public Interface
File (partial class) - Chapter10.File.cs
A partial class extending Serialization.File that provides CH10 file handling capabilities.
public File() // Constructor - initializes base with "Chapter10" type
public IWriter<Test> Exporter { get; } // Lazy-initialized writer instance
CH10AnalogStreamDecode - CH10AnalogStreamDecode.cs
Listens for UDP multicast streams containing CH10 packet data and dispatches parsed packets to registered handlers.
// Properties
public string MulticastReceiveAddress { get; set; } // Default: MulticastCommandBase.DEFAULT_RECEIVE_ADDRESS
public int ResponsePort { get; set; } // Default: (int)MulticastCommandBase.Ports.Response
public IPAddress BindToAdapterIPAddress { get; set; } // Default: IPAddress.Any
// Methods
public void StartListening() // Starts UDP listener on background thread
public void StopListening() // Signals listener to stop
// Delegate types
public delegate void TimePacketDelegate(TimePacketFormat2 packet);
public delegate void AnalogDataPacketDelegate(AnalogDataFormat1Packet packet);
public delegate void TMATSPacketDelegate(TMATSPacket packet);
public delegate void BadCRCDelegate(IPacketHeader packet);
// Event handlers (assign to receive callbacks)
public BadCRCDelegate OnBadCRC;
public TimePacketDelegate OnTimePacket;
public AnalogDataPacketDelegate OnAnalogPacket;
public TMATSPacketDelegate OnTMATSPacket;
Chapter10File - Chapter10File.cs
Parses CH10 binary data and provides access to extracted headers and packets. Also contains static methods for writing CH10 files.
// Constructor - parses all packets from byte array
public Chapter10File(byte[] bytes)
// Accessors for parsed data
public ITransportStreamHeader[] GetTransportHeaders()
public IPacketHeader[] GetPacketHeaders()
public ISecondaryTimeFormatHeader[] GetSecondaryTimeHeaders()
public byte[] GetBytesForPacket(IPacketHeader packet)
// Properties
public int GoodPackets { get; } // Count of successfully parsed packets
public int RejectedPackets { get; } // Count of packets failing validation
// Static methods
public static long ReadChapter10PacketHeader(byte[] bytes, long startIndex, out IPacketHeader packetHeader)
public static long GetIndexOfNextPacket(byte[] bytes, long startIndex)
// Static write methods
public static void WriteFilePCM(string tmats, GetNextSampleDelegate getNextSample,
GetChannelLengthDelegate getChannelLength, int totalChannels, int nanoseconds, int seconds,
double sampleRate, bool includeSecondaryHeader, string fileName,
TickEventHandler tickEventHandler, object tickObject)
public static void WriteFileAnalog(string tmats, GetNextSampleDelegate getNextSample,
GetChannelLengthDelegate getChannelLength, int totalChannels, int nanoseconds, int seconds,
double sampleRate, bool includeSecondaryHeader, string fileName,
TickEventHandler tickEventHandler, object tickObject)
// Delegates for write operations
public delegate short GetNextSampleDelegate(int channelIdx);
public delegate long GetChannelLengthDelegate(int channelIndex);
File.Writer (nested class) - Chapter10.File.Writer.cs
Implements IWriter<Test> for exporting test data to CH10 format.
// Constructor (internal)
internal Writer(File fileType, int encoding)
// Properties
public bool IncludeSecondaryHeader { get; set; } // Default: true
public bool UseAnalogFormat { get; set; } // Default: true
public bool UsePCMFormat { get; set; } // Default: false
public double Start { get; set; }
public double Stop { get; set; }
public bool Filtered { get; set; }
// Constants
public const long BASE_RTC = 141989612500056L;
// Methods
public void Write(string pathname, string id, string dataFolder, Test test,
bool bFiltering, bool includeGroupNameInISOExport, FilteredData fd,
Channel tmChannel, int channelNumber, BeginEventHandler beginEventHandler,
CancelEventHandler cancelEventHandler, EndEventHandler endEventHandler,
TickEventHandler tickEventHandler, ErrorEventHandler errorEventHandler,
CancelRequested cancelRequested, double minStartTime, int dataCollectionLength)
public void Initialize(string pathname, string id, string dataFolder, Test test,
bool bFiltering, bool includeGroupNameInISOExport, FilteredData fd,
Channel tmChannel, int channelNumber, BeginEventHandler beginEventHandler,
CancelEventHandler cancelEventHandler, EndEventHandler endEventHandler,
TickEventHandler tickEventHandler, ErrorEventHandler errorEventHandler,
CancelRequested cancelRequested)
3. Invariants
- Sync Pattern Validation: All valid CH10 packets must have
PacketHeader.EXPECTED_SYNC_PATTERNat their sync pattern field. - Checksum Validation:
packetHeader.CheckSummust equalpacketHeader.ComputeCheckSum()for a packet to be considered valid. - RTC Frequency: Relative Time Counter operates at 10MHz (
RTC_PER_SECOND = 10000000). - Time Packet Boundary:
TimePacketFormat1packets must always start on a second boundary. - Packet Ordering: Transport headers, packet headers, and secondary time headers are stored in the order they are read.
- Thread Safety:
CH10AnalogStreamDecodeuses locks (MyLock,LEFT_OVER_BYTES_LOCK) for thread-safe operations. - Packet Target Size: Write operations target 100ms of data per packet (sample rate divided by 10).
4. Dependencies
This module depends on:
DTS.Common.Utilities.Logging-APILoggerfor loggingDTS.Common.Utils-FileUtils,NetworkUtils,PTP1588TimestampsDTS.Common-Constants.NANOS_PER_SECONDDTS.DASLib.Command.SLICE.MulticastCommands-MulticastCommandBasefor default multicast settingsDTS.Serialization.IRIGCH10.Packets- Packet types (TMATSPacket,AnalogDataFormat1Packet,TimePacketFormat1,TimePacketFormat2,PCMDataPacket, etc.)DTS.Common.DAS.Concepts-Channel,AnalogInputChannelDTS.Common.Enums-IsoViewModeIRIGCh10- External library for CH10 typesSliceRaw.File.Reader-GetDataScalermethod for channel data scaling- File system templates at
TMTTemplates\directory
What depends on this module:
- Cannot be determined from source alone; no downstream consumers are visible in these files.
5. Gotchas
-
NotImplementedException: The
Write(string pathname, string id, Test test, ...)overload inFile.WriterthrowsNotImplementedException. Use the full overload with all parameters instead. -
Arbitrary RTC Base:
BASE_RTC(141989612500056L) is documented as "made up" and arbitrary. The comment states: "we don't really have an RTC, so we make up one with an arbitrary value." -
File Template Dependency: TMATS generation depends on external template files:
TMTTemplates\S6ATMTTemplate_PCM_ExportBase.tmtTMTTemplates\S6ATMTTemplate_PCM_ExportChannel.tmtTMTTemplates\S6ATMTTemplate_ANALOG_ExportBase.tmtTMTTemplates\S6ATMTTemplate_ANALOG_ExportChannel.tmt
These must exist at runtime or TMATS generation will fail.
-
Channel Naming Side Effect:
GetChannelName()depends onIsoViewModeStatic.ViewMode, a static/global state that affects channel naming behavior. -
BinaryReader Cleanup: The
Writemethod opensBinaryReaderinstances per channel. If an exception occurs beforeCloseAndDisposeReadersis called, readers may leak. The method does attempt cleanup in a finally block viaendEventHandlerinvocation, but explicit reader disposal is not guaranteed on all error paths. -
Leftover Bytes Handling:
CH10AnalogStreamDecode.QueueBytes()has a bug - it copies data intonewBytesbut then assignsbytes(the input parameter) to_leftOvertBytesinstead ofnewBytes. This may cause data loss in stream parsing. -
WriteTest.cs is Commented Out: The entire
WriteTestclass is commented out, suggesting it may be obsolete or under development.