using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class CommandCompleteForReadGroupCountersInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Read Group Counters";

	public override string DisplayGroup => "Status Parameters";

	public CommandCompleteForReadGroupCountersInfo(CommandCompleteForReadGroupCounters packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForReadGroupCounters commandCompleteForReadGroupCounters = (CommandCompleteForReadGroupCounters)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForReadGroupCounters.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForReadGroupCounters.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForReadGroupCounters.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForReadGroupCounters.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForReadGroupCounters.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Block Errors", "Total count of RDS block errors received", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsBlockErrors, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Groups Received", "Total count of RDS groups received", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsGroupsReceived, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Group 0", "Total count of RDS group type 0A/0B received", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsGroup0, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Group 2", "Total count of RDS group type 2A/2B received", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsGroup2, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Block B", "Total count of RDS groups which matched Block-B match condition", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsBlockB, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Processed Group 0", "Total count of interrupts from processing RDS group type 0A/0B", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsProcessedGroup0, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Processed Group 2", "Total count of interrupts from processing RDS group type 2A/2B", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsProcessedGroup2, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Group Filtered", "Total count of RDS groups which passed the group filter", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsGroupFiltered, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total RDS Change Filtered", "Total count of RDS groups which passed the change filter", 32, FormatValue(commandCompleteForReadGroupCounters.UserFields.TotalRdsChangeFiltered, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CommandCompleteForReadGroupCounters commandCompleteForReadGroupCounters = (CommandCompleteForReadGroupCounters)packet;
		int num = -1;
		if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.NumHciCommandPackets = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field CommandOpcode");
		}
		if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsBlockErrors = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsGroupsReceived = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsGroup0 = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsGroup2 = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsBlockB = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsProcessedGroup0 = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsProcessedGroup2 = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsGroupFiltered = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadGroupCounters.UserFields.TotalRdsChangeFiltered = Convert.ToUInt32(value, 16);
		}
	}
}
