using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ProdTestListModeRxStatsEvent : PacketBase
{
	public class UserFieldsWrapper
	{
		private const uint _Command = 4u;

		private uint _Dh1TotalReceivedPackets;

		private uint _Dh1ReceivedPacketsWithAccessOk;

		private uint _Dh1ReceivedPacketsWithHecOk;

		private uint _Dh1ReceivedPacketsWithPktTypeOk;

		private uint _Dh1ReceivedPacketsWithCrcOk;

		private uint _Dh1ReceivedPacketsWithPayloadOk;

		private uint _Dh1Ber;

		private uint _Dh5TotalReceivedPackets;

		private uint _Dh5ReceivedPacketsWithAccessOk;

		private uint _Dh5ReceivedPacketsWithHecOk;

		private uint _Dh5ReceivedPacketsWithPktTypeOk;

		private uint _Dh5ReceivedPacketsWithCrcOk;

		private uint _Dh5ReceivedPacketsWithPayloadOk;

		private uint _Dh5Ber;

		private uint _TwoDh5TotalReceivedPackets;

		private uint _TwoDh5ReceivedPacketsWithAccessOk;

		private uint _TwoDh5ReceivedPacketsWithHecOk;

		private uint _TwoDh5ReceivedPacketsWithPktTypeOk;

		private uint _TwoDh5ReceivedPacketsWithCrcOk;

		private uint _TwoDh5ReceivedPacketsWithPayloadOk;

		private uint _TwoDh5Ber;

		private uint _ThreeDh5TotalReceivedPackets;

		private uint _ThreeDh5ReceivedPacketsWithAccessOk;

		private uint _ThreeDh5ReceivedPacketsWithHecOk;

		private uint _ThreeDh5ReceivedPacketsWithPktTypeOk;

		private uint _ThreeDh5ReceivedPacketsWithCrcOk;

		private uint _ThreeDh5ReceivedPacketsWithPayloadOk;

		private uint _ThreeDh5Ber;

		private uint _LeTotalReceivedPackets;

		private uint _LeReceivedPacketsWithAccessOk;

		private uint _LeReceivedPacketsWithHecOk;

		private uint _LeReceivedPacketsWithPktTypeOk;

		private uint _LeReceivedPacketsWithCrcOk;

		private uint _LeReceivedPacketsWithPayloadOk;

		private uint _LeBer;

		public uint Command => 4u;

		public uint Dh1TotalReceivedPackets
		{
			get
			{
				return _Dh1TotalReceivedPackets;
			}
			set
			{
				_Dh1TotalReceivedPackets = value;
			}
		}

		public uint Dh1ReceivedPacketsWithAccessOk
		{
			get
			{
				return _Dh1ReceivedPacketsWithAccessOk;
			}
			set
			{
				_Dh1ReceivedPacketsWithAccessOk = value;
			}
		}

		public uint Dh1ReceivedPacketsWithHecOk
		{
			get
			{
				return _Dh1ReceivedPacketsWithHecOk;
			}
			set
			{
				_Dh1ReceivedPacketsWithHecOk = value;
			}
		}

		public uint Dh1ReceivedPacketsWithPktTypeOk
		{
			get
			{
				return _Dh1ReceivedPacketsWithPktTypeOk;
			}
			set
			{
				_Dh1ReceivedPacketsWithPktTypeOk = value;
			}
		}

		public uint Dh1ReceivedPacketsWithCrcOk
		{
			get
			{
				return _Dh1ReceivedPacketsWithCrcOk;
			}
			set
			{
				_Dh1ReceivedPacketsWithCrcOk = value;
			}
		}

		public uint Dh1ReceivedPacketsWithPayloadOk
		{
			get
			{
				return _Dh1ReceivedPacketsWithPayloadOk;
			}
			set
			{
				_Dh1ReceivedPacketsWithPayloadOk = value;
			}
		}

		public uint Dh1Ber
		{
			get
			{
				return _Dh1Ber;
			}
			set
			{
				_Dh1Ber = value;
			}
		}

		public uint Dh5TotalReceivedPackets
		{
			get
			{
				return _Dh5TotalReceivedPackets;
			}
			set
			{
				_Dh5TotalReceivedPackets = value;
			}
		}

		public uint Dh5ReceivedPacketsWithAccessOk
		{
			get
			{
				return _Dh5ReceivedPacketsWithAccessOk;
			}
			set
			{
				_Dh5ReceivedPacketsWithAccessOk = value;
			}
		}

		public uint Dh5ReceivedPacketsWithHecOk
		{
			get
			{
				return _Dh5ReceivedPacketsWithHecOk;
			}
			set
			{
				_Dh5ReceivedPacketsWithHecOk = value;
			}
		}

		public uint Dh5ReceivedPacketsWithPktTypeOk
		{
			get
			{
				return _Dh5ReceivedPacketsWithPktTypeOk;
			}
			set
			{
				_Dh5ReceivedPacketsWithPktTypeOk = value;
			}
		}

		public uint Dh5ReceivedPacketsWithCrcOk
		{
			get
			{
				return _Dh5ReceivedPacketsWithCrcOk;
			}
			set
			{
				_Dh5ReceivedPacketsWithCrcOk = value;
			}
		}

		public uint Dh5ReceivedPacketsWithPayloadOk
		{
			get
			{
				return _Dh5ReceivedPacketsWithPayloadOk;
			}
			set
			{
				_Dh5ReceivedPacketsWithPayloadOk = value;
			}
		}

		public uint Dh5Ber
		{
			get
			{
				return _Dh5Ber;
			}
			set
			{
				_Dh5Ber = value;
			}
		}

		public uint TwoDh5TotalReceivedPackets
		{
			get
			{
				return _TwoDh5TotalReceivedPackets;
			}
			set
			{
				_TwoDh5TotalReceivedPackets = value;
			}
		}

		public uint TwoDh5ReceivedPacketsWithAccessOk
		{
			get
			{
				return _TwoDh5ReceivedPacketsWithAccessOk;
			}
			set
			{
				_TwoDh5ReceivedPacketsWithAccessOk = value;
			}
		}

		public uint TwoDh5ReceivedPacketsWithHecOk
		{
			get
			{
				return _TwoDh5ReceivedPacketsWithHecOk;
			}
			set
			{
				_TwoDh5ReceivedPacketsWithHecOk = value;
			}
		}

		public uint TwoDh5ReceivedPacketsWithPktTypeOk
		{
			get
			{
				return _TwoDh5ReceivedPacketsWithPktTypeOk;
			}
			set
			{
				_TwoDh5ReceivedPacketsWithPktTypeOk = value;
			}
		}

		public uint TwoDh5ReceivedPacketsWithCrcOk
		{
			get
			{
				return _TwoDh5ReceivedPacketsWithCrcOk;
			}
			set
			{
				_TwoDh5ReceivedPacketsWithCrcOk = value;
			}
		}

		public uint TwoDh5ReceivedPacketsWithPayloadOk
		{
			get
			{
				return _TwoDh5ReceivedPacketsWithPayloadOk;
			}
			set
			{
				_TwoDh5ReceivedPacketsWithPayloadOk = value;
			}
		}

		public uint TwoDh5Ber
		{
			get
			{
				return _TwoDh5Ber;
			}
			set
			{
				_TwoDh5Ber = value;
			}
		}

		public uint ThreeDh5TotalReceivedPackets
		{
			get
			{
				return _ThreeDh5TotalReceivedPackets;
			}
			set
			{
				_ThreeDh5TotalReceivedPackets = value;
			}
		}

		public uint ThreeDh5ReceivedPacketsWithAccessOk
		{
			get
			{
				return _ThreeDh5ReceivedPacketsWithAccessOk;
			}
			set
			{
				_ThreeDh5ReceivedPacketsWithAccessOk = value;
			}
		}

		public uint ThreeDh5ReceivedPacketsWithHecOk
		{
			get
			{
				return _ThreeDh5ReceivedPacketsWithHecOk;
			}
			set
			{
				_ThreeDh5ReceivedPacketsWithHecOk = value;
			}
		}

		public uint ThreeDh5ReceivedPacketsWithPktTypeOk
		{
			get
			{
				return _ThreeDh5ReceivedPacketsWithPktTypeOk;
			}
			set
			{
				_ThreeDh5ReceivedPacketsWithPktTypeOk = value;
			}
		}

		public uint ThreeDh5ReceivedPacketsWithCrcOk
		{
			get
			{
				return _ThreeDh5ReceivedPacketsWithCrcOk;
			}
			set
			{
				_ThreeDh5ReceivedPacketsWithCrcOk = value;
			}
		}

		public uint ThreeDh5ReceivedPacketsWithPayloadOk
		{
			get
			{
				return _ThreeDh5ReceivedPacketsWithPayloadOk;
			}
			set
			{
				_ThreeDh5ReceivedPacketsWithPayloadOk = value;
			}
		}

		public uint ThreeDh5Ber
		{
			get
			{
				return _ThreeDh5Ber;
			}
			set
			{
				_ThreeDh5Ber = value;
			}
		}

		public uint LeTotalReceivedPackets
		{
			get
			{
				return _LeTotalReceivedPackets;
			}
			set
			{
				_LeTotalReceivedPackets = value;
			}
		}

		public uint LeReceivedPacketsWithAccessOk
		{
			get
			{
				return _LeReceivedPacketsWithAccessOk;
			}
			set
			{
				_LeReceivedPacketsWithAccessOk = value;
			}
		}

		public uint LeReceivedPacketsWithHecOk
		{
			get
			{
				return _LeReceivedPacketsWithHecOk;
			}
			set
			{
				_LeReceivedPacketsWithHecOk = value;
			}
		}

		public uint LeReceivedPacketsWithPktTypeOk
		{
			get
			{
				return _LeReceivedPacketsWithPktTypeOk;
			}
			set
			{
				_LeReceivedPacketsWithPktTypeOk = value;
			}
		}

		public uint LeReceivedPacketsWithCrcOk
		{
			get
			{
				return _LeReceivedPacketsWithCrcOk;
			}
			set
			{
				_LeReceivedPacketsWithCrcOk = value;
			}
		}

		public uint LeReceivedPacketsWithPayloadOk
		{
			get
			{
				return _LeReceivedPacketsWithPayloadOk;
			}
			set
			{
				_LeReceivedPacketsWithPayloadOk = value;
			}
		}

		public uint LeBer
		{
			get
			{
				return _LeBer;
			}
			set
			{
				_LeBer = value;
			}
		}
	}

	private const uint _EventCode = 255u;

	private Type[] expectedResponseTypes = new Type[0];

	private PacketInfoBase info;

	private uint _PayloadLength;

	public UserFieldsWrapper _UserFields = new UserFieldsWrapper();

	public override PacketType Type => PacketType.Notification;

	public override Type[] ExpectedResponseTypes => expectedResponseTypes;

	public override PacketInfoBase Info
	{
		get
		{
			if (info == null)
			{
				info = new ProdTestListModeRxStatsEventInfo(this);
			}
			return info;
		}
	}

	public uint EventCode => 255u;

	public uint PayloadLength
	{
		get
		{
			ToBitString();
			return _PayloadLength;
		}
	}

	public UserFieldsWrapper UserFields => _UserFields;

	protected override bool FromBitBuilder(ref BitBuilder bitBuilder)
	{
		if (bitBuilder.RemoveBitsAsUint(8) != EventCode)
		{
			return false;
		}
		_PayloadLength = bitBuilder.RemoveBitsAsUint(8);
		int numberOfBits = bitBuilder.GetNumberOfBits();
		if (numberOfBits > _PayloadLength * 8 + 7)
		{
			return false;
		}
		if (numberOfBits < _PayloadLength * 8)
		{
			return false;
		}
		if (bitBuilder.RemoveBitsAsUint(8) != UserFields.Command)
		{
			return false;
		}
		UserFields.Dh1TotalReceivedPackets = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh1ReceivedPacketsWithAccessOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh1ReceivedPacketsWithHecOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh1ReceivedPacketsWithPktTypeOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh1ReceivedPacketsWithCrcOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh1ReceivedPacketsWithPayloadOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh1Ber = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh5TotalReceivedPackets = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh5ReceivedPacketsWithAccessOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh5ReceivedPacketsWithHecOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh5ReceivedPacketsWithPktTypeOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh5ReceivedPacketsWithCrcOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh5ReceivedPacketsWithPayloadOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.Dh5Ber = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.TwoDh5TotalReceivedPackets = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.TwoDh5ReceivedPacketsWithAccessOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.TwoDh5ReceivedPacketsWithHecOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.TwoDh5ReceivedPacketsWithPktTypeOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.TwoDh5ReceivedPacketsWithCrcOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.TwoDh5ReceivedPacketsWithPayloadOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.TwoDh5Ber = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.ThreeDh5TotalReceivedPackets = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.ThreeDh5ReceivedPacketsWithAccessOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.ThreeDh5ReceivedPacketsWithHecOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.ThreeDh5ReceivedPacketsWithPktTypeOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.ThreeDh5ReceivedPacketsWithCrcOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.ThreeDh5ReceivedPacketsWithPayloadOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.ThreeDh5Ber = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.LeTotalReceivedPackets = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.LeReceivedPacketsWithAccessOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.LeReceivedPacketsWithHecOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.LeReceivedPacketsWithPktTypeOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.LeReceivedPacketsWithCrcOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.LeReceivedPacketsWithPayloadOk = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		UserFields.LeBer = bitBuilder.RemoveBitsAsUintLittleEndian(32);
		if (bitBuilder.GetNumberOfBits() > 7)
		{
			return false;
		}
		return true;
	}

	public override string ToBitString()
	{
		BitBuilder bitBuilder = new BitBuilder();
		bitBuilder.AddBitsAsUint(EventCode, 8);
		int numberOfBits = bitBuilder.GetNumberOfBits();
		bitBuilder.AddBitsAsUint(0u, 8);
		bitBuilder.AddBitsAsUint(UserFields.Command, 8);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh1TotalReceivedPackets, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh1ReceivedPacketsWithAccessOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh1ReceivedPacketsWithHecOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh1ReceivedPacketsWithPktTypeOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh1ReceivedPacketsWithCrcOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh1ReceivedPacketsWithPayloadOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh1Ber, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh5TotalReceivedPackets, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh5ReceivedPacketsWithAccessOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh5ReceivedPacketsWithHecOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh5ReceivedPacketsWithPktTypeOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh5ReceivedPacketsWithCrcOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh5ReceivedPacketsWithPayloadOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.Dh5Ber, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.TwoDh5TotalReceivedPackets, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.TwoDh5ReceivedPacketsWithAccessOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.TwoDh5ReceivedPacketsWithHecOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.TwoDh5ReceivedPacketsWithPktTypeOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.TwoDh5ReceivedPacketsWithCrcOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.TwoDh5ReceivedPacketsWithPayloadOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.TwoDh5Ber, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.ThreeDh5TotalReceivedPackets, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.ThreeDh5ReceivedPacketsWithAccessOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.ThreeDh5ReceivedPacketsWithHecOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.ThreeDh5ReceivedPacketsWithPktTypeOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.ThreeDh5ReceivedPacketsWithCrcOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.ThreeDh5ReceivedPacketsWithPayloadOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.ThreeDh5Ber, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.LeTotalReceivedPackets, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.LeReceivedPacketsWithAccessOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.LeReceivedPacketsWithHecOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.LeReceivedPacketsWithPktTypeOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.LeReceivedPacketsWithCrcOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.LeReceivedPacketsWithPayloadOk, 32);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.LeBer, 32);
		_PayloadLength = (uint)((bitBuilder.GetNumberOfBits() - numberOfBits - 8) / 8);
		if ((bitBuilder.GetNumberOfBits() - numberOfBits - 8) % 8 != 0)
		{
			_PayloadLength++;
		}
		bitBuilder.ChangeBitsAsUint(numberOfBits, _PayloadLength, 8);
		return bitBuilder.ToString();
	}
}
