Ejemplo n.º 1
0
 public SynchronizationPacket()
 {
     RootLayer = new RootLayer
     {
         Vector = RootLayerVector.VECTOR_ROOT_E131_EXTENDED
     };
     FramingLayer = new SynchronizationPacketFramingLayer();
 }
Ejemplo n.º 2
0
        public void Given_TheDataIsCorrect_When_ParseIsCalled_Then_TheDataIsParsedAsExpected()
        {
            UInt16 synchronizationAddress = 1028;
            byte   sequenceNumber         = 67;
            var    bytes = GetSynchronizationPacketFramingLayer(sequenceNumber, synchronizationAddress);

            var framingLayer = SynchronizationPacketFramingLayer.Parse(bytes.ToArray());

            Assert.Equal(FramingLayerVector.VECTOR_E131_EXTENDED_SYNCHRONIZATION, framingLayer.Vector);
            Assert.Equal(sequenceNumber, framingLayer.SequenceNumber);
            Assert.Equal(synchronizationAddress, framingLayer.SynchronizationAddress);
        }
Ejemplo n.º 3
0
        public void When_WriteIsCalled_Then_TheDataIsCorrect()
        {
            UInt16 syncAddress    = 1023;
            byte   sequenceNumber = 135;

            var framingLayer = new SynchronizationPacketFramingLayer()
            {
                SynchronizationAddress = syncAddress,
                SequenceNumber         = sequenceNumber
            };

            var expectedBytes = GetSynchronizationPacketFramingLayer(sequenceNumber, syncAddress);

            using var owner = MemoryPool <byte> .Shared.Rent(SynchronizationPacketFramingLayer.Length);

            var actualBytes = owner.Memory.Span.Slice(0, SynchronizationPacketFramingLayer.Length);

            framingLayer.Write(actualBytes);
            Assert.Equal(expectedBytes.ToArray(), actualBytes.ToArray());
        }
Ejemplo n.º 4
0
        public static Span <byte> GetSynchronizationPacket(byte[] CID, byte sequenceNumber)
        {
            var rootLayer = new RootLayer
            {
                CID    = CID,
                Vector = RootLayerVector.VECTOR_ROOT_E131_EXTENDED
            };

            var framingLayer = new SynchronizationPacketFramingLayer
            {
                SequenceNumber = sequenceNumber
            };

            int totalLength = SynchronizationPacketFramingLayer.Length + RootLayer.Length;

            using var owner = MemoryPool <byte> .Shared.Rent(totalLength);

            var bytes = owner.Memory.Span.Slice(0, totalLength);

            rootLayer.Write(bytes, (UInt16)(SynchronizationPacketFramingLayer.Length));
            framingLayer.Write(bytes.Slice(RootLayer.Length));

            return(bytes);
        }
Ejemplo n.º 5
0
        public static SynchronizationPacket Parse(ReadOnlySpan <byte> bytes, RootLayer rootLayer, SynchronizationPacketFramingLayer framingLayer)
        {
            SynchronizationPacket packet = new SynchronizationPacket
            {
                RootLayer    = rootLayer,
                FramingLayer = framingLayer
            };

            return(packet);
        }