diff --git a/README.md b/README.md index 4ca391c..e39a11f 100644 --- a/README.md +++ b/README.md @@ -74,12 +74,12 @@ jT808_0x0200.Direction = 0; jT808_0x0200.StatusFlag = 2; jT808_0x0200.JT808LocationAttachData = new Dictionary(); -jT808_0x0200.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 +jT808_0x0200.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); -jT808_0x0200.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 +jT808_0x0200.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 125 }); @@ -160,9 +160,9 @@ 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); +Assert.Equal(100, ((JT808_0x0200_0x01)jT808_0x0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); //4.2.附加信息2 -Assert.Equal(125, ((JT808_0x0200_0x02)jT808_0x0200.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); +Assert.Equal(125, ((JT808_0x0200_0x02)jT808_0x0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); ``` ### 举个栗子2 diff --git a/src/JT808.Protocol.Benchmark/JT808SerializerContext.cs b/src/JT808.Protocol.Benchmark/JT808SerializerContext.cs index c958193..66c0462 100644 --- a/src/JT808.Protocol.Benchmark/JT808SerializerContext.cs +++ b/src/JT808.Protocol.Benchmark/JT808SerializerContext.cs @@ -58,56 +58,56 @@ namespace JT808.Protocol.Benchmark jT808UploadLocationRequest.Direction = 0; jT808UploadLocationRequest.StatusFlag = 2; jT808UploadLocationRequest.JT808LocationAttachData = new Dictionary(); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x03, new JT808_0x0200_0x03 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x03, new JT808_0x0200_0x03 { Speed=56 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x04, new JT808_0x0200_0x04 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x04, new JT808_0x0200_0x04 { EventId=1 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x11, new JT808_0x0200_0x11 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x11, new JT808_0x0200_0x11 { AreaId=1, JT808PositionType= Enums.JT808PositionType.圆形区域 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x12, new JT808_0x0200_0x12 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x12, new JT808_0x0200_0x12 { AreaId = 1, JT808PositionType = Enums.JT808PositionType.圆形区域, Direction= Enums.JT808DirectionType.出 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x13, new JT808_0x0200_0x13 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x13, new JT808_0x0200_0x13 { DrivenRoute= Enums.JT808DrivenRouteType.过长, DrivenRouteId=2, Time=34 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x25, new JT808_0x0200_0x25 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x25, new JT808_0x0200_0x25 { CarSignalStatus=23 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x2A, new JT808_0x0200_0x2A + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x2A, new JT808_0x0200_0x2A { IOStatus=244 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x2B, new JT808_0x0200_0x2B + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x2B, new JT808_0x0200_0x2B { Analog = 242 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x30, new JT808_0x0200_0x30 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x30, new JT808_0x0200_0x30 { WiFiSignalStrength=0x02 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x31, new JT808_0x0200_0x31 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x31, new JT808_0x0200_0x31 { GNSSCount=0x05 }); diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x0200Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x0200Test.cs index ecede6c..dada5ab 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x0200Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x0200Test.cs @@ -39,11 +39,11 @@ namespace JT808.Protocol.Test.MessageBody StatusFlag = 2, JT808LocationAttachData = new Dictionary() }; - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); @@ -79,11 +79,11 @@ namespace JT808.Protocol.Test.MessageBody StatusFlag = 2, JT808LocationAttachData = new Dictionary() }; - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); @@ -133,8 +133,8 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(132444444, jT808UploadLocationRequest.Lng); Assert.Equal(60, jT808UploadLocationRequest.Speed); Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); - Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x01]).Mileage); - Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); + Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); + Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); } [Fact] @@ -171,11 +171,11 @@ namespace JT808.Protocol.Test.MessageBody JT808LocationAttachData = new Dictionary(), JT808CustomLocationAttachData = new Dictionary() }; - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); @@ -201,8 +201,8 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(132444444, jT808UploadLocationRequest.Lng); Assert.Equal(60, jT808UploadLocationRequest.Speed); Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); - Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x01]).Mileage); - Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); + Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); + Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); var jT808LocationAttachImpl0x06 = JT808Serializer.Deserialize(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x06]); Assert.Equal(18, jT808LocationAttachImpl0x06.Age); Assert.Equal(1, jT808LocationAttachImpl0x06.Gender); @@ -232,11 +232,11 @@ namespace JT808.Protocol.Test.MessageBody StatusFlag = 2, JT808LocationAttachData = new Dictionary() }; - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); @@ -289,8 +289,8 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(132444444, jT808UploadLocationRequest.Lng); Assert.Equal(60, jT808UploadLocationRequest.Speed); Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); - Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x01]).Mileage); - Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); + Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); + Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); } [Fact] @@ -313,56 +313,56 @@ namespace JT808.Protocol.Test.MessageBody jT808UploadLocationRequest.Direction = 0; jT808UploadLocationRequest.StatusFlag = 2; jT808UploadLocationRequest.JT808LocationAttachData = new Dictionary(); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x03, new JT808_0x0200_0x03 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x03, new JT808_0x0200_0x03 { Speed = 56 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x04, new JT808_0x0200_0x04 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x04, new JT808_0x0200_0x04 { EventId = 1 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x11, new JT808_0x0200_0x11 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x11, new JT808_0x0200_0x11 { AreaId = 1, JT808PositionType = Enums.JT808PositionType.圆形区域 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x12, new JT808_0x0200_0x12 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x12, new JT808_0x0200_0x12 { AreaId = 1, JT808PositionType = Enums.JT808PositionType.圆形区域, Direction = Enums.JT808DirectionType.出 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x13, new JT808_0x0200_0x13 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x13, new JT808_0x0200_0x13 { DrivenRoute = Enums.JT808DrivenRouteType.过长, DrivenRouteId = 2, Time = 34 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x25, new JT808_0x0200_0x25 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x25, new JT808_0x0200_0x25 { CarSignalStatus = 23 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x2A, new JT808_0x0200_0x2A + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x2A, new JT808_0x0200_0x2A { IOStatus = 244 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x2B, new JT808_0x0200_0x2B + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x2B, new JT808_0x0200_0x2B { Analog = 242 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x30, new JT808_0x0200_0x30 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x30, new JT808_0x0200_0x30 { WiFiSignalStrength = 0x02 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x31, new JT808_0x0200_0x31 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x31, new JT808_0x0200_0x31 { GNSSCount = 0x05 }); diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x0201Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x0201Test.cs index e67296a..bcac222 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x0201Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x0201Test.cs @@ -37,11 +37,11 @@ namespace JT808.Protocol.Test.MessageBody StatusFlag = 2, JT808LocationAttachData = new Dictionary() }; - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); @@ -65,8 +65,8 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(132444444, jT808_0X0201.Position.Lng); Assert.Equal(60, jT808_0X0201.Position.Speed); Assert.Equal((uint)2, jT808_0X0201.Position.StatusFlag); - Assert.Equal(100, ((JT808_0x0200_0x01)jT808_0X0201.Position.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x01]).Mileage); - Assert.Equal(55, ((JT808_0x0200_0x02)jT808_0X0201.Position.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); + Assert.Equal(100, ((JT808_0x0200_0x01)jT808_0X0201.Position.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); + Assert.Equal(55, ((JT808_0x0200_0x02)jT808_0X0201.Position.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x0500Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x0500Test.cs index 6c88a64..d3394da 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x0500Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x0500Test.cs @@ -34,11 +34,11 @@ namespace JT808.Protocol.Test.MessageBody StatusFlag = 2, JT808LocationAttachData = new Dictionary() }; - JT808_0x0200_1.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + JT808_0x0200_1.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - JT808_0x0200_1.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + JT808_0x0200_1.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); @@ -67,8 +67,8 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(0, JT808Bodies.JT808_0x0200.Direction); Assert.Equal(60, JT808Bodies.JT808_0x0200.Speed); Assert.Equal((uint)2, JT808Bodies.JT808_0x0200.StatusFlag); - Assert.Equal(100, ((JT808_0x0200_0x01)JT808Bodies.JT808_0x0200.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x01]).Mileage); - Assert.Equal(55, ((JT808_0x0200_0x02)JT808Bodies.JT808_0x0200.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); + Assert.Equal(100, ((JT808_0x0200_0x01)JT808Bodies.JT808_0x0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); + Assert.Equal(55, ((JT808_0x0200_0x02)JT808Bodies.JT808_0x0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x0704Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x0704Test.cs index a743808..7c11dc2 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x0704Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x0704Test.cs @@ -40,11 +40,11 @@ namespace JT808.Protocol.Test.MessageBody StatusFlag = 2, JT808LocationAttachData = new Dictionary() }; - JT808_0x0200_1.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + JT808_0x0200_1.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - JT808_0x0200_1.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + JT808_0x0200_1.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 55 }); @@ -64,11 +64,11 @@ namespace JT808.Protocol.Test.MessageBody StatusFlag = 1, JT808LocationAttachData = new Dictionary() }; - JT808_0x0200_2.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + JT808_0x0200_2.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 96 }); - JT808_0x0200_2.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + JT808_0x0200_2.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 66 }); @@ -138,8 +138,8 @@ namespace JT808.Protocol.Test.MessageBody 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[JT808_0x0200_BodyBase.AttachId0x01]).Mileage); - Assert.Equal(55, ((JT808_0x0200_0x02)JT808Bodies.Positions[0].JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); + 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); @@ -148,8 +148,8 @@ namespace JT808.Protocol.Test.MessageBody 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[JT808_0x0200_BodyBase.AttachId0x01]).Mileage); - Assert.Equal(66, ((JT808_0x0200_0x02)JT808Bodies.Positions[1].JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); + 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); } } } diff --git a/src/JT808.Protocol.Test/Simples/Demo1.cs b/src/JT808.Protocol.Test/Simples/Demo1.cs index 8728b5c..bbd56d0 100644 --- a/src/JT808.Protocol.Test/Simples/Demo1.cs +++ b/src/JT808.Protocol.Test/Simples/Demo1.cs @@ -45,12 +45,12 @@ namespace JT808.Protocol.Test.Simples JT808LocationAttachData = new Dictionary() }; - jT808_0x0200.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x01, new JT808_0x0200_0x01 + jT808_0x0200.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 { Mileage = 100 }); - jT808_0x0200.JT808LocationAttachData.Add(JT808_0x0200_BodyBase.AttachId0x02, new JT808_0x0200_0x02 + jT808_0x0200.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 { Oil = 125 }); diff --git a/src/JT808.Protocol.Test/Simples/Demo2.cs b/src/JT808.Protocol.Test/Simples/Demo2.cs index 9f5c416..ce570f4 100644 --- a/src/JT808.Protocol.Test/Simples/Demo2.cs +++ b/src/JT808.Protocol.Test/Simples/Demo2.cs @@ -51,9 +51,9 @@ namespace JT808.Protocol.Test.Simples 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); + Assert.Equal(100, ((JT808_0x0200_0x01)jT808_0x0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); //4.2.附加信息2 - Assert.Equal(125, ((JT808_0x0200_0x02)jT808_0x0200.JT808LocationAttachData[JT808_0x0200_BodyBase.AttachId0x02]).Oil); + Assert.Equal(125, ((JT808_0x0200_0x02)jT808_0x0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); } } } diff --git a/src/JT808.Protocol.Test/Simples/Demo3.cs b/src/JT808.Protocol.Test/Simples/Demo3.cs index c12a109..619d842 100644 --- a/src/JT808.Protocol.Test/Simples/Demo3.cs +++ b/src/JT808.Protocol.Test/Simples/Demo3.cs @@ -37,8 +37,8 @@ namespace JT808.Protocol.Test.Simples StatusFlag = 2, JT808LocationAttachData = new Dictionary { - { JT808_0x0200_BodyBase.AttachId0x01,new JT808_0x0200_0x01{Mileage = 100}}, - { JT808_0x0200_BodyBase.AttachId0x02,new JT808_0x0200_0x02{Oil = 125}} + { JT808Constants.JT808_0x0200_0x01,new JT808_0x0200_0x01{Mileage = 100}}, + { JT808Constants.JT808_0x0200_0x02,new JT808_0x0200_0x02{Oil = 125}} } }); jT808Package.Header.MsgNum = 1; diff --git a/src/JT808.Protocol/Extensions/JT808ConfigExtensions.cs b/src/JT808.Protocol/Extensions/JT808ConfigExtensions.cs index 26b8751..d785da0 100644 --- a/src/JT808.Protocol/Extensions/JT808ConfigExtensions.cs +++ b/src/JT808.Protocol/Extensions/JT808ConfigExtensions.cs @@ -4,10 +4,8 @@ using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Text; -namespace JT808.Protocol.Extensions +namespace JT808.Protocol { public static class JT808ConfigExtensions { diff --git a/src/JT808.Protocol/Extensions/JT808FormatterExtensions.cs b/src/JT808.Protocol/Extensions/JT808FormatterExtensions.cs deleted file mode 100644 index 38927d6..0000000 --- a/src/JT808.Protocol/Extensions/JT808FormatterExtensions.cs +++ /dev/null @@ -1,35 +0,0 @@ -using JT808.Protocol.Attributes; -using JT808.Protocol.Enums; -using JT808.Protocol.Exceptions; -using JT808.Protocol.Formatters; -using JT808.Protocol.Interfaces; -using System; -using System.Collections.Concurrent; -using System.Linq.Expressions; -using System.Reflection; - -namespace JT808.Protocol.Extensions -{ - [Obsolete("使用JT808ConfigExtensions")] - public static class JT808FormatterExtensions - { - public static IJT808Formatter GetFormatter(IJT808Config jT808Config) - { - return (IJT808Formatter)GetFormatter(typeof(T), jT808Config); - } - - public static IJT808MessagePackFormatter GetMessagePackFormatter(IJT808Config jT808Config) - { - return (IJT808MessagePackFormatter)GetFormatter(typeof(T), jT808Config); - } - - public static object GetFormatter(Type type,IJT808Config jT808Config) - { - if (!jT808Config.FormatterFactory.FormatterDict.TryGetValue(type.GUID, out var formatter)) - { - throw new JT808Exception(JT808ErrorCode.NotGlobalRegisterFormatterAssembly, type.FullName); - } - return formatter; - } - } -} diff --git a/src/JT808.Protocol/Extensions/JT808FormatterResolverExtensions.cs b/src/JT808.Protocol/Extensions/JT808FormatterResolverExtensions.cs deleted file mode 100644 index be26377..0000000 --- a/src/JT808.Protocol/Extensions/JT808FormatterResolverExtensions.cs +++ /dev/null @@ -1,159 +0,0 @@ -using JT808.Protocol.Formatters; -using System; -using System.Collections.Concurrent; -using System.Linq.Expressions; -using System.Reflection; -using JT808.Protocol.Interfaces; -using JT808.Protocol.MessagePack; - -namespace JT808.Protocol.Extensions -{ - /// - /// - /// ref http://adamsitnik.com/Span/#span-must-not-be-a-generic-type-argument - /// ref http://adamsitnik.com/Span/ - /// ref:MessagePack.Formatters.DynamicObjectTypeFallbackFormatter - /// - [Obsolete("使用JT808MessagePackFormatterResolverExtensions")] - public static class JT808FormatterResolverExtensions - { - delegate int JT808SerializeMethod(object dynamicFormatter, ref byte[] bytes, int offset, object value, IJT808Config config); - - delegate dynamic JT808DeserializeMethod(object dynamicFormatter, ReadOnlySpan bytes, out int readSize, IJT808Config config); - - static readonly ConcurrentDictionary jT808Serializers = new ConcurrentDictionary(); - - static readonly ConcurrentDictionary jT808Deserializes = new ConcurrentDictionary(); - - public static int JT808DynamicSerialize(object objFormatter, ref byte[] bytes, int offset, dynamic value, IJT808Config config) - { - Type type = value.GetType(); - var ti = type.GetTypeInfo(); - (object Value, JT808SerializeMethod SerializeMethod) formatterAndDelegate; - if (!jT808Serializers.TryGetValue(type, out formatterAndDelegate)) - { - var t = type; - { - var formatterType = typeof(IJT808Formatter<>).MakeGenericType(t); - var param0 = Expression.Parameter(typeof(object), "formatter"); - var param1 = Expression.Parameter(typeof(byte[]).MakeByRefType(), "bytes"); - var param2 = Expression.Parameter(typeof(int), "offset"); - var param3 = Expression.Parameter(typeof(object), "value"); - var param4 = Expression.Parameter(typeof(IJT808Config),"config"); - var serializeMethodInfo = formatterType.GetRuntimeMethod("Serialize", new[] { typeof(byte[]).MakeByRefType(), typeof(int), t, typeof(IJT808Config) }); - var body = Expression.Call( - Expression.Convert(param0, formatterType), - serializeMethodInfo, - param1, - param2, - ti.IsValueType ? Expression.Unbox(param3, t) : Expression.Convert(param3, t), - param4); - var lambda = Expression.Lambda(body, param0, param1, param2, param3, param4).Compile(); - formatterAndDelegate = (objFormatter, lambda); - } - jT808Serializers.TryAdd(t, formatterAndDelegate); - } - return formatterAndDelegate.SerializeMethod(formatterAndDelegate.Value, ref bytes, offset, value, config); - } - - public static dynamic JT808DynamicDeserialize(object objFormatter, ReadOnlySpan bytes, out int readSize, IJT808Config config) - { - var type = objFormatter.GetType(); - (object Value, JT808DeserializeMethod DeserializeMethod) formatterAndDelegate; - if (!jT808Deserializes.TryGetValue(type, out formatterAndDelegate)) - { - var t = type; - { - var formatterType = typeof(IJT808Formatter<>).MakeGenericType(t); - ParameterExpression param0 = Expression.Parameter(typeof(object), "formatter"); - ParameterExpression param1 = Expression.Parameter(typeof(ReadOnlySpan), "bytes"); - ParameterExpression param2 = Expression.Parameter(typeof(int).MakeByRefType(), "readSize"); - ParameterExpression param3 = Expression.Parameter(typeof(IJT808Config), "config"); - var deserializeMethodInfo = type.GetRuntimeMethod("Deserialize", new[] { typeof(ReadOnlySpan), typeof(int).MakeByRefType() , typeof(IJT808Config) }); - var body = Expression.Call( - Expression.Convert(param0, type), - deserializeMethodInfo, - param1, - param2, - param3 - ); - var lambda = Expression.Lambda(body, param0, param1, param2, param3).Compile(); - formatterAndDelegate = (objFormatter, lambda); - } - jT808Deserializes.TryAdd(t, formatterAndDelegate); - } - return formatterAndDelegate.DeserializeMethod(formatterAndDelegate.Value, bytes, out readSize, config); - } - } - - /// - /// - /// ref http://adamsitnik.com/Span/#span-must-not-be-a-generic-type-argument - /// ref http://adamsitnik.com/Span/ - /// ref:MessagePack.Formatters.DynamicObjectTypeFallbackFormatter - /// - public static class JT808MessagePackFormatterResolverExtensions - { - delegate void JT808SerializeMethod(object dynamicFormatter, ref JT808MessagePackWriter writer,object value, IJT808Config config); - - delegate dynamic JT808DeserializeMethod(object dynamicFormatter, ref JT808MessagePackReader reader, IJT808Config config); - - static readonly ConcurrentDictionary jT808Serializers = new ConcurrentDictionary(); - - static readonly ConcurrentDictionary jT808Deserializes = new ConcurrentDictionary(); - public static void JT808DynamicSerialize(object objFormatter, ref JT808MessagePackWriter writer, object value, IJT808Config config) - { - Type type = value.GetType(); - var ti = type.GetTypeInfo(); - // (object Value, JT808SerializeMethod SerializeMethod) formatterAndDelegate; - if (!jT808Serializers.TryGetValue(type, out var formatterAndDelegate)) - { - var t = type; - { - var formatterType = typeof(IJT808MessagePackFormatter<>).MakeGenericType(t); - var param0 = Expression.Parameter(typeof(object), "formatter"); - var param1 = Expression.Parameter(typeof(JT808MessagePackWriter).MakeByRefType(), "writer"); - var param2 = Expression.Parameter(typeof(object), "value"); - var param3 = Expression.Parameter(typeof(IJT808Config), "config"); - var serializeMethodInfo = formatterType.GetRuntimeMethod("Serialize", new[] { typeof(JT808MessagePackWriter).MakeByRefType(), t, typeof(IJT808Config) }); - var body = Expression.Call( - Expression.Convert(param0, formatterType), - serializeMethodInfo, - param1, - ti.IsValueType ? Expression.Unbox(param2, t) : Expression.Convert(param2, t), - param3); - var lambda = Expression.Lambda(body, param0, param1, param2, param3).Compile(); - formatterAndDelegate = (objFormatter, lambda); - } - jT808Serializers.TryAdd(t, formatterAndDelegate); - } - formatterAndDelegate.SerializeMethod(formatterAndDelegate.Value, ref writer, value, config); - } - public static dynamic JT808DynamicDeserialize(object objFormatter, ref JT808MessagePackReader reader, IJT808Config config) - { - var type = objFormatter.GetType(); - // (object Value, JT808DeserializeMethod DeserializeMethod) formatterAndDelegate; - if (!jT808Deserializes.TryGetValue(type, out var formatterAndDelegate)) - { - var t = type; - { - var formatterType = typeof(IJT808MessagePackFormatter<>).MakeGenericType(t); - ParameterExpression param0 = Expression.Parameter(typeof(object), "formatter"); - ParameterExpression param1 = Expression.Parameter(typeof(JT808MessagePackReader).MakeByRefType(), "reader"); - ParameterExpression param2 = Expression.Parameter(typeof(IJT808Config), "config"); - var deserializeMethodInfo = type.GetRuntimeMethod("Deserialize", new[] { typeof(JT808MessagePackReader).MakeByRefType(), typeof(IJT808Config) }); - var body = Expression.Call( - Expression.Convert(param0, type), - deserializeMethodInfo, - param1, - param2 - ); - var lambda = Expression.Lambda(body, param0, param1, param2).Compile(); - formatterAndDelegate = (objFormatter, lambda); - } - jT808Deserializes.TryAdd(t, formatterAndDelegate); - } - return formatterAndDelegate.DeserializeMethod(formatterAndDelegate.Value,ref reader, config); - } - } -} diff --git a/src/JT808.Protocol/Extensions/JT808MessagePackFormatterResolverExtensions.cs b/src/JT808.Protocol/Extensions/JT808MessagePackFormatterResolverExtensions.cs new file mode 100644 index 0000000..2bdf6c8 --- /dev/null +++ b/src/JT808.Protocol/Extensions/JT808MessagePackFormatterResolverExtensions.cs @@ -0,0 +1,81 @@ +using JT808.Protocol.Formatters; +using System; +using System.Collections.Concurrent; +using System.Linq.Expressions; +using System.Reflection; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; + +namespace JT808.Protocol.Extensions +{ + /// + /// + /// ref http://adamsitnik.com/Span/#span-must-not-be-a-generic-type-argument + /// ref http://adamsitnik.com/Span/ + /// ref:MessagePack.Formatters.DynamicObjectTypeFallbackFormatter + /// + public static class JT808MessagePackFormatterResolverExtensions + { + delegate void JT808SerializeMethod(object dynamicFormatter, ref JT808MessagePackWriter writer,object value, IJT808Config config); + + delegate dynamic JT808DeserializeMethod(object dynamicFormatter, ref JT808MessagePackReader reader, IJT808Config config); + + static readonly ConcurrentDictionary jT808Serializers = new ConcurrentDictionary(); + + static readonly ConcurrentDictionary jT808Deserializes = new ConcurrentDictionary(); + public static void JT808DynamicSerialize(object objFormatter, ref JT808MessagePackWriter writer, object value, IJT808Config config) + { + Type type = value.GetType(); + var ti = type.GetTypeInfo(); + // (object Value, JT808SerializeMethod SerializeMethod) formatterAndDelegate; + if (!jT808Serializers.TryGetValue(type, out var formatterAndDelegate)) + { + var t = type; + { + var formatterType = typeof(IJT808MessagePackFormatter<>).MakeGenericType(t); + var param0 = Expression.Parameter(typeof(object), "formatter"); + var param1 = Expression.Parameter(typeof(JT808MessagePackWriter).MakeByRefType(), "writer"); + var param2 = Expression.Parameter(typeof(object), "value"); + var param3 = Expression.Parameter(typeof(IJT808Config), "config"); + var serializeMethodInfo = formatterType.GetRuntimeMethod("Serialize", new[] { typeof(JT808MessagePackWriter).MakeByRefType(), t, typeof(IJT808Config) }); + var body = Expression.Call( + Expression.Convert(param0, formatterType), + serializeMethodInfo, + param1, + ti.IsValueType ? Expression.Unbox(param2, t) : Expression.Convert(param2, t), + param3); + var lambda = Expression.Lambda(body, param0, param1, param2, param3).Compile(); + formatterAndDelegate = (objFormatter, lambda); + } + jT808Serializers.TryAdd(t, formatterAndDelegate); + } + formatterAndDelegate.SerializeMethod(formatterAndDelegate.Value, ref writer, value, config); + } + public static dynamic JT808DynamicDeserialize(object objFormatter, ref JT808MessagePackReader reader, IJT808Config config) + { + var type = objFormatter.GetType(); + // (object Value, JT808DeserializeMethod DeserializeMethod) formatterAndDelegate; + if (!jT808Deserializes.TryGetValue(type, out var formatterAndDelegate)) + { + var t = type; + { + var formatterType = typeof(IJT808MessagePackFormatter<>).MakeGenericType(t); + ParameterExpression param0 = Expression.Parameter(typeof(object), "formatter"); + ParameterExpression param1 = Expression.Parameter(typeof(JT808MessagePackReader).MakeByRefType(), "reader"); + ParameterExpression param2 = Expression.Parameter(typeof(IJT808Config), "config"); + var deserializeMethodInfo = type.GetRuntimeMethod("Deserialize", new[] { typeof(JT808MessagePackReader).MakeByRefType(), typeof(IJT808Config) }); + var body = Expression.Call( + Expression.Convert(param0, type), + deserializeMethodInfo, + param1, + param2 + ); + var lambda = Expression.Lambda(body, param0, param1, param2).Compile(); + formatterAndDelegate = (objFormatter, lambda); + } + jT808Deserializes.TryAdd(t, formatterAndDelegate); + } + return formatterAndDelegate.DeserializeMethod(formatterAndDelegate.Value,ref reader, config); + } + } +} diff --git a/src/JT808.Protocol/Formatters/IJT808FormatterOfT.cs b/src/JT808.Protocol/Formatters/IJT808MessagePackFormatter.cs similarity index 59% rename from src/JT808.Protocol/Formatters/IJT808FormatterOfT.cs rename to src/JT808.Protocol/Formatters/IJT808MessagePackFormatter.cs index f8e3e7d..9d49e44 100644 --- a/src/JT808.Protocol/Formatters/IJT808FormatterOfT.cs +++ b/src/JT808.Protocol/Formatters/IJT808MessagePackFormatter.cs @@ -4,14 +4,6 @@ using JT808.Protocol.MessagePack; namespace JT808.Protocol.Formatters { - [Obsolete("使用IJT808MessagePackFormatter")] - public interface IJT808Formatter: IJT808Formatter - { - T Deserialize(ReadOnlySpan bytes, out int readSize, IJT808Config config); - - int Serialize(ref byte[] bytes, int offset, T value, IJT808Config config); - } - public interface IJT808MessagePackFormatter : IJT808Formatter { void Serialize(ref JT808MessagePackWriter writer, T value, IJT808Config config); diff --git a/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x0104_Formatter.cs b/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x0104_Formatter.cs index 83c31f6..11adf4d 100644 --- a/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x0104_Formatter.cs +++ b/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x0104_Formatter.cs @@ -17,7 +17,7 @@ namespace JT808.Protocol.Formatters.MessageBodyFormatters for (int i = 0; i < jT808_0x0104.AnswerParamsCount; i++) { var paramId = reader.ReadVirtualUInt32();//参数ID - if (JT808_0x8103_BodyBase.JT808_0x8103Method.TryGetValue(paramId, out Type type)) + if (config.JT808_0X8103_Factory.ParamMethods.TryGetValue(paramId, out Type type)) { if (jT808_0x0104.ParamList != null) { diff --git a/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x0200_Formatter.cs b/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x0200_Formatter.cs index 2889e59..9278ba6 100644 --- a/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x0200_Formatter.cs +++ b/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x0200_Formatter.cs @@ -41,7 +41,7 @@ namespace JT808.Protocol.Formatters.MessageBodyFormatters ReadOnlySpan attachSpan= reader.GetVirtualReadOnlySpan(2); byte attachId = attachSpan[0]; byte attachLen = attachSpan[1]; - if (JT808_0x0200_BodyBase.JT808LocationAttachMethod.TryGetValue(attachId, out Type jT808LocationAttachType)) + if (config.JT808_0X0200_Factory.JT808LocationAttachMethod.TryGetValue(attachId, out Type jT808LocationAttachType)) { object attachImplObj = config.GetMessagePackFormatterByType(jT808LocationAttachType); dynamic attachImpl = JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize(attachImplObj,ref reader, config); diff --git a/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x8103_Formatter.cs b/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x8103_Formatter.cs index aff2aba..1293477 100644 --- a/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x8103_Formatter.cs +++ b/src/JT808.Protocol/Formatters/MessageBodyFormatters/JT808_0x8103_Formatter.cs @@ -22,7 +22,7 @@ namespace JT808.Protocol.Formatters.MessageBodyFormatters for (int i = 0; i < paramCount; i++) { var paramId = reader.ReadVirtualUInt32();//参数ID - if (JT808_0x8103_BodyBase.JT808_0x8103Method.TryGetValue(paramId, out Type type)) + if (config.JT808_0X8103_Factory.ParamMethods.TryGetValue(paramId, out Type type)) { object attachImplObj = config.GetMessagePackFormatterByType(type); dynamic attachImpl = JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize(attachImplObj, ref reader, config); diff --git a/src/JT808.Protocol/Interfaces/GlobalConfigBase.cs b/src/JT808.Protocol/Interfaces/GlobalConfigBase.cs index 878fb8b..1a8ca9e 100644 --- a/src/JT808.Protocol/Interfaces/GlobalConfigBase.cs +++ b/src/JT808.Protocol/Interfaces/GlobalConfigBase.cs @@ -19,7 +19,9 @@ namespace JT808.Protocol.Interfaces Encoding = Encoding.GetEncoding("GBK"); FormatterFactory = new JT808FormatterFactory(); JT808_0X0200_Custom_Factory = new JT808_0x0200_Custom_Factory(); + JT808_0X0200_Factory = new JT808_0x0200_Factory(); JT808_0X8103_Custom_Factory = new JT808_0x8103_Custom_Factory(); + JT808_0X8103_Factory = new JT808_0x8103_Factory(); TerminalPhoneNoLength = 12; } public abstract string ConfigId { get; } @@ -31,7 +33,9 @@ namespace JT808.Protocol.Interfaces public virtual bool SkipCRCCode { get; set; } public virtual IJT808FormatterFactory FormatterFactory { get; set; } public virtual IJT808_0x0200_Custom_Factory JT808_0X0200_Custom_Factory { get; set; } + public virtual IJT808_0x0200_Factory JT808_0X0200_Factory { get; set; } public virtual IJT808_0x8103_Custom_Factory JT808_0X8103_Custom_Factory { get; set; } + public virtual IJT808_0x8103_Factory JT808_0X8103_Factory { get; set; } public virtual int TerminalPhoneNoLength { get; set; } public virtual IJT808Config Register(params Assembly[] externalAssemblies) { diff --git a/src/JT808.Protocol/Interfaces/IJT808Config.cs b/src/JT808.Protocol/Interfaces/IJT808Config.cs index f7f690d..120e1fb 100644 --- a/src/JT808.Protocol/Interfaces/IJT808Config.cs +++ b/src/JT808.Protocol/Interfaces/IJT808Config.cs @@ -36,10 +36,18 @@ namespace JT808.Protocol.Interfaces /// IJT808_0x0200_Custom_Factory JT808_0X0200_Custom_Factory { get; set; } /// + /// 附加信息工厂 + /// + IJT808_0x0200_Factory JT808_0X0200_Factory { get; set; } + /// ///自定义设置终端参数工厂 /// IJT808_0x8103_Custom_Factory JT808_0X8103_Custom_Factory { get; set; } /// + ///设置终端参数工厂 + /// + IJT808_0x8103_Factory JT808_0X8103_Factory { get; set; } + /// /// 统一编码 /// Encoding Encoding { get; set; } diff --git a/src/JT808.Protocol/Interfaces/IJT808_0x0200_Custom_Factory.cs b/src/JT808.Protocol/Interfaces/IJT808_0x0200_Custom_Factory.cs index 17aee5f..173bcbe 100644 --- a/src/JT808.Protocol/Interfaces/IJT808_0x0200_Custom_Factory.cs +++ b/src/JT808.Protocol/Interfaces/IJT808_0x0200_Custom_Factory.cs @@ -4,7 +4,7 @@ using System.Text; namespace JT808.Protocol.Interfaces { - public interface IJT808_0x0200_Custom_Factory: IJT808ExternalRegister + public interface IJT808_0x0200_Custom_Factory: IJT808ExternalRegister { HashSet AttachIds { get; } } diff --git a/src/JT808.Protocol/Interfaces/IJT808_0x0200_Factory.cs b/src/JT808.Protocol/Interfaces/IJT808_0x0200_Factory.cs new file mode 100644 index 0000000..c1d8636 --- /dev/null +++ b/src/JT808.Protocol/Interfaces/IJT808_0x0200_Factory.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Interfaces +{ + public interface IJT808_0x0200_Factory + { + ConcurrentDictionary JT808LocationAttachMethod { get; set; } + } +} diff --git a/src/JT808.Protocol/Interfaces/IJT808_0x8103_Factory.cs b/src/JT808.Protocol/Interfaces/IJT808_0x8103_Factory.cs new file mode 100644 index 0000000..7a18e3d --- /dev/null +++ b/src/JT808.Protocol/Interfaces/IJT808_0x8103_Factory.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Interfaces +{ + public interface IJT808_0x8103_Factory + { + ConcurrentDictionary ParamMethods { get; set; } + } +} diff --git a/src/JT808.Protocol/Internal/JT808_0x0200_Factory.cs b/src/JT808.Protocol/Internal/JT808_0x0200_Factory.cs new file mode 100644 index 0000000..d197e04 --- /dev/null +++ b/src/JT808.Protocol/Internal/JT808_0x0200_Factory.cs @@ -0,0 +1,31 @@ +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessageBody; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Internal +{ + class JT808_0x0200_Factory : IJT808_0x0200_Factory + { + public ConcurrentDictionary JT808LocationAttachMethod { get ; set; } + + public JT808_0x0200_Factory() + { + JT808LocationAttachMethod = new ConcurrentDictionary(); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x01, typeof(JT808_0x0200_0x01)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x02, typeof(JT808_0x0200_0x02)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x03, typeof(JT808_0x0200_0x03)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x04, typeof(JT808_0x0200_0x04)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x11, typeof(JT808_0x0200_0x11)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x12, typeof(JT808_0x0200_0x12)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x13, typeof(JT808_0x0200_0x13)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x25, typeof(JT808_0x0200_0x25)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x2A, typeof(JT808_0x0200_0x2A)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x2B, typeof(JT808_0x0200_0x2B)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x30, typeof(JT808_0x0200_0x30)); + JT808LocationAttachMethod.TryAdd(JT808Constants.JT808_0x0200_0x31, typeof(JT808_0x0200_0x31)); + } + } +} diff --git a/src/JT808.Protocol/Internal/JT808_0x8103_Factory.cs b/src/JT808.Protocol/Internal/JT808_0x8103_Factory.cs new file mode 100644 index 0000000..f7d3337 --- /dev/null +++ b/src/JT808.Protocol/Internal/JT808_0x8103_Factory.cs @@ -0,0 +1,101 @@ +using JT808.Protocol.MessageBody; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace JT808.Protocol.Interfaces +{ + class JT808_0x8103_Factory : IJT808_0x8103_Factory + { + public JT808_0x8103_Factory() + { + ParamMethods = new ConcurrentDictionary(); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0001, typeof(JT808_0x8103_0x0001)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0002, typeof(JT808_0x8103_0x0002)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0003, typeof(JT808_0x8103_0x0003)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0004, typeof(JT808_0x8103_0x0004)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0005, typeof(JT808_0x8103_0x0005)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0006, typeof(JT808_0x8103_0x0006)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0007, typeof(JT808_0x8103_0x0007)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0010, typeof(JT808_0x8103_0x0010)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0011, typeof(JT808_0x8103_0x0011)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0012, typeof(JT808_0x8103_0x0012)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0013, typeof(JT808_0x8103_0x0013)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0014, typeof(JT808_0x8103_0x0014)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0015, typeof(JT808_0x8103_0x0015)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0016, typeof(JT808_0x8103_0x0016)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0017, typeof(JT808_0x8103_0x0017)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0018, typeof(JT808_0x8103_0x0018)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0019, typeof(JT808_0x8103_0x0019)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x001A, typeof(JT808_0x8103_0x001A)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x001B, typeof(JT808_0x8103_0x001B)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x001C, typeof(JT808_0x8103_0x001C)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x001D, typeof(JT808_0x8103_0x001D)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0020, typeof(JT808_0x8103_0x0020)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0021, typeof(JT808_0x8103_0x0021)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0022, typeof(JT808_0x8103_0x0022)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0027, typeof(JT808_0x8103_0x0027)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0028, typeof(JT808_0x8103_0x0028)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0029, typeof(JT808_0x8103_0x0029)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x002C, typeof(JT808_0x8103_0x002C)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x002D, typeof(JT808_0x8103_0x002D)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x002E, typeof(JT808_0x8103_0x002E)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x002F, typeof(JT808_0x8103_0x002F)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0030, typeof(JT808_0x8103_0x0030)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0031, typeof(JT808_0x8103_0x0031)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0040, typeof(JT808_0x8103_0x0040)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0041, typeof(JT808_0x8103_0x0041)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0042, typeof(JT808_0x8103_0x0042)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0043, typeof(JT808_0x8103_0x0043)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0044, typeof(JT808_0x8103_0x0044)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0045, typeof(JT808_0x8103_0x0045)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0046, typeof(JT808_0x8103_0x0046)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0047, typeof(JT808_0x8103_0x0047)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0048, typeof(JT808_0x8103_0x0048)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0049, typeof(JT808_0x8103_0x0049)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0050, typeof(JT808_0x8103_0x0050)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0051, typeof(JT808_0x8103_0x0051)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0052, typeof(JT808_0x8103_0x0052)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0053, typeof(JT808_0x8103_0x0053)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0054, typeof(JT808_0x8103_0x0054)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0055, typeof(JT808_0x8103_0x0055)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0056, typeof(JT808_0x8103_0x0056)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0057, typeof(JT808_0x8103_0x0057)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0058, typeof(JT808_0x8103_0x0058)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0059, typeof(JT808_0x8103_0x0059)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x005A, typeof(JT808_0x8103_0x005A)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x005B, typeof(JT808_0x8103_0x005B)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x005C, typeof(JT808_0x8103_0x005C)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x005D, typeof(JT808_0x8103_0x005D)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x005E, typeof(JT808_0x8103_0x005E)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0064, typeof(JT808_0x8103_0x0064)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0065, typeof(JT808_0x8103_0x0065)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0070, typeof(JT808_0x8103_0x0070)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0071, typeof(JT808_0x8103_0x0081)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0072, typeof(JT808_0x8103_0x0072)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0073, typeof(JT808_0x8103_0x0073)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0074, typeof(JT808_0x8103_0x0074)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0080, typeof(JT808_0x8103_0x0080)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0081, typeof(JT808_0x8103_0x0081)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0082, typeof(JT808_0x8103_0x0082)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0083, typeof(JT808_0x8103_0x0083)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0084, typeof(JT808_0x8103_0x0084)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0090, typeof(JT808_0x8103_0x0090)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0091, typeof(JT808_0x8103_0x0091)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0092, typeof(JT808_0x8103_0x0092)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0093, typeof(JT808_0x8103_0x0093)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0094, typeof(JT808_0x8103_0x0094)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0095, typeof(JT808_0x8103_0x0095)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0100, typeof(JT808_0x8103_0x0100)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0101, typeof(JT808_0x8103_0x0101)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0102, typeof(JT808_0x8103_0x0102)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0103, typeof(JT808_0x8103_0x0103)); + ParamMethods.TryAdd(JT808Constants.JT808_0x8103_0x0110, typeof(JT808_0x8103_0x0110)); + } + + public ConcurrentDictionary ParamMethods { get; set; } + } +} diff --git a/src/JT808.Protocol/JT808.Protocol.csproj b/src/JT808.Protocol/JT808.Protocol.csproj index 90dbbbb..e72a342 100644 --- a/src/JT808.Protocol/JT808.Protocol.csproj +++ b/src/JT808.Protocol/JT808.Protocol.csproj @@ -8,13 +8,14 @@ JT808 JT808协议、GB808协议、道路运输车辆卫星定位系统-北斗兼容车载终端通讯协议 JT808协议、GB808协议、道路运输车辆卫星定位系统-北斗兼容车载终端通讯协议 - false + true https://github.com/SmallChi/JT808 https://github.com/SmallChi/JT808 https://github.com/SmallChi/JT808/blob/master/LICENSE https://github.com/SmallChi/JT808/blob/master/LICENSE - true - 2.1.0 + false + 2.1.1 + LICENSE bin\Release\netstandard2.0\JT808.Protocol.xml @@ -27,6 +28,10 @@ + + True + + diff --git a/src/JT808.Protocol/JT808Constants.cs b/src/JT808.Protocol/JT808Constants.cs index a086a53..879bbf3 100644 --- a/src/JT808.Protocol/JT808Constants.cs +++ b/src/JT808.Protocol/JT808Constants.cs @@ -17,5 +17,371 @@ namespace JT808.Protocol public const int DateLimitYear = 2000; public static readonly DateTime UTCBaseTime = new DateTime(1970, 1, 1); public static Encoding Encoding { get;} + + public const byte JT808_0x0200_0x01 = 0x01; + public const byte JT808_0x0200_0x02 = 0x02; + public const byte JT808_0x0200_0x03 = 0x03; + public const byte JT808_0x0200_0x04 = 0x04; + public const byte JT808_0x0200_0x11 = 0x11; + public const byte JT808_0x0200_0x12 = 0x12; + public const byte JT808_0x0200_0x13 = 0x13; + public const byte JT808_0x0200_0x25 = 0x25; + public const byte JT808_0x0200_0x2A = 0x2A; + public const byte JT808_0x0200_0x2B = 0x2B; + public const byte JT808_0x0200_0x30 = 0x30; + public const byte JT808_0x0200_0x31 = 0x31; + /// + /// 终端心跳发送间隔,单位为秒(s) + /// + public const uint JT808_0x8103_0x0001 = 0x0001; + /// + /// TCP 消息应答超时时间,单位为秒(s) + /// + public const uint JT808_0x8103_0x0002 = 0x0002; + /// + /// TCP 消息重传次数 + /// + public const uint JT808_0x8103_0x0003 = 0x0003; + /// + /// UDP 消息应答超时时间,单位为秒(s) + /// + public const uint JT808_0x8103_0x0004 = 0x0004; + /// + /// UDP 消息重传次数 + /// + public const uint JT808_0x8103_0x0005 = 0x0005; + /// + /// SMS 消息应答超时时间,单位为秒(s) + /// + public const uint JT808_0x8103_0x0006 = 0x0006; + /// + /// SMS 消息重传次数 + /// + public const uint JT808_0x8103_0x0007 = 0x0007; + /// + /// 主服务器 APN,无线通信拨号访问点。若网络制式为 CDMA,则该处为PPP 拨号号码 + /// + public const uint JT808_0x8103_0x0010 = 0x0010; + /// + /// 主服务器无线通信拨号用户名 + /// + public const uint JT808_0x8103_0x0011 = 0x0011; + /// + /// 主服务器无线通信拨号密码 + /// + public const uint JT808_0x8103_0x0012 = 0x0012; + /// + /// 主服务器地址,IP 或域名 + /// + public const uint JT808_0x8103_0x0013 = 0x0013; + /// + /// 主服务器地址,IP 或域名 + /// + public const uint JT808_0x8103_0x0014 = 0x0014; + /// + /// 备份服务器无线通信拨号用户名 + /// + public const uint JT808_0x8103_0x0015 = 0x0015; + /// + /// 备份服务器无线通信拨号密码 + /// + public const uint JT808_0x8103_0x0016 = 0x0016; + /// + /// 备份服务器地址,IP 或域名 + /// + public const uint JT808_0x8103_0x0017 = 0x0017; + /// + /// 服务器 TCP 端口 + /// + public const uint JT808_0x8103_0x0018 = 0x0018; + /// + /// 服务器 UDP 端口 + /// + public const uint JT808_0x8103_0x0019 = 0x0019; + /// + /// 道路运输证 IC 卡认证主服务器 IP 地址或域名 + /// + public const uint JT808_0x8103_0x001A = 0x001A; + /// + /// 道路运输证 IC 卡认证主服务器 TCP 端口 + /// + public const uint JT808_0x8103_0x001B = 0x001B; + /// + /// 道路运输证 IC 卡认证主服务器 UDP 端口 + /// + public const uint JT808_0x8103_0x001C = 0x001C; + /// + /// 道路运输证 IC 卡认证备份服务器 IP 地址或域名,端口同主服务器 + /// + public const uint JT808_0x8103_0x001D = 0x001D; + /// + /// 位置汇报策略,0:定时汇报;1:定距汇报;2:定时和定距汇报 + /// + public const uint JT808_0x8103_0x0020 = 0x0020; + /// + /// 位置汇报方案,0:根据 ACC 状态; 1:根据登录状态和 ACC 状态,先判断登录状态,若登录再根据 ACC 状态 + /// + public const uint JT808_0x8103_0x0021 = 0x0021; + /// + /// 驾驶员未登录汇报时间间隔,单位为秒(s),>0 + /// + public const uint JT808_0x8103_0x0022 = 0x0022; + /// + /// 休眠时汇报时间间隔,单位为秒(s),>0 + /// + public const uint JT808_0x8103_0x0027 = 0x0027; + /// + /// 紧急报警时汇报时间间隔,单位为秒(s),>0 + /// + public const uint JT808_0x8103_0x0028 = 0x0028; + /// + /// 缺省时间汇报间隔,单位为秒(s),>0 + /// + public const uint JT808_0x8103_0x0029 = 0x0029; + /// + /// 缺省距离汇报间隔,单位为米(m),>0 + /// + public const uint JT808_0x8103_0x002C = 0x002C; + /// + /// 驾驶员未登录汇报距离间隔,单位为米(m),>0 + /// + public const uint JT808_0x8103_0x002D = 0x002D; + /// + /// 休眠时汇报距离间隔,单位为米(m),>0 + /// + public const uint JT808_0x8103_0x002E = 0x002E; + /// + /// 紧急报警时汇报距离间隔,单位为米(m),>0 + /// + public const uint JT808_0x8103_0x002F = 0x002F; + /// + /// 拐点补传角度,<180 + /// + public const uint JT808_0x8103_0x0030 = 0x0030; + /// + /// 电子围栏半径(非法位移阈值),单位为米 + /// + public const uint JT808_0x8103_0x0031 = 0x0031; + /// + /// 监控平台电话号码 + /// + public const uint JT808_0x8103_0x0040 = 0x0040; + /// + /// 复位电话号码,可采用此电话号码拨打终端电话让终端复位 + /// + public const uint JT808_0x8103_0x0041 = 0x0041; + /// + /// 恢复出厂设置电话号码,可采用此电话号码拨打终端电话让终端恢复出厂设置 + /// + public const uint JT808_0x8103_0x0042 = 0x0042; + /// + /// 监控平台 SMS 电话号码 + /// + public const uint JT808_0x8103_0x0043 = 0x0043; + /// + /// 接收终端 SMS 文本报警号码 + /// + public const uint JT808_0x8103_0x0044 = 0x0044; + /// + /// 终端电话接听策略,0:自动接听;1:ACC ON 时自动接听,OFF 时手动接听 + /// + public const uint JT808_0x8103_0x0045 = 0x0045; + /// + /// 每次最长通话时间,单位为秒(s),0 为不允许通话,0xFFFFFFFF 为不限制 + /// + public const uint JT808_0x8103_0x0046 = 0x0046; + /// + /// 当月最长通话时间,单位为秒(s),0 为不允许通话,0xFFFFFFFF 为不限制 + /// + public const uint JT808_0x8103_0x0047 = 0x0047; + /// + /// 监听电话号码 + /// + public const uint JT808_0x8103_0x0048 = 0x0048; + /// + /// 监管平台特权短信号码 + /// + public const uint JT808_0x8103_0x0049 = 0x0049; + /// + /// 报警屏蔽字,与位置信息汇报消息中的报警标志相对应,相应位为 1则相应报警被屏蔽 + /// + public const uint JT808_0x8103_0x0050 = 0x0050; + /// + /// 报警发送文本 SMS 开关,与位置信息汇报消息中的报警标志相对应,相应位为 1 则相应报警时发送文本 SMS + /// + public const uint JT808_0x8103_0x0051 = 0x0051; + /// + /// 报警拍摄开关,与位置信息汇报消息中的报警标志相对应,相应位为1 则相应报警时摄像头拍摄 + /// + public const uint JT808_0x8103_0x0052 = 0x0052; + /// + /// 报警拍摄存储标志,与位置信息汇报消息中的报警标志相对应,相应位为 1 则对相应报警时拍的照片进行存储,否则实时上传 + /// + public const uint JT808_0x8103_0x0053 = 0x0053; + /// + /// 关键标志,与位置信息汇报消息中的报警标志相对应,相应位为 1 则对相应报警为关键报警 + /// + public const uint JT808_0x8103_0x0054 = 0x0054; + /// + /// 最高速度,单位为公里每小时(km/h) + /// + public const uint JT808_0x8103_0x0055 = 0x0055; + /// + /// 超速持续时间,单位为秒(s) + /// + public const uint JT808_0x8103_0x0056 = 0x0056; + /// + /// 连续驾驶时间门限,单位为秒(s) + /// + public const uint JT808_0x8103_0x0057 = 0x0057; + /// + /// 当天累计驾驶时间门限,单位为秒(s) + /// + public const uint JT808_0x8103_0x0058 = 0x0058; + /// + /// 最小休息时间,单位为秒(s) + /// + public const uint JT808_0x8103_0x0059 = 0x0059; + /// + /// 最长停车时间,单位为秒(s) + /// + public const uint JT808_0x8103_0x005A = 0x005A; + /// + /// 超速报警预警差值,单位为 1/10Km/h + /// + public const uint JT808_0x8103_0x005B = 0x005B; + /// + /// 疲劳驾驶预警差值,单位为秒(s),>0 + /// + public const uint JT808_0x8103_0x005C = 0x005C; + /// + /// 碰撞报警参数设置 + /// b7-b0: 碰撞时间,单位 4ms; + /// b15-b8:碰撞加速度,单位 0.1g,设置范围在:0-79 之间,默认为10。 + /// + public const uint JT808_0x8103_0x005D = 0x005D; + /// + /// 侧翻报警参数设置: + /// 侧翻角度,单位 1 度,默认为 30 度 + /// + public const uint JT808_0x8103_0x005E = 0x005E; + /// + /// 定时拍照控制,见 表 13 + /// + public const uint JT808_0x8103_0x0064 = 0x0064; + /// + /// 定距拍照控制,见 表 14 + /// + public const uint JT808_0x8103_0x0065 = 0x0065; + /// + /// 图像/视频质量,1-10,1 最好 + /// + public const uint JT808_0x8103_0x0070 = 0x0070; + /// + /// 亮度,0-255 + /// + public const uint JT808_0x8103_0x0071 = 0x0071; + /// + /// 对比度,0-127 + /// + public const uint JT808_0x8103_0x0072 = 0x0072; + /// + /// 饱和度,0-127 + /// + public const uint JT808_0x8103_0x0073 = 0x0073; + /// + /// 色度,0-255 + /// + public const uint JT808_0x8103_0x0074 = 0x0074; + /// + /// 车辆里程表读数,1/10km + /// + public const uint JT808_0x8103_0x0080 = 0x0080; + /// + /// 车辆所在的省域 ID + /// + public const uint JT808_0x8103_0x0081 = 0x0081; + /// + /// 车辆所在的市域 ID + /// + public const uint JT808_0x8103_0x0082 = 0x0082; + /// + /// 公安交通管理部门颁发的机动车号牌 + /// + public const uint JT808_0x8103_0x0083 = 0x0083; + /// + /// 车牌颜色,按照 JT/T415-2006 的 5.4.12 + /// + public const uint JT808_0x8103_0x0084 = 0x0084; + /// + /// GNSS 定位模式,定义如下: + /// bit0,0:禁用 GPS 定位, 1:启用 GPS 定位; + /// bit1,0:禁用北斗定位, 1:启用北斗定位; + /// bit2,0:禁用 GLONASS 定位, 1:启用 GLONASS 定位; + /// bit3,0:禁用 Galileo 定位, 1:启用 Galileo 定位。 + /// + public const uint JT808_0x8103_0x0090 = 0x0090; + /// + /// GNSS 波特率,定义如下: + /// 0x00:4800;0x01:9600; + /// 0x02:19200;0x03:38400; + /// 0x04:57600;0x05:115200。 + /// + public const uint JT808_0x8103_0x0091 = 0x0091; + /// + /// GNSS 模块详细定位数据输出频率,定义如下: + /// 0x00:500ms;0x01:1000ms(默认值); + /// 0x02:2000ms;0x03:3000ms; + /// 0x04:4000ms。 + /// + public const uint JT808_0x8103_0x0092 = 0x0092; + /// + /// GNSS 模块详细定位数据采集频率,单位为秒,默认为 1。 + /// + public const uint JT808_0x8103_0x0093 = 0x0093; + /// + /// GNSS 模块详细定位数据上传方式 + /// 0x00,本地存储,不上传(默认值); + /// 0x01,按时间间隔上传; + /// 0x02,按距离间隔上传; + /// 0x0B,按累计时间上传,达到传输时间后自动停止上传; + /// 0x0C,按累计距离上传,达到距离后自动停止上传; + /// 0x0D,按累计条数上传,达到上传条数后自动停止上传。 + /// + public const uint JT808_0x8103_0x0094 = 0x0094; + /// + /// GNSS 模块详细定位数据上传设置: + /// 上传方式为 0x01 时,单位为秒; + /// 上传方式为 0x02 时,单位为米; + /// 上传方式为 0x0B 时,单位为秒; + /// 上传方式为 0x0C 时,单位为米; + /// 上传方式为 0x0D 时,单位为条。 + /// + public const uint JT808_0x8103_0x0095 = 0x0095; + /// + /// CAN 总线通道 1 采集时间间隔(ms),0 表示不采集 + /// + public const uint JT808_0x8103_0x0100 = 0x0100; + /// + /// CAN 总线通道 1 上传时间间隔(s),0 表示不上传 + /// + public const uint JT808_0x8103_0x0101 = 0x0101; + /// + /// CAN 总线通道 2 采集时间间隔(ms),0 表示不采集 + /// + public const uint JT808_0x8103_0x0102 = 0x0102; + /// + /// CAN 总线通道 2 上传时间间隔(s),0 表示不上传 + /// + public const uint JT808_0x8103_0x0103 = 0x0103; + /// + /// CAN 总线 ID 单独采集设置: + /// bit63-bit32 表示此 ID 采集时间间隔(ms),0 表示不采集; + /// bit31 表示 CAN 通道号,0:CAN1,1:CAN2; + /// bit30 表示帧类型,0:标准帧,1:扩展帧; + /// bit29 表示数据采集方式,0:原始数据,1:采集区间的计算值; + /// bit28-bit0 表示 CAN 总线 ID。 + /// + public const uint JT808_0x8103_0x0110 = 0x0110; } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_BodyBase.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_BodyBase.cs index a7937ec..3596491 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_BodyBase.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_BodyBase.cs @@ -9,46 +9,6 @@ namespace JT808.Protocol.MessageBody /// public abstract class JT808_0x0200_BodyBase { - /// - /// 位置附加信息方法 - /// - internal static IDictionary JT808LocationAttachMethod { get; private set; } - - static JT808_0x0200_BodyBase() - { - InitJT808LocationAttachMethod(); - } - - private static void InitJT808LocationAttachMethod() - { - JT808LocationAttachMethod = new Dictionary - { - {AttachId0x01, typeof(JT808_0x0200_0x01)}, - {AttachId0x02, typeof(JT808_0x0200_0x02)}, - {AttachId0x03, typeof(JT808_0x0200_0x03)}, - {AttachId0x04, typeof(JT808_0x0200_0x04)}, - {AttachId0x11, typeof(JT808_0x0200_0x11)}, - {AttachId0x12, typeof(JT808_0x0200_0x12)}, - {AttachId0x13, typeof(JT808_0x0200_0x13)}, - {AttachId0x25, typeof(JT808_0x0200_0x25)}, - {AttachId0x2A, typeof(JT808_0x0200_0x2A)}, - {AttachId0x2B, typeof(JT808_0x0200_0x2B)}, - {AttachId0x30, typeof(JT808_0x0200_0x30)}, - {AttachId0x31, typeof(JT808_0x0200_0x31)}, - }; - } - - internal static void AddJT808LocationAttachMethod(byte attachInfoId) - where TJT808LocationAttach : JT808_0x0200_BodyBase - { - JT808LocationAttachMethod.Add(attachInfoId, typeof(TJT808LocationAttach)); - } - - internal static void AddJT808LocationAttachMethod(byte attachInfoId, Type type) - { - JT808LocationAttachMethod.Add(attachInfoId, type); - } - /// /// 附加信息Id /// @@ -58,18 +18,5 @@ namespace JT808.Protocol.MessageBody /// 附加信息长度 /// public abstract byte AttachInfoLength { get; set; } - - public const byte AttachId0x01 = 0x01; - public const byte AttachId0x02 = 0x02; - public const byte AttachId0x03 = 0x03; - public const byte AttachId0x04 = 0x04; - public const byte AttachId0x11 = 0x11; - public const byte AttachId0x12 = 0x12; - public const byte AttachId0x13 = 0x13; - public const byte AttachId0x25 = 0x25; - public const byte AttachId0x2A = 0x2A; - public const byte AttachId0x2B = 0x2B; - public const byte AttachId0x30 = 0x30; - public const byte AttachId0x31 = 0x31; } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8103_BodyBase.cs b/src/JT808.Protocol/MessageBody/JT808_0x8103_BodyBase.cs index 7c1eaba..c0f7116 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8103_BodyBase.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8103_BodyBase.cs @@ -5,361 +5,6 @@ namespace JT808.Protocol.MessageBody { public abstract class JT808_0x8103_BodyBase { - /// - /// 终端心跳发送间隔,单位为秒(s) - /// - public const uint JT808_0x8103_0x0001_Type = 0x0001; - /// - /// TCP 消息应答超时时间,单位为秒(s) - /// - public const uint JT808_0x8103_0x0002_Type = 0x0002; - /// - /// TCP 消息重传次数 - /// - public const uint JT808_0x8103_0x0003_Type = 0x0003; - /// - /// UDP 消息应答超时时间,单位为秒(s) - /// - public const uint JT808_0x8103_0x0004_Type = 0x0004; - /// - /// UDP 消息重传次数 - /// - public const uint JT808_0x8103_0x0005_Type = 0x0005; - /// - /// SMS 消息应答超时时间,单位为秒(s) - /// - public const uint JT808_0x8103_0x0006_Type = 0x0006; - /// - /// SMS 消息重传次数 - /// - public const uint JT808_0x8103_0x0007_Type = 0x0007; - /// - /// 主服务器 APN,无线通信拨号访问点。若网络制式为 CDMA,则该处为PPP 拨号号码 - /// - public const uint JT808_0x8103_0x0010_Type = 0x0010; - /// - /// 主服务器无线通信拨号用户名 - /// - public const uint JT808_0x8103_0x0011_Type = 0x0011; - /// - /// 主服务器无线通信拨号密码 - /// - public const uint JT808_0x8103_0x0012_Type = 0x0012; - /// - /// 主服务器地址,IP 或域名 - /// - public const uint JT808_0x8103_0x0013_Type = 0x0013; - /// - /// 主服务器地址,IP 或域名 - /// - public const uint JT808_0x8103_0x0014_Type = 0x0014; - /// - /// 备份服务器无线通信拨号用户名 - /// - public const uint JT808_0x8103_0x0015_Type = 0x0015; - /// - /// 备份服务器无线通信拨号密码 - /// - public const uint JT808_0x8103_0x0016_Type = 0x0016; - /// - /// 备份服务器地址,IP 或域名 - /// - public const uint JT808_0x8103_0x0017_Type = 0x0017; - /// - /// 服务器 TCP 端口 - /// - public const uint JT808_0x8103_0x0018_Type = 0x0018; - /// - /// 服务器 UDP 端口 - /// - public const uint JT808_0x8103_0x0019_Type = 0x0019; - /// - /// 道路运输证 IC 卡认证主服务器 IP 地址或域名 - /// - public const uint JT808_0x8103_0x001A_Type = 0x001A; - /// - /// 道路运输证 IC 卡认证主服务器 TCP 端口 - /// - public const uint JT808_0x8103_0x001B_Type = 0x001B; - /// - /// 道路运输证 IC 卡认证主服务器 UDP 端口 - /// - public const uint JT808_0x8103_0x001C_Type = 0x001C; - /// - /// 道路运输证 IC 卡认证备份服务器 IP 地址或域名,端口同主服务器 - /// - public const uint JT808_0x8103_0x001D_Type = 0x001D; - /// - /// 位置汇报策略,0:定时汇报;1:定距汇报;2:定时和定距汇报 - /// - public const uint JT808_0x8103_0x0020_Type = 0x0020; - /// - /// 位置汇报方案,0:根据 ACC 状态; 1:根据登录状态和 ACC 状态,先判断登录状态,若登录再根据 ACC 状态 - /// - public const uint JT808_0x8103_0x0021_Type = 0x0021; - /// - /// 驾驶员未登录汇报时间间隔,单位为秒(s),>0 - /// - public const uint JT808_0x8103_0x0022_Type = 0x0022; - /// - /// 休眠时汇报时间间隔,单位为秒(s),>0 - /// - public const uint JT808_0x8103_0x0027_Type = 0x0027; - /// - /// 紧急报警时汇报时间间隔,单位为秒(s),>0 - /// - public const uint JT808_0x8103_0x0028_Type = 0x0028; - /// - /// 缺省时间汇报间隔,单位为秒(s),>0 - /// - public const uint JT808_0x8103_0x0029_Type = 0x0029; - /// - /// 缺省距离汇报间隔,单位为米(m),>0 - /// - public const uint JT808_0x8103_0x002C_Type = 0x002C; - /// - /// 驾驶员未登录汇报距离间隔,单位为米(m),>0 - /// - public const uint JT808_0x8103_0x002D_Type = 0x002D; - /// - /// 休眠时汇报距离间隔,单位为米(m),>0 - /// - public const uint JT808_0x8103_0x002E_Type = 0x002E; - /// - /// 紧急报警时汇报距离间隔,单位为米(m),>0 - /// - public const uint JT808_0x8103_0x002F_Type = 0x002F; - /// - /// 拐点补传角度,<180 - /// - public const uint JT808_0x8103_0x0030_Type = 0x0030; - /// - /// 电子围栏半径(非法位移阈值),单位为米 - /// - public const uint JT808_0x8103_0x0031_Type = 0x0031; - /// - /// 监控平台电话号码 - /// - public const uint JT808_0x8103_0x0040_Type = 0x0040; - /// - /// 复位电话号码,可采用此电话号码拨打终端电话让终端复位 - /// - public const uint JT808_0x8103_0x0041_Type = 0x0041; - /// - /// 恢复出厂设置电话号码,可采用此电话号码拨打终端电话让终端恢复出厂设置 - /// - public const uint JT808_0x8103_0x0042_Type = 0x0042; - /// - /// 监控平台 SMS 电话号码 - /// - public const uint JT808_0x8103_0x0043_Type = 0x0043; - /// - /// 接收终端 SMS 文本报警号码 - /// - public const uint JT808_0x8103_0x0044_Type = 0x0044; - /// - /// 终端电话接听策略,0:自动接听;1:ACC ON 时自动接听,OFF 时手动接听 - /// - public const uint JT808_0x8103_0x0045_Type = 0x0045; - /// - /// 每次最长通话时间,单位为秒(s),0 为不允许通话,0xFFFFFFFF 为不限制 - /// - public const uint JT808_0x8103_0x0046_Type = 0x0046; - /// - /// 当月最长通话时间,单位为秒(s),0 为不允许通话,0xFFFFFFFF 为不限制 - /// - public const uint JT808_0x8103_0x0047_Type = 0x0047; - /// - /// 监听电话号码 - /// - public const uint JT808_0x8103_0x0048_Type = 0x0048; - /// - /// 监管平台特权短信号码 - /// - public const uint JT808_0x8103_0x0049_Type = 0x0049; - /// - /// 报警屏蔽字,与位置信息汇报消息中的报警标志相对应,相应位为 1则相应报警被屏蔽 - /// - public const uint JT808_0x8103_0x0050_Type = 0x0050; - /// - /// 报警发送文本 SMS 开关,与位置信息汇报消息中的报警标志相对应,相应位为 1 则相应报警时发送文本 SMS - /// - public const uint JT808_0x8103_0x0051_Type = 0x0051; - /// - /// 报警拍摄开关,与位置信息汇报消息中的报警标志相对应,相应位为1 则相应报警时摄像头拍摄 - /// - public const uint JT808_0x8103_0x0052_Type = 0x0052; - /// - /// 报警拍摄存储标志,与位置信息汇报消息中的报警标志相对应,相应位为 1 则对相应报警时拍的照片进行存储,否则实时上传 - /// - public const uint JT808_0x8103_0x0053_Type = 0x0053; - /// - /// 关键标志,与位置信息汇报消息中的报警标志相对应,相应位为 1 则对相应报警为关键报警 - /// - public const uint JT808_0x8103_0x0054_Type = 0x0054; - /// - /// 最高速度,单位为公里每小时(km/h) - /// - public const uint JT808_0x8103_0x0055_Type = 0x0055; - /// - /// 超速持续时间,单位为秒(s) - /// - public const uint JT808_0x8103_0x0056_Type = 0x0056; - /// - /// 连续驾驶时间门限,单位为秒(s) - /// - public const uint JT808_0x8103_0x0057_Type = 0x0057; - /// - /// 当天累计驾驶时间门限,单位为秒(s) - /// - public const uint JT808_0x8103_0x0058_Type = 0x0058; - /// - /// 最小休息时间,单位为秒(s) - /// - public const uint JT808_0x8103_0x0059_Type = 0x0059; - /// - /// 最长停车时间,单位为秒(s) - /// - public const uint JT808_0x8103_0x005A_Type = 0x005A; - /// - /// 超速报警预警差值,单位为 1/10Km/h - /// - public const uint JT808_0x8103_0x005B_Type = 0x005B; - /// - /// 疲劳驾驶预警差值,单位为秒(s),>0 - /// - public const uint JT808_0x8103_0x005C_Type = 0x005C; - /// - /// 碰撞报警参数设置 - /// b7-b0: 碰撞时间,单位 4ms; - /// b15-b8:碰撞加速度,单位 0.1g,设置范围在:0-79 之间,默认为10。 - /// - public const uint JT808_0x8103_0x005D_Type = 0x005D; - /// - /// 侧翻报警参数设置: - /// 侧翻角度,单位 1 度,默认为 30 度 - /// - public const uint JT808_0x8103_0x005E_Type = 0x005E; - /// - /// 定时拍照控制,见 表 13 - /// - public const uint JT808_0x8103_0x0064_Type = 0x0064; - /// - /// 定距拍照控制,见 表 14 - /// - public const uint JT808_0x8103_0x0065_Type = 0x0065; - /// - /// 图像/视频质量,1-10,1 最好 - /// - public const uint JT808_0x8103_0x0070_Type = 0x0070; - /// - /// 亮度,0-255 - /// - public const uint JT808_0x8103_0x0071_Type = 0x0071; - /// - /// 对比度,0-127 - /// - public const uint JT808_0x8103_0x0072_Type = 0x0072; - /// - /// 饱和度,0-127 - /// - public const uint JT808_0x8103_0x0073_Type = 0x0073; - /// - /// 色度,0-255 - /// - public const uint JT808_0x8103_0x0074_Type = 0x0074; - /// - /// 车辆里程表读数,1/10km - /// - public const uint JT808_0x8103_0x0080_Type = 0x0080; - /// - /// 车辆所在的省域 ID - /// - public const uint JT808_0x8103_0x0081_Type = 0x0081; - /// - /// 车辆所在的市域 ID - /// - public const uint JT808_0x8103_0x0082_Type = 0x0082; - /// - /// 公安交通管理部门颁发的机动车号牌 - /// - public const uint JT808_0x8103_0x0083_Type = 0x0083; - /// - /// 车牌颜色,按照 JT/T415-2006 的 5.4.12 - /// - public const uint JT808_0x8103_0x0084_Type = 0x0084; - /// - /// GNSS 定位模式,定义如下: - /// bit0,0:禁用 GPS 定位, 1:启用 GPS 定位; - /// bit1,0:禁用北斗定位, 1:启用北斗定位; - /// bit2,0:禁用 GLONASS 定位, 1:启用 GLONASS 定位; - /// bit3,0:禁用 Galileo 定位, 1:启用 Galileo 定位。 - /// - public const uint JT808_0x8103_0x0090_Type = 0x0090; - /// - /// GNSS 波特率,定义如下: - /// 0x00:4800;0x01:9600; - /// 0x02:19200;0x03:38400; - /// 0x04:57600;0x05:115200。 - /// - public const uint JT808_0x8103_0x0091_Type = 0x0091; - /// - /// GNSS 模块详细定位数据输出频率,定义如下: - /// 0x00:500ms;0x01:1000ms(默认值); - /// 0x02:2000ms;0x03:3000ms; - /// 0x04:4000ms。 - /// - public const uint JT808_0x8103_0x0092_Type = 0x0092; - /// - /// GNSS 模块详细定位数据采集频率,单位为秒,默认为 1。 - /// - public const uint JT808_0x8103_0x0093_Type = 0x0093; - /// - /// GNSS 模块详细定位数据上传方式 - /// 0x00,本地存储,不上传(默认值); - /// 0x01,按时间间隔上传; - /// 0x02,按距离间隔上传; - /// 0x0B,按累计时间上传,达到传输时间后自动停止上传; - /// 0x0C,按累计距离上传,达到距离后自动停止上传; - /// 0x0D,按累计条数上传,达到上传条数后自动停止上传。 - /// - public const uint JT808_0x8103_0x0094_Type = 0x0094; - /// - /// GNSS 模块详细定位数据上传设置: - /// 上传方式为 0x01 时,单位为秒; - /// 上传方式为 0x02 时,单位为米; - /// 上传方式为 0x0B 时,单位为秒; - /// 上传方式为 0x0C 时,单位为米; - /// 上传方式为 0x0D 时,单位为条。 - /// - public const uint JT808_0x8103_0x0095_Type = 0x0095; - /// - /// CAN 总线通道 1 采集时间间隔(ms),0 表示不采集 - /// - public const uint JT808_0x8103_0x0100_Type = 0x0100; - /// - /// CAN 总线通道 1 上传时间间隔(s),0 表示不上传 - /// - public const uint JT808_0x8103_0x0101_Type = 0x0101; - /// - /// CAN 总线通道 2 采集时间间隔(ms),0 表示不采集 - /// - public const uint JT808_0x8103_0x0102_Type = 0x0102; - /// - /// CAN 总线通道 2 上传时间间隔(s),0 表示不上传 - /// - public const uint JT808_0x8103_0x0103_Type = 0x0103; - /// - /// CAN 总线 ID 单独采集设置: - /// bit63-bit32 表示此 ID 采集时间间隔(ms),0 表示不采集; - /// bit31 表示 CAN 通道号,0:CAN1,1:CAN2; - /// bit30 表示帧类型,0:标准帧,1:扩展帧; - /// bit29 表示数据采集方式,0:原始数据,1:采集区间的计算值; - /// bit28-bit0 表示 CAN 总线 ID。 - /// - public const uint JT808_0x8103_0x0110_Type = 0x0110; - - public static IDictionary JT808_0x8103Method { get; private set; } /// /// 参数 ID /// @@ -369,93 +14,5 @@ namespace JT808.Protocol.MessageBody /// 参数长度 /// public abstract byte ParamLength { get; set; } - - static JT808_0x8103_BodyBase() - { - JT808_0x8103Method = new Dictionary - { - { JT808_0x8103_0x0001_Type, typeof(JT808_0x8103_0x0001) }, - { JT808_0x8103_0x0002_Type, typeof(JT808_0x8103_0x0002) }, - { JT808_0x8103_0x0003_Type, typeof(JT808_0x8103_0x0003) }, - { JT808_0x8103_0x0004_Type, typeof(JT808_0x8103_0x0004) }, - { JT808_0x8103_0x0005_Type, typeof(JT808_0x8103_0x0005) }, - { JT808_0x8103_0x0006_Type, typeof(JT808_0x8103_0x0006) }, - { JT808_0x8103_0x0007_Type, typeof(JT808_0x8103_0x0007) }, - { JT808_0x8103_0x0010_Type, typeof(JT808_0x8103_0x0010) }, - { JT808_0x8103_0x0011_Type, typeof(JT808_0x8103_0x0011) }, - { JT808_0x8103_0x0012_Type, typeof(JT808_0x8103_0x0012) }, - { JT808_0x8103_0x0013_Type, typeof(JT808_0x8103_0x0013) }, - { JT808_0x8103_0x0014_Type, typeof(JT808_0x8103_0x0014) }, - { JT808_0x8103_0x0015_Type, typeof(JT808_0x8103_0x0015) }, - { JT808_0x8103_0x0016_Type, typeof(JT808_0x8103_0x0016) }, - { JT808_0x8103_0x0017_Type, typeof(JT808_0x8103_0x0017) }, - { JT808_0x8103_0x0018_Type, typeof(JT808_0x8103_0x0018) }, - { JT808_0x8103_0x0019_Type, typeof(JT808_0x8103_0x0019) }, - { JT808_0x8103_0x001A_Type, typeof(JT808_0x8103_0x001A) }, - { JT808_0x8103_0x001B_Type, typeof(JT808_0x8103_0x001B) }, - { JT808_0x8103_0x001C_Type, typeof(JT808_0x8103_0x001C) }, - { JT808_0x8103_0x001D_Type, typeof(JT808_0x8103_0x001D) }, - { JT808_0x8103_0x0020_Type, typeof(JT808_0x8103_0x0020) }, - { JT808_0x8103_0x0021_Type, typeof(JT808_0x8103_0x0021) }, - { JT808_0x8103_0x0022_Type, typeof(JT808_0x8103_0x0022) }, - { JT808_0x8103_0x0027_Type, typeof(JT808_0x8103_0x0027) }, - { JT808_0x8103_0x0028_Type, typeof(JT808_0x8103_0x0028) }, - { JT808_0x8103_0x0029_Type, typeof(JT808_0x8103_0x0029) }, - { JT808_0x8103_0x002C_Type, typeof(JT808_0x8103_0x002C) }, - { JT808_0x8103_0x002D_Type, typeof(JT808_0x8103_0x002D) }, - { JT808_0x8103_0x002E_Type, typeof(JT808_0x8103_0x002E) }, - { JT808_0x8103_0x002F_Type, typeof(JT808_0x8103_0x002F) }, - { JT808_0x8103_0x0030_Type, typeof(JT808_0x8103_0x0030) }, - { JT808_0x8103_0x0031_Type, typeof(JT808_0x8103_0x0031) }, - { JT808_0x8103_0x0040_Type, typeof(JT808_0x8103_0x0040) }, - { JT808_0x8103_0x0041_Type, typeof(JT808_0x8103_0x0041) }, - { JT808_0x8103_0x0042_Type, typeof(JT808_0x8103_0x0042) }, - { JT808_0x8103_0x0043_Type, typeof(JT808_0x8103_0x0043) }, - { JT808_0x8103_0x0044_Type, typeof(JT808_0x8103_0x0044) }, - { JT808_0x8103_0x0045_Type, typeof(JT808_0x8103_0x0045) }, - { JT808_0x8103_0x0046_Type, typeof(JT808_0x8103_0x0046) }, - { JT808_0x8103_0x0047_Type, typeof(JT808_0x8103_0x0047) }, - { JT808_0x8103_0x0048_Type, typeof(JT808_0x8103_0x0048) }, - { JT808_0x8103_0x0049_Type, typeof(JT808_0x8103_0x0049) }, - { JT808_0x8103_0x0050_Type, typeof(JT808_0x8103_0x0050) }, - { JT808_0x8103_0x0051_Type, typeof(JT808_0x8103_0x0051) }, - { JT808_0x8103_0x0052_Type, typeof(JT808_0x8103_0x0052) }, - { JT808_0x8103_0x0053_Type, typeof(JT808_0x8103_0x0053) }, - { JT808_0x8103_0x0054_Type, typeof(JT808_0x8103_0x0054) }, - { JT808_0x8103_0x0055_Type, typeof(JT808_0x8103_0x0055) }, - { JT808_0x8103_0x0056_Type, typeof(JT808_0x8103_0x0056) }, - { JT808_0x8103_0x0057_Type, typeof(JT808_0x8103_0x0057) }, - { JT808_0x8103_0x0058_Type, typeof(JT808_0x8103_0x0058) }, - { JT808_0x8103_0x0059_Type, typeof(JT808_0x8103_0x0059) }, - { JT808_0x8103_0x005A_Type, typeof(JT808_0x8103_0x005A) }, - { JT808_0x8103_0x005B_Type, typeof(JT808_0x8103_0x005B) }, - { JT808_0x8103_0x005C_Type, typeof(JT808_0x8103_0x005C) }, - { JT808_0x8103_0x005D_Type, typeof(JT808_0x8103_0x005D) }, - { JT808_0x8103_0x005E_Type, typeof(JT808_0x8103_0x005E) }, - { JT808_0x8103_0x0064_Type, typeof(JT808_0x8103_0x0064) }, - { JT808_0x8103_0x0065_Type, typeof(JT808_0x8103_0x0065) }, - { JT808_0x8103_0x0070_Type, typeof(JT808_0x8103_0x0070) }, - { JT808_0x8103_0x0071_Type, typeof(JT808_0x8103_0x0081) }, - { JT808_0x8103_0x0072_Type, typeof(JT808_0x8103_0x0072) }, - { JT808_0x8103_0x0073_Type, typeof(JT808_0x8103_0x0073) }, - { JT808_0x8103_0x0074_Type, typeof(JT808_0x8103_0x0074) }, - { JT808_0x8103_0x0080_Type, typeof(JT808_0x8103_0x0080) }, - { JT808_0x8103_0x0081_Type, typeof(JT808_0x8103_0x0081) }, - { JT808_0x8103_0x0082_Type, typeof(JT808_0x8103_0x0082) }, - { JT808_0x8103_0x0083_Type, typeof(JT808_0x8103_0x0083) }, - { JT808_0x8103_0x0084_Type, typeof(JT808_0x8103_0x0084) }, - { JT808_0x8103_0x0090_Type, typeof(JT808_0x8103_0x0090) }, - { JT808_0x8103_0x0091_Type, typeof(JT808_0x8103_0x0091) }, - { JT808_0x8103_0x0092_Type, typeof(JT808_0x8103_0x0092) }, - { JT808_0x8103_0x0093_Type, typeof(JT808_0x8103_0x0093) }, - { JT808_0x8103_0x0094_Type, typeof(JT808_0x8103_0x0094) }, - { JT808_0x8103_0x0095_Type, typeof(JT808_0x8103_0x0095) }, - { JT808_0x8103_0x0100_Type, typeof(JT808_0x8103_0x0100) }, - { JT808_0x8103_0x0101_Type, typeof(JT808_0x8103_0x0101) }, - { JT808_0x8103_0x0102_Type, typeof(JT808_0x8103_0x0102) }, - { JT808_0x8103_0x0103_Type, typeof(JT808_0x8103_0x0103) }, - { JT808_0x8103_0x0110_Type, typeof(JT808_0x8103_0x0110) } - }; - } } }