Пример #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);

            DMPLayer dmpLayer = new DMPLayer(properties);

            return(dmpLayer);
        }
Пример #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();
            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);
        }
Пример #3
0
 public FramingLayer(string sourceName, Int16 universeID, byte sequenceID, byte[] data)
 {
     SourceName = sourceName;
     UniverseID = universeID;
     SequenceID = sequenceID;
     DMPLayer   = new DMPLayer(data);
 }
Пример #4
0
        public byte[] ToArray()
        {
            MemoryStream stream = new MemoryStream(Length);
            BinaryWriter buffer = new BigEndianBinaryWriter(stream);

            Int16 flagsAndFramingLength = (Int16)(SACNPacket.FLAGS | Length);

            buffer.Write(flagsAndFramingLength);
            buffer.Write(FRAMING_VECTOR);
            buffer.Write(Encoding.UTF8.GetBytes(SourceName));
            for (int i = 0; i < 64 - SourceName.Length; i++)
            {
                buffer.Write((byte)0);
            }
            buffer.Write(PRIORITY);
            buffer.Write(RESERVED);
            buffer.Write(SequenceID);
            buffer.Write(OPTIONS);
            buffer.Write(UniverseID);

            buffer.Write(DMPLayer.ToArray());

            return(stream.ToArray());
        }