This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTS.Serialization.IRIGCH10.Packets
{
public class TransportStreamHeader : ITransportStreamHeader
{
/*• Transport Stream: 4-byte or 32-bit value. (Byteswap to PC format.)
o Bit [3:0] 4-bit Message Format is set to 1.
o Bit [7:4] 4-bit Message Type is set to 0.
o Bit [31:8] 24-bit UDP message sequence number. It is incremented by 1 for each packet sent out in stream including Time data packet, CGPD (TMATS), and Analog data packets.
*/
private byte[] _bytes = new byte[4];
public int MessageFormat { get; }
public int MessageType { get; }
public int SequenceNumber { get; }
public TransportStreamHeader()
{
}
public TransportStreamHeader(byte[] input)
{
if (null == input) { throw new NullReferenceException($"input is null"); }
if (TRANSPORT_HEADER_LENGTH != input.Length) { throw new Exception($"Expected {TRANSPORT_HEADER_LENGTH} bytes, received {input.Length}"); }
Buffer.BlockCopy(input, 0, _bytes, 0, TRANSPORT_HEADER_LENGTH);
var int32 = BitConverter.ToInt32(input, 0);
var bits = new BitArray(BitConverter.GetBytes(int32));
MessageFormat = Utils.Utils.BitArrayToInt32(bits, 0, 3);
MessageType = Utils.Utils.BitArrayToInt32(bits, 4, 7);
SequenceNumber = Utils.Utils.BitArrayToInt32(bits, 8, 31);
_bytes = input;
}
public const int TRANSPORT_HEADER_LENGTH = 4;
}
}