using System;
using QCRPG.Framework;

namespace QCRPG.TSL.ZigBee.Packets;

public class VsPeekRequestInfo : PacketInfoBase
{
	public override string Name => "Vs Peek Request";

	public override string DisplayGroup => "Vendor Specific Packets";

	public VsPeekRequestInfo(VsPeekRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		VsPeekRequest vsPeekRequest = (VsPeekRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("ElementSize", "", 8, FormatValue(vsPeekRequest.UserFields.Elementsize, 8), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("NumElements", "", 8, FormatValue(vsPeekRequest.UserFields.Numelements, 8), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Address", "", 32, FormatValue(vsPeekRequest.UserFields.Address, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		VsPeekRequest vsPeekRequest = (VsPeekRequest)packet;
		int num = -1;
		if (index == ++num)
		{
			vsPeekRequest.UserFields.Elementsize = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsPeekRequest.UserFields.Numelements = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsPeekRequest.UserFields.Address = Convert.ToUInt32(value, 16);
		}
	}
}
