using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class ServiceAvailableInfo : PacketInfoBase
{
	public override string Name => "Service Available";

	public override string DisplayGroup => "Events";

	public ServiceAvailableInfo(ServiceAvailable packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ServiceAvailable serviceAvailable = (ServiceAvailable)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Service Available", ServiceAvailable.UserFieldsWrapper.ServiceAvailableInfo.ServiceAvailableToDescription(), 8, FormatValue(serviceAvailable.UserFields.ServiceAvailable, 8), ServiceAvailable.UserFieldsWrapper.ServiceAvailableInfo.ServiceAvailableToString(ServiceAvailable.UserFieldsWrapper.ServiceAvailableInfo.ValueToServiceAvailable(serviceAvailable.UserFields.ServiceAvailable)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SINR", "Measured sinr in dBm (signed)", 8, FormatValue(serviceAvailable.UserFields.Sinr, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Interference Detector Threshold", "Measured interference detector threshold", 8, FormatValue(serviceAvailable.UserFields.InterferenceDetectorThreshold, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ServiceAvailable serviceAvailable = (ServiceAvailable)packet;
		int num = -1;
		if (index == ++num)
		{
			serviceAvailable.UserFields.ServiceAvailable = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			serviceAvailable.UserFields.Sinr = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			serviceAvailable.UserFields.InterferenceDetectorThreshold = Convert.ToUInt32(value, 16);
		}
	}
}
