using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class TxGroupControlInfo : PacketInfoBase
{
	public override string Name => "Tx Group Control";

	public override string DisplayGroup => "Transmitter Control";

	public TxGroupControlInfo(TxGroupControl packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		TxGroupControl txGroupControl = (TxGroupControl)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Buffer Control", TxGroupControl.UserFieldsWrapper.BufferControlInfo.BufferControlToDescription(), 8, FormatValue(txGroupControl.UserFields.BufferControl, 8), TxGroupControl.UserFieldsWrapper.BufferControlInfo.BufferControlToString(TxGroupControl.UserFieldsWrapper.BufferControlInfo.ValueToBufferControl(txGroupControl.UserFields.BufferControl)), "", "3", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Buffer Available Threshold", "This value determines the threshold for TX_RDS_GROUPS_AVAILABLE event generation.  The value should be less than maximum groups buffered using TX_RDS_RAW_GROUPS command.  Only valid for one shot transmit.  This event will be generated whenever the firmware has transmitted the specified number of groups.", 8, FormatValue(txGroupControl.UserFields.BufferAvailableThreshold, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		TxGroupControl txGroupControl = (TxGroupControl)packet;
		int num = -1;
		if (index == ++num)
		{
			txGroupControl.UserFields.BufferControl = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			txGroupControl.UserFields.BufferAvailableThreshold = Convert.ToUInt32(value, 16);
		}
	}
}
