using JT808.Protocol.Enums;
using JT808.Protocol.Extensions;
using JT808.Protocol.Formatters;
using JT808.Protocol.Interfaces;
using JT808.Protocol.MessagePack;
using System.Text.Json;
namespace JT808.Protocol.MessageBody
{
///
/// 平台通用应答
///
public class JT808_0x8001 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze
{
///
/// 0x8001
///
public override ushort MsgId { get; } = 0x8001;
///
/// 平台通用应答
///
public override string Description => "平台通用应答";
///
/// 应答消息流水号
///
public ushort MsgNum { get; set; }
///
/// 应答消息Id
///
///
public ushort AckMsgId { get; set; }
///
/// 返回结果
///
///
public JT808PlatformResult JT808PlatformResult { get; set; }
///
///
///
///
///
///
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
{
JT808_0x8001 value = new JT808_0x8001();
value.MsgNum = reader.ReadUInt16();
writer.WriteNumber($"[{value.MsgNum.ReadNumber()}]应答消息流水号", value.MsgNum);
value.AckMsgId = reader.ReadUInt16();
writer.WriteNumber($"[{value.AckMsgId.ReadNumber()}]应答消息Id", value.AckMsgId);
value.JT808PlatformResult = (JT808PlatformResult)reader.ReadByte();
writer.WriteNumber($"[{((byte)value.JT808PlatformResult).ReadNumber()}]结果-{value.JT808PlatformResult.ToString()}", (byte)value.JT808PlatformResult);
}
///
///
///
///
///
///
public JT808_0x8001 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
{
JT808_0x8001 value = new JT808_0x8001();
value.MsgNum = reader.ReadUInt16();
value.AckMsgId = reader.ReadUInt16();
value.JT808PlatformResult = (JT808PlatformResult)reader.ReadByte();
return value;
}
///
///
///
///
///
///
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8001 value, IJT808Config config)
{
writer.WriteUInt16(value.MsgNum);
writer.WriteUInt16(value.AckMsgId);
writer.WriteByte((byte)value.JT808PlatformResult);
}
}
}