Files
DP44/docs/ai/DataPRO/SLICECommands/RealtimeCommands.md
2026-04-17 14:55:32 -04:00

16 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/SLICECommands/RealtimeCommands/EndRealtimeMode.cs
DataPRO/SLICECommands/RealtimeCommands/UDPStreamPacket.cs
DataPRO/SLICECommands/RealtimeCommands/StartRealtimeMode.cs
DataPRO/SLICECommands/RealtimeCommands/RealtimeCommandBase.cs
DataPRO/SLICECommands/RealtimeCommands/IGetRealtimeSamples.cs
DataPRO/SLICECommands/RealtimeCommands/GetRealtimeSamplesSLICE6.cs
DataPRO/SLICECommands/RealtimeCommands/GetRealtimeSamplesSLICE2.cs
DataPRO/SLICECommands/RealtimeCommands/RetrieveSingleSample.cs
DataPRO/SLICECommands/RealtimeCommands/GetRealtimeSamplesTSRAIR.cs
DataPRO/SLICECommands/RealtimeCommands/RetrieveSampleAverage.cs
DataPRO/SLICECommands/RealtimeCommands/StartRealtimeStreamingMode.cs
DataPRO/SLICECommands/RealtimeCommands/GetRealtimeSamples.cs
DataPRO/SLICECommands/RealtimeCommands/RealtimeStreamDecoder.cs
DataPRO/SLICECommands/RealtimeCommands/UDPRealtimeByteConverter.cs
DataPRO/SLICECommands/RealtimeCommands/StreamReaderUDP.cs
DataPRO/SLICECommands/RealtimeCommands/StreamConfigUDP.cs
2026-04-17T15:47:03.304493+00:00 zai-org/GLM-5-FP8 1 f9034be22d5d24be

Documentation: DTS.DASLib.Command.SLICE.RealtimeCommands

1. Purpose

This module provides the command infrastructure for realtime data acquisition from SLICE data acquisition devices. It handles the complete lifecycle of realtime operations: starting/stopping realtime mode, configuring and reading UDP data streams, retrieving samples (single, averaged, or multi-sample batches), and decoding binary stream packets. The module supports multiple hardware variants (SLICE2, SLICE6, TSRAIR) with device-specific data handling for byte ordering and sign conversion.


2. Public Interface

Interfaces

IGetRealtimeSamples

Interface for objects capable of retrieving realtime samples from SLICE devices.

Member Signature Description
SampleNumber ulong SampleNumber { get; } Returns the sample number for the first sample; subsequent samples are consecutive.
TimeStamp ulong TimeStamp { get; } Returns the timestamp of the samples.
SequenceNumber ulong SequenceNumber { get; } Returns the sequence number.
GetChannelData short[] GetChannelData(int zeroBasedChannel) Returns all samples for the specified channel.
Channels ushort Channels { get; set; } Total channel count for the unit.
SamplesReturned int SamplesReturned { get; } Count of samples per channel returned.
LogCommands bool LogCommands { get; set; } Whether to log commands (default false to avoid spammy logs).
SyncExecute void SyncExecute() Executes the sample retrieval.

Abstract Base Class

RealtimeCommandBase

Abstract base class for all realtime commands. Inherits from CommandBase.

Protected Enum Commands:

Value Name Code
Reserved 0x00
StartRealtimeMode 0x01
EndRealtimeMode 0x02
GetRealtimeSamples 0x03
RetrieveSingleSample 0x04
RetrieveSampleAverage 0x05
RetrieveInternalOffsetSampleAvg 0x06
StartRealtimeStreamingMode 0x07
GetRealtimeStreamSamples 0x08
StartTimeStampStreamMode 0x09
GetTimeStampStreamSamples 0x0A
ChannelTappedTest 0x0B
I106StreamConfigSet 0x0C
I106StreamConfigGet 0x0D

Constructors:

  • protected RealtimeCommandBase(DTS.Common.Interface.DASFactory.ICommunication sock)
  • protected RealtimeCommandBase(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)

Abstract Property:

  • protected abstract Commands _Command { get; } — Derived classes must specify their command code.

Concrete Command Classes

EndRealtimeMode

Command to end realtime mode on a SLICE device.

Constructor Signature
public EndRealtimeMode(DTS.Common.Interface.DASFactory.ICommunication sock)
public EndRealtimeMode(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)

Overrides _Command to return Commands.EndRealtimeMode.


StartRealtimeMode

Command to start realtime mode on a SLICE device.

Constructor Signature
public StartRealtimeMode(DTS.Common.Interface.DASFactory.ICommunication sock)
public StartRealtimeMode(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)
Property Type Description
SupportsMultipleSampleRealtime bool Gets/sets whether multiple-sample realtime is supported. When set, allocates byte[1] or byte[0] for command.Parameter.

Behavior: The presence of command.Parameter (even as a single byte) signals firmware that multiple-sample realtime is supported.


