using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class CommandCompleteForGetTransmitterConfigurationInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Get Transmitter Configuration";

	public override string DisplayGroup => "Transmitter Control";

	public CommandCompleteForGetTransmitterConfigurationInfo(CommandCompleteForGetTransmitterConfiguration packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForGetTransmitterConfiguration commandCompleteForGetTransmitterConfiguration = (CommandCompleteForGetTransmitterConfiguration)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForGetTransmitterConfiguration.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForGetTransmitterConfiguration.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForGetTransmitterConfiguration.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForGetTransmitterConfiguration.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForGetTransmitterConfiguration.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Emphasis", CommandCompleteForGetTransmitterConfiguration.UserFieldsWrapper.EmphasisInfo.EmphasisToDescription(), 8, FormatValue(commandCompleteForGetTransmitterConfiguration.UserFields.Emphasis, 8), CommandCompleteForGetTransmitterConfiguration.UserFieldsWrapper.EmphasisInfo.EmphasisToString(CommandCompleteForGetTransmitterConfiguration.UserFieldsWrapper.EmphasisInfo.ValueToEmphasis(commandCompleteForGetTransmitterConfiguration.UserFields.Emphasis)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RDS Standard", CommandCompleteForGetTransmitterConfiguration.UserFieldsWrapper.RdsStandardInfo.RdsStandardToDescription(), 8, FormatValue(commandCompleteForGetTransmitterConfiguration.UserFields.RdsStandard, 8), CommandCompleteForGetTransmitterConfiguration.UserFieldsWrapper.RdsStandardInfo.RdsStandardToString(CommandCompleteForGetTransmitterConfiguration.UserFieldsWrapper.RdsStandardInfo.ValueToRdsStandard(commandCompleteForGetTransmitterConfiguration.UserFields.RdsStandard)), "", "2", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Band Low Limit", "FM band start", 32, FormatValue(commandCompleteForGetTransmitterConfiguration.UserFields.BandLowLimit, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
		fieldInfoList.Add(new PacketFieldInfo("Band High Limit", "FM band end", 32, FormatValue(commandCompleteForGetTransmitterConfiguration.UserFields.BandHighLimit, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CommandCompleteForGetTransmitterConfiguration commandCompleteForGetTransmitterConfiguration = (CommandCompleteForGetTransmitterConfiguration)packet;
		int num = -1;
		if (index == ++num)
		{
			commandCompleteForGetTransmitterConfiguration.UserFields.NumHciCommandPackets = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field CommandOpcode");
		}
		if (index == ++num)
		{
			commandCompleteForGetTransmitterConfiguration.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetTransmitterConfiguration.UserFields.Emphasis = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetTransmitterConfiguration.UserFields.RdsStandard = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetTransmitterConfiguration.UserFields.BandLowLimit = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetTransmitterConfiguration.UserFields.BandHighLimit = Convert.ToUInt32(value, 16);
		}
	}
}
