using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeBatchScanSetBatchScanParamInfo : PacketInfoBase
{
	public override string Name => "Le Batch Scan Set Batch Scan Param";

	public override string DisplayGroup => "Vendor Specific";

	public LeBatchScanSetBatchScanParamInfo(LeBatchScanSetBatchScanParam packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeBatchScanSetBatchScanParam leBatchScanSetBatchScanParam = (LeBatchScanSetBatchScanParam)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Batch_Scan_opcode", "Set Batch Scan Parameters", 8, FormatValue(leBatchScanSetBatchScanParam.UserFields.BatchScanOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Batch_Scan_Mode", LeBatchScanSetBatchScanParam.UserFieldsWrapper.BatchScanModeInfo.BatchScanModeToDescription(), 8, FormatValue(leBatchScanSetBatchScanParam.UserFields.BatchScanMode, 8), LeBatchScanSetBatchScanParam.UserFieldsWrapper.BatchScanModeInfo.BatchScanModeToString(LeBatchScanSetBatchScanParam.UserFieldsWrapper.BatchScanModeInfo.ValueToBatchScanMode(leBatchScanSetBatchScanParam.UserFields.BatchScanMode)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Duty_cycle_scan_window", "Batch Scan scan time (# of slot)", 32, FormatValue(leBatchScanSetBatchScanParam.UserFields.DutyCycleScanWindow, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Duty_cyle_scan_interval", "Batch Scan interval period (# of slot)", 32, FormatValue(leBatchScanSetBatchScanParam.UserFields.DutyCyleScanInterval, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("own_address_type", DeviceAddressTypeInfo.DeviceAddressTypeToDescription(), 8, FormatValue(leBatchScanSetBatchScanParam.UserFields.OwnAddressType, 8), DeviceAddressTypeInfo.DeviceAddressTypeToString(DeviceAddressTypeInfo.ValueToDeviceAddressType(leBatchScanSetBatchScanParam.UserFields.OwnAddressType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Batch_scan_Discard_Rule", LeBatchScanSetBatchScanParam.UserFieldsWrapper.BatchScanDiscardRuleInfo.BatchScanDiscardRuleToDescription(), 8, FormatValue(leBatchScanSetBatchScanParam.UserFields.BatchScanDiscardRule, 8), LeBatchScanSetBatchScanParam.UserFieldsWrapper.BatchScanDiscardRuleInfo.BatchScanDiscardRuleToString(LeBatchScanSetBatchScanParam.UserFieldsWrapper.BatchScanDiscardRuleInfo.ValueToBatchScanDiscardRule(leBatchScanSetBatchScanParam.UserFields.BatchScanDiscardRule)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeBatchScanSetBatchScanParam leBatchScanSetBatchScanParam = (LeBatchScanSetBatchScanParam)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field BatchScanOpcode");
		}
		if (index == ++num)
		{
			leBatchScanSetBatchScanParam.UserFields.BatchScanMode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBatchScanSetBatchScanParam.UserFields.DutyCycleScanWindow = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBatchScanSetBatchScanParam.UserFields.DutyCyleScanInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBatchScanSetBatchScanParam.UserFields.OwnAddressType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBatchScanSetBatchScanParam.UserFields.BatchScanDiscardRule = Convert.ToUInt32(value, 16);
		}
	}
}
