Exemplo n.º 1
0
        public void Test1()
        {
            JT808Package jT808Package = new JT808Package
            {
                Header = new JT808Header
                {
                    MsgId           = Enums.JT808MsgId.查询终端参数应答.ToUInt16Value(),
                    MsgNum          = 10,
                    TerminalPhoneNo = "123456789",
                },
                Bodies = new JT808_0x0104
                {
                    MsgNum            = 20,
                    AnswerParamsCount = 1,
                    ParamList         = new List <JT808_0x8103_BodyBase> {
                        new JT808_0x8103_0x0001()
                        {
                            ParamId     = 0x0001,
                            ParamLength = 4,
                            ParamValue  = 10
                        }
                    }
                }
            };
            var hex = JT808Serializer.Serialize(jT808Package).ToHexString();

            Assert.Equal("7E0104000C000123456789000A00140100000001040000000A907E", hex);
        }
Exemplo n.º 2
0
        public void Test1()
        {
            JT808Package jT808Package = new JT808Package
            {
                Header = new JT808Header
                {
                    MsgId           = Enums.JT808MsgId.终端注册应答.ToUInt16Value(),
                    MsgNum          = 10,
                    TerminalPhoneNo = "012345678900",
                },
                Bodies = new JT808_0x8100
                {
                    Code = "123456",
                    JT808TerminalRegisterResult = Enums.JT808TerminalRegisterResult.成功,
                    MsgNum = 100
                }
            };
            //"7E
            //81 00
            //00 09
            //01 23 45 67 89 00
            //00 0A
            //00 64
            //00
            //31 32 33 34 35 36
            //68
            //7E"
            var hex = JT808Serializer.Serialize(jT808Package).ToHexString();

            Assert.Equal("7E81000009012345678900000A006400313233343536687E", hex);
        }
Exemplo n.º 3
0
        public void Test1()
        {
            JT808Package jT808_0X0100 = new JT808Package
            {
                Header = new JT808Header
                {
                    MsgId           = Enums.JT808MsgId.终端注册.ToUInt16Value(),
                    ManualMsgNum    = 10,
                    TerminalPhoneNo = "123456789",
                },
                Bodies = new JT808_0x0100
                {
                    AreaID         = 40,
                    CityOrCountyId = 50,
                    MakerId        = "1234",
                    PlateColor     = 1,
                    PlateNo        = "粤A12345",
                    TerminalId     = "CHI123",
                    TerminalModel  = "smallchi123"
                }
            };
            var hex = JT808Serializer.Serialize(jT808_0X0100).ToHexString();

            Assert.Equal("7E0100002D000123456789000A002800323132333430736D616C6C6368693132333030303030303030304348493132333001D4C1413132333435BA7E", hex);
        }
Exemplo n.º 4
0
        public void Test1()
        {
            JT808_0x8606 jT808_0X8606 = new JT808_0x8606
            {
                RouteId              = 9999,
                RouteProperty        = 1268,
                StartTime            = DateTime.Parse("2018-11-20 00:00:12"),
                EndTime              = DateTime.Parse("2018-11-21 00:00:12"),
                InflectionPointItems = new List <JT808InflectionPointProperty>()
            };

            jT808_0X8606.InflectionPointItems.Add(new JT808InflectionPointProperty()
            {
                InflectionPointId            = 1000,
                InflectionPointLat           = 123456789,
                InflectionPointLng           = 123456788,
                SectionDrivingUnderThreshold = 123,
                SectionHighestSpeed          = 69,
                SectionId = 1287,
                SectionLongDrivingThreshold = 50,
                SectionOverspeedDuration    = 23,
                SectionProperty             = 89,
                SectionWidth = 56
            });
            jT808_0X8606.InflectionPointItems.Add(new JT808InflectionPointProperty()
            {
                InflectionPointId            = 1001,
                InflectionPointLat           = 123456780,
                InflectionPointLng           = 123456781,
                SectionDrivingUnderThreshold = 124,
                SectionHighestSpeed          = 42,
                SectionId = 12007,
                SectionLongDrivingThreshold = 58,
                SectionOverspeedDuration    = 26,
                SectionProperty             = 50,
                SectionWidth = 75
            });
            var hex = JT808Serializer.Serialize(jT808_0X8606).ToHexString();

            //00 00 27 0F
            //04 F4
            //00 02
            //00 00 03 E8
            //00 00 05 07
            //07 5B CD 15
            //07 5B CD 14
            //38
            //59    //‭0101 1001‬
            //00 32
            //00 7B
            //00 00 03 E9
            //00 00 2E E7
            //07 5B CD 0C
            //07 5B CD 0D
            //4B
            //32    //‭‭0011 0010‬
            //00 2A
            //1A
            Assert.Equal("0000270F04F40002000003E800000507075BCD15075BCD1438590032007B000003E900002EE7075BCD0C075BCD0D4B32002A1A", hex);
        }
Exemplo n.º 5
0
        public void Test1()
        {
            JT808Package jT808Package = new JT808Package
            {
                Header = new JT808Header
                {
                    MsgId           = Enums.JT808MsgId.终端控制.ToUInt16Value(),
                    ManualMsgNum    = 1,
                    TerminalPhoneNo = "12345678900",
                },
                Bodies = new JT808_0x8105
                {
                    CommandWord  = 1,
                    CommandValue = new CommandParams
                    {
                        ConnectionControl = 1,
                        DialPointName     = "TKName",
                        DialUserName      = "******",
                        DialPwd           = "TK123",
                        FirmwareVersion   = "1.0",
                        HardwareVersion   = "2.0",
                        ConnectTimeLimit  = 60,
                        MakerId           = "12345",
                        MonitoringPlatformAuthenticationCode = "code",
                        ServerUrl = "www.baidu.com",
                        TCPPort   = 8806,
                        UDPPort   = 3306,
                        URL       = "www.TK.com"
                    }
                }
            };
            var hex = JT808Serializer.Serialize(jT808Package).ToHexString();

            Assert.Equal("7E8105004B012345678900000101313B544B4E616D653B544B3B544B3132333B7777772E62616964752E636F6D3B383830363B333330363B31323334353B636F64653B322E303B312E303B7777772E544B2E636F6D3B3630227E", hex);
        }
Exemplo n.º 6
0
        public void Test1()
        {
            JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200
            {
                AlarmFlag  = 1,
                Altitude   = 40,
                GPSTime    = DateTime.Parse("2018-07-15 10:10:10"),
                Lat        = 12222222,
                Lng        = 132444444,
                Speed      = 60,
                Direction  = 0,
                StatusFlag = 2,
                JT808LocationAttachData = new Dictionary <byte, JT808_0x0200_BodyBase>()
            };

            jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01
            {
                Mileage = 100
            });
            jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02
            {
                Oil = 55
            });
            var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString();

            Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C000018071510101001040000006402020037", hex);
        }
Exemplo n.º 7
0
Arquivo: Demo6.cs Projeto: ymd1223/J8
        public void Test1()
        {
            JT808Package dt1Package = new JT808Package();

            dt1Package.Header = new JT808Header
            {
                MsgId           = 0x91,
                MsgNum          = 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,
                MsgNum          = 126,
                TerminalPhoneNo = "1234567892"
            };
            DT2Demo6 dT2Demo6 = new DT2Demo6();

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

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

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

            JT808Package dt1Package1 = JT808Serializer.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 = JT808Serializer.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.º 8
0
        public void Test1()
        {
            JT808_0x0801 jT808_0X0801 = new JT808_0x0801
            {
                ChannelId              = 123,
                EventItemCoding        = JT808EventItemCoding.定时动作.ToByteValue(),
                MultimediaCodingFormat = JT808MultimediaCodingFormat.JPEG.ToByteValue(),
                MultimediaId           = 2567,
                MultimediaType         = JT808MultimediaType.图像.ToByteValue(),
                MultimediaDataPackage  = new byte[] { 0x01, 0x02, 0x03, 0x04 },
                Position = new JT808_0x0200
                {
                    AlarmFlag  = 1,
                    Altitude   = 40,
                    GPSTime    = DateTime.Parse("2018-11-15 23:26:10"),
                    Lat        = 12222222,
                    Lng        = 132444444,
                    Speed      = 60,
                    Direction  = 0,
                    StatusFlag = 2
                }
            };
            string hex = JT808Serializer.Serialize(jT808_0X0801).ToHexString();

            Assert.Equal("00000A070000017B000000010000000200BA7F0E07E4F11C0028003C000018111523261001020304", hex);
        }
Exemplo n.º 9
0
        public void Test1()
        {
            JT808_0x0102 jT808LoginRequestProperty = new JT808_0x0102
            {
                Code = "45612"
            };
            string hex = JT808Serializer.Serialize(jT808LoginRequestProperty).ToHexString();

            Assert.Equal("3435363132", hex);
        }
Exemplo n.º 10
0
        public void Test1()
        {
            JT808_0x8500 jT808_0X8500 = new JT808_0x8500
            {
                ControlFlag = 12
            };
            var hex = JT808Serializer.Serialize(jT808_0X8500).ToHexString();

            Assert.Equal("0C", hex);
        }
Exemplo n.º 11
0
        public void Test1()
        {
            JT808_0x0702 jT808_0X0702 = new JT808_0x0702
            {
                IC_Card_Status       = JT808ICCardStatus.从业资格证IC卡拔出_驾驶员下班,
                IC_Card_PlugDateTime = DateTime.Parse("2018-08-16 09:16:16")
            };
            var hex = JT808Serializer.Serialize(jT808_0X0702).ToHexString();

            Assert.Equal("02 18 08 16 09 16 16".Replace(" ", ""), hex);
        }
Exemplo n.º 12
0
        public void Test1()
        {
            JT808_0x9102 jT808_0X9102 = new JT808_0x9102();

            jT808_0X9102.ChannelNo   = 1;
            jT808_0X9102.ControlCmd  = 1;
            jT808_0X9102.CloseAVData = 0;
            jT808_0X9102.StreamType  = 0;
            var hex = JT808Serializer.Serialize(jT808_0X9102).ToHexString();

            Assert.Equal("01010000", hex);
        }
Exemplo n.º 13
0
        public void Test_Serilize_0x00()
        {
            JT808_0x8700 value = new JT808_0x8700();

            value.CommandId = 0x00;
            value.JT808CarDVRDownPackage = new JT808CarDVRDownPackage {
                CommandId = 0x00,
                Bodies    = new JT808_CarDVR_Down_0x00()
            };
            var hex = JT808Serializer.Serialize(value).ToHexString();

            Assert.Equal("00557A000000002F", hex);
        }
Exemplo n.º 14
0
        public void Test1()
        {
            JT808_0x0608 value = new JT808_0x0608
            {
                QueryType = 5,
                Ids       = new List <uint>()
                {
                    1, 2, 3
                }
            };
            var hex = JT808Serializer.Serialize(value).ToHexString();

            Assert.Equal("0500000003000000010000000200000003", hex);
        }
Exemplo n.º 15
0
        public void Test1()
        {
            JT808_0x9101 jT808_0X9101 = new JT808_0x9101();

            jT808_0X9101.ServerIPAddress           = "127.0.0.1";
            jT808_0X9101.ServerVideoChannelTcpPort = 1888;
            jT808_0X9101.ServerVideoChannelUdpPort = 0;
            jT808_0X9101.LogicalChannelNo          = 1;
            jT808_0X9101.DataType   = 1;
            jT808_0X9101.StreamType = 1;
            var hex = JT808Serializer.Serialize(jT808_0X9101).ToHexString();

            Assert.Equal("093132372E302E302E3107600000010101", hex);
        }
Exemplo n.º 16
0
        public void Test1()
        {
            JT808_0x0802 jT808_0X0802 = new JT808_0x0802
            {
                MsgNum = 12369,
                MultimediaSearchItems = new List <JT808MultimediaSearchProperty>()
            };

            jT808_0X0802.MultimediaSearchItems.Add(new JT808MultimediaSearchProperty()
            {
                ChannelId       = 123,
                EventItemCoding = JT808EventItemCoding.定时动作.ToByteValue(),
                MultimediaId    = 258,
                MultimediaType  = JT808MultimediaType.图像.ToByteValue(),
                Position        = new JT808_0x0200()
                {
                    AlarmFlag  = 1,
                    Altitude   = 40,
                    GPSTime    = DateTime.Parse("2018-11-16 20:20:20"),
                    Lat        = 12222222,
                    Lng        = 132444444,
                    Speed      = 60,
                    Direction  = 0,
                    StatusFlag = 2,
                }
            });

            jT808_0X0802.MultimediaSearchItems.Add(new JT808MultimediaSearchProperty()
            {
                ChannelId       = 124,
                EventItemCoding = JT808EventItemCoding.平台下发指令.ToByteValue(),
                MultimediaId    = 259,
                MultimediaType  = JT808MultimediaType.视频.ToByteValue(),
                Position        = new JT808_0x0200()
                {
                    AlarmFlag  = 1,
                    Altitude   = 40,
                    GPSTime    = DateTime.Parse("2018-11-16 22:22:22"),
                    Lat        = 12222222,
                    Lng        = 132444444,
                    Speed      = 60,
                    Direction  = 0,
                    StatusFlag = 2,
                }
            });

            string hex = JT808Serializer.Serialize(jT808_0X0802).ToHexString();

            Assert.Equal("3051000200000102007B01000000010000000200BA7F0E07E4F11C0028003C000018111620202000000103027C00000000010000000200BA7F0E07E4F11C0028003C0000181116222222", hex);
        }
Exemplo n.º 17
0
        public void Test1()
        {
            JT808_0x8600 jT808_0X8600 = new JT808_0x8600
            {
                SettingAreaProperty = JT808SettingProperty.追加区域.ToByteValue(),
                AreaItems           = new List <JT808CircleAreaProperty>()
            };

            jT808_0X8600.AreaItems.Add(new JT808CircleAreaProperty
            {
                AreaId            = 1522,
                AreaProperty      = 222,
                CenterPointLat    = 123456789,
                CenterPointLng    = 123456789,
                Radius            = 200,
                StartTime         = DateTime.Parse("2018-10-18 00:00:12"),
                EndTime           = DateTime.Parse("2018-10-19 00:00:12"),
                HighestSpeed      = 60,
                OverspeedDuration = 200
            });
            jT808_0X8600.AreaItems.Add(new JT808CircleAreaProperty
            {
                AreaId            = 1523,
                AreaProperty      = 0,
                CenterPointLat    = 123456789,
                CenterPointLng    = 123456789,
                Radius            = 200,
                StartTime         = DateTime.Parse("2018-10-18 00:00:12"),
                EndTime           = DateTime.Parse("2018-10-19 00:00:12"),
                HighestSpeed      = 60,
                OverspeedDuration = 200
            });
            jT808_0X8600.AreaItems.Add(new JT808CircleAreaProperty
            {
                AreaId            = 1524,
                AreaProperty      = 2211,
                CenterPointLat    = 123456789,
                CenterPointLng    = 123456789,
                Radius            = 200,
                StartTime         = DateTime.Parse("2018-10-18 00:00:12"),
                EndTime           = DateTime.Parse("2018-10-19 00:00:12"),
                HighestSpeed      = 60,
                OverspeedDuration = 200
            });
            var hex = JT808Serializer.Serialize(jT808_0X8600).ToHexString();

            //"01 03 00 00 05 F2 00 DE 07 5B CD 15 07 5B CD 15 00 00 00 C8 00 3C C8 00 00 05 F3 00 00 07 5B CD 15 07 5B CD 15 00 00 00 C8 00 00 05 F4 08 A3 07 5B CD 15 07 5B CD 15 00 00 00 C8 18 10 18 00 00 12 18 10 19 00 00 12 00 3C C8"
            Assert.Equal("0103000005F200DE075BCD15075BCD15000000C8003CC8000005F30000075BCD15075BCD15000000C8000005F408A3075BCD15075BCD15000000C8181018000012181019000012003CC8", hex);
        }
Exemplo n.º 18
0
        public void Test1()
        {
            JT808Package jT808Package = new JT808Package
            {
                Header = new JT808Header
                {
                    MsgId           = Enums.JT808MsgId.查询终端参数.ToUInt16Value(),
                    ManualMsgNum    = 1,
                    TerminalPhoneNo = "12345678900",
                }
            };
            var hex = JT808Serializer.Serialize(jT808Package).ToHexString();

            Assert.Equal("7E8104000001234567890000010D7E", hex);
        }
Exemplo n.º 19
0
        public void Test1()
        {
            JT808Header jT808HeaderProperty = new JT808Header
            {
                TerminalPhoneNo = "13812345678"
            };

            jT808HeaderProperty.MessageBodyProperty = new JT808HeaderMessageBodyProperty(5);
            jT808HeaderProperty.MsgNum = 135;
            jT808HeaderProperty.MsgId  = JT808MsgId.终端鉴权.ToUInt16Value();

            var hex = JT808Serializer.Serialize(jT808HeaderProperty).ToHexString();

            Assert.Equal("01 02 00 05 01 38 12 34 56 78 00 87".Replace(" ", ""), hex);
        }
Exemplo n.º 20
0
        public void Test2()
        {
            JT808Package jT808Package = new JT808Package
            {
                Header = new JT808Header
                {
                    MsgId           = Enums.JT808MsgId.查询终端参数应答.ToUInt16Value(),
                    MsgNum          = 10,
                    TerminalPhoneNo = "123456789",
                },
                Bodies = new JT808_0x0104
                {
                    MsgNum            = 20,
                    AnswerParamsCount = 2,
                    ParamList         = new List <JT808_0x8103_BodyBase> {
                        new JT808_0x8103_0x0001()
                        {
                            ParamId     = 0x0001,
                            ParamLength = 4,
                            ParamValue  = 10
                        },
                        new JT808_0x8103_0x0013()
                        {
                            ParamId    = 0x0013,
                            ParamValue = "www.baidu.com"
                        }
                    }
                }
            };
            var hex = JT808Serializer.Serialize(jT808Package).ToHexString();

            Assert.Equal("7E0104001E000123456789000A00140200000001040000000A000000130D7777772E62616964752E636F6DF27E", hex);
        }
        public void Serializer()
        {
            JT808_JTActiveSafety_0x0900 jT808UploadLocationRequest = new JT808_JTActiveSafety_0x0900
            {
                USBMessageCount = 2,
                USBMessages     = new List <JT808_JTActiveSafety_0x0900_USBMessage> {
                    new JT808_JTActiveSafety_0x0900_USBMessage {
                        USBID = 1,
                        MessageContentObejct = new JT808_JTActiveSafety_0x0900_USB_0xF7 {
                            AlarmStatus      = 1,
                            WorkingCondition = 2
                        }
                    },
                    new JT808_JTActiveSafety_0x0900_USBMessage {
                        USBID = 2,
                        MessageContentObejct = new JT808_JTActiveSafety_0x0900_USB_0xF8 {
                            CompantName           = "CompantName",
                            CustomerCode          = "CustomerCode",
                            DevicesID             = "DevicesID",
                            HardwareVersionNumber = "HardwareVersionNumber",
                            ProductModel          = "ProductModel",
                            SoftwareVersionNumber = "SoftwareVersionNumber"
                        }
                    }
                }
            };
            var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString();

            Assert.Equal("0201050200000001025C0B436F6D70616E744E616D650C50726F647563744D6F64656C15486172647761726556657273696F6E4E756D62657215536F66747761726556657273696F6E4E756D626572094465766963657349440C437573746F6D6572436F6465", hex);
        }
Exemplo n.º 22
0
        public void Test1()
        {
            JT808_0x8604 jT808_0X8604 = new JT808_0x8604();

            jT808_0X8604.AreaId            = 1234;
            jT808_0X8604.AreaProperty      = JT808SettingProperty.追加区域.ToByteValue();
            jT808_0X8604.StartTime         = DateTime.Parse("2018-11-20 00:00:12");
            jT808_0X8604.EndTime           = DateTime.Parse("2018-11-21 00:00:12");
            jT808_0X8604.HighestSpeed      = 62;
            jT808_0X8604.OverspeedDuration = 218;
            jT808_0X8604.PeakItems         = new List <JT808Properties.JT808PeakProperty>();
            jT808_0X8604.PeakItems.Add(new JT808Properties.JT808PeakProperty
            {
                Lat = 123456789,
                Lng = 123456788
            });
            jT808_0X8604.PeakItems.Add(new JT808Properties.JT808PeakProperty
            {
                Lat = 123456700,
                Lng = 123456701
            });
            var hex = JT808Serializer.Serialize(jT808_0X8604).ToHexString();

            Assert.Equal("000004D200011811200000121811210000120002075BCD15075BCD14075BCCBC075BCCBD", hex);
        }
Exemplo n.º 23
0
        public JT808SessionServiceTest()
        {
            SimpleTcpClient1 = new JT808SimpleTcpClient(endPoint);
            SimpleTcpClient2 = new JT808SimpleTcpClient(endPoint);
            SimpleTcpClient3 = new JT808SimpleTcpClient(endPoint);
            SimpleTcpClient4 = new JT808SimpleTcpClient(endPoint);
            SimpleTcpClient5 = new JT808SimpleTcpClient(endPoint);
            // 心跳会话包
            JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001");

            SimpleTcpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1));

            // 心跳会话包
            JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002");

            SimpleTcpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2));

            // 心跳会话包
            JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003");

            SimpleTcpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3));

            // 心跳会话包
            JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004");

            SimpleTcpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4));

            // 心跳会话包
            JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005");

            SimpleTcpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5));
            Thread.Sleep(1000);
        }
Exemplo n.º 24
0
        public void Test5_1()
        {
            JT808Package jT808Package = new JT808Package();

            jT808Package.Header = new JT808Header
            {
                MsgId           = Enums.JT808MsgId.位置信息汇报.ToUInt16Value(),
                MsgNum          = 8888,
                TerminalPhoneNo = "112233445566",
                //MessageBodyProperty=new JT808MessageBodyProperty(38),
            };
            JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200
            {
                AlarmFlag  = 1,
                Altitude   = 40,
                GPSTime    = DateTime.Parse("2018-07-15 10:10:10"),
                Lat        = 12222222,
                Lng        = 132444444,
                Speed      = 60,
                Direction  = 0,
                StatusFlag = 2,
                JT808LocationAttachData = new Dictionary <byte, JT808_0x0200_BodyBase>()
            };

            jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01
            {
                Mileage = 100
            });
            jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02
            {
                Oil = 55
            });
            jT808Package.Bodies = jT808UploadLocationRequest;
            var hex = JT808Serializer.Serialize(jT808Package).ToHexString();
        }
Exemplo n.º 25
0
        public void Test1()
        {
            JT808Package jT808Package = new JT808Package
            {
                Header = new JT808Header
                {
                    MsgId           = Enums.JT808MsgId.查询终端属性应答.ToUInt16Value(),
                    ManualMsgNum    = 8888,
                    TerminalPhoneNo = "112233445566",
                }
            };
            JT808_0x0107 jT808_0X0107 = new JT808_0x0107
            {
                // 00000000 00000101
                TerminalType                  = 5,
                MakerId                       = "10601",
                TerminalModel                 = "10455545955103",
                TerminalId                    = "4d6a13",
                Terminal_SIM_ICCID            = "12345678901234567890",
                Terminal_Hardware_Version_Num = "abcdefg",
                Terminal_Firmware_Version_Num = "poiuytrewq",
                // 00000111
                GNSSModule = 7,
                // 00001001
                CommunicationModule = 9
            };

            jT808Package.Bodies = jT808_0X0107;
            string hex = JT808Serializer.Serialize(jT808Package).ToHexString();

            Assert.Equal("7E0107004111223344556622B8000531303630313130343535353435393535313033000000000000346436613133001234567890123456789007616263646566670A706F69757974726577710709EA7E".Replace(" ", ""), hex);
        }
