using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class WriteAutomaticFlushTimeoutInfo : PacketInfoBase
{
	public override string Name => "Write Automatic Flush Timeout";

	public override string DisplayGroup => "Host Control and Baseband";

	public WriteAutomaticFlushTimeoutInfo(WriteAutomaticFlushTimeout packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		WriteAutomaticFlushTimeout writeAutomaticFlushTimeout = (WriteAutomaticFlushTimeout)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Specifies which Connection_Handle's Flush Timeout to write to. Range: 0x0000-0x0EFF.  Reserved for future use (0x0F00 - 0x0FFF)", 16, FormatValue(writeAutomaticFlushTimeout.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Flush_Timeout", "0x0000: Timeout = ∞; No Automatic Flush (default). Flush Timeout = N * 0.625 msec, Size: 11 bits, Range: 0x0001 - 0x07FF, Mandatory Range for Controller: 0x0002 to 0x07FF", 16, FormatValue(writeAutomaticFlushTimeout.UserFields.FlushTimeout, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		WriteAutomaticFlushTimeout writeAutomaticFlushTimeout = (WriteAutomaticFlushTimeout)packet;
		int num = -1;
		if (index == ++num)
		{
			writeAutomaticFlushTimeout.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			writeAutomaticFlushTimeout.UserFields.FlushTimeout = Convert.ToUInt32(value, 16);
		}
	}
}
