private bool outputONTTXOpticalPower(string _index, Button b)
        {
            try {
                b.Background = Brushes.Lime;
                string _comPort = "";
                switch (_index)
                {
                case "1": { _comPort = GlobalData.initSetting.USBDEBUG1; break; }

                case "2": { _comPort = GlobalData.initSetting.USBDEBUG2; break; }

                case "3": { _comPort = GlobalData.initSetting.USBDEBUG3; break; }

                case "4": { _comPort = GlobalData.initSetting.USBDEBUG4; break; }
                }

                Thread t = new Thread(new ThreadStart(() => {
                    bool ret       = false;
                    string message = "";
                    GW ont         = null;
                    try {
                        switch (GlobalData.initSetting.ONTTYPE)
                        {
                        case "GW040H": { ont = new GW040H(_comPort); break; }

                        case "GW020BoB": { ont = new GW020BoB(_comPort); break; }

                        default: break;
                        }
                        if (!ont.Open(out message))
                        {
                            ret = false;
                        }
                        else
                        {
                            ret = ont.Login(out message);
                        }

                        ont.outTXPower();
                        Thread.Sleep(1000);
                        message = ont.Read();
                    }
                    catch (Exception ex) {
                        message = ex.ToString();
                    }
                    MessageBox.Show(string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL"), "OUTPUT TX POWER", MessageBoxButton.OK, ret == true ? MessageBoxImage.Information : MessageBoxImage.Error);
                    try { ont.Close(); } catch { }
                    App.Current.Dispatcher.Invoke(new Action(() => {
                        b.Background = (SolidColorBrush) new BrushConverter().ConvertFrom("#777777");
                    }));
                }));
                t.IsBackground = true;
                t.Start();
                return(true);
            }
            catch {
                return(false);
            }
        }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            GlobalData.manualTest.IQS610PLOG    = "";
            GlobalData.manualTest.DCAX86100DLOG = "";
            GlobalData.manualTest.ONTLOG        = "";

            switch (b.Name)
            {
            case "IQSconn": {
                Thread t = new Thread(new ThreadStart(() => {
                        bool ret       = false;
                        string message = "";

                        //CONNECT TO IQS1700
                        GlobalData.manualTest.IQS610PLOG += "Connecting to IQS1700...\n";
                        GlobalData.powerDevice            = new IQS1700(GlobalData.initSetting.EXFOIP, GlobalData.initSetting.EXFOPORT);
                        message = "";
                        ret     = GlobalData.powerDevice.Open(out message);
                        GlobalData.manualTest.IQS610PLOG += message + "\n";
                        GlobalData.manualTest.IQS610PLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                        //CONNECT TO IQS9100B
                        GlobalData.manualTest.IQS610PLOG += "Connecting to IQS9100B...\n";
                        GlobalData.switchDevice           = new IQS9100B(GlobalData.initSetting.EXFOIP, GlobalData.initSetting.EXFOPORT);
                        message = "";
                        ret     = GlobalData.switchDevice.Open(out message);
                        GlobalData.manualTest.IQS610PLOG += message + "\n";
                        GlobalData.manualTest.IQS610PLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            case "IQSinit": {
                Thread t = new Thread(new ThreadStart(() => {
                        bool ret       = false;
                        string message = "";
                        //KHỞI TẠO MODULE IQS1700
                        GlobalData.manualTest.IQS610PLOG += "Initializing module IQS1700...\n";
                        message = "";
                        try {
                            ret = GlobalData.powerDevice.Initialize();
                        }
                        catch (Exception ex) {
                            message = ex.ToString();
                        }
                        GlobalData.manualTest.IQS610PLOG += message + "\n";
                        GlobalData.manualTest.IQS610PLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");

                        //KHỞI TẠO MODULE IQS9100B
                        GlobalData.manualTest.IQS610PLOG += "Initializing module IQS9100B...\n";
                        message = "";
                        try {
                            ret = GlobalData.switchDevice.Initialize();
                        } catch (Exception ex) {
                            message = ex.ToString();
                        }
                        GlobalData.manualTest.IQS610PLOG += message + "\n";
                        GlobalData.manualTest.IQS610PLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            case "IQSgetdBm": {
                Thread t = new Thread(new ThreadStart(() => {
                        GlobalData.manualTest.IQS610PLOG += string.Format("Read power dBm of module IQS1700 Rack {0}...\n", GlobalData.initSetting.PWINSTRPORT);
                        string message = "";
                        try {
                            double value1 = 0, value2 = 0, value3 = 0, value4 = 0;
                            Thread t1     = new Thread(new ThreadStart(() => {
                                value1 = double.Parse(GlobalData.powerDevice.getPower_dBm_NoAtt(1));
                            }));
                            t1.IsBackground = true;
                            t1.Start();
                            Thread t2 = new Thread(new ThreadStart(() => {
                                value2 = double.Parse(GlobalData.powerDevice.getPower_dBm_NoAtt(2));
                            }));
                            t2.IsBackground = true;
                            t2.Start();
                            Thread t3 = new Thread(new ThreadStart(() => {
                                value3 = double.Parse(GlobalData.powerDevice.getPower_dBm_NoAtt(3));
                            }));
                            t3.IsBackground = true;
                            t3.Start();
                            Thread t4 = new Thread(new ThreadStart(() => {
                                value4 = double.Parse(GlobalData.powerDevice.getPower_dBm_NoAtt(4));
                            }));
                            t4.IsBackground = true;
                            t4.Start();
                            while (t1.IsAlive == true || t2.IsAlive == true || t3.IsAlive == true || t4.IsAlive == true)
                            {
                                Thread.Sleep(100);
                            }
                            message += "Channel1: " + value1.ToString() + " dBm\n";
                            message += "Channel2: " + value2.ToString() + " dBm\n";
                            message += "Channel3: " + value3.ToString() + " dBm\n";
                            message += "Channel4: " + value4.ToString() + " dBm\n";
                        }
                        catch (Exception ex) {
                            message = ex.ToString();
                        }
                        GlobalData.manualTest.IQS610PLOG += message + "\n";
                        GlobalData.manualTest.IQS610PLOG += string.Format("=> Result: {0}\n", "PASS");
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            case "IQSgetmW": {
                //Thread t = new Thread(new ThreadStart(() => {
                //    GlobalData.manualTest.IQS610PLOG += string.Format("Read power Watt of module IQS1700 at Port...\n");
                //    string message = "";
                //    try {
                //        double value1 = 0, value2 = 0, value3 = 0, value4 = 0;
                //        Thread t1 = new Thread(new ThreadStart(() => {
                //            value1 = BaseFunctions.convert_dBm_To_uW(GlobalData.powerDevice.getPower_dBm(1));
                //        }));
                //        t1.IsBackground = true;
                //        t1.Start();
                //        Thread t2 = new Thread(new ThreadStart(() => {
                //            value2 = BaseFunctions.convert_dBm_To_uW(GlobalData.powerDevice.getPower_dBm(2));
                //        }));
                //        t2.IsBackground = true;
                //        t2.Start();
                //        Thread t3 = new Thread(new ThreadStart(() => {
                //            value3 = BaseFunctions.convert_dBm_To_uW(GlobalData.powerDevice.getPower_dBm(3));
                //        }));
                //        t3.IsBackground = true;
                //        t3.Start();
                //        Thread t4 = new Thread(new ThreadStart(() => {
                //            value4 = BaseFunctions.convert_dBm_To_uW(GlobalData.powerDevice.getPower_dBm(4));
                //        }));
                //        t4.IsBackground = true;
                //        t4.Start();
                //        while (t1.IsAlive == true || t2.IsAlive == true || t3.IsAlive == true || t4.IsAlive == true) { Thread.Sleep(100); }
                //        message += "Channel1: " + value1.ToString() + " uW\n";
                //        message += "Channel2: " + value2.ToString() + " uW\n";
                //        message += "Channel3: " + value3.ToString() + " uW\n";
                //        message += "Channel4: " + value4.ToString() + " uW\n";
                //    }
                //    catch (Exception ex) {
                //        message = ex.ToString();
                //    }
                //    GlobalData.manualTest.IQS610PLOG += message + "\n";
                //    GlobalData.manualTest.IQS610PLOG += string.Format("=> Result: {0}\n", "PASS");
                //}));
                //t.IsBackground = true;
                //t.Start();
                break;
            }

            case "IQSSwitch": {
                SelectPort sp = new SelectPort();
                sp.ShowDialog();
                int _port = 0;
                if (sp.PortSelected.Trim() == "")
                {
                    return;
                }
                else
                {
                    _port = int.Parse(sp.PortSelected);
                }
                Thread t = new Thread(new ThreadStart(() => {
                        bool ret       = false;
                        string message = "";
                        GlobalData.manualTest.IQS610PLOG += string.Format("Switch module IQS9100B to Port{0}...\n", _port);
                        message = "";
                        try {
                            ret = GlobalData.switchDevice.switchToPort(_port);
                        }
                        catch (Exception ex) {
                            message = ex.ToString();
                        }
                        GlobalData.manualTest.IQS610PLOG += message + "\n";
                        GlobalData.manualTest.IQS610PLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            case "DCAcalib": {
                //Ngắt kết nối Switch quang
                GlobalData.manualTest.DCAX86100DLOG += string.Format("Switch off cổng kết nối quang...\n");
                bool kq = GlobalData.switchDevice.switchOff();
                GlobalData.manualTest.DCAX86100DLOG += string.Format("=> Result: {0}\n", kq == true ? "PASS" : "FAIL");
                if (kq == false)
                {
                    return;
                }

                //Calib máy đo ER
                CalibratingWindow cw = new CalibratingWindow();
                Thread            t  = new Thread(new ThreadStart(() => {
                        bool ret       = false;
                        string message = "";
                        App.Current.Dispatcher.Invoke(new Action(() => { cw.Show(); }));

                        GlobalData.manualTest.DCAX86100DLOG += string.Format("Calibrating DCAX86100D...\n");
                        message = "";
                        try {
                            ret = GlobalData.erDevice.ManualCalibrate();
                            CalibrationModuleTime.Write();
                        }
                        catch (Exception ex) {
                            message = ex.ToString();
                        }

                        App.Current.Dispatcher.Invoke(new Action(() => { cw.Close(); }));
                        GlobalData.manualTest.DCAX86100DLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                        if (ret == true)
                        {
                            App.Current.Dispatcher.Invoke(new Action(() => {
                                MessageBox.Show("Tool sẽ tự động đóng.\nVui lòng mở lại tool để tiếp tục calib sản phẩm.", "Đóng tool", MessageBoxButton.OK, MessageBoxImage.Information);
                                Environment.Exit(0);
                            }));
                        }
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            case "DCAgetdBm": {
                SelectPort sp = new SelectPort();
                sp.ShowDialog();
                int _port = 0;
                if (sp.PortSelected.Trim() == "")
                {
                    return;
                }
                else
                {
                    _port = int.Parse(sp.PortSelected);
                }
                Thread t = new Thread(new ThreadStart(() => {
                        bool ret       = false;
                        string message = "";
                        //Switch Port IQS9100B
                        GlobalData.manualTest.DCAX86100DLOG += string.Format("Switch module IQS9100B to Port{0}...\n", _port);
                        message = "";
                        try {
                            ret = GlobalData.switchDevice.switchToPort(_port);
                        }
                        catch (Exception ex) {
                            message = ex.ToString();
                        }
                        GlobalData.manualTest.DCAX86100DLOG += message + "\n";
                        GlobalData.manualTest.DCAX86100DLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                        if (!ret)
                        {
                            return;
                        }

                        //Get Power
                        GlobalData.manualTest.DCAX86100DLOG += string.Format("Getting Power value (dBm) from DCAX86100D...\n");
                        message = "";
                        try {
                            message = double.Parse(GlobalData.erDevice.getdBm().Replace("\r", "").Replace("\n", "")).ToString();
                        }
                        catch (Exception ex) {
                            message = ex.ToString();
                        }
                        GlobalData.manualTest.DCAX86100DLOG += message + " dBm\n";
                        GlobalData.manualTest.DCAX86100DLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            case "DCAgetER": {
                SelectPort sp = new SelectPort();
                sp.ShowDialog();
                int _port = 0;
                if (sp.PortSelected.Trim() == "")
                {
                    return;
                }
                else
                {
                    _port = int.Parse(sp.PortSelected);
                }

                Thread t = new Thread(new ThreadStart(() => {
                        bool ret       = false;
                        string message = "";
                        GlobalData.manualTest.DCAX86100DLOG += string.Format("Getting ER value from DCAX86100D Port{0}...\n", _port);
                        message = "";
                        try {
                            message = GlobalData.erDevice.getER(_port);
                        }
                        catch (Exception ex) {
                            message = ex.ToString();
                        }
                        GlobalData.manualTest.DCAX86100DLOG += message + "\n";
                        GlobalData.manualTest.DCAX86100DLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            case "ONTlogin": {
                //SelectPort sp = new SelectPort();
                //sp.ShowDialog();
                //int _port = 1;
                //if (sp.PortSelected.Trim() == "") return;
                //else _port = int.Parse(sp.PortSelected);
                //string _comPort = "";
                //switch (_port) {
                //    case 1: { _comPort = GlobalData.initSetting.USBDEBUG1; break; }
                //    case 2: { _comPort = GlobalData.initSetting.USBDEBUG2; break; }
                //    case 3: { _comPort = GlobalData.initSetting.USBDEBUG3; break; }
                //    case 4: { _comPort = GlobalData.initSetting.USBDEBUG4; break; }
                //}

                //Thread t = new Thread(new ThreadStart(() => {
                //    bool ret = false;
                //    string message = "";
                //    GlobalData.manualTest.ONTLOG += string.Format("Login to ONT {0}...\n", _comPort);
                //    GW ont = null;
                //    try {
                //        switch (GlobalData.initSetting.ONTTYPE) {
                //            case "GW040H": { ont = new GW040H(_comPort);break; }
                //            case "GW020BoB": { ont = new GW020BoB(_comPort); break; }
                //            default: break;
                //        }
                //        if (!ont.Open(out message)) ret = false;
                //        else ret = ont.Login(out message);
                //    }
                //    catch (Exception ex) {
                //        message = ex.ToString();
                //    }
                //    GlobalData.manualTest.ONTLOG += message + "\n";
                //    GlobalData.manualTest.ONTLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                //    try { ont.Close(); } catch { }
                //}));
                //t.IsBackground = true;
                //t.Start();
                break;
            }

            case "ONTtx": {
                SelectPort sp = new SelectPort();
                sp.ShowDialog();
                int _port = 0;
                if (sp.PortSelected.Trim() == "")
                {
                    return;
                }
                else
                {
                    _port = int.Parse(sp.PortSelected);
                }
                string _comPort = "";
                switch (_port)
                {
                case 1: { _comPort = GlobalData.initSetting.USBDEBUG1; break; }

                case 2: { _comPort = GlobalData.initSetting.USBDEBUG2; break; }

                case 3: { _comPort = GlobalData.initSetting.USBDEBUG3; break; }

                case 4: { _comPort = GlobalData.initSetting.USBDEBUG4; break; }
                }

                Thread t = new Thread(new ThreadStart(() => {
                        bool ret       = false;
                        string message = "";
                        GW ont         = null;
                        try {
                            GlobalData.manualTest.ONTLOG += string.Format("Login to ONT {0}...\n", _comPort);
                            switch (GlobalData.initSetting.ONTTYPE)
                            {
                            case "GW040H": { ont = new GW040H(_comPort); break; }

                            case "GW020BoB": { ont = new GW020BoB(_comPort); break; }

                            default: break;
                            }
                            if (!ont.Open(out message))
                            {
                                ret = false;
                            }
                            else
                            {
                                ret = ont.Login(out message);
                            }
                            GlobalData.manualTest.ONTLOG += message + "\n";

                            GlobalData.manualTest.ONTLOG += string.Format("Send command to request ONT output optical Power {0}...\n", _comPort);
                            ont.outTXPower();
                            Thread.Sleep(1000);
                            message = ont.Read();
                            GlobalData.manualTest.ONTLOG += message + "\n";
                        }
                        catch (Exception ex) {
                            message = ex.ToString();
                            GlobalData.manualTest.ONTLOG += message + "\n";
                        }
                        GlobalData.manualTest.ONTLOG += string.Format("=> Result: {0}\n", ret == true ? "PASS" : "FAIL");
                        try { ont.Close(); } catch { }
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            default: break;
            }
        }
        //----RUN ALL
        //****************************************************************************************************
        //****************************************************************************************************
        //****************************************************************************************************
        bool RunAll(testinginfo _testtemp, bosainfo _bosainfo, variables _vari)
        {
            System.Diagnostics.Stopwatch pt = new System.Diagnostics.Stopwatch();
            pt.Start();
            bool   _result  = false;
            string _message = "";

            GW      ontDevice  = null;
            FVA3150 instrument = null;

            switch (globalData.initSetting.ONTTYPE)
            {
            case "GW040H": {
                ontDevice = new GW040H(_testtemp.COMPORT);
                break;
            }

            case "GW020BoB": {
                ontDevice = new GW020BoB(_testtemp.COMPORT);
                break;
            }

            default: return(false);
            }

            //Connect to Instrument
            _testtemp.SYSTEMLOG += string.Format("Connect to FVA3150 {0}...\r\n", _testtemp.GPIB);
            instrument           = new FVA3150(_testtemp.GPIB);
            if (instrument.Open(out _message) == false)
            {
                _testtemp.SYSTEMLOG += "...FAIL" + "\r\n";
                _testtemp.SYSTEMLOG += _message + "\r\n";
                goto END;
            }
            _testtemp.SYSTEMLOG += "...PASS" + "\r\n";

            //login to ONT
            if (ontDevice.loginToONT(_testtemp) == false)
            {
                goto END;
            }


            //Get MAC Address
            _testtemp.MACADDRESS = ontDevice.getMACAddress(_testtemp);
            if (_testtemp.MACADDRESS == string.Empty)
            {
                _testtemp.ERRORCODE = "(Mã Lỗi: COT-GM-0001)"; goto END;
            }


            //Set Vapd + Slope
            if (globalData.initSetting.ONTTYPE == "GW040H")
            {
                if (ontDevice.setVapdAndSlope(_bosainfo, _testtemp, instrument, _vari) == false)
                {
                    goto END;
                }
                pt.Stop();
                _testtemp.SYSTEMLOG += string.Format("Set Vadp + Slope time = {0} ms\r\n", pt.ElapsedMilliseconds);
            }


            //Overload + Sensitivity
            if (globalData.initSetting.ONTTYPE == "GW040H")
            {
                if (ontDevice.overloadSensitivity(_bosainfo, _testtemp, instrument, _vari) == false)
                {
                    goto END;
                }
                pt.Stop();
                _testtemp.SYSTEMLOG += string.Format("Overload + Sensitivity time = {0} ms\r\n", pt.ElapsedMilliseconds);
            }


            //RX DDMI Calibration
            if (ontDevice.calibDDMI(_bosainfo, _testtemp, instrument, _vari) == false)
            {
                goto END;
            }
            pt.Stop();
            _testtemp.SYSTEMLOG += string.Format("RX DDMI Calibration time = {0} ms\r\n", pt.ElapsedMilliseconds);

            //RX DDMI Curve
            if (globalData.initSetting.ONTTYPE == "GW040H")
            {
                if (ontDevice.curveDDMI(_bosainfo, _testtemp, instrument, _vari) == false)
                {
                    goto END;
                }
                pt.Stop();
                _testtemp.SYSTEMLOG += string.Format("RX DDMI Curve time = {0} ms\r\n", pt.ElapsedMilliseconds);
            }

            //LOS Calibration
            bool _flag = false;

            if (ontDevice.calibLOS(_bosainfo, _testtemp, instrument, _vari, ref _flag) == false)
            {
                goto END;
            }
            pt.Stop();
            _testtemp.SYSTEMLOG += string.Format("LOS Calibration time = {0} ms\r\n", pt.ElapsedMilliseconds);

            //LOS Check
            if (globalData.initSetting.ONTTYPE == "GW040H")
            {
                if (ontDevice.checkLOS(_flag, _bosainfo, _testtemp, instrument, _vari) == false)
                {
                    goto END;
                }
                pt.Stop();
                _testtemp.SYSTEMLOG += string.Format("LOS check time = {0} ms\r\n", pt.ElapsedMilliseconds);
            }

            //Write Flash
            if (globalData.initSetting.ONTTYPE == "GW040H")
            {
                if (ontDevice.writeFlash(_bosainfo, _testtemp) == false)
                {
                    goto END;
                }
                pt.Stop();
                _testtemp.SYSTEMLOG += string.Format("Write flash time = {0} ms\r\n", pt.ElapsedMilliseconds);
            }

            _result = true;

END:
            try { ontDevice.Close(); } catch { }
            return(_result);
        }
Пример #4
0
        //****************************************************************************************************
        //****************************************************************************************************
        //****************************************************************************************************
        bool RunAll(testinginfo _testtemp, bosainfo _bosainfo, variables _vari)
        {
            System.Diagnostics.Stopwatch pt = new System.Diagnostics.Stopwatch();
            pt.Start();
            string _apdTime = "", _pwTime = "", _erTime = "", _ddmiTime = "";


            if (!(GlobalData.initSetting.ONTTYPE == "GW020BoB" && GlobalData.initSetting.ONTAPD == "Only Write APD LUT"))
            {
                //Kiem tra ket noi toi may do Power
                _testtemp.SYSTEMLOG += string.Format("Kiểm tra kết nối tới máy đo EXFO IQS610P {0}...\r\n", GlobalData.initSetting.EXFOIP);
                if (Network.PingNetwork(GlobalData.initSetting.EXFOIP) == false)
                {
                    _testtemp.SYSTEMLOG += "...Kết quả = FAIL\r\n";
                    GlobalData.connectionManagement.IQS1700STATUS  = false;
                    GlobalData.connectionManagement.IQS9100BSTATUS = false;
                    return(false);
                }
                _testtemp.SYSTEMLOG += "...Kết quả = PASS\r\n";
            }


            //login to ONT
            bool _result   = false;
            GW   ontDevice = null;

            switch (GlobalData.initSetting.ONTTYPE)
            {
            case "GW040H": {
                ontDevice = new GW040H(_testtemp.COMPORT);
                break;
            }

            case "GW020BoB": {
                ontDevice = new GW020BoB(_testtemp.COMPORT);
                break;
            }

            default: return(false);
            }
            if (ontDevice.loginToONT(_testtemp) == false)
            {
                goto END;
            }


            //Get MAC Address
            if (!GlobalData.initSetting.ENABLEWRITEMAC)
            {
                _testtemp.MACADDRESS = ontDevice.getMACAddress(_testtemp);
                if (_testtemp.MACADDRESS == string.Empty)
                {
                    _testtemp.ERRORCODE = "(Mã Lỗi: COT-GM-0001)"; goto END;
                }
            }

            //Write APD LUT
            if (GlobalData.initSetting.ENABLEWRITEAPD == true)
            {
                if (ontDevice.writeAPD(_bosainfo, _testtemp) == false)
                {
                    goto END;
                }
            }
            pt.Stop();
            _apdTime = string.Format("PW time = {0} ms\r\n", pt.ElapsedMilliseconds);
            pt.Reset(); pt.Restart();

            //Calib Power
            if (GlobalData.initSetting.ENABLETUNINGPOWER)
            {
                if (ontDevice.calibPower(int.Parse(_testtemp.ONTINDEX), _bosainfo, _testtemp, _vari) == false)
                {
                    goto END;
                }
            }

            pt.Stop();
            _pwTime = string.Format("PW time = {0} ms\r\n", pt.ElapsedMilliseconds);

            //Calib ER
            if (GlobalData.initSetting.ENABLETUNINGER || GlobalData.initSetting.ENABLETUNINGCROSSING)
            {
                pt.Reset();
                pt.Restart();

                //Đăng kí thứ tự Calib ER
                if (this._addToListSequenceTestER(_testtemp) == false)
                {
                    goto END;
                }

                //Chờ đến lượt timeout 90s
                if (this._waitForTurn(_testtemp) == false)
                {
                    goto END;
                }

                //Kiem tra ket noi toi may do DCA
                _testtemp.SYSTEMLOG += string.Format("Kiểm tra kết nối tới máy đo DCA X86100D {0}...\r\n", GlobalData.initSetting.ERINSTRGPIB);
                if (GlobalData.erDevice.isConnected() == false)
                {
                    _testtemp.SYSTEMLOG += "...Kết quả = FAIL\r\n";
                    GlobalData.connectionManagement.DCAX86100DSTATUS = false;
                    return(false);
                }
                _testtemp.SYSTEMLOG += "...Kết quả = PASS\r\n";

                //Calib Dark level
                _testtemp.SYSTEMLOG += string.Format("Switching port...{0} OFF\r\n", _testtemp.ONTINDEX);
                GlobalData.switchDevice.switchOff();
                Thread.Sleep(500);
                GlobalData.erDevice.Calibrate();
                Thread.Sleep(500);

                //Switch Port check ER
                _testtemp.SYSTEMLOG += string.Format("Switching port...{0} ON\r\n", _testtemp.ONTINDEX);
                if (GlobalData.switchDevice.switchToPort(int.Parse(_testtemp.ONTINDEX)) == false)
                {
                    goto END;
                }

                //Calib ER
                if (GlobalData.initSetting.ENABLETUNINGER)
                {
                    if (ontDevice.calibER(int.Parse(_testtemp.ONTINDEX), _bosainfo, _testtemp, _vari) == false)
                    {
                        goto END;
                    }
                }

                //Calib Crossing
                if (GlobalData.initSetting.ENABLETUNINGCROSSING && GlobalData.initSetting.ONTTYPE == "GW020BoB")
                {
                    if (ontDevice.calibCrossing(int.Parse(_testtemp.ONTINDEX), _bosainfo, _testtemp, _vari) == false)
                    {
                        goto END;
                    }
                }

                //Xóa thứ tự đăng kí Calib ER (để Thread # có thể sử dụng)
                this._removeFromListSequenceTestER(_testtemp);

                pt.Stop();
                _erTime = string.Format("ER time = {0} ms\r\n", pt.ElapsedMilliseconds);
            }

            //TX DDMI
            pt.Reset(); pt.Restart();
            if (GlobalData.initSetting.ENABLETXDDMI)
            {
                if (ontDevice.txDDMI(int.Parse(_testtemp.ONTINDEX), _bosainfo, _testtemp, _vari) == false)
                {
                    goto END;
                }
            }

            //Signal Off
            if (GlobalData.initSetting.ENABLESIGNALOFF && GlobalData.initSetting.ONTTYPE == "GW040H")
            {
                if (ontDevice.signalOff(int.Parse(_testtemp.ONTINDEX), _bosainfo, _testtemp, _vari) == false)
                {
                    goto END;
                }
            }

            //Write flash
            if (GlobalData.initSetting.ENABLEWRITEFLASH && GlobalData.initSetting.ONTTYPE == "GW040H")
            {
                if (ontDevice.writeFlash(_bosainfo, _testtemp) == false)
                {
                    goto END;
                }
            }

            //Verify Signal
            if (GlobalData.initSetting.ENABLEVERIFYSIGNAL && GlobalData.initSetting.ONTTYPE == "GW040H")
            {
                if (ontDevice.verifySignal(int.Parse(_testtemp.ONTINDEX), _bosainfo, _testtemp, _vari) == false)
                {
                    goto END;
                }
            }

            //Write MAC
            if (GlobalData.initSetting.ENABLEWRITEMAC)
            {
                if (ontDevice.writeMAC(_testtemp) == false)
                {
                    goto END;
                }
            }

            pt.Stop();
            _ddmiTime = string.Format("DDMI,SIGOFF,WRITE FLASH time = {0} ms\r\n", pt.ElapsedMilliseconds);

            _result = true;

END:
            _testtemp.SYSTEMLOG += _pwTime;
            _testtemp.SYSTEMLOG += _erTime;
            _testtemp.SYSTEMLOG += _ddmiTime;
            this._removeFromListSequenceTestER(_testtemp);
            try { ontDevice.Close(); } catch { }
            return(_result);
        }