using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ProdTestLeTxBurstInfo : PacketInfoBase
{
	public override string Name => "Prod Test Le Tx Burst";

	public override string DisplayGroup => "Vendor Specific";

	public ProdTestLeTxBurstInfo(ProdTestLeTxBurst packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ProdTestLeTxBurst prodTestLeTxBurst = (ProdTestLeTxBurst)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("SubOpCode", ProdTestLeTxBurst.UserFieldsWrapper.SubopcodeInfo.SubopcodeToDescription(), 8, FormatValue(prodTestLeTxBurst.UserFields.Subopcode, 8), ProdTestLeTxBurst.UserFieldsWrapper.SubopcodeInfo.SubopcodeToString(ProdTestLeTxBurst.UserFieldsWrapper.SubopcodeInfo.ValueToSubopcode(prodTestLeTxBurst.UserFields.Subopcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Hop_Channels", "Frequency offset , For 0x05 - 0x10 hopping channel space. For example, the space is 5 x 2MHZ, if the frequency offset is 0x05. For others, 40 LE channels hopping", 8, FormatValue(prodTestLeTxBurst.UserFields.HopChannels, 8), "", "00", "FF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Payload_Length", "Payload_Length in bytes", 16, FormatValue(prodTestLeTxBurst.UserFields.PayloadLength, 16), "", "0000", "03FD", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Payload_Type", ProdTestLeTxBurst.UserFieldsWrapper.PayloadTypeInfo.PayloadTypeToDescription(), 8, FormatValue(prodTestLeTxBurst.UserFields.PayloadType, 8), ProdTestLeTxBurst.UserFieldsWrapper.PayloadTypeInfo.PayloadTypeToString(ProdTestLeTxBurst.UserFieldsWrapper.PayloadTypeInfo.ValueToPayloadType(prodTestLeTxBurst.UserFields.PayloadType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet_Type", ProdTestLeTxBurst.UserFieldsWrapper.PacketTypeInfo.PacketTypeToDescription(), 8, FormatValue(prodTestLeTxBurst.UserFields.PacketType, 8), ProdTestLeTxBurst.UserFieldsWrapper.PacketTypeInfo.PacketTypeToString(ProdTestLeTxBurst.UserFieldsWrapper.PacketTypeInfo.ValueToPacketType(prodTestLeTxBurst.UserFields.PacketType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Transmit_Output_Power", "Transmit_Output_Power : 0x00 =Lowest power, 0xXX=Highest power(the max power level differes per chip)", 8, FormatValue(prodTestLeTxBurst.UserFields.TransmitOutputPower, 8), "", "00", "FF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ProdTestLeTxBurst prodTestLeTxBurst = (ProdTestLeTxBurst)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Subopcode");
		}
		if (index == ++num)
		{
			prodTestLeTxBurst.UserFields.HopChannels = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			prodTestLeTxBurst.UserFields.PayloadLength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			prodTestLeTxBurst.UserFields.PayloadType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			prodTestLeTxBurst.UserFields.PacketType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			prodTestLeTxBurst.UserFields.TransmitOutputPower = Convert.ToUInt32(value, 16);
		}
	}
}
