using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeReceiverTestV3Info : PacketInfoBase
{
	public override string Name => "Le Receiver Test V3";

	public override string DisplayGroup => "LE Controller";

	public LeReceiverTestV3Info(LeReceiverTestV3 packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeReceiverTestV3 leReceiverTestV = (LeReceiverTestV3)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("RX_Channel", "Channel number. N = (F - 2402) / 2; 0x00 = 2402MHz; 0x27 = 2480MHz", 8, FormatValue(leReceiverTestV.UserFields.RxChannel, 8), CteFrequencyValueExpression.CteFrequencyValueToString(leReceiverTestV.UserFields.RxChannel), "", "27", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PHY", LeReceiverTestV3.UserFieldsWrapper.PhyInfo.PhyToDescription(), 8, FormatValue(leReceiverTestV.UserFields.Phy, 8), LeReceiverTestV3.UserFieldsWrapper.PhyInfo.PhyToString(LeReceiverTestV3.UserFieldsWrapper.PhyInfo.ValueToPhy(leReceiverTestV.UserFields.Phy)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Modulation_Index", LeReceiverTestV3.UserFieldsWrapper.ModulationIndexInfo.ModulationIndexToDescription(), 8, FormatValue(leReceiverTestV.UserFields.ModulationIndex, 8), LeReceiverTestV3.UserFieldsWrapper.ModulationIndexInfo.ModulationIndexToString(LeReceiverTestV3.UserFieldsWrapper.ModulationIndexInfo.ValueToModulationIndex(leReceiverTestV.UserFields.ModulationIndex)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Expected_CTE_Length", LeReceiverTestV3.UserFieldsWrapper.ExpectedCteLengthInfo.ExpectedCteLengthToDescription(), 8, FormatValue(leReceiverTestV.UserFields.ExpectedCteLength, 8), LeReceiverTestV3.UserFieldsWrapper.ExpectedCteLengthInfo.ExpectedCteLengthToString(LeReceiverTestV3.UserFieldsWrapper.ExpectedCteLengthInfo.ValueToExpectedCteLength(leReceiverTestV.UserFields.ExpectedCteLength)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Expected_CTE_Type", LeReceiverTestV3.UserFieldsWrapper.ExpectedCteTypeInfo.ExpectedCteTypeToDescription(), 8, FormatValue(leReceiverTestV.UserFields.ExpectedCteType, 8), LeReceiverTestV3.UserFieldsWrapper.ExpectedCteTypeInfo.ExpectedCteTypeToString(LeReceiverTestV3.UserFieldsWrapper.ExpectedCteTypeInfo.ValueToExpectedCteType(leReceiverTestV.UserFields.ExpectedCteType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Slot_Durations", LeReceiverTestV3.UserFieldsWrapper.SlotDurationsInfo.SlotDurationsToDescription(), 8, FormatValue(leReceiverTestV.UserFields.SlotDurations, 8), LeReceiverTestV3.UserFieldsWrapper.SlotDurationsInfo.SlotDurationsToString(LeReceiverTestV3.UserFieldsWrapper.SlotDurationsInfo.ValueToSlotDurations(leReceiverTestV.UserFields.SlotDurations)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Length_Of_Switching_Pattern", LeReceiverTestV3.UserFieldsWrapper.LengthOfSwitchingPatternInfo.LengthOfSwitchingPatternToDescription(), 8, FormatValue(leReceiverTestV.UserFields.LengthOfSwitchingPattern, 8), LeReceiverTestV3.UserFieldsWrapper.LengthOfSwitchingPatternInfo.LengthOfSwitchingPatternToString(LeReceiverTestV3.UserFieldsWrapper.LengthOfSwitchingPatternInfo.ValueToLengthOfSwitchingPattern(leReceiverTestV.UserFields.LengthOfSwitchingPattern)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < leReceiverTestV.UserFields.AntennaIdsSetList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Antenna_IDs[" + i + "]", "", 8, FormatValue(leReceiverTestV.UserFields.AntennaIdsSetList[i].AntennaIds, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeReceiverTestV3 leReceiverTestV = (LeReceiverTestV3)packet;
		int num = -1;
		if (index == ++num)
		{
			leReceiverTestV.UserFields.RxChannel = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leReceiverTestV.UserFields.Phy = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leReceiverTestV.UserFields.ModulationIndex = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leReceiverTestV.UserFields.ExpectedCteLength = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leReceiverTestV.UserFields.ExpectedCteType = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leReceiverTestV.UserFields.SlotDurations = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leReceiverTestV.UserFields.LengthOfSwitchingPattern = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < leReceiverTestV.UserFields.AntennaIdsSetList.Count; i++)
		{
			if (index == ++num)
			{
				leReceiverTestV.UserFields.AntennaIdsSetList[i].AntennaIds = Convert.ToUInt32(value, 16);
				break;
			}
		}
	}
}
