using System.Xml.Serialization;

namespace QRCT_modem_RF_Debug_tool;

public class WCN39xx_TxScenario : IUserDefinedCompareEqual
{
	[XmlElement]
	public datapair chan;

	[XmlElement]
	public datapair htMode;

	[XmlElement]
	public datapair txRate;

	[XmlElement]
	public datapair txPwrCtrl;

	[XmlElement]
	public string dacGain;

	[XmlElement]
	public string gainIndex;

	[XmlElement]
	public string paCfg;

	[XmlElement]
	public string targetPower;

	public WCN39xx_TxScenario DeepCopy()
	{
		WCN39xx_TxScenario wCN39xx_TxScenario = new WCN39xx_TxScenario();
		if (chan != null)
		{
			wCN39xx_TxScenario.chan = chan.cloneSelf();
		}
		if (htMode != null)
		{
			wCN39xx_TxScenario.htMode = htMode.cloneSelf();
		}
		if (txRate != null)
		{
			wCN39xx_TxScenario.txRate = txRate.cloneSelf();
		}
		if (txPwrCtrl != null)
		{
			wCN39xx_TxScenario.txPwrCtrl = txPwrCtrl.cloneSelf();
		}
		wCN39xx_TxScenario.dacGain = dacGain;
		wCN39xx_TxScenario.gainIndex = gainIndex;
		wCN39xx_TxScenario.paCfg = paCfg;
		wCN39xx_TxScenario.targetPower = targetPower;
		return wCN39xx_TxScenario;
	}

	public override string ToString()
	{
		string text = $"{chan.show}_{htMode.show}_{txRate.show}_{txPwrCtrl.show}_";
		if (txPwrCtrl.show == "TxPowerForce_CLPC")
		{
			return text + $"TargetPwr({targetPower})";
		}
		return text + $"dacGain({dacGain})_gainIndex({gainIndex}_paCfg({paCfg})";
	}

	public bool IsEqual(object comparedObj)
	{
		if (comparedObj != null)
		{
			WCN39xx_TxScenario wCN39xx_TxScenario = comparedObj as WCN39xx_TxScenario;
			if (chan.CheckEqual(wCN39xx_TxScenario.chan) && htMode.CheckEqual(wCN39xx_TxScenario.htMode) && txRate.CheckEqual(wCN39xx_TxScenario.txRate) && txPwrCtrl.CheckEqual(wCN39xx_TxScenario.txPwrCtrl))
			{
				if (txPwrCtrl.show == "TxPowerForce_CLPC")
				{
					if (targetPower == wCN39xx_TxScenario.targetPower)
					{
						return true;
					}
				}
				else if (gainIndex == wCN39xx_TxScenario.gainIndex && dacGain == wCN39xx_TxScenario.dacGain && paCfg == wCN39xx_TxScenario.paCfg)
				{
					return true;
				}
			}
		}
		return false;
	}
}