GetRealtimeSamples

Base implementation of IGetRealtimeSamples for retrieving realtime samples.

Constructor Signature
public GetRealtimeSamples(DTS.Common.Interface.DASFactory.ICommunication sock)
public GetRealtimeSamples(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec, bool bPolling = false)
Property Type Description
SampleNumber ulong First sample number; remaining samples are sequential.
TimeStamp ulong Timestamp of samples.
SequenceNumber ulong Sequence number.
Channels ushort Channel count (must be set before execution).
SamplesReturned int Number of samples returned per channel. Can be 0.
Method Signature Description
GetChannelData public short[] GetChannelData(int zeroBasedChannel) Returns sample array for specified channel.

Default timeout: 2000ms.


GetRealtimeSamplesSLICE6

SLICE6-specific implementation of GetRealtimeSamples.

Constructor Signature
public GetRealtimeSamplesSLICE6(DTS.Common.Interface.DASFactory.ICommunication sock)
public GetRealtimeSamplesSLICE6(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)

Data handling: SLICE6 data is signed; byte-swapped but no offset conversion applied.


GetRealtimeSamplesSLICE2

SLICE2-specific implementation of GetRealtimeSamples.

Constructor Signature
public GetRealtimeSamplesSLICE2(DTS.Common.Interface.DASFactory.ICommunication sock)
public GetRealtimeSamplesSLICE2(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)

Data handling: Converts unsigned to signed data with + 0x8000 offset after byte swapping. Sets LogCommands = false by default.


GetRealtimeSamplesTSRAIR

TSRAIR-specific implementation of GetRealtimeSamples.

Constructor Signature
public GetRealtimeSamplesTSRAIR(ICommunication sock)
public GetRealtimeSamplesTSRAIR(ICommunication sock, int TimeoutMillisec)
Property Type Description
Timestamps List<UInt64> List of timestamps (protected _timestamps field).

Data handling: TSRAIR data is unsigned; byte-swapped but no normalization applied.


RetrieveSingleSample

Command to retrieve a single sample from all channels.

Constructor Signature
public RetrieveSingleSample(DTS.Common.Interface.DASFactory.ICommunication sock)
public RetrieveSingleSample(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)
Property Type Description
Channels ushort Number of channels (derived from _data length).
Method Signature Description
GetChannelData public short GetChannelData(int zeroBasedChannel) Returns single sample value for specified channel.

RetrieveSampleAverage

Command to retrieve averaged sample data.

Constructor Signature
public RetrieveSampleAverage(DTS.Common.Interface.DASFactory.ICommunication sock)
public RetrieveSampleAverage(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)
Property Type Description
Samples ushort Number of samples to average (sent as parameter at position 0).
Channels ushort Number of channels returned.
Method Signature Description
GetChannelData public short GetChannelData(int zeroBasedChannel) Returns averaged value for specified channel.

Constants: SAMPLES_POSITION = 0, DATA_POSITION = 2.


StartRealtimeStreamingMode

Command to put firmware into realtime streaming mode for continuous data transmission.

Constructor Signature
public StartRealtimeStreamingMode(DTS.Common.Interface.DASFactory.ICommunication sock, byte[] channelList)
public StartRealtimeStreamingMode(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec, byte[] channelList)
Property Type Description
ChannelList byte[] Channels to collect data on; each channel represented as a byte.

StartTimeStampStreamMode

Command to start IRIG realtime stream with timestamped data.

Constructor Signature
public StartTimeStampStreamMode(DTS.Common.Interface.DASFactory.ICommunication sock)
public StartTimeStampStreamMode(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)
Property Type Description
SupportsMultipleSampleRealtime bool Controls parameter allocation (backing field _bSupportsIrigTimeStampSampleRealtime).
ParamsToSend byte[] Parameters to send with the command.

Behavior: Sets MinimumProtocolVersion using sock.GetMinProto(ProtocolLimitedCommands.UDPRealtimeStream).


StreamConfigUDPGet

Command to retrieve UDP stream configuration (I106 format).

