Exemplo n.º 1
0
        public void Deserialize()
        {
            var jT808UploadLocationRequest = JT808Serializer.Deserialize <JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes());

            jT808UploadLocationRequest.BasicLocationAttachData.TryGetValue(JT808_SuBiao_Constants.JT808_0X0200_0x64, out var value);
            JT808_0x0200_0x64 jT808_0X0200_0X64 = value as JT808_0x0200_0x64;

            Assert.Equal(1u, jT808_0X0200_0X64.AlarmId);
            Assert.Equal(2, jT808_0X0200_0X64.AlarmIdentification.AttachCount);
            Assert.Equal(3, jT808_0X0200_0X64.AlarmIdentification.SN);
            Assert.Equal("4444444", jT808_0X0200_0X64.AlarmIdentification.TerminalID);
            Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808_0X0200_0X64.AlarmIdentification.Time);
            Assert.Equal(5, jT808_0X0200_0X64.AlarmLevel);
            Assert.Equal(6, jT808_0X0200_0X64.AlarmOrEventType);
            Assert.Equal(Convert.ToDateTime("2019-12-11 18:31:00"), jT808_0X0200_0X64.AlarmTime);
            Assert.Equal(7, jT808_0X0200_0X64.Altitude);
            Assert.Equal(0x64, jT808_0X0200_0X64.AttachInfoId);
            Assert.Equal(32, jT808_0X0200_0X64.AttachInfoLength);
            Assert.Equal(10, jT808_0X0200_0X64.CarOrPedestrianDistanceAhead);
            Assert.Equal(11, jT808_0X0200_0X64.DeviateType);
            Assert.Equal(12, jT808_0X0200_0X64.FlagState);
            Assert.Equal(13, jT808_0X0200_0X64.Latitude);
            Assert.Equal(14, jT808_0X0200_0X64.Longitude);
            Assert.Equal(15, jT808_0X0200_0X64.RoadSignIdentificationData);
            Assert.Equal(16, jT808_0X0200_0X64.RoadSignIdentificationType);
            Assert.Equal(17, jT808_0X0200_0X64.Speed);
            Assert.Equal(18, jT808_0X0200_0X64.VehicleSpeed);
            Assert.Equal(19, jT808_0X0200_0X64.VehicleState);
        }
Exemplo n.º 2
0
        public void Test4()
        {
            byte[]       bytes        = "0000270F00331811200000121811210000120002000003E800000507075BCD15075BCD1438030032007B004517000003E900002EE7075BCD0C075BCD0D4B03003A007C002A1A".ToHexBytes();
            JT808_0x8606 jT808_0X8606 = JT808Serializer.Deserialize <JT808_0x8606>(bytes);

            Assert.Equal((uint)9999, jT808_0X8606.RouteId);
            Assert.Equal((uint)51, jT808_0X8606.RouteProperty);
            Assert.Equal(DateTime.Parse("2018-11-20 00:00:12"), jT808_0X8606.StartTime);
            Assert.Equal(DateTime.Parse("2018-11-21 00:00:12"), jT808_0X8606.EndTime);

            Assert.Equal(2, jT808_0X8606.InflectionPointItems.Count);

            Assert.Equal((uint)1000, jT808_0X8606.InflectionPointItems[0].InflectionPointId);
            Assert.Equal((uint)123456789, jT808_0X8606.InflectionPointItems[0].InflectionPointLat);
            Assert.Equal((uint)123456788, jT808_0X8606.InflectionPointItems[0].InflectionPointLng);

            Assert.Equal((ushort)123, jT808_0X8606.InflectionPointItems[0].SectionDrivingUnderThreshold);
            Assert.Equal((ushort)69, jT808_0X8606.InflectionPointItems[0].SectionHighestSpeed);
            Assert.Equal((uint)1287, jT808_0X8606.InflectionPointItems[0].SectionId);
            Assert.Equal((ushort)50, jT808_0X8606.InflectionPointItems[0].SectionLongDrivingThreshold);
            Assert.Equal((byte)23, jT808_0X8606.InflectionPointItems[0].SectionOverspeedDuration);
            Assert.Equal(3, jT808_0X8606.InflectionPointItems[0].SectionProperty);
            Assert.Equal(56, jT808_0X8606.InflectionPointItems[0].SectionWidth);

            Assert.Equal((uint)1001, jT808_0X8606.InflectionPointItems[1].InflectionPointId);
            Assert.Equal((uint)123456780, jT808_0X8606.InflectionPointItems[1].InflectionPointLat);
            Assert.Equal((uint)123456781, jT808_0X8606.InflectionPointItems[1].InflectionPointLng);
            Assert.Equal((ushort)124, jT808_0X8606.InflectionPointItems[1].SectionDrivingUnderThreshold);
            Assert.Equal((ushort)42, jT808_0X8606.InflectionPointItems[1].SectionHighestSpeed);
            Assert.Equal((uint)12007, jT808_0X8606.InflectionPointItems[1].SectionId);
            Assert.Equal((ushort)58, jT808_0X8606.InflectionPointItems[1].SectionLongDrivingThreshold);
            Assert.Equal((byte)26, jT808_0X8606.InflectionPointItems[1].SectionOverspeedDuration);
            Assert.Equal(3, jT808_0X8606.InflectionPointItems[1].SectionProperty);
            Assert.Equal(75, jT808_0X8606.InflectionPointItems[1].SectionWidth);
        }
Exemplo n.º 3
0
        public void Test2_1()
        {
            byte[]       bytes        = "7E0104001E000123456789000A00140200000001040000000A000000130D7777772E62616964752E636F6DF27E".ToHexBytes();
            JT808Package jT808_0X8104 = JT808Serializer.Deserialize <JT808Package>(bytes);

            Assert.Equal(Enums.JT808MsgId.查询终端参数应答.ToUInt16Value(), jT808_0X8104.Header.MsgId);
            Assert.Equal(10, jT808_0X8104.Header.MsgNum);
            Assert.Equal("123456789", jT808_0X8104.Header.TerminalPhoneNo);

            JT808_0x0104 JT808Bodies = (JT808_0x0104)jT808_0X8104.Bodies;

            Assert.Equal(20, JT808Bodies.MsgNum);
            Assert.Equal(2, JT808Bodies.AnswerParamsCount);
            foreach (var item in JT808Bodies.ParamList)
            {
                switch (item.ParamId)
                {
                case 0x0001:
                    Assert.Equal(0x0001u, ((JT808_0x8103_0x0001)item).ParamId);
                    Assert.Equal(4, ((JT808_0x8103_0x0001)item).ParamLength);
                    Assert.Equal(10u, ((JT808_0x8103_0x0001)item).ParamValue);
                    break;

                case 0x0013:
                    Assert.Equal(0x0013u, ((JT808_0x8103_0x0013)item).ParamId);
                    Assert.Equal("www.baidu.com", ((JT808_0x8103_0x0013)item).ParamValue);
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 4
0
        public void Test2()
        {
            byte[]       bodys             = "34 35 36 31 32".ToHexBytes();
            JT808_0x0102 jT808LoginRequest = JT808Serializer.Deserialize <JT808_0x0102>(bodys);

            Assert.Equal("45612", jT808LoginRequest.Code);
        }
Exemplo n.º 5
0
        public void Test2()
        {
            var jT808_0x9303 = JT808Serializer.Deserialize <JT808_0x9303>("0102".ToHexBytes());

            Assert.Equal(1, jT808_0x9303.LogicChannelNo);
            Assert.Equal(2, jT808_0x9303.IrisAdjustment);
        }
Exemplo n.º 6
0
        public void Test2()
        {
            var          bytes        = "0C".ToHexBytes();
            JT808_0x8500 jT808_0X8500 = JT808Serializer.Deserialize <JT808_0x8500>(bytes);

            Assert.Equal(12, jT808_0X8500.ControlFlag);
        }
Exemplo n.º 7
0
        public void Deserialize()
        {
            var jT808UploadLocationRequest = JT808Serializer.Deserialize <JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106520000000010C060512010203041100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes());

            jT808UploadLocationRequest.BasicLocationAttachData.TryGetValue(JT808_SuBiao_Constants.JT808_0X0200_0x65, out var value);
            JT808_0x0200_0x65 jT808_0X0200_0X65 = value as JT808_0x0200_0x65;

            Assert.Equal(1u, jT808_0X0200_0X65.AlarmId);
            Assert.Equal(2, jT808_0X0200_0X65.AlarmIdentification.AttachCount);
            Assert.Equal(3, jT808_0X0200_0X65.AlarmIdentification.SN);
            Assert.Equal("4444444", jT808_0X0200_0X65.AlarmIdentification.TerminalID);
            Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808_0X0200_0X65.AlarmIdentification.Time);
            Assert.Equal(5, jT808_0X0200_0X65.AlarmLevel);
            Assert.Equal(6, jT808_0X0200_0X65.AlarmOrEventType);
            Assert.Equal(Convert.ToDateTime("2019-12-11 18:31:00"), jT808_0X0200_0X65.AlarmTime);
            Assert.Equal(7, jT808_0X0200_0X65.Altitude);
            Assert.Equal(0x65, jT808_0X0200_0X65.AttachInfoId);
            Assert.Equal(32, jT808_0X0200_0X65.AttachInfoLength);
            Assert.Equal(new byte[] { 1, 2, 3, 4 }.ToHexString(), jT808_0X0200_0X65.Retain.ToHexString());
            Assert.Equal(12, jT808_0X0200_0X65.FlagState);
            Assert.Equal(13, jT808_0X0200_0X65.Latitude);
            Assert.Equal(14, jT808_0X0200_0X65.Longitude);
            Assert.Equal(17, jT808_0X0200_0X65.Speed);
            Assert.Equal(18, jT808_0X0200_0X65.Fatigue);
            Assert.Equal(19, jT808_0X0200_0X65.VehicleState);
        }
Exemplo n.º 8
0
        public void Test2()
        {
            var jT808_0x9207 = JT808Serializer.Deserialize <JT808_0x9207>("000102".ToHexBytes());

            Assert.Equal(1, jT808_0x9207.MgsNum);
            Assert.Equal(2, jT808_0x9207.UploadControl);
        }
Exemplo n.º 9
0
        public void Test2()
        {
            var          bytes        = "191126155850".ToHexBytes();
            JT808_0x8004 jT808_0X8004 = JT808Serializer.Deserialize <JT808_0x8004>(bytes);

            Assert.Equal(DateTime.Parse("2019-11-26 15:58:50"), jT808_0X8004.Time);
        }
Exemplo n.º 10
0
        public void Test2()
        {
            var jT808_0x9302 = JT808Serializer.Deserialize <JT808_0x9302>("0102".ToHexBytes());

            Assert.Equal(1, jT808_0x9302.LogicChannelNo);
            Assert.Equal(2, jT808_0x9302.FocusAdjustmentDirection);
        }
Exemplo n.º 11
0
        public void Test1()
        {
            JT808Package dt1Package = new JT808Package();

            dt1Package.Header = new JT808Header
            {
                MsgId           = 0x91,
                ManualMsgNum    = 126,
                TerminalPhoneNo = "1234567891"
            };
            DT1Demo6 dT1Demo6 = new DT1Demo6();

            dT1Demo6.Age1     = 18;
            dT1Demo6.Sex1     = 2;
            dt1Package.Bodies = dT1Demo6;

            JT808Package dt2Package = new JT808Package();

            dt2Package.Header = new JT808Header
            {
                MsgId           = 0x91,
                ManualMsgNum    = 126,
                TerminalPhoneNo = "1234567892"
            };
            DT2Demo6 dT2Demo6 = new DT2Demo6();

            dT2Demo6.Age2     = 18;
            dT2Demo6.Sex2     = 2;
            dt2Package.Bodies = dT2Demo6;
            byte[] dt1Data = DT1JT808Serializer.Serialize(dt1Package);
            var    dt1Hex  = dt1Data.ToHexString();

            //7E00910003001234567891007D02020012657E
            byte[] dt2Data = DT2JT808Serializer.Serialize(dt2Package);
            var    dt2Hex  = dt2Data.ToHexString();

            //7E00910003001234567892007D02020012667E
            Assert.Equal("7E00910003001234567891007D02020012657E", dt1Hex);
            Assert.Equal("7E00910003001234567892007D02020012667E", dt2Hex);

            JT808Package dt1Package1 = DT1JT808Serializer.Deserialize(dt1Data);

            Assert.Equal(0x91, dt1Package1.Header.MsgId);
            Assert.Equal(126, dt1Package1.Header.MsgNum);
            Assert.Equal("1234567891", dt1Package1.Header.TerminalPhoneNo);
            DT1Demo6 dt1Bodies = (DT1Demo6)dt1Package1.Bodies;

            Assert.Equal((ushort)18, dt1Bodies.Age1);
            Assert.Equal(2, dt1Bodies.Sex1);

            JT808Package dt2Package1 = DT2JT808Serializer.Deserialize(dt2Data);

            Assert.Equal(0x91, dt2Package1.Header.MsgId);
            Assert.Equal(126, dt2Package1.Header.MsgNum);
            Assert.Equal("1234567892", dt2Package1.Header.TerminalPhoneNo);
            DT2Demo6 dt2Bodies = (DT2Demo6)dt2Package1.Bodies;

            Assert.Equal((ushort)18, dt2Bodies.Age2);
            Assert.Equal(2, dt2Bodies.Sex2);
        }
Exemplo n.º 12
0
 public void TestJT808_0x0100_Deserialize()
 {
     for (int i = 0; i < N; i++)
     {
         var result = JT808Serializer.Deserialize(bytes0x0100);
     }
 }
Exemplo n.º 13
0
        public void Test6()
        {
            //7E 02 00 00 3C 04 00 21 68 20 87 1D 0C 00 00 00 00 00 0C 00 C2 01 5B 6C 6E 06 C8 56 98 00 1E 00 00 00 E0 18 09 16 10 35 37 01 04 00 05 4C 7D 01 02 02 00 00 03 02 00 00 25 04 00 00 00 00 2B 04 00 00 00 00 30 01 1D 31 01 0D 97 7E

            byte[] bytes        = "7E 02 00 00 3C 04 00 21 68 20 87 1D 0C 00 00 00 00 00 0C 00 C2 01 5B 6C 6E 06 C8 56 98 00 1E 00 00 00 E0 18 09 16 10 35 37 01 04 00 05 4C 7D 01 02 02 00 00 03 02 00 00 25 04 00 00 00 00 2B 04 00 00 00 00 30 01 1D 31 01 0D 97 7E".ToHexBytes();
            var    jT808Package = JT808Serializer.Deserialize <JT808Package>(bytes);
        }
Exemplo n.º 14
0
        public void Test1_1()
        {
            var          bytes        = "7E8105004B012345678900000101313B544B4E616D653B544B3B544B3132333B7777772E62616964752E636F6D3B383830363B333330363B31323334353B636F64653B322E303B312E303B7777772E544B2E636F6D3B3630227E".ToHexBytes();
            JT808Package jT808Package = JT808Serializer.Deserialize <JT808Package>(bytes);

            Assert.Equal(Enums.JT808MsgId.终端控制.ToUInt16Value(), jT808Package.Header.MsgId);
            Assert.Equal(1, jT808Package.Header.MsgNum);
            Assert.Equal("12345678900", jT808Package.Header.TerminalPhoneNo);

            var JT808_0x8105 = (JT808_0x8105)jT808Package.Bodies;

            Assert.Equal(1, JT808_0x8105.CommandWord);
            Assert.Equal("www.TK.com", JT808_0x8105.CommandValue.URL);
            Assert.Equal(3306, (int)JT808_0x8105.CommandValue.UDPPort);
            Assert.Equal(8806, (int)JT808_0x8105.CommandValue.TCPPort);
            Assert.Equal("www.baidu.com", JT808_0x8105.CommandValue.ServerUrl);
            Assert.Equal("code", JT808_0x8105.CommandValue.MonitoringPlatformAuthenticationCode);
            Assert.Equal(12345, JT808_0x8105.CommandValue.ManufacturerCode);
            Assert.Equal("2.0", JT808_0x8105.CommandValue.HardwareVersion);
            Assert.Equal("1.0", JT808_0x8105.CommandValue.FirmwareVersion);
            Assert.Equal("TK", JT808_0x8105.CommandValue.DialUserName);
            Assert.Equal("TK123", JT808_0x8105.CommandValue.DialPwd);
            Assert.Equal("TKName", JT808_0x8105.CommandValue.DialPointName);
            Assert.Equal(1, (byte)JT808_0x8105.CommandValue.ConnectionControl);
            Assert.Equal(60, (UInt16)JT808_0x8105.CommandValue.ConnectTimeLimit);
        }
Exemplo n.º 15
0
        public void Test2()
        {
            var jT808_0x1206 = JT808Serializer.Deserialize <JT808_0x1206>("000101".ToHexBytes());

            Assert.Equal(1, jT808_0x1206.MsgNum);
            Assert.Equal(1, jT808_0x1206.Result);
        }
Exemplo n.º 16
0
        public void Test_2019_4()
        {
            var bytes = "0100000026000000010000000200BA7F0E07E4F11C0028003C000018071510101001040000006402020037313131313131313131313100000001323232323232323232323200000002333333333333333333333300000003".ToHexBytes();
            JT809_0x1200_0x1202 jT809_0X1200_0X1202 = JT809_2019_Serializer.Deserialize <JT809_0x1200_0x1202>(bytes);

            Assert.Equal(JT809_VehiclePositionEncrypt.已加密, jT809_0X1200_0X1202.GNSSData.Encrypt);
            Assert.Equal("11111111111", jT809_0X1200_0X1202.GNSSData.PlatformId1);
            Assert.Equal(1u, jT809_0X1200_0X1202.GNSSData.Alarm1);
            Assert.Equal("22222222222", jT809_0X1200_0X1202.GNSSData.PlatformId2);
            Assert.Equal(2u, jT809_0X1200_0X1202.GNSSData.Alarm2);
            Assert.Equal("33333333333", jT809_0X1200_0X1202.GNSSData.PlatformId3);
            Assert.Equal(3u, jT809_0X1200_0X1202.GNSSData.Alarm3);

            var jt808_0x0200Hex = jT809_0X1200_0X1202.GNSSData.GnssData;
            var jt808_0x0200    = JT808Serializer_2019.Deserialize <JT808_0x0200>(jt808_0x0200Hex, JT808.Protocol.Enums.JT808Version.JTT2019);

            Assert.Equal((uint)1, jt808_0x0200.AlarmFlag);
            Assert.Equal(DateTime.Parse("2018-07-15 10:10:10"), jt808_0x0200.GPSTime);
            Assert.Equal(12222222, jt808_0x0200.Lat);
            Assert.Equal(132444444, jt808_0x0200.Lng);
            Assert.Equal(60, jt808_0x0200.Speed);
            Assert.Equal((uint)2, jt808_0x0200.StatusFlag);
            Assert.Equal(100, ((JT808_0x0200_0x01)jt808_0x0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
            Assert.Equal(55, ((JT808_0x0200_0x02)jt808_0x0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
        }
Exemplo n.º 17
0
        public void Test2()
        {
            byte[]       bytes        = "7E 07 04 00 53 11 22 33 44 55 66 22 B8 00 02 00 00 26 00 00 00 01 00 00 00 02 00 BA 7F 0E 07 E4 F1 1C 00 28 00 3C 00 00 18 07 15 10 10 10 01 04 00 00 00 64 02 02 00 37 00 26 00 00 00 02 00 00 00 01 00 CB 73 55 07 E6 A3 23 00 29 00 36 00 78 18 07 15 10 10 30 01 04 00 00 00 60 02 02 00 42 D4 7E".ToHexBytes();
            JT808Package jT808Package = JT808Serializer.Deserialize <JT808Package>(bytes);

            Assert.Equal(Enums.JT808MsgId.定位数据批量上传.ToUInt16Value(), jT808Package.Header.MsgId);
            Assert.Equal(8888, jT808Package.Header.MsgNum);
            Assert.Equal("112233445566", jT808Package.Header.TerminalPhoneNo);

            JT808_0x0704 JT808Bodies = (JT808_0x0704)jT808Package.Bodies;

            Assert.Equal(2, JT808Bodies.Count);
            Assert.Equal(JT808_0x0704.BatchLocationType.正常位置批量汇报, JT808Bodies.LocationType);

            Assert.Equal((uint)1, JT808Bodies.Positions[0].AlarmFlag);
            Assert.Equal(DateTime.Parse("2018-07-15 10:10:10"), JT808Bodies.Positions[0].GPSTime);
            Assert.Equal(12222222, JT808Bodies.Positions[0].Lat);
            Assert.Equal(132444444, JT808Bodies.Positions[0].Lng);
            Assert.Equal(0, JT808Bodies.Positions[0].Direction);
            Assert.Equal(60, JT808Bodies.Positions[0].Speed);
            Assert.Equal((uint)2, JT808Bodies.Positions[0].StatusFlag);
            Assert.Equal(100, ((JT808_0x0200_0x01)JT808Bodies.Positions[0].JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
            Assert.Equal(55, ((JT808_0x0200_0x02)JT808Bodies.Positions[0].JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);

            Assert.Equal((uint)2, JT808Bodies.Positions[1].AlarmFlag);
            Assert.Equal(DateTime.Parse("2018-07-15 10:10:30"), JT808Bodies.Positions[1].GPSTime);
            Assert.Equal(13333333, JT808Bodies.Positions[1].Lat);
            Assert.Equal(132555555, JT808Bodies.Positions[1].Lng);
            Assert.Equal(54, JT808Bodies.Positions[1].Speed);
            Assert.Equal(120, JT808Bodies.Positions[1].Direction);
            Assert.Equal((uint)1, JT808Bodies.Positions[1].StatusFlag);
            Assert.Equal(96, ((JT808_0x0200_0x01)JT808Bodies.Positions[1].JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
            Assert.Equal(66, ((JT808_0x0200_0x02)JT808Bodies.Positions[1].JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
        }
Exemplo n.º 18
0
        public void Test2()
        {
            var jT808_0x9306 = JT808Serializer.Deserialize <JT808_0x9306>("0102".ToHexBytes());

            Assert.Equal(1, jT808_0x9306.LogicChannelNo);
            Assert.Equal(2, jT808_0x9306.ChangeMultipleControl);
        }
Exemplo n.º 19
0
Arquivo: Demo2.cs Projeto: rench/JT808
        public void Test1()
        {
            //1.转成byte数组
            byte[] bytes = "7E 02 00 00 26 12 34 56 78 90 12 00 7D 02 00 00 00 01 00 00 00 02 00 BA 7F 0E 07 E4 F1 1C 00 28 00 3C 00 00 18 10 15 10 10 10 01 04 00 00 00 64 02 02 00 7D 01 13 7E".ToHexBytes();

            //2.将数组反序列化
            var jT808Package = JT808Serializer.Deserialize <JT808Package>(bytes);

            //3.数据包头
            Assert.Equal(Enums.JT808MsgId.位置信息汇报.ToValue(), jT808Package.Header.MsgId);
            Assert.Equal(38, jT808Package.Header.MessageBodyProperty.DataLength);
            Assert.Equal(126, jT808Package.Header.MsgNum);
            Assert.Equal("123456789012", jT808Package.Header.TerminalPhoneNo);
            Assert.False(jT808Package.Header.MessageBodyProperty.IsPackge);
            Assert.Equal(0, jT808Package.Header.MessageBodyProperty.PackageIndex);
            Assert.Equal(0, jT808Package.Header.MessageBodyProperty.PackgeCount);
            Assert.Equal(JT808EncryptMethod.None, jT808Package.Header.MessageBodyProperty.Encrypt);

            //4.数据包体
            JT808_0x0200 jT808_0x0200 = (JT808_0x0200)jT808Package.Bodies;

            Assert.Equal((uint)1, jT808_0x0200.AlarmFlag);
            Assert.Equal((uint)40, jT808_0x0200.Altitude);
            Assert.Equal(DateTime.Parse("2018-10-15 10:10:10"), jT808_0x0200.GPSTime);
            Assert.Equal(12222222, jT808_0x0200.Lat);
            Assert.Equal(132444444, jT808_0x0200.Lng);
            Assert.Equal(60, jT808_0x0200.Speed);
            Assert.Equal(0, jT808_0x0200.Direction);
            Assert.Equal((uint)2, jT808_0x0200.StatusFlag);
            //4.1.附加信息1
            Assert.Equal(100, ((JT808_0x0200_0x01)jT808_0x0200.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x01]).Mileage);
            //4.2.附加信息2
            Assert.Equal(125, ((JT808_0x0200_0x02)jT808_0x0200.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil);
        }
Exemplo n.º 20
0
 protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List <object> output)
 {
     byte[] buffer = new byte[input.Capacity + 2];
     try
     {
         input.ReadBytes(buffer, 1, input.Capacity);
         buffer[0] = JT808Package.BeginFlag;
         buffer[input.Capacity + 1] = JT808Package.EndFlag;
         JT808Package jT808Package = JT808Serializer.Deserialize <JT808Package>(buffer);
         MsgSuccessCounter.Increment();
         output.Add(jT808Package);
         if (logger.IsEnabled(LogLevel.Debug))
         {
             logger.LogDebug("accept package success count<<<" + MsgSuccessCounter.Count.ToString());
         }
     }
     catch (JT808.Protocol.Exceptions.JT808Exception ex)
     {
         MsgFailCounter.Increment();
         if (logger.IsEnabled(LogLevel.Error))
         {
             logger.LogError("accept package fail count<<<" + MsgFailCounter.Count.ToString());
             logger.LogError(ex, "accept msg<<<" + buffer);
         }
     }
     catch (Exception ex)
     {
         MsgFailCounter.Increment();
         if (logger.IsEnabled(LogLevel.Error))
         {
             logger.LogError("accept package fail count<<<" + MsgFailCounter.Count.ToString());
             logger.LogError(ex, "accept msg<<<" + buffer);
         }
     }
 }
Exemplo n.º 21
0
        public void Test2()
        {
            var jT808_0x9305 = JT808Serializer.Deserialize <JT808_0x9305>("0102".ToHexBytes());

            Assert.Equal(1, jT808_0x9305.LogicChannelNo);
            Assert.Equal(2, jT808_0x9305.StartOrStop);
        }
Exemplo n.º 22
0
        public void Test1_1()
        {
            byte[]       bytes        = "7B".ToHexBytes();
            JT808_0x0301 jT808_0X8104 = JT808Serializer.Deserialize <JT808_0x0301>(bytes);

            Assert.Equal(123, jT808_0X8104.EventId);
        }
Exemplo n.º 23
0
        public void Test2()
        {
            var jT808_0x1205 = JT808Serializer.Deserialize <JT808_0x1205>("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F".ToHexBytes());

            Assert.Equal(1, jT808_0x1205.MsgNum);
            Assert.Equal(2u, jT808_0x1205.AVResouceTotal);

            Assert.Equal(1u, jT808_0x1205.AVResouces[0].AlarmFlag);
            Assert.Equal(2, jT808_0x1205.AVResouces[0].AVResourceType);
            Assert.Equal(Convert.ToDateTime("2019-07-16 10:20:01"), jT808_0x1205.AVResouces[0].BeginTime);
            Assert.Equal(Convert.ToDateTime("2019-07-16 10:25:01"), jT808_0x1205.AVResouces[0].EndTime);
            Assert.Equal(3u, jT808_0x1205.AVResouces[0].FileSize);
            Assert.Equal(4, jT808_0x1205.AVResouces[0].LogicChannelNo);
            Assert.Equal(5, jT808_0x1205.AVResouces[0].MemoryType);
            Assert.Equal(6, jT808_0x1205.AVResouces[0].StreamType);

            Assert.Equal(11u, jT808_0x1205.AVResouces[1].AlarmFlag);
            Assert.Equal(21, jT808_0x1205.AVResouces[1].AVResourceType);
            Assert.Equal(Convert.ToDateTime("2019-07-16 11:20:01"), jT808_0x1205.AVResouces[1].BeginTime);
            Assert.Equal(Convert.ToDateTime("2019-07-16 11:25:02"), jT808_0x1205.AVResouces[1].EndTime);
            Assert.Equal(31u, jT808_0x1205.AVResouces[1].FileSize);
            Assert.Equal(41, jT808_0x1205.AVResouces[1].LogicChannelNo);
            Assert.Equal(51, jT808_0x1205.AVResouces[1].MemoryType);
            Assert.Equal(61, jT808_0x1205.AVResouces[1].StreamType);
        }
Exemplo n.º 24
0
        public void Test2_1()
        {
            byte[]       bytes        = "0200000001040000000A000000130D7777772E62616964752E636F6D".ToHexBytes();
            JT808_0x8103 jT808_0X8103 = JT808Serializer.Deserialize <JT808_0x8103>(bytes);

            foreach (var item in jT808_0X8103.ParamList)
            {
                switch (item.ParamId)
                {
                case 0x0001:
                    Assert.Equal(0x0001u, ((JT808_0x8103_0x0001)item).ParamId);
                    Assert.Equal(4, ((JT808_0x8103_0x0001)item).ParamLength);
                    Assert.Equal(10u, ((JT808_0x8103_0x0001)item).ParamValue);
                    break;

                case 0x0013:
                    Assert.Equal(0x0013u, ((JT808_0x8103_0x0013)item).ParamId);
                    Assert.Equal("www.baidu.com", ((JT808_0x8103_0x0013)item).ParamValue);
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 25
0
 public void TestJT808_0x02001()
 {
     for (int i = 0; i < N; i++)
     {
         var result = JT808Serializer.Deserialize <JT808Package>(bytes);
     }
 }
Exemplo n.º 26
0
        public void Test2()
        {
            var jT808_0x9105 = JT808Serializer.Deserialize <JT808_0x9105>("0102".ToHexBytes());

            Assert.Equal(1, jT808_0x9105.ChannelNo);
            Assert.Equal(2, jT808_0x9105.DropRate);
        }
Exemplo n.º 27
0
Arquivo: Demo4.cs Projeto: ymd1223/J8
 protected override void Execute(Dictionary <byte, byte[]> jT808CustomLocationAttachOriginalData)
 {
     JT808CustomLocationAttachData = new Dictionary <byte, JT808_0x0200_CustomBodyBase>();
     foreach (var item in jT808CustomLocationAttachOriginalData)
     {
         try
         {
             switch (item.Key)
             {
             case dt2_0x81:
                 var info81 = JT808Serializer.Deserialize <JT808_0x0200_DT2_0x81>(item.Value);
                 if (info81 != null)
                 {
                     IExtDataProcessor extDataProcessor = new JT808_0x0200_DT2_0x81_ExtDataProcessor(info81);
                     extDataProcessor.Processor(ExtData);
                     JT808CustomLocationAttachData.Add(dt2_0x81, info81);
                 }
                 break;
             }
         }
         catch (Exception)
         {
         }
     }
 }
Exemplo n.º 28
0
        public void Deserialize()
        {
            var jT808UploadLocationRequest = JT808Serializer.Deserialize <JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010663B000000010C1100070000000D0000000E191211183100001334343434343434191210183100030200020400010003000500020900060008000A0007".ToHexBytes());

            jT808UploadLocationRequest.BasicLocationAttachData.TryGetValue(JT808_SuBiao_Constants.JT808_0X0200_0x66, out var value);
            JT808_0x0200_0x66 jT808_0X0200_0X66 = value as JT808_0x0200_0x66;

            Assert.Equal(1u, jT808_0X0200_0X66.AlarmId);
            Assert.Equal(2, jT808_0X0200_0X66.AlarmIdentification.AttachCount);
            Assert.Equal(3, jT808_0X0200_0X66.AlarmIdentification.SN);
            Assert.Equal("4444444", jT808_0X0200_0X66.AlarmIdentification.TerminalID);
            Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808_0X0200_0X66.AlarmIdentification.Time);
            Assert.Equal(Convert.ToDateTime("2019-12-11 18:31:00"), jT808_0X0200_0X66.AlarmTime);
            Assert.Equal(7, jT808_0X0200_0X66.Altitude);
            Assert.Equal(2, jT808_0X0200_0X66.AlarmOrEventCount);
            Assert.Equal(1, jT808_0X0200_0X66.AlarmOrEvents[0].AlarmOrEventType);
            Assert.Equal(2, jT808_0X0200_0X66.AlarmOrEvents[0].BatteryLevel);
            Assert.Equal(3, jT808_0X0200_0X66.AlarmOrEvents[0].TirePressure);
            Assert.Equal(4, jT808_0X0200_0X66.AlarmOrEvents[0].TirePressureAlarmPosition);
            Assert.Equal(5, jT808_0X0200_0X66.AlarmOrEvents[0].TireTemperature);
            Assert.Equal(6, jT808_0X0200_0X66.AlarmOrEvents[1].AlarmOrEventType);
            Assert.Equal(7, jT808_0X0200_0X66.AlarmOrEvents[1].BatteryLevel);
            Assert.Equal(8, jT808_0X0200_0X66.AlarmOrEvents[1].TirePressure);
            Assert.Equal(9, jT808_0X0200_0X66.AlarmOrEvents[1].TirePressureAlarmPosition);
            Assert.Equal(10, jT808_0X0200_0X66.AlarmOrEvents[1].TireTemperature);
            Assert.Equal(0x66, jT808_0X0200_0X66.AttachInfoId);
            Assert.Equal(12, jT808_0X0200_0X66.FlagState);
            Assert.Equal(13, jT808_0X0200_0X66.Latitude);
            Assert.Equal(14, jT808_0X0200_0X66.Longitude);
            Assert.Equal(17, jT808_0X0200_0X66.Speed);
            Assert.Equal(19, jT808_0X0200_0X66.VehicleState);
        }
Exemplo n.º 29
0
        public void Test_0xF7_2()
        {
            var jT808_0x0900_0xF7 = JT808Serializer.Deserialize <JT808_0x0900_0xF7>("020105020000000102050200000001".ToHexBytes());

            Assert.Equal(JT808_JTActiveSafety_Constants.JT808_0X0900_0xF7, jT808_0x0900_0xF7.PassthroughType);
            Assert.Equal(2, jT808_0x0900_0xF7.USBMessageCount);
            Assert.Equal(1, jT808_0x0900_0xF7.USBMessages[0].USBID);
            Assert.Equal(5, jT808_0x0900_0xF7.USBMessages[0].MessageLength);
            Assert.Equal(2, jT808_0x0900_0xF7.USBMessages[0].WorkingCondition);
            Assert.Equal(1u, jT808_0x0900_0xF7.USBMessages[0].AlarmStatus);

            Assert.Equal(2, jT808_0x0900_0xF7.USBMessages[1].USBID);
            Assert.Equal(5, jT808_0x0900_0xF7.USBMessages[1].MessageLength);
            Assert.Equal(2, jT808_0x0900_0xF7.USBMessages[1].WorkingCondition);
            Assert.Equal(1u, jT808_0x0900_0xF7.USBMessages[1].AlarmStatus);
        }
Exemplo n.º 30
0
        public void Test2()
        {
            byte[]       bytes        = "0000001F1F8B080000000000000B2BCE4DCCC949CEC82CA6320D0027F897E258000000".ToHexBytes();
            JT808_0x0901 jT808_0X8600 = JT808Serializer.Deserialize <JT808_0x0901>(bytes);

            Assert.Equal((uint)88, jT808_0X8600.UnCompressMessageLength);
            Assert.Equal(Encoding.UTF8.GetBytes(UserName), jT808_0X8600.UnCompressMessage);
        }