using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FM.Packets;

public class RdsAdvanceControlInfo : PacketInfoBase
{
	public override string Name => "Rds Advance Control";

	public override string DisplayGroup => "RDS Control";

	public RdsAdvanceControlInfo(RdsAdvanceControl packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		RdsAdvanceControl rdsAdvanceControl = (RdsAdvanceControl)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Register Address", RegisterMapInfo.RegisterMapToDescription(), 8, FormatValue(rdsAdvanceControl.UserFields.RegisterAddress, 8), RegisterMapInfo.RegisterMapToString(RegisterMapInfo.ValueToRegisterMap(rdsAdvanceControl.UserFields.RegisterAddress)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Undefined", "", 1, FormatValue(rdsAdvanceControl.UserFields.Undefined, 1), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Automatic AF Search", RdsAdvanceControl.UserFieldsWrapper.AutomaticAfSearchInfo.AutomaticAfSearchToDescription(), 1, FormatValue(rdsAdvanceControl.UserFields.AutomaticAfSearch, 1), RdsAdvanceControl.UserFieldsWrapper.AutomaticAfSearchInfo.AutomaticAfSearchToString(RdsAdvanceControl.UserFieldsWrapper.AutomaticAfSearchInfo.ValueToAutomaticAfSearch(rdsAdvanceControl.UserFields.AutomaticAfSearch)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Process Alternative Frequency List", RdsAdvanceControl.UserFieldsWrapper.ProcessAlternativeFrequencyListInfo.ProcessAlternativeFrequencyListToDescription(), 1, FormatValue(rdsAdvanceControl.UserFields.ProcessAlternativeFrequencyList, 1), RdsAdvanceControl.UserFieldsWrapper.ProcessAlternativeFrequencyListInfo.ProcessAlternativeFrequencyListToString(RdsAdvanceControl.UserFieldsWrapper.ProcessAlternativeFrequencyListInfo.ValueToProcessAlternativeFrequencyList(rdsAdvanceControl.UserFields.ProcessAlternativeFrequencyList)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Process Program Service Name", RdsAdvanceControl.UserFieldsWrapper.ProcessProgramServiceNameInfo.ProcessProgramServiceNameToDescription(), 1, FormatValue(rdsAdvanceControl.UserFields.ProcessProgramServiceName, 1), RdsAdvanceControl.UserFieldsWrapper.ProcessProgramServiceNameInfo.ProcessProgramServiceNameToString(RdsAdvanceControl.UserFieldsWrapper.ProcessProgramServiceNameInfo.ValueToProcessProgramServiceName(rdsAdvanceControl.UserFields.ProcessProgramServiceName)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Process Radio Text", RdsAdvanceControl.UserFieldsWrapper.ProcessRadioTextInfo.ProcessRadioTextToDescription(), 1, FormatValue(rdsAdvanceControl.UserFields.ProcessRadioText, 1), RdsAdvanceControl.UserFieldsWrapper.ProcessRadioTextInfo.ProcessRadioTextToString(RdsAdvanceControl.UserFieldsWrapper.ProcessRadioTextInfo.ValueToProcessRadioText(rdsAdvanceControl.UserFields.ProcessRadioText)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Pass Block-E", RdsAdvanceControl.UserFieldsWrapper.PassBlockEInfo.PassBlockEToDescription(), 1, FormatValue(rdsAdvanceControl.UserFields.PassBlockE, 1), RdsAdvanceControl.UserFieldsWrapper.PassBlockEInfo.PassBlockEToString(RdsAdvanceControl.UserFieldsWrapper.PassBlockEInfo.ValueToPassBlockE(rdsAdvanceControl.UserFields.PassBlockE)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Pass Uncorrectable Blocks", RdsAdvanceControl.UserFieldsWrapper.PassUncorrectableBlocksInfo.PassUncorrectableBlocksToDescription(), 1, FormatValue(rdsAdvanceControl.UserFields.PassUncorrectableBlocks, 1), RdsAdvanceControl.UserFieldsWrapper.PassUncorrectableBlocksInfo.PassUncorrectableBlocksToString(RdsAdvanceControl.UserFieldsWrapper.PassUncorrectableBlocksInfo.ValueToPassUncorrectableBlocks(rdsAdvanceControl.UserFields.PassUncorrectableBlocks)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Change Filter", RdsAdvanceControl.UserFieldsWrapper.ChangeFilterInfo.ChangeFilterToDescription(), 1, FormatValue(rdsAdvanceControl.UserFields.ChangeFilter, 1), RdsAdvanceControl.UserFieldsWrapper.ChangeFilterInfo.ChangeFilterToString(RdsAdvanceControl.UserFieldsWrapper.ChangeFilterInfo.ValueToChangeFilter(rdsAdvanceControl.UserFields.ChangeFilter)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		RdsAdvanceControl rdsAdvanceControl = (RdsAdvanceControl)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field RegisterAddress");
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Undefined");
		}
		if (index == ++num)
		{
			rdsAdvanceControl.UserFields.AutomaticAfSearch = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rdsAdvanceControl.UserFields.ProcessAlternativeFrequencyList = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rdsAdvanceControl.UserFields.ProcessProgramServiceName = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rdsAdvanceControl.UserFields.ProcessRadioText = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rdsAdvanceControl.UserFields.PassBlockE = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rdsAdvanceControl.UserFields.PassUncorrectableBlocks = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rdsAdvanceControl.UserFields.ChangeFilter = Convert.ToUInt32(value, 16);
		}
	}
}
