using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LlPowerControlRspInfo : PacketInfoBase
{
	public override string Name => "Ll Power Control Rsp";

	public override string DisplayGroup => "Enhanced Logging";

	public LlPowerControlRspInfo(LlPowerControlRsp packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LlPowerControlRsp llPowerControlRsp = (LlPowerControlRsp)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Seq_Num", "", 8, FormatValue(llPowerControlRsp.UserFields.SeqNum, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Logs_Lost_Drop", "", 8, FormatValue(llPowerControlRsp.UserFields.LogsLostDrop, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Prod_ID", "", 8, FormatValue(llPowerControlRsp.UserFields.ProdId, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Id", LlPowerControlRsp.UserFieldsWrapper.LogIdInfo.LogIdToDescription(), 16, FormatValue(llPowerControlRsp.UserFields.LogId, 16), LlPowerControlRsp.UserFieldsWrapper.LogIdInfo.LogIdToString(LlPowerControlRsp.UserFieldsWrapper.LogIdInfo.ValueToLogId(llPowerControlRsp.UserFields.LogId)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Format_Level", "", 8, FormatValue(llPowerControlRsp.UserFields.LogFormatLevel, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Timestamp", "", 32, FormatValue(llPowerControlRsp.UserFields.Timestamp, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Handle", "", 8, FormatValue(llPowerControlRsp.UserFields.Handle, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PDU_Length", "", 8, FormatValue(llPowerControlRsp.UserFields.PduLength, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Opcode", LlPowerControlRsp.UserFieldsWrapper.OpcodeInfo.OpcodeToDescription(), 8, FormatValue(llPowerControlRsp.UserFields.Opcode, 8), LlPowerControlRsp.UserFieldsWrapper.OpcodeInfo.OpcodeToString(LlPowerControlRsp.UserFieldsWrapper.OpcodeInfo.ValueToOpcode(llPowerControlRsp.UserFields.Opcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Min", "", 1, FormatValue(llPowerControlRsp.UserFields.Min, 1), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max", "", 1, FormatValue(llPowerControlRsp.UserFields.Max, 1), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RFU", "", 6, FormatValue(llPowerControlRsp.UserFields.Rfu, 6), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Delta", "", 8, FormatValue(llPowerControlRsp.UserFields.Delta, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("TxPower", "", 8, FormatValue(llPowerControlRsp.UserFields.Txpower, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("APR", "", 8, FormatValue(llPowerControlRsp.UserFields.Apr, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Event_counter", "", 16, FormatValue(llPowerControlRsp.UserFields.EventCounter, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LlPowerControlRsp llPowerControlRsp = (LlPowerControlRsp)packet;
		int num = -1;
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.SeqNum = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.LogsLostDrop = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.ProdId = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.LogId = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.LogFormatLevel = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.Timestamp = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.Handle = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.PduLength = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Opcode");
		}
		if (index == ++num)
		{
			llPowerControlRsp.UserFields.Min = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			llPowerControlRsp.UserFields.Max = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			llPowerControlRsp.UserFields.Rfu = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			llPowerControlRsp.UserFields.Delta = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			llPowerControlRsp.UserFields.Txpower = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			llPowerControlRsp.UserFields.Apr = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			llPowerControlRsp.UserFields.EventCounter = Convert.ToUInt32(value, 16);
		}
	}
}