Exemplo n.º 26
0
 protected override void Encode(IChannelHandlerContext context, JT808ClientRequest message, IByteBuffer output)
 {
     if (message.Package != null)
     {
         try
         {
             var sendData = JT808Serializer.Serialize(message.Package, message.MinBufferSize);
             output.WriteBytes(sendData);
             jT808SendAtomicCounterService.MsgSuccessIncrement();
         }
         catch (JT808.Protocol.Exceptions.JT808Exception ex)
         {
             logger.LogError(ex, context.Channel.Id.AsShortText());
         }
         catch (System.Exception ex)
         {
             logger.LogError(ex, context.Channel.Id.AsShortText());
         }
     }
     else if (message.HexData != null)
     {
         output.WriteBytes(message.HexData);
         jT808SendAtomicCounterService.MsgSuccessIncrement();
     }
 }
Exemplo n.º 27
0
        public void Test1()
        {
            JT808Package jT808Package = new JT808Package
            {
                Header = new JT808Header
                {
                    MsgId           = Enums.JT808MsgId.平台通用应答.ToUInt16Value(),
                    ManualMsgNum    = 10,
                    TerminalPhoneNo = "12345678900",
                },
                Bodies = new JT808_0x8001
                {
                    AckMsgId            = Enums.JT808MsgId.位置信息汇报.ToUInt16Value(),
                    JT808PlatformResult = Enums.JT808PlatformResult.成功,
                    MsgNum = 100
                }
            };
            //"7E
            //80 01
            //00 05
            //01 23 45 67 89 00
            //00 0A
            //00 64
            //02 00
            //00
            //61
            //7E"
            var hex = JT808Serializer.Serialize(jT808Package).ToHexString();

            Assert.Equal("7E80010005012345678900000A0064020000617E", hex);
        }
