示例#1
0
        private static ConnectionResponseDataBlock ParseConnectionResponseDataBlock(IEnumerable <byte> bytes)
        {
            var enumerable = bytes as byte[] ?? bytes.ToArray();

            return(new ConnectionResponseDataBlock(enumerable.ElementAt(0), enumerable.ElementAt(1),
                                                   UniCastAddress.FromByteArray(enumerable.Skip(2).ToArray())));
        }
示例#2
0
        public void Usage()
        {
            var bytes = new byte[] { 0x11, 0x64 };

            var uniCastAddress = UniCastAddress.FromByteArray(bytes);

            uniCastAddress.Area.Should().Be(1);
            uniCastAddress.Line.Should().Be(1);
            uniCastAddress.DeviceAddress.Should().Be(0x64);
        }
        public TunnelRequest Build(byte headerLength, byte protocolVersion, ushort totalLength, byte[] responseBytes)
        {
            var structureLength      = responseBytes[0];
            var communicationChannel = responseBytes[1];
            var sequenceCounter      = responseBytes[2];
            var messageCode          = responseBytes[4];
            var addInformationLength = responseBytes[5];
            var controlField         = responseBytes[6];
            var controlField2        = responseBytes[7];
            var npduLength           = responseBytes[12];


            return(new TunnelRequest(headerLength, protocolVersion, totalLength, structureLength, communicationChannel,
                                     sequenceCounter, messageCode, addInformationLength, controlField, controlField2,
                                     UniCastAddress.FromByteArray(new[] { responseBytes[8], responseBytes[9] }),
                                     MultiCastAddress.FromByteArray(new[] { responseBytes[10], responseBytes[11] }), npduLength,
                                     new[] { responseBytes[12], responseBytes[13] }));
        }