protected override bool StartTest()
        {
            RxPowerArray.Clear();
            BerArray.Clear();

            logoStr = "";
            if (AnalysisInputParameters(inputParameters) == false)
            {
                OutPutandFlushLog();
                return(false);
            }

            //if (testRxOverloadStruct.IsOptSourceUnitOMA)
            //{
            //    testRxOverloadStruct.SpecDelta = Algorithm.CalculateFromOMAtoDBM(testRxOverloadStruct.SpecDelta, Convert.ToDouble(OSERValueArray[GlobalParameters.CurrentChannel - 1]));
            //    testRxOverloadStruct.SpecDelta = Math.Round(testRxOverloadStruct.SpecDelta, 4);
            //    testRxOverloadStruct.CsenAlignRxPwr = Algorithm.CalculateFromOMAtoDBM(testRxOverloadStruct.CsenAlignRxPwr, Convert.ToDouble(OSERValueArray[GlobalParameters.CurrentChannel - 1]));
            //    testRxOverloadStruct.CsenAlignRxPwr = Math.Round(testRxOverloadStruct.CsenAlignRxPwr, 4);
            //}

            if (tempAtten != null && tempED != null && tempps != null)
            {
                // open apc
                {
                    CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODON));
                }
                // open apc

                //tempAtten.SetAllChannnel_RxOverLoad(10);
                Log.SaveLogToTxt("Step2...SetAttenValue");
                tempAtten.AttnValue(testRxOverloadStruct.CsenAlignRxPwr.ToString());
                Log.SaveLogToTxt("Step3...AutoAlaign");
                bool isAutoAlaign = tempED.AutoAlaign(true);
                if (isAutoAlaign)
                {
                    Log.SaveLogToTxt(isAutoAlaign.ToString());
                    Log.SaveLogToTxt("Step4...StartTestRxOverload");

                    double ber = -1;
                    int    i   = 0;
                    int    LoopCount;
                    double RxPower  = 0;
                    double countMol = testRxOverloadStruct.LoopTime % testRxOverloadStruct.GatingTime;
                    if (countMol == 0)
                    {
                        LoopCount = Convert.ToInt32(testRxOverloadStruct.LoopTime / testRxOverloadStruct.GatingTime);
                    }
                    else
                    {
                        LoopCount = Convert.ToInt32((testRxOverloadStruct.LoopTime - countMol) / testRxOverloadStruct.GatingTime) + 1;
                    }

                    double startPower = 0;
                    if (tempAtten.offsetlist.ContainsKey(tempAtten.CurrentChannel))
                    {
                        startPower = Convert.ToDouble(tempAtten.offsetlist[tempAtten.CurrentChannel]);
                    }

                    do
                    {
                        RxPower = startPower - testRxOverloadStruct.AttStep * i;

                        if (RxPower < testRxOverloadStruct.CsenAlignRxPwr)
                        {
                            OverloadPoint = testRxOverloadStruct.CsenAlignRxPwr;
                            Log.SaveLogToTxt("Can't find OverloadPoint...");
                            break;
                        }
                        else
                        {
                            tempAtten.AttnValue(RxPower.ToString());
                            RxPowerArray.Add(RxPower);
                            Log.SaveLogToTxt("SetAtten=" + RxPower.ToString());

                            tempED.EdGatingStart();    //刷新误码数
                            for (int j = 0; j < LoopCount; j++)
                            {
                                Thread.Sleep(Convert.ToInt32(testRxOverloadStruct.GatingTime * 1000));
                                ber = tempED.QureyEdErrorRatio();
                                Log.SaveLogToTxt("Ber=" + ber.ToString());
                                if (ber != 0)
                                {
                                    BerArray.Add(ber);
                                    break;
                                }
                                else
                                {
                                    if (j == LoopCount - 1)
                                    {
                                        BerArray.Add(ber);
                                    }
                                }
                            }
                        }

                        i++;
                    }while (ber != 0);


                    if (ber == 0 && i != 1)
                    {
                        i          = 0;
                        startPower = RxPower + testRxOverloadStruct.AttStep;
                        do
                        {
                            RxPower = startPower - 0.2 * i;

                            if (RxPower < testRxOverloadStruct.CsenAlignRxPwr)
                            {
                                OverloadPoint = testRxOverloadStruct.CsenAlignRxPwr;
                                Log.SaveLogToTxt("Can't find OverloadPoint...");
                                break;
                            }
                            else
                            {
                                tempAtten.AttnValue(RxPower.ToString());
                                RxPowerArray.Add(RxPower);
                                Log.SaveLogToTxt("SetAtten=" + RxPower.ToString());

                                tempED.EdGatingStart();    //刷新误码数
                                for (int j = 0; j < LoopCount; j++)
                                {
                                    Thread.Sleep(Convert.ToInt32(testRxOverloadStruct.GatingTime * 1000));
                                    ber = tempED.QureyEdErrorRatio();
                                    Log.SaveLogToTxt("Ber=" + ber.ToString());
                                    if (ber != 0)
                                    {
                                        BerArray.Add(ber);
                                        break;
                                    }
                                    else
                                    {
                                        if (j == LoopCount - 1)
                                        {
                                            BerArray.Add(ber);
                                        }
                                    }
                                }
                            }

                            i++;
                        }while (ber != 0);


                        if (ber == 0)
                        {
                            OverloadPoint = RxPower;
                            Log.SaveLogToTxt("OverloadPoint= " + OverloadPoint.ToString());
                        }
                    }
                    else          //光源点无误码
                    {
                        OverloadPoint = RxPower;
                        Log.SaveLogToTxt("OverloadPoint= " + OverloadPoint.ToString() + " LightSource= " + OverloadPoint.ToString());
                    }

                    OutPutandFlushLog();
                    return(true);
                }
                else
                {
                    Log.SaveLogToTxt(isAutoAlaign.ToString());
                    OverloadPoint = -1000;
                    OutPutandFlushLog();
                    return(isAutoAlaign);
                }
            }
            else
            {
                Log.SaveLogToTxt("Equipments are not enough!");
                AnalysisOutputProcData(procData);
                AnalysisOutputParameters(outputParameters);

                return(false);
            }
        }