Exemplo n.º 28
0
        public void Test1()
        {
            JT808_0x8401 jT808_0X8401 = new JT808_0x8401();

            jT808_0X8401.SettingTelephoneBook = Enums.JT808SettingTelephoneBook.追加电话本;
            List <JT808ContactProperty> jT808ContactProperties = new List <JT808ContactProperty>();

            jT808ContactProperties.Add(new JT808ContactProperty
            {
                TelephoneBookContactType = Enums.JT808TelephoneBookContactType.呼入,
                Contact     = "smallchi",
                PhoneNumber = "13456smallch"
            });
            jT808ContactProperties.Add(new JT808ContactProperty
            {
                TelephoneBookContactType = Enums.JT808TelephoneBookContactType.呼入_呼出,
                Contact     = "koike",
                PhoneNumber = "koike123456"
            });
            jT808_0X8401.JT808ContactProperties = jT808ContactProperties;
            var hex = JT808Serializer.Serialize(jT808_0X8401).ToHexString();

            Assert.Equal("0202010C3133343536736D616C6C636808736D616C6C636869030B6B6F696B65313233343536056B6F696B65", hex);
            //"02 02 01 0C 31 33 34 35 36 73 6D 61 6C 6C 63 68 08 73 6D 61 6C 6C 63 68 69 03 0B 6B 6F 69 6B 65 31 32 33 34 35 36 05 6B 6F 69 6B 65"
        }
