using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class SearchRdsStationsInfo : PacketInfoBase
{
	public override string Name => "Search Rds Stations";

	public override string DisplayGroup => "Receiver Control";

	public SearchRdsStationsInfo(SearchRdsStations packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SearchRdsStations searchRdsStations = (SearchRdsStations)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Search Mode", SearchRdsStations.UserFieldsWrapper.SearchModeInfo.SearchModeToDescription(), 8, FormatValue(searchRdsStations.UserFields.SearchMode, 8), SearchRdsStations.UserFieldsWrapper.SearchModeInfo.SearchModeToString(SearchRdsStations.UserFieldsWrapper.SearchModeInfo.ValueToSearchMode(searchRdsStations.UserFields.SearchMode)), "", "3", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Scan Time", SearchRdsStations.UserFieldsWrapper.ScanTimeInfo.ScanTimeToDescription(), 8, FormatValue(searchRdsStations.UserFields.ScanTime, 8), SearchRdsStations.UserFieldsWrapper.ScanTimeInfo.ScanTimeToString(SearchRdsStations.UserFieldsWrapper.ScanTimeInfo.ValueToScanTime(searchRdsStations.UserFields.ScanTime)), "", "F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Search Direction", SearchRdsStations.UserFieldsWrapper.SearchDirectionInfo.SearchDirectionToDescription(), 8, FormatValue(searchRdsStations.UserFields.SearchDirection, 8), SearchRdsStations.UserFieldsWrapper.SearchDirectionInfo.SearchDirectionToString(SearchRdsStations.UserFieldsWrapper.SearchDirectionInfo.ValueToSearchDirection(searchRdsStations.UserFields.SearchDirection)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Program Type", "The RDS/RBDS program type", 8, FormatValue(searchRdsStations.UserFields.ProgramType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Program Identification", "The RDS/RBDS program identification", 16, FormatValue(searchRdsStations.UserFields.ProgramIdentification, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SearchRdsStations searchRdsStations = (SearchRdsStations)packet;
		int num = -1;
		if (index == ++num)
		{
			searchRdsStations.UserFields.SearchMode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			searchRdsStations.UserFields.ScanTime = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			searchRdsStations.UserFields.SearchDirection = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			searchRdsStations.UserFields.ProgramType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			searchRdsStations.UserFields.ProgramIdentification = Convert.ToUInt32(value, 16);
		}
	}
}
