using System;
using QCRPG.Framework;

namespace QCRPG.TSL.NFC.Packets;

public class CoreInterfaceErrorNtfInfo : PacketInfoBase
{
	public override string Name => "Core Interface Error Ntf";

	public override string DisplayGroup => "NCI Core";

	public CoreInterfaceErrorNtfInfo(CoreInterfaceErrorNtf packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CoreInterfaceErrorNtf coreInterfaceErrorNtf = (CoreInterfaceErrorNtf)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Status", StatusCodesInfo.StatusCodesToDescription(), 8, FormatValue(coreInterfaceErrorNtf.UserFields.Status, 8), StatusCodesInfo.StatusCodesToString(StatusCodesInfo.ValueToStatusCodes(coreInterfaceErrorNtf.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Conn ID", "The identifier of the Logical Connection where the error occurred. The four least significant bits of the octet SHALL contain the Conn ID as defined in Table 4. The four most significant bits are RFU.", 8, FormatValue(coreInterfaceErrorNtf.UserFields.ConnId, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CoreInterfaceErrorNtf coreInterfaceErrorNtf = (CoreInterfaceErrorNtf)packet;
		int num = -1;
		if (index == ++num)
		{
			coreInterfaceErrorNtf.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			coreInterfaceErrorNtf.UserFields.ConnId = Convert.ToUInt32(value, 16);
		}
	}
}