Constructor Signature
public StreamConfigUDPGet(Common.Interface.DASFactory.ICommunication sock)
public StreamConfigUDPGet(Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
Property Type Parameter Position
Stream_Profile_Number byte 0
UdpIpPort byte[] 1-28
TimeChannelID ushort 29
DataChannelID ushort 31
TMNS_PCMSUBFRAMEID uint 33
TMNS_MSGID uint 37
TMNS_PCMINORPERMAJOR uint 41
TMNS_TMATSPORTNUMBER uint 45
IENAUDP_PortNumber uint 49
TMNS5 uint 53
TMNS6 uint 57
TMNS7 uint 61

Constant: COMMAND_PAYLOAD_SIZE = 65.


StreamConfigUDPSet

Command to set UDP stream configuration (I106 format).

Constructor Signature
public StreamConfigUDPSet(Common.Interface.DASFactory.ICommunication sock)
public StreamConfigUDPSet(Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
Property Type Parameter Position
Stream_Profile_Number byte 0
UdpIpPort byte[] 1
Irig106Config0 ushort 29
Irig106Config1 ushort 31
TMNS_PCMSubFrameId uint 33
TMNS_MsgId uint 37
TMNS_PCMMinorPerMajor uint 41
TMNS_TMATSPortNumber uint 45
IENAUDP_PortNumber uint 49
TMNS5 uint 53
TMNS6 uint 57
TMNS7 uint 61

Constant: COMMAND_PAYLOAD_SIZE = 74.


Data/Utility Classes

UDPStreamPacket

Data structure representing a UDP stream packet (ported from FWTU).

Property Type Description
ChannelData short[][] First array = channels, second array = sample index.
TimeStamp long Timestamp value.
SampleNumber ulong Sample number.
SequenceNumber ulong Sequence number.
PTPTimesec uint PTP time seconds component.
PTPTimeNsec uint PTP time nanoseconds component.
PTPSyncStatusError bool PTP sync error flag.
ADCOverflowStatus bool ADC overflow flag.
PTPTimeString string Formatted string: "{sec}:{nsec padded to 9 digits}".

RealtimeStreamDecoder

Decodes SPS realtime stream packets.

Enum ByteIndex:

Value Offset
Sync 0
Type 1
Command 2
Status 3
Group 4
Id 5
DataLength 6
SequenceNumber 8
HeaderCRC 10
DataCRC 12
TimeStamp 14
ChannelList 22
SampleNumber 26
DataStart 34
Constructor Signature
public RealtimeStreamDecoder(IReadOnlyList<byte> bytes)
Property Type Description
SequenceNumber ushort Decoded sequence number.
TimeStamp ulong Decoded timestamp.
SampleNumber ulong Decoded sample number.
Channels int[] Array of active channel indices.
RtData ushort[] Raw data for all channels (not yet converted to signed).

UDPRealtimeByteConverter

Converts UDP realtime byte streams (ported from FWTU).

Enum UDP_BYTE_INDEX:

Value Offset
PKT_PATTERN 0
CHANNEL_ID 2
PKT_LEN 4
DATA_LEN 8
DATA_TYPE_VER 12
SEQ_NUMBER 13
PKT_FLAGS 14
DATA_TYPE 15
REL_TIME32 16
REL_TIME16 20
HDR_CRC16 22
PTP_U32_LSW 24
PTP_U32_MSW 28
RSV_U16 32
HDR2CRC16 34
CSDW 36
DATA_START 40

Enum UDP_DATA_TYPE:

Value Code Description
CGDP_TYPE 0x01 Setup XML record.
TIME_DATA_PTP 0x12 Time data, format 2.
ANALOG_DATA_FORMAT_1 0x21 Analog data format 1.
Constructor Signature
public UDPRealtimeByteConverter(byte[] bytes)
Property Type Description
PacketPattern ushort Packet pattern.
DataChannelID ushort Channel ID.
PacketLength uint Total packet length.
DataLength uint Data length (not same as RtData.Length).
DataTypeVersion byte Data type version.
SequenceNumber byte Sequence number.
PacketFlags byte Packet flags.
DataType byte Data type indicator.
RelativeTime32 uint Relative time (32-bit portion).
RelativeTime16 ushort Relative time (16-bit portion).
HdrCrc16 ushort Header CRC.
PtpTimeStampSec uint PTP timestamp seconds.
PtpTimeStampNsec uint PTP timestamp nanoseconds.
Hdr2Crc16 uint Secondary header CRC.
ChannelMask uint Channel mask.
UdpSampleCount ulong Sample count.
RtData ushort[] Realtime data array (XOR'd with 0x8000).
Channels uint[] Active channels.
SequenceNumberPrev byte Previous sequence number.

StreamReaderUDP

UDP stream reader for receiving realtime data (ported from FWTU).

Constructor Signature
public StreamReaderUDP(string streamAddress, string hostAddress, UDPStreamProfile uDPStreamType, byte[] channels)
Property Type Description
StreamAddress string UDP stream address.
cmdline byte[] Parameters sent to start command.
HostIPAddress string IP of receive endpoint (default IPAddress.Any).
UDPStreamType UDPStreamProfile Stream profile type.
UDPEndpoint EndPoint UDP endpoint.
UDPSampleNumber ulong Sample number counter.
Channels byte[] Channels to receive.
Method Signature Description
CloseSocket public void CloseSocket() Closes the UDP socket.
Read public UDPStreamPacket Read() Receives packets and returns decoded UDPStreamPacket, or null if no data.

Behavior: Supports multicast (IP range 224-239). Sets socket receive timeout to 2000ms. Hardcoded to 6 channels for UDP data parsing.


3. Invariants

  1. Command Type: All realtime commands