From 631ad20369ac8f6edbb9024f9a5acc442371a484 Mon Sep 17 00:00:00 2001 From: SmallChi <564952747@qq.com> Date: Sun, 23 Sep 2018 15:28:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A00x1202=E6=B6=88?= =?UTF-8?q?=E6=81=AF=202.=E5=A2=9E=E5=8A=A00x1202=E6=B5=8B=E8=AF=95=203.?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=AC=E5=85=B1=E5=AE=9A=E4=BD=8D=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/车牌颜色字典.png | Bin 3287 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 doc/车牌颜色字典.png diff --git a/doc/车牌颜色字典.png b/doc/车牌颜色字典.png deleted file mode 100644 index 34e9e5e82090d341d6c58f7a5933a6bd46f98219..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3287 zcmYjU2{e>#8y=<_*@pT^ma&xOOHq+xW^CEB_WAT#vV~+V%QSXF8j@znnih-_W6L(m zQXzxvO9;a>3NdCFj3vGQ@SpSj|2gk@-uv9oeLv6jT=(_d=Y5l`EsX_u#d$#>kbtR) z!Br558^*C;@qjsFfdtBw^WqA=YOD_`@0DEO*fQ4UwuS%zP^r{)_6}}=W3G?@z&T_Q z6tb|g1(=yxE^>UpCNi~?#{XROo4Rsf)r6K$5%IXBH&1z2<@O5UfJeghsk zy-G5(^fI$lsa>Z5G!_8hY8U$0J3gaZUc{9-l~NY&4T(geRW>+llcsAI%*=e+0UAJR zn8uNbUOv;fIevFCZVmuphk?$fY3ETD?P?Yh*$uZA)`=FYm> z+f$AWw%zelUZq*3v9{G@!@_}FTU|w16zLR zclu|B8#)P)8k~PqixH2L;n{n%%k+7kD9vzjL3z-+e97dVX9}kxR!+?xoq5wFaU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mg(yYm-&av1mXC*bI6iz!Su)K5~w_Raw{TNdsohE#^%DF z;xa8?^bvyRw6U2s|K9W(A@t-_C52~ Date: Sun, 23 Sep 2018 15:29:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A00x1202=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=8F=8A=E6=B5=8B=E8=AF=95=202.=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E8=BD=A6=E8=BE=86=E5=AE=9A=E4=BD=8D=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + doc/JT-T809.pdf | Bin 338089 -> 339285 bytes .../JT809_0x1200_0x1202Test.cs | 59 +++++++++++++ src/JT809.Protocol/JT809.Protocol.csproj | 5 +- .../JT809Enums/JT809SubBusinessType.cs | 1 + .../JT809_VehiclePositionExcrypt.cs | 15 ++++ .../JT809Extensions/JT809BinaryExtensions.cs | 18 ++-- .../JT809_0x1200_0x1202Formatter.cs | 58 +++++++++++++ .../JT809VehiclePositionProperties.cs | 78 ++++++++++++++++++ .../JT809_0x1200_0x1202.cs | 26 ++++++ 10 files changed, 247 insertions(+), 14 deletions(-) create mode 100644 src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x1200_0x1202Test.cs create mode 100644 src/JT809.Protocol/JT809Enums/JT809_VehiclePositionExcrypt.cs create mode 100644 src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1200_0x1202Formatter.cs create mode 100644 src/JT809.Protocol/JT809Properties/JT809VehiclePositionProperties.cs create mode 100644 src/JT809.Protocol/JT809SubMessageBody/JT809_0x1200_0x1202.cs diff --git a/README.md b/README.md index c8d0cc6..50c527e 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,4 @@ |:------:|:------:|:------:|:------:| | 1 | 0x1200 | √ | 主链路动态信息交换消息 | | 2 | 0x1201 | √ | 上传车辆注册信息 | +| 3 | 0x1202 | √ | 实时上传车辆定位信息 | \ No newline at end of file diff --git a/doc/JT-T809.pdf b/doc/JT-T809.pdf index c3b2c79994dd61365d0c428fabd4f0d5842344b5..5b37a4be0269c35a746aed14ea826a4a5da189e0 100644 GIT binary patch delta 5029 zcmc&&J8T?97}hyH9+!X#PDmn9n1q-(Lh|lBc4r2Hk)4NAVC>jIAXyGF_Qo-CeBtf_ zi4ZypB#H>7pjZinsHrRz5CsLIN*Se~p`(hT6mF0x;h)Ft?f!GAC^*UY?|e5i|NF82 z{@%Xd|Je80=d~Y)9^TwT5~@f{7D&R_7x!-t!QZZ*@82B$p*@t){I`p>!`-*H*0R>- z##RPUved4HbZa4(BQiCA@?`WD2&&E5$;s%#_|)2! zjjfG#r?t{)w(>v!8a`N~`PUDI$GX$g&Fi6v3t78)t+kr9;ifa!J2Q)&l}-lFGmG$b z;l|ahk4CF2ghr>P;A?s|n!UE!*|@rSV-h~me5<*-n01z-`O{~YVf|*dwcfc*K+DO= z1_+a_TY(M1V2AH9@ zU_$mDuNbrR7A1U>EH<*OwRUI32w@(Z?|;x}B+Tm;^*tF>{26!6c!B^K=7Rq^T_kt{|v9z#7_t6Z`5icf2UUe4#?lN z`W+y@4%Kf1Y45V+_^|!$&ahp5Qn#z;AG72aN0uJ9zl}U$!EHz8p0ukSM{YIjD%x$y zT}PUG>}upGOST=Ed)lsc9Jw`OSJ5+;+;yb6*RDpMwPf3oxly~?apcxMyNdQ(a@UdO zb9Oayz>;l8<__A`&cXV*E|u0iG1(&4WHgnrsW0YJ#$>pUN+_6UALD5igWtJ`Ehfk% z&qFdAyM5h06Un%#6qO4BQ<$-2LSX?VOQ2HXv#G!WN+vyH&$nyOaKEu6p%fGwiqAXyd7{k6(pmMk`j1Q#*W^4qM z%(|{GpynWT7x`0jrf?8y&Vww`Tm)GHSdb-}Cqb5Io)%fs^=W4$R5(qvBC`4{V>P(aKTC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I#psE2qa*iN6%bf(P1@?(1^ZPf+kN36M8+$1oNTY+sGMOY4&SMEd&(W@za~# z`g^JviDz}KB)&zbb zZwxXpqy?-?BUgUqDKlb1#@7#&c(U7Fj_>YvE4N3lAwm)C8e35NGO9;E1WUb%KkVw% zcmd@yZO6?+;L_S7CLav-oR_u)5q70YX>ZliuL?ALP@TGL<|5+bNRdGyv%j7Ig7wmZ zU%aR@DKFxYp#-^5j1iN~)CQ5Or!OvuHYnXp->XWURYdT5u*xW-=GKAZUJXoyzIiqX zhNUudRp@*D5EMV(AE;Uj7>pV{BEv?%7zIPy?DegrfDCzkN8|-#OCmQe{=X#;7~5Ph fkjEy(lUv>OWy|r8Tiu6Os3*U+v-8@W*Vq0Bq$>k| diff --git a/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x1200_0x1202Test.cs b/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x1200_0x1202Test.cs new file mode 100644 index 0000000..e1e4c7e --- /dev/null +++ b/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x1200_0x1202Test.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using JT809.Protocol; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809MessageBody; +using JT809.Protocol.JT809Exceptions; +using JT809.Protocol.JT809SubMessageBody; + +namespace JT809.Protocol.Test.JT809SubMessageBody +{ + public class JT809_0x1200_0x1202Test + { + [Fact] + public void Test1() + { + JT809_0x1200_0x1202 jT809_0X1200_0X1202 = new JT809_0x1200_0x1202(); + jT809_0X1200_0X1202.VehiclePosition.Day = 19; + jT809_0X1200_0X1202.VehiclePosition.Month = 7; + jT809_0X1200_0X1202.VehiclePosition.Year = 2012; + jT809_0X1200_0X1202.VehiclePosition.Hour = 15; + jT809_0X1200_0X1202.VehiclePosition.Minute = 15; + jT809_0X1200_0X1202.VehiclePosition.Second = 15; + jT809_0X1200_0X1202.VehiclePosition.Lon = 133123456; + jT809_0X1200_0X1202.VehiclePosition.Lat = 24123456; + jT809_0X1200_0X1202.VehiclePosition.Vec1 = 50; + jT809_0X1200_0X1202.VehiclePosition.Vec2 = 51; + jT809_0X1200_0X1202.VehiclePosition.Vec3 = 150; + jT809_0X1200_0X1202.VehiclePosition.Direction = 45; + jT809_0X1200_0X1202.VehiclePosition.Altitude = 45; + jT809_0X1200_0X1202.VehiclePosition.State = 3; + jT809_0X1200_0X1202.VehiclePosition.Alarm = 257; + var hex = JT809Serializer.Serialize(jT809_0X1200_0X1202).ToHexString(); + //"00 13 07 07 DC 0F 0F 0F 07 EF 4D 80 01 70 18 40 00 32 00 33 00 00 00 96 00 2D 00 2D 00 00 00 03 00 00 01 01" + } + + [Fact] + public void Test2() + { + var bytes = "00 13 07 07 DC 0F 0F 0F 07 EF 4D 80 01 70 18 40 00 32 00 33 00 00 00 96 00 2D 00 2D 00 00 00 03 00 00 01 01".ToHexBytes(); + JT809_0x1200_0x1202 jT809_0X1200_0X1202 = JT809Serializer.Deserialize(bytes); + Assert.Equal(19, jT809_0X1200_0X1202.VehiclePosition.Day); + Assert.Equal(7, jT809_0X1200_0X1202.VehiclePosition.Month); + Assert.Equal(2012, jT809_0X1200_0X1202.VehiclePosition.Year); + Assert.Equal(15, jT809_0X1200_0X1202.VehiclePosition.Hour); + Assert.Equal(15, jT809_0X1200_0X1202.VehiclePosition.Minute); + Assert.Equal(15, jT809_0X1200_0X1202.VehiclePosition.Second); + Assert.Equal((uint)133123456, jT809_0X1200_0X1202.VehiclePosition.Lon); + Assert.Equal((uint)24123456, jT809_0X1200_0X1202.VehiclePosition.Lat); + Assert.Equal(50, jT809_0X1200_0X1202.VehiclePosition.Vec1); + Assert.Equal(51, jT809_0X1200_0X1202.VehiclePosition.Vec2); + Assert.Equal((ushort)45, jT809_0X1200_0X1202.VehiclePosition.Direction); + Assert.Equal((ushort)45, jT809_0X1200_0X1202.VehiclePosition.Altitude); + Assert.Equal((uint)3, jT809_0X1200_0X1202.VehiclePosition.State); + Assert.Equal((uint)257, jT809_0X1200_0X1202.VehiclePosition.Alarm); + } + } +} diff --git a/src/JT809.Protocol/JT809.Protocol.csproj b/src/JT809.Protocol/JT809.Protocol.csproj index cf095a2..0b294fc 100644 --- a/src/JT809.Protocol/JT809.Protocol.csproj +++ b/src/JT809.Protocol/JT809.Protocol.csproj @@ -44,6 +44,7 @@ + @@ -53,8 +54,4 @@ - - - - diff --git a/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs b/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs index 7075451..d2a0f3b 100644 --- a/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs +++ b/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs @@ -20,6 +20,7 @@ namespace JT809.Protocol.JT809Enums ///实时上传车辆定位信息 /// [Description("实时上传车辆定位信息")] + [JT809BodiesType(typeof(JT809_0x1200_0x1202))] UP_EXG_MSG_REAL_LOCATION = 0x1202, /// ///车辆定位信息自动补报 diff --git a/src/JT809.Protocol/JT809Enums/JT809_VehiclePositionExcrypt.cs b/src/JT809.Protocol/JT809Enums/JT809_VehiclePositionExcrypt.cs new file mode 100644 index 0000000..8f2408e --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_VehiclePositionExcrypt.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 定位信息是否使用国家测绘局批准的地图保密插件进行加密。 + /// + public enum JT809_VehiclePositionExcrypt:byte + { + 未加密 = 0x00, + 已加密 = 0x01 + } +} diff --git a/src/JT809.Protocol/JT809Extensions/JT809BinaryExtensions.cs b/src/JT809.Protocol/JT809Extensions/JT809BinaryExtensions.cs index 7a9461c..d6a4cc6 100644 --- a/src/JT809.Protocol/JT809Extensions/JT809BinaryExtensions.cs +++ b/src/JT809.Protocol/JT809Extensions/JT809BinaryExtensions.cs @@ -49,6 +49,14 @@ namespace JT809.Protocol.JT809Extensions return result * (int)Math.Pow(100, dig - 1); } + public static int ReadBCD32(ReadOnlySpan read, ref int offset, int len) + { + int result = Convert.ToInt32(read[offset].ToString("X")); + offset += len; + return result * (int)Math.Pow(100, len - 1); + } + + public static long ReadBCD64(this byte data, byte dig) { long result = Convert.ToInt64(data.ToString("X")); @@ -311,16 +319,6 @@ namespace JT809.Protocol.JT809Extensions return codeBytes.Length; } - public static int WriteBCDLittle(ref byte[] write, int offset, string data, int digit, int len) - { - ReadOnlySpan bcd = data.PadLeft(len, '0').AsSpan(); - for (int i = 0; i < digit; i++) - { - write[offset + i] = Convert.ToByte(bcd.Slice(i * 2, 2).ToString(), 16); - } - return digit; - } - public static int WriteBCDLittle(IMemoryOwner memoryOwner, int offset, string data, int digit, int len) { ReadOnlySpan bcd = data.PadLeft(len, '0').AsSpan(); diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1200_0x1202Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1200_0x1202Formatter.cs new file mode 100644 index 0000000..b9db23b --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1200_0x1202Formatter.cs @@ -0,0 +1,58 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using JT809.Protocol.JT809Enums; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x1200_0x1202Formatter : IJT809Formatter + { + public JT809_0x1200_0x1202 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1200_0x1202 jT809_0X1200_0X1202 = new JT809_0x1200_0x1202(); + jT809_0X1200_0X1202.VehiclePosition.Encrypt = (JT809_VehiclePositionExcrypt)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Day= JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Month = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Year = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Hour = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Minute = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Second = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Lon = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Lat = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Vec1 = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Vec2 = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Vec3 = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Direction = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Altitude = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.State = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Alarm = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + readSize = offset; + return jT809_0X1200_0X1202; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1200_0x1202 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset,(byte) value.VehiclePosition.Encrypt); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Day); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Month); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Year); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Hour); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Minute); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Second); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.Lon); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.Lat); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Vec1); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Vec2); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.Vec3); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Direction); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Altitude); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.State); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.Alarm); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Properties/JT809VehiclePositionProperties.cs b/src/JT809.Protocol/JT809Properties/JT809VehiclePositionProperties.cs new file mode 100644 index 0000000..aad81ef --- /dev/null +++ b/src/JT809.Protocol/JT809Properties/JT809VehiclePositionProperties.cs @@ -0,0 +1,78 @@ +using JT809.Protocol.JT809Enums; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Properties +{ + /// + /// 车辆定位 + /// + public class JT809VehiclePositionProperties + { + /// + /// 该字段标识传输的定位信息是否使用国家测绘局批准的地图保密插件进行加密。 + /// + public JT809_VehiclePositionExcrypt Encrypt { get; set; } + /// + /// 日 + /// + public byte Day { get; set; } + /// + /// 月 + /// + public byte Month { get; set; } + /// + /// 年 + /// + public ushort Year { get; set; } + /// + /// 时 + /// + public byte Hour { get; set; } + /// + /// 分 + /// + public byte Minute { get; set; } + /// + /// 秒 + /// + public byte Second { get; set; } + /// + /// 经度,单位为 1*10^-6 度。 + /// + public uint Lon { get; set; } + /// + /// 纬度,单位为 1*10^-6 度。 + /// + public uint Lat { get; set; } + /// + /// 速度,指卫星定位车载终端设备上传的行车速度信息,为必填项。单位为千米每小时(km/h)。 + /// + public ushort Vec1 { get; set; } + /// + /// 行驶记录速度,指车辆行驶记录设备上传的行车速度 信息,为必填项。单位为千米每小时(km/h)。 + /// + public ushort Vec2 { get; set; } + /// + /// 车辆当前总里程数,值车辆上传的行车里程数。单位单位为千米(km) + /// + public uint Vec3 { get; set; } + /// + /// 方向,0-359,单位为度(。),正北为 0,顺时针。 + /// + public ushort Direction { get; set; } + /// + /// 海拔高度,单位为米(m)。 + /// + public ushort Altitude { get; set; } + /// + /// 车辆状态,二进制表示,B31B30B29。。。。。。B2B1B0.具体定义按照 JT/T808-2011 中表 17 的规定 + /// + public uint State { get; set; } + /// + /// 报警状态,二进制表示,0 标识正常,1 表示报警: B31B30B29 。。。。。。 B2B1B0.具 体 定 义 按 照JT/T808-2011 中表 18 的规定 + /// + public uint Alarm { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1200_0x1202.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1200_0x1202.cs new file mode 100644 index 0000000..878613d --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1200_0x1202.cs @@ -0,0 +1,26 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using JT809.Protocol.JT809Properties; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 实时上传车辆定位信息 + /// 子业务类型标识:UP_EXG_MSG_REAL_LOCATION + /// + [JT809Formatter(typeof(JT809_0x1200_0x1202Formatter))] + public class JT809_0x1200_0x1202:JT809SubBodies + { + public JT809_0x1200_0x1202() + { + VehiclePosition = new JT809VehiclePositionProperties(); + } + /// + /// 车辆定位信息 + /// + public JT809VehiclePositionProperties VehiclePosition { get; set; } + } +}