using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class AmpReceiverReportInfo : PacketInfoBase
{
	public override string Name => "Amp Receiver Report";

	public override string DisplayGroup => "Testing";

	public AmpReceiverReportInfo(AmpReceiverReport packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		AmpReceiverReport ampReceiverReport = (AmpReceiverReport)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Controller_Type", "See Bluetooth Assigned Numbers.", 8, FormatValue(ampReceiverReport.UserFields.ControllerType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Reason", "0x00 Configured Interval report, 0x01 Test Ended report, 0x02 - 0xFF Reserved.", 8, FormatValue(ampReceiverReport.UserFields.Reason, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Event_type", "0x00 Frames received report, 0x01 Frames received and bits in error report (optional), 0x02 - 0xFF Reserved.", 32, FormatValue(ampReceiverReport.UserFields.EventType, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number_Of_Frames", "Number of frames received so far.", 16, FormatValue(ampReceiverReport.UserFields.NumberOfFrames, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number_Of_Error_Frames", "Number of frames with errors received so far.", 16, FormatValue(ampReceiverReport.UserFields.NumberOfErrorFrames, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number_Of_Bits", "Number of bits received so far. Shall be set to 0x00000000 if the Event_type is not equal to 0x01.", 32, FormatValue(ampReceiverReport.UserFields.NumberOfBits, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number_Of_Error_Bits", "Number of bit errors received so far. Shall be set to 0x00000000 if the Event_type is not equal to 0x01.", 32, FormatValue(ampReceiverReport.UserFields.NumberOfErrorBits, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		AmpReceiverReport ampReceiverReport = (AmpReceiverReport)packet;
		int num = -1;
		if (index == ++num)
		{
			ampReceiverReport.UserFields.ControllerType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ampReceiverReport.UserFields.Reason = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ampReceiverReport.UserFields.EventType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ampReceiverReport.UserFields.NumberOfFrames = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ampReceiverReport.UserFields.NumberOfErrorFrames = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ampReceiverReport.UserFields.NumberOfBits = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ampReceiverReport.UserFields.NumberOfErrorBits = Convert.ToUInt32(value, 16);
		}
	}
}
