using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class CommandCompleteForGetProgramServiceInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Get Program Service";

	public override string DisplayGroup => "Receiver Control";

	public CommandCompleteForGetProgramServiceInfo(CommandCompleteForGetProgramService packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForGetProgramService commandCompleteForGetProgramService = (CommandCompleteForGetProgramService)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForGetProgramService.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForGetProgramService.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForGetProgramService.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForGetProgramService.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForGetProgramService.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Program Identification", "The RDS/RBDS program identification", 16, FormatValue(commandCompleteForGetProgramService.UserFields.ProgramIdentification, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Program Type", "The RDS/RBDS program type", 8, FormatValue(commandCompleteForGetProgramService.UserFields.ProgramType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Traffic Program Code Flag", CommandCompleteForGetProgramService.UserFieldsWrapper.TrafficProgramCodeFlagInfo.TrafficProgramCodeFlagToDescription(), 8, FormatValue(commandCompleteForGetProgramService.UserFields.TrafficProgramCodeFlag, 8), CommandCompleteForGetProgramService.UserFieldsWrapper.TrafficProgramCodeFlagInfo.TrafficProgramCodeFlagToString(CommandCompleteForGetProgramService.UserFieldsWrapper.TrafficProgramCodeFlagInfo.ValueToTrafficProgramCodeFlag(commandCompleteForGetProgramService.UserFields.TrafficProgramCodeFlag)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Traffic Announcement Code Flag", CommandCompleteForGetProgramService.UserFieldsWrapper.TrafficAnnouncementCodeFlagInfo.TrafficAnnouncementCodeFlagToDescription(), 8, FormatValue(commandCompleteForGetProgramService.UserFields.TrafficAnnouncementCodeFlag, 8), CommandCompleteForGetProgramService.UserFieldsWrapper.TrafficAnnouncementCodeFlagInfo.TrafficAnnouncementCodeFlagToString(CommandCompleteForGetProgramService.UserFieldsWrapper.TrafficAnnouncementCodeFlagInfo.ValueToTrafficAnnouncementCodeFlag(commandCompleteForGetProgramService.UserFields.TrafficAnnouncementCodeFlag)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Music Speech Switch Code Flag", CommandCompleteForGetProgramService.UserFieldsWrapper.MusicSpeechSwitchCodeFlagInfo.MusicSpeechSwitchCodeFlagToDescription(), 8, FormatValue(commandCompleteForGetProgramService.UserFields.MusicSpeechSwitchCodeFlag, 8), CommandCompleteForGetProgramService.UserFieldsWrapper.MusicSpeechSwitchCodeFlagInfo.MusicSpeechSwitchCodeFlagToString(CommandCompleteForGetProgramService.UserFieldsWrapper.MusicSpeechSwitchCodeFlagInfo.ValueToMusicSpeechSwitchCodeFlag(commandCompleteForGetProgramService.UserFields.MusicSpeechSwitchCodeFlag)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Decoder Identification Code Flag", CommandCompleteForGetProgramService.UserFieldsWrapper.DecoderIdentificationCodeFlagInfo.DecoderIdentificationCodeFlagToDescription(), 8, FormatValue(commandCompleteForGetProgramService.UserFields.DecoderIdentificationCodeFlag, 8), CommandCompleteForGetProgramService.UserFieldsWrapper.DecoderIdentificationCodeFlagInfo.DecoderIdentificationCodeFlagToString(CommandCompleteForGetProgramService.UserFieldsWrapper.DecoderIdentificationCodeFlagInfo.ValueToDecoderIdentificationCodeFlag(commandCompleteForGetProgramService.UserFields.DecoderIdentificationCodeFlag)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number Of Valid Program Service Strings", "", 8, FormatValue(commandCompleteForGetProgramService.UserFields.NumberOfValidProgramServiceStrings, 8), "", "", "C", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < commandCompleteForGetProgramService.UserFields.ProgramServiceNameList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Name String[" + i + "]", "", 64, FormatValue(commandCompleteForGetProgramService.UserFields.ProgramServiceNameList[i].NameString, 64), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("Null Terminator[" + i + "]", "", 8, FormatValue(commandCompleteForGetProgramService.UserFields.ProgramServiceNameList[i].NullTerminator, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CommandCompleteForGetProgramService commandCompleteForGetProgramService = (CommandCompleteForGetProgramService)packet;
		int num = -1;
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.NumHciCommandPackets = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field CommandOpcode");
		}
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.Status = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.ProgramIdentification = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.ProgramType = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.TrafficProgramCodeFlag = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.TrafficAnnouncementCodeFlag = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.MusicSpeechSwitchCodeFlag = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.DecoderIdentificationCodeFlag = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			commandCompleteForGetProgramService.UserFields.NumberOfValidProgramServiceStrings = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < commandCompleteForGetProgramService.UserFields.ProgramServiceNameList.Count; i++)
		{
			if (index == ++num)
			{
				commandCompleteForGetProgramService.UserFields.ProgramServiceNameList[i].NameString = Convert.ToUInt64(value, 16);
				break;
			}
			if (index == ++num)
			{
				commandCompleteForGetProgramService.UserFields.ProgramServiceNameList[i].NullTerminator = Convert.ToUInt32(value, 16);
				break;
			}
		}
	}
}
