using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class QbceQcmSwitchPhyInfo : PacketInfoBase
{
	public override string Name => "Qbce Qcm Switch Phy";

	public override string DisplayGroup => "Vendor Specific";

	public QbceQcmSwitchPhyInfo(QbceQcmSwitchPhy packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		QbceQcmSwitchPhy qbceQcmSwitchPhy = (QbceQcmSwitchPhy)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Subopcode", "HCI_VS_QBCE_QCM_SWITCH_PHY", 8, FormatValue(qbceQcmSwitchPhy.UserFields.Subopcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection_Handle to be used to identify a connection. Range:0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use)", 16, FormatValue(qbceQcmSwitchPhy.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PHY", QbceQcmSwitchPhy.UserFieldsWrapper.PhyInfo.PhyToDescription(), 8, FormatValue(qbceQcmSwitchPhy.UserFields.Phy, 8), QbceQcmSwitchPhy.UserFieldsWrapper.PhyInfo.PhyToString(QbceQcmSwitchPhy.UserFieldsWrapper.PhyInfo.ValueToPhy(qbceQcmSwitchPhy.UserFields.Phy)), "0", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		QbceQcmSwitchPhy qbceQcmSwitchPhy = (QbceQcmSwitchPhy)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Subopcode");
		}
		if (index == ++num)
		{
			qbceQcmSwitchPhy.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			qbceQcmSwitchPhy.UserFields.Phy = Convert.ToUInt32(value, 16);
		}
	}
}
