Exemplo n.º 1
0
        internal static FramingLayer Parse(BigEndianBinaryReader buffer)
        {
            UInt16 flagsAndFramingLength = (UInt16)buffer.ReadInt16();
            UInt16 flags = (UInt16)(flagsAndFramingLength & SACNPacket.FIRST_FOUR_BITS_MASK);

            Debug.Assert(flags == SACNPacket.FLAGS);
            UInt16 length = (UInt16)(flagsAndFramingLength & SACNPacket.LAST_TWELVE_BITS_MASK);

            Int32 vector2 = buffer.ReadInt32();

            Debug.Assert(vector2 == FRAMING_VECTOR);
            byte[] sourceNameBytes = buffer.ReadBytes(64);
            string sourceName      = new string(Encoding.UTF8.GetChars(sourceNameBytes)).TrimEnd('\0');
            byte   priority        = buffer.ReadByte();
            Int16  reserved        = buffer.ReadInt16();
            byte   sequenceID      = buffer.ReadByte();
            byte   options         = buffer.ReadByte();
            Int16  universeID      = buffer.ReadInt16();

            FramingLayer framingLayer = new FramingLayer();

            framingLayer.SequenceID = sequenceID;
            framingLayer.SourceName = sourceName;
            framingLayer.DMPLayer   = DMPLayer.Parse(buffer);

            return(framingLayer);
        }
Exemplo n.º 2
0
        internal static RootLayer Parse(BigEndianBinaryReader buffer)
        {
            RootLayer rootLayer = new RootLayer();

            Int16 preambleLength = buffer.ReadInt16();

            Debug.Assert(preambleLength == PREAMBLE_LENGTH);
            Int16 postambleLength = buffer.ReadInt16();

            Debug.Assert(postambleLength == POSTAMBLE_LENGTH);
            byte[] packetIdentifier = buffer.ReadBytes(12);
            Debug.Assert(packetIdentifier.SequenceEqual(PACKET_IDENTIFIER));
            UInt16 flagsAndRootLength = (UInt16)buffer.ReadInt16();
            UInt16 flags = (UInt16)(flagsAndRootLength & SACNPacket.FIRST_FOUR_BITS_MASK);

            Debug.Assert(flags == SACNPacket.FLAGS);
            UInt16 length = (UInt16)(flagsAndRootLength & SACNPacket.LAST_TWELVE_BITS_MASK);
            Int32  vector = buffer.ReadInt32();

            Debug.Assert(vector == ROOT_VECTOR);
            Guid cid = new Guid(buffer.ReadBytes(16));

            rootLayer.UUID         = cid;
            rootLayer.FramingLayer = FramingLayer.Parse(buffer);

            return(rootLayer);
        }
Exemplo n.º 3
0
        public byte[] ToArray()
        {
            MemoryStream stream = new MemoryStream(Length);
            BinaryWriter buffer = new BigEndianBinaryWriter(stream);

            buffer.Write(PREAMBLE_LENGTH);
            buffer.Write(POSTAMBLE_LENGTH);
            buffer.Write(PACKET_IDENTIFIER);
            Int16 flagsAndRootLength = (Int16)(SACNPacket.FLAGS | Length);

            buffer.Write(flagsAndRootLength);
            buffer.Write(ROOT_VECTOR);
            buffer.Write(UUID.ToByteArray());

            buffer.Write(FramingLayer.ToArray());
            return(stream.ToArray());
        }
Exemplo n.º 4
0
 public RootLayer(Guid uuid, string sourceName, Int16 universeID, byte sequenceID, byte[] data)
 {
     FramingLayer = new FramingLayer(sourceName, universeID, sequenceID, data);
 }