using System;
using QCRPG.Framework;

namespace QCRPG.TSL.ZigBee.Packets;

public class MlmeRxEnableInfo : PacketInfoBase
{
	public override string Name => "Mlme Rx Enable";

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

	public MlmeRxEnableInfo(MlmeRxEnable packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		MlmeRxEnable mlmeRxEnable = (MlmeRxEnable)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("DeferPermit", "TRUE if the requested operation can be deferred until the next superframe if the requested time has already passed. FALSE if the requested operation is only to be attempted in the current superframe. This parameter is ignored for nonbeacon-enabled PANs", 8, FormatValue(mlmeRxEnable.UserFields.Deferpermit, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RxOnTime", "The number of symbols measured from the start of the superframe before the receiver is to be enabled or disabled. This is a 24-bit value, and the precision of this value shall be a minimum of 20 bits, with the lowest 4 bits being the least significant. This parameter is ignored for nonbeacon-enabled PANs", 32, FormatValue(mlmeRxEnable.UserFields.Rxontime, 32), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RxOnDuration", "The number of symbols for which the receiver is to be enabled", 32, FormatValue(mlmeRxEnable.UserFields.Rxonduration, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		MlmeRxEnable mlmeRxEnable = (MlmeRxEnable)packet;
		int num = -1;
		if (index == ++num)
		{
			mlmeRxEnable.UserFields.Deferpermit = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeRxEnable.UserFields.Rxontime = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeRxEnable.UserFields.Rxonduration = Convert.ToUInt32(value, 16);
		}
	}
}
