using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HciVsDebugCalculateRomCrcEventInfo : PacketInfoBase
{
	public override string Name => "Hci Vs Debug Calculate Rom Crc Event";

	public override string DisplayGroup => "Vendor Specific";

	public HciVsDebugCalculateRomCrcEventInfo(HciVsDebugCalculateRomCrcEvent packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HciVsDebugCalculateRomCrcEvent hciVsDebugCalculateRomCrcEvent = (HciVsDebugCalculateRomCrcEvent)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", HciVsDebugCalculateRomCrcEvent.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(hciVsDebugCalculateRomCrcEvent.UserFields.SubOpcode, 8), HciVsDebugCalculateRomCrcEvent.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(HciVsDebugCalculateRomCrcEvent.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(hciVsDebugCalculateRomCrcEvent.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(hciVsDebugCalculateRomCrcEvent.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(hciVsDebugCalculateRomCrcEvent.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ROM_CRC", "", 32, FormatValue(hciVsDebugCalculateRomCrcEvent.UserFields.RomCrc, 32), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HciVsDebugCalculateRomCrcEvent hciVsDebugCalculateRomCrcEvent = (HciVsDebugCalculateRomCrcEvent)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			hciVsDebugCalculateRomCrcEvent.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciVsDebugCalculateRomCrcEvent.UserFields.RomCrc = Convert.ToUInt32(value, 16);
		}
	}
}