示例#2
0
        protected override bool StartTest()
        {
            RxPowerArray.Clear();
            BerArrayRX.Clear();
            TxPowerArray.Clear();
            BerArrayTX.Clear();


            logoStr = "";
            if (AnalysisInputParameters(inputParameters) == false)
            {
                OutPutandFlushLog();
                return(false);
            }

            if (tempED != null && tempAttenRX != null && tempAttenTX != null && tempPowerMeter != null && tempps != null)
            {
                if (!CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODON)))
                {
                    return(false);                                                         //开启APC
                }
                if (!tempPPG.ConfigurePrbsLength(Convert.ToByte(testTxReturnLostToleranceStruct.ReturnLosTolerancePRBS)))
                {
                    return(false);                                                                                                      //Bert码型为PRBS31
                }
                //if (!SetTargetPower(testTxReturnLostToleranceStruct.TargetPower)) return false; //调节反射器处的衰减器,使光功率计值降TargetPower以下

                tempAttenTX.OutPutSwitch(false);

                Log.SaveLogToTxt("Step2...SetAttenValue");
                tempAttenRX.AttnValue(testTxReturnLostToleranceStruct.CsenAlignRxPwr.ToString());
                Log.SaveLogToTxt("Step3...AutoAlaign");

                bool isAutoAlaign = tempED.AutoAlaign(true);
                if (isAutoAlaign)
                {
                    Log.SaveLogToTxt(isAutoAlaign.ToString());
                    Log.SaveLogToTxt("Step4...TestTxReturnLostTolerance");

                    double ber       = -1;
                    int    i         = 0;
                    double RxPower   = 0;
                    int    LoopCount = 0;
                    double countMol  = testTxReturnLostToleranceStruct.LoopTime % testTxReturnLostToleranceStruct.GatingTime;
                    if (countMol == 0)
                    {
                        LoopCount = Convert.ToInt32(testTxReturnLostToleranceStruct.LoopTime / testTxReturnLostToleranceStruct.GatingTime);
                    }
                    else
                    {
                        LoopCount = Convert.ToInt32((testTxReturnLostToleranceStruct.LoopTime - countMol) / testTxReturnLostToleranceStruct.GatingTime) + 1;
                    }

                    do
                    {
                        RxPower = testTxReturnLostToleranceStruct.StartRxPwr + testTxReturnLostToleranceStruct.RXAttStep * i;

                        tempAttenRX.AttnValue(RxPower.ToString());
                        RxPowerArray.Add(RxPower);
                        Log.SaveLogToTxt("SetAttenRX=" + RxPower.ToString());

                        tempED.EdGatingStart();    //刷新误码数
                        for (int j = 0; j < LoopCount; j++)
                        {
                            Thread.Sleep(Convert.ToInt32(testTxReturnLostToleranceStruct.GatingTime * 1000));
                            ber = tempED.QureyEdErrorRatio();
                            Log.SaveLogToTxt("BerRX=" + ber.ToString());
                            if (ber != 0)
                            {
                                BerArrayRX.Add(ber);
                                break;
                            }
                            else
                            {
                                if (j == LoopCount - 1)
                                {
                                    BerArrayRX.Add(ber);
                                }
                            }
                        }

                        i++;
                    }while (ber != 0);

                    if (ber == 0)
                    {
                        NoneBerPoint = RxPower;
                        //tempAttenRX.AttnValue(NoneBerPoint.ToString());
                        Log.SaveLogToTxt("NoneBerPoint= " + NoneBerPoint.ToString());
                    }

                    //tempED.EdGatingStart();    //刷新误码数

                    double value = 11.5;

                    do
                    {
                        StartTxPwr = dut.ReadDmiTxp() - value;
                        if (!this.SetTargetPower(StartTxPwr))
                        {
                            return(false);
                        }

                        tempED.EdGatingStart();    //刷新误码数
                        for (int j = 0; j < LoopCount; j++)
                        {
                            Thread.Sleep(Convert.ToInt32(testTxReturnLostToleranceStruct.GatingTime * 1000));
                            ber = tempED.QureyEdErrorRatio();
                            Log.SaveLogToTxt("BerRX=" + ber.ToString());
                            if (ber != 0)
                            {
                                break;
                            }
                        }

                        if (ber == 0)
                        {
                            TxReturnLosTolerance = tempPowerMeter.ReadPower();
                            Log.SaveLogToTxt("TxReturnLosTolerance= " + TxReturnLosTolerance.ToString());
                            break;
                        }
                        //tempAttenTX.SetAttnValue(40);
                        value += 0.5;
                    } while (value < 13);

                    TxReturnLosTolerance = value;

                    OutPutandFlushLog();
                    return(true);
                }
                else
                {
                    Log.SaveLogToTxt(isAutoAlaign.ToString());
                    TxReturnLosTolerance = -1000;
                    OutPutandFlushLog();
                    return(isAutoAlaign);
                }
            }
            else
            {
                Log.SaveLogToTxt("Equipments are not enough!");
                //AnalysisOutputProcData(procData);
                AnalysisOutputParameters(outputParameters);

                return(false);
            }
        }