using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class DebugConfigureCxmMciLogBitmapCmdInfo : PacketInfoBase
{
	public override string Name => "Debug Configure Cxm Mci Log Bitmap Cmd";

	public override string DisplayGroup => "Vendor Specific";

	public DebugConfigureCxmMciLogBitmapCmdInfo(DebugConfigureCxmMciLogBitmapCmd packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		DebugConfigureCxmMciLogBitmapCmd debugConfigureCxmMciLogBitmapCmd = (DebugConfigureCxmMciLogBitmapCmd)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(debugConfigureCxmMciLogBitmapCmd.UserFields.SubOpcode, 8), DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(debugConfigureCxmMciLogBitmapCmd.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Bitmap", "Each bit is mapped for each subopcode of Coex Agent GPM MCI message. 0 - Disable log event message 1 - Enable log event message\r\n\r\n" + DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.LogBitmapInfo.LogBitmapToDescription(), debugConfigureCxmMciLogBitmapCmd.UserFields.LogBitmapList.Count * 8, FormatValue(debugConfigureCxmMciLogBitmapCmd.UserFields.LogBitmapList, debugConfigureCxmMciLogBitmapCmd.UserFields.LogBitmapList.Count * 8, includeSpaces: false), DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.LogBitmapInfo.LogBitmapToString(DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.LogBitmapInfo.ValueToLogBitmap(debugConfigureCxmMciLogBitmapCmd.UserFields.LogBitmapList)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Enable_SchedInfo", "Used to disable/enable Sched Info log event 0 – Disable log event message 1 – Enable log event message\r\n\r\n" + DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.EnableSchedinfoInfo.EnableSchedinfoToDescription(), 8, FormatValue(debugConfigureCxmMciLogBitmapCmd.UserFields.EnableSchedinfo, 8), DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.EnableSchedinfoInfo.EnableSchedinfoToString(DebugConfigureCxmMciLogBitmapCmd.UserFieldsWrapper.EnableSchedinfoInfo.ValueToEnableSchedinfo(debugConfigureCxmMciLogBitmapCmd.UserFields.EnableSchedinfo)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		DebugConfigureCxmMciLogBitmapCmd debugConfigureCxmMciLogBitmapCmd = (DebugConfigureCxmMciLogBitmapCmd)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, debugConfigureCxmMciLogBitmapCmd.UserFields.LogBitmapList.Count);
			int num2 = 0;
			while (value.Length > 0)
			{
				string value2 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				debugConfigureCxmMciLogBitmapCmd.UserFields.LogBitmapList[num2] = Convert.ToUInt32(value2, 16);
				num2++;
			}
		}
		if (index == ++num)
		{
			debugConfigureCxmMciLogBitmapCmd.UserFields.EnableSchedinfo = Convert.ToUInt32(value, 16);
		}
	}
}
