//----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);
        }
Exemplo n.º 2
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);
        }