using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetAodTxParametersInfo : PacketInfoBase
{
	public override string Name => "Le Set Aod Tx Parameters";

	public override string DisplayGroup => "LE Controller";

	public LeSetAodTxParametersInfo(LeSetAodTxParameters packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetAodTxParameters leSetAodTxParameters = (LeSetAodTxParameters)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Number_Of_Antenna_IDs", "The number of antenna IDs defined in a sequence", 8, FormatValue(leSetAodTxParameters.UserFields.NumberOfAntennaIds, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < leSetAodTxParameters.UserFields.AntennaIdsSetList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Antenna_IDs[" + i + "]", "", 8, FormatValue(leSetAodTxParameters.UserFields.AntennaIdsSetList[i].AntennaIds, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		fieldInfoList.Add(new PacketFieldInfo("Slot_Durations", SlotDurationsInfo.SlotDurationsToDescription(), 8, FormatValue(leSetAodTxParameters.UserFields.SlotDurations, 8), SlotDurationsInfo.SlotDurationsToString(SlotDurationsInfo.ValueToSlotDurations(leSetAodTxParameters.UserFields.SlotDurations)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeSetAodTxParameters leSetAodTxParameters = (LeSetAodTxParameters)packet;
		int num = -1;
		if (index == ++num)
		{
			leSetAodTxParameters.UserFields.NumberOfAntennaIds = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < leSetAodTxParameters.UserFields.AntennaIdsSetList.Count; i++)
		{
			if (index == ++num)
			{
				leSetAodTxParameters.UserFields.AntennaIdsSetList[i].AntennaIds = Convert.ToUInt32(value, 16);
				return;
			}
		}
		if (index == ++num)
		{
			leSetAodTxParameters.UserFields.SlotDurations = Convert.ToUInt32(value, 16);
		}
	}
}
