Skip to content

Commit

Permalink
修复里程数据类型
Browse files Browse the repository at this point in the history
  • Loading branch information
yedajiang44 committed Aug 7, 2024
1 parent 7f6924b commit d7b320c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/JT808.Protocol.Test/MessageBody/JT808_0x0200Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void Test2()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
}

Expand Down Expand Up @@ -215,7 +215,7 @@ public void Test4()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
var jT808LocationAttachImpl0x61 = (JT808LocationAttachImpl0x61)jT808UploadLocationRequest.CustomLocationAttachData[0x61];
Assert.Equal(18, jT808LocationAttachImpl0x61.Age);
Expand Down Expand Up @@ -307,7 +307,7 @@ public void Test5()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
}
[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/JT808.Protocol.Test/MessageBody/JT808_0x0201Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void Test2()
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.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808_0X0201.Position.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808_0X0201.Position.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
}

Expand Down
2 changes: 1 addition & 1 deletion src/JT808.Protocol.Test/MessageBody/JT808_0x0500Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void Test2()
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.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)JT808Bodies.JT808_0x0200.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)JT808Bodies.JT808_0x0200.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
}

Expand Down
4 changes: 2 additions & 2 deletions src/JT808.Protocol.Test/MessageBody/JT808_0x0704Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void Test2()
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].BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)JT808Bodies.Positions[0].BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)JT808Bodies.Positions[0].BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);

Assert.Equal((uint)2, JT808Bodies.Positions[1].AlarmFlag);
Expand All @@ -153,7 +153,7 @@ public void Test2()
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].BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(96u, ((JT808_0x0200_0x01)JT808Bodies.Positions[1].BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(66, ((JT808_0x0200_0x02)JT808Bodies.Positions[1].BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
}

Expand Down
12 changes: 6 additions & 6 deletions src/JT808.Protocol.Test/Simples/Demo10.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void Test2_1_1()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal(2u, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
var jT808LocationAttachImpl0XDF = (JT808LocationAttachImpl0xDF)jT808UploadLocationRequest.CustomLocationAttachData[0xDF];
Assert.Equal(0xDF, jT808LocationAttachImpl0XDF.AttachInfoId);
Expand Down Expand Up @@ -167,7 +167,7 @@ public void Test2_2_2()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal(2u, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
var jT808LocationAttachImpl0XDD = (JT808LocationAttachImpl0xDD)jT808UploadLocationRequest.CustomLocationAttachData3[0xDD];
Assert.Equal(0xDD, jT808LocationAttachImpl0XDD.AttachInfoId);
Expand Down Expand Up @@ -231,7 +231,7 @@ public void Test2_2_1()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal(2u, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
var jT808LocationAttachImpl0XDE = (JT808LocationAttachImpl0xDE)jT808UploadLocationRequest.CustomLocationAttachData2[0xDE];
Assert.Equal(0xDE, jT808LocationAttachImpl0XDE.AttachInfoId);
Expand Down Expand Up @@ -295,7 +295,7 @@ public void Test2_1_4()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal(2u, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
var jT808LocationAttachImpl0X62 = (JT808LocationAttachImpl0x62)jT808UploadLocationRequest.CustomLocationAttachData4[0x62];
Assert.Equal(0x62, jT808LocationAttachImpl0X62.AttachInfoId);
Expand Down Expand Up @@ -380,7 +380,7 @@ public void Test_Mix_2()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal(2u, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);

var jT808LocationAttachImpl0X62 = (JT808LocationAttachImpl0x62)jT808UploadLocationRequest.CustomLocationAttachData4[0x62];
Expand Down Expand Up @@ -475,7 +475,7 @@ public void Test_Repeat_2()
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal(2u, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);

var jT808LocationAttachImpl0XDF = (JT808LocationAttachImpl0xDF)jT808UploadLocationRequest.CustomLocationAttachData[0xDF];
Expand Down
2 changes: 1 addition & 1 deletion src/JT808.Protocol.Test/Simples/Demo2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Test1()
Assert.Equal(0, jT808_0x0200.Direction);
Assert.Equal((uint)2, jT808_0x0200.StatusFlag);
//4.1.附加信息1
Assert.Equal(100, ((JT808_0x0200_0x01)jT808_0x0200.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
Assert.Equal(100u, ((JT808_0x0200_0x01)jT808_0x0200.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage);
//4.2.附加信息2
Assert.Equal(125, ((JT808_0x0200_0x02)jT808_0x0200.BasicLocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil);
}
Expand Down
8 changes: 4 additions & 4 deletions src/JT808.Protocol/MessageBody/JT808_0x0200_0x01.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class JT808_0x0200_0x01 : JT808MessagePackFormatter<JT808_0x0200_0x01>, J
/// <summary>
/// 里程
/// </summary>
public int Mileage { get; set; }
public uint Mileage { get; set; }
/// <summary>
/// 里程 1/10km,对应车上里程表读数
/// </summary>
Expand All @@ -42,7 +42,7 @@ public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJ
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId);
value.AttachInfoLength = reader.ReadByte();
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength);
value.Mileage = reader.ReadInt32();
value.Mileage = reader.ReadUInt32();
writer.WriteNumber($"[{value.Mileage.ReadNumber()}]里程", value.Mileage);
}
/// <summary>
Expand All @@ -56,7 +56,7 @@ public override JT808_0x0200_0x01 Deserialize(ref JT808MessagePackReader reader,
JT808_0x0200_0x01 value = new JT808_0x0200_0x01();
value.AttachInfoId = reader.ReadByte();
value.AttachInfoLength = reader.ReadByte();
value.Mileage = reader.ReadInt32();
value.Mileage = reader.ReadUInt32();
return value;
}
/// <summary>
Expand All @@ -69,7 +69,7 @@ public override void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0
{
writer.WriteByte(value.AttachInfoId);
writer.WriteByte(value.AttachInfoLength);
writer.WriteInt32(value.Mileage);
writer.WriteUInt32(value.Mileage);
}
}
}

0 comments on commit d7b320c

Please sign in to comment.