using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class CommandCompleteForGetStationParametersInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Get Station Parameters";

	public override string DisplayGroup => "Receiver Control";

	public CommandCompleteForGetStationParametersInfo(CommandCompleteForGetStationParameters packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForGetStationParameters commandCompleteForGetStationParameters = (CommandCompleteForGetStationParameters)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForGetStationParameters.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForGetStationParameters.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForGetStationParameters.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForGetStationParameters.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForGetStationParameters.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Frequency Tuned", "", 32, FormatValue(commandCompleteForGetStationParameters.UserFields.FrequencyTuned, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Service Available", CommandCompleteForGetStationParameters.UserFieldsWrapper.ServiceAvailableInfo.ServiceAvailableToDescription(), 8, FormatValue(commandCompleteForGetStationParameters.UserFields.ServiceAvailable, 8), CommandCompleteForGetStationParameters.UserFieldsWrapper.ServiceAvailableInfo.ServiceAvailableToString(CommandCompleteForGetStationParameters.UserFieldsWrapper.ServiceAvailableInfo.ValueToServiceAvailable(commandCompleteForGetStationParameters.UserFields.ServiceAvailable)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RSSI", "The current signal strength level (-120 to -20 range)", 8, FormatValue(commandCompleteForGetStationParameters.UserFields.Rssi, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Stereo Program", CommandCompleteForGetStationParameters.UserFieldsWrapper.StereoProgramInfo.StereoProgramToDescription(), 8, FormatValue(commandCompleteForGetStationParameters.UserFields.StereoProgram, 8), CommandCompleteForGetStationParameters.UserFieldsWrapper.StereoProgramInfo.StereoProgramToString(CommandCompleteForGetStationParameters.UserFieldsWrapper.StereoProgramInfo.ValueToStereoProgram(commandCompleteForGetStationParameters.UserFields.StereoProgram)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RDS Sync Status", CommandCompleteForGetStationParameters.UserFieldsWrapper.RdsSyncStatusInfo.RdsSyncStatusToDescription(), 8, FormatValue(commandCompleteForGetStationParameters.UserFields.RdsSyncStatus, 8), CommandCompleteForGetStationParameters.UserFieldsWrapper.RdsSyncStatusInfo.RdsSyncStatusToString(CommandCompleteForGetStationParameters.UserFieldsWrapper.RdsSyncStatusInfo.ValueToRdsSyncStatus(commandCompleteForGetStationParameters.UserFields.RdsSyncStatus)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Mute Mode", MuteModeInfo.MuteModeToDescription(), 8, FormatValue(commandCompleteForGetStationParameters.UserFields.MuteMode, 8), MuteModeInfo.MuteModeToString(MuteModeInfo.ValueToMuteMode(commandCompleteForGetStationParameters.UserFields.MuteMode)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SINR", "Measured sinr in dBm (signed)", 8, FormatValue(commandCompleteForGetStationParameters.UserFields.Sinr, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Interference Detector Threshold", "Measured interference detector threshold", 8, FormatValue(commandCompleteForGetStationParameters.UserFields.InterferenceDetectorThreshold, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CommandCompleteForGetStationParameters commandCompleteForGetStationParameters = (CommandCompleteForGetStationParameters)packet;
		int num = -1;
		if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.NumHciCommandPackets = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field CommandOpcode");
		}
		if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.FrequencyTuned = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.ServiceAvailable = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.Rssi = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.StereoProgram = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.RdsSyncStatus = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.MuteMode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.Sinr = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForGetStationParameters.UserFields.InterferenceDetectorThreshold = Convert.ToUInt32(value, 16);
		}
	}
}
