using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeTransmitterTestInfo : PacketInfoBase
{
	public override string Name => "Le Transmitter Test";

	public override string DisplayGroup => "LE Controller";

	public LeTransmitterTestInfo(LeTransmitterTest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeTransmitterTest leTransmitterTest = (LeTransmitterTest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("TX Frequency", "N = (F - 2402) / 2; 0x00 = 2402MHz; 0x27 = 2480MHz", 8, FormatValue(leTransmitterTest.UserFields.TxFrequency, 8), "", "", "27", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Length Of Test Data", "Length in bytes of payload data in each packet", 8, FormatValue(leTransmitterTest.UserFields.LengthOfTestData, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet Payload", LeTransmitterTest.UserFieldsWrapper.PacketPayloadInfo.PacketPayloadToDescription(), 8, FormatValue(leTransmitterTest.UserFields.PacketPayload, 8), LeTransmitterTest.UserFieldsWrapper.PacketPayloadInfo.PacketPayloadToString(LeTransmitterTest.UserFieldsWrapper.PacketPayloadInfo.ValueToPacketPayload(leTransmitterTest.UserFields.PacketPayload)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeTransmitterTest leTransmitterTest = (LeTransmitterTest)packet;
		int num = -1;
		if (index == ++num)
		{
			leTransmitterTest.UserFields.TxFrequency = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leTransmitterTest.UserFields.LengthOfTestData = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leTransmitterTest.UserFields.PacketPayload = Convert.ToUInt32(value, 16);
		}
	}
}