Exemplo n.º 29
0
        public void Test1()
        {
            JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200
            {
                AlarmFlag  = 1,
                Altitude   = 40,
                GPSTime    = DateTime.Parse("2021-04-03 11:10:10"),
                Lat        = 12222222,
                Lng        = 132444444,
                Speed      = 60,
                Direction  = 0,
                StatusFlag = 2,
                JT808CustomLocationAttachData = new Dictionary <byte, JT808_0x0200_CustomBodyBase>(),
                ExceptionLocationAttachData   = new List <JT808_0x0200_CustomBodyBase>()
            };

            jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x00, new JT808LocationAttachImpl0x00
            {
                TestValue = new byte[] { 0, 1, 2, 3 }
            });
            jT808UploadLocationRequest.ExceptionLocationAttachData.Add(new JT808LocationAttachImpl0x00
            {
                TestId = "012345678912"
            });
            var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString();

            Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000210403111010000400010203000C303132333435363738393132", hex);
        }
Exemplo n.º 30
0
        public void Test3()
        {
            JT808Package jT808Package = new JT808Package();

            jT808Package.Header = new JT808Header
            {
                MsgId           = Enums.JT808MsgId.终端注册应答,
                MsgNum          = 10,
                TerminalPhoneNo = "012345678900",
            };
            jT808Package.Bodies = new JT808_0x8100
            {
                Code = "123456",
                JT808TerminalRegisterResult = Enums.JT808TerminalRegisterResult.数据库中无该终端,
                MsgNum = 100
            };
            //"7E
            //81 00
            //00 03
            //01 23 45 67 89 00
            //00 0A
            //00 64
            //04
            //61
            //7E"
            var hex = JT808Serializer.Serialize(jT808Package).ToHexString();
        }