using System.Threading;
using QC.QTMDotNetKernelInterface;

namespace QC.MultiplexManager;

[QTMTestClass]
public class MultiplexManager
{
	private MultiplexManagerImp mm;

	public MultiplexManager()
	{
		mm = new MultiplexManagerImp();
	}

	[QTMParameter(ArgumentName = "DUT_Number", DefaultValue = "1", Description = "The name of the mutex to unlock will be based on the GROUP ID that this DUT_Number belongs to, as defined in the Multiplex Manager configuration file.")]
	[QTMParameter(ArgumentName = "Input_Parameter_Source", DefaultValue = "QSPR_GLOBAL_VARIABLES", Description = "Specifies whether to get the input parameters for this test from QSPR Global Variables or from the Test Tree Input Parameters themselves. If QSPR_GLOBAL_VARIABLES is selected, the QSPR GVs MULTIPLEX_MANAGER_CONFIG_FILE and DUT_INDEX will be used.")]
	[QTMParameter(ArgumentName = "Multiplex_Manager_Config_File", DefaultValue = "", DisplayHint = DisplayHints.FILE, Description = "Full path and filename for the Multiplex Manager configuration file which specifies DUT grouping and multiplexer information.")]
	public bool UnlockResource(InputParameterSource Input_Parameter_Source, string Multiplex_Manager_Config_File, int DUT_Number)
	{
		return mm.UnlockResourceImp(Input_Parameter_Source, Multiplex_Manager_Config_File, DUT_Number);
	}

	[QTMParameter(ArgumentName = "DUT_Number", DefaultValue = "1", Description = "The name of the mutex to lock will be based on the GROUP ID that this DUT_Number belongs to, as defined in the Multiplex Manager configuration file.")]
	[QTMParameter(ArgumentName = "Multiplex_Manager_Config_File", DefaultValue = "", DisplayHint = DisplayHints.FILE, Description = "Full path and filename for the Multiplex Manager configuration file which specifies DUT grouping and multiplexer information.")]
	[QTMParameter(ArgumentName = "Lock_Acq_Timeout", DefaultValue = "-1", Description = "How long to wait to acquire the mutex lock. A value of -1 means wait indefinitely. If the mutex is not acquired before the timeout, the test returns failure.", UnitOfMeasure = "sec")]
	[QTMParameter(ArgumentName = "Input_Parameter_Source", DefaultValue = "QSPR_GLOBAL_VARIABLES", Description = "Specifies whether to get the input parameters for this test from QSPR Global Variables or from the Test Tree Input Parameters themselves. If QSPR_GLOBAL_VARIABLES is selected, the QSPR GVs MULTIPLEX_MANAGER_CONFIG_FILE, DUT_INDEX, and XTT_TIMEOUT will be used.")]
	public bool LockResource(InputParameterSource Input_Parameter_Source, string Multiplex_Manager_Config_File, int DUT_Number, int Lock_Acq_Timeout)
	{
		return mm.LockResourceImp(Input_Parameter_Source, Multiplex_Manager_Config_File, DUT_Number, Lock_Acq_Timeout);
	}

	[QTMParameter(ArgumentName = "Requested_RF_Ports", DefaultValue = "C0_WCDMA_TX0,C0_WCDMA_RX0,C0_WCDMA_RX1,C0_LTE_TX0,C0_LTE_RX0,C0_LTE_RX1,C1_LTE_RX0,C1_LTE_RX1,C0_GSM_TX0,C0_GSM_RX0,C1_GSM_TX0,C1_GSM_RX0,C0_CDMA_TX0,C0_CDMA_RX0,C0_CDMA_RX1,C0_TDSCDMA_TX0,C0_TDSCDMA_RX0,C0_TDSCDMA_RX1", Description = "The specific technologies to be tested.")]
	[QTMParameter(ArgumentName = "DUT_Number", DefaultValue = "1", Description = "The specific DUT path to switch to.")]
	[QTMParameter(ArgumentName = "Input_Parameter_Source", DefaultValue = "QSPR_GLOBAL_VARIABLES", Description = "Specifies whether to get the input parameters for this test from QSPR Global Variables or from the Test Tree Input Parameters themselves. If QSPR_GLOBAL_VARIABLES is selected, the QSPR GVs MULTIPLEX_MANAGER_CONFIG_FILE and DUT_INDEX will be used.")]
	[QTMParameter(ArgumentName = "Multiplex_Manager_Config_File", DefaultValue = "", DisplayHint = DisplayHints.FILE, Description = "Full path and filename for the Multiplex Manager configuration file which specifies DUT grouping and multiplexer information.")]
	public bool SwitchPath(InputParameterSource Input_Parameter_Source, string Multiplex_Manager_Config_File, int DUT_Number, string Requested_RF_Ports)
	{
		return mm.SwitchPathImp(Input_Parameter_Source, Multiplex_Manager_Config_File, DUT_Number, Requested_RF_Ports, "");
	}

	[QTMParameter(ArgumentName = "Multiplex_Manager_Config_File", DefaultValue = "", DisplayHint = DisplayHints.FILE, Description = "Full path and filename for the Multiplex Manager configuration file which specifies DUT grouping and multiplexer information.")]
	[QTMParameter(ArgumentName = "Requested_RF_Ports", DefaultValue = "C0_WCDMA_TX0,C0_WCDMA_RX0,C0_WCDMA_RX1,C0_LTE_TX0,C0_LTE_RX0,C0_LTE_RX1,C1_LTE_RX0,C1_LTE_RX1,C0_GSM_TX0,C0_GSM_RX0,C1_GSM_TX0,C1_GSM_RX0,C0_CDMA_TX0,C0_CDMA_RX0,C0_CDMA_RX1,C0_TDSCDMA_TX0,C0_TDSCDMA_RX0,C0_TDSCDMA_RX1", Description = "The specific technologies to be tested.")]
	[QTMParameter(ArgumentName = "Requested_Bands", DefaultValue = "", Description = "Comma separated list of bands to be tested. Supported bands: LTE_B1..LTE_BX, WCDMA_B1..WCDMA_BX, CDMA_B0..CDMA_BX, GSM")]
	[QTMParameter(ArgumentName = "Input_Parameter_Source", DefaultValue = "QSPR_GLOBAL_VARIABLES", Description = "Specifies whether to get the input parameters for this test from QSPR Global Variables or from the Test Tree Input Parameters themselves. If QSPR_GLOBAL_VARIABLES is selected, the QSPR GVs MULTIPLEX_MANAGER_CONFIG_FILE and DUT_INDEX will be used.")]
	[QTMParameter(ArgumentName = "DUT_Number", DefaultValue = "1", Description = "The specific DUT path to switch to.")]
	public bool SwitchPath(InputParameterSource Input_Parameter_Source, string Multiplex_Manager_Config_File, int DUT_Number, string Requested_RF_Ports, string Requested_Bands)
	{
		return mm.SwitchPathImp(Input_Parameter_Source, Multiplex_Manager_Config_File, DUT_Number, Requested_RF_Ports, Requested_Bands);
	}

	[QTMParameter(ArgumentName = "Technology_Code", DefaultValue = "", Description = "QTI SCPI Technology Code", IOType = ParameterIOType.Input)]
	[QTMParameter(ArgumentName = "Input_Parameter_Source", DefaultValue = "QSPR_GLOBAL_VARIABLES", Description = "Specifies whether to get the input parameters for this test from QSPR Global Variables or from the Test Tree Input Parameters themselves. If QSPR_GLOBAL_VARIABLES is selected, the QSPR GV MULTIPLEX_MANAGER_CONFIG_FILE will be used.")]
	[QTMParameter(ArgumentName = "Multiplex_Manager_Config_File", DefaultValue = "", DisplayHint = DisplayHints.FILE, Description = "Full path and filename for the Multiplex Manager configuration file which specifies DUT grouping and multiplexer information.")]
	[QTMParameter(ArgumentName = "Tx_Antenna_Numbers", DefaultValue = "WWAN_ANT1", Description = "Comma separate list of Antenna Identifier in Multipex Manager Configuration File", IOType = ParameterIOType.Input)]
	[QTMParameter(ArgumentName = "Rx_Antenna_Numbers", DefaultValue = "WWAN_ANT1,WWAN_ANT2", Description = "Comma separate list of Antenna Identifier in Multipex Manager Configuration File", IOType = ParameterIOType.Input)]
	public bool SwitchPathByAntennaNumbers(InputParameterSource Input_Parameter_Source, string Multiplex_Manager_Config_File, int DUT_Number, string Tx_Antenna_Numbers, string Rx_Antenna_Numbers, string Technology_Code)
	{
		return mm.SwitchPathAntennaNumbersImp(Input_Parameter_Source, Multiplex_Manager_Config_File, DUT_Number, Tx_Antenna_Numbers, Rx_Antenna_Numbers, Technology_Code);
	}

