using System;
using QCRPG.Framework;

namespace QCRPG.TSL.ZigBee.Packets;

public class VsDutTxRawConfirmationInfo : PacketInfoBase
{
	public override string Name => "Vs Dut Tx Raw Confirmation";

	public override string DisplayGroup => "MLME Confirmation Packets";

	public VsDutTxRawConfirmationInfo(VsDutTxRawConfirmation packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		VsDutTxRawConfirmation vsDutTxRawConfirmation = (VsDutTxRawConfirmation)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("PacketLength", "", 32, FormatValue(vsDutTxRawConfirmation.UserFields.Packetlength, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ProtocolID", "ProtocolID\r\n\r\n" + ProtocolIdInfo.ProtocolIdToDescription(), 8, FormatValue(vsDutTxRawConfirmation.UserFields.Protocolid, 8), ProtocolIdInfo.ProtocolIdToString(ProtocolIdInfo.ValueToProtocolId(vsDutTxRawConfirmation.UserFields.Protocolid)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Event Code", CommandOpcodeInfo.CommandOpcodeToDescription(), 8, FormatValue(vsDutTxRawConfirmation.UserFields.EventCode, 8), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(vsDutTxRawConfirmation.UserFields.EventCode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Length", "Payload Length", 16, FormatValue(vsDutTxRawConfirmation.UserFields.Length, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", "Status\r\n\r\n" + ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(vsDutTxRawConfirmation.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(vsDutTxRawConfirmation.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		VsDutTxRawConfirmation vsDutTxRawConfirmation = (VsDutTxRawConfirmation)packet;
		int num = -1;
		if (index == ++num)
		{
			vsDutTxRawConfirmation.UserFields.Packetlength = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			vsDutTxRawConfirmation.UserFields.Protocolid = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field EventCode");
		}
		if (index == ++num)
		{
			vsDutTxRawConfirmation.UserFields.Length = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsDutTxRawConfirmation.UserFields.Status = Convert.ToUInt32(value, 16);
		}
	}
}
