using System;
using QCRPG.Framework;

namespace QCRPG.TSL.ZigBee.Packets;

public class MlmeSetMacDeviceTableInfo : PacketInfoBase
{
	public override string Name => "Mlme Set Mac Device Table";

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

	public MlmeSetMacDeviceTableInfo(MlmeSetMacDeviceTable packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		MlmeSetMacDeviceTable mlmeSetMacDeviceTable = (MlmeSetMacDeviceTable)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("PIBAttribute", "The identifier of the PIB attribute to write", 8, FormatValue(mlmeSetMacDeviceTable.UserFields.Pibattribute, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PIBAttributeIndex", "", 8, FormatValue(mlmeSetMacDeviceTable.UserFields.Pibattributeindex, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PIBAttributeLength", "", 8, FormatValue(mlmeSetMacDeviceTable.UserFields.Pibattributelength, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PanID", "", 16, FormatValue(mlmeSetMacDeviceTable.UserFields.Panid, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ShortAddress", "", 16, FormatValue(mlmeSetMacDeviceTable.UserFields.Shortaddress, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ExtAddress", "", 64, FormatValue(mlmeSetMacDeviceTable.UserFields.Extaddress, 64), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("FrameCounter", "", 32, FormatValue(mlmeSetMacDeviceTable.UserFields.Framecounter, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Flags", "", 16, FormatValue(mlmeSetMacDeviceTable.UserFields.Flags, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("KeyTableIndex", "", 8, FormatValue(mlmeSetMacDeviceTable.UserFields.Keytableindex, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		MlmeSetMacDeviceTable mlmeSetMacDeviceTable = (MlmeSetMacDeviceTable)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Pibattribute");
		}
		if (index == ++num)
		{
			mlmeSetMacDeviceTable.UserFields.Pibattributeindex = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSetMacDeviceTable.UserFields.Pibattributelength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSetMacDeviceTable.UserFields.Panid = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSetMacDeviceTable.UserFields.Shortaddress = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSetMacDeviceTable.UserFields.Extaddress = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSetMacDeviceTable.UserFields.Framecounter = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSetMacDeviceTable.UserFields.Flags = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSetMacDeviceTable.UserFields.Keytableindex = Convert.ToUInt32(value, 16);
		}
	}
}
