Beispiel #1
0
        public static AcnPacket Create(AcnRootLayer rootLayer, Type packetType)
        {
            AcnPacket packet = (AcnPacket)Activator.CreateInstance(packetType);

            packet.Root = rootLayer;
            return(packet);
        }
Beispiel #2
0
            /// <summary>
            /// Creates the specified root layer.
            /// </summary>
            /// <param name="rootLayer">The root layer.</param>
            /// <param name="reader">The reader.</param>
            /// <returns></returns>
            public AcnPacket Create(AcnRootLayer rootLayer, AcnBinaryReader reader)
            {
                AcnPacket packet = (AcnPacket)Activator.CreateInstance(typeof(TPacketType));

                packet.Root = rootLayer;
                packet.ReadData(reader);
                return(packet);
            }
Beispiel #3
0
        public static AcnPacket ReadPacket(AcnRootLayer header, AcnBinaryReader data)
        {
            AcnPacket packet = AcnPacket.Create(header);

            if (packet != null)
            {
                packet.Root = header;
                packet.ReadData(data);
            }

            return(packet);
        }
Beispiel #4
0
        public static AcnPacket Build(AcnRootLayer header)
        {
            Type packetType;

            if (packetStore.TryGetValue(new PacketKey(header.ProtocolId), out packetType))
            {
                AcnPacket packet = (AcnPacket)Activator.CreateInstance(packetType);
                return(packet);
            }

            return(null);
        }
Beispiel #5
0
        public static AcnPacket Build(AcnRootLayer header, AcnBinaryReader data)
        {
            IPacketBuilder packetType;

            if (factory.TryGetBuilder(new PacketKey(header.ProtocolId), out packetType))
            {
                AcnPacket packet = packetType.Create(header, data);
                return(packet);
            }

            return(null);
        }
Beispiel #6
0
 public static void WriteTcpPacket(AcnPacket packet, AcnBinaryWriter data)
 {
     packet.Root.WriteData(data, true);
     packet.WriteData(data);
     packet.Root.WriteLength(data);
 }
Beispiel #7
0
 /// <summary>
 /// Reads a single packet from the data stream and returns the created packet information. This version assumes the header
 /// information has already been read and so starts at the PDU layer.
 /// </summary>
 /// <remarks>
 /// This will create the correct packet class from the registerd packet formats in the packet factory.
 /// </remarks>
 /// <param name="data">The recieved packet data.</param>
 /// <returns>The packet information, cast to the desired packet type.</returns>
 public static AcnPacket ReadPacket(AcnRootLayer header, AcnBinaryReader data)
 {
     return(AcnPacket.Create(header, data));
 }