using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class SetReceiverConfigurationInfo : PacketInfoBase
{
	public override string Name => "Set Receiver Configuration";

	public override string DisplayGroup => "Receiver Control";

	public SetReceiverConfigurationInfo(SetReceiverConfiguration packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetReceiverConfiguration setReceiverConfiguration = (SetReceiverConfiguration)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Emphasis", SetReceiverConfiguration.UserFieldsWrapper.EmphasisInfo.EmphasisToDescription(), 8, FormatValue(setReceiverConfiguration.UserFields.Emphasis, 8), SetReceiverConfiguration.UserFieldsWrapper.EmphasisInfo.EmphasisToString(SetReceiverConfiguration.UserFieldsWrapper.EmphasisInfo.ValueToEmphasis(setReceiverConfiguration.UserFields.Emphasis)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Channel Spacing", SetReceiverConfiguration.UserFieldsWrapper.ChannelSpacingInfo.ChannelSpacingToDescription(), 8, FormatValue(setReceiverConfiguration.UserFields.ChannelSpacing, 8), SetReceiverConfiguration.UserFieldsWrapper.ChannelSpacingInfo.ChannelSpacingToString(SetReceiverConfiguration.UserFieldsWrapper.ChannelSpacingInfo.ValueToChannelSpacing(setReceiverConfiguration.UserFields.ChannelSpacing)), "", "2", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RDS Standard", SetReceiverConfiguration.UserFieldsWrapper.RdsStandardInfo.RdsStandardToDescription(), 8, FormatValue(setReceiverConfiguration.UserFields.RdsStandard, 8), SetReceiverConfiguration.UserFieldsWrapper.RdsStandardInfo.RdsStandardToString(SetReceiverConfiguration.UserFieldsWrapper.RdsStandardInfo.ValueToRdsStandard(setReceiverConfiguration.UserFields.RdsStandard)), "", "2", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("High And Low Side Injection", SetReceiverConfiguration.UserFieldsWrapper.HighAndLowSideInjectionInfo.HighAndLowSideInjectionToDescription(), 8, FormatValue(setReceiverConfiguration.UserFields.HighAndLowSideInjection, 8), SetReceiverConfiguration.UserFieldsWrapper.HighAndLowSideInjectionInfo.HighAndLowSideInjectionToString(SetReceiverConfiguration.UserFieldsWrapper.HighAndLowSideInjectionInfo.ValueToHighAndLowSideInjection(setReceiverConfiguration.UserFields.HighAndLowSideInjection)), "", "2", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Band Low Limit", "FM band start", 32, FormatValue(setReceiverConfiguration.UserFields.BandLowLimit, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
		fieldInfoList.Add(new PacketFieldInfo("Band High Limit", "FM band end", 32, FormatValue(setReceiverConfiguration.UserFields.BandHighLimit, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SetReceiverConfiguration setReceiverConfiguration = (SetReceiverConfiguration)packet;
		int num = -1;
		if (index == ++num)
		{
			setReceiverConfiguration.UserFields.Emphasis = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setReceiverConfiguration.UserFields.ChannelSpacing = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setReceiverConfiguration.UserFields.RdsStandard = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setReceiverConfiguration.UserFields.HighAndLowSideInjection = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setReceiverConfiguration.UserFields.BandLowLimit = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setReceiverConfiguration.UserFields.BandHighLimit = Convert.ToUInt32(value, 16);
		}
	}
}