	[QTMParameter(ArgumentName = "DUT_Number", DefaultValue = "1", Description = "The specific DUT path to switch to.")]
	[QTMParameter(ArgumentName = "Input_Parameter_Source", DefaultValue = "QSPR_GLOBAL_VARIABLES", Description = "Specifies whether to get the input parameters for this test from QSPR Global Variables or from the Test Tree Input Parameters themselves. If QSPR_GLOBAL_VARIABLES is selected, the QSPR GV MULTIPLEX_MANAGER_CONFIG_FILE will be used.")]
	[QTMParameter(ArgumentName = "Multiplex_Manager_Config_File", DefaultValue = "", DisplayHint = DisplayHints.FILE, Description = "Full path and filename for the Multiplex Manager configuration file which specifies DUT grouping and multiplexer information.")]
	public bool SetPorsPathsGlobalVariable(InputParameterSource Input_Parameter_Source, string Multiplex_Manager_Config_File, int DUT_Number)
	{
		return mm.SetPortsPathsGlobalVariableImp(Input_Parameter_Source, Multiplex_Manager_Config_File, DUT_Number);
	}

	[QTMParameter(ArgumentName = "DUT_Number", DefaultValue = "1", Description = "The specific DUT path to switch to.")]
	[QTMParameter(ArgumentName = "Multiplex_Manager_Config_File", DefaultValue = "", DisplayHint = DisplayHints.FILE, Description = "Full path and filename for the Multiplex Manager configuration file which specifies DUT grouping and multiplexer information.")]
	public void SetMultiPortGlobalVariable(string Multiplex_Manager_Config_File, int DUT_Number)
	{
		mm.SetGlobalVariable("MULTIPLEX_MANAGER_CONFIG_FILE", Multiplex_Manager_Config_File);
		mm.SetGlobalVariable("DUT_INDEX", DUT_Number.ToString());
	}

	[QTMParameter(ArgumentName = "Dut_IDs", Description = "Comma separated list of DUT IDs defined in the Multiplex Manager configuration file.", IOType = ParameterIOType.Output)]
	[QTMParameter(ArgumentName = "Multiplex_Manager_Config_File", DefaultValue = "", DisplayHint = DisplayHints.FILE, Description = "Full path and filename for the Multiplex Manager configuration file which specifies DUT grouping and multiplexer information.")]
	[QTMParameter(ArgumentName = "Input_Parameter_Source", DefaultValue = "QSPR_GLOBAL_VARIABLES", Description = "Specifies whether to get the input parameters for this test from QSPR Global Variables or from the Test Tree Input Parameters themselves. If QSPR_GLOBAL_VARIABLES is selected, the QSPR GV MULTIPLEX_MANAGER_CONFIG_FILE will be used.")]
	[QTMParameter(ArgumentName = "Group_IDs", Description = "Comma separated list of Group IDs defined in the Multiplex Manager configuration file.", IOType = ParameterIOType.Output)]
	public bool GetDutAndGroupIDs(InputParameterSource Input_Parameter_Source, string Multiplex_Manager_Config_File, out string Dut_IDs, out string Group_IDs)
	{
		return mm.GetDutAndGroupIDsImp(Input_Parameter_Source, Multiplex_Manager_Config_File, out Dut_IDs, out Group_IDs);
	}

	[QTMParameter(ArgumentName = "SleepTime", DefaultValue = "10", Description = "Sleep time in second")]
	public bool Sleep(int SleepTime)
	{
		Thread.Sleep(SleepTime * 1000);
		return true;
	}
}
