using System;
using QCRPG.Framework;

namespace QCRPG.TSL.ZigBee.Packets;

public class VsDutRxTestRequestInfo : PacketInfoBase
{
	public override string Name => "Vs Dut Rx Test Request";

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

	public VsDutRxTestRequestInfo(VsDutRxTestRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		VsDutRxTestRequest vsDutRxTestRequest = (VsDutRxTestRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Flags", VsDutRxTestRequest.UserFieldsWrapper.FlagsInfo.FlagsToDescription(), 32, FormatValue(vsDutRxTestRequest.UserFields.Flags, 32), VsDutRxTestRequest.UserFieldsWrapper.FlagsInfo.FlagsToString(VsDutRxTestRequest.UserFieldsWrapper.FlagsInfo.ValueToFlags(vsDutRxTestRequest.UserFields.Flags)), "00000000", "00000003", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Mode", VsDutRxTestRequest.UserFieldsWrapper.ModeInfo.ModeToDescription(), 8, FormatValue(vsDutRxTestRequest.UserFields.Mode, 8), VsDutRxTestRequest.UserFieldsWrapper.ModeInfo.ModeToString(VsDutRxTestRequest.UserFieldsWrapper.ModeInfo.ValueToMode(vsDutRxTestRequest.UserFields.Mode)), "00", "02", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Page", "Page that for the test", 8, FormatValue(vsDutRxTestRequest.UserFields.Page, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Channel", "Range (0B(11)-0x1A/26(Decimal))", 8, FormatValue(vsDutRxTestRequest.UserFields.Channel, 8), "", "0B", "1A", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.DecimalInteger));
		fieldInfoList.Add(new PacketFieldInfo("PayloadLength", "Length of the payload data in each packet", 16, FormatValue(vsDutRxTestRequest.UserFields.Payloadlength, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PacketType", TestPacketTypeInfo.TestPacketTypeToDescription(), 8, FormatValue(vsDutRxTestRequest.UserFields.Packettype, 8), TestPacketTypeInfo.TestPacketTypeToString(TestPacketTypeInfo.ValueToTestPacketType(vsDutRxTestRequest.UserFields.Packettype)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Gap", "Period between burst mode transmissions in microseconds", 16, FormatValue(vsDutRxTestRequest.UserFields.Gap, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
		fieldInfoList.Add(new PacketFieldInfo("RSSIPeriod", "Controls the period in milliseconds that RSSI indications will be sent", 16, FormatValue(vsDutRxTestRequest.UserFields.Rssiperiod, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.DecimalInteger));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		VsDutRxTestRequest vsDutRxTestRequest = (VsDutRxTestRequest)packet;
		int num = -1;
		if (index == ++num)
		{
			vsDutRxTestRequest.UserFields.Flags = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsDutRxTestRequest.UserFields.Mode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsDutRxTestRequest.UserFields.Page = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsDutRxTestRequest.UserFields.Channel = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsDutRxTestRequest.UserFields.Payloadlength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsDutRxTestRequest.UserFields.Packettype = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsDutRxTestRequest.UserFields.Gap = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			vsDutRxTestRequest.UserFields.Rssiperiod = Convert.ToUInt32(value, 16);
		}
	}
}
