using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Xml.Serialization;
using QC.MMI.MMI_Common;
using QC.MMI.MMI_PCBA_Tester_Control;
using QC.MMI.MMI_StationConfig;
using QC.QMSLPhone;
using QC.QTMDotNetKernelInterface;
using QC.QTMDotNetKernelInterface.Environment;
using TableApi;

namespace QC.MMI.MMI_PCBA_Tests;

[QTMTestClass]
public class MMI_PCBA_Tests : QSPRTest
{
	public enum MMIMODE
	{
		FFBM,
		QMMI
	}

	private enum StationFlagOptions
	{
		PASS = 80,
		FAIL = 70,
		UNTESTED = 85,
		BYPASS = 66
	}

	public enum FTMUtilityOptions
	{
		AUTOSTART,
		WLAN,
		BT,
		CHARGER,
		NFC
	}

	public enum xyLOCATE
	{
		HOME_KEY,
		MIC1,
		MIC2,
		LIGHTSENSE,
		LED_1,
		LED_2,
		LED_3,
		EARPIECE,
		PROXSENSE,
		LEVER1,
		LEVER2,
		LEVER3,
		LEVER4,
		LEVER5,
		VOLUP,
		VOLDWN,
		PWR,
		ICON_CALL,
		KEYPD_1,
		KEYPD_2,
		KEYPD_3,
		KEYPD_4,
		KEYPD_5,
		KEYPD_6,
		KEYPD_7,
		KEYPD_8,
		KEYPD_9,
		KEYPD_0,
		KEY_UNLOCK,
		LOC_LCD_BACKLIGHT,
		LOC_TOUCH_1,
		LOC_TOUCH_2,
		LOC_TOUCH_3,
		LOC_TOUCH_4,
		LCD_LL,
		LCD_LR,
		LCD_UL,
		LCD_UR,
		SPKR_1,
		SPKR_2,
		SPKR_3,
		SPKR_4,
		MAG_POS1,
		MAG_POS2,
		MAG_POS3,
		MAG_POS4,
		HALL_1,
		HALL_2,
		SPARE1,
		SPARE2,
		SPARE3,
		SPARE4,
		SPARE5,
		SPARE6,
		SPARE7,
		SPARE8,
		SPARE9,
		UL_CORNER,
		LL_CORNER,
		UR_CORNER,
		LR_CORNER
	}

	public const string tempLogFolder = "C:\\Qualcomm\\QDART\\MMI\\temp\\";

	private const int audioTaskFinishWaitTimeMs = 1000;

	private const int vendorQualcomm = 535;

	private const int vendorSony = 432;

	private const int vendorAvago = 263;

	private const int vendorRFMicro = 308;

	private const int vendorMurata = 524;

	private const string UNKNOWN = "Unknown";

	public const string OPTIONAL_SECTION = "Optional";

	private Phone phone;

	private uint _timeOut;

	private string _Optional;

	private string _parameter;

	private string stationconfignickname;

	private string dut;

	private string port;

	private bool _useqpst;

	private bool _moreLog;

	private int _sntype;

	private int _targettype;

	private int _mmitype;

	private MMIMODE MMI_MODE;

	private bool enable_reconnect;

	private bool _reverse;

	private string _sequence_file;

	private bool _check_ffbm;

	private bool _erase_folder;

	private bool use_dutsequencefile;

	private int _delay_s_port_to_mmi;

	private int currentStation;

	private int reboot_type;

	private int _samples;

	private double onOffDeltaVolt;

	private bool _deprecated;

	private bool disableCharging;

	private bool has_homekey;

	private int retryCounts;

	private double d_delta_value;

	private bool _checkcapacity;

	private double sdcard_capacity_ll;

	private double sdcard_capacity_ul;

	private int wifi_test_type;

	private string wifi_ap_name;

	private double wifi_rssi_ll;

	private int bluetooth_test_type;

	private string bluetooth_ap_name;

	private int wigig_test_type;

	private double wigig_level_ll;

	private string wigig_ap_name;

	private double bt_rssi_ll;

	private bool test_wifi;

	private string test_wifi_setting;

	private bool test_bluetooth;

	private string test_bluetooth_setting;

	private bool test_wigig;

	private string test_wigig_setting;

	private bool test_gps;

	private bool _value_check;

	private int _wait_table_move_s;

	private bool movesensorboard;

	private int xyTable_X_max_block_camera;

	private int xyTable_Y_max_block_camera;

	private int _devicesPresentRequired;

	private bool led_red;

	private bool led_green;

	private bool led_blue;

	private bool light_detect_only;

	private bool exact_4_points;

	private int test_delay_getresult_s;

	private string key_list;

	private string user_defined_case;

	private bool test_usb_3x;

	private int select_sbu_path;

	private string case_name;

	private bool _pressureSensor;

	private double _pressureSensorDelta_ll;

	private double _pressureSensorDelta_ul;

	private bool _checkHumiditySensor;

	private double _humiditySensorDelta_ll;

	private double _humiditySensorDelta_ul;

	private bool _checkTemperatureSensor;

	private double _temperatureSensorDelta_ll;

	private double _temperatureSensorDelta_ul;

	private double usb_ufpVolt_ll;

	private bool _resetDUT;

	private uint key_interm_time;

	private bool checkPower;

	private double power_ll;

	private bool xyTableEnabled;

	private string xyTableCfgNickname = "mmi_xyTable.cfg";

	private Speed XY_SPEED = Speed.DEFAULT_16;

	private bool Z_SPEED_UP;

	private bool useFixture;

	private string dut_index = "";

	private int cameraID;

	private int test_delay_s;

	private int image_W;

	private int image_H;

	private string roi;

	private bool enableDebug;

	private int cradleType = 1;

	private string sequenceFileLocalLocation = "C:\\Program Files (x86)\\Qualcomm\\QDART\\Databases\\mmi-pcba.cfg";

	private string sequenceFileRemoteName = "pcba_default.xml";

	private string imageFileLocalLocation = "C:\\Qualcomm\\QDART\\MMI\\temp\\image.png";

	private string imageFileRemoteName = "image.png";

	private string previousTestName = "Not Tested";

	private string MMI_testName = "";

	private ushort FTMErrorCode;

	private uint TestErrorCode;

	private ushort iNumTest;

	private byte TimeOutOccurred;

	private int fixtureInstanceID;

	private bool fixtureIsRevB;

	private string portDUT = "";

	private bool useQPST;

	private bool readSN;

	private bool isAPQ;

	private string portXyTable = "";

	private string baudrateXyTable = "";

	private string resultFileRemoteName = "mmi-pcba.res";

	private string ManualTestResultFileRemoteName = "mmi.res";

	private USB_IO_Expander fixtureInstance = new USB_IO_Expander();

	private bool xyTable_connected;

	private xyTable xyTableInstance = new xyTable();

	private int testIndex;

	private Result xmlRes = new Result();

	private TestCase xmlRes4Case = new TestCase();

	private string rffe_scan_local_path = "C:\\Qualcomm\\QDART\\MMI\\temp\\RFFE_SCAN.dat";

	private bool overallTestResut = true;

	private string resultsFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\mmi-pcba.res";

	private string touchLogRemoteName = "touch_track.txt";

	private string touchLogFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\touch_track.txt";

	private string gyroLogRemoteName = "GYROSCOPE.track";

	private string gyroLogFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK.txt";

	private LibraryModeEnum ConnectLibMod;

	private int DUT_COMPORT;

	private string msg = "";

	[QTMParameter(ParameterIOType.Input, TestList = "", Description = "Timeout in sec", UnitOfMeasure = "sec", DefaultValue = "5", NumberOfElements = 1)]
	public uint TimeOut
	{
		get
		{
			return _timeOut;
		}
		set
		{
			_timeOut = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, Description = "Optional input parameter", DefaultValue = "", NumberOfElements = 1)]
	public string Optional
	{
		get
		{
			return _Optional;
		}
		set
		{
			_Optional = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "", Description = "", UnitOfMeasure = "", DefaultValue = "", NumberOfElements = 1, ParentName = "Optional")]
	public string PARAMETER
	{
		get
		{
			return _parameter;
		}
		set
		{
			_parameter = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "Optional to set nickname to compatible for different project", UnitOfMeasure = "", DefaultValue = "mmi_stationConfig.xml", NumberOfElements = 1)]
	public string StationConfigNickname
	{
		get
		{
			return stationconfignickname;
		}
		set
		{
			stationconfignickname = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "Common DUT settings", UnitOfMeasure = "", DefaultValue = "", NumberOfElements = 1)]
	public string DUT
	{
		get
		{
			return dut;
		}
		set
		{
			dut = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "DUT Diag port", UnitOfMeasure = "", DefaultValue = "Auto", NumberOfElements = 1, ParentName = "DUT")]
	public string PORT
	{
		get
		{
			return port;
		}
		set
		{
			port = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "Use QPST server to connect DUT", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1, ParentName = "DUT")]
	public bool UseQPST
	{
		get
		{
			return _useqpst;
		}
		set
		{
			_useqpst = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "Log more details", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1, ParentName = "Optional")]
	public bool MoreLog
	{
		get
		{
			return _moreLog;
		}
		set
		{
			_moreLog = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "How to get SN", UnitOfMeasure = "", DisplayHint = DisplayHints.ENUM_LIST, Constraints = "0:Generate;1:NV;2:GV;3:Other", DefaultValue = "1", NumberOfElements = 1, ParentName = "DUT")]
	public int SN_Type
	{
		get
		{
			return _sntype;
		}
		set
		{
			_sntype = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "MSM/MDM, APQ, Other", UnitOfMeasure = "", DisplayHint = DisplayHints.ENUM_LIST, Constraints = "0:MSM/MDM;1:APQ;2:Other", DefaultValue = "0", NumberOfElements = 1, ParentName = "DUT")]
	public int Target
	{
		get
		{
			return _targettype;
		}
		set
		{
			_targettype = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "MMI APP: FFBM, QMMI, Auto -read app version to determine QMMI or not", UnitOfMeasure = "", DisplayHint = DisplayHints.ENUM_LIST, Constraints = "0:Auto;1:FFBM;2:QMMI", DefaultValue = "2", NumberOfElements = 1, ParentName = "DUT")]
	public int MMI_TYPE
	{
		get
		{
			return _mmitype;
		}
		set
		{
			_mmitype = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "USB_OTG", Description = "", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool Enable_Reconnect
	{
		get
		{
			return enable_reconnect;
		}
		set
		{
			enable_reconnect = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "AUTO_DETECT", Description = "reverse direction", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool reverse
	{
		get
		{
			return _reverse;
		}
		set
		{
			_reverse = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "STATION_INIT", Description = "DUT test sequence file, in Databases folder", UnitOfMeasure = "", DefaultValue = "pcba_default.xml", NumberOfElements = 1, ParentName = "DUT")]
	public string SequenceFileNickname
	{
		get
		{
			return _sequence_file;
		}
		set
		{
			_sequence_file = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CONNECT", Description = "Check DUT under FFBM test mode", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool FFBM_CHECK
	{
		get
		{
			return _check_ffbm;
		}
		set
		{
			_check_ffbm = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CONNECT", Description = "Erase all files under FTM_AP folder", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool ERASE_FTM_AP_FOLDER
	{
		get
		{
			return _erase_folder;
		}
		set
		{
			_erase_folder = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CONNECT", Description = "Use sequence file in DUT", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool USE_DUT_SEQUENCE_FILE
	{
		get
		{
			return use_dutsequencefile;
		}
		set
		{
			use_dutsequencefile = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CONNECT", Description = "Delay interval time from diag port shown to MMI ready in seconds", UnitOfMeasure = "sec", DefaultValue = "0", NumberOfElements = 1)]
	public int DELAY_S_PORT_TO_MMI
	{
		get
		{
			return _delay_s_port_to_mmi;
		}
		set
		{
			_delay_s_port_to_mmi = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CHECK_PREVIOUS_STATION_FLAG,WRITE_STATION_FLAG", Description = "Current station index", UnitOfMeasure = "", DefaultValue = "2", NumberOfElements = 1)]
	public int currentStationIndex
	{
		get
		{
			return currentStation;
		}
		set
		{
			currentStation = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "REBOOT_DUT,USB_UFP, USB_VCONN", Description = "Select reboot type", DisplayHint = DisplayHints.ENUM_LIST, Constraints = "0:diag;1:adb", DefaultValue = "0", NumberOfElements = 1, ParentName = "Reset_DUT")]
	public int REBOOT_TYPE
	{
		get
		{
			return reboot_type;
		}
		set
		{
			reboot_type = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "VIBRATOR", Description = "Samples to track target", UnitOfMeasure = "", DefaultValue = "10", NumberOfElements = 1)]
	public int SAMPLES
	{
		get
		{
			return _samples;
		}
		set
		{
			_samples = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_BACKLIGHT_PHONE,LCD_RGB_PHONE,LED_RGB_PHONE,LCD_RGB,LED_RED,LED_RED_PHONE,LED_GREEN,LED_GREEN_PHONE,LED_BLUE,LED_BLUE_PHONE,VIBRATOR,FLASHLIGHT,KEY_BACKLIGHT", Description = "", UnitOfMeasure = "", DefaultValue = "1", NumberOfElements = 1)]
	public double onOffDelta
	{
		get
		{
			return onOffDeltaVolt;
		}
		set
		{
			onOffDeltaVolt = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_RGB,LCD_RGB_PHONE,LCD_BACKLIGHT_PHONE,LED_RGB_PHONE,FLASHLIGHT,VIBRATOR,LED_RED,LED_RED_PHONE,LED_GREEN,LED_GREEN_PHONE,LED_BLUE,LED_BLUE_PHONE", Description = "", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1, ParentName = "Optional")]
	public bool deprecated
	{
		get
		{
			return _deprecated;
		}
		set
		{
			_deprecated = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LED_RGB_PHONE", Description = "Disable charging to turn off charging status indicator", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool DISABLE_CHARGING
	{
		get
		{
			return disableCharging;
		}
		set
		{
			disableCharging = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "KEY_PHONE", Description = "Device have home key or not", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool HAS_HOMEKEY
	{
		get
		{
			return has_homekey;
		}
		set
		{
			has_homekey = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "TOUCH_PHONE, KEY_PHONE", Description = "Retry counts", UnitOfMeasure = "", DefaultValue = "2", NumberOfElements = 1, ParentName = "Optional")]
	public int RetryCounts
	{
		get
		{
			return retryCounts;
		}
		set
		{
			retryCounts = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "PROXIMITY_SENSOR_PHONE", Description = "", UnitOfMeasure = "", DefaultValue = "2.0", NumberOfElements = 1)]
	public double d_Delta_Value
	{
		get
		{
			return d_delta_value;
		}
		set
		{
			d_delta_value = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "SDCARD", Description = "Check capacity", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool Check_Capacity
	{
		get
		{
			return _checkcapacity;
		}
		set
		{
			_checkcapacity = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "SDCARD", Description = "", UnitOfMeasure = "", DefaultValue = "1000000", NumberOfElements = 1, ParentName = "Check_Capacity")]
	public double sdcard_capacity_LL
	{
		get
		{
			return sdcard_capacity_ll;
		}
		set
		{
			sdcard_capacity_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "SDCARD", Description = "", UnitOfMeasure = "", DefaultValue = "100000000", NumberOfElements = 1, ParentName = "Check_Capacity")]
	public double sdcard_capacity_UL
	{
		get
		{
			return sdcard_capacity_ul;
		}
		set
		{
			sdcard_capacity_ul = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,WIFI", Description = "", UnitOfMeasure = "", DisplayHint = DisplayHints.ENUM_LIST, Constraints = "0:Check result only;1:Scan AP;2:Check signal level", DefaultValue = "2", NumberOfElements = 1, ParentName = "TEST_WIFI_SETTING")]
	public int WIFI_TEST_TYPE
	{
		get
		{
			return wifi_test_type;
		}
		set
		{
			wifi_test_type = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,WIFI", Description = "", UnitOfMeasure = "", DefaultValue = "", NumberOfElements = 1, ParentName = "WIFI_TEST_TYPE")]
	public string WIFI_AP_NAME
	{
		get
		{
			return wifi_ap_name;
		}
		set
		{
			wifi_ap_name = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,WIFI", Description = "", UnitOfMeasure = "", DefaultValue = "-80", NumberOfElements = 1, ParentName = "WIFI_TEST_TYPE")]
	public double WIFI_RSSI_LL
	{
		get
		{
			return wifi_rssi_ll;
		}
		set
		{
			wifi_rssi_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,BLUETOOTH", Description = "", UnitOfMeasure = "", DisplayHint = DisplayHints.ENUM_LIST, Constraints = "0:Check result only;1:Scan AP;2:Check signal level", DefaultValue = "2", NumberOfElements = 1, ParentName = "TEST_BLUETOOTH_SETTING")]
	public int BLUETOOTH_TEST_TYPE
	{
		get
		{
			return bluetooth_test_type;
		}
		set
		{
			bluetooth_test_type = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,BLUETOOTH", Description = "", UnitOfMeasure = "", DefaultValue = "Hydra", NumberOfElements = 1, ParentName = "BLUETOOTH_TEST_TYPE")]
	public string BLUETOOTH_AP_NAME
	{
		get
		{
			return bluetooth_ap_name;
		}
		set
		{
			bluetooth_ap_name = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,WIGIG", Description = "", UnitOfMeasure = "", DisplayHint = DisplayHints.ENUM_LIST, Constraints = "0:Check result only;1:Scan AP;2:Check signal level", DefaultValue = "2", NumberOfElements = 1, ParentName = "TEST_WIGIG_SETTING")]
	public int WIGIG_TEST_TYPE
	{
		get
		{
			return wigig_test_type;
		}
		set
		{
			wigig_test_type = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,WIGIG", Description = "", UnitOfMeasure = "", DefaultValue = "-100", NumberOfElements = 1, ParentName = "WIGIG_TEST_TYPE")]
	public double WIGIG_LEVEL_LL
	{
		get
		{
			return wigig_level_ll;
		}
		set
		{
			wigig_level_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,WIGIG", Description = "", UnitOfMeasure = "", DefaultValue = "AndroidAP", NumberOfElements = 1, ParentName = "WIGIG_TEST_TYPE")]
	public string WIGIG_AP_NAME
	{
		get
		{
			return wigig_ap_name;
		}
		set
		{
			wigig_ap_name = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,BLUETOOTH", Description = "", UnitOfMeasure = "", DefaultValue = "-100", NumberOfElements = 1, ParentName = "BLUETOOTH_TEST_TYPE")]
	public double BLUETOOTH_RSSI_LL
	{
		get
		{
			return bt_rssi_ll;
		}
		set
		{
			bt_rssi_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST", Description = "To test WIFI", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool TEST_WIFI
	{
		get
		{
			return test_wifi;
		}
		set
		{
			test_wifi = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,WIFI", Description = "WIFI test setting", DefaultValue = "", NumberOfElements = 1)]
	public string TEST_WIFI_SETTING
	{
		get
		{
			return test_wifi_setting;
		}
		set
		{
			test_wifi_setting = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST", Description = "To test BLUETOOTH", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool TEST_BLUETOOTH
	{
		get
		{
			return test_bluetooth;
		}
		set
		{
			test_bluetooth = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,BLUETOOTH", Description = "BLUETOOTH test setting", DefaultValue = "", NumberOfElements = 1)]
	public string TEST_BLUETOOTH_SETTING
	{
		get
		{
			return test_bluetooth_setting;
		}
		set
		{
			test_bluetooth_setting = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST", Description = "To test WIGIG", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool TEST_WIGIG
	{
		get
		{
			return test_wigig;
		}
		set
		{
			test_wigig = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST,WIGIG", Description = "WIGIG test setting", DefaultValue = "", NumberOfElements = 1)]
	public string TEST_WIGIG_SETTING
	{
		get
		{
			return test_wigig_setting;
		}
		set
		{
			test_wigig_setting = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "BACKGROUND_TEST", Description = "To test GPS", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool TEST_GPS
	{
		get
		{
			return test_gps;
		}
		set
		{
			test_gps = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "AUDIO_LOOPBACK_EARPIECE_EX_HEADSET_MIC_PHONE,AUDIO_LOOPBACK_SPEAKER_EX_HEADSET_MIC_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC1_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC2_PHONE,AUDIO_LOOPBACK_SPEAKER_EX_MIC2_PHONE,AUDIO_LOOPBACK_SPEAKER_PHONE_EX_MIC1", Description = "", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool value_check
	{
		get
		{
			return _value_check;
		}
		set
		{
			_value_check = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_RGB_PHONE,MAGNETIC_SENSOR_PHONE,KEY_PHONE,SIDE_KEY_PHONE,LIGHT_SENSOR_PHONE,PROXIMITY_SENSOR_PHONE,LED_RED_PHONE,LED_GREEN_PHONE,LED_BLUE_PHONE", Description = "", UnitOfMeasure = "", DefaultValue = "0", NumberOfElements = 1, ParentName = "Optional")]
	public int wait_table_move_s
	{
		get
		{
			return _wait_table_move_s;
		}
		set
		{
			_wait_table_move_s = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CAMERA_FRONT_FACE_DETECT", Description = "", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1, ParentName = "Optional")]
	public bool MoveSensorBoard
	{
		get
		{
			return movesensorboard;
		}
		set
		{
			movesensorboard = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CAMERA_FRONT_FACE_DETECT", Description = "", UnitOfMeasure = "", DefaultValue = "0", NumberOfElements = 1, ParentName = "Optional")]
	public int X_max
	{
		get
		{
			return xyTable_X_max_block_camera;
		}
		set
		{
			xyTable_X_max_block_camera = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CAMERA_FRONT_FACE_DETECT", Description = "", UnitOfMeasure = "", DefaultValue = "0", NumberOfElements = 1, ParentName = "Optional")]
	public int Y_max
	{
		get
		{
			return xyTable_Y_max_block_camera;
		}
		set
		{
			xyTable_Y_max_block_camera = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "RFFE_SCAN", Description = "", UnitOfMeasure = "", DefaultValue = "6", NumberOfElements = 1)]
	public int DevicesRequired
	{
		get
		{
			return _devicesPresentRequired;
		}
		set
		{
			_devicesPresentRequired = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LED_RGB_PHONE", Description = "DUT support LED_RED", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool LED_RED_TEST
	{
		get
		{
			return led_red;
		}
		set
		{
			led_red = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LED_RGB_PHONE", Description = "DUT support LED_GREEN", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool LED_GREEN_TEST
	{
		get
		{
			return led_green;
		}
		set
		{
			led_green = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LED_RGB_PHONE", Description = "DUT support LED_BLUE", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool LED_BLUE_TEST
	{
		get
		{
			return led_blue;
		}
		set
		{
			led_blue = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LED_RGB_PHONE", Description = "Only detect the light use LDR instead of RGB sensor to check each color", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool LIGHT_DETECT_ONLY
	{
		get
		{
			return light_detect_only;
		}
		set
		{
			light_detect_only = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "TOUCH_PHONE", Description = "Touch track report exactly 4 point", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool EXACT_4_POINTS
	{
		get
		{
			return exact_4_points;
		}
		set
		{
			exact_4_points = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "AUDIO_LOOPBACK_EARPIECE_EX_HEADSET_MIC_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC1_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC2_PHONE,AUDIO_LOOPBACK_SPEAKER_EX_HEADSET_MIC_PHONE", Description = "", UnitOfMeasure = "", DefaultValue = "5", NumberOfElements = 1, ParentName = "Optional")]
	public int Test_Delay_GetResult_S
	{
		get
		{
			return test_delay_getresult_s;
		}
		set
		{
			test_delay_getresult_s = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "KEYPAD", Description = "List all keys need to check, seperate by comma", UnitOfMeasure = "", DefaultValue = "power,up,down", NumberOfElements = 1)]
	public string KEY_LIST
	{
		get
		{
			return key_list;
		}
		set
		{
			key_list = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "", Description = "Specify test name as it is in sequence file, default same as test case name", UnitOfMeasure = "", DefaultValue = "", NumberOfElements = 1, ParentName = "Optional")]
	public string TEST_CASE_NAME_IN_SEQ_FILE
	{
		get
		{
			return user_defined_case;
		}
		set
		{
			user_defined_case = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "AUDIO_LOOPBACK_EARPIECE_EX_HEADSET_MIC_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC1_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC2_PHONE,AUDIO_LOOPBACK_SPEAKER_EX_HEADSET_MIC_PHONE", Description = "Flag to setup test for USB3.x feature/path", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool TEST_USB_3x
	{
		get
		{
			return test_usb_3x;
		}
		set
		{
			test_usb_3x = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "AUDIO_LOOPBACK_EARPIECE_EX_HEADSET_MIC_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC1_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC2_PHONE,AUDIO_LOOPBACK_SPEAKER_EX_HEADSET_MIC_PHONE", Description = "USB3.x MIC path", UnitOfMeasure = "", DisplayHint = DisplayHints.ENUM_LIST, Constraints = "0:SBU1;1:SBU2", DefaultValue = "1", NumberOfElements = 1, ParentName = "TEST_USB_3x")]
	public int SELECT_SBU_PATH
	{
		get
		{
			return select_sbu_path;
		}
		set
		{
			select_sbu_path = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "AUDIO_PLAYTONE_SPEAKER,AUDIO_LOOPBACK_HEADSET,AUDIO_LOOPBACK_MIC1_EARPIECE,AUDIO_LOOPBACK_SPEAKER_EX_HEADSET_MIC_PHONE,AUDIO_LOOPBACK_EARPIECE_EX_HEADSET_MIC_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC2_PHONE,AUDIO_LOOPBACK_HEADSET_EX_MIC1_PHONE", Description = "Test name in sequence file", UnitOfMeasure = "", DefaultValue = "", NumberOfElements = 1, ParentName = "Optional")]
	public string CASE_NAME
	{
		get
		{
			return case_name;
		}
		set
		{
			case_name = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "PRESSURE_SENSOR", Description = "Compare DUT pressure sensor to tester pressure sensor BMP285", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool Check_Pressure_Sensor
	{
		get
		{
			return _pressureSensor;
		}
		set
		{
			_pressureSensor = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "PRESSURE_SENSOR", Description = "", UnitOfMeasure = "Pa", DefaultValue = "-1.0", NumberOfElements = 1, ParentName = "Check_Pressure_Sensor")]
	public double Pressure_Sensor_Delta_LL
	{
		get
		{
			return _pressureSensorDelta_ll;
		}
		set
		{
			_pressureSensorDelta_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "PRESSURE_SENSOR", Description = "", UnitOfMeasure = "Pa", DefaultValue = "1.0", NumberOfElements = 1, ParentName = "Check_Pressure_Sensor")]
	public double Pressure_Sensor_Delta_UL
	{
		get
		{
			return _pressureSensorDelta_ul;
		}
		set
		{
			_pressureSensorDelta_ul = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "HUMIDITY_SENSOR", Description = "Compare DUT humidity sensor to tester humidity sensor SHTW2", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool Check_Humidity_Sensor
	{
		get
		{
			return _checkHumiditySensor;
		}
		set
		{
			_checkHumiditySensor = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "HUMIDITY_SENSOR", Description = "", UnitOfMeasure = "%", DefaultValue = "-1.0", NumberOfElements = 1, ParentName = "Check_Humidty_Sensor")]
	public double Humidity_Sensor_Delta_LL
	{
		get
		{
			return _humiditySensorDelta_ll;
		}
		set
		{
			_humiditySensorDelta_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "HUMIDITY_SENSOR", Description = "", UnitOfMeasure = "%", DefaultValue = "1.0", NumberOfElements = 1, ParentName = "Check_Humidty_Sensor")]
	public double Humidity_Sensor_Delta_UL
	{
		get
		{
			return _humiditySensorDelta_ul;
		}
		set
		{
			_humiditySensorDelta_ul = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "TEMPERATURE_SENSOR", Description = "Compare DUT temperature sensor to tester temperature sensor SHTW2", UnitOfMeasure = "", DefaultValue = "True", NumberOfElements = 1)]
	public bool Check_Temperature_Sensor
	{
		get
		{
			return _checkTemperatureSensor;
		}
		set
		{
			_checkTemperatureSensor = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "TEMPERATURE_SENSOR", Description = "", UnitOfMeasure = "C", DefaultValue = "-1.0", NumberOfElements = 1, ParentName = "Check_Temperature_Sensor")]
	public double Temperature_Sensor_Delta_LL
	{
		get
		{
			return _temperatureSensorDelta_ll;
		}
		set
		{
			_temperatureSensorDelta_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "TEMPERATURE_SENSOR", Description = "", UnitOfMeasure = "C", DefaultValue = "1.0", NumberOfElements = 1, ParentName = "Check_Temperature_Sensor")]
	public double Temperature_Sensor_Delta_UL
	{
		get
		{
			return _temperatureSensorDelta_ul;
		}
		set
		{
			_temperatureSensorDelta_ul = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "USB_UFP, USB_VCONN", Description = "", UnitOfMeasure = "", DefaultValue = "4.0", NumberOfElements = 1)]
	public double USB_UFPvolt_LL
	{
		get
		{
			return usb_ufpVolt_ll;
		}
		set
		{
			usb_ufpVolt_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "USB_UFP, USB_VCONN", Description = "Flag to reset then reconnect to the DUT", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool Reset_DUT
	{
		get
		{
			return _resetDUT;
		}
		set
		{
			_resetDUT = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "KEY, KEY_PHONE", Description = "Wait DUT back to QMMI after PWR key press", UnitOfMeasure = "sec", DefaultValue = "7", NumberOfElements = 1)]
	public uint KEY_INTERM_TIME
	{
		get
		{
			return key_interm_time;
		}
		set
		{
			key_interm_time = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CHECK_KEYWORDS_IN_GV", Description = "Flag to check power or not", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool CHECK_POWER
	{
		get
		{
			return checkPower;
		}
		set
		{
			checkPower = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "CHECK_KEYWORDS_IN_GV", Description = "", UnitOfMeasure = "dBFS", DefaultValue = "-30", NumberOfElements = 1, ParentName = "CHECK_POWER")]
	public double POWER_LL
	{
		get
		{
			return power_ll;
		}
		set
		{
			power_ll = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_QUALITY_PHONE", Description = "Camera ID", UnitOfMeasure = "", DefaultValue = "1", NumberOfElements = 1)]
	public int CameraID
	{
		get
		{
			return cameraID;
		}
		set
		{
			cameraID = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_QUALITY_PHONE", Description = "", UnitOfMeasure = "sec", DefaultValue = "2", NumberOfElements = 1)]
	public int TEST_DELAY_S
	{
		get
		{
			return test_delay_s;
		}
		set
		{
			test_delay_s = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_QUALITY_PHONE", Description = "", UnitOfMeasure = "", DefaultValue = "1280", NumberOfElements = 1)]
	public int IMAGE_W
	{
		get
		{
			return image_W;
		}
		set
		{
			image_W = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_QUALITY_PHONE", Description = "", UnitOfMeasure = "", DefaultValue = "960", NumberOfElements = 1)]
	public int IMAGE_H
	{
		get
		{
			return image_H;
		}
		set
		{
			image_H = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_QUALITY_PHONE", Description = "", UnitOfMeasure = "", DefaultValue = "350,350,780,350,780,630,350,630", NumberOfElements = 1)]
	public string ROI
	{
		get
		{
			return roi;
		}
		set
		{
			roi = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "LCD_QUALITY_PHONE", Description = "", UnitOfMeasure = "", DefaultValue = "False", NumberOfElements = 1)]
	public bool ENABLE_DEBUG
	{
		get
		{
			return enableDebug;
		}
		set
		{
			enableDebug = value;
		}
	}

	public bool OverallTestResut
	{
		get
		{
			return overallTestResut;
		}
		set
		{
			overallTestResut = value;
		}
	}

	public string ResultsFileName
	{
		get
		{
			return resultsFileName;
		}
		set
		{
			resultsFileName = value;
		}
	}

	public MMI_PCBA_Tests(QSPREnvironment qsprEnv)
		: base(qsprEnv)
	{
		phone = Phone.SpecificPhoneInstance(qsprEnv.SchedulerID, out var _);
	}

	public bool STATION_INIT()
	{
		testIndex = 0;
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string text = "";
			base.Env.GlobalVariable.GetGlobalVariable("DUT_INDEX", out dut_index);
			if (dut_index == "00")
			{
				base.Env.GlobalVariable.GetGlobalVariable("PANEL", out dut_index);
				base.Env.GlobalVariable.SetGlobalVariable("DUT_INDEX", dut_index);
			}
			portDUT = PORT;
			if (string.IsNullOrEmpty(dut_index) || dut_index == "00")
			{
				text = Path.Combine(GetType().Assembly.Location, "..\\..\\Databases", StationConfigNickname);
				xyTableInstance.xyTableCfgFullPath = Path.Combine(GetType().Assembly.Location, "..\\..\\Databases", xyTableCfgNickname);
				ResultsFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\mmi-pcba_" + phone.GetPhoneComPort() + Path.GetExtension(ResultsFileName);
			}
			else
			{
				text = Path.Combine(GetType().Assembly.Location, "..\\..\\Databases", "DUT_" + dut_index, StationConfigNickname);
				xyTableInstance.xyTableCfgFullPath = Path.Combine(GetType().Assembly.Location, "..\\..\\Databases", "DUT_" + dut_index, xyTableCfgNickname);
				rffe_scan_local_path = "C:\\Qualcomm\\QDART\\MMI\\temp\\RFFE_SCAN.dat";
				rffe_scan_local_path = rffe_scan_local_path.Replace("RFFE_SCAN.dat", "DUT" + dut_index + "_RFFE_SCAN.dat");
				ResultsFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\DUT" + dut_index + "_mmi-pcba.res";
				touchLogFileName = touchLogFileName.Replace("touch_track.txt", "DUT" + dut_index + "_touch_track.txt");
				gyroLogFileName = gyroLogFileName.Replace("GYROSCOPE_TRACK.txt", "DUT" + dut_index + "_GYROSCOPE_TRACK.txt");
			}
			WriteDebugMessage(text);
			if (!File.Exists(text))
			{
				WriteErrorMessage("stationConfig file not found");
				return false;
			}
			sequenceFileLocalLocation = Path.Combine(GetType().Assembly.Location, "..\\..\\Databases", SequenceFileNickname);
			if (SequenceFileNickname.Contains(".xml"))
			{
				resultFileRemoteName = "pcba_default_res.xml";
			}
			root root = new root();
			using (FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read, FileShare.Read))
			{
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(root));
				root = (root)xmlSerializer.Deserialize(fileStream);
				fileStream.Close();
			}
			if (MoreLog)
			{
				WriteDebugMessage("DUT.PORT: " + portDUT);
				WriteDebugMessage("DUT.OPTIONAL: " + root.DUT.OPTIONAL);
				WriteDebugMessage("FIXTURE.ID: " + root.FIXTURE.ID);
				WriteDebugMessage("FIXTURE.FixtureRevision: " + root.FIXTURE.FixtureRevision);
				WriteDebugMessage("FIXTURE.Enable: " + root.FIXTURE.Enable);
				WriteDebugMessage("FIXTURE.OPTIONAL: " + root.FIXTURE.OPTIONAL);
				WriteDebugMessage("XY_TABLE.PORT: " + root.XY_TABLE.PORT);
				WriteDebugMessage("XY_TABLE.Enable: " + root.XY_TABLE.Enable);
				WriteDebugMessage("XY_TABLE.CRADLE_TYPE: " + root.XY_TABLE.CRADLE_TYPE);
				WriteDebugMessage("XY_TABLE.XY_SPEED: " + root.XY_TABLE.XY_SPEED);
				WriteDebugMessage("XY_TABLE.Z_SPEED_UP: " + root.XY_TABLE.Z_SPEED_UP);
				WriteDebugMessage("XY_TABLE.OPTIONAL: " + root.XY_TABLE.OPTIONAL);
				WriteDebugMessage("Sequence: " + sequenceFileLocalLocation);
				WriteDebugMessage("xyTableCfg: " + xyTableInstance.xyTableCfgFullPath);
			}
			useQPST = UseQPST;
			isAPQ = Target == 1;
			readSN = SN_Type == 1;
			useFixture = bool.Parse(root.FIXTURE.Enable);
			fixtureInstanceID = int.Parse(root.FIXTURE.ID);
			if (!string.IsNullOrEmpty(root.FIXTURE.FixtureRevision))
			{
				fixtureIsRevB = (root.FIXTURE.FixtureRevision.Contains("B") ? true : false);
			}
			portXyTable = "COM" + root.XY_TABLE.PORT;
			baudrateXyTable = root.XY_TABLE.BAUDRATE;
			cradleType = int.Parse(root.XY_TABLE.CRADLE_TYPE);
			xyTableEnabled = bool.Parse(root.XY_TABLE.Enable);
			Enum.TryParse<Speed>(root.XY_TABLE.XY_SPEED, out XY_SPEED);
			bool.TryParse(root.XY_TABLE.Z_SPEED_UP, out Z_SPEED_UP);
			if (!Directory.Exists("C:\\Qualcomm\\QDART\\MMI\\temp\\"))
			{
				DirectoryInfo directoryInfo = new DirectoryInfo("C:\\Qualcomm\\QDART\\MMI\\temp\\");
				directoryInfo.Create();
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			return false;
		}
	}

	public bool CONNECT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		fixtureInstance.Vbatt_table_updated = true;
		fixtureInstance.isRevB = fixtureIsRevB;
		try
		{
			bool flag = false;
			if (useFixture)
			{
				string USB_Name = "";
				try
				{
					fixtureInstance.USB_Connect(fixtureInstanceID, out USB_Name);
				}
				catch (Exception ex)
				{
					WriteErrorMessage("Failed to match fixture ID or fixture not connected:");
					WriteErrorMessage(ex.Message);
					return false;
				}
				if (!fixtureInstance.IO_Inited())
				{
					fixtureInstance.IO_init();
					WriteDebugMessage(QC.MMI.MMI_PCBA_Tester_Control.DebugMessage.str_debug_msg);
				}
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_OTG_EN, ref setBit, ref IO_OUT);
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.VBAT_EN_N, ref setBit, ref IO_OUT);
				if (fixtureInstance.isRevB)
				{
					setBit = USB_IO_Expander.SetValue.HIGH;
					fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.OMTP_CTIA_SELECT, ref setBit, ref IO_OUT);
					fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.HUB_RESET_N, ref setBit, ref IO_OUT);
					if (!fixtureInstance.InitializeDevices())
					{
						WriteErrorMessage("InitializeDevices fail.");
						return false;
					}
					if (!fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.CONNECT_DUT_CC1_SS1))
					{
						WriteErrorMessage("CONNECT_DUT_CC1_SS1 fail.");
						return false;
					}
					setBit = USB_IO_Expander.SetValue.LOW;
					fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.HUB_RESET_N, ref setBit, ref IO_OUT);
				}
				WriteDebugMessage("Fixture connect success.");
				if (xyTableEnabled)
				{
					if (!xyTable_connected)
					{
						IO_OUT = true;
						setBit = USB_IO_Expander.SetValue.HIGH;
						fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_PWRON, ref setBit, ref IO_OUT);
						if (!XY_TABLE_Connect())
						{
							WriteErrorMessage("Failed to connect XYTable");
							return false;
						}
						fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_TST_MIC2_IN);
						setBit = USB_IO_Expander.SetValue.LOW;
						fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
						fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
						fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC2_OUT);
					}
					if (xyTableEnabled)
					{
						ZRetractAll();
						MoveHome(enable_partialRetract: false, enableProxPosition: false);
						SetXYTableUnitToMetric();
						string retValue = "";
						string errMsg = "";
						string cmd = "16 qti_setxystep;90 qti_xyfreqmax;90 qti_xyfreqmin;90 qti_xyfreq;qti_xyfreq?";
						xyTableInstance.SendRawCmd(cmd, ref retValue, ref errMsg);
						cmd = "4 qti_setxystep;200 qti_xyfreqmax;200 qti_xyfreqmin;200 qti_xyfreq;qti_xyfreq?";
						xyTableInstance.SendRawCmd(cmd, ref retValue, ref errMsg);
						if (!xyTableInstance.setXyzSpeed(XY_SPEED, ref retValue))
						{
							WriteErrorMessage("Failed to Set XYTable Speed, Error msg: " + retValue);
							return false;
						}
						if (Z_SPEED_UP && !xyTableInstance.setXyzSpeed(XY_SPEED, ref retValue, isMotor: false))
						{
							WriteErrorMessage("Failed to Set XYTable Speed, Error msg: " + retValue);
							return false;
						}
					}
					WriteDebugMessage("XY Table connect success.");
				}
			}
			int result = 0;
			if (string.IsNullOrEmpty(portDUT) || portDUT.ToUpper() == "AUTO" || portDUT == "-1" || portDUT == "0")
			{
				result = 0;
			}
			else
			{
				if (!int.TryParse(portDUT, out result))
				{
					string message = "Invalid DUT comport listed ";
					WriteErrorMessage(message);
					return false;
				}
				if (result < 0)
				{
					result = 0;
				}
			}
			if (useQPST)
			{
				phone.SetLibraryMode(LibraryModeEnum.QPST);
			}
			else
			{
				phone.SetLibraryMode(LibraryModeEnum.QPhoneMS);
			}
			WriteLogMessage("\r\nTrying to connect to Phone");
			string text = "0";
			text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "20";
			}
			int result2 = 0;
			if (!int.TryParse(text, out result2))
			{
				WriteLogMessage("Timeout not found  using 20 seconds default");
				result2 = 20000;
			}
			else
			{
				result2 *= 1000;
			}
			int num = 1000;
			int num2 = 0;
			bool flag2 = false;
			WriteLogMessage("Connecting to Phone ... COM" + result);
			while (!phone.IsPhoneConnected())
			{
				if (isAPQ)
				{
					ConnectToPhone(phone, result, Phone.TargetType.QLIB_TARGET_TYPE_APQ);
				}
				else
				{
					ConnectToPhone(phone, result);
				}
				if (phone.IsPhoneConnected() || result2 <= 0)
				{
					break;
				}
				Thread.Sleep(num);
				result2 -= num;
				num2 += num;
				WriteDebugMessage($"booting up...elapsed time-{num2} ms");
				flag2 = true;
			}
			if (!phone.IsPhoneConnected())
			{
				WriteLogMessage("Failed to connect to Phone");
				return false;
			}
			WriteLogMessage("\r\nConnected to COM - " + phone.GetPhoneComPort());
			DebugLogTimeStamp("Connected", MoreLog);
			if (flag2)
			{
				Thread.Sleep(2000);
			}
			flag = phone.IsPhoneConnected();
			if (DELAY_S_PORT_TO_MMI > 0)
			{
				Thread.Sleep(DELAY_S_PORT_TO_MMI * 1000);
				WriteLogMessage("Delay interval seconds from Diag port shown to MMI ready: " + DELAY_S_PORT_TO_MMI);
			}
			MMI_MODE = MMIMODE.FFBM;
			if (MMI_TYPE == 0)
			{
				byte[] array = new byte[3];
				phone.FTM_AP_Read_App_Version(ref FTMErrorCode, array);
				string @string = Encoding.ASCII.GetString(array);
				WriteLogMessage("FTM AP Version:" + @string);
				int result3 = 0;
				if (int.TryParse(@string, out result3) && result3 >= 400)
				{
					MMI_MODE = MMIMODE.QMMI;
				}
			}
			else if (MMI_TYPE == 2)
			{
				MMI_MODE = MMIMODE.QMMI;
			}
			if (MMI_MODE == MMIMODE.QMMI)
			{
				sequenceFileRemoteName = "pcba_default.xml";
			}
			else
			{
				sequenceFileRemoteName = "mmi-pcba.cfg";
			}
			if (phone.IsPhoneConnected())
			{
				if (USE_DUT_SEQUENCE_FILE)
				{
					string text2 = "C:\\Qualcomm\\QDART\\MMI\\temp\\temp_sequence_file_from_DUT.cfg";
					if (MMI_MODE == MMIMODE.QMMI)
					{
						text2 = "C:\\Qualcomm\\QDART\\MMI\\temp\\temp_sequence_file_from_DUT.xml";
					}
					if (File.Exists(text2))
					{
						File.Delete(text2);
					}
					phone.FTM_AP_ReadFile(ref FTMErrorCode, sequenceFileRemoteName, text2);
					sequenceFileLocalLocation = text2;
				}
				if (FFBM_CHECK)
				{
					byte CurrentBootMode = 0;
					byte CurrentBootSubMode = 0;
					byte NextBootMode = 0;
					byte NextBootSubMode = 0;
					phone.FFBM_GET_MODE(ref FTMErrorCode, ref CurrentBootMode, ref CurrentBootSubMode, ref NextBootMode, ref NextBootSubMode);
					if (FTMErrorCode != 0)
					{
						WriteErrorMessage("phone FFBM_GET_MODE fail with error code:" + FTMErrorCode);
						return false;
					}
					if (CurrentBootMode != 1)
					{
						WriteErrorMessage("DUT current boot mode not FFBM");
						return false;
					}
				}
				if (readSN)
				{
					string rSN = "";
					ReadSerialNumber(out rSN);
					if (string.IsNullOrEmpty(rSN))
					{
						rSN = "SN" + DateTime.Now.ToString("HH_mm_ss");
						WriteLogMessage("SN Auto-Generate");
					}
					WriteLogMessage("Serial#: " + rSN);
					base.Env.GlobalVariable.SetGlobalVariable("SN", rSN);
				}
				if (ERASE_FTM_AP_FOLDER)
				{
					EraseAllFilesFromPhone();
					DebugLogTimeStamp("Finished erase FTM_AP folder", MoreLog);
				}
				if (!phone.IsPhoneConnected())
				{
					if (isAPQ)
					{
						ConnectToPhone(phone, result, Phone.TargetType.QLIB_TARGET_TYPE_APQ);
					}
					else
					{
						ConnectToPhone(phone, result);
					}
					if (!phone.IsPhoneConnected())
					{
						WriteErrorMessage("DUT lost connection afetr erased cfg file");
						return false;
					}
				}
				Thread.Sleep(200);
				WriteLogMessage("\r\nLoading sequence file to phone");
				phone.FTM_AP_WriteFile(ref FTMErrorCode, sequenceFileRemoteName, sequenceFileLocalLocation);
				if (FTMErrorCode != 0)
				{
					DebugLogTimeStamp("Retry- loading sequence file", MoreLog);
					for (int i = 0; i < 20; i++)
					{
						Thread.Sleep(200);
						if (!phone.IsPhoneConnected())
						{
							if (isAPQ)
							{
								ConnectToPhone(phone, result, Phone.TargetType.QLIB_TARGET_TYPE_APQ);
							}
							else
							{
								ConnectToPhone(phone, result);
							}
							if (!phone.IsPhoneConnected())
							{
								WriteErrorMessage("DUT lost connection after loading sequence file");
								return false;
							}
						}
						if (FTMErrorCode == 0)
						{
							break;
						}
					}
				}
				if (FTMErrorCode != 0)
				{
					CheckFTMErrorCodeWithErrorMessage("Failed to load sequence file to DUT");
					return false;
				}
				WriteLogMessage("\r\nSelecting sequence file");
				for (int j = 0; j < 5; j++)
				{
					try
					{
						Thread.Sleep(500);
						phone.FTM_AP_SelectSequence(sequenceFileRemoteName, ref FTMErrorCode, ref iNumTest);
					}
					catch
					{
					}
					if (FTMErrorCode == 0)
					{
						break;
					}
				}
				DebugLogTimeStamp("", MoreLog);
				if (FTMErrorCode != 0)
				{
					CheckFTMErrorCodeWithErrorMessage("DUT failed to Select sequence file");
					return false;
				}
				InitializeResultsFile();
				flag = phone.IsPhoneConnected();
				if (!flag)
				{
					WriteErrorMessage("Failed to connect DUT");
					return false;
				}
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex2)
		{
			WriteErrorMessage(ex2.Message);
			return false;
		}
	}

	public bool POWER_ON_CHECK()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		string text2 = "0";
		try
		{
			text2 = FindParameterValueFromSectionWithName("vBusSaftyUpperLimitmA");
		}
		catch (Exception)
		{
			text2 = "1200";
		}
		string text3 = "0";
		try
		{
			text3 = FindParameterValueFromSectionWithName("vBusLowerLimitmA");
		}
		catch (Exception)
		{
			text3 = "140";
		}
		string text4 = "0";
		try
		{
			text4 = FindParameterValueFromSectionWithName("vBusUpperLimitmA");
		}
		catch (Exception)
		{
			text4 = "450";
		}
		if (!int.TryParse(text2, out var result))
		{
			WriteLogMessage("Failed to find a legit vBusSaftyUpperLimitmA");
			return false;
		}
		if (!int.TryParse(text3, out var result2))
		{
			WriteLogMessage("Failed to find a legit vbusLowerLimit");
			return false;
		}
		if (!int.TryParse(text4, out var result3))
		{
			WriteLogMessage("Failed to find a legit vbusUpperLimit");
			return false;
		}
		try
		{
			double current_reading = 0.0;
			double current_reading2 = 0.0;
			string USB_Name = "";
			try
			{
				if (!fixtureInstance.USB_Connect(fixtureInstanceID, out USB_Name))
				{
					return false;
				}
			}
			catch (Exception ex4)
			{
				WriteErrorMessage(string.Format("Failed to match fixture ID with dip switch or fixture not connected" + ex4.Message));
				return false;
			}
			if (!fixtureInstance.PC_VBUS_Current(out current_reading))
			{
				WriteErrorMessage($"Error in getting VBUS current");
				return false;
			}
			if (current_reading >= (double)result)
			{
				WriteErrorMessage($"VBUS current={current_reading} exceeding safty limit {result}");
				return false;
			}
			bool result4 = false;
			bool IO_OUT = false;
			int.TryParse(text, out var result5);
			int num = 200;
			int num2 = result5 * 1000 / num;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.PC_VBUS_Current(out current_reading);
			fixtureInstance.VBAT_Current(out current_reading2);
			for (int i = 0; i < num2; i++)
			{
				Thread.Sleep(num);
				if (current_reading >= (double)result)
				{
					fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_OTG_EN, ref setBit, ref IO_OUT);
					fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.VBAT_EN_N, ref setBit, ref IO_OUT);
					WriteLogMessage($"VBUS current = {current_reading} exceeding safty limits {result}, power shuted down ");
					result4 = false;
					break;
				}
				if (current_reading <= (double)result3 && current_reading >= (double)result2)
				{
					WriteLogMessage($"VBUS value = {current_reading} within limit:  {result2}  {result3}");
					result4 = true;
					break;
				}
				WriteLogMessage(string.Format("\r\n ({1})-vBus Current {0} mA", current_reading.ToString(), i));
				WriteLogMessage(string.Format(" ({1})-vBat Current {0} mA", current_reading2.ToString(), i));
				fixtureInstance.PC_VBUS_Current(out current_reading);
				fixtureInstance.VBAT_Current(out current_reading2);
				if (i == num2 - 1)
				{
					WriteLogMessage("Time out - DUT not boot up properly");
					return false;
				}
			}
			WriteLogMessage($"\r\nvBus Current {current_reading.ToString()} mA");
			WriteLogMessage($"vBat Current {current_reading2.ToString()} mA");
			return result4;
		}
		catch (Exception ex5)
		{
			WriteErrorMessage(ex5.Message);
			return false;
		}
	}

	public bool UPDATE_SEQUENCE_FROM_DUT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		DebugLogTimeStamp("Start", enable: true);
		try
		{
			int result = 0;
			if (portDUT.ToUpper() == "AUTO")
			{
				result = 0;
			}
			else
			{
				if (!int.TryParse(portDUT, out result))
				{
					string message = "Invalid DUT comport listed ";
					WriteErrorMessage(message);
					return false;
				}
				if (result < 0)
				{
					result = 0;
				}
			}
			if (useQPST)
			{
				phone.SetLibraryMode(LibraryModeEnum.QPST);
			}
			else
			{
				phone.SetLibraryMode(LibraryModeEnum.QPhoneMS);
			}
			WriteLogMessage("\r\nTrying to connect to Phone");
			string text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "20";
			}
			int result2 = 0;
			if (!int.TryParse(text, out result2))
			{
				WriteLogMessage("Timeout not found  using 20 seconds default");
				result2 = 20000;
			}
			else
			{
				result2 *= 1000;
			}
			int num = 1000;
			int num2 = 0;
			bool flag = false;
			while (!phone.IsPhoneConnected())
			{
				if (isAPQ)
				{
					ConnectToPhone(phone, result, Phone.TargetType.QLIB_TARGET_TYPE_APQ);
				}
				else
				{
					ConnectToPhone(phone, result);
				}
				if (phone.IsPhoneConnected() || result2 <= 0)
				{
					break;
				}
				Thread.Sleep(num);
				result2 -= num;
				num2 += num;
				WriteLogMessage($"booting up...elapsed time-{num2} ms");
				flag = true;
			}
			if (!phone.IsPhoneConnected())
			{
				WriteLogMessage("Failed to connect to Phone");
				return false;
			}
			WriteLogMessage("\r\nConnected to COM - " + phone.GetPhoneComPort());
			DebugLogTimeStamp("Connected", MoreLog);
			if (flag)
			{
				Thread.Sleep(2000);
			}
			WriteLogMessage("\r\nUpdate local MMI PCBA cfg file from DUT");
			phone.FTM_AP_ReadFile(ref FTMErrorCode, sequenceFileRemoteName, sequenceFileLocalLocation);
			if (FTMErrorCode != 0)
			{
				DebugLogTimeStamp("Retry- Reading cfg", MoreLog);
				for (int i = 0; i < 10; i++)
				{
					Thread.Sleep(1000);
					if (!phone.IsPhoneConnected())
					{
						if (isAPQ)
						{
							ConnectToPhone(phone, result, Phone.TargetType.QLIB_TARGET_TYPE_APQ);
						}
						else
						{
							ConnectToPhone(phone, result);
						}
						if (!phone.IsPhoneConnected())
						{
							WriteErrorMessage("Phone lost connection after Reading cfg file");
							return false;
						}
						phone.FTM_AP_ReadFile(ref FTMErrorCode, sequenceFileRemoteName, sequenceFileLocalLocation);
					}
					if (FTMErrorCode == 0)
					{
						return true;
					}
				}
				return false;
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	public bool CHECK_PREVIOUS_STATION_FLAG()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string value = TimeOut.ToString();
			if (string.IsNullOrEmpty(value))
			{
				value = "20";
			}
			if (!CheckPreviousStation(currentStationIndex))
			{
				WriteErrorMessage("Failed: Check previous station status");
				return false;
			}
			WriteLines(name, bStart: false);
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public void XYZ_MOVEHOME()
	{
		if (useFixture && xyTable_connected && xyTableEnabled)
		{
			xyTableInstance.WaitForCmd = true;
			MoveHome(enable_partialRetract: true, enableProxPosition: false);
			xyTableInstance.WaitForCmd = true;
		}
	}

	public bool DISCONNECT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			if (useFixture && xyTable_connected && xyTableEnabled)
			{
				xyTableInstance.WaitForCmd = false;
				MoveHome(enable_partialRetract: true, enableProxPosition: false);
				xyTableInstance.WaitForCmd = true;
			}
			phone.DisconnectServer();
			if (useFixture)
			{
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_OTG_EN, ref setBit, ref IO_OUT);
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.VBAT_EN_N, ref setBit, ref IO_OUT);
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	public bool REBOOT_DUT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "5";
			}
			int result = 0;
			if (!int.TryParse(text, out result))
			{
				WriteLogMessage("Timeout not found using 5 seconds for " + name);
				result = 20000;
			}
			else
			{
				result *= 1000;
			}
			if (REBOOT_TYPE == 0)
			{
				phone.DIAG_CONTROL_F(mode_enum_type.MODE_RESET_F, 100);
			}
			else
			{
				SEND_ADB_CMD(TimeOut, "/C adb reboot");
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error in getting logcat log: " + ex.Message);
			return false;
		}
	}

	public bool WRITE_STATION_FLAG()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			StationFlagOptions stationFlagOptions = StationFlagOptions.PASS;
			stationFlagOptions = ((!OverallTestResut) ? StationFlagOptions.FAIL : StationFlagOptions.PASS);
			string value = TimeOut.ToString();
			if (string.IsNullOrEmpty(value))
			{
				value = "20";
			}
			bool flag = false;
			try
			{
				flag = bool.Parse(FindParameterValueFromSectionWithName("bypassStation"));
			}
			catch (Exception)
			{
				flag = false;
			}
			if (flag)
			{
				stationFlagOptions = StationFlagOptions.BYPASS;
				WriteLogMessage("BYPASS flag is true ... will bypass station flag");
			}
			WritePCBAMMIStationConfigFlag(currentStationIndex, stationFlagOptions);
			WriteLines(name, bStart: false);
			return true;
		}
		catch (Exception ex2)
		{
			WriteLogMessage(name + ex2.Message);
			return false;
		}
	}

	public bool EXIT_TEST(uint pass_fail, string methodName)
	{
		try
		{
			ushort iFTM_Error_Code = 999;
			WriteLogMessage("\r\nExiting Test: " + methodName);
			phone.FTM_AP_EXIT_TEST(ref iFTM_Error_Code, pass_fail, methodName);
			Thread.Sleep(30);
			if (iFTM_Error_Code != 0)
			{
				WriteLogMessage("\r\nErroe in exiting Test: " + methodName + "; Error Code: " + iFTM_Error_Code);
				return false;
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(methodName + ex.Message);
			return false;
		}
	}

	public bool QCN_RESTORE_FILE(string QCNPathFileName, string FileName)
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		bool bSkipReset = true;
		string sPC = "000000";
		string ErrorMessage = "";
		string text = QCNPathFileName + "\\" + FileName;
		WriteLogMessage($"\r\nStarting Restore QCN file");
		if (!phone.IsPhoneConnected())
		{
			WriteLogMessage($"\r\nPhone not connected for loading QCN");
			return false;
		}
		try
		{
			text = text.ToUpper();
			if (!File.Exists(text))
			{
				WriteLogMessage($"\r\nQCN file not exist {text} : ");
				return false;
			}
			if (!phone.RestoreQCNFile(text, sPC, bSkipReset, out ErrorMessage))
			{
				WriteLogMessage($"\r\nRestore QCN file failed {text} : ");
				return false;
			}
			WriteLogMessage($"\r\nFinish Restore QCN file");
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage("\r\nError loading QCN" + ex.Message);
			return false;
		}
	}

	public bool NEXT_BOOT_ONLINE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "5";
			}
			int result = 0;
			if (!int.TryParse(text, out result))
			{
				WriteLogMessage("Timeout not found  using 2 seconds for " + name);
				result = 20000;
			}
			else
			{
				result *= 1000;
			}
			byte iBootMode = 0;
			byte iSubBootMode = 0;
			phone.FFBM_SET_MODE(iBootMode, iSubBootMode, ref FTMErrorCode);
			if (FTMErrorCode != 0)
			{
				WriteErrorMessage("phone FFBM_SET_MODE fail with error code:" + FTMErrorCode);
				return false;
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error to set next boot mode: " + ex.Message);
			return false;
		}
	}

	public bool CAP_LOG_CAT_LOG()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			if (string.IsNullOrEmpty(dut_index))
			{
				capture_logcat_log((int)(TimeOut * 1000), "\"C:\\Qualcomm\\QDART\\MMI\\temp\\\"");
			}
			else
			{
				capture_logcat_log((int)(TimeOut * 1000), "\"C:\\Qualcomm\\QDART\\MMI\\temp\\\"");
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error in getting logcat log: " + ex.Message);
			return false;
		}
	}

	private bool capture_logcat_log(int TimeOut_s, string logFile)
	{
		try
		{
			if (File.Exists(logFile))
			{
				File.Delete(logFile);
			}
			Process process = new Process();
			process.StartInfo.FileName = "CMD.exe";
			process.StartInfo.CreateNoWindow = true;
			process.StartInfo.UseShellExecute = false;
			process.StartInfo.RedirectStandardInput = true;
			process.StartInfo.Arguments = "/C adb shell logcat -d >" + logFile + "&adb shell logcat -c";
			process.Start();
			Thread.Sleep(TimeOut_s);
			process.StartInfo.Arguments = "/C taskkill /F /IM adb.exe";
			process.Start();
			Thread.Sleep(1000);
			process.Close();
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error in getting logcat log: " + ex.Message);
			return false;
		}
	}

	public bool SEND_ADB_CMD(uint TimeOut_s, string adbCMD)
	{
		try
		{
			Process process = new Process();
			process.StartInfo.FileName = "CMD.exe";
			process.StartInfo.CreateNoWindow = false;
			process.StartInfo.UseShellExecute = false;
			process.StartInfo.RedirectStandardInput = true;
			process.StartInfo.Arguments = adbCMD;
			process.Start();
			Thread.Sleep((int)(TimeOut_s * 1000));
			process.Close();
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error in getting logcat log: " + ex.Message);
			return false;
		}
	}

	public bool SEND_ADB_DIRECTLY(uint TimeOut_s, string adbCMD)
	{
		try
		{
			Process process = new Process();
			process.StartInfo.FileName = "adb";
			process.StartInfo.CreateNoWindow = false;
			process.StartInfo.UseShellExecute = false;
			process.StartInfo.ErrorDialog = false;
			process.StartInfo.RedirectStandardInput = true;
			process.StartInfo.RedirectStandardOutput = true;
			process.StartInfo.RedirectStandardError = true;
			process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
			process.StartInfo.CreateNoWindow = true;
			process.StartInfo.Arguments = adbCMD;
			process.Start();
			Thread.Sleep((int)(TimeOut_s * 1000));
			process.Close();
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error in getting logcat log: " + ex.Message);
			return false;
		}
	}

	public bool CHECK_KEYWORDS_IN_GV(string gvName, string keyWords)
	{
		try
		{
			string name = MethodBase.GetCurrentMethod().Name;
			WriteLines(name);
			WriteDebugMessage("GV: " + gvName + "\r\nKeyWords: " + keyWords);
			if (!string.IsNullOrEmpty(gvName))
			{
				string gvValue = "";
				base.Env.GlobalVariable.GetGlobalVariable(gvName, out gvValue);
				WriteDebugMessage("Value:\r\n" + gvValue);
				if (!string.IsNullOrEmpty(gvValue))
				{
					if (!CHECK_POWER)
					{
						return gvValue.Contains(keyWords);
					}
					int num = gvValue.IndexOf("dBFS");
					int num2 = gvValue.IndexOf("Power");
					string text = gvValue.Substring(num2 + 6, num - num2);
					double result = -99.9;
					double.TryParse(text.Replace("dBFS", "").TrimEnd().TrimStart(), out result);
					if (result > POWER_LL)
					{
						return true;
					}
					WriteDebugMessage("Power:" + result + " out of limit：" + POWER_LL);
				}
			}
			return false;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error: " + ex.Message);
			return false;
		}
	}

	public bool AUTO_DETECT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "20";
			}
			int result = 0;
			if (!int.TryParse(text, out result))
			{
				WriteLogMessage("Timeout not found  using 20 seconds default");
				result = 20;
			}
			result *= 1000;
			bool result2 = false;
			if (xyTable_connected)
			{
				int num = 1000;
				int num2 = 0;
				while (!xyTableInstance.checkidDUTPresnt(reverse))
				{
					if (xyTableInstance.checkidDUTPresnt(reverse))
					{
						result2 = true;
						WriteLogMessage("auto-detect completed, starting test plan");
						break;
					}
					if (result <= 0)
					{
						WriteErrorMessage("auto-detect failed, try again or increase the timeout");
						break;
					}
					Thread.Sleep(num);
					result -= num;
					num2 += num;
					WriteLogMessage($"waiting for auto-detect...elapsed time-{num2} ms");
				}
				result2 = xyTableInstance.checkidDUTPresnt(reverse);
			}
			return result2;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	public void USING_UPDATED_XYZ_POS()
	{
	}

	public bool DEBUG_MOVING_OFFSET_ERROR()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		int num;
		try
		{
			num = int.Parse(FindParameterValueFromSectionWithName("repeat_cnt"));
		}
		catch (Exception)
		{
			num = 10;
		}
		int millisecondsTimeout;
		try
		{
			millisecondsTimeout = int.Parse(FindParameterValueFromSectionWithName("delay_ms"));
		}
		catch (Exception)
		{
			millisecondsTimeout = 100;
		}
		string text = "LEVER1";
		try
		{
			text = FindParameterValueFromSectionWithName("loc1");
		}
		catch (Exception)
		{
			text = "LEVER1";
		}
		string text2 = "LEVER2";
		try
		{
			text2 = FindParameterValueFromSectionWithName("loc2");
		}
		catch (Exception)
		{
			text2 = "LEVER2";
		}
		int x = 0;
		int y = 0;
		int z = 0;
		int z2 = 0;
		int x2 = 0;
		int y2 = 0;
		int z3 = 0;
		int z4 = 0;
		try
		{
			for (int i = 0; i < num; i++)
			{
				xyTableInstance.Retract_MoveTo(text);
				if (!xyTableInstance.GetPositions(ref x, ref y, ref z, ref z2))
				{
					msg += "\r\nfail to get xyTable position info";
				}
				if (!xyTableInstance.GetCfgPOS(text, ref x2, ref y2, ref z3, ref z4, useOffset: false, ref msg))
				{
					msg += "failed to get xyTable position info";
				}
				WriteLogMessage("------ LOOP " + (i + 1) + " of " + num + " ------");
				WriteLogMessage("CFG Location:" + text + " X, Y = " + x2 + ", " + y2);
				WriteLogMessage("Current Location:" + text + " X, Y = " + x + ", " + y);
				Thread.Sleep(millisecondsTimeout);
				xyTableInstance.Retract_MoveTo(text2);
				if (!xyTableInstance.GetPositions(ref x, ref y, ref z, ref z2))
				{
					msg += "\r\nfail to get xyTable position info";
				}
				if (!xyTableInstance.GetCfgPOS(text2, ref x2, ref y2, ref z3, ref z4, useOffset: false, ref msg))
				{
					msg += "failed to get xyTable position info";
				}
				WriteLogMessage("CFG Location:" + text2 + " X, Y = " + x2 + ", " + y2);
				WriteLogMessage("Current Location:" + text2 + " X, Y = " + x + ", " + y);
				Thread.Sleep(millisecondsTimeout);
			}
			return true;
		}
		catch (Exception ex5)
		{
			WriteLogMessage(name + ex5.Message);
			xyTableInstance.zRetract_partial(DUT_zone: false, retractz1: true, retractz2: true);
			return false;
		}
	}

	public bool DEBUG_RGB_REPEATIBILITY_TEST()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		int num;
		try
		{
			num = int.Parse(FindParameterValueFromSectionWithName("repeat_cnt"));
		}
		catch (Exception)
		{
			num = 10;
		}
		try
		{
			int.Parse(FindParameterValueFromSectionWithName("delay_ms"));
		}
		catch (Exception)
		{
		}
		try
		{
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
			bool IO_OUT = true;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.LOC_LCD_BACKLIGHT.ToString(), enablePartialRetract: true);
			RunSingleTestWithWait("LCD_RED", 0);
			WriteLogMessage("-------LCD RED-------\r\n");
			for (int i = 0; i < num; i++)
			{
				double num2 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.RED);
				double num3 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.GREEN);
				double num4 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.BLUE);
				Thread.Sleep(200);
				WriteLogMessage("RED loop: " + i + " rgb=" + num2 + ";" + num3 + ";" + num4);
			}
			RunSingleTestWithWait("LCD_GREEN", 0);
			WriteLogMessage("-------LCD GREEN-------");
			for (int j = 0; j < num; j++)
			{
				double num2 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.RED);
				double num3 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.GREEN);
				double num4 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.BLUE);
				Thread.Sleep(200);
				WriteLogMessage("GREEN loop: " + j + " rgb=" + num2 + ";" + num3 + ";" + num4);
			}
			RunSingleTestWithWait("LCD_BLUE", 0);
			WriteLogMessage("-------LCD BLUE-------");
			for (int k = 0; k < num; k++)
			{
				double num2 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.RED);
				double num3 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.GREEN);
				double num4 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.BLUE);
				Thread.Sleep(200);
				WriteLogMessage("BLUE loop: " + k + " rgb=" + num2 + ";" + num3 + ";" + num4);
			}
			RunSingleTestWithWait("LCD_BACKLIGHT", 0);
			WriteLogMessage("-------LCD_BACKLIGHT-------");
			for (int l = 0; l < num; l++)
			{
				double num2 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.RED);
				double num3 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.GREEN);
				double num4 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.BLUE);
				Thread.Sleep(200);
				WriteLogMessage("LCD_BACKLIGHT loop: " + l + " rgb=" + num2 + ";" + num3 + ";" + num4);
			}
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, "LCD_BACKLIGHT");
			WriteLogMessage("-------EXIT LCD_BACKLIGHT-------");
			for (int m = 0; m < num; m++)
			{
				double num2 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.RED);
				double num3 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.GREEN);
				double num4 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.BLUE);
				Thread.Sleep(200);
				WriteLogMessage("EXIT LCD_BACKLIGHT loop: " + m + " rgb=" + num2 + ";" + num3 + ";" + num4);
			}
			return true;
		}
		catch (Exception ex3)
		{
			WriteLogMessage(name + ex3.Message);
			return false;
		}
	}

	public bool RUNASYNC(INI_FileStructure testDetails)
	{
		string sectionName = testDetails.sectionName;
		try
		{
			RunSingleTest(testDetails.sectionName);
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(sectionName + ex.Message);
			return false;
		}
	}

	public bool[] CHECK_RESULT(INI_FileStructure testDetails)
	{
		bool[] result = new bool[2];
		string sectionName = testDetails.sectionName;
		try
		{
			GetResultsFile();
			result = CheckResultPresentInResultsFile(sectionName);
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(sectionName + ex.Message);
			return result;
		}
	}

	public bool DelayInSeconds()
	{
		Thread.Sleep((int)(TimeOut * 1000));
		WriteLogMessage("Delay seconds: " + TimeOut);
		return true;
	}

	public bool BT_FM_WLAN_PIN_CONNECTIVTY()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string value = TimeOut.ToString();
			if (string.IsNullOrEmpty(value))
			{
				value = "20";
			}
			bool flag = false;
			if (EnableFTMUtility(FTMUtilityOptions.BT, on: true))
			{
				short fmResponse = 0;
				phone.FTM_BT_SET_LegacyLoggingMode(0);
				try
				{
					phone.FTM_BT_HCI_Reset();
				}
				catch (Exception)
				{
					Thread.Sleep(2000);
					phone.FTM_BT_HCI_Reset();
				}
				phone.FTM_BT_Get_PIN_CONNECTIVITIY(out var btResponse, out var wlanResponse, out fmResponse);
				WriteLogMessage($"Pin connectivity - BT : {btResponse.ToString()}, WLAN : {wlanResponse.ToString()}, FM : {fmResponse.ToString()}");
				flag = ((btResponse % 2 == 0 && fmResponse % 2 == 0 && wlanResponse % 2 == 0) ? true : false);
				EnableFTMUtility(FTMUtilityOptions.BT, on: false);
				WriteLines(name, bStart: false);
				return flag;
			}
			WriteLogMessage("Failed to enable BT FTM");
			return false;
		}
		catch (Exception ex2)
		{
			WriteLogMessage(name + ex2.Message);
			return false;
		}
	}

	public bool SYSTEM_INFO()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool result = true;
		try
		{
			RunSingleTest(name);
			GetResultsFile(name, 5);
			if (MMI_MODE == MMIMODE.QMMI)
			{
				string details = "";
				ResultFromResultsFile(name);
				ResultDetailsForTestCase_Xml(name, "", out details);
			}
			WriteLines(name, bStart: false);
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool RFFE_SCAN()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		try
		{
			string value = TimeOut.ToString();
			if (string.IsNullOrEmpty(value))
			{
				value = "20";
			}
			int devicesRequired = DevicesRequired;
			if (!GetRFFE_ScanFileFromDevice())
			{
				WriteLogMessage("Failed to get RFFE scan file from device");
				return false;
			}
			int numberOfDeviceInstancesPresent = 0;
			if (!ParseRFFEScanFile(out numberOfDeviceInstancesPresent))
			{
				return false;
			}
			if (devicesRequired != numberOfDeviceInstancesPresent)
			{
				WriteLogMessage($"Failed to match required devices present, Devices present - {numberOfDeviceInstancesPresent}, Devices required {devicesRequired}");
				flag = false;
			}
			else
			{
				WriteLogMessage($"Devices instances present({numberOfDeviceInstancesPresent}) = Devices instances required({devicesRequired})");
				flag = true;
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool EMMC()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool UFS()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "0";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool STORAGE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool CPU()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("cpu_FreqHz_LL"), out var result))
		{
			WriteLogMessage("Failed to find cpu freq lower limit, cpu_FreqHz_LL ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("cpu_FreqHz_UL"), out var result2))
		{
			WriteLogMessage("Failed to find cpu freq uppper limit, cpu_FreqHz_UL ");
			return false;
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			double result3 = -999.0;
			string text = ResultFromResultsFile(name, "CPUFREQ MAX");
			text = text.Replace("H", "");
			text = text.Replace("z", "");
			if (!double.TryParse(text, out result3))
			{
				WriteLogMessage("Failed to find CPUFREQ MAX in result file");
				return false;
			}
			bool flag = false;
			if (result3 >= result && result3 <= result2)
			{
				WriteLogMessage($"CPU Freq Max- Value within limit {result} <= {result3} <= {result2}");
				flag = true;
			}
			else
			{
				WriteLogMessage("memory value out of limit");
				flag = false;
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool MEMORY()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		if (MMI_MODE == MMIMODE.QMMI)
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("memory_MB_LL"), out var result))
		{
			WriteLogMessage("Failed to find memory lower limit, memory_MB_LL ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("memory_MB_UL"), out var result2))
		{
			WriteLogMessage("Failed to find memory uppper limit, memory_MB_UL ");
			return false;
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			double result3 = -999.0;
			string text = ResultFromResultsFile(name, "MemTotal");
			text = text.Replace("M", "");
			text = text.Replace("B", "");
			if (!double.TryParse(text, out result3))
			{
				WriteLogMessage("Failed to find MemTotal in result file");
				return false;
			}
			bool flag = false;
			if (result3 >= result && result3 <= result2)
			{
				WriteLogMessage($"Memory - Value within limit {result} <= {result3} <= {result2}");
				flag = true;
			}
			else
			{
				WriteLogMessage("memory value out of limit");
				flag = false;
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool USER_DEFINED()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (string.IsNullOrEmpty(name))
		{
			WriteLogMessage("User defined test name not configured");
			return false;
		}
		try
		{
			RunSingleTest(MMI_testName);
			GetResultsFile(MMI_testName);
			WriteLines(name, bStart: false);
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, MMI_testName);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool LED_RED()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		try
		{
			string onTestName = "LED_RED_ON";
			string offTestName = "LED_RED_OFF";
			if (!deprecated)
			{
				onTestName = "LED_RED";
				offTestName = "LED_RED";
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta);
			}
			else
			{
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta, deprecated: true);
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			return false;
		}
	}

	public bool LED_RED_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		try
		{
			xyTableInstance.Retract_MoveTo_touch(xyLOCATE.LIGHTSENSE.ToString());
			Thread.Sleep(wait_table_move_s * 1000);
			string onTestName = "LED_RED_ON";
			string offTestName = "LED_RED_OFF";
			if (!deprecated)
			{
				onTestName = "LED_RED";
				offTestName = "LED_RED";
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta);
			}
			else
			{
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta, deprecated: true);
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			xyTableInstance.zRetract_partial();
			return false;
		}
	}

	public bool LED_RGB_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (!CheckFixtureExist())
		{
			return false;
		}
		double num = 0.0;
		double num2 = 0.0;
		double color_value = 0.0;
		bool flag = true;
		double num3 = onOffDelta;
		string text = "";
		try
		{
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			int Delta_x = 0;
			int Delta_y = 0;
			int Delta_z = 0;
			int Delta_z2 = 0;
			string text2 = "";
			if (!getDelta_to_target_POS("LED_1", ref Delta_x, ref Delta_y, ref Delta_z, ref Delta_z2, ref text2))
			{
				WriteLogMessage("failed to get getDelta_to_target_POS");
			}
			if (Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_y) >= 20 || Math.Abs(Delta_z) >= 20)
			{
				xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.LED_1.ToString(), enablePartialRetract: true);
			}
			if (!LIGHT_DETECT_ONLY)
			{
				if (LED_RED_TEST)
				{
					text = "LED_RED";
					if (DISABLE_CHARGING)
					{
						EnableFTMUtility(FTMUtilityOptions.CHARGER, on: false);
					}
					RunSingleTest(text);
					Thread.Sleep(1000);
					if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.RED, ref color_value))
					{
						return false;
					}
					num = color_value;
					phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
					if (DISABLE_CHARGING)
					{
						EnableFTMUtility(FTMUtilityOptions.CHARGER, on: false);
					}
					Thread.Sleep(1000);
					if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.RED, ref color_value))
					{
						return false;
					}
					num2 = color_value;
					WriteLogMessage("RED Color voltage = " + num);
					WriteLogMessage("RED OFF Color voltage = " + num2);
					flag = Math.Abs(num - num2) >= num3 && flag;
				}
				if (LED_GREEN_TEST)
				{
					text = "LED_GREEN";
					if (DISABLE_CHARGING)
					{
						EnableFTMUtility(FTMUtilityOptions.CHARGER, on: false);
					}
					RunSingleTest(text);
					Thread.Sleep(1000);
					if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.GREEN, ref color_value))
					{
						return false;
					}
					num = color_value;
					phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
					if (DISABLE_CHARGING)
					{
						EnableFTMUtility(FTMUtilityOptions.CHARGER, on: false);
					}
					Thread.Sleep(1000);
					if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.GREEN, ref color_value))
					{
						return false;
					}
					num2 = color_value;
					WriteLogMessage("GREEN Color voltage percent= " + num);
					WriteLogMessage("GREEN OFF Color voltage percent= " + num2);
					flag = Math.Abs(num - num2) >= num3 && flag;
				}
				if (LED_BLUE_TEST)
				{
					text = "LED_BLUE";
					if (DISABLE_CHARGING)
					{
						EnableFTMUtility(FTMUtilityOptions.CHARGER, on: false);
					}
					RunSingleTest(text);
					Thread.Sleep(1000);
					if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.BLUE, ref color_value))
					{
						return false;
					}
					num = color_value;
					phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
					if (DISABLE_CHARGING)
					{
						EnableFTMUtility(FTMUtilityOptions.CHARGER, on: false);
					}
					Thread.Sleep(1000);
					if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.BLUE, ref color_value))
					{
						return false;
					}
					num2 = color_value;
					WriteLogMessage("BLUE Color voltage percent= " + num);
					WriteLogMessage("BLUE OFF Color voltage percent= " + num2);
					flag = Math.Abs(num - num2) >= num3 && flag;
				}
			}
			else
			{
				if (LED_RED_TEST)
				{
					text = "LED_RED";
					flag &= LED_INDICATOR(text, text, onOffDelta);
				}
				if (LED_GREEN_TEST)
				{
					text = "LED_GREEN";
					flag &= LED_INDICATOR(text, text, onOffDelta);
				}
				if (LED_BLUE_TEST)
				{
					text = "LED_BLUE";
					flag &= LED_INDICATOR(text, text, onOffDelta);
				}
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
		finally
		{
			ZRetractAll();
		}
	}

	public bool LED_GREEN_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		try
		{
			xyTableInstance.Retract_MoveTo_touch(xyLOCATE.LIGHTSENSE.ToString());
			Thread.Sleep(wait_table_move_s * 1000);
			string onTestName = "LED_GREEN_ON";
			string offTestName = "LED_GREEN_OFF";
			if (!deprecated)
			{
				onTestName = "LED_GREEN";
				offTestName = "LED_GREEN";
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta);
			}
			else
			{
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta, deprecated: true);
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			xyTableInstance.zRetractAll();
			return false;
		}
	}

	public bool LED_GREEN()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		try
		{
			string onTestName = "LED_GREEN_ON";
			string offTestName = "LED_GREEN_OFF";
			if (!deprecated)
			{
				onTestName = "LED_GREEN";
				offTestName = "LED_GREEN";
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta);
			}
			else
			{
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta, deprecated: true);
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			return false;
		}
	}

	public bool LED_BLUE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		try
		{
			string onTestName = "LED_BLUE_ON";
			string offTestName = "LED_BLUE_OFF";
			if (!deprecated)
			{
				onTestName = "LED_BLUE";
				offTestName = "LED_BLUE";
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta);
			}
			else
			{
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta, deprecated: true);
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			return false;
		}
	}

	public bool LED_BLUE_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		try
		{
			xyTableInstance.Retract_MoveTo_touch(xyLOCATE.LIGHTSENSE.ToString());
			Thread.Sleep(wait_table_move_s * 1000);
			string onTestName = "LED_BLUE_ON";
			string offTestName = "LED_BLUE_OFF";
			if (!deprecated)
			{
				onTestName = "LED_BLUE";
				offTestName = "LED_BLUE";
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta);
			}
			else
			{
				flag = LED_INDICATOR(onTestName, offTestName, onOffDelta, deprecated: true);
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			xyTableInstance.zRetractAll();
			return false;
		}
	}

	public bool FLASHLIGHT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		string testName = "FLASHLIGHT_ON";
		string text = "FLASHLIGHT_OFF";
		if (!deprecated)
		{
			testName = "FLASHLIGHT";
			text = "FLASHLIGHT";
		}
		try
		{
			RunSingleTest(testName);
			Thread.Sleep(500);
			double num = 0.0;
			double num2 = 0.0;
			int num3 = 5;
			int num4 = 0;
			for (int i = 0; i < num3; i++)
			{
				double analog_Voltage_FLASHLIGHT_Sensor = fixtureInstance.Get_Analog_Voltage_FLASHLIGHT_Sensor();
				num4++;
				num += analog_Voltage_FLASHLIGHT_Sensor;
				WriteLogMessage($"ON reading {i} - {analog_Voltage_FLASHLIGHT_Sensor} volts");
				Thread.Sleep(100);
			}
			num /= (double)num4;
			WriteLogMessage($"ON reading average value {num}volts");
			if (deprecated)
			{
				RunSingleTest(text);
			}
			else
			{
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
			}
			Thread.Sleep(500);
			for (int j = 0; j < num3; j++)
			{
				double analog_Voltage_FLASHLIGHT_Sensor2 = fixtureInstance.Get_Analog_Voltage_FLASHLIGHT_Sensor();
				num2 += analog_Voltage_FLASHLIGHT_Sensor2;
				WriteLogMessage($"OFF reading {j} - {analog_Voltage_FLASHLIGHT_Sensor2} volts");
			}
			num2 /= (double)num3;
			WriteLogMessage($"OFF reading average value {num2}volts");
			flag = ((onOffDelta <= num - num2) ? true : false);
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			if (deprecated)
			{
				RunSingleTest(text);
			}
			else
			{
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
			}
			return false;
		}
	}

	public bool FLASHLIGHT_1()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string s = "0";
		bool flag = false;
		string methodName = "FLASHLIGHT_ON";
		string text = "FLASHLIGHT_OFF";
		if (!deprecated)
		{
			methodName = "FLASHLIGHT_1";
			text = "FLASHLIGHT_1";
		}
		try
		{
			RunSingleTestWithWait(methodName, ushort.Parse(s));
			Thread.Sleep(500);
			double num = 0.0;
			double num2 = 0.0;
			int num3 = 5;
			int num4 = 0;
			for (int i = 0; i < num3; i++)
			{
				double analog_Voltage_FLASHLIGHT_Sensor = fixtureInstance.Get_Analog_Voltage_FLASHLIGHT_Sensor();
				num4++;
				num += analog_Voltage_FLASHLIGHT_Sensor;
				WriteLogMessage($"ON reading {i} - {analog_Voltage_FLASHLIGHT_Sensor} volts");
				Thread.Sleep(100);
			}
			num /= (double)num4;
			WriteLogMessage($"ON reading average value {num}volts");
			if (deprecated)
			{
				RunSingleTestWithWait(text, ushort.Parse(s));
			}
			else
			{
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
			}
			Thread.Sleep(500);
			for (int j = 0; j < num3; j++)
			{
				double analog_Voltage_FLASHLIGHT_Sensor2 = fixtureInstance.Get_Analog_Voltage_FLASHLIGHT_Sensor();
				num2 += analog_Voltage_FLASHLIGHT_Sensor2;
				WriteLogMessage($"OFF reading {j} - {analog_Voltage_FLASHLIGHT_Sensor2} volts");
			}
			num2 /= (double)num3;
			WriteLogMessage($"OFF reading average value {num2}volts");
			flag = ((onOffDelta <= num - num2) ? true : false);
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			if (deprecated)
			{
				RunSingleTestWithWait(text, ushort.Parse(s));
			}
			else
			{
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
			}
			return false;
		}
	}

	public bool LCD_BACKLIGHT_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		if (!CheckFixtureExist())
		{
			return false;
		}
		double num = 0.0;
		double num2 = 0.0;
		double color_value = 0.0;
		bool result = false;
		double num3 = 0.0;
		bool IO_OUT = true;
		num3 = onOffDelta;
		string text2 = "LCD_BACKLIGHT";
		try
		{
			xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.LOC_LCD_BACKLIGHT.ToString(), enablePartialRetract: true);
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			if (!fixtureIsRevB)
			{
				num = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.RED);
				num += fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.GREEN);
				num += fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.BLUE);
				num /= 3.0;
				WriteLogMessage("\r\n Backlight off voltage:  " + num);
				RunSingleTestWithWait(text2, ushort.Parse(text));
				Thread.Sleep(1000);
				num2 = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.RED);
				num2 += fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.GREEN);
				num2 += fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(USB_IO_Expander.LCD_Color.BLUE);
				num2 /= 3.0;
				WriteLogMessage("\r\n Backlight on voltage:  " + num2);
			}
			else
			{
				if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.RED, ref color_value))
				{
					return false;
				}
				num += color_value;
				if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.GREEN, ref color_value))
				{
					return false;
				}
				num += color_value;
				if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.BLUE, ref color_value))
				{
					return false;
				}
				num += color_value;
				num /= 3.0;
				WriteLogMessage("\r\n Backlight off voltage percent:  " + num);
				RunSingleTestWithWait(text2, ushort.Parse(text));
				Thread.Sleep(1000);
				color_value = 0.0;
				if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.RED, ref color_value))
				{
					return false;
				}
				num2 += color_value;
				if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.GREEN, ref color_value))
				{
					return false;
				}
				num2 += color_value;
				if (!fixtureInstance.I2C_Read_RGB(USB_IO_Expander.LCD_Color.BLUE, ref color_value))
				{
					return false;
				}
				num2 += color_value;
				num2 /= 3.0;
				WriteLogMessage("\r\n Backlight on voltage percent:  " + num2);
			}
			if (Math.Abs(num - num2) >= num3)
			{
				result = true;
			}
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text2);
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text2);
			return false;
		}
		finally
		{
			ZRetractAll();
		}
	}

	public bool LCD_RGB()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = true;
		try
		{
			flag &= ColorCheck(USB_IO_Expander.LCD_Color.RED);
			flag &= ColorCheck(USB_IO_Expander.LCD_Color.GREEN);
			flag &= ColorCheck(USB_IO_Expander.LCD_Color.BLUE);
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	private bool ColorCheck(USB_IO_Expander.LCD_Color Color, string testPrefix = "LCD_")
	{
		double color_value = 0.0;
		double num = 0.0;
		double color_value2 = 0.0;
		List<USB_IO_Expander.LCD_Color> list = new List<USB_IO_Expander.LCD_Color>(new USB_IO_Expander.LCD_Color[3]
		{
			USB_IO_Expander.LCD_Color.BLUE,
			USB_IO_Expander.LCD_Color.RED,
			USB_IO_Expander.LCD_Color.GREEN
		});
		list.Remove(Color);
		RunSingleTest(testPrefix + Color);
		Thread.Sleep(1000);
		if (fixtureIsRevB)
		{
			if (!fixtureInstance.I2C_Read_RGB(Color, ref color_value))
			{
				return false;
			}
			foreach (USB_IO_Expander.LCD_Color item in list)
			{
				if (!fixtureInstance.I2C_Read_RGB(item, ref color_value2))
				{
					return false;
				}
				num += color_value2;
			}
			num /= 2.0;
			WriteLogMessage(Color.ToString() + " Color Percent = " + color_value);
			WriteLogMessage(Color.ToString() + " OFF Color Percent = " + num);
			if (color_value.ToString() == null)
			{
				return false;
			}
		}
		else
		{
			color_value = fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(Color);
			foreach (USB_IO_Expander.LCD_Color item2 in list)
			{
				num += fixtureInstance.Get_Analog_Voltage_LCD_Light_Sensor(item2);
			}
			num /= 2.0;
			WriteLogMessage(Color.ToString() + "Color voltage = " + color_value);
			WriteLogMessage(Color.ToString() + "OFF Color voltage = " + num);
		}
		return Math.Abs(color_value - num) >= onOffDelta;
	}

	public bool LCD_RGB_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (!useFixture)
		{
			WriteLogMessage($"\r\n Test Fixture not present - Cannot run {name} Test.");
			return false;
		}
		if (!xyTableEnabled)
		{
			WriteLogMessage($"\r\n XYTable not present - Cannot run {name} Test.");
			return false;
		}
		bool flag = true;
		_ = onOffDelta;
		try
		{
			int Delta_x = 0;
			int Delta_y = 0;
			int Delta_z = 0;
			int Delta_z2 = 0;
			string text = "";
			if (!getDelta_to_target_POS("LOC_LCD_BACKLIGHT", ref Delta_x, ref Delta_y, ref Delta_z, ref Delta_z2, ref text))
			{
				WriteLogMessage("failed to get getDelta_to_target_POS");
			}
			if (Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_z) >= 2000)
			{
				xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.LOC_LCD_BACKLIGHT.ToString(), enablePartialRetract: true);
			}
			flag = LCD_RGB();
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
		finally
		{
			ZRetractAll();
		}
	}

	public bool LCD_LOAD_IMAGE(ushort timeOutSeconds)
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			WriteLogMessage("\r\nLoading IMAGE.png file to phone");
			phone.FTM_AP_WriteFile(ref FTMErrorCode, imageFileRemoteName, imageFileLocalLocation);
			Thread.Sleep(200);
			CheckFTMErrorCodeWithErrorMessage("Failed to load image.png file to phone");
			RunSingleTestWithWait(MMI_testName, timeOutSeconds);
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool KEYPAD_BACKLIGHT()
	{
		string text = MethodBase.GetCurrentMethod().Name;
		WriteLines(text);
		if (MMI_MODE == MMIMODE.FFBM)
		{
			text = "KEYPADBACKLIGHT";
		}
		if (!useFixture)
		{
			WriteLogMessage($"\r\n Test Fixture not present - Cannot run {text} Test.");
			return false;
		}
		try
		{
			List<double> list = new List<double>();
			List<double> list2 = new List<double>();
			for (int i = 0; i < 8; i++)
			{
				if (3 == i || 7 == i)
				{
					list.Add(0.0);
					continue;
				}
				string readVal = "";
				fixtureInstance.SetKeyBacklight(i);
				Thread.Sleep(100);
				fixtureInstance.ReadKeyBacklight(out readVal);
				WriteDebugMessage($"\r\nRead OFF value = {readVal} for IO{i}");
				readVal = readVal.Replace(" ", "").Substring(4, 4);
				WriteDebugMessage($"\r\nRead OFF value = {readVal} for IO{i}");
				int num = Convert.ToInt32(readVal, 16);
				WriteDebugMessage($"\r\nRead OFF value = {num} for IO{i}");
				double item = (double)num / 4096.0 * 2.5;
				WriteDebugMessage(item.ToString("f2"));
				list.Add(item);
			}
			RunSingleTest(text);
			for (int j = 0; j < 8; j++)
			{
				if (3 == j || 7 == j)
				{
					list2.Add(0.0);
					continue;
				}
				string readVal2 = "";
				Thread.Sleep(50);
				fixtureInstance.SetKeyBacklight(j);
				Thread.Sleep(100);
				fixtureInstance.ReadKeyBacklight(out readVal2);
				WriteDebugMessage($"\r\nRead ON value = {readVal2} for IO{j}");
				readVal2 = readVal2.Replace(" ", "").Substring(4, 4);
				WriteDebugMessage($"\r\nRead ON value = {readVal2} for IO{j}");
				int num2 = Convert.ToInt32(readVal2, 16);
				WriteDebugMessage($"\r\nRead ON value = {num2} for IO{j}");
				double item2 = (double)num2 / 4096.0 * 2.5;
				WriteDebugMessage(item2.ToString("f2"));
				list2.Add(item2);
			}
			for (int k = 0; k < 8; k++)
			{
				if (3 != k && 7 != k && !(Math.Abs(list2[k] - list[k]) > onOffDelta))
				{
					WriteLogMessage($"\r\n|IO{k} ON voltage:{list2[k]} - OFF voltage:{list[k]}|<onOffDelta:{onOffDelta}");
					return false;
				}
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			return false;
		}
	}

	public bool SENSOR_ON_THE_MOVE_X()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		if (!CheckFixtureExist())
		{
			return false;
		}
		bool result = true;
		if (!bool.TryParse(FindParameterValueFromSectionWithName("GYROSCOPE"), out result))
		{
			result = true;
		}
		Stopwatch stopwatch = new Stopwatch();
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("GYRO_Y_Delta"), out var result2))
		{
			WriteLogMessage("Failed to find GYRO_Y_Delta ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("GS_X_Delta"), out var result3))
		{
			WriteLogMessage("Failed to find GS_X_Delta ");
			return false;
		}
		double num = 10.0;
		double x = -999.0;
		double y = -999.0;
		double z = -999.0;
		double x2 = -999.0;
		double y2 = -999.0;
		double z2 = -999.0;
		double num2 = -999.0;
		double num3 = -999.0;
		double num4 = -999.0;
		double x3 = -999.0;
		double y3 = -999.0;
		double z3 = -999.0;
		try
		{
			ushort timeOut_s = 1;
			if (result)
			{
				if (!GYROSCOPE(ref x, ref y, ref z, timeOut_s))
				{
					WriteLogMessage("Error in getting GYROSCOPE readings");
					return false;
				}
				WriteLogMessage($"GYRO Initial readings: x={x}, y={y}, z={z}");
			}
			if (!GRAVITY_SENSOR(ref x2, ref y2, ref z2, timeOut_s))
			{
				WriteLogMessage("Error in getting GRAVITY_SENSOR readings");
				return false;
			}
			WriteLogMessage($"GRAVITY_SENSOR Initial readings: x={x2}, y={y2}, z={z2}");
			List<double> T_x = new List<double>();
			List<double> T_y = new List<double>();
			List<double> T_z = new List<double>();
			if (cradleType == 2)
			{
				ReleasePhoneLever("LEVER3");
			}
			xyTableInstance.Retract_MoveTo(xyLOCATE.LEVER1.ToString());
			bool result4 = true;
			xyTableInstance.WaitForCmd = false;
			PressDownSideLever(moveWhileDownOK: true);
			stopwatch.Start();
			if (result)
			{
				RunSingleTest("GYROSCOPE");
			}
			xyTableInstance.WaitForCmd = true;
			xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LEVER1.ToString(), useOffset: false, moveWhileDownOK: true);
			if (result)
			{
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, "GYROSCOPE");
			}
			stopwatch.Stop();
			WriteLogMessage("SENSOR_X in s:" + stopwatch.ElapsedMilliseconds);
			if (result)
			{
				GetGyroLog(ref T_x, ref T_y, ref T_z);
				if (flag)
				{
					string sourceFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK.txt";
					string destFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK" + name + "__" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".txt";
					File.Copy(sourceFileName, destFileName);
				}
				num3 = getMoveReading(y, 0.02, T_y);
				WriteLogMessage($"GYRO Move readings: x={num2}, y={num3}, z={num4}");
				if (Math.Abs(num3 - y) < result2)
				{
					WriteLogMessage($"Failed GRYO limit Check GYRO_Y_Move [{num3}] < GYRO_Y_Delta [{result2}]");
					result4 = false;
				}
			}
			if (!GRAVITY_SENSOR(ref x3, ref y3, ref z3, timeOut_s))
			{
				WriteLogMessage("Error in getting GRAVITY_SENSOR readings");
				return false;
			}
			WriteLogMessage($"GRAVITY_SENSOR Move readings: x={x3}, y={y3}, z={z3}");
			xyTableInstance.zRetract_partial(DUT_zone: false, retractz1: true, retractz2: true);
			if (result3 > Math.Abs(x3 - x2) || Math.Abs(x3 - x2) > num)
			{
				WriteLogMessage("GRAVITY_SENSOR X Delta Limit check failed");
				result4 = false;
			}
			return result4;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			xyTableInstance.zRetract_partial(DUT_zone: false, retractz1: true, retractz2: true);
			return false;
		}
	}

	public bool SENSOR_ON_THE_MOVE_X_V3()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = true;
		string[] array = new string[1] { "TIMEOUT_S" };
		string[] default_values = new string[1] { "0" };
		string[] parameter_values = new string[1] { "0" };
		getParameters(array, default_values, ref parameter_values);
		ushort result = 1;
		if (!ushort.TryParse(parameter_values[0], out result))
		{
			WriteLogMessage($"Error to parse {array[0]} ");
			return false;
		}
		string[] limits = new string[24]
		{
			"GYRO_INIT_X_LL", "GYRO_INIT_X_UL", "GYRO_INIT_Y_LL", "GYRO_INIT_Y_UL", "GYRO_INIT_Z_LL", "GYRO_INIT_Z_UL", "GS_INIT_X_LL", "GS_INIT_X_UL", "GS_INIT_Y_LL", "GS_INIT_Y_UL",
			"GS_INIT_Z_LL", "GS_INIT_Z_UL", "GYRO_MOVE_X_LL", "GYRO_MOVE_X_UL", "GYRO_MOVE_Y_LL", "GYRO_MOVE_Y_UL", "GYRO_MOVE_Z_LL", "GYRO_MOVE_Z_UL", "GS_MOVE_X_LL", "GS_MOVE_X_UL",
			"GS_MOVE_Y_LL", "GS_MOVE_Y_UL", "GS_MOVE_Z_LL", "GS_MOVE_Z_UL"
		};
		double[] limits_values = new double[24]
		{
			-999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0,
			-999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0,
			-999.0, -999.0, -999.0, -999.0
		};
		if (!getLimits(limits, ref limits_values))
		{
			return false;
		}
		double x = -999.0;
		double y = -999.0;
		double z = -999.0;
		double x2 = -999.0;
		double y2 = -999.0;
		double z2 = -999.0;
		double num = -999.0;
		double num2 = -999.0;
		double num3 = -999.0;
		double x3 = -999.0;
		double y3 = -999.0;
		double z3 = -999.0;
		try
		{
			ushort timeOut_s = result;
			if (!GYROSCOPE(ref x, ref y, ref z, timeOut_s))
			{
				WriteLogMessage("Error in getting GYRO readings");
				return false;
			}
			WriteLogMessage($"GYRO Initial readings: x={x}, y={y}, z={z}");
			if (!GRAVITY_SENSOR(ref x2, ref y2, ref z2, timeOut_s))
			{
				WriteLogMessage("Error in getting GRAVITY_SENSOR readings");
				return false;
			}
			WriteLogMessage($"GRAVITY_SENSOR Initial readings: x={x2}, y={y2}, z={z2}");
			List<double> T_x = new List<double>();
			List<double> T_y = new List<double>();
			List<double> T_z = new List<double>();
			if (cradleType == 2)
			{
				ReleasePhoneLever("LEVER3");
			}
			xyTableInstance.Retract_MoveTo(xyLOCATE.LEVER1.ToString(), useOffset: false, enablePartiialRetract: true, z1_retract: false, z2_retract: true);
			bool result2 = true;
			xyTableInstance.WaitForCmd = false;
			PressDownSideLever(moveWhileDownOK: true);
			RunSingleTestWithWait("GYROSCOPE_TRACK", result);
			xyTableInstance.WaitForCmd = true;
			xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LEVER1.ToString(), useOffset: false, moveWhileDownOK: true);
			GetGyroLog(ref T_x, ref T_y, ref T_z);
			if (flag)
			{
				string sourceFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK.txt";
				string destFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK" + name + "__" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".txt";
				File.Copy(sourceFileName, destFileName);
			}
			double lL = 0.02;
			double uL = 1.0;
			num2 = getAverageReading_remove_outlier(lL, uL, T_y);
			WriteLogMessage($"GYRO Move readings: x={num}, y={num2}, z={num3}");
			if (!GRAVITY_SENSOR(ref x3, ref y3, ref z3, timeOut_s))
			{
				WriteLogMessage("Error in getting GRAVITY_SENSOR readings");
				return false;
			}
			WriteLogMessage($"GRAVITY_SENSOR Move readings: x={x3}, y={y3}, z={z3}");
			xyTableInstance.zRetract_partial();
			int num4 = 0;
			if (x < limits_values[num4] || x > limits_values[num4 + 1])
			{
				WriteLogMessage($"Limit check failed: GYRO_X_Init = {x} [{limits_values[num4]},{limits_values[num4 + 1]}]");
				result2 = false;
			}
			if (y < limits_values[num4 + 2] || y > limits_values[num4 + 3])
			{
				WriteLogMessage($"Limit check failed: GYRO_Y_Init = {y} [{limits_values[num4 + 2]},{limits_values[num4 + 3]}]");
				result2 = false;
			}
			if (z < limits_values[num4 + 4] || x > limits_values[num4 + 5])
			{
				WriteLogMessage($"Limit check failed: GYRO_Z_Init = {x} [{limits_values[num4 + 4]},{limits_values[num4 + 5]}]");
				result2 = false;
			}
			if (x2 < limits_values[num4 + 6] || x2 > limits_values[num4 + 7])
			{
				WriteLogMessage($"Limit check failed: GS_X_Init = {x2} [{limits_values[num4 + 6]},{limits_values[num4 + 7]}]");
				result2 = false;
			}
			if (y2 < limits_values[num4 + 8] || y2 > limits_values[num4 + 9])
			{
				WriteLogMessage($"Limit check failed: GS_Y_Init = {y2} [{limits_values[num4 + 8]},{limits_values[num4 + 9]}]");
				result2 = false;
			}
			if (z2 < limits_values[num4 + 10] || x2 > limits_values[num4 + 11])
			{
				WriteLogMessage($"Limit check failed: GS_Z_Init = {x2} [{limits_values[num4 + 10]},{limits_values[num4 + 11]}]");
				result2 = false;
			}
			num4 = 12;
			if (num2 < limits_values[num4 + 2] || num2 > limits_values[num4 + 3])
			{
				WriteLogMessage($"Limit check failed: GYRO_Y_Move = {num2} [{limits_values[num4 + 2]},{limits_values[num4 + 3]}]");
				result2 = false;
			}
			if (x3 < limits_values[num4 + 6] || x3 > limits_values[num4 + 7])
			{
				WriteLogMessage($"Limit check failed: GS_X_Move = {x3} [{limits_values[num4 + 6]},{limits_values[num4 + 7]}]");
				result2 = false;
			}
			return result2;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			xyTableInstance.zRetract_partial(DUT_zone: false, retractz1: true, retractz2: true);
			return false;
		}
	}

	public bool SENSOR_ON_THE_MOVE_Y_V3()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = true;
		string[] array = new string[1] { "TIMEOUT_S" };
		string[] default_values = new string[1] { "0" };
		string[] parameter_values = new string[1] { "0" };
		getParameters(array, default_values, ref parameter_values);
		ushort result = 1;
		if (!ushort.TryParse(parameter_values[0], out result))
		{
			WriteLogMessage($"Error to parse {array[0]} ");
			return false;
		}
		string[] limits = new string[24]
		{
			"GYRO_INIT_X_LL", "GYRO_INIT_X_UL", "GYRO_INIT_Y_LL", "GYRO_INIT_Y_UL", "GYRO_INIT_Z_LL", "GYRO_INIT_Z_UL", "GS_INIT_X_LL", "GS_INIT_X_UL", "GS_INIT_Y_LL", "GS_INIT_Y_UL",
			"GS_INIT_Z_LL", "GS_INIT_Z_UL", "GYRO_MOVE_X_LL", "GYRO_MOVE_X_UL", "GYRO_MOVE_Y_LL", "GYRO_MOVE_Y_UL", "GYRO_MOVE_Z_LL", "GYRO_MOVE_Z_UL", "GS_MOVE_X_LL", "GS_MOVE_X_UL",
			"GS_MOVE_Y_LL", "GS_MOVE_Y_UL", "GS_MOVE_Z_LL", "GS_MOVE_Z_UL"
		};
		double[] limits_values = new double[24]
		{
			-999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0,
			-999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0,
			-999.0, -999.0, -999.0, -999.0
		};
		if (!getLimits(limits, ref limits_values))
		{
			return false;
		}
		double x = -999.0;
		double y = -999.0;
		double z = -999.0;
		double x2 = -999.0;
		double y2 = -999.0;
		double z2 = -999.0;
		double num = -999.0;
		double num2 = -999.0;
		double num3 = -999.0;
		double x3 = -999.0;
		double y3 = -999.0;
		double z3 = -999.0;
		try
		{
			ushort timeOut_s = result;
			if (!GYROSCOPE(ref x, ref y, ref z, timeOut_s))
			{
				WriteLogMessage("Error in getting GYROSCOPE readings");
				return false;
			}
			WriteLogMessage($"GYROSCOPE Initial readings: x={x}, y={y}, z={z}");
			if (!GRAVITY_SENSOR(ref x2, ref y2, ref z2, timeOut_s))
			{
				WriteLogMessage("Error in getting GRAVITY_SENSOR initial readings");
				return false;
			}
			WriteLogMessage($"GRAVITY_SENSOR Initial readings: x={x2}, y={y2}, z={z2}");
			xyTableInstance.Retract_MoveTo(xyLOCATE.LEVER2.ToString());
			xyTableInstance.WaitForCmd = false;
			TopPhoneLever(moveWhileDownOK: true);
			RunSingleTestWithWait("GYROSCOPE_TRACK", result);
			xyTableInstance.WaitForCmd = true;
			xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LEVER2.ToString(), useOffset: false, moveWhileDownOK: true);
			List<double> T_x = new List<double>();
			List<double> T_y = new List<double>();
			List<double> T_z = new List<double>();
			bool result2 = true;
			GetGyroLog(ref T_x, ref T_y, ref T_z);
			if (flag)
			{
				string sourceFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK.txt";
				string destFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK" + name + "__" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".txt";
				File.Copy(sourceFileName, destFileName);
			}
			double lL = 0.02;
			double uL = 1.0;
			num = getAverageReading_remove_outlier(lL, uL, T_x);
			WriteLogMessage($"GYRO Move readings: x={num}, y={num2}, z={num3}");
			if (!GRAVITY_SENSOR(ref x3, ref y3, ref z3, timeOut_s))
			{
				WriteLogMessage("Error in getting GRAVITY_SENSOR move readings");
				return false;
			}
			WriteLogMessage($"GRAVITY_SENSOR Move readings: x={x3}, y={y3}, z={z3}");
			xyTableInstance.zRetract_partial();
			int num4 = 0;
			if (x < limits_values[num4] || x > limits_values[num4 + 1])
			{
				WriteLogMessage($"Limit check failed: GYRO_X_Init = {x} [{limits_values[num4]},{limits_values[num4 + 1]}]");
				result2 = false;
			}
			if (y < limits_values[num4 + 2] || y > limits_values[num4 + 3])
			{
				WriteLogMessage($"Limit check failed: GYRO_Y_Init = {y} [{limits_values[num4 + 2]},{limits_values[num4 + 3]}]");
				result2 = false;
			}
			if (z < limits_values[num4 + 4] || x > limits_values[num4 + 5])
			{
				WriteLogMessage($"Limit check failed: GYRO_Z_Init = {x} [{limits_values[num4 + 4]},{limits_values[num4 + 5]}]");
				result2 = false;
			}
			if (x2 < limits_values[num4 + 6] || x2 > limits_values[num4 + 7])
			{
				WriteLogMessage($"Limit check failed: GS_X_Init = {x2} [{limits_values[num4 + 6]},{limits_values[num4 + 7]}]");
				result2 = false;
			}
			if (y2 < limits_values[num4 + 8] || y2 > limits_values[num4 + 9])
			{
				WriteLogMessage($"Limit check failed: GS_Y_Init = {y2} [{limits_values[num4 + 8]},{limits_values[num4 + 9]}]");
				result2 = false;
			}
			if (z2 < limits_values[num4 + 10] || x2 > limits_values[num4 + 11])
			{
				WriteLogMessage($"Limit check failed: GS_Z_Init = {x2} [{limits_values[num4 + 10]},{limits_values[num4 + 11]}]");
				result2 = false;
			}
			num4 = 12;
			if (num < limits_values[num4] || num > limits_values[num4 + 1])
			{
				WriteLogMessage($"Limit check failed: GYRO_X_Move = {num} [{limits_values[num4]},{limits_values[num4 + 1]}]");
				result2 = false;
			}
			if (y3 < limits_values[num4 + 8] || y3 > limits_values[num4 + 9])
			{
				WriteLogMessage($"Limit check failed: GS_Y_Move = {y3} [{limits_values[num4 + 8]},{limits_values[num4 + 9]}]");
				result2 = false;
			}
			return result2;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			xyTableInstance.zRetract_partial(DUT_zone: false, retractz1: true, retractz2: true);
			return false;
		}
	}

	public bool SENSOR_ON_THE_MOVE_Y()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		if (!CheckFixtureExist())
		{
			return false;
		}
		bool result = true;
		if (!bool.TryParse(FindParameterValueFromSectionWithName("GYROSCOPE"), out result))
		{
			result = true;
		}
		Stopwatch stopwatch = new Stopwatch();
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("GYRO_X_Delta"), out var result2))
		{
			WriteLogMessage("Failed to find GYRO_X_Delta ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("GS_Y_Delta"), out var result3))
		{
			WriteLogMessage("Failed to find GS_Y_Delta ");
			return false;
		}
		double num = 10.0;
		double x = -999.0;
		double y = -999.0;
		double z = -999.0;
		double x2 = -999.0;
		double y2 = -999.0;
		double z2 = -999.0;
		double num2 = -999.0;
		double num3 = -999.0;
		double num4 = -999.0;
		double x3 = -999.0;
		double y3 = -999.0;
		double z3 = -999.0;
		try
		{
			ushort timeOut_s = 1;
			if (result)
			{
				if (!GYROSCOPE(ref x, ref y, ref z, timeOut_s))
				{
					WriteLogMessage("Error in getting GYROSCOPE readings");
					return false;
				}
				WriteLogMessage($"GYROSCOPE Initial readings: x={x}, y={y}, z={z}");
			}
			if (!GRAVITY_SENSOR(ref x2, ref y2, ref z2, timeOut_s))
			{
				WriteLogMessage("Error in getting GRAVITY_SENSOR readings");
				return false;
			}
			WriteLogMessage($"GRAVITY_SENSOR Initial readings: x={x2}, y={y2}, z={z2}");
			xyTableInstance.Retract_MoveTo(xyLOCATE.LEVER2.ToString());
			xyTableInstance.WaitForCmd = false;
			TopPhoneLever(moveWhileDownOK: true);
			List<double> T_x = new List<double>();
			List<double> T_y = new List<double>();
			List<double> T_z = new List<double>();
			bool result4 = true;
			stopwatch.Start();
			if (result)
			{
				RunSingleTest("GYROSCOPE");
			}
			xyTableInstance.WaitForCmd = true;
			xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LEVER2.ToString(), useOffset: false, moveWhileDownOK: true);
			if (result)
			{
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, "GYROSCOPE");
			}
			stopwatch.Stop();
			WriteLogMessage("SENSOR_Y in s:" + stopwatch.ElapsedMilliseconds);
			if (result)
			{
				GetGyroLog(ref T_x, ref T_y, ref T_z);
				if (flag)
				{
					string sourceFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK.txt";
					string destFileName = "C:\\Qualcomm\\QDART\\MMI\\temp\\GYROSCOPE_TRACK" + name + "__" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".txt";
					File.Copy(sourceFileName, destFileName);
				}
				WriteLogMessage("T_x: " + T_x.Count());
				num2 = getMoveReading(x, 0.02, T_x);
				WriteLogMessage($"GYRO Move readings: x={num2}, y={num3}, z={num4}");
				if (Math.Abs(num2 - x) < result2)
				{
					WriteLogMessage($"Failed GRYO limit Check GYRO_X_Move [{num2}] < GYRO_X_Delta [{result2}]");
					result4 = false;
				}
			}
			if (!GRAVITY_SENSOR(ref x3, ref y3, ref z3, timeOut_s))
			{
				WriteLogMessage("Error in getting GRAVITY_SENSOR readings");
				return false;
			}
			WriteLogMessage($"GRAVITY_SENSOR Move readings: x={x3}, y={y3}, z={z3}");
			xyTableInstance.zRetract_partial(DUT_zone: false, retractz1: true, retractz2: true);
			if (result3 > Math.Abs(y3 - y2) || Math.Abs(y3 - y2) > num)
			{
				WriteLogMessage("GRAVITY_SENSOR Y Delta Limit check failed");
				result4 = false;
			}
			return result4;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			xyTableInstance.zRetract_partial(DUT_zone: false, retractz1: true, retractz2: true);
			return false;
		}
	}

	public bool GYROSCOPE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("x_lowerLimit"), out var result))
		{
			WriteLogMessage("Failed to find x_lowerLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("x_upperLimit"), out var result2))
		{
			WriteLogMessage("Failed to find x_upperLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("y_lowerLimit"), out var result3))
		{
			WriteLogMessage("Failed to find y_lowerLimit");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("y_upperLimit"), out var result4))
		{
			WriteLogMessage("Failed to find y_upperLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("z_lowerLimit"), out var result5))
		{
			WriteLogMessage("Failed to find z_lowerLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("z_upperLimit"), out var result6))
		{
			WriteLogMessage("Failed to find z_upperLimit ");
			return false;
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			double result7 = -999.0;
			if (!double.TryParse(ResultFromResultsFile(name, "x"), out var result8))
			{
				WriteLogMessage("Failed to find x value in result file");
				return false;
			}
			if (!double.TryParse(ResultFromResultsFile(name, "y"), out var result9))
			{
				WriteLogMessage("Failed to find y value in result file");
				return false;
			}
			if (!double.TryParse(ResultFromResultsFile(name, "z"), out result7))
			{
				WriteLogMessage("Failed to find z value in result file");
				return false;
			}
			bool flag = false;
			if (result8 >= result && result8 <= result2)
			{
				WriteLogMessage($"X - Value within limit {result} <= {result8} <= {result2}");
				if (result9 >= result3 && result9 <= result4)
				{
					WriteLogMessage($"Y - Value within limit {result3} <= {result9} <= {result4}");
					if (result7 >= result5 && result7 <= result6)
					{
						WriteLogMessage($"Z - Value within limit {result5} <= {result7} <= {result6}");
						flag = true;
					}
					else
					{
						WriteLogMessage("z_value out of limit");
						flag = false;
					}
				}
				else
				{
					WriteLogMessage("y_value out of limit");
					flag = false;
				}
			}
			else
			{
				WriteLogMessage("x_value out of limit");
				flag = false;
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	private bool GYROSCOPE(ref double x, ref double y, ref double z, ushort timeOut_s, bool enableLog = false)
	{
		bool result = true;
		string name = MethodBase.GetCurrentMethod().Name;
		try
		{
			phone.FTM_AP_Execute_Single_Test_WithWait(name, ref FTMErrorCode, timeOut_s, ref TestErrorCode, ref TimeOutOccurred);
			GetResultsFile(name);
			x = -999.0;
			y = -999.0;
			z = -999.0;
			if (!double.TryParse(ResultFromResultsFile(name, "x", 10, enableLog), out x))
			{
				WriteLogMessage("Failed to find x value in result file");
				result = false;
			}
			if (!double.TryParse(ResultFromResultsFile(name, "y", 1, enableLog), out y))
			{
				WriteLogMessage("Failed to find y value in result file");
				result = false;
			}
			if (!double.TryParse(ResultFromResultsFile(name, "z", 1, enableLog), out z))
			{
				WriteLogMessage("Failed to find z value in result file");
				result = false;
			}
			WriteLines(name, bStart: false);
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool GSENSOR()
	{
		WriteLogMessage("Deprecated, use GRAVITY_SENSOR instead.");
		return false;
	}

	public bool GRAVITY_SENSOR()
	{
		string text = MethodBase.GetCurrentMethod().Name;
		WriteLines(text);
		if (MMI_MODE == MMIMODE.FFBM)
		{
			text = "GSENSOR";
		}
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "0";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("x_lowerLimit"), out var result))
		{
			WriteLogMessage("Failed to find x_lowerLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("x_upperLimit"), out var result2))
		{
			WriteLogMessage("Failed to find x_upperLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("y_lowerLimit"), out var result3))
		{
			WriteLogMessage("Failed to find y_lowerLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("y_upperLimit"), out var result4))
		{
			WriteLogMessage("Failed to find y_upperLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("z_lowerLimit"), out var result5))
		{
			WriteLogMessage("Failed to find z_lowerLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("z_upperLimit"), out var result6))
		{
			WriteLogMessage("Failed to find z_upperLimit ");
			return false;
		}
		try
		{
			RunSingleTest(text);
			GetResultsFile(text);
			double result7 = -999.0;
			if (!double.TryParse(ResultFromResultsFile(text, "x"), out var result8))
			{
				WriteLogMessage("Failed to find x in result file");
				return false;
			}
			if (!double.TryParse(ResultFromResultsFile(text, "y"), out var result9))
			{
				WriteLogMessage("Failed to find y in result file");
				return false;
			}
			if (!double.TryParse(ResultFromResultsFile(text, "z"), out result7))
			{
				WriteLogMessage("Failed to find z in result file");
				return false;
			}
			bool flag = false;
			if (result8 >= result && result8 <= result2)
			{
				WriteLogMessage($"x - Value within limit {result} <= {result8} <= {result2}");
				if (result9 >= result3 && result9 <= result4)
				{
					WriteLogMessage($"y - Value within limit {result3} <= {result9} <= {result4}");
					if (result7 >= result5 && result7 <= result6)
					{
						WriteLogMessage($"z - Value within limit {result5} <= {result7} <= {result6}");
						flag = true;
					}
					else
					{
						WriteLogMessage("z out of limit");
						flag = false;
					}
				}
				else
				{
					WriteLogMessage("y out of limit");
					flag = false;
				}
			}
			else
			{
				WriteLogMessage("x out of limit");
				flag = false;
			}
			WriteLines(text, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(text + ex.Message);
			return false;
		}
	}

	private bool GRAVITY_SENSOR(ref double x, ref double y, ref double z, ushort timeOut_s, bool enableLog = false)
	{
		bool result = true;
		string text = MethodBase.GetCurrentMethod().Name;
		if (MMI_MODE == MMIMODE.FFBM)
		{
			text = "GSENSOR";
		}
		try
		{
			RunSingleTest(text);
			Thread.Sleep(2000);
			GetResultsFile();
			x = -999.0;
			y = -999.0;
			z = -999.0;
			if (!double.TryParse(ResultFromResultsFile(text, "x", 10, enableLog), out x))
			{
				WriteLogMessage("Failed to find x value in result file");
				result = false;
			}
			if (!double.TryParse(ResultFromResultsFile(text, "y", 1, enableLog), out y))
			{
				WriteLogMessage("Failed to find y value in result file");
				result = false;
			}
			if (!double.TryParse(ResultFromResultsFile(text, "z", 1, enableLog), out z))
			{
				WriteLogMessage("Failed to find z zvalue in result file");
				result = false;
			}
			WriteLines(text, bStart: false);
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(text + ex.Message);
			return false;
		}
	}

	public bool MSENSOR()
	{
		WriteLogMessage("Deprecated, use MAGNETIC_SENSOR instead.");
		return false;
	}

	private bool MAGNETIC_SENSOR(ref double x, ref double y, ref double z, string methodName)
	{
		try
		{
			RunSingleTest(methodName);
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, methodName);
			GetResultsFile(methodName);
			x = -999.0;
			y = -999.0;
			z = -999.0;
			if (!double.TryParse(ResultFromResultsFile(methodName, "x"), out x))
			{
				WriteLogMessage("Failed to find x value in result file");
			}
			if (!double.TryParse(ResultFromResultsFile(methodName, "y"), out y))
			{
				WriteLogMessage("Failed to find y value in result file");
			}
			if (!double.TryParse(ResultFromResultsFile(methodName, "z"), out z))
			{
				WriteLogMessage("Failed to find z value in result file");
			}
			WriteLines(methodName, bStart: false);
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(methodName + ex.Message);
			return false;
		}
	}

	public bool MSENSOR_PHONE()
	{
		WriteLogMessage("Deprecated, use MAGNETIC_SENSOR_PHONE instead.");
		return false;
	}

	public bool MAGNETIC_SENSOR_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool result = true;
		if (MMI_MODE == MMIMODE.QMMI)
		{
			MMI_testName = "MAGNETIC_SENSOR";
		}
		else
		{
			MMI_testName = "MSENSOR";
		}
		if (!CheckFixtureExist())
		{
			return false;
		}
		new Stopwatch();
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "10";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("M_X_Delta"), out var result2))
		{
			WriteLogMessage("Failed to find M_X_Delta in Parameter");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("M_Y_Delta"), out var result3))
		{
			WriteLogMessage("Failed to find M_Y_Delta in Parameter");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("M_Z_Delta"), out var result4))
		{
			WriteLogMessage("Failed to find M_Z_Delta in Parameter");
			return false;
		}
		double num = 500.0;
		double x = -999.0;
		double y = -999.0;
		double z = -999.0;
		double x2 = -999.0;
		double y2 = -999.0;
		double z2 = -999.0;
		try
		{
			int Delta_x = 0;
			int Delta_y = 0;
			int Delta_z = 0;
			int Delta_z2 = 0;
			string text = "";
			if (!getDelta_to_target_POS("MAG_POS1", ref Delta_x, ref Delta_y, ref Delta_z, ref Delta_z2, ref text))
			{
				WriteLogMessage("failed to get getDelta_to_target_POS");
			}
			if (Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_z) >= 2000)
			{
				xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.MAG_POS1.ToString(), enablePartialRetract: true);
			}
			Thread.Sleep(wait_table_move_s * 1000);
			if (!MAGNETIC_SENSOR(ref x, ref y, ref z, MMI_testName))
			{
				WriteLogMessage("Error in getting initial MAGNETIC_SENSOR readings");
				return false;
			}
			WriteLogMessage($"MAGNETIC_SENSOR Initial readings: x={x}, y={y}, z={z}");
			xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.MAG_POS2.ToString(), enablePartialRetract: true);
			Thread.Sleep(wait_table_move_s * 1000);
			if (!MAGNETIC_SENSOR(ref x2, ref y2, ref z2, MMI_testName))
			{
				WriteLogMessage("Error in getting move MAGNETIC_SENSOR readings");
				return false;
			}
			WriteLogMessage($"MAGNETIC_SENSOR Move readings: x={x2}, y={y2}, z={z2}");
			int num2 = 0;
			if (result2 > Math.Abs(x2 - x) || Math.Abs(x2 - x) > num)
			{
				WriteLogMessage("MAGNETIC_SENSOR X Delta Limit check failed");
				num2++;
				result = false;
			}
			if (result3 > Math.Abs(y2 - y) || Math.Abs(y2 - y) > num)
			{
				WriteLogMessage("MAGNETIC_SENSOR Y Delta Limit check failed");
				num2++;
				result = false;
			}
			if (result4 > Math.Abs(z2 - z) || Math.Abs(z2 - z) > num)
			{
				WriteLogMessage("MAGNETIC_SENSOR Z Delta Limit check failed");
				num2++;
				result = false;
			}
			if (num2 < 2)
			{
				WriteLogMessage("more than 2 of the 3 axis pass");
				return true;
			}
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool LSENSOR()
	{
		WriteLogMessage("Deprecated, use LIGHT_SENSOR instead.");
		return false;
	}

	public bool LIGHT_SENSOR()
	{
		string text = MethodBase.GetCurrentMethod().Name;
		WriteLines(text);
		if (MMI_MODE == MMIMODE.FFBM)
		{
			text = "LSENSOR";
		}
		bool IO_OUT = true;
		double result = -999.0;
		double result2 = -999.0;
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "0";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("lux_value_lowerLimit"), out var result3))
		{
			WriteLogMessage("Failed to find lux_value_lowerLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("lux_value_upperLimit"), out var result4))
		{
			WriteLogMessage("Failed to find lux_value_upperLimit ");
			return false;
		}
		try
		{
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			RunSingleTest(text);
			Thread.Sleep(200);
			GetResultsFile(text);
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
			double num = -999.0;
			if (!double.TryParse(ResultFromResultsFile(text, "value"), out result))
			{
				WriteLogMessage("Failed to find value in result file");
				setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
				return false;
			}
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			RunSingleTest(text);
			Thread.Sleep(200);
			GetResultsFile(text);
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
			if (!double.TryParse(ResultFromResultsFile(text, "value"), out result2))
			{
				WriteLogMessage("Failed to find value in result file");
				return false;
			}
			num = result - result2;
			bool flag = false;
			if (num >= result3 && num <= result4)
			{
				WriteLogMessage(string.Format("\r\nDelta_Lux = {1}\r\n -- value within limit [{0},{2}]", result3, num, result4));
				flag = true;
			}
			else
			{
				WriteLogMessage(string.Format("nDelta_Lux = {1}\r\n [{3} - {4}] out of limit [{0}, {2}]", result3, num, result4, result, result2));
				flag = false;
			}
			WriteLines(text, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(text + ex.Message);
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			return false;
		}
	}

	public bool LSENSOR_PHONE()
	{
		WriteLogMessage("Deprecated, use LIGHT_SENSOR_PHONE instead.");
		return false;
	}

	public bool LIGHT_SENSOR_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		name = ((MMI_MODE != MMIMODE.QMMI) ? "LSENSOR" : "LIGHT_SENSOR");
		if (!CheckFixtureExist())
		{
			return false;
		}
		double result = -999.0;
		double result2 = -999.0;
		string[] limits = new string[4] { "ON_LL", "ON_UL", "OFF_LL", "OFF_UL" };
		double[] limits_values = new double[4] { -999.0, -999.0, -999.0, -999.0 };
		if (!getLimits(limits, ref limits_values))
		{
			return false;
		}
		double num = limits_values[0];
		double num2 = limits_values[1];
		double num3 = limits_values[2];
		double num4 = limits_values[3];
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		bool IO_OUT = true;
		try
		{
			int Delta_x = 0;
			int Delta_y = 0;
			int Delta_z = 0;
			int Delta_z2 = 0;
			string text2 = "";
			if (!getDelta_to_target_POS("LIGHTSENSE", ref Delta_x, ref Delta_y, ref Delta_z, ref Delta_z2, ref text2))
			{
				WriteLogMessage("Failed to get getDelta_to_target_POS");
			}
			if (Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_y) >= 20 || Math.Abs(Delta_z) >= 20)
			{
				xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.LIGHTSENSE.ToString(), enablePartialRetract: true);
			}
			Thread.Sleep(wait_table_move_s * 1000);
			USB_IO_Expander.SetValue setBit;
			if (fixtureIsRevB)
			{
				if (!fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.CAMERA_LED_CNTRL_EN))
				{
					return false;
				}
			}
			else
			{
				setBit = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			RunSingleTestWithWait(name, ushort.Parse(text));
			GetResultsFile(name);
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, name);
			if (!double.TryParse(ResultFromResultsFile(name, "value"), out result))
			{
				WriteLogMessage("Failed to find value in result file");
				setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
				return false;
			}
			if (fixtureIsRevB)
			{
				if (!fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.CAMERA_LED_CNTRL_DIS))
				{
					return false;
				}
			}
			else
			{
				setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			Thread.Sleep(500);
			RunSingleTestWithWait(name, ushort.Parse(text));
			GetResultsFile(name);
			if (!double.TryParse(ResultFromResultsFile(name, "value"), out result2))
			{
				WriteLogMessage("Failed to find value in result file");
				return false;
			}
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, name);
			bool flag = false;
			if (result >= num && result <= num2)
			{
				WriteLogMessage(string.Format("\r\n ON check passed ON_value = {1} -- within limit [{0},{2}]", num, result, num2));
				flag = true;
			}
			else
			{
				WriteLogMessage(string.Format("\r\n ON check failed ON_value = {1} -- out of limit [{0},{2}]", num, result, num2));
				flag = false;
			}
			if (result2 >= num3 && result2 <= num4)
			{
				WriteLogMessage(string.Format("\r\n OFF check passed OFF_value = {1} -- within limit [{0},{2}]", num3, result2, num4));
				flag = flag;
			}
			else
			{
				WriteLogMessage(string.Format("\r\n OFF check failed OFF_value = {1} -- out of limit [{0},{2}]", num3, result2, num4));
				flag = false;
			}
			WriteLines(name, bStart: false);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage("xy Table message: " + xyTableInstance.msg);
			WriteLogMessage(name + ex.Message);
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			return false;
		}
		finally
		{
			ZRetractAll();
		}
	}

	public bool PSENSOR()
	{
		WriteLogMessage("Deprecated, use PROXIMITY_SENSOR instead.");
		return false;
	}

	public bool PROXIMITY_SENSOR()
	{
		string text = MethodBase.GetCurrentMethod().Name;
		WriteLines(text);
		if (MMI_MODE == MMIMODE.FFBM)
		{
			text = "PSENSOR";
		}
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "0";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("prx_value_lowerLimit"), out var result))
		{
			WriteLogMessage("Failed to find prx_value_lowerLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("prx_value_upperLimit"), out var result2))
		{
			WriteLogMessage("Failed to find prx_value_upperLimit ");
			return false;
		}
		try
		{
			RunSingleTest(text);
			Thread.Sleep(200);
			GetResultsFile(text);
			double result3 = -999.0;
			if (!double.TryParse(ResultFromResultsFile(text, "value"), out result3))
			{
				WriteLogMessage("Failed to find value in result file");
				return false;
			}
			bool flag = false;
			if (result3 >= result && result3 <= result2)
			{
				WriteLogMessage($"Prx value within limit {result} <= {result3} <= {result2}");
				flag = true;
			}
			else
			{
				WriteLogMessage("Prx value out of limit");
				flag = false;
			}
			WriteLines(text, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(text + ex.Message);
			return false;
		}
	}

	public bool PSENSOR_FAR()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		name = ((MMI_MODE != MMIMODE.QMMI) ? "PSENSOR" : "PROXIMITY_SENSOR");
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "0";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("prx_value_lowerLimit"), out var result))
		{
			WriteLogMessage("Failed to find prx_value_lowerLimit ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("prx_value_upperLimit"), out var result2))
		{
			WriteLogMessage("Failed to find prx_value_upperLimit ");
			return false;
		}
		try
		{
			double result3 = -999.0;
			ushort.TryParse(text, out var result4);
			run_test_get_result(name, "value", result4, out var result_string, 0);
			double.TryParse(result_string, out result3);
			bool flag = false;
			if (result3 >= result && result3 <= result2)
			{
				WriteLogMessage($"Prx value within limit {result} <= {result3} <= {result2}");
				flag = true;
			}
			else
			{
				WriteLogMessage("prx value out of limit");
				flag = false;
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool PSENSOR_PHONE()
	{
		WriteLogMessage("Deprecated, use PROXIMITY_SENSOR_PHONE instead.");
		return false;
	}

	public bool PROXIMITY_SENSOR_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		name = ((MMI_MODE != MMIMODE.QMMI) ? "PSENSOR" : "PROXIMITY_SENSOR");
		if (!CheckFixtureExist())
		{
			return false;
		}
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		ushort.TryParse(text, out var result);
		bool flag = false;
		double result2 = -1.0;
		double result3 = -1.0;
		bool flag2 = false;
		try
		{
			int Delta_x = 0;
			int Delta_y = 0;
			int Delta_z = 0;
			int Delta_z2 = 0;
			string text2 = "";
			if (!getDelta_to_target_POS("PROXSENSE", ref Delta_x, ref Delta_y, ref Delta_z, ref Delta_z2, ref text2))
			{
				WriteLogMessage("failed to get getDelta_to_target_POS");
			}
			string result_string;
			if (Math.Abs(Delta_x) <= 2000 || Math.Abs(Delta_y) <= 1000)
			{
				if (Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_z) >= 20)
				{
					xyTableInstance.Retract_MoveTo(xyLOCATE.PROXSENSE.ToString(), useOffset: true);
					run_test_get_result(name, "value", result, out result_string, 0, 1);
					double.TryParse(result_string, out result3);
					flag2 = true;
				}
			}
			else
			{
				run_test_get_result(name, "value", result, out result_string, 0, 1);
				double.TryParse(result_string, out result3);
				flag2 = true;
			}
			if (Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_y) >= 20 || Math.Abs(Delta_z) >= 20)
			{
				xyTableInstance.Retract_MoveTo_touch(xyLOCATE.PROXSENSE.ToString());
			}
			else
			{
				xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.LIGHTSENSE.ToString(), enablePartialRetract: true);
			}
			Thread.Sleep(wait_table_move_s * 1000);
			run_test_get_result(name, "value", result, out result_string, 1000);
			double.TryParse(result_string, out result2);
			if (!flag2)
			{
				xyTableInstance.Retract_MoveTo(xyLOCATE.PROXSENSE.ToString(), useOffset: true);
				run_test_get_result(name, "value", result, out result_string, 0, 1);
				double.TryParse(result_string, out result3);
				flag2 = true;
			}
			if (d_Delta_Value < Math.Abs(result3 - result2))
			{
				WriteLogMessage($"Delta Value within limit {d_Delta_Value} <= {result3} - {result2}");
				flag = true;
			}
			else
			{
				WriteLogMessage($"Delta Value out of limit {d_Delta_Value} > {result3} - {result2}");
				flag = false;
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			WriteLogMessage("xy Table message: " + xyTableInstance.msg);
			xyTableInstance.zRetract_partial(DUT_zone: true);
			return false;
		}
		finally
		{
			ZRetractAll();
		}
	}

	public bool PRESSURE_SENSOR()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string readVal = "";
		double temperature = 0.0;
		double pressure = 0.0;
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		fixtureInstance.ReadPressureSensor_BMP285(out readVal, out temperature, out pressure);
		throw new NotSupportedException();
	}

	public bool HUMIDITY_SENSOR()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string readVal = "";
		double percentH = 0.0;
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		fixtureInstance.ReadHumiditySensor_SHTW2(out readVal, out percentH);
		throw new NotSupportedException();
	}

	public bool TEMPERATURE_SENSOR()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string readVal = "";
		double TCelcius = 0.0;
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		fixtureInstance.ReadTemperatureSensor_SHTW2(out readVal, out TCelcius);
		throw new NotSupportedException();
	}

	public bool SDCARD()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			bool flag = false;
			if (ResultFromResultsFile(name))
			{
				if (!Check_Capacity)
				{
					return true;
				}
				double result = -999.0;
				string text = ResultFromResultsFile(name, "sdcard_capacity");
				text = text.Replace("k", "");
				text = text.Replace("g", "");
				text = text.Replace("m", "");
				text = text.Replace("b", "");
				text = text.Replace("K", "");
				text = text.Replace("G", "");
				text = text.Replace("M", "");
				text = text.Replace("B", "");
				text = text.Replace(" ", "");
				text = text.Replace("\r", "");
				text = text.Replace("\n", "");
				if (!double.TryParse(text, out result))
				{
					WriteLogMessage("Failed to find sdcard_capacity in result file");
					WriteLogMessage("Or the output string is not standard: " + text);
					return false;
				}
				if (result >= sdcard_capacity_LL && result <= sdcard_capacity_UL)
				{
					WriteLogMessage($"SDCARD - Value within limit {sdcard_capacity_LL} <= {result} <= {sdcard_capacity_UL}");
					flag = true;
				}
				else
				{
					WriteLogMessage("SDCARD value out of limit");
					flag = false;
				}
			}
			else
			{
				flag = false;
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool SIMCARD1()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool SIMCARD2()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool WIFI()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (TEST_WIFI)
		{
			WriteLogMessage("\r\n WIFI configured as run background in BACKGROUND_TEST node");
			return false;
		}
		MMI_testName = "WIFI";
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(MMI_testName);
			Thread.Sleep(3000);
			GetResultsFile(MMI_testName);
			if (MMI_MODE == MMIMODE.QMMI)
			{
				string details = "";
				ResultFromResultsFile(name);
				ResultDetailsForTestCase_Xml(name, "", out details);
			}
			WriteLines(name, bStart: false);
			return GetResult_WIFI(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	private bool GetResult_WIFI(string MMI_testName)
	{
		try
		{
			bool result = ResultFromResultsFile(MMI_testName);
			if (WIFI_TEST_TYPE == 0)
			{
				return result;
			}
			if (string.IsNullOrEmpty(WIFI_AP_NAME))
			{
				WriteLogMessage("\r\n Not configured WIFI_AP_NAME");
				return false;
			}
			if (MMI_MODE == MMIMODE.FFBM)
			{
				string[] array = Result_List_FromResultsFile(MMI_testName, "AP");
				if (1 == WIFI_TEST_TYPE)
				{
					return array.Contains(WIFI_AP_NAME);
				}
				double value_from_Result_string_List = MMI_INI_FileManager.GetValue_from_Result_string_List(array, "ESSID", WIFI_AP_NAME, "Signal level");
				if (WIFI_RSSI_LL > value_from_Result_string_List)
				{
					WriteLogMessage($"\r\n {MMI_testName} Signal level check failed: WIFI_RSSI_LL {WIFI_RSSI_LL} > {value_from_Result_string_List}");
					return false;
				}
				WriteLogMessage($"\r\n {MMI_testName} Signal level check pass...");
				return true;
			}
			string details = "";
			double result2 = 0.0;
			if (ResultDetailsForTestCase_Xml(MMI_testName, WIFI_AP_NAME, out details))
			{
				WriteLogMessage($"\r\n {WIFI_AP_NAME} : {details}");
				if (!string.IsNullOrEmpty(details))
				{
					if (1 == WIFI_TEST_TYPE)
					{
						return true;
					}
					string[] array2 = details.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
					if (array2.Length > 0)
					{
						string[] array3 = array2;
						foreach (string text in array3)
						{
							if (text.Contains("Signal level:") && double.TryParse(text.Replace("Signal level:", ""), out result2))
							{
								if (WIFI_RSSI_LL > result2)
								{
									WriteLogMessage($"\r\n {MMI_testName} Signal level check failed: WIFI_RSSI_LL {WIFI_RSSI_LL} > {result2}");
									return false;
								}
								WriteLogMessage($"\r\n {MMI_testName} Signal level check pass...");
								return true;
							}
						}
					}
				}
			}
			WriteLogMessage($"\r\n {MMI_testName} not found Signal level data.");
			return false;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	public bool WIFI_AP()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		MMI_testName = "WIFI_AP";
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		string text2 = "false";
		try
		{
			text2 = FindParameterValueFromSectionWithName("Use_SN_As_SSID");
		}
		catch (Exception)
		{
			text2 = "false";
		}
		string text3 = "false";
		try
		{
			text3 = FindParameterValueFromSectionWithName("enableRSSI");
		}
		catch (Exception)
		{
			text3 = "false";
		}
		string text4 = "";
		try
		{
			text4 = FindParameterValueFromSectionWithName("SSID");
		}
		catch (Exception)
		{
			text4 = "";
		}
		double result = 999.0;
		if (text3.ToUpper().Trim() == "TRUE" && !double.TryParse(FindParameterValueFromSectionWithName("Signal_Level_Lower_Limit"), out result))
		{
			WriteLogMessage("Failed to find Signal_Level_Lower_Limit ");
			return false;
		}
		try
		{
			WriteLogMessage("Make sure PC with wireless and NetCable not connect to start the test.");
			if (text2.ToUpper().Trim() == "TRUE")
			{
				WriteLogMessage("Not support use SN as SSID yet.");
			}
			RunSingleTestWithWait(MMI_testName, ushort.Parse(text));
			Thread.Sleep(5000);
			GetResultsFile(MMI_testName);
			if (!ResultFromResultsFile(MMI_testName))
			{
				return false;
			}
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			int num = int.Parse(text);
			bool flag = false;
			num = 3 * num;
			while (num-- > 0)
			{
				dictionary.Clear();
				dictionary = WifiScan_SSID_VS_RSSI();
				if (dictionary.Count != 0)
				{
					if (dictionary.Keys.Contains(text4))
					{
						flag = true;
						break;
					}
					Thread.Sleep(300);
				}
			}
			if (!flag)
			{
				WriteLogMessage("Failed to scan SSID:" + text4);
				return false;
			}
			WriteLogMessage("Found SSID:" + text4 + " RSSI:" + dictionary[text4]);
			if (text3.ToUpper().Trim() == "TRUE")
			{
				if (result > (double)dictionary[text4])
				{
					WriteLogMessage("RSSI out of limit:" + result);
					return false;
				}
				WriteLogMessage("Check limit pass with low limit RSSI:" + result);
			}
			WriteLines(name, bStart: false);
			return true;
		}
		catch (Exception ex4)
		{
			WriteLogMessage(name + ex4.Message);
			return false;
		}
	}

	public bool FM()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool BLUETOOTH()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (TEST_BLUETOOTH)
		{
			WriteLogMessage("\r\n BLUETOOTH configured as run background in BACKGROUND_TEST node");
			return false;
		}
		MMI_testName = "BLUETOOTH";
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(MMI_testName);
			Thread.Sleep(3000);
			GetResultsFile(MMI_testName);
			if (MMI_MODE == MMIMODE.QMMI)
			{
				string details = "";
				ResultFromResultsFile(name);
				ResultDetailsForTestCase_Xml(name, "", out details);
			}
			WriteLines(name, bStart: false);
			return GetResult_BLUETOOTH(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	private bool GetResult_BLUETOOTH(string MMI_testName)
	{
		try
		{
			double num = 999.0;
			if (2 == BLUETOOTH_TEST_TYPE)
			{
				num = BLUETOOTH_RSSI_LL;
			}
			bool result = ResultFromResultsFile(MMI_testName);
			if (BLUETOOTH_TEST_TYPE == 0)
			{
				return result;
			}
			if (string.IsNullOrEmpty(BLUETOOTH_AP_NAME))
			{
				WriteLogMessage("\r\n Not configured BLUETOOTH_AP_NAME");
				return false;
			}
			if (MMI_MODE == MMIMODE.FFBM)
			{
				string[] array = Result_List_FromResultsFile(MMI_testName, "AP");
				if (1 == BLUETOOTH_TEST_TYPE)
				{
					return array.Contains(BLUETOOTH_AP_NAME);
				}
				double value_from_Result_string_List = MMI_INI_FileManager.GetValue_from_Result_string_List(array, "Device name", BLUETOOTH_AP_NAME, "RSSI");
				if (num > value_from_Result_string_List)
				{
					WriteLogMessage($"\r\n {MMI_testName} Test failed RSSI= {value_from_Result_string_List} < RSSI_LL={num} for AP={BLUETOOTH_AP_NAME}");
					return false;
				}
				WriteLogMessage($"\r\n {MMI_testName} Signal level check pass...");
				return true;
			}
			string details = "";
			double result2 = 0.0;
			if (ResultDetailsForTestCase_Xml(MMI_testName, BLUETOOTH_AP_NAME, out details) && !string.IsNullOrEmpty(details))
			{
				if (1 == BLUETOOTH_TEST_TYPE)
				{
					return true;
				}
				string[] array2 = details.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
				if (array2.Length > 0)
				{
					string[] array3 = array2;
					foreach (string text in array3)
					{
						if (text.Contains("Signal level:") && double.TryParse(text.Replace("Signal level:", ""), out result2))
						{
							if (num > result2)
							{
								WriteLogMessage($"\r\n {MMI_testName} Signal level check failed: BT_RSSI_LL {num} > {result2}");
								return false;
							}
							WriteLogMessage($"\r\n {MMI_testName} Signal level check pass...");
							return true;
						}
					}
				}
			}
			WriteLogMessage($"\r\n {MMI_testName} not found Signal level data.");
			return false;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	public bool GPS()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (TEST_GPS)
		{
			WriteLogMessage("\r\n GPS configured as run background in BACKGROUND_TEST node");
			return false;
		}
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			Thread.Sleep(5000);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool NFC()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool TELEPHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(MMI_testName);
			GetResultsFile(MMI_testName);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool TELEPHONE_SIMCARD1()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(MMI_testName);
			GetResultsFile(MMI_testName);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool TELEPHONE_SIMCARD2()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(MMI_testName);
			GetResultsFile(MMI_testName);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool BACKGROUND_TEST()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			if (TEST_WIFI)
			{
				RunSingleTest("WIFI");
			}
			if (TEST_BLUETOOTH)
			{
				RunSingleTest("BLUETOOTH");
			}
			if (TEST_GPS)
			{
				RunSingleTest("GPS");
				Thread.Sleep(50);
			}
			WriteLines(name, bStart: false);
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool BACKGROUND_TEST_RESULT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = true;
		try
		{
			GetResultsFile();
			bool flag2 = false;
			string text = "fail";
			if (TEST_WIFI)
			{
				flag2 = GetResult_WIFI("WIFI");
				text = (flag2 ? "pass" : "fail");
				WriteLogMessage("WIFI test - " + text);
				flag = flag && flag2;
			}
			if (TEST_BLUETOOTH)
			{
				flag2 = GetResult_BLUETOOTH("BLUETOOTH");
				text = (flag2 ? "pass" : "fail");
				WriteLogMessage("BLUETOOTH test - " + text);
				flag = flag && flag2;
			}
			if (TEST_GPS)
			{
				flag2 = ResultFromResultsFile("GPS");
				text = (flag2 ? "pass" : "fail");
				WriteLogMessage("GPS test - " + text);
				flag = flag && flag2;
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool WIGIG()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (TEST_WIGIG)
		{
			WriteLogMessage("\r\n WIGIG configured as run background in BACKGROUND_TEST node");
			return false;
		}
		MMI_testName = "WIGIG";
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(MMI_testName);
			Thread.Sleep(3000);
			GetResultsFile(MMI_testName);
			if (MMI_MODE == MMIMODE.QMMI)
			{
				string details = "";
				ResultFromResultsFile(name);
				ResultDetailsForTestCase_Xml(name, "", out details);
			}
			WriteLines(name, bStart: false);
			return GetResult_WIGIG(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	private bool GetResult_WIGIG(string MMI_testName)
	{
		try
		{
			bool result = ResultFromResultsFile(MMI_testName);
			if (WIGIG_TEST_TYPE == 0)
			{
				return result;
			}
			if (string.IsNullOrEmpty(WIGIG_AP_NAME))
			{
				WriteLogMessage("\r\n Not configured WIGIG_AP_NAME");
				return false;
			}
			string details = "";
			double result2 = 0.0;
			if (ResultDetailsForTestCase_Xml(MMI_testName, WIGIG_AP_NAME, out details) && !string.IsNullOrEmpty(details))
			{
				if (1 == WIGIG_TEST_TYPE)
				{
					return true;
				}
				string[] array = details.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length > 0)
				{
					string[] array2 = array;
					foreach (string text in array2)
					{
						if (text.Contains("Level:") && double.TryParse(text.Replace("Level:", ""), out result2))
						{
							if (WIGIG_LEVEL_LL > result2)
							{
								WriteLogMessage($"\r\n {MMI_testName} Signal level check failed: WIGIG_LEVEL_LL {WIGIG_LEVEL_LL} > {result2}");
								return false;
							}
							WriteLogMessage($"\r\n {MMI_testName} Signal level check pass...");
							return true;
						}
					}
				}
			}
			WriteLogMessage($"\r\n {MMI_testName} not found Signal level data.");
			return false;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	public bool AUDIO_PLAYTONE_SPEAKER()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string methodName = (string.IsNullOrEmpty(CASE_NAME) ? "AUDIO_PLAYTONE_SPEAKER" : CASE_NAME);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_FF_SPKR_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			RunSingleTestWithWait(methodName, 0);
			for (int i = 0; i < 20; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					break;
				}
			}
			Thread.Sleep(1000);
			WriteLines(name, bStart: false);
			return setBit == USB_IO_Expander.SetValue.LOW;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_HEADSET()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string caseName = (string.IsNullOrEmpty(CASE_NAME) ? "AUDIO_LOOPBACK_HEADSET" : CASE_NAME);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC2_OUT);
			bool IO_OUT = true;
			bool result = true;
			bool flag = true;
			int num = 2;
			SetAudioLoopbackHeadset(caseName, IO_OUT, out var setBit, out result);
			if (!result)
			{
				for (int i = 0; i < num; i++)
				{
					if (result)
					{
						break;
					}
					WriteLogMessage("Failed to detect tone at RIGHT HS..trying again");
					Thread.Sleep(8000);
					SetAudioLoopbackHeadset(caseName, IO_OUT, out setBit, out result);
				}
			}
			flag = flag && result;
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_L_OUT);
			result = false;
			for (int j = 0; j < 40; j++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					WriteLogMessage("TONE detected at LEFT HS SPEAKER");
					result = true;
					break;
				}
			}
			if (!result)
			{
				WriteLogMessage("Failed to detect tone at LEFT HS");
			}
			flag = flag && result;
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_MIC1_EARPIECE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string methodName = (string.IsNullOrEmpty(CASE_NAME) ? "AUDIO_LOOPBACK_MIC1_EARPIECE" : CASE_NAME);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC1_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_SPKR1);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_EAR_OUT);
			RunSingleTestWithWait(methodName, 0);
			bool flag = false;
			bool flag2 = true;
			for (int i = 0; i < 40; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					flag = true;
					WriteLogMessage("TONE detected at EARPIECE");
					break;
				}
			}
			if (!flag)
			{
				WriteLogMessage("Failed to detect tone at EARPIECE");
			}
			flag2 = flag2 && flag;
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			WriteLines(name, bStart: false);
			return flag2;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_SPEAKER_EX_HEADSET_MIC_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (!string.IsNullOrEmpty(CASE_NAME))
		{
			_ = CASE_NAME;
		}
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			bool flag = false;
			bool flag2 = false;
			for (int num = 2; num > 0; num--)
			{
				fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_TST_MIC2_IN);
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
				fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC2_OUT);
				RunSingleTestWithWait(MMI_testName, 0);
				Thread.Sleep(Test_Delay_GetResult_S * 1000);
				GetResultsFile();
				if (ResultFromResultsFile(MMI_testName))
				{
					break;
				}
			}
			if (value_check)
			{
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_LL"), out var result))
				{
					WriteLogMessage("Failed to find Freq_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_UL"), out var result2))
				{
					WriteLogMessage("Failed to find Freq_value_UL");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_LL"), out var result3))
				{
					WriteLogMessage("Failed to find Level_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_UL"), out var result4))
				{
					WriteLogMessage("Failed to find Level_value_UL ");
					return false;
				}
				double result5 = -999.0;
				double result6 = -999.0;
				string text = ResultFromResultsFile(MMI_testName, "Cap");
				if (text == "NOT FOUND")
				{
					WriteLogMessage("FREQ VALUE (Cap) NOT FOUND in result file");
				}
				text = text.Replace("K", "");
				text = text.Replace("B", "");
				text = text.Replace("Hz", "");
				string text2 = ResultFromResultsFile(MMI_testName, "Power");
				if (text == "NOT FOUND")
				{
					WriteLogMessage("LEVEL VALUE (Power) NOT FOUND in result file");
					return false;
				}
				text2 = text2.Replace("d", "");
				text2 = text2.Replace("B", "");
				text2 = text2.Replace("F", "");
				text2 = text2.Replace("S", "");
				text2 = text2.Replace("m", "");
				if (!double.TryParse(text, out result5))
				{
					WriteLogMessage("Failed to find Freq_value in result file");
					return false;
				}
				if (!double.TryParse(text2, out result6))
				{
					WriteLogMessage("Failed to find Level_value in result file");
					return false;
				}
				if (result5 >= result && result5 <= result2)
				{
					WriteLogMessage($"Freq_value within limit {result} <= {result5} <= {result2}");
					flag = true;
				}
				else
				{
					WriteLogMessage("Freq_Value out of limit");
					flag = false;
				}
				flag2 = flag;
				flag = false;
				if (result6 >= result3 && result6 <= result4)
				{
					WriteLogMessage($"Level_value within limit {result3} <= {result6} <= {result4}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Level_Value out of limit");
					flag = false;
				}
				flag2 = flag2 && flag;
				if (!flag2)
				{
					WriteLogMessage("Failed Limit check");
				}
				if (!flag2)
				{
					WriteLogMessage($"\r\n Test Failed -- {name}");
				}
				WriteLines(name, bStart: false);
				return flag2;
			}
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_EARPIECE_EX_HEADSET_MIC_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (!CheckFixtureExist())
		{
			return false;
		}
		MMI_testName = (string.IsNullOrEmpty(CASE_NAME) ? "AUDIO_LOOPBACK_EARPIECE_EX_HEADSET_MIC" : CASE_NAME);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			bool flag = false;
			bool flag2 = false;
			for (int num = 2; num > 0; num--)
			{
				int Delta_x = 0;
				int Delta_y = 0;
				int Delta_z = 0;
				int Delta_z2 = 0;
				string text = "";
				if (!getDelta_to_target_POS("LIGHTSENSE", ref Delta_x, ref Delta_y, ref Delta_z, ref Delta_z2, ref text))
				{
					WriteLogMessage("failed to get getDelta_to_target_POS");
				}
				if (Math.Abs(Delta_x) >= 20 || Math.Abs(Delta_y) >= 20 || Math.Abs(Delta_z) >= 20)
				{
					xyTableInstance.zMoveToAndPress_partialRetract(xyLOCATE.LIGHTSENSE.ToString(), enablePartialRetract: true);
				}
				fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_TST_MIC1_IN);
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
				fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC2_OUT);
				RunSingleTestWithWait(MMI_testName, 0);
				Thread.Sleep(Test_Delay_GetResult_S * 1000);
				GetResultsFile();
				if (ResultFromResultsFile(MMI_testName))
				{
					break;
				}
			}
			if (value_check)
			{
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_LL"), out var result))
				{
					WriteLogMessage("Failed to find Freq_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_UL"), out var result2))
				{
					WriteLogMessage("Failed to find Freq_value_UL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_LL"), out var result3))
				{
					WriteLogMessage("Failed to find Level_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_UL"), out var result4))
				{
					WriteLogMessage("Failed to find Level_value_UL ");
					return false;
				}
				double result5 = -999.0;
				double result6 = -999.0;
				string text2 = ResultFromResultsFile(MMI_testName, "Cap");
				if (text2 == "NOT FOUND")
				{
					WriteLogMessage("FREQ VALUE (Cap) NOT FOUND in result file");
				}
				text2 = text2.Replace("K", "");
				text2 = text2.Replace("B", "");
				text2 = text2.Replace("Hz", "");
				string text3 = ResultFromResultsFile(MMI_testName, "Power");
				if (text2 == "NOT FOUND")
				{
					WriteLogMessage("LEVEL VALUE (Power) NOT FOUND in result file");
					return false;
				}
				text3 = text3.Replace("d", "");
				text3 = text3.Replace("B", "");
				text3 = text3.Replace("F", "");
				text3 = text3.Replace("S", "");
				text3 = text3.Replace("m", "");
				if (!double.TryParse(text2, out result5))
				{
					WriteLogMessage("Failed to find Freq_value in result file");
					return false;
				}
				if (!double.TryParse(text3, out result6))
				{
					WriteLogMessage("Failed to find Level_value in result file");
					return false;
				}
				if (result5 >= result && result5 <= result2)
				{
					WriteLogMessage($"Freq_value within limit {result} <= {result5} <= {result2}");
					flag = true;
				}
				else
				{
					WriteLogMessage("Freq_Value out of limit");
					flag = false;
				}
				flag2 = flag;
				flag = false;
				if (result6 >= result3 && result6 <= result4)
				{
					WriteLogMessage($"Level_value within limit {result3} <= {result6} <= {result4}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Level_Value out of limit");
					flag = false;
				}
				flag2 = flag2 && flag;
				if (!flag2)
				{
					WriteLogMessage("Failed limit check");
				}
				if (!flag2)
				{
					WriteLogMessage($"\r\n Test Failed -- {name}");
				}
				WriteLines(name, bStart: false);
				return flag2;
			}
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_HEADSET_EX_MIC2_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		MMI_testName = (string.IsNullOrEmpty(CASE_NAME) ? "AUDIO_LOOPBACK_HEADSET_EX_MIC2" : CASE_NAME);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			bool flag = false;
			bool flag2 = false;
			for (int num = 2; num > 0; num--)
			{
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setValue = USB_IO_Expander.SetValue.LOW;
				if (fixtureIsRevB && fixtureInstance.Set_Audio_CC1_CC2())
				{
					if (!fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Control.USB2_CTRL, USB_IO_Expander.SetValue.LOW))
					{
						return false;
					}
					if (!fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Control.USB2_AUDIO_SEL, USB_IO_Expander.SetValue.LOW))
					{
						return false;
					}
					fixtureInstance.Enable_USB2_DPDM_Audio_Paths();
					fixtureInstance.Set_HeadSet_Audio_Paths();
					fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Control.USBC_HPH_SELECT, USB_IO_Expander.SetValue.HIGH);
				}
				setValue = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_L_OUT);
				setValue = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setValue, ref IO_OUT);
				setValue = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setValue, ref IO_OUT);
				fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_SPKR2);
				if (fixtureIsRevB)
				{
					fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.POWER_OFF_DUT);
					return true;
				}
				RunSingleTestWithWait(MMI_testName, 0);
				Thread.Sleep(Test_Delay_GetResult_S * 1000);
				GetResultsFile();
				if (ResultFromResultsFile(MMI_testName))
				{
					break;
				}
			}
			if (value_check)
			{
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_LL"), out var result))
				{
					WriteLogMessage("Failed to find Freq_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_UL"), out var result2))
				{
					WriteLogMessage("Failed to find Freq_value_UL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_LL"), out var result3))
				{
					WriteLogMessage("Failed to find Level_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_UL"), out var result4))
				{
					WriteLogMessage("Failed to find Level_value_UL ");
					return false;
				}
				double result5 = -999.0;
				double result6 = -999.0;
				string text = ResultFromResultsFile(MMI_testName, "Cap");
				if (text == "NOT FOUND")
				{
					WriteLogMessage("FREQ VALUE (Cap) NOT FOUND in result file");
				}
				text = text.Replace("K", "");
				text = text.Replace("B", "");
				text = text.Replace("Hz", "");
				string text2 = ResultFromResultsFile(MMI_testName, "Power");
				if (text == "NOT FOUND")
				{
					WriteLogMessage("LEVEL VALUE (Power) NOT FOUND in result file");
					return false;
				}
				text2 = text2.Replace("d", "");
				text2 = text2.Replace("B", "");
				text2 = text2.Replace("F", "");
				text2 = text2.Replace("S", "");
				text2 = text2.Replace("m", "");
				if (!double.TryParse(text, out result5))
				{
					WriteLogMessage("Failed to find Freq_value in result file");
					return false;
				}
				if (!double.TryParse(text2, out result6))
				{
					WriteLogMessage("Failed to find Level_value in result file");
					return false;
				}
				if (result5 >= result && result5 <= result2)
				{
					WriteLogMessage($"Freq_value within limit {result} <= {result5} <= {result2}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Freq_Value out of limit");
					flag = false;
				}
				flag2 = flag;
				flag = false;
				if (result6 >= result3 && result6 <= result4)
				{
					WriteLogMessage($"Level_value within limit {result3} <= {result6} <= {result4}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Level_Value out of limit");
					flag = false;
				}
				flag2 = flag2 && flag;
				if (!flag2)
				{
					WriteLogMessage("Failed Limit check");
				}
				if (!flag2)
				{
					WriteLogMessage($"\r\n Test Failed -- {name}");
				}
				WriteLines(name, bStart: false);
				return flag2;
			}
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_HEADSET_EX_MIC1_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		MMI_testName = (string.IsNullOrEmpty(CASE_NAME) ? "AUDIO_LOOPBACK_HEADSET_EX_MIC1" : CASE_NAME);
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		try
		{
			bool flag = false;
			bool flag2 = false;
			for (int num = 2; num > 0; num--)
			{
				fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_L_OUT);
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
				setBit = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
				fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_SPKR2);
				ushort result = 0;
				ushort.TryParse(text, out result);
				RunSingleTestWithWait(MMI_testName, result);
				Thread.Sleep(Test_Delay_GetResult_S * 1000);
				GetResultsFile();
				if (ResultFromResultsFile(MMI_testName))
				{
					break;
				}
			}
			if (value_check)
			{
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_LL"), out var result2))
				{
					WriteLogMessage("Failed to find Freq_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_UL"), out var result3))
				{
					WriteLogMessage("Failed to find Freq_value_UL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_LL"), out var result4))
				{
					WriteLogMessage("Failed to find Level_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_UL"), out var result5))
				{
					WriteLogMessage("Failed to find Level_value_UL ");
					return false;
				}
				double result6 = -999.0;
				double result7 = -999.0;
				string text2 = ResultFromResultsFile(MMI_testName, "Cap");
				if (text2 == "NOT FOUND")
				{
					WriteLogMessage("FREQ VALUE (Cap) NOT FOUND in result file");
				}
				text2 = text2.Replace("K", "");
				text2 = text2.Replace("B", "");
				text2 = text2.Replace("Hz", "");
				string text3 = ResultFromResultsFile(MMI_testName, "Power");
				if (text2 == "NOT FOUND")
				{
					WriteLogMessage("LEVEL VALUE (Power) NOT FOUND in result file");
					return false;
				}
				text3 = text3.Replace("d", "");
				text3 = text3.Replace("B", "");
				text3 = text3.Replace("F", "");
				text3 = text3.Replace("S", "");
				text3 = text3.Replace("m", "");
				if (!double.TryParse(text2, out result6))
				{
					WriteLogMessage("Failed to find Freq_value in result file");
					return false;
				}
				if (!double.TryParse(text3, out result7))
				{
					WriteLogMessage("Failed to find Level_value in result file");
					return false;
				}
				if (result6 >= result2 && result6 <= result3)
				{
					WriteLogMessage($"Freq_value within limit {result2} <= {result6} <= {result3}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Freq_Value out of limit");
					flag = false;
				}
				flag2 = flag;
				flag = false;
				if (result7 >= result4 && result7 <= result5)
				{
					WriteLogMessage($"Level_value within limit {result4} <= {result7} <= {result5}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Level_Value out of limit");
					flag = false;
				}
				flag2 = flag2 && flag;
				if (!flag2)
				{
					WriteLogMessage("Failed Limit check");
				}
				if (!flag2)
				{
					WriteLogMessage($"\r\n Test Failed -- {name}");
				}
				WriteLines(name, bStart: false);
				return flag2;
			}
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool HEADSET_R_OUT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_R_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			RunSingleTestWithWait("AUDIO_PLAYTONE_HEADSET", 0);
			for (int i = 0; i < 30; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					break;
				}
			}
			Thread.Sleep(1000);
			WriteLines(name, bStart: false);
			if (setBit == USB_IO_Expander.SetValue.LOW)
			{
				return true;
			}
			return false;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool HEADSET_L_OUT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(1000, USB_IO_Expander.MUX_Control.RLY_HPH_L_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			RunSingleTestWithWait("AUDIO_PLAYTONE_HEADSET", 0);
			for (int i = 0; i < 20; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					break;
				}
			}
			Thread.Sleep(1000);
			WriteLines(name, bStart: false);
			return setBit == USB_IO_Expander.SetValue.LOW;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool EAR_PIECE_OUT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_EAR_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			RunSingleTestWithWait("AUDIO_PLAYTONE_EARPIECE", 0);
			for (int i = 0; i < 20; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					break;
				}
			}
			Thread.Sleep(1000);
			WriteLines(name, bStart: false);
			if (setBit == USB_IO_Expander.SetValue.LOW)
			{
				return true;
			}
			return false;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_SPEAKER_PLAYTONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_FF_SPKR_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			RunSingleTestWithWait(name, 0);
			for (int i = 0; i < 20; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					break;
				}
			}
			Thread.Sleep(1000);
			WriteLines(name, bStart: false);
			return setBit == USB_IO_Expander.SetValue.LOW;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_PLAYTONE_SPEAKER_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_TST_MIC2_IN);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			RunSingleTestWithWait("AUDIO_PLAYTONE_SPEAKER", 0);
			for (int i = 0; i < 20; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					break;
				}
			}
			Thread.Sleep(1000);
			WriteLines(name, bStart: false);
			return setBit == USB_IO_Expander.SetValue.LOW;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool HEADSET_MIC()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC2_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			setBit = USB_IO_Expander.SetValue.HIGH;
			RunSingleTestWithWait("AUDIO_HEADSET_MIC", 10);
			Thread.Sleep(2000);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_R_OUT);
			Thread.Sleep(200);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_R_OUT);
			Thread.Sleep(200);
			RunSingleTestWithWait("AUDIO_PLAYFILE_HEADSET", 0);
			for (int i = 0; i < 20; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					break;
				}
			}
			Thread.Sleep(1000);
			WriteLines(name, bStart: false);
			return setBit == USB_IO_Expander.SetValue.LOW;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_EX_LOOPBACK_HEADSET()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "10";
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_LL"), out var result))
		{
			WriteLogMessage("Failed to find Freq_value_LL ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_UL"), out var result2))
		{
			WriteLogMessage("Failed to find Freq_value_UL ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_LL"), out var result3))
		{
			WriteLogMessage("Failed to find Level_value_LL ");
			return false;
		}
		if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_UL"), out var result4))
		{
			WriteLogMessage("Failed to find Level_value_UL ");
			return false;
		}
		try
		{
			bool flag = false;
			bool flag2 = false;
			USB_IO_Expander.MUX_Control audioExLoopbackHeadset = USB_IO_Expander.MUX_Control.RLY_HPH_R_OUT;
			if (!SetAudioExLoopbackHeadset(audioExLoopbackHeadset))
			{
				return false;
			}
			GetResultsFile();
			double result5 = -999.0;
			double result6 = -999.0;
			string text = ResultFromResultsFile(name, "FREQ VALUE");
			if (text == "NOT FOUND")
			{
				WriteLogMessage("FREQ VALUE NOT FOUND in result file");
			}
			text = text.Replace("K", "");
			text = text.Replace("B", "");
			text = text.Replace("Hz", "");
			string text2 = ResultFromResultsFile(name, "LEVEL VALUE");
			if (text == "NOT FOUND")
			{
				WriteLogMessage("FREQ VALUE NOT FOUND in result file");
				return false;
			}
			text2 = text2.Replace("d", "");
			text2 = text2.Replace("B", "");
			text2 = text2.Replace("m", "");
			if (!double.TryParse(text, out result5))
			{
				WriteLogMessage("Failed to find Freq_value in result file");
				return false;
			}
			if (!double.TryParse(text2, out result6))
			{
				WriteLogMessage("Failed to find Level_value in result file");
				return false;
			}
			if (result5 >= result && result5 <= result2)
			{
				WriteLogMessage($"HS RIGHT Freq_value within limit {result} <= {result5} <= {result2}");
				flag = true;
			}
			else
			{
				WriteLogMessage(" Freq_Value out of limit");
				flag = false;
			}
			flag2 = flag;
			flag = false;
			if (result6 >= result3 && result6 <= result4)
			{
				WriteLogMessage($"HS RIGHT Level_value within limit {result3} <= {result6} <= {result4}");
				flag = true;
			}
			else
			{
				WriteLogMessage("Level_Value out of limit");
				flag = false;
			}
			flag2 = flag2 && flag;
			if (!flag2)
			{
				WriteLogMessage("Failed for RIGHT HS");
			}
			bool flag3 = flag2;
			flag = false;
			audioExLoopbackHeadset = USB_IO_Expander.MUX_Control.RLY_HPH_L_OUT;
			if (!SetAudioExLoopbackHeadset(audioExLoopbackHeadset))
			{
				return false;
			}
			GetResultsFile();
			result5 = (result6 = -999.0);
			text = ResultFromResultsFile(name, "FREQ VALUE");
			text = text.Replace("K", "");
			text = text.Replace("B", "");
			text = text.Replace("Hz", "");
			text2 = ResultFromResultsFile(name, "LEVEL VALUE");
			text2 = text2.Replace("d", "");
			text2 = text2.Replace("B", "");
			text2 = text2.Replace("m", "");
			if (!double.TryParse(text, out result5))
			{
				WriteLogMessage("Failed to find Freq_value in result file");
				return false;
			}
			if (!double.TryParse(text2, out result6))
			{
				WriteLogMessage("Failed to find Level_value in result file");
				return false;
			}
			if (result5 >= result && result5 <= result2)
			{
				WriteLogMessage($"HS LEFT Freq_value within limit {result} <= {result5} <= {result2}");
				flag = true;
			}
			else
			{
				WriteLogMessage(" Freq_Value out of limit");
				flag = false;
			}
			flag2 = flag;
			flag = false;
			if (result6 >= result3 && result6 <= result4)
			{
				WriteLogMessage($"HS LEFT Level_value within limit {result3} <= {result6} <= {result4}");
				flag = true;
			}
			else
			{
				WriteLogMessage("HS LEFT Level_Value out of limit");
				flag = false;
			}
			flag2 = flag2 && flag;
			if (!flag2)
			{
				WriteLogMessage("Failed for LEFT HS");
			}
			flag2 = flag2 && flag3;
			if (!flag2)
			{
				WriteLogMessage($"\r\n Test Failed -- {name}");
			}
			WriteLines(name, bStart: false);
			return flag2;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_SPEAKER_EX_MIC2_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		MMI_testName = "AUDIO_LOOPBACK_SPEAKER_EX_MIC2";
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "10";
		}
		try
		{
			bool flag = false;
			bool flag2 = false;
			for (int num = 2; num > 0; num--)
			{
				RunSingleTestWithWait(MMI_testName, 0);
				Thread.Sleep(1000);
				GetResultsFile();
				if (ResultFromResultsFile(MMI_testName))
				{
					break;
				}
			}
			if (value_check)
			{
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_LL"), out var result))
				{
					WriteLogMessage("Failed to find Freq_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_UL"), out var result2))
				{
					WriteLogMessage("Failed to find Freq_value_UL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_LL"), out var result3))
				{
					WriteLogMessage("Failed to find Level_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_UL"), out var result4))
				{
					WriteLogMessage("Failed to find Level_value_UL ");
					return false;
				}
				double result5 = -999.0;
				double result6 = -999.0;
				string text = ResultFromResultsFile(MMI_testName, "Cap");
				if (text == "NOT FOUND")
				{
					WriteLogMessage("FREQ VALUE (Cap) NOT FOUND in result file");
				}
				text = text.Replace("K", "");
				text = text.Replace("B", "");
				text = text.Replace("Hz", "");
				string text2 = ResultFromResultsFile(MMI_testName, "Power");
				if (text == "NOT FOUND")
				{
					WriteLogMessage("LEVEL VALUE (Power) NOT FOUND in result file");
					return false;
				}
				text2 = text2.Replace("d", "");
				text2 = text2.Replace("B", "");
				text2 = text2.Replace("F", "");
				text2 = text2.Replace("S", "");
				text2 = text2.Replace("m", "");
				if (!double.TryParse(text, out result5))
				{
					WriteLogMessage("Failed to find Freq_value in result file");
					return false;
				}
				if (!double.TryParse(text2, out result6))
				{
					WriteLogMessage("Failed to find Level_value in result file");
					return false;
				}
				if (result5 >= result && result5 <= result2)
				{
					WriteLogMessage($"Freq_value within limit {result} <= {result5} <= {result2}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Freq_Value out of limit");
					flag = false;
				}
				flag2 = flag;
				flag = false;
				if (result6 >= result3 && result6 <= result4)
				{
					WriteLogMessage($"Level_value within limit {result3} <= {result6} <= {result4}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Level_Value out of limit");
					flag = false;
				}
				flag2 = flag2 && flag;
				if (!flag2)
				{
					WriteLogMessage("Failed Limit check");
				}
				if (!flag2)
				{
					WriteLogMessage($"\r\n Test Failed -- {name}");
				}
				WriteLines(name, bStart: false);
				return flag2;
			}
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_SPEAKER_PHONE_EX_MIC1()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		MMI_testName = "AUDIO_SPEAKER_PRIMARY_MIC_LOOPBACK";
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "10";
		}
		try
		{
			bool flag = false;
			bool flag2 = false;
			RunSingleTestWithWait(MMI_testName, 0);
			GetResultsFile();
			if (value_check)
			{
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_LL"), out var result))
				{
					WriteLogMessage("Failed to find Freq_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Freq_value_UL"), out var result2))
				{
					WriteLogMessage("Failed to find Freq_value_UL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_LL"), out var result3))
				{
					WriteLogMessage("Failed to find Level_value_LL ");
					return false;
				}
				if (!double.TryParse(FindParameterValueFromSectionWithName("Level_value_UL"), out var result4))
				{
					WriteLogMessage("Failed to find Level_value_UL ");
					return false;
				}
				double result5 = -999.0;
				double result6 = -999.0;
				string text = ResultFromResultsFile(MMI_testName, "FREQ VALUE");
				if (text == "NOT FOUND")
				{
					WriteLogMessage("FREQ VALUE NOT FOUND in result file");
				}
				text = text.Replace("K", "");
				text = text.Replace("B", "");
				text = text.Replace("Hz", "");
				string text2 = ResultFromResultsFile(MMI_testName, "LEVEL VALUE");
				if (text == "NOT FOUND")
				{
					WriteLogMessage("FREQ VALUE NOT FOUND in result file");
					return false;
				}
				text2 = text2.Replace("d", "");
				text2 = text2.Replace("B", "");
				text2 = text2.Replace("m", "");
				if (!double.TryParse(text, out result5))
				{
					WriteLogMessage("Failed to find Freq_value in result file");
					return false;
				}
				if (!double.TryParse(text2, out result6))
				{
					WriteLogMessage("Failed to find Level_value in result file");
					return false;
				}
				if (result5 >= result && result5 <= result2)
				{
					WriteLogMessage($"Freq_value within limit {result} <= {result5} <= {result2}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Freq_Value out of limit");
					flag = false;
				}
				flag2 = flag;
				flag = false;
				if (result6 >= result3 && result6 <= result4)
				{
					WriteLogMessage($"Level_value within limit {result3} <= {result6} <= {result4}");
					flag = true;
				}
				else
				{
					WriteLogMessage(" Level_Value out of limit");
					flag = false;
				}
				flag2 = flag2 && flag;
				if (!flag2)
				{
					WriteLogMessage("Failed Limit check");
				}
				if (!flag2)
				{
					WriteLogMessage($"\r\n Test Failed -- {name}");
				}
				WriteLines(name, bStart: false);
				return flag2;
			}
			return ResultFromResultsFile(MMI_testName);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_MIC1_FF_SPEAKER()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC1_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_SPKR1);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_FF_SPKR_OUT);
			RunSingleTestWithWait("AUDIO_LOOPBACK_MIC1_FF_SPEAKER", 0);
			bool flag = false;
			bool flag2 = true;
			for (int i = 0; i < 40; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					flag = true;
					WriteLogMessage("TONE detected at FF SPEAKER");
					break;
				}
			}
			flag2 = flag2 && flag;
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			WriteLines(name, bStart: false);
			return flag2;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_MIC1_FF_SPEAKER_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC1_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_SPKR1);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_TST_MIC2_IN);
			RunSingleTestWithWait("AUDIO_LOOPBACK_MIC1_FF_SPEAKER", 0);
			bool flag = false;
			bool flag2 = true;
			for (int i = 0; i < 40; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					flag = true;
					WriteLogMessage("TONE detected at FF SPEAKER");
					break;
				}
			}
			flag2 = flag2 && flag;
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			WriteLines(name, bStart: false);
			return flag2;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool AUDIO_LOOPBACK_MIC1_EARPIECE_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			EarpieceTest();
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC1_OUT);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_SPKR1);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_TST_MIC1_IN);
			RunSingleTestWithWait("AUDIO_LOOPBACK_MIC1_EARPIECE", 0);
			bool flag = false;
			bool flag2 = true;
			for (int i = 0; i < 40; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					flag = true;
					WriteLogMessage("TONE detected at EARPIECE");
					break;
				}
			}
			if (!flag)
			{
				WriteLogMessage("Failed to detect tone at EARPIECE");
			}
			flag2 = flag2 && flag;
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			WriteLines(name, bStart: false);
			return flag2;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool INTERNAL_MIC()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_SPKR1);
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			RunSingleTestWithWait("AUDIO_HANDSET_MIC", 10);
			Thread.Sleep(2000);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC1_OUT);
			Thread.Sleep(200);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_L_OUT);
			Thread.Sleep(200);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_R_OUT);
			Thread.Sleep(200);
			RunSingleTestWithWait("AUDIO_PLAYFILE_HEADSET", 0);
			for (int i = 0; i < 20; i++)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(200);
				if (setBit == USB_IO_Expander.SetValue.LOW)
				{
					break;
				}
			}
			Thread.Sleep(1000);
			WriteLines(name, bStart: false);
			bool flag = false;
			if (setBit == USB_IO_Expander.SetValue.LOW)
			{
				WriteLogMessage("TONE detected");
				flag = true;
			}
			else
			{
				WriteLogMessage("TONE not detected");
				flag = false;
			}
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool KEY()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			RunSingleTest("KEY");
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_VOL_DN, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_VOL_DN, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_VOL_UP, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_VOL_UP, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_PWRON, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_PWRON, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			Thread.Sleep((int)(KEY_INTERM_TIME * 1000));
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, "KEY");
			GetResultsFile(name);
			bool result = true;
			WriteLines(name, bStart: false);
			string text = ResultFromResultsFile(name, "power");
			if (!(text.ToUpper() == "DETECTED"))
			{
				WriteLogMessage($"\r\n power {name} not detected");
				result = false;
			}
			text = ResultFromResultsFile(name, "volumedown");
			if (!(text.ToUpper() == "DETECTED"))
			{
				WriteLogMessage($"\r\n volumedown {name} not detected");
				result = false;
			}
			text = ResultFromResultsFile(name, "volumeup");
			if (!(text.ToUpper() == "DETECTED"))
			{
				WriteLogMessage($"\r\n volumeup {name} not detected");
				result = false;
			}
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool KEY_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (!CheckFixtureExist())
		{
			return false;
		}
		MMI_testName = "KEY";
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			bool flag = true;
			RunSingleTestWithWait("KEY", 0);
			AllSideKeyPush(HoldKeyPress: true, HoldBetweenKey: true, 100, 100, HAS_HOMEKEY);
			if (KEY_INTERM_TIME > wait_table_move_s)
			{
				Thread.Sleep((int)(KEY_INTERM_TIME * 1000));
			}
			else
			{
				Thread.Sleep(wait_table_move_s * 1000);
			}
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, "KEY");
			Thread.Sleep(500);
			int millisecondsTimeout = 500;
			for (int i = 0; i < RetryCounts; i++)
			{
				flag = true;
				GetResultsFile(MMI_testName);
				WriteLines(name, bStart: false);
				string text = ResultFromResultsFile(MMI_testName, "power");
				if (!(text.ToUpper() == "DETECTED"))
				{
					WriteLogMessage($"\r\n power {name} not detected");
					flag = false;
				}
				text = ResultFromResultsFile(MMI_testName, "volumedown");
				if (!(text.ToUpper() == "DETECTED"))
				{
					WriteLogMessage($"\r\n volumedown {name} not detected");
					flag = false;
				}
				text = ResultFromResultsFile(MMI_testName, "volumeup");
				if (!(text.ToUpper() == "DETECTED"))
				{
					WriteLogMessage($"\r\n volumeup {name} not detected");
					flag = false;
				}
				if (HAS_HOMEKEY)
				{
					text = ResultFromResultsFile(MMI_testName, "home");
					if (!(text.ToUpper() == "DETECTED"))
					{
						WriteLogMessage($"\r\n home {name} not detected");
						flag = false;
					}
				}
				if (flag)
				{
					XYZ_MOVEHOME();
					return flag;
				}
				XYZ_MOVEHOME();
				RunSingleTestWithWait("KEY", 0);
				xyTableInstance.zRetractAll(Retract_z1: false);
				AllSideKeyPush(HoldKeyPress: true, HoldBetweenKey: true, 100, 100, HAS_HOMEKEY);
				if (KEY_INTERM_TIME > wait_table_move_s)
				{
					Thread.Sleep((int)(KEY_INTERM_TIME * 1000));
				}
				else
				{
					Thread.Sleep(wait_table_move_s * 1000);
				}
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, "KEY");
				Thread.Sleep(millisecondsTimeout);
			}
			XYZ_MOVEHOME();
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool SIDE_KEY_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		MMI_testName = "KEY";
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		ushort.Parse(text);
		try
		{
			bool flag = true;
			RunSingleTestWithWait(MMI_testName, 0);
			AllSideKeyPush();
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, MMI_testName);
			Thread.Sleep(wait_table_move_s * 1000);
			Thread.Sleep(500);
			int num = 11;
			int millisecondsTimeout = 1000;
			for (int i = 0; i < num; i++)
			{
				flag = true;
				GetResultsFile(MMI_testName);
				WriteLines(name, bStart: false);
				string text2 = ResultFromResultsFile(MMI_testName, "power", 1, enable_log_msg: false);
				if (!(text2.ToUpper() == "DETECTED"))
				{
					WriteLogMessage($"\r\n power {name} not detected");
					flag = false;
				}
				text2 = ResultFromResultsFile(MMI_testName, "volumedown", 1, enable_log_msg: false);
				if (!(text2.ToUpper() == "DETECTED"))
				{
					WriteLogMessage($"\r\n volumedown {name} not detected");
					flag = false;
				}
				text2 = ResultFromResultsFile(MMI_testName, "volumeup", 1, enable_log_msg: false);
				if (!(text2.ToUpper() == "DETECTED"))
				{
					WriteLogMessage($"\r\n volumeup {name} not detected");
					flag = false;
				}
				if (flag)
				{
					return flag;
				}
				if (i % 4 == 3)
				{
					RunSingleTestWithWait("KEY", 0);
					AllSideKeyPush();
					phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, "KEY");
				}
				Thread.Sleep(millisecondsTimeout);
			}
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool HOME_KEY_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		MMI_testName = "KEY";
		WriteLines(name);
		_ = TimeOut;
		try
		{
			bool result = true;
			int num = 2;
			while (num > 0)
			{
				RunSingleTestWithWait(MMI_testName, 0);
				HomeKey(enablePartialRetract: true);
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, MMI_testName);
				string text = ResultFromResultsFile(MMI_testName, "home", 2);
				if (!(text.ToUpper() == "DETECTED"))
				{
					WriteLogMessage($"\r\n home Key not detected");
					result = false;
					num--;
					continue;
				}
				return true;
			}
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool KEYPAD()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		if (!useFixture)
		{
			WriteLogMessage($"\r\n Test Fixture not present - Cannot run {name} Test.");
			return false;
		}
		try
		{
			RunSingleTest(name);
			fixtureInstance.PressKeys();
			Thread.Sleep(2000);
			GetResultsFile();
			string[] array = KEY_LIST.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries);
			string text = "";
			bool result = true;
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				text = ResultFromResultsFile(name, text2);
				WriteLogMessage($"Key:{text2} {text}");
				if (text.ToUpper().Contains("NOT"))
				{
					result = false;
				}
			}
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(ex.Message);
			return false;
		}
	}

	public bool CAMERA_FRONT()
	{
		WriteLogMessage("Deprecated, use CAMERA_FRONT_FACE_DETECT instead.");
		return false;
	}

	public bool CAMERA_FRONT_FACE_DETECT()
	{
		string text = MethodBase.GetCurrentMethod().Name;
		WriteLines(text);
		if (MMI_MODE == MMIMODE.FFBM)
		{
			text = "CAMERA_FRONT";
		}
		bool IO_OUT = true;
		try
		{
			string value = TimeOut.ToString();
			if (string.IsNullOrEmpty(value))
			{
				value = "20";
			}
			if (useFixture)
			{
				if (MoveSensorBoard)
				{
					int x = -1;
					int y = -1;
					int z = -1;
					int z2 = -1;
					xyTableInstance.GetPositions(ref x, ref y, ref z, ref z2);
					if (x > X_max || y > Y_max)
					{
						xyTableInstance.zMoveTo_NoPress_partialRetract(xyLOCATE.LL_CORNER.ToString(), enablePartialRetract: true);
					}
				}
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			RunSingleTest(text);
			Thread.Sleep(3000);
			GetResultsFile(text);
			if (useFixture)
			{
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			WriteLines(text, bStart: false);
			return ResultFromResultsFile(text);
		}
		catch (Exception ex)
		{
			if (useFixture)
			{
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			WriteLogMessage(text + ex.Message);
			return false;
		}
		finally
		{
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
		}
	}

	public bool CAMERA_BACK()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool IO_OUT = true;
		try
		{
			string text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "20";
			}
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			RunSingleTestWithWait(name, ushort.Parse(text));
			GetResultsFile();
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool CAMERA_BACK_MAIN()
	{
		WriteLogMessage("Deprecated, use CAMERA_BACK_MAIN_FACE_DETECT instead.");
		return false;
	}

	public bool CAMERA_BACK_MAIN_FACE_DETECT()
	{
		string text = MethodBase.GetCurrentMethod().Name;
		WriteLines(text);
		if (MMI_MODE == MMIMODE.FFBM)
		{
			text = "CAMERA_BACK_MAIN";
		}
		bool IO_OUT = true;
		try
		{
			string value = TimeOut.ToString();
			if (string.IsNullOrEmpty(value))
			{
				value = "20";
			}
			if (useFixture)
			{
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			RunSingleTest(text);
			Thread.Sleep(3000);
			GetResultsFile(text);
			if (useFixture)
			{
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			WriteLines(text, bStart: false);
			return ResultFromResultsFile(text);
		}
		catch (Exception ex)
		{
			if (useFixture)
			{
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			WriteLogMessage(text + ex.Message);
			return false;
		}
		finally
		{
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
		}
	}

	public bool CAMERA_BACK_AUX()
	{
		WriteLogMessage("Deprecated, use CAMERA_BACK_AUX_FACE_DETECT instead.");
		return false;
	}

	public bool CAMERA_BACK_AUX_FACE_DETECT()
	{
		string text = MethodBase.GetCurrentMethod().Name;
		WriteLines(text);
		if (MMI_MODE == MMIMODE.FFBM)
		{
			text = "CAMERA_BACK_AUX";
		}
		bool IO_OUT = true;
		try
		{
			string value = TimeOut.ToString();
			if (string.IsNullOrEmpty(value))
			{
				value = "20";
			}
			if (useFixture)
			{
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			RunSingleTest(text);
			GetResultsFile(text);
			if (useFixture)
			{
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			WriteLines(text, bStart: false);
			return ResultFromResultsFile(text);
		}
		catch (Exception ex)
		{
			if (useFixture)
			{
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.PHOT_LED1, ref setBit, ref IO_OUT);
			}
			WriteLogMessage(text + ex.Message);
			return false;
		}
	}

	public bool CAMERA_BACK_MAIN_SNAPSHOT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "20";
			}
			RunSingleTestWithWait(name, ushort.Parse(text));
			GetResultsFile();
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool CAMERA_FRONT_SNAPSHOT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "20";
			}
			RunSingleTestWithWait(name, ushort.Parse(text));
			GetResultsFile();
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool HEADSET()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "0";
		}
		try
		{
			RunSingleTestWithWait("HEADSET", ushort.Parse(text));
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_HS_DETECT, ref setBit, ref IO_OUT);
			Thread.Sleep(1000);
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_HS_DETECT, ref setBit, ref IO_OUT);
			Thread.Sleep(3000);
			GetResultsFile();
			WriteLines(name, bStart: false);
			string text2 = ResultFromResultsFile(name, "headphone");
			string text3 = ResultFromResultsFile(name, "headphone_insert");
			string text4 = ResultFromResultsFile(name, "microphone");
			string text5 = ResultFromResultsFile(name, "microphone_insert");
			if ((text2.ToUpper() == "DETECTED" || text3.ToUpper() == "DETECTED") && (text4.ToUpper() == "DETECTED" || text5.ToUpper() == "DETECTED"))
			{
				return true;
			}
			return false;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool KEY_HEADSET()
	{
		string text = MethodBase.GetCurrentMethod().Name;
		WriteLines(text);
		if (MMI_MODE == MMIMODE.QMMI)
		{
			text = "HEADSET_KEY";
		}
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			bool result = true;
			int num = 2;
			while (num > 0)
			{
				RunSingleTest(text);
				headset_insertion_sim(100, 0);
				headset_insertion_sim(500, 0);
				headset_insertion_sim(1000, 0);
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 1u, text);
				if (FTMErrorCode != 0)
				{
					WriteLogMessage($"\r\nError to exit {text}...");
				}
				string text2 = ResultFromResultsFile(text, "headphone", 2);
				string text3 = ResultFromResultsFile(text, "headphone_insert", 0, enable_log_msg: false);
				WriteLogMessage($"\r\n -- HP_String={text2},HP_String_8909=={text3}");
				if (text2.ToUpper() == "DETECTED" || text3.ToUpper() == "DETECTED")
				{
					WriteLines(text, bStart: false);
					return true;
				}
				result = false;
				num--;
				WriteLogMessage($"\r\n Retry {text}...");
			}
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(text + ex.Message);
			return false;
		}
	}

	public bool KEY_HEADSET_HANGUP()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		name = "HEADSET_KEY";
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			bool result = true;
			int num = 2;
			while (num > 0)
			{
				RunSingleTest(name);
				headset_hangup(450, 450, 2250);
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, name);
				if (FTMErrorCode != 0)
				{
					WriteLogMessage($"\r\nError to exit {name}...");
				}
				string text = ResultFromResultsFile(name, "hangup", 2);
				WriteLogMessage($"\r\n -- HUP_String=={text}");
				if (text.ToUpper() == "DETECTED")
				{
					WriteLines(name, bStart: false);
					return true;
				}
				result = false;
				num--;
				WriteLogMessage($"\r\n Retry {name}...");
			}
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool VIBRATOR()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string testName = "VIBRATOR_ON";
		string text = "VIBRATOR_OFF";
		if (!deprecated)
		{
			testName = "VIBRATOR";
			text = "VIBRATOR";
		}
		string text2 = TimeOut.ToString();
		if (string.IsNullOrEmpty(text2))
		{
			text2 = "20";
		}
		try
		{
			double num = 0.0;
			double num2 = 0.0;
			if (SAMPLES < 1)
			{
				SAMPLES = 10;
			}
			for (int i = 0; i < SAMPLES; i++)
			{
				double analog_Voltage_VIB_DETECT = fixtureInstance.Get_Analog_Voltage_VIB_DETECT();
				num2 += analog_Voltage_VIB_DETECT;
				WriteLogMessage($"OFF reading {i} - {analog_Voltage_VIB_DETECT} volts");
				Thread.Sleep(100);
			}
			num2 /= (double)SAMPLES;
			WriteLogMessage($"VIB OFF reading average value {num2}volts");
			RunSingleTest(testName);
			Thread.Sleep(400);
			for (int j = 0; j < SAMPLES; j++)
			{
				double analog_Voltage_VIB_DETECT2 = fixtureInstance.Get_Analog_Voltage_VIB_DETECT();
				num += analog_Voltage_VIB_DETECT2;
				WriteLogMessage($"ON reading {j} - {analog_Voltage_VIB_DETECT2} volts");
				Thread.Sleep(100);
			}
			num /= (double)SAMPLES;
			WriteLogMessage($"VIB ON reading average value {num}volts");
			bool flag = false;
			flag = ((onOffDelta <= Math.Abs(num - num2)) ? true : false);
			if (deprecated)
			{
				RunSingleTest(text);
			}
			else
			{
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
			}
			WriteLines(name, bStart: false);
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			if (deprecated)
			{
				RunSingleTestWithWait(text, ushort.Parse(text2));
			}
			else
			{
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, text);
			}
			return false;
		}
	}

	public bool TOUCH()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		try
		{
			RunSingleTestWithWait(name, ushort.Parse(text));
			GetResultsFile();
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool TOUCH_PHONE()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		if (MMI_MODE == MMIMODE.QMMI)
		{
			name = "TOUCH";
			touchLogRemoteName = "touch.track";
		}
		else
		{
			name = "TOUCH_TRACK";
		}
		if (!CheckFixtureExist())
		{
			return false;
		}
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "20";
		}
		List<double> T_x = new List<double>();
		List<double> T_y = new List<double>();
		try
		{
			while (RetryCounts > 0)
			{
				string text2 = "";
				int value = 400;
				RunSingleTestWithWait(name, ushort.Parse(text));
				xyTableInstance.zMoveTo_NoPress_partialRetract(xyLOCATE.LOC_TOUCH_1.ToString(), enablePartialRetract: true);
				xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LOC_TOUCH_1.ToString(), useOffset: false, moveWhileDownOK: true);
				xyTableInstance.RetractZ_ByValue(zACT.TOUCH, value, ref text2);
				if (flag)
				{
					xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LOC_TOUCH_1.ToString(), useOffset: false, moveWhileDownOK: true);
					xyTableInstance.RetractZ_ByValue(zACT.TOUCH, value, ref text2);
				}
				xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LOC_TOUCH_2.ToString(), useOffset: false, moveWhileDownOK: true);
				xyTableInstance.RetractZ_ByValue(zACT.TOUCH, value, ref text2);
				xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LOC_TOUCH_3.ToString(), useOffset: false, moveWhileDownOK: true);
				xyTableInstance.RetractZ_ByValue(zACT.TOUCH, value, ref text2);
				xyTableInstance.NoRetract_MoveTo_touch(xyLOCATE.LOC_TOUCH_4.ToString(), useOffset: false, moveWhileDownOK: true);
				xyTableInstance.RetractZ_ByValue(zACT.TOUCH, value, ref text2);
				Thread.Sleep(1000);
				phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, name);
				if (FTMErrorCode != 0)
				{
					WriteLogMessage("Error in FTM_AP_EXIT_TEST for TOUCH Test");
					return false;
				}
				GetTouchLog(ref T_x, ref T_y);
				if (T_x.Count >= 4)
				{
					break;
				}
				WriteLogMessage("Missing nummber of touch points: got " + T_x.Count + " ponits (it should be 4)");
				if (RetryCounts > 0)
				{
					WriteLogMessage("Retry ...");
					T_x.Clear();
					T_y.Clear();
					RetryCounts--;
					continue;
				}
				WriteLogMessage("Failed to get correct number of coordinates");
				return false;
			}
			short[] array = new short[4] { 9999, 9999, 9999, 9999 };
			short[] array2 = new short[4] { 9999, 9999, 9999, 9999 };
			short[] array3 = new short[4];
			short[] array4 = array3;
			short[] array5 = new short[4];
			short[] array6 = array5;
			for (int i = 0; i < 4; i++)
			{
				if (!short.TryParse(FindParameterValueFromSectionWithName("X" + (i + 1) + "_LL"), out array[i]))
				{
					WriteLogMessage("Failed to find X" + (i + 1) + "_LL limit ");
					return false;
				}
				if (!short.TryParse(FindParameterValueFromSectionWithName("Y" + (i + 1) + "_LL"), out array2[i]))
				{
					WriteLogMessage("Failed to find Y" + (i + 1) + "_LL limit ");
					return false;
				}
				if (!short.TryParse(FindParameterValueFromSectionWithName("X" + (i + 1) + "_UL"), out array4[i]))
				{
					WriteLogMessage("Failed to find X" + (i + 1) + "_UL limit ");
					return false;
				}
				if (!short.TryParse(FindParameterValueFromSectionWithName("Y" + (i + 1) + "_UL"), out array6[i]))
				{
					WriteLogMessage("Failed to find Y" + (i + 1) + "_UL limit ");
					return false;
				}
			}
			int count = T_x.Count;
			bool result = false;
			bool[] array7 = new bool[4];
			bool[] array8 = array7;
			if (EXACT_4_POINTS)
			{
				for (int j = 0; j < count; j++)
				{
					for (int k = 0; k < 4; k++)
					{
						if (!array8[k] && !((double)array[k] > T_x[j]) && !((double)array2[k] > T_y[j]) && !((double)array4[k] < T_x[j]) && !((double)array6[k] < T_y[j]))
						{
							WriteLogMessage("Limit Check Passed for touch point(" + (j + 1) + ") : X = " + T_x[j] + "; Y = " + T_y[j]);
							array8[k] = true;
							break;
						}
					}
					if (array8[0] && array8[1] && array8[2] && array8[3])
					{
						result = true;
						break;
					}
				}
			}
			else
			{
				for (int l = 0; l < count; l++)
				{
					int num = 0;
					for (int m = 0; m < 4; m++)
					{
						if (num == 3)
						{
							WriteLogMessage("Limit Check failed for touch point(" + (l + 1) + ") : X = " + T_x[l] + "; Y = " + T_y[l]);
							return false;
						}
						if ((double)array[m] < T_x[l] && (double)array2[m] < T_y[l] && (double)array4[m] > T_x[l] && (double)array6[m] > T_y[l])
						{
							WriteLogMessage("Limit Check Passed for touch point(" + (l + 1) + ") : X = " + T_x[l] + "; Y = " + T_y[l] + "in area " + (m + 1));
							array8[m] = true;
							break;
						}
						num++;
					}
				}
				if (array8[0] && array8[1] && array8[2] && array8[3])
				{
					result = true;
				}
			}
			WriteLines(name, bStart: false);
			return result;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool BATTERY()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool SMB()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			RunSingleTest(name);
			GetResultsFile(name);
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool WIPOWER()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			throw new NotSupportedException();
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool USB_OTG()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		bool flag = false;
		string text = TimeOut.ToString();
		if (string.IsNullOrEmpty(text))
		{
			text = "0";
		}
		try
		{
			bool IO_OUT = true;
			USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
			USB_IO_Expander.SetValue setBit2 = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_OTG_EN, ref setBit, ref IO_OUT);
			if (!int.TryParse(text, out var result))
			{
				result = 1000;
			}
			result *= 1000;
			while (phone.IsPhoneConnected() && result > 0)
			{
				WriteLogMessage("Waiting for phone to be disconnected for OTG test");
				if (!phone.IsPhoneConnected())
				{
					break;
				}
				Thread.Sleep(200);
				result -= 200;
			}
			IO_OUT = false;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.OTG_VBUS_STAT, ref setBit2, ref IO_OUT);
			while (setBit2 == USB_IO_Expander.SetValue.LOW && result > 0)
			{
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.OTG_VBUS_STAT, ref setBit2, ref IO_OUT);
				WriteLogMessage("\r\n Checking OTG Status ");
				if (setBit2 != 0)
				{
					break;
				}
				Thread.Sleep(200);
				result -= 200;
			}
			if (setBit2 == USB_IO_Expander.SetValue.HIGH)
			{
				WriteLogMessage("\r\n Passed USB OTG Test");
				flag = true;
			}
			else
			{
				WriteLogMessage("\r\n Failed USB OTG Test");
				flag = false;
			}
			IO_OUT = true;
			setBit = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_OTG_EN, ref setBit, ref IO_OUT);
			if (Enable_Reconnect && !DUT_ReConnect())
			{
				WriteLogMessage("Failed to Reconnected to DUT");
			}
			return flag;
		}
		catch (Exception ex)
		{
			WriteLogMessage("\r\n Error: USB OTG Test");
			WriteLogMessage(name + ex.Message);
			bool IO_OUT2 = true;
			USB_IO_Expander.SetValue setBit3 = USB_IO_Expander.SetValue.LOW;
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_OTG_EN, ref setBit3, ref IO_OUT2);
			return false;
		}
	}

	public bool USB_UFP()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		double A = 0.0;
		double A2 = 0.0;
		double B = 0.0;
		double B2 = 0.0;
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			if (Reset_DUT)
			{
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.HUB_RESET_N, ref setBit, ref IO_OUT);
				REBOOT_DUT();
				setBit = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.HUB_RESET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(100);
				DUT_ReConnect();
			}
			fixtureInstance.Set_UFPVBUS(out A, out A2, out B, out B2);
			Thread.Sleep(500);
			fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.CONNECT_DUT_CC1_SS1);
			fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.POWER_OFF_DUT);
			Thread.Sleep(500);
			fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.POWER_DUT);
			DUT_ReConnect();
			WriteLogMessage($"\r\nUFP voltage A4: {A} ");
			WriteLogMessage($"\r\nUFP voltage A9: {A2} ");
			WriteLogMessage($"\r\nUFP voltage B4: {B} ");
			WriteLogMessage($"\r\nUFP voltage B9: {B2} ");
			if (A < USB_UFPvolt_LL || A2 < USB_UFPvolt_LL || B < USB_UFPvolt_LL || B2 < USB_UFPvolt_LL)
			{
				WriteLogMessage("\r\nFailed UFP voltage check");
				return false;
			}
			WriteLogMessage("\r\nPassed UFP voltage check");
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool USB_CHECK_CC()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.CONNECT_DUT_CC2_SS2);
			if (Reset_DUT)
			{
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.HUB_RESET_N, ref setBit, ref IO_OUT);
				REBOOT_DUT();
				setBit = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.HUB_RESET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(100);
			}
			if (!DUT_ReConnect())
			{
				WriteLogMessage("\r\nFaield to connect to DUT when setting USB CC2 pin");
				return false;
			}
			Thread.Sleep(500);
			fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Mode.CONNECT_DUT_CC1_SS1);
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool USB_VCONN()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		double vconn = 0.0;
		string value = TimeOut.ToString();
		if (string.IsNullOrEmpty(value))
		{
			value = "20";
		}
		try
		{
			if (Reset_DUT)
			{
				bool IO_OUT = true;
				USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.HUB_RESET_N, ref setBit, ref IO_OUT);
				REBOOT_DUT();
				setBit = USB_IO_Expander.SetValue.HIGH;
				fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.HUB_RESET_N, ref setBit, ref IO_OUT);
				Thread.Sleep(100);
				DUT_ReConnect();
			}
			fixtureInstance.Set_VCONN(out vconn);
			WriteLogMessage($"\r\nUFP voltage A4 {vconn} = ");
			if (vconn < USB_UFPvolt_LL)
			{
				WriteLogMessage("\r\nFailed VCONN voltage check");
				return false;
			}
			WriteLogMessage("\r\nPassed UFP voltage check");
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool USB()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		try
		{
			string text = TimeOut.ToString();
			if (string.IsNullOrEmpty(text))
			{
				text = "20";
			}
			RunSingleTestWithWait(name, ushort.Parse(text));
			GetResultsFile();
			WriteLines(name, bStart: false);
			return ResultFromResultsFile(name);
		}
		catch (Exception ex)
		{
			WriteLogMessage(name + ex.Message);
			return false;
		}
	}

	public bool USB_SS_CONNECT()
	{
		string name = MethodBase.GetCurrentMethod().Name;
		WriteLines(name);
		int num = 5;
		if (fixtureInstance.isRevB)
		{
			if (!fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Control.USB2_CTRL, USB_IO_Expander.SetValue.LOW))
			{
				return false;
			}
			if (!fixtureInstance.I2C_Control_Output(USB_IO_Expander.I2C_Control.USB2_AUDIO_SEL, USB_IO_Expander.SetValue.LOW))
			{
				return false;
			}
		}
		else if (!fixtureInstance.SetIOexpand_SX1508("13"))
		{
			return false;
		}
		Thread.Sleep(500);
		for (int i = 0; i < num; i++)
		{
			if (phone.IsPhoneConnected())
			{
				if (!fixtureInstance.isRevB && !fixtureInstance.SetIOexpand_SX1508("10"))
				{
					return false;
				}
				WriteLines(name, bStart: false);
				return true;
			}
			Thread.Sleep(200);
		}
		if (!fixtureInstance.isRevB && !fixtureInstance.SetIOexpand_SX1508("10"))
		{
			return false;
		}
		if (!CONNECT())
		{
			WriteLogMessage("Error Occurred: Cannot reconnect to DUT");
		}
		return false;
	}

	private void DebugLogTimeStamp(string info = "", bool enable = false)
	{
		if (enable)
		{
			WriteDebugMessage("\r\n" + info + " ----->TimeStamp: " + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + "\r\n");
		}
	}

	private bool DUT_ReConnect()
	{
		_ = MethodBase.GetCurrentMethod().Name;
		try
		{
			int dUT_COMPORT = DUT_COMPORT;
			phone.SetLibraryMode(ConnectLibMod);
			int num = 5000;
			int num2 = 1000;
			int num3 = 0;
			while (!phone.IsPhoneConnected())
			{
				if (isAPQ)
				{
					ConnectToPhone(phone, dUT_COMPORT, Phone.TargetType.QLIB_TARGET_TYPE_APQ);
				}
				else
				{
					ConnectToPhone(phone, dUT_COMPORT);
				}
				if (phone.IsPhoneConnected() || num <= 0)
				{
					break;
				}
				Thread.Sleep(num2);
				num -= num2;
				num3 += num2;
				WriteLogMessage($"Reconnecting...elapsed time-{num3} ms");
			}
			if (!phone.IsPhoneConnected())
			{
				WriteErrorMessage("Failed to connect to Phone");
				return false;
			}
			WriteLogMessage("\r\nRe-Connected to COM - " + phone.GetPhoneComPort());
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	private bool SetAudioLoopbackHeadset(string caseName, bool IO_OUT, out USB_IO_Expander.SetValue setBit, out bool result)
	{
		setBit = USB_IO_Expander.SetValue.LOW;
		fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
		Thread.Sleep(100);
		setBit = USB_IO_Expander.SetValue.HIGH;
		fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
		Thread.Sleep(100);
		setBit = USB_IO_Expander.SetValue.LOW;
		fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
		Thread.Sleep(100);
		setBit = USB_IO_Expander.SetValue.LOW;
		fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_R_OUT);
		Thread.Sleep(100);
		setBit = USB_IO_Expander.SetValue.HIGH;
		fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_HPH_R_OUT);
		Thread.Sleep(100);
		RunSingleTestWithWait(caseName, 0);
		result = false;
		for (int i = 0; i < 30; i++)
		{
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.TONE_DET_N, ref setBit, ref IO_OUT);
			Thread.Sleep(200);
			if (setBit == USB_IO_Expander.SetValue.LOW)
			{
				result = true;
				WriteLogMessage("TONE detected at RIGHT HS SPEAKER");
				break;
			}
		}
		return IO_OUT;
	}

	private Dictionary<string, int> WifiScan_SSID_VS_RSSI()
	{
		Dictionary<string, int> dictionary = new Dictionary<string, int>();
		IntPtr pAvailableNetworkList = IntPtr.Zero;
		List<Guid> list = new List<Guid>();
		WifiAPI.WlanOpenHandle(2u, IntPtr.Zero, out var _, out var clientHandle);
		WifiAPI.WlanNotificationCallbackDelegate funcCallback = OnWlanNotification;
		WifiAPI.WlanRegisterNotification(clientHandle, WifiAPI.WlanNotificationSource.All, ignoreDuplicate: false, funcCallback, IntPtr.Zero, IntPtr.Zero, out var _);
		Thread.Sleep(20);
		WifiAPI.WlanEnumInterfaces(clientHandle, IntPtr.Zero, out var ppInterfaceList);
		try
		{
			WifiAPI.ListHeader listHeader = (WifiAPI.ListHeader)Marshal.PtrToStructure(ppInterfaceList, typeof(WifiAPI.ListHeader));
			long num = ppInterfaceList.ToInt64() + Marshal.SizeOf((object)listHeader);
			for (int i = 0; i < listHeader.numberOfItems; i++)
			{
				WifiAPI.WlanInterfaceInfo wlanInterfaceInfo = (WifiAPI.WlanInterfaceInfo)Marshal.PtrToStructure(new IntPtr(num), typeof(WifiAPI.WlanInterfaceInfo));
				num += Marshal.SizeOf((object)wlanInterfaceInfo);
				list.Add(wlanInterfaceInfo.interfaceGuid);
			}
		}
		finally
		{
			WifiAPI.WlanFreeMemory(ppInterfaceList);
		}
		foreach (Guid item in list)
		{
			WifiAPI.WlanScan(clientHandle, item, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
			try
			{
				WifiAPI.WlanGetAvailableNetworkList(clientHandle, item, 1u, IntPtr.Zero, out pAvailableNetworkList);
				string text = "";
				WifiAPI.WlanAvailableNetwork[] array = ConvertAvailableNetworkListPtr(pAvailableNetworkList);
				for (int j = 0; j < array.Length; j++)
				{
					WifiAPI.WlanAvailableNetwork wlanAvailableNetwork = array[j];
					string @string = Encoding.ASCII.GetString(wlanAvailableNetwork.dot11Ssid.SSID);
					char[] trimChars = new char[1];
					text = @string.Trim(trimChars);
					if (!dictionary.Keys.Contains(text))
					{
						dictionary.Add(text, -100 + (int)wlanAvailableNetwork.wlanSignalQuality / 2);
					}
				}
			}
			finally
			{
				WifiAPI.WlanFreeMemory(pAvailableNetworkList);
			}
		}
		WifiAPI.WlanCloseHandle(clientHandle, IntPtr.Zero);
		return dictionary;
	}

	private WifiAPI.WlanAvailableNetwork[] ConvertAvailableNetworkListPtr(IntPtr availNetListPtr)
	{
		WifiAPI.ListHeader listHeader = (WifiAPI.ListHeader)Marshal.PtrToStructure(availNetListPtr, typeof(WifiAPI.ListHeader));
		long num = availNetListPtr.ToInt64() + Marshal.SizeOf(typeof(WifiAPI.ListHeader));
		WifiAPI.WlanAvailableNetwork[] array = new WifiAPI.WlanAvailableNetwork[listHeader.numberOfItems];
		for (int i = 0; i < listHeader.numberOfItems; i++)
		{
			ref WifiAPI.WlanAvailableNetwork reference = ref array[i];
			reference = (WifiAPI.WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(num), typeof(WifiAPI.WlanAvailableNetwork));
			num += Marshal.SizeOf(typeof(WifiAPI.WlanAvailableNetwork));
		}
		return array;
	}

	private void OnWlanNotification(ref WifiAPI.WlanNotificationData notifyData, IntPtr context)
	{
	}

	private void WriteLines(string testName = "", bool bStart = true)
	{
		if (bStart)
		{
			testIndex++;
			msg = "================================================" + testIndex + " " + testName;
			if (string.IsNullOrEmpty(TEST_CASE_NAME_IN_SEQ_FILE))
			{
				MMI_testName = testName;
			}
			else
			{
				MMI_testName = TEST_CASE_NAME_IN_SEQ_FILE;
				WriteLogMessage("Using TEST_CASE_NAME_IN_SEQ_FILE: " + MMI_testName);
			}
		}
		else
		{
			msg = $"\r\nFinished {testName}...";
		}
		WriteLogMessage(msg);
		if (MoreLog)
		{
			WriteDebugMessage(msg);
		}
		DebugLogTimeStamp(testName, MoreLog);
	}

	private string FindParameterValueFromSectionWithName(string name)
	{
		string result = "Not found";
		string[] array = PARAMETER.Split(';');
		string[] array2 = array;
		foreach (string text in array2)
		{
			if (text.Contains(name + ":"))
			{
				result = text.Replace(name + ":", "").TrimEnd();
				break;
			}
		}
		return result;
	}

	private void GetTouchLog(ref List<double> T_x, ref List<double> T_y)
	{
		Stopwatch stopwatch = new Stopwatch();
		stopwatch.Start();
		int num = 10;
		if (File.Exists(touchLogFileName))
		{
			File.Delete(touchLogFileName);
		}
		Thread.Sleep(1000);
		while (true)
		{
			FTMErrorCode = 0;
			phone.FTM_AP_ReadFile(ref FTMErrorCode, touchLogRemoteName, touchLogFileName);
			int length = touchLogFileName.Length;
			string text = touchLogFileName.Substring(length - 4);
			string text2 = touchLogFileName.Substring(0, length - 4);
			File.Copy(touchLogFileName, text2 + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + text);
			if (FTMErrorCode == 0 || FTMErrorCode == 2)
			{
				break;
			}
			WriteLogMessage("Retry- get Touch log file");
			int num2 = (int)(num * 1000 - stopwatch.ElapsedMilliseconds);
			if (num2 <= 0)
			{
				break;
			}
			Thread.Sleep(500);
		}
		using StreamReader streamReader = new StreamReader(touchLogFileName);
		char[] separator = new char[1] { ',' };
		char[] separator2 = new char[1] { ';' };
		string text3;
		if (MMI_MODE == MMIMODE.QMMI)
		{
			if (string.IsNullOrEmpty(text3 = streamReader.ReadToEnd()))
			{
				return;
			}
			if (MoreLog)
			{
				WriteDebugMessage("touch_track.txt: " + text3);
			}
			string[] array = text3.Split(separator2, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 0)
			{
				return;
			}
			string[] array2 = array;
			foreach (string text4 in array2)
			{
				string[] array3 = text4.Split(separator, StringSplitOptions.RemoveEmptyEntries);
				if (!double.TryParse(array3[0].Trim(), out var result) || !double.TryParse(array3[1].Trim(), out var result2))
				{
					WriteLogMessage("Error parsing from touch log file");
					continue;
				}
				T_x.Add(result);
				T_y.Add(result2);
			}
			return;
		}
		while ((text3 = streamReader.ReadLine()) != null)
		{
			text3 = text3.Replace("(", "").Replace(")", "");
			string[] array4 = text3.Split(separator);
			if (!double.TryParse(array4[0].Trim(), out var result3) || !double.TryParse(array4[1].Trim(), out var result4))
			{
				WriteLogMessage("Error parsing from touch log file");
				continue;
			}
			T_x.Add(result3);
			T_y.Add(result4);
		}
	}

	private double getMoveReading(double base_reading, double delta, List<double> samples)
	{
		double num = 0.0;
		int num2 = 0;
		foreach (double sample in samples)
		{
			double num3 = sample;
			if (Math.Abs(num3 - base_reading) > Math.Abs(delta))
			{
				num += num3;
				num2++;
			}
		}
		if (num2 > 0)
		{
			return num / (double)num2;
		}
		return 0.0;
	}

	private double getAverageReading_remove_outlier(double LL, double UL, List<double> samples)
	{
		double num = 0.0;
		int num2 = 0;
		foreach (double sample in samples)
		{
			double num3 = sample;
			if (Math.Abs(num3) > LL && Math.Abs(num3) < UL)
			{
				num += num3;
				num2++;
			}
		}
		if (num2 > 0)
		{
			return num / (double)num2;
		}
		return 0.0;
	}

	private void GetGyroLog(ref List<double> T_x, ref List<double> T_y, ref List<double> T_z)
	{
		Stopwatch stopwatch = new Stopwatch();
		stopwatch.Start();
		int num = 10;
		if (File.Exists(gyroLogFileName))
		{
			File.Delete(gyroLogFileName);
		}
		while (true)
		{
			FTMErrorCode = 0;
			phone.FTM_AP_ReadFile(ref FTMErrorCode, gyroLogRemoteName, gyroLogFileName);
			if (FTMErrorCode == 0)
			{
				break;
			}
			WriteLogMessage("Retry- get gyro log file");
			int num2 = (int)(num * 1000 - stopwatch.ElapsedMilliseconds);
			if (num2 <= 0)
			{
				break;
			}
			Thread.Sleep(500);
		}
		using StreamReader streamReader = new StreamReader(gyroLogFileName);
		char[] separator = new char[1] { ',' };
		char[] separator2 = new char[1] { ';' };
		string text;
		if (MMI_MODE == MMIMODE.QMMI)
		{
			if (string.IsNullOrEmpty(text = streamReader.ReadToEnd()))
			{
				return;
			}
			string[] array = text.Split(separator2, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 0)
			{
				return;
			}
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				string[] array3 = text2.Split(separator, StringSplitOptions.RemoveEmptyEntries);
				if (!double.TryParse(array3[0].Trim(), out var result) || !double.TryParse(array3[1].Trim(), out var result2) || !double.TryParse(array3[2].Trim(), out var result3))
				{
					WriteLogMessage("Error parsing from touch log file");
					continue;
				}
				T_x.Add(result);
				T_y.Add(result2);
				T_z.Add(result3);
			}
			return;
		}
		while ((text = streamReader.ReadLine()) != null)
		{
			text = text.Replace("(", "").Replace(")", "");
			string[] array4 = text.Split(separator);
			if (!double.TryParse(array4[0].Trim(), out var result4) || !double.TryParse(array4[1].Trim(), out var result5) || !double.TryParse(array4[2].Trim(), out var result6))
			{
				WriteLogMessage("Error parsing gyro log file");
				continue;
			}
			T_x.Add(result4);
			T_y.Add(result5);
			T_z.Add(result6);
		}
	}

	private bool getParameters(string[] parameters, string[] default_values, ref string[] parameter_values)
	{
		try
		{
			for (int i = 0; i < parameters.Count(); i++)
			{
				parameter_values[i] = default_values[i];
				try
				{
					parameter_values[i] = FindParameterValueFromSectionWithName(parameters[i]);
				}
				catch (Exception)
				{
					parameter_values[i] = default_values[i];
				}
			}
		}
		catch
		{
			return false;
		}
		return true;
	}

	private bool getLimits(string[] limits, ref double[] limits_values)
	{
		try
		{
			for (int i = 0; i < limits.Count(); i++)
			{
				limits_values[i] = -999.0;
				try
				{
					string s = FindParameterValueFromSectionWithName(limits[i]);
					if (!double.TryParse(s, out limits_values[i]))
					{
						WriteLogMessage($"Info: Not able to parse limit for {limits[i]}  - use '-999'");
						limits_values[i] = -999.0;
					}
				}
				catch (Exception)
				{
					WriteLogMessage(string.Format("Info: Not found {0} limit for {0}  - use '-999'", limits[i]));
				}
			}
		}
		catch (Exception ex2)
		{
			WriteLogMessage("Error: " + ex2);
			return false;
		}
		return true;
	}

	private void headset_hangup(int delay_0, int delay_1, int delay_after)
	{
		bool IO_OUT = true;
		USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
		fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_VOL_UP, ref setBit, ref IO_OUT);
		Thread.Sleep(delay_0);
		setBit = USB_IO_Expander.SetValue.HIGH;
		fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_VOL_UP, ref setBit, ref IO_OUT);
		Thread.Sleep(delay_1);
		setBit = USB_IO_Expander.SetValue.LOW;
		fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SOLENOID_VOL_UP, ref setBit, ref IO_OUT);
		Thread.Sleep(delay_after);
	}

	private void headset_insertion_sim(int delay_1, int delay_after)
	{
		bool IO_OUT = true;
		USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.HIGH;
		fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_HS_DETECT, ref setBit, ref IO_OUT);
		Thread.Sleep(delay_1);
		setBit = USB_IO_Expander.SetValue.LOW;
		fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_HS_DETECT, ref setBit, ref IO_OUT);
		Thread.Sleep(delay_after);
	}

	private bool CheckPreviousStation(int currentStation)
	{
		short num = 128;
		byte[] array = new byte[num];
		int itemID = 2499;
		string text = "";
		try
		{
			if (currentStation < 2)
			{
				throw new Exception("currentStation shoud be equal or greater than 2 ");
			}
			phone.NVRead((nv_items_enum_type)itemID, array, num);
			text = "Station flags get from NV2499 is " + Encoding.Default.GetString(array) + "     .";
			WriteDebugMessage(text);
			for (int i = 0; i < currentStation - 1; i++)
			{
				if (array[i] != 80 && array[i] != 66)
				{
					WriteErrorMessage($"station {i} did not pass");
					throw new Exception(text);
				}
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	private bool CheckFixtureExist(bool Check_XY_TableExist = true)
	{
		if (!useFixture)
		{
			WriteLogMessage($"\r\n Test Fixture not present - Cannot run Test.");
			return false;
		}
		if (Check_XY_TableExist && !xyTableEnabled)
		{
			WriteLogMessage($"\r\n XYTable not present - Cannot run Test.");
			return false;
		}
		return true;
	}

	private bool XY_TABLE_Connect()
	{
		_ = MethodBase.GetCurrentMethod().Name;
		try
		{
			if (tableInit())
			{
				WriteLogMessage("\r\nConnected to XY Table");
				xyTable_connected = true;
				return true;
			}
			return false;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error to connect XYTable: " + ex.Message);
			return false;
		}
	}

	private bool tableInit()
	{
		bool flag = false;
		if (!xyTableInstance.OpenUserDefConfigFile(ref xyTableInstance.msg))
		{
			WriteLogMessage(xyTableInstance.msg);
			return false;
		}
		xyTableInstance.QuerySafetyZone();
		if (!xyTableInstance.ControllerPortOk())
		{
			int num = 10;
			int millisecondsTimeout = 1000;
			bool flag2 = false;
			for (int i = 0; i < num; i++)
			{
				Thread.Sleep(millisecondsTimeout);
				if (xyTableInstance.Connect(portXyTable, baudrateXyTable))
				{
					flag2 = true;
					break;
				}
				xyTableInstance.ClosePort();
			}
			if (!flag2)
			{
				WriteLogMessage("Could not connect to COM port." + xyTableInstance.msg);
				return false;
			}
			if (!xyTableInstance.ControllerPortOk())
			{
				WriteLogMessage("COM port is not responding");
				return false;
			}
		}
		if (!xyTableInstance.setDimensionType())
		{
			return false;
		}
		xyTableInstance.WaitForCmd = true;
		xyTableInstance.zRetractAll();
		xyTableInstance.MoveXYHome();
		return true;
	}

	private void ConnectToPhone(Phone phone, int Comport, Phone.TargetType targetType = Phone.TargetType.QLIB_TARGET_TYPE_MSM_MDM)
	{
		try
		{
			if (Comport == 0)
			{
				phone.ConnectToServer(65535, targetType);
			}
			else
			{
				phone.ConnectToServer(Comport, targetType);
			}
			if (phone.IsPhoneConnected())
			{
				Thread.Sleep(1000);
				if (Comport == 0)
				{
					phone.ConnectToServer(65535, targetType);
				}
				else
				{
					phone.ConnectToServer(Comport, targetType);
				}
			}
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Error in ConnectToPhone at COM Port" + Comport + "; Inner exception: " + ex.Message);
		}
	}

	private bool LED_INDICATOR(string onTestName, string offTestName, double onOffDelta, bool deprecated = false, int sample = 1, int interval_ms = 100)
	{
		bool flag = false;
		if (deprecated)
		{
			RunSingleTest(offTestName);
		}
		else
		{
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, offTestName);
		}
		WriteLogMessage("SENSOR LED OFF");
		double num = 0.0;
		double num2 = 0.0;
		for (int i = 0; i < sample; i++)
		{
			double analog_voltage_Indicator_LED_light_Sensor = fixtureInstance.Get_analog_voltage_Indicator_LED_light_Sensor();
			num2 += analog_voltage_Indicator_LED_light_Sensor;
			WriteLogMessage($"OFF reading {i} - {analog_voltage_Indicator_LED_light_Sensor} volts");
		}
		num2 /= (double)sample;
		WriteLogMessage($"OFF reading average value {num2}volts");
		RunSingleTest(onTestName);
		WriteLogMessage("SENSOR LED ON");
		Thread.Sleep(2000);
		for (int j = 0; j < sample; j++)
		{
			double analog_voltage_Indicator_LED_light_Sensor2 = fixtureInstance.Get_analog_voltage_Indicator_LED_light_Sensor();
			num += analog_voltage_Indicator_LED_light_Sensor2;
			WriteLogMessage($"ON reading {j} - {analog_voltage_Indicator_LED_light_Sensor2} volts");
		}
		num /= (double)sample;
		WriteLogMessage($"ON reading average value {num}volts");
		if (deprecated)
		{
			RunSingleTestWithWait(offTestName, 0);
		}
		else
		{
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, offTestName);
		}
		WriteLogMessage("SENSOR LED OFF");
		if (onOffDelta <= num - num2)
		{
			return true;
		}
		return false;
	}

	private void SetXYTableUnitToMetric()
	{
		xyTableInstance.isMetric = true;
		WriteLogMessage("Using METRIC - mm");
		xyTableInstance.setDimensionType();
	}

	public void CombineTextFile(string file1, string file2, string combined_file)
	{
		if (!File.Exists(file1))
		{
			file1 = file2;
		}
		if (!File.Exists(file2))
		{
			file2 = file1;
		}
		string text = "copy \"" + file1 + "\" + \"" + file2 + "\" \"" + combined_file + "\"";
		ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe", "/c " + text);
		processStartInfo.CreateNoWindow = true;
		processStartInfo.UseShellExecute = false;
		processStartInfo.RedirectStandardError = true;
		processStartInfo.RedirectStandardOutput = true;
		Process process = Process.Start(processStartInfo);
		process.WaitForExit();
	}

	private void SetGlobalVariable(string gvName, string gvValue)
	{
		base.Env.GlobalVariable.SetGlobalVariable(gvName, gvValue);
	}

	private void GetGlobalVariable(string gvName, out string gvValue)
	{
		base.Env.GlobalVariable.GetGlobalVariable(gvName, out gvValue);
	}

	private void WriteErrorMessage(string message)
	{
		base.Env.DebugMessage.Write("Error", message);
	}

	private void WriteDebugMessage(string message)
	{
		base.Env.DebugMessage.Write("Debug", message);
	}

	private void WriteLogMessage(string logMesssage)
	{
		base.Env.DebugMessage.Write("Log", logMesssage);
	}

	private void RunSingleTestWithWait(string methodName, ushort timeout, bool exit_previous_test = false)
	{
		WriteLogMessage($"\r\nRunSingleTestWithWait {methodName}...");
		if (!(previousTestName == "Not Tested"))
		{
			try
			{
				if (exit_previous_test)
				{
					phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, previousTestName);
					if (FTMErrorCode != 0)
					{
						WriteErrorMessage("Error sending FTM_AP_EXIT_TEST for:" + methodName + " -- error code: " + FTMErrorCode);
					}
				}
			}
			catch
			{
				WriteErrorMessage("Not support FTM_AP_EXIT_TEST");
			}
		}
		phone.FTM_AP_Execute_Single_Test_WithWait(methodName, ref FTMErrorCode, timeout, ref TestErrorCode, ref TimeOutOccurred);
		if (FTMErrorCode != 0)
		{
			WriteErrorMessage("Error sending FTM_AP_Execute_Single_Test_WithWait:" + methodName + " -- error code: " + FTMErrorCode);
		}
		else
		{
			previousTestName = methodName;
		}
	}

	private void RunSingleTest(string testName)
	{
		WriteLogMessage($"\r\nRunSingleTest {testName}...");
		phone.FTM_AP_Execute_Single_Test(testName, ref FTMErrorCode);
		Thread.Sleep(100);
	}

	private void GetResultsFile(string caseName = "", int waitTimeSeconds = 10)
	{
		string sLocalFile = ResultsFileName;
		Stopwatch stopwatch = new Stopwatch();
		stopwatch.Start();
		while (true)
		{
			FTMErrorCode = 0;
			bool result = false;
			InitializeResultsFile();
			phone.FTM_AP_ReadFile(ref FTMErrorCode, resultFileRemoteName, sLocalFile);
			if (FTMErrorCode == 0)
			{
				if (MMI_MODE != MMIMODE.QMMI)
				{
					WriteLogMessage("Got result file");
					return;
				}
				DeserialXmlResult(ResultsFileName);
				if (string.IsNullOrEmpty(caseName))
				{
					WriteLogMessage("Got result file");
					return;
				}
				if (FoundResultForTestCase_Xml(caseName, out result))
				{
					WriteLogMessage("Found result for " + caseName);
					return;
				}
				WriteLogMessage("Retry- get result for " + caseName);
			}
			else
			{
				WriteLogMessage("Retry- get result file(code - " + FTMErrorCode + "): " + resultFileRemoteName);
			}
			int num = (int)(waitTimeSeconds * 1000 - stopwatch.ElapsedMilliseconds);
			if (num <= 0)
			{
				break;
			}
			Thread.Sleep(500);
		}
		throw new Exception("\r\nGetResultsFile timeout");
	}

	private bool ResultFromResultsFile(string testName, int waitTimeSeconds = 10)
	{
		if (MMI_MODE == MMIMODE.QMMI)
		{
			bool result = false;
			FoundResultForTestCase_Xml(testName, out result);
			return result;
		}
		Stopwatch stopwatch = new Stopwatch();
		stopwatch.Start();
		List<INI_FileStructure> iNIFileDetails = MMI_INI_FileManager.GetINIFileDetails(ResultsFileName);
		foreach (INI_FileStructure item in iNIFileDetails)
		{
			if (item.sectionName == testName)
			{
				NameValue[] nameValueList = item.nameValueList;
				foreach (NameValue nameValue in nameValueList)
				{
					WriteLogMessage("\r\n" + nameValue.name + " = " + nameValue.value);
				}
			}
		}
		string text = "FAIL";
		while (true)
		{
			text = MMI_INI_FileManager.FindValueFromSectionWithName(iNIFileDetails, testName, "Result");
			if (text != "NOT FOUND")
			{
				break;
			}
			WriteLogMessage("Entry not found in result file, getting result file again");
			GetResultsFile();
			iNIFileDetails = MMI_INI_FileManager.GetINIFileDetails(ResultsFileName);
			int num = (int)(waitTimeSeconds * 1000 - stopwatch.ElapsedMilliseconds);
			if (num <= 0)
			{
				break;
			}
			Thread.Sleep(500);
		}
		if (text.ToUpper() == "PASS")
		{
			return true;
		}
		return false;
	}

	private string ResultFromResultsFile(string testName, string itemName, int waitTimeSeconds = 10, bool enable_log_msg = true)
	{
		string details = "";
		if (MMI_MODE == MMIMODE.QMMI)
		{
			bool result = false;
			if (FoundResultForTestCase_Xml(testName, out result))
			{
				ResultDetailsForTestCase_Xml(testName, itemName, out details);
			}
			return details;
		}
		Stopwatch stopwatch = new Stopwatch();
		stopwatch.Start();
		int millisecondsTimeout = 1000;
		while (true)
		{
			GetResultsFile();
			List<INI_FileStructure> iNIFileDetails = MMI_INI_FileManager.GetINIFileDetails(ResultsFileName);
			foreach (INI_FileStructure item in iNIFileDetails)
			{
				if (!(item.sectionName == testName))
				{
					continue;
				}
				if (enable_log_msg)
				{
					WriteLogMessage("\r\n --- " + testName + "------");
				}
				NameValue[] nameValueList = item.nameValueList;
				foreach (NameValue nameValue in nameValueList)
				{
					if (enable_log_msg)
					{
						WriteLogMessage("\r\n" + nameValue.name + " = " + nameValue.value);
					}
				}
			}
			try
			{
				details = MMI_INI_FileManager.FindValueFromSectionWithName(iNIFileDetails, testName, itemName);
			}
			catch (Exception)
			{
				details = "";
			}
			if (!(details == "NOT FOUND"))
			{
				break;
			}
			int num = (int)(waitTimeSeconds * 1000 - stopwatch.ElapsedMilliseconds);
			if (num > 0)
			{
				WriteLogMessage("\r\n Did not find " + itemName + " in " + testName + " try again");
				Thread.Sleep(millisecondsTimeout);
				continue;
			}
			WriteLogMessage("\r\n Not able to find " + itemName + " in " + testName + " - Give up");
			return details;
		}
		return details;
	}

	private bool[] CheckResultPresentInResultsFile(string testName)
	{
		WriteLogMessage("\r\n[" + testName + "]\r\n");
		bool[] array = new bool[2];
		List<INI_FileStructure> iNIFileDetails = MMI_INI_FileManager.GetINIFileDetails(ResultsFileName);
		foreach (INI_FileStructure item in iNIFileDetails)
		{
			if (item.sectionName == testName)
			{
				NameValue[] nameValueList = item.nameValueList;
				foreach (NameValue nameValue in nameValueList)
				{
					WriteLogMessage("\r\n" + nameValue.name + " = " + nameValue.value);
				}
			}
		}
		string text = "FAIL";
		text = MMI_INI_FileManager.FindValueFromSectionWithName(iNIFileDetails, testName, "Result");
		if (text != "NOT FOUND")
		{
			array[0] = true;
		}
		else
		{
			WriteLogMessage("Entry not found in result file, getting result file again");
			array[0] = false;
		}
		if (text.ToUpper() == "PASS")
		{
			array[1] = true;
			return array;
		}
		array[1] = false;
		return array;
	}

	private string GetTimestampFromResultsFile(string testName)
	{
		string text = "";
		FTMErrorCode = 0;
		InitializeResultsFile();
		phone.FTM_AP_ReadFile(ref FTMErrorCode, resultFileRemoteName, ResultsFileName);
		if (FTMErrorCode == 0)
		{
			List<INI_FileStructure> iNIFileDetails = MMI_INI_FileManager.GetINIFileDetails(ResultsFileName);
			foreach (INI_FileStructure item in iNIFileDetails)
			{
				if (item.sectionName == testName)
				{
					WriteLogMessage("\r\n --- " + testName + "------");
				}
			}
			try
			{
				text = MMI_INI_FileManager.FindValueFromSectionWithName(iNIFileDetails, testName, "Timestamp");
			}
			catch (Exception)
			{
				text = "";
			}
			if (text == "NOT FOUND")
			{
				text = "";
			}
		}
		else
		{
			text = "";
		}
		return text;
	}

	private string[] Result_List_FromResultsFile(string testName, string itemName)
	{
		string[] array = new string[5] { "", "", "", "", "" };
		int num = 0;
		int num2 = 5;
		List<INI_FileStructure> iNIFileDetails = MMI_INI_FileManager.GetINIFileDetails(ResultsFileName);
		foreach (INI_FileStructure item in iNIFileDetails)
		{
			if (!(item.sectionName == testName))
			{
				continue;
			}
			NameValue[] nameValueList = item.nameValueList;
			foreach (NameValue nameValue in nameValueList)
			{
				WriteLogMessage("\r\n" + nameValue.name + " = " + nameValue.value);
				if (nameValue.name == itemName && num < num2)
				{
					array[num] = nameValue.value;
					num++;
				}
			}
			return array;
		}
		return array;
	}

	private bool DeserialXmlResult(string resfile)
	{
		try
		{
			using FileStream fileStream = new FileStream(resfile, FileMode.Open, FileAccess.Read, FileShare.Read);
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(Result));
			xmlRes = (Result)xmlSerializer.Deserialize(fileStream);
			fileStream.Close();
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage("Deserial result xml fail: " + ex.Message);
			return false;
		}
	}

	private bool FoundResultForTestCase_Xml(string caseName, out bool result)
	{
		result = false;
		try
		{
			xmlRes4Case = new TestCase();
			foreach (TestCase item in xmlRes.TestCase)
			{
				if (item.name == caseName)
				{
					xmlRes4Case = item;
					if (xmlRes4Case.result.ToUpper() == "PASS")
					{
						result = true;
					}
					return true;
				}
			}
			return false;
		}
		catch
		{
			return false;
		}
	}

	private bool ResultDetailsForTestCase_Xml(string testName, string dataName, out string details)
	{
		details = "";
		try
		{
			bool result = false;
			if (FoundResultForTestCase_Xml(testName, out result))
			{
				foreach (Data datum in xmlRes4Case.DataSet.Data)
				{
					if (string.IsNullOrEmpty(dataName))
					{
						WriteLogMessage($"\r\n{datum.name} : {datum.Value}");
					}
					if (datum.name == dataName)
					{
						details = datum.Value;
						WriteLogMessage($"\r\n{datum.name} : {details}");
						break;
					}
				}
				return true;
			}
			return false;
		}
		catch
		{
			return false;
		}
	}

	private void EraseAllFilesFromPhone()
	{
		WriteLogMessage("Erasing all files from FTM AP folder");
		phone.FTM_AP_ERASE_ALL_FILES(ref FTMErrorCode);
		Thread.Sleep(200);
		CheckFTMErrorCodeWithErrorMessage("Failed to erase all files");
	}

	private void CheckFTMErrorCodeWithErrorMessage(string errorMessage)
	{
		if (FTMErrorCode != 0)
		{
			WriteErrorMessage(errorMessage);
		}
	}

	private void InitializeResultsFile()
	{
		if (File.Exists(ResultsFileName))
		{
			File.Delete(ResultsFileName);
			Thread.Sleep(30);
		}
	}

	private bool WritePCBAMMIStationConfigFlag(int currentStationIndex, StationFlagOptions status)
	{
		short num = 128;
		byte[] array = new byte[num];
		int itemID = 2499;
		try
		{
			phone.NVRead((nv_items_enum_type)itemID, array, num);
		}
		catch (Exception ex)
		{
			throw new Exception($"Failed to read station flag NV information from device - error message {ex.Message}");
		}
		array[currentStationIndex] = (byte)status;
		try
		{
			phone.NVWrite((nv_items_enum_type)itemID, array, num);
		}
		catch (Exception ex2)
		{
			throw new Exception($"Failed to write station flag NV information to device - error message {ex2.Message}");
		}
		try
		{
			phone.EFS_SyncWithWait(10);
		}
		catch (Exception ex3)
		{
			throw new Exception($"Failed to do EFS Sync - error message {ex3.Message}");
		}
		return true;
	}

	private void ReadSerialNumber(out string rSN)
	{
		rSN = "";
		byte[] array = new byte[128];
		try
		{
			phone.NVRead(nv_items_enum_type.NV_FACTORY_DATA_1_I, array, 128);
		}
		catch (Exception)
		{
			throw new PhoneException("Error reading SN from the phone");
		}
		byte[] array2 = array;
		foreach (byte b in array2)
		{
			if (b == 0)
			{
				break;
			}
			rSN += (char)b;
		}
	}

	public bool EnableFTMUtility(FTMUtilityOptions ftmUtilityOption, bool on)
	{
		if (on)
		{
			phone.FTM_AP_Utility(ref FTMErrorCode, (byte)ftmUtilityOption, 1);
		}
		else
		{
			phone.FTM_AP_Utility(ref FTMErrorCode, (byte)ftmUtilityOption, 0);
		}
		return true;
	}

	private string ConvertPIDToString(byte PID_MSB, byte PID_LSB, int MID)
	{
		int num = PID_MSB << 8;
		num += PID_LSB;
		string text = "";
		switch (MID)
		{
		case 535:
			text = num switch
			{
				192 => "WTR3605/3925", 
				200 => "WTR4905", 
				201 => "WTR3950(LTEU)", 
				204 => "WTR3956", 
				203 => "WTR5975", 
				202 => "WTR2955", 
				16 => "QFE1040", 
				17 => "QFE1045", 
				18 => "QFE1035", 
				19 => "QFE1055", 
				0 => "QFE2035FC", 
				80 => "QFE1510 v2.0", 
				1 => "QFE1520", 
				2 => "QFE1550", 
				3 => "QFE2520", 
				4 => "QFE2550", 
				5 => "QFE3510", 
				49 => "QFE2101", 
				32 => "QFE2310", 
				33 => "QFE2320/30/40", 
				35 => "QFE3345/E", 
				36 => "QFE3340FC", 
				37 => "QFE3330", 
				38 => "QFE3320", 
				41 => "QFE3350", 
				_ => "Unknown", 
			} + $"(0x{num:X})";
			break;
		case 432:
			switch (num)
			{
			case 38:
				text = "ASM_SP4T";
				break;
			case 0:
			case 2:
				text = "ASM_SP4T";
				break;
			default:
				text = "Unknown";
				break;
			}
			text += $"(0x{num:X})";
			break;
		case 263:
			text = num switch
			{
				3 => "PA_B13", 
				7 => "PA_B34_B39", 
				_ => "Unknown", 
			} + $"(0x{num:X})";
			break;
		case 308:
			switch (num)
			{
			case 24:
				text = "PA_B7";
				break;
			case 25:
				text = "PA_B17";
				break;
			case 44:
				text = "ASM_SP4T";
				break;
			case 27:
			case 82:
				text = "PA_B17_B28";
				break;
			case 26:
				text = "ASM_SP10T";
				break;
			case 6:
			case 29:
				text = "PA_B11_B21";
				break;
			default:
				text = "Unknown";
				break;
			}
			text += $"(0x{num:X})";
			break;
		case 524:
			text = num switch
			{
				129 => "ASM_SP12T", 
				136 => "ASM_SP10T", 
				32 => "ASM_SP6T", 
				131 => "ASM_SP4T", 
				_ => "Unknown", 
			} + $"(0x{num:X})";
			break;
		default:
			text = text + "Unknown" + $"(0x{num:X})";
			break;
		}
		return text.PadRight(20);
	}

	private string ConvertToMID(byte MSB, byte LSB, ref int ManufactureID)
	{
		int num = MSB << 8;
		num = (ManufactureID = num + LSB);
		string text = "";
		text = num switch
		{
			535 => "QUALCOMM", 
			308 => "RF MICRO", 
			432 => "SONY", 
			263 => "AVAGO", 
			524 => "MURATA", 
			_ => "Unknown", 
		} + $"(0x{num:X})";
		return text.PadRight(15);
	}

	private bool GetRFFE_ScanFileFromDevice()
	{
		try
		{
			phone.EFSReadFile(rffe_scan_local_path, "rfc/rffe_scan/rffe_scan.dat");
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage($"Failed to get RFFE scan file from device - ErrorMessage - {ex.Message}");
			return false;
		}
	}

	private bool ParseRFFEScanFile(out int numberOfDeviceInstancesPresent)
	{
		byte[] array = new byte[2048];
		numberOfDeviceInstancesPresent = 0;
		try
		{
			if (!File.Exists(rffe_scan_local_path))
			{
				WriteErrorMessage($"Failed to find RFFE scan on PC @ {rffe_scan_local_path}");
				return false;
			}
			long length;
			using (FileStream fileStream = new FileStream(rffe_scan_local_path, FileMode.Open))
			{
				fileStream.Seek(0L, SeekOrigin.Begin);
				length = fileStream.Length;
				for (int i = 0; i < fileStream.Length; i++)
				{
					array[i] = (byte)fileStream.ReadByte();
				}
				fileStream.Close();
			}
			string logMesssage = "File Size = " + length;
			WriteLogMessage(logMesssage);
			logMesssage = "File Version = " + array[0];
			WriteLogMessage(logMesssage);
			if (array[0] == 1 || array[0] == 2)
			{
				logMesssage = "RFHW ID = " + array[12];
				WriteLogMessage(logMesssage);
				logMesssage = "Number of Device Instances = " + array[16];
				WriteLogMessage(logMesssage);
				logMesssage = "Number of Device Instances Present = " + array[20];
				numberOfDeviceInstancesPresent = array[20];
				WriteLogMessage(logMesssage);
				if (array[0] == 2)
				{
					logMesssage = "Error Code = " + array[24];
					WriteLogMessage(logMesssage);
				}
				long num = 44L;
				long num2 = 24L;
				if (array[0] == 1)
				{
					num2 = 24L;
				}
				else if (array[0] == 2)
				{
					num2 = 28L;
				}
				long num3 = (length - num2) / num;
				logMesssage = "";
				WriteLogMessage(logMesssage);
				logMesssage = "Dev Inst, BUS, MID,        PID,           P_REV, USID, Status";
				WriteLogMessage(logMesssage);
				logMesssage = "---------------------------------------------------------------";
				WriteLogMessage(logMesssage);
				for (int j = 0; j < num3; j++)
				{
					logMesssage = array[num2 + j * num + 4].ToString().PadRight(3) + ",";
					logMesssage = logMesssage + array[num2 + j * num + 12].ToString().PadRight(3) + ",";
					int ManufactureID = 0;
					logMesssage = logMesssage + ConvertToMID(array[num2 + j * num + 17], array[num2 + j * num + 16], ref ManufactureID) + ", ";
					logMesssage = logMesssage + ConvertPIDToString(array[num2 + j * num + 21], array[num2 + j * num + 20], ManufactureID) + ", ";
					logMesssage = logMesssage + $"0x{array[num2 + j * num + 24]:X}".PadRight(2) + ",";
					logMesssage = logMesssage + $"0x{array[num2 + j * num + 36]:X}".PadRight(2) + ",";
					logMesssage += ConvertDeviceStatus(array[num2 + j * num + 40]);
					WriteLogMessage(logMesssage);
				}
			}
			else
			{
				logMesssage = "Unsupported file version number";
				WriteLogMessage(logMesssage);
			}
			return true;
		}
		catch (Exception ex)
		{
			WriteErrorMessage(ex.Message);
			return false;
		}
	}

	private string ConvertDeviceStatus(byte status)
	{
		return status switch
		{
			0 => "PRESENT", 
			1 => "MISSING_NON_FATAL", 
			2 => "MISSING_FATAL", 
			_ => "UNKNOWN STATUS", 
		};
	}

	private bool SetAudioExLoopbackHeadset(USB_IO_Expander.MUX_Control SPKR_L_or_R)
	{
		bool IO_OUT = true;
		USB_IO_Expander.SetValue setBit = USB_IO_Expander.SetValue.LOW;
		try
		{
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_SINE_OUT, ref setBit, ref IO_OUT);
			Thread.Sleep(100);
			fixtureInstance.Individual_Control(USB_IO_Expander.IndividualControl.RLY_POGO_AMP_N, ref setBit, ref IO_OUT);
			Thread.Sleep(100);
			fixtureInstance.Set_Mux_Select(100, SPKR_L_or_R);
			Thread.Sleep(100);
			setBit = USB_IO_Expander.SetValue.HIGH;
			fixtureInstance.Set_Mux_Select(100, SPKR_L_or_R);
			Thread.Sleep(100);
			fixtureInstance.Set_Mux_Select(100, USB_IO_Expander.MUX_Control.RLY_MIC2_OUT);
			Thread.Sleep(100);
			RunSingleTestWithWait("AUDIO_Ex_LOOPBACK_HEADSET", 0);
			return true;
		}
		catch
		{
			WriteLogMessage("Error in seting up AUDIO_Ex_LOOPBACK_HEADSET");
			return false;
		}
	}

	private bool run_test_get_result(string methodName, string result_key_word, ushort timeOutSeconds, out string result_string, int time_delay_ms, int retry_get_res = 0)
	{
		result_string = "";
		try
		{
			RunSingleTestWithWait(methodName, timeOutSeconds);
			for (int i = 0; i < retry_get_res; i++)
			{
				Thread.Sleep(time_delay_ms);
				GetResultsFile();
			}
			result_string = ResultFromResultsFile(methodName, result_key_word);
			phone.FTM_AP_EXIT_TEST(ref FTMErrorCode, 2u, methodName);
			return true;
		}
		catch (Exception ex)
		{
			WriteLogMessage("Failed to find " + result_key_word + " for " + methodName + " test in result file");
			WriteLogMessage(methodName + ex.Message);
			return false;
		}
	}

	public void EarpieceTest()
	{
		bool retractWhenDone = false;
		bool moveWhileDownOK = false;
		if (!xyTableInstance.zMoveToAndPress(xyLOCATE.EARPIECE.ToString(), useOffsets: false, ref msg, moveDiagnal: false, moveWhileDownOK, retractWhenDone))
		{
			WriteErrorMessage("Error:" + msg);
		}
	}

	public void TouchSwipe()
	{
		bool retractWhenDone = true;
		bool useOffsets = false;
		if (!xyTableInstance.zTouchSwipe(xyLOCATE.KEYPD_7.ToString(), xyLOCATE.KEYPD_9.ToString(), useOffsets, retractWhenDone))
		{
			WriteErrorMessage("Error in TouchSwipte command or no response from controller");
		}
	}

	public void ZRetractAll()
	{
		xyTableInstance.zRetractAll();
	}

	public void MoveHome(bool enable_partialRetract = true, bool enableProxPosition = true)
	{
		xyTableInstance.zRetractAll();
		int x = 100;
		int y = 100;
		int z = 0;
		int z2 = 0;
		if (enableProxPosition && !xyTableInstance.GetPositions(ref x, ref y, ref z, ref z2))
		{
			msg += "\r\nfail to get xyTable position info";
		}
		if (x > 20 || y > 20)
		{
			if (enable_partialRetract)
			{
				if (!xyTableInstance.MoveXYHome_Z_partialRetract())
				{
					WriteErrorMessage("Error in MoveXYHome_Z_partialRetract command or no reponse from controller");
				}
			}
			else if (!xyTableInstance.MoveXYHome())
			{
				WriteErrorMessage("Errorin MoveXYHome command or no reponse from controller");
			}
		}
		Thread.Sleep(100);
	}

	public void HomeKey(bool enablePartialRetract = false)
	{
		string text = xyLOCATE.HOME_KEY.ToString();
		if (!enablePartialRetract)
		{
			xyTableInstance.zRetractAll();
		}
		else if (xyTableInstance.safeZoneStatus(text))
		{
			xyTableInstance.zRetract_partial(DUT_zone: true);
		}
		else
		{
			xyTableInstance.zRetract_partial();
		}
		string text2 = "";
		bool moveWhileDownOK = true;
		bool retractWhenDone = false;
		bool moveDiagnal = false;
		bool useOffsets = false;
		if (!xyTableInstance.zMoveToAndPress(text, useOffsets, ref text2, moveDiagnal, moveWhileDownOK, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text2);
		}
		if (!enablePartialRetract)
		{
			xyTableInstance.zRetractAll();
		}
		else if (xyTableInstance.safeZoneStatus(text))
		{
			xyTableInstance.zRetract_partial(DUT_zone: true);
		}
		else
		{
			xyTableInstance.zRetract_partial();
		}
	}

	public void AllSideKeyPush(bool HoldKeyPress = true, bool HoldBetweenKey = true, int holdTime_ms = 100, int delay_bewteen_key = 100, bool push_home_Key = false)
	{
		string text = "";
		bool flag = false;
		bool retractWhenDone = false;
		bool moveDiagnal = false;
		bool flag2 = false;
		string text2 = xyLOCATE.VOLUP.ToString();
		xyTableInstance.zMoveToAndPress_partialRetract(text2, enablePartialRetract: true);
		flag2 = true;
		flag = true;
		if (!xyTableInstance.zMoveToAndPress(text2, flag2, ref text, moveDiagnal, flag, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		if (HoldKeyPress)
		{
			Thread.Sleep(holdTime_ms);
		}
		flag2 = false;
		retractWhenDone = false;
		if (!xyTableInstance.zMoveToAndPress(text2, flag2, ref text, moveDiagnal, flag, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		if (HoldBetweenKey)
		{
			Thread.Sleep(delay_bewteen_key);
		}
		text2 = xyLOCATE.VOLDWN.ToString();
		if (!xyTableInstance.zMoveToAndPress(text2, flag2, ref text, moveDiagnal, flag, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		flag2 = true;
		if (!xyTableInstance.zMoveToAndPress(text2, flag2, ref text, moveDiagnal, flag, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		if (HoldKeyPress)
		{
			Thread.Sleep(holdTime_ms);
		}
		flag2 = false;
		if (!xyTableInstance.zMoveToAndPress(text2, flag2, ref text, moveDiagnal, flag, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		if (HoldBetweenKey)
		{
			Thread.Sleep(delay_bewteen_key);
		}
		text2 = xyLOCATE.PWR.ToString();
		if (!xyTableInstance.zMoveToAndPress(text2, flag2, ref text, moveDiagnal, flag, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		flag2 = true;
		if (!xyTableInstance.zMoveToAndPress(text2, flag2, ref text, moveDiagnal, flag, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		if (HoldKeyPress)
		{
			Thread.Sleep(holdTime_ms);
		}
		flag2 = false;
		retractWhenDone = false;
		if (!xyTableInstance.zMoveToAndPress(text2, flag2, ref text, moveDiagnal, flag, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		if (push_home_Key)
		{
			HomeKey(enablePartialRetract: true);
		}
	}

	public void ReleasePhoneLever(string ReleaseLeverName = "LEVER1", bool moveWhileDownOK = false)
	{
		string text = "";
		bool retractWhenDone = true;
		bool moveDiagnal = false;
		bool useOffsets = false;
		if (!xyTableInstance.zMoveToAndPress(ReleaseLeverName, useOffsets, ref text, moveDiagnal, moveWhileDownOK, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		xyTableInstance.phoneIsReleased = true;
	}

	public void PressDownSideLever(bool moveWhileDownOK = false)
	{
		string text = "";
		bool retractWhenDone = false;
		bool moveDiagnal = false;
		bool useOffsets = false;
		string xyLocation = xyLOCATE.LEVER1.ToString();
		if (!xyTableInstance.zMoveToAndPress(xyLocation, useOffsets, ref text, moveDiagnal, moveWhileDownOK, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
		if (cradleType == 1)
		{
			xyTableInstance.phoneIsReleased = true;
		}
	}

	public void TopPhoneLever(bool moveWhileDownOK = false)
	{
		string text = "";
		bool retractWhenDone = false;
		bool moveDiagnal = false;
		bool useOffsets = false;
		string xyLocation = xyLOCATE.LEVER2.ToString();
		if (!xyTableInstance.phoneIsReleased)
		{
			WriteErrorMessage("CAUTION: The Release Lever must be pressed first.");
		}
		else if (!xyTableInstance.zMoveToAndPress(xyLocation, useOffsets, ref text, moveDiagnal, moveWhileDownOK, retractWhenDone))
		{
			WriteErrorMessage("Error:" + text);
		}
	}

	public bool getDelta_to_target_POS(string LocName, ref int Delta_x, ref int Delta_y, ref int Delta_z1, ref int Delta_z2, ref string msg, bool useOffset = false)
	{
		try
		{
			int x = 0;
			int y = 0;
			int z = 0;
			int z2 = 0;
			int x2 = 0;
			int y2 = 0;
			int z3 = 0;
			int z4 = 0;
			if (!xyTableInstance.GetPositions(ref x, ref y, ref z, ref z2))
			{
				msg += "\r\nfail to get xyTable position info";
			}
			if (!xyTableInstance.GetCfgPOS(LocName, ref x2, ref y2, ref z3, ref z4, useOffset, ref msg))
			{
				msg += "failed to get xyTable position info";
			}
			Delta_x = x2 - x;
			Delta_y = y2 - y;
			Delta_z1 = z3 - z;
			Delta_z2 = z4 - z2;
			return true;
		}
		catch (Exception ex)
		{
			msg += ex.Message;
			return false;
		}
	}
}
