using System;
using QCRPG.Framework;

namespace QCRPG.TSL.ZigBee.Packets;

public class MlmeSyncInfo : PacketInfoBase
{
	public override string Name => "Mlme Sync";

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

	public MlmeSyncInfo(MlmeSync packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		MlmeSync mlmeSync = (MlmeSync)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("LogicalChannel", "The logical channel on which to attempt coordinator synchronization.", 8, FormatValue(mlmeSync.UserFields.Logicalchannel, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ChannelPage", "The channel page on which to attempt coordinator synchronization.", 8, FormatValue(mlmeSync.UserFields.Channelpage, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("TrackBeacon", "TRUE if the MLME is to synchronize with the next beacon and attempt to track all future beacons. FALSE if the MLME is to synchronize with only the next beacon.", 8, FormatValue(mlmeSync.UserFields.Trackbeacon, 8), "", "00", "01", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		MlmeSync mlmeSync = (MlmeSync)packet;
		int num = -1;
		if (index == ++num)
		{
			mlmeSync.UserFields.Logicalchannel = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSync.UserFields.Channelpage = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeSync.UserFields.Trackbeacon = Convert.ToUInt32(value, 16);
		}
	}
}
