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

            packet.Root = rootLayer;
            return(packet);
        }
Exemplo n.º 2
0
        public static AcnPacket ReadTcpPacket(AcnBinaryReader data)
        {
            AcnRootLayer rootLayer = new AcnRootLayer();

            rootLayer.ReadData(data, true);

            return(ReadPacket(rootLayer, data));;
        }
Exemplo n.º 3
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);
            }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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)
        {
            long startPosition = reader.BaseStream.Position;

            PduHeader pduHeader = new PduHeader();

            pduHeader.ReadPdu(reader);

            IPacketBuilder builder;

            if (TryGetBuilder(new PacketKey(pduHeader.Vector), out builder))
            {
                reader.BaseStream.Seek(startPosition, System.IO.SeekOrigin.Begin);
                return(builder.Create(rootLayer, reader));
            }

            return(null);
        }
Exemplo n.º 8
0
 public static AcnPacket Create(AcnRootLayer header)
 {
     return(AcnPacketFactory.Build(header));
 }
Exemplo n.º 9
0
 public AcnPacket(int protocolId)
 {
     Root            = new AcnRootLayer();
     Root.ProtocolId = protocolId;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates an ACN packet from the header information and the recieved data.
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="data">The data.</param>
 /// <returns>The created ACN packet, may be cast to the correct packet type.</returns>
 public static AcnPacket Create(AcnRootLayer header, AcnBinaryReader data)
 {
     return(AcnPacketFactory.Build(header, data));
 }
Exemplo n.º 11
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));
 }