This module implements serialization and deserialization for IRIG CH10 (Chapter 10) data files, which are standardized binary formats for recording test and measurement data. It provides functionality to read existing CH10 files (parsing headers, packets, and transport stream metadata), write new CH10 files in either analog or PCM format, and decode real-time UDP multicast streams containing CH10 packets. The module serves as the core data I/O layer for handling IRIG CH10-compliant test data within the DTS system.
-
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)
Writes a Test object to a CH10 file at pathname. Reads raw sample data from files associated with channels in test, computes TMATS metadata (analog or PCM format based on UseAnalogFormat/UsePCMFormat), and calls Chapter10File.WriteFileAnalog or Chapter10File.WriteFilePCM. Handles file I/O errors, progress reporting via tickEventHandler, and cleanup of file readers.
-
public void Initialize(...)
Stub method with no implementation (empty body). No behavior defined.
-
public void StartListening()
Starts a background Task that listens for UDP multicast packets on MulticastReceiveAddress (default 239.1.1.1) at ResponsePort (default 5017). Binds to BindToAdapterIPAddress (default IPAddress.Any). Joins the multicast group and begins parsing incoming bytes.
-
public void StopListening()
Signals the listening thread to stop via _stopListening.Set().
-
public delegate void TimePacketDelegate(TimePacketFormat2 packet);
Delegate for handling received time packets.
-
public delegate void AnalogDataPacketDelegate(AnalogDataFormat1Packet packet);
Delegate for handling received analog data packets.
-
public delegate void TMATSPacketDelegate(TMATSPacket packet);
Delegate for handling received TMATS packets.
-
public delegate void BadCRCDelegate(IPacketHeader packet);
Delegate for handling packets with invalid CRC.
-
public TimePacketDelegate OnTimePacket { get; set; }
Callback invoked when a valid TimePacketFormat2 is parsed.
-
public AnalogDataPacketDelegate OnAnalogPacket { get; set; }
Callback invoked when a valid AnalogDataFormat1Packet is parsed.
-
public TMATSPacketDelegate OnTMATSPacket { get; set; }
Callback invoked when a valid TMATSPacket is parsed.
-
public BadCRCDelegate OnBadCRC { get; set; }
Callback invoked when a packet header has an incorrect CRC.
-
public Chapter10File(byte[] bytes)
Constructor that parses all CH10 packets and transport headers from a byte array. Populates internal lists for transport headers, packet headers, secondary time headers, and tracks byte ranges for each packet. Sets GoodPackets and RejectedPackets counts.
-
public ITransportStreamHeader[] GetTransportHeaders()
Returns all parsed transport stream headers in order.
-
public IPacketHeader[] GetPacketHeaders()
Returns all parsed packet headers in order.
-
public ISecondaryTimeFormatHeader[] GetSecondaryTimeHeaders()
Returns all parsed secondary time format headers in order.
-
public byte[] GetBytesForPacket(IPacketHeader packet)
Returns a copy of the full packet bytes (header + payload) for a given packet. Returns null if packet was not parsed from this instance.
-
public int GoodPackets { get; }
Number of successfully parsed packets.
-
public int RejectedPackets { get; }
Number of packets rejected (invalid sync pattern or CRC).
-
public static long GetIndexOfNextPacket(byte[] bytes, long startIndex)
Scans bytes starting at startIndex for the next valid packet sync pattern (PacketHeader.EXPECTED_SYNC_PATTERN). Returns index of next sync, or bytes.Length if none found.
-
public static long ReadChapter10PacketHeader(byte[] bytes, long startIndex, out IPacketHeader packetHeader)
Reads a packet header from bytes at startIndex. Returns the index of the end of the packet (i.e., startIndex + packetHeader.PacketLength). Populates packetHeader.
-
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)
Writes a PCM-format CH10 file. Writes a TMATS packet first, then interleaves time packets (Format 1 or 2 depending on includeSecondaryHeader) and PCM data packets. Uses getNextSample to read samples and getChannelLength to determine total samples per channel.
-
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)
Writes an analog-format CH10 file. Behavior identical to WriteFilePCM but produces AnalogDataFormat1Packet packets.
-
public delegate short GetNextSampleDelegate(int channelIdx);
Delegate to retrieve the next ADC sample for a given channel index.
-
public delegate long GetChannelLengthDelegate(int channelIndex);
Delegate to retrieve the total number of samples for a given channel.