using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class CommandCompleteForEnableReceiverInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Enable Receiver";

	public override string DisplayGroup => "Receiver Control";

	public CommandCompleteForEnableReceiverInfo(CommandCompleteForEnableReceiver packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForEnableReceiver commandCompleteForEnableReceiver = (CommandCompleteForEnableReceiver)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForEnableReceiver.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForEnableReceiver.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForEnableReceiver.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForEnableReceiver.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForEnableReceiver.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Emphasis", CommandCompleteForEnableReceiver.UserFieldsWrapper.EmphasisInfo.EmphasisToDescription(), 8, FormatValue(commandCompleteForEnableReceiver.UserFields.Emphasis, 8), CommandCompleteForEnableReceiver.UserFieldsWrapper.EmphasisInfo.EmphasisToString(CommandCompleteForEnableReceiver.UserFieldsWrapper.EmphasisInfo.ValueToEmphasis(commandCompleteForEnableReceiver.UserFields.Emphasis)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Channel Spacing", CommandCompleteForEnableReceiver.UserFieldsWrapper.ChannelSpacingInfo.ChannelSpacingToDescription(), 8, FormatValue(commandCompleteForEnableReceiver.UserFields.ChannelSpacing, 8), CommandCompleteForEnableReceiver.UserFieldsWrapper.ChannelSpacingInfo.ChannelSpacingToString(CommandCompleteForEnableReceiver.UserFieldsWrapper.ChannelSpacingInfo.ValueToChannelSpacing(commandCompleteForEnableReceiver.UserFields.ChannelSpacing)), "", "2", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RDS Standard", CommandCompleteForEnableReceiver.UserFieldsWrapper.RdsStandardInfo.RdsStandardToDescription(), 8, FormatValue(commandCompleteForEnableReceiver.UserFields.RdsStandard, 8), CommandCompleteForEnableReceiver.UserFieldsWrapper.RdsStandardInfo.RdsStandardToString(CommandCompleteForEnableReceiver.UserFieldsWrapper.RdsStandardInfo.ValueToRdsStandard(commandCompleteForEnableReceiver.UserFields.RdsStandard)), "", "2", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("High And Low Side Injection", CommandCompleteForEnableReceiver.UserFieldsWrapper.HighAndLowSideInjectionInfo.HighAndLowSideInjectionToDescription(), 8, FormatValue(commandCompleteForEnableReceiver.UserFields.HighAndLowSideInjection, 8), CommandCompleteForEnableReceiver.UserFieldsWrapper.HighAndLowSideInjectionInfo.HighAndLowSideInjectionToString(CommandCompleteForEnableReceiver.UserFieldsWrapper.HighAndLowSideInjectionInfo.ValueToHighAndLowSideInjection(commandCompleteForEnableReceiver.UserFields.HighAndLowSideInjection)), "", "2", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Band Low Limit", "FM band start", 32, FormatValue(commandCompleteForEnableReceiver.UserFields.BandLowLimit, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
		fieldInfoList.Add(new PacketFieldInfo("Band High Limit", "FM band end", 32, FormatValue(commandCompleteForEnableReceiver.UserFields.BandHighLimit, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
	}

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