using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class GpioConfigurationInfo : PacketInfoBase
{
	public override string Name => "Gpio Configuration";

	public override string DisplayGroup => "Production Test Mode";

	public GpioConfigurationInfo(GpioConfiguration packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		GpioConfiguration gpioConfiguration = (GpioConfiguration)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("GPIO Number", "GPIO To Configure", 8, FormatValue(gpioConfiguration.UserFields.GpioNumber, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("GPIO Config", GpioConfiguration.UserFieldsWrapper.GpioConfigInfo.GpioConfigToDescription(), 8, FormatValue(gpioConfiguration.UserFields.GpioConfig, 8), GpioConfiguration.UserFieldsWrapper.GpioConfigInfo.GpioConfigToString(GpioConfiguration.UserFieldsWrapper.GpioConfigInfo.ValueToGpioConfig(gpioConfiguration.UserFields.GpioConfig)), "", "3", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		GpioConfiguration gpioConfiguration = (GpioConfiguration)packet;
		int num = -1;
		if (index == ++num)
		{
			gpioConfiguration.UserFields.GpioNumber = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			gpioConfiguration.UserFields.GpioConfig = Convert.ToUInt32(value, 16);
		}
	}
}
