using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class SetTransmitterConfigurationInfo : PacketInfoBase
{
	public override string Name => "Set Transmitter Configuration";

	public override string DisplayGroup => "Transmitter Control";

	public SetTransmitterConfigurationInfo(SetTransmitterConfiguration packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetTransmitterConfiguration setTransmitterConfiguration = (SetTransmitterConfiguration)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Emphasis", SetTransmitterConfiguration.UserFieldsWrapper.EmphasisInfo.EmphasisToDescription(), 8, FormatValue(setTransmitterConfiguration.UserFields.Emphasis, 8), SetTransmitterConfiguration.UserFieldsWrapper.EmphasisInfo.EmphasisToString(SetTransmitterConfiguration.UserFieldsWrapper.EmphasisInfo.ValueToEmphasis(setTransmitterConfiguration.UserFields.Emphasis)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RDS Standard", SetTransmitterConfiguration.UserFieldsWrapper.RdsStandardInfo.RdsStandardToDescription(), 8, FormatValue(setTransmitterConfiguration.UserFields.RdsStandard, 8), SetTransmitterConfiguration.UserFieldsWrapper.RdsStandardInfo.RdsStandardToString(SetTransmitterConfiguration.UserFieldsWrapper.RdsStandardInfo.ValueToRdsStandard(setTransmitterConfiguration.UserFields.RdsStandard)), "", "2", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Band Low Limit", "FM band start", 32, FormatValue(setTransmitterConfiguration.UserFields.BandLowLimit, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
		fieldInfoList.Add(new PacketFieldInfo("Band High Limit", "FM band end", 32, FormatValue(setTransmitterConfiguration.UserFields.BandHighLimit, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
	}

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