using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetCigParametersTestInfo : PacketInfoBase
{
	public override string Name => "Le Set Cig Parameters Test";

	public override string DisplayGroup => "LE Controller";

	public LeSetCigParametersTestInfo(LeSetCigParametersTest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetCigParametersTest leSetCigParametersTest = (LeSetCigParametersTest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("CIG_ID", "", 8, FormatValue(leSetCigParametersTest.UserFields.CigId, 8), "", "0", "EF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SDU_Interval_M_TO_S", "Interval in microseconds of periodic SDUs.", 24, FormatValue(leSetCigParametersTest.UserFields.SduIntervalMToS, 24), "", "FF", "FFFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SDU_Interval_S_TO_M", "Interval in microseconds of periodic SDUs.", 24, FormatValue(leSetCigParametersTest.UserFields.SduIntervalSToM, 24), "", "FF", "FFFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("FT_M_TO_S", "The flush timeout for a payload from the master.", 8, FormatValue(leSetCigParametersTest.UserFields.FtMToS, 8), "", "1", "FF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("FT_S_TO_M", "The flush timeout for a payload from the slave.", 8, FormatValue(leSetCigParametersTest.UserFields.FtSToM, 8), "", "1", "FF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ISO_Interval", "ISO_Interval is in multiples of 1.25 ms.", 16, FormatValue(leSetCigParametersTest.UserFields.IsoInterval, 16), "", "0004", "0C80", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SCA", "Slave’s sleep clock accuracy.\r\n\r\n" + ClockAccuracyInfo.ClockAccuracyToDescription(), 8, FormatValue(leSetCigParametersTest.UserFields.Sca, 8), ClockAccuracyInfo.ClockAccuracyToString(ClockAccuracyInfo.ValueToClockAccuracy(leSetCigParametersTest.UserFields.Sca)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packing", IsoPackingInfo.IsoPackingToDescription(), 8, FormatValue(leSetCigParametersTest.UserFields.Packing, 8), IsoPackingInfo.IsoPackingToString(IsoPackingInfo.ValueToIsoPacking(leSetCigParametersTest.UserFields.Packing)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Framing", IsoFramingInfo.IsoFramingToDescription(), 8, FormatValue(leSetCigParametersTest.UserFields.Framing, 8), IsoFramingInfo.IsoFramingToString(IsoFramingInfo.ValueToIsoFraming(leSetCigParametersTest.UserFields.Framing)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CIS_Count", "Total number of Connected Isochronous Stream.", 8, FormatValue(leSetCigParametersTest.UserFields.CisCount, 8), "", "0", "1F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < leSetCigParametersTest.UserFields.CisParametersList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("CIS_ID[" + i + "]", "Used to identify a Connected Isochronous Stream.", 8, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].CisId, 8), "", "0", "EF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("NSE[" + i + "]", "Maximum number of subevents in each interval of Connected Isochronous Stream.", 8, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].Nse, 8), "", "1", "1F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("Max_SDU_M_TO_S[" + i + "]", "Maximum size of an SDU in octets from the master Host.", 16, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].MaxSduMToS, 16), "", "0", "FFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("Max_SDU_S_TO_M[" + i + "]", "Maximum size of an SDU in octets from the slave Host.", 16, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].MaxSduSToM, 16), "", "0", "FFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("Max_PDU_M_TO_S[" + i + "]", "Maximum size, in octets, of the payload from master Link Layer to slave Link Layer.", 16, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].MaxPduMToS, 16), "", "0", "FB", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("Max_PDU_S_TO_M[" + i + "]", "Maximum size, in octets, of the payload from slave Link Layer to master Link Layer.", 16, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].MaxPduSToM, 16), "", "0", "FB", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("PHY_M_TO_S[" + i + "]", TransmitterPhyPreferenceInfo.TransmitterPhyPreferenceToDescription(), 8, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].PhyMToS, 8), TransmitterPhyPreferenceInfo.TransmitterPhyPreferenceToString(TransmitterPhyPreferenceInfo.ValueToTransmitterPhyPreference(leSetCigParametersTest.UserFields.CisParametersList[i].PhyMToS)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("PHY_S_TO_M[" + i + "]", TransmitterPhyPreferenceInfo.TransmitterPhyPreferenceToDescription(), 8, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].PhySToM, 8), TransmitterPhyPreferenceInfo.TransmitterPhyPreferenceToString(TransmitterPhyPreferenceInfo.ValueToTransmitterPhyPreference(leSetCigParametersTest.UserFields.CisParametersList[i].PhySToM)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("BN_M_TO_S[" + i + "]", "The burst number for master to slave transmission.", 8, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].BnMToS, 8), "", "0", "F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("BN_S_TO_M[" + i + "]", "The burst number for slave to master transmission.", 8, FormatValue(leSetCigParametersTest.UserFields.CisParametersList[i].BnSToM, 8), "", "0", "F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeSetCigParametersTest leSetCigParametersTest = (LeSetCigParametersTest)packet;
		int num = -1;
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.CigId = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.SduIntervalMToS = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.SduIntervalSToM = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.FtMToS = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.FtSToM = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.IsoInterval = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.Sca = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.Packing = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.Framing = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetCigParametersTest.UserFields.CisCount = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < leSetCigParametersTest.UserFields.CisParametersList.Count; i++)
		{
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].CisId = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].Nse = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].MaxSduMToS = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].MaxSduSToM = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].MaxPduMToS = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].MaxPduSToM = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].PhyMToS = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].PhySToM = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].BnMToS = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				leSetCigParametersTest.UserFields.CisParametersList[i].BnSToM = Convert.ToUInt32(value, 16);
				break;
			}
		}
	}
}
