using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LtPhyTestModeInfo : PacketInfoBase
{
	public override string Name => "Lt Phy Test Mode";

	public override string DisplayGroup => "Vendor Specific";

	public LtPhyTestModeInfo(LtPhyTestMode packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LtPhyTestMode ltPhyTestMode = (LtPhyTestMode)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", "Set PHY test parameters", 8, FormatValue(ltPhyTestMode.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Enable", LtPhyTestMode.UserFieldsWrapper.EnableInfo.EnableToDescription(), 8, FormatValue(ltPhyTestMode.UserFields.Enable, 8), LtPhyTestMode.UserFieldsWrapper.EnableInfo.EnableToString(LtPhyTestMode.UserFieldsWrapper.EnableInfo.ValueToEnable(ltPhyTestMode.UserFields.Enable)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PHY_Test_Mode", LtPhyTestMode.UserFieldsWrapper.PhyTestModeInfo.PhyTestModeToDescription(), 8, FormatValue(ltPhyTestMode.UserFields.PhyTestMode, 8), LtPhyTestMode.UserFieldsWrapper.PhyTestModeInfo.PhyTestModeToString(LtPhyTestMode.UserFieldsWrapper.PhyTestModeInfo.ValueToPhyTestMode(ltPhyTestMode.UserFields.PhyTestMode)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PHY_M2S", "", 8, FormatValue(ltPhyTestMode.UserFields.PhyM2s, 8), "", "01", "04", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PHY_S2M", "", 8, FormatValue(ltPhyTestMode.UserFields.PhyS2m, 8), "", "01", "04", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LtPhyTestMode ltPhyTestMode = (LtPhyTestMode)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			ltPhyTestMode.UserFields.Enable = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ltPhyTestMode.UserFields.PhyTestMode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ltPhyTestMode.UserFields.PhyM2s = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ltPhyTestMode.UserFields.PhyS2m = Convert.ToUInt32(value, 16);
		}
	}
}
