Esempio n. 1
0
        internal static DMPLayer Parse(BigEndianBinaryReader buffer)
        {
            Int16 flagsAndDMPLength = buffer.ReadInt16();
            byte  vector3           = buffer.ReadByte();

            Debug.Assert(vector3 == DMP_VECTOR);
            byte addressTypeAndDataType = buffer.ReadByte();

            Debug.Assert(addressTypeAndDataType == ADDRESS_TYPE_AND_DATA_TYPE);
            Int16 firstPropertyAddress = buffer.ReadInt16();

            Debug.Assert(firstPropertyAddress == FIRST_PROPERTY_ADDRESS);
            Int16 addressIncrement = buffer.ReadInt16();

            Debug.Assert(addressIncrement == ADDRESS_INCREMENT);
            Int16 propertyValueCount = buffer.ReadInt16();

            byte startCode = buffer.ReadByte();

            byte[] properties = buffer.ReadBytes(propertyValueCount - 1);

            var dmpLayer = new DMPLayer(properties);

            return(dmpLayer);
        }
Esempio n. 2
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();

            Debug.Assert(reserved == RESERVED);
            byte   sequenceID = buffer.ReadByte();
            byte   options    = buffer.ReadByte();
            UInt16 universeID = buffer.ReadUInt16();

            FramingLayer framingLayer = new FramingLayer()
            {
                SourceName = sourceName,
                Priority   = priority,
                SequenceID = sequenceID,
                Options    = FramingOptions.Parse(options),
                UniverseID = universeID,
                DMPLayer   = DMPLayer.Parse(buffer)
            };

            return(framingLayer);
        }
Esempio n. 3
0
 public FramingLayer(string sourceName, UInt16 universeID, byte sequenceID, byte[] data, byte priority)
 {
     SourceName = sourceName;
     UniverseID = universeID;
     SequenceID = sequenceID;
     Options    = new FramingOptions();
     DMPLayer   = new DMPLayer(data);
     Priority   = priority;
 }
Esempio n. 4
0
        public byte[] ToArray()
        {
            using (var stream = new MemoryStream(Length))
                using (var buffer = new BigEndianBinaryWriter(stream))
                {
                    UInt16 flagsAndFramingLength = (UInt16)(SACNPacket.FLAGS | Length);
                    buffer.Write(flagsAndFramingLength);
                    buffer.Write(FRAMING_VECTOR);
                    buffer.Write(Encoding.UTF8.GetBytes(SourceName));
                    buffer.Write(Enumerable.Repeat((byte)0, 64 - SourceName.Length).ToArray());
                    buffer.Write(Priority);
                    buffer.Write(RESERVED);
                    buffer.Write(SequenceID);
                    buffer.Write(Options.GetByte());
                    buffer.Write(UniverseID);

                    buffer.Write(DMPLayer.ToArray());

                    return(stream.ToArray());
                }
        }