using System;
using QCRPG.Framework;

namespace QCRPG.TSL.NFC.Packets;

public class RfIntfActivatedNtfInfo : PacketInfoBase
{
	public override string Name => "Rf Intf Activated Ntf";

	public override string DisplayGroup => "RF Management";

	public RfIntfActivatedNtfInfo(RfIntfActivatedNtf packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		RfIntfActivatedNtf rfIntfActivatedNtf = (RfIntfActivatedNtf)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("RF Discovery ID", RfDiscoveryIdInfo.RfDiscoveryIdToDescription(), 8, FormatValue(rfIntfActivatedNtf.UserFields.RfDiscoveryId, 8), RfDiscoveryIdInfo.RfDiscoveryIdToString(RfDiscoveryIdInfo.ValueToRfDiscoveryId(rfIntfActivatedNtf.UserFields.RfDiscoveryId)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RF Interface", RfInterfacesInfo.RfInterfacesToDescription(), 8, FormatValue(rfIntfActivatedNtf.UserFields.RfInterface, 8), RfInterfacesInfo.RfInterfacesToString(RfInterfacesInfo.ValueToRfInterfaces(rfIntfActivatedNtf.UserFields.RfInterface)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RF Protocol", RfProtocolsInfo.RfProtocolsToDescription(), 8, FormatValue(rfIntfActivatedNtf.UserFields.RfProtocol, 8), RfProtocolsInfo.RfProtocolsToString(RfProtocolsInfo.ValueToRfProtocols(rfIntfActivatedNtf.UserFields.RfProtocol)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Activation RF Technology and Mode", RfTechnologyAndModeInfo.RfTechnologyAndModeToDescription(), 8, FormatValue(rfIntfActivatedNtf.UserFields.ActivationRfTechnologyAndMode, 8), RfTechnologyAndModeInfo.RfTechnologyAndModeToString(RfTechnologyAndModeInfo.ValueToRfTechnologyAndMode(rfIntfActivatedNtf.UserFields.ActivationRfTechnologyAndMode)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max Data Packet Payload Size", "Max Data Packet Payload Size the NFCC can receive for the Static RF Connection. A number from 32 – 255.", 8, FormatValue(rfIntfActivatedNtf.UserFields.MaxDataPacketPayloadSize, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Initial Number of Credits", "Initial Number of Credits given by the NFCC to the DH for the Static RF Connection.", 8, FormatValue(rfIntfActivatedNtf.UserFields.InitialNumberOfCredits, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Length of RF Technology Specific Parameters", "The length of RF Technology Specific Parameters field to follow.", 8, FormatValue(rfIntfActivatedNtf.UserFields.LengthOfRfTechnologySpecificParameters, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RF Technology Specific Parameters", "Depends on poll mode.", rfIntfActivatedNtf.UserFields.RfTechnologySpecificParametersList.Count * 8, FormatValue(rfIntfActivatedNtf.UserFields.RfTechnologySpecificParametersList, rfIntfActivatedNtf.UserFields.RfTechnologySpecificParametersList.Count * 8, includeSpaces: false), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Data Exchange RF Technology and Mode", RfTechnologyAndModeInfo.RfTechnologyAndModeToDescription(), 8, FormatValue(rfIntfActivatedNtf.UserFields.DataExchangeRfTechnologyAndMode, 8), RfTechnologyAndModeInfo.RfTechnologyAndModeToString(RfTechnologyAndModeInfo.ValueToRfTechnologyAndMode(rfIntfActivatedNtf.UserFields.DataExchangeRfTechnologyAndMode)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Data Exchange Transmit Bit Rate", BitRatesInfo.BitRatesToDescription(), 8, FormatValue(rfIntfActivatedNtf.UserFields.DataExchangeTransmitBitRate, 8), BitRatesInfo.BitRatesToString(BitRatesInfo.ValueToBitRates(rfIntfActivatedNtf.UserFields.DataExchangeTransmitBitRate)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Data Exchange Receive Bit Rate", BitRatesInfo.BitRatesToDescription(), 8, FormatValue(rfIntfActivatedNtf.UserFields.DataExchangeReceiveBitRate, 8), BitRatesInfo.BitRatesToString(BitRatesInfo.ValueToBitRates(rfIntfActivatedNtf.UserFields.DataExchangeReceiveBitRate)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Length of Activation Parameters", "The length of Activation Parameters field to follow.", 8, FormatValue(rfIntfActivatedNtf.UserFields.LengthOfActivationParameters, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Activation Parameters", "Activation Parameters are defined in the RF Interface section that corresponds to the RF Interface value. If a proprietary interface is activated, proprietary parameters MAY be used.", rfIntfActivatedNtf.UserFields.ActivationParametersList.Count * 8, FormatValue(rfIntfActivatedNtf.UserFields.ActivationParametersList, rfIntfActivatedNtf.UserFields.ActivationParametersList.Count * 8, includeSpaces: false), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		RfIntfActivatedNtf rfIntfActivatedNtf = (RfIntfActivatedNtf)packet;
		int num = -1;
		if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.RfDiscoveryId = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.RfInterface = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.RfProtocol = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.ActivationRfTechnologyAndMode = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.MaxDataPacketPayloadSize = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.InitialNumberOfCredits = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.LengthOfRfTechnologySpecificParameters = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, rfIntfActivatedNtf.UserFields.RfTechnologySpecificParametersList.Count);
			int num2 = 0;
			while (value.Length > 0)
			{
				string value2 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				rfIntfActivatedNtf.UserFields.RfTechnologySpecificParametersList[num2] = Convert.ToUInt32(value2, 16);
				num2++;
			}
		}
		if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.DataExchangeRfTechnologyAndMode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.DataExchangeTransmitBitRate = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.DataExchangeReceiveBitRate = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rfIntfActivatedNtf.UserFields.LengthOfActivationParameters = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, rfIntfActivatedNtf.UserFields.ActivationParametersList.Count);
			int num3 = 0;
			while (value.Length > 0)
			{
				string value3 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				rfIntfActivatedNtf.UserFields.ActivationParametersList[num3] = Convert.ToUInt32(value3, 16);
				num3++;
			}
		}
	}
}
