Skip to content

Commit

Permalink
0x0200_03海拔高度附加信息
Browse files Browse the repository at this point in the history
  • Loading branch information
capfhz committed Oct 24, 2021
1 parent e1af391 commit f9c9248
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/JT905.Protocol.Test/MessageBody/JT905_0x0200_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Test1()
// 7E
byte[] bytes = "7E0200001910010111111114A610004C00C000000000F8345603F89E38000000201014000002E97E".ToHexBytes();
JT905Package jT905Package = JT905Serializer.Deserialize(bytes);
var json = JT905Serializer.Analyze(bytes);
var json = JT905Serializer.Analyze(bytes,options:JTJsonWriterOptions.Instance);
byte[] jt905_0xB03 = "7E0B03004C10010739501709E9000018008000010000F86EDB03F83BB0000000201013133943393631393600000000000000000000003236370000000000000000000000000000000045583330353520201013134400000A65057E".ToHexBytes();
JT905Package jT905Package1 = JT905Serializer.Deserialize(bytes);
}
Expand Down
70 changes: 70 additions & 0 deletions src/JT905.Protocol/MessageBody/JT905_0x0200_0x03.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using JT905.Protocol.Extensions;
using JT905.Protocol.Interfaces;
using JT905.Protocol.MessagePack;
using System.Runtime.Serialization;
using System.Text.Json;

namespace JT905.Protocol.MessageBody
{
/// <summary>
/// 海拔高度,INT16,单位为米( m)
/// </summary>
public class JT905_0x0200_0x03 : JT905_0x0200_BodyBase, IJT905MessagePackFormatter<JT905_0x0200_0x03>, IJT905Analyze
{
/// <summary>
/// 海拔高度,INT16,单位为米( m)
/// </summary>
public ushort Altitude { get; set; }

/// <summary>
/// JT905_0x0200_0x02
/// </summary>
public override byte AttachInfoId { get; set; } = JT905Constants.JT905_0x0200_0x03;
/// <summary>
/// 2 byte
/// </summary>
public override byte AttachInfoLength { get; set; } = 2;
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="writer"></param>
/// <param name="config"></param>
public void Analyze(ref JT905MessagePackReader reader, Utf8JsonWriter writer, IJT905Config config)
{
JT905_0x0200_0x02 value = new JT905_0x0200_0x02();
value.AttachInfoId = reader.ReadByte();
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId);
value.AttachInfoLength = reader.ReadByte();
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength);
value.Oil = reader.ReadUInt16();
writer.WriteNumber($"[{value.Oil.ReadNumber()}]海拔高度,INT16,单位为米( m)", value.Oil);
}
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="config"></param>
/// <returns></returns>
public JT905_0x0200_0x03 Deserialize(ref JT905MessagePackReader reader, IJT905Config config)
{
JT905_0x0200_0x03 value = new JT905_0x0200_0x03();
value.AttachInfoId = reader.ReadByte();
value.AttachInfoLength = reader.ReadByte();
value.Altitude = reader.ReadUInt16();
return value;
}
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
/// <param name="value"></param>
/// <param name="config"></param>
public void Serialize(ref JT905MessagePackWriter writer, JT905_0x0200_0x03 value, IJT905Config config)
{
writer.WriteByte(value.AttachInfoId);
writer.WriteByte(value.AttachInfoLength);
writer.WriteUInt16(value.Altitude);
}
}
}

0 comments on commit f9c9248

Please sign in to comment.