using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ProdTestTxContinuousInfo : PacketInfoBase
{
	public override string Name => "Prod Test Tx Continuous";

	public override string DisplayGroup => "Vendor Specific";

	public ProdTestTxContinuousInfo(ProdTestTxContinuous packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ProdTestTxContinuous prodTestTxContinuous = (ProdTestTxContinuous)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Command", "", 8, FormatValue(prodTestTxContinuous.UserFields.Command, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Channel Number", "Device transmit channel number.", 8, FormatValue(prodTestTxContinuous.UserFields.ChannelNumber, 8), "", "", "4E", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Transmit Output Power", "0x00 = lowest power; 0x07 = highest power for BTS4020/21/BD; 0x09 = highest power for BTS4025, QSC/QTR, WCN2243, and WCN3660", 8, FormatValue(prodTestTxContinuous.UserFields.TransmitOutputPower, 8), "", "", "09", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Transmit Type", ProdTestTxContinuous.UserFieldsWrapper.TransmitTypeInfo.TransmitTypeToDescription(), 8, FormatValue(prodTestTxContinuous.UserFields.TransmitType, 8), ProdTestTxContinuous.UserFieldsWrapper.TransmitTypeInfo.TransmitTypeToString(ProdTestTxContinuous.UserFieldsWrapper.TransmitTypeInfo.ValueToTransmitType(prodTestTxContinuous.UserFields.TransmitType)), "04", "0D", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Pattern Length", "Specifies the length of the repeated pattern for Transmit Type 0x07", 8, FormatValue(prodTestTxContinuous.UserFields.PatternLength, 8), "", "01", "20", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Bit Pattern", "Bit pattern transmitted repeatedly", 32, FormatValue(prodTestTxContinuous.UserFields.BitPattern, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ProdTestTxContinuous prodTestTxContinuous = (ProdTestTxContinuous)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Command");
		}
		if (index == ++num)
		{
			prodTestTxContinuous.UserFields.ChannelNumber = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			prodTestTxContinuous.UserFields.TransmitOutputPower = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			prodTestTxContinuous.UserFields.TransmitType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			prodTestTxContinuous.UserFields.PatternLength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			prodTestTxContinuous.UserFields.BitPattern = Convert.ToUInt32(value, 16);
		}
	}
}
