예제 #1
0
        public static void WritePacket(RdmPacket packet, RdmBinaryWriter data, bool onlyContent)
        {
            if (!onlyContent)
            {
                packet.WriteHeader(data);
            }

            packet.WriteData(data);

            if (!onlyContent)
            {
                packet.Header.WriteLength(data);
            }
        }
예제 #2
0
        public void WriteData(RdmBinaryWriter data)
        {
            //Save position so we can write length later.
            messageLengthPosition = data.BaseStream.Position;

            data.Write(MessageLength);
            data.Write(DestinationId);
            data.Write(SourceId);
            data.Write(TransactionNumber);
            data.Write(PortOrResponseType);
            data.Write(MessageCount);
            data.WriteNetwork(SubDevice);
            data.Write((byte)Command);
            data.WriteNetwork((short)ParameterId);

            //Save position so we can write length later.
            dataLengthPosition = data.BaseStream.Position;
            data.Write(ParameterDataLength);
        }
예제 #3
0
        public void WriteLength(RdmBinaryWriter data)
        {
            if (messageLengthPosition < 0 || dataLengthPosition <= 0)
            {
                throw new InvalidOperationException("Packet data has not been written yet. You can not write the length until the body is written.");
            }

            MessageLength       = (byte)(data.BaseStream.Position - messageLengthPosition + 2);
            ParameterDataLength = (byte)((data.BaseStream.Position - 1) - dataLengthPosition);

            //Write Message Length
            data.BaseStream.Seek(messageLengthPosition, System.IO.SeekOrigin.Begin);
            data.Write(MessageLength);

            //Write Parameter Data Length
            data.BaseStream.Seek(dataLengthPosition, System.IO.SeekOrigin.Begin);
            data.Write(ParameterDataLength);

            //Move back to end of stream.
            data.BaseStream.Seek(0, System.IO.SeekOrigin.End);
        }
예제 #4
0
 protected abstract void WriteData(RdmBinaryWriter data);
예제 #5
0
 protected void WriteHeader(RdmBinaryWriter data)
 {
     Header.WriteData(data);
 }
예제 #6
0
 public static void WritePacket(RdmPacket packet, RdmBinaryWriter data)
 {
     WritePacket(packet, data, false);
 }