protected bool SerchCoefPointsTarget1E3(Attennuator tempAtt, ErrorDetector tempED, double startAttValue, double targetBer, double addStep, double sumStep, out ArrayList AttenPoints, out ArrayList BerPints)
        {
            lock (tempAtten)
            {
                byte   i          = 0;
                double currentBer = 0;
                //AttenPoints[]=
                AttenPoints = new ArrayList();
                BerPints    = new ArrayList();
                AttenPoints.Clear();
                BerPints.Clear();
                do
                {
                    tempAtt.AttnValue(startAttValue.ToString());
                    currentBer = tempED.RapidErrorRate();
                    if (currentBer != 0)
                    {
                        AttenPoints.Add(startAttValue);
                        BerPints.Add(currentBer);
                    }
                    if (currentBer > targetBer)
                    {
                        startAttValue += addStep;
                    }
                    else
                    {
                        startAttValue -= sumStep;
                    }
                    i++;
                } while (i < 8 && (currentBer < (targetBer * 1E-1)));

                return(true);
            }
        }
Exemplo n.º 2
0
        private bool SingleChannelTest()
        {
            Ber = pED.RapidErrorRate(0);
            if (Ber >= 1)
            {
                System.Threading.Thread.Sleep(2000);
                Ber = pED.RapidErrorRate(0);
            }
            if (flagReadTxpowerDmi)
            {
                DmiTxPower = dut.ReadDmiTxp();
            }
            if (flagReadRxpowerDmi)
            {
                DmiRxPower = dut.ReadDmiRxp();
            }
            Log.SaveLogToTxt("Ber= " + Ber.ToString());

            return(true);
        }
        protected double StepSearchTargetPoint(double StartInputPower, double LLimit, double ULimit, double targetBerLL, double targetBerUL, Attennuator tempAtt, ErrorDetector tempED, out ArrayList serchAttPoints, out ArrayList serchRxDmiPoints, out ArrayList serchBerPoints)
        {
            //double low = LLimit;
            //double high = ULimit;
            lock (tempAtten)
            {
                double currentCense = 0;
                byte   Rcount       = 0;
                serchAttPoints   = new ArrayList();
                serchRxDmiPoints = new ArrayList();
                serchBerPoints   = new ArrayList();
                serchAttPoints.Clear();
                serchBerPoints.Clear();

                double CurrentInputPower = StartInputPower;

                // tempAtt

                while (CurrentInputPower <= ULimit && CurrentInputPower >= LLimit && Rcount <= 20)
                {
                    tempAtt.AttnValue(CurrentInputPower.ToString());
                    double TempRxDmiPower = dut.ReadDmiRxp();
                    serchAttPoints.Add(CurrentInputPower);
                    serchRxDmiPoints.Add(TempRxDmiPower);
                    currentCense = tempED.RapidErrorRate();
                    serchBerPoints.Add(currentCense);

                    if (currentCense < targetBerLL)// 误码太小->光太大->减小光
                    {
                        CurrentInputPower -= testBerStruct.FirstPointStep;
                        Rcount++;
                    }
                    else if (currentCense > targetBerUL)// 误码太大->光太小->加大入射光
                    {
                        CurrentInputPower += testBerStruct.FirstPointStep;
                        Rcount++;
                    }
                    else
                    {
                        return(CurrentInputPower);
                    }
                }
                return(-10000);
            }
        }
        protected void QuickTest(Attennuator tempAtten, ErrorDetector tempED)
        {
            lock (tempAtten)
            {
                try
                {
                    tempAtten.AttnValue(testBerStruct.CsenStartingRxPwr.ToString());
                    double sensitivity = tempED.RapidErrorRate();
                    Log.SaveLogToTxt("SetAtten=" + testBerStruct.CsenStartingRxPwr.ToString());
                    Log.SaveLogToTxt("QUICBER=" + sensitivity.ToString());
                    if (sensitivity >= 1)
                    {
                        sensitivityPoint = 1;
                        AnalysisOutputParameters(outputParameters);
                        AnalysisOutputProcData(procData);

                        return;
                    }

                    {
                        if (sensitivity <= ber_erp)
                        {
                            sensitivityPoint = testBerStruct.CsenStartingRxPwr;
                        }
                        else
                        {
                            sensitivityPoint = sensitivity;
                            Log.SaveLogToTxt("AttPoint=" + testBerStruct.CsenStartingRxPwr.ToString() + ber_erp.ToString());
                        }
                    }
                    Log.SaveLogToTxt("sensitivityPoint= " + sensitivityPoint.ToString());
                    AnalysisOutputParameters(outputParameters);
                    AnalysisOutputProcData(procData);
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }
            }
        }
        protected double SerchTargetPoint(Attennuator tempAtt, ErrorDetector tempED, double attValue, double targetBerLL, double targetBerUL, double addStep, double sumStep)
        {
            lock (tempAtten)
            {
                byte   i            = 0;
                double currentCense = 0;
                do
                {
                    tempAtt.AttnValue(attValue.ToString());
                    currentCense = tempED.RapidErrorRate(1);
                    if (currentCense > targetBerUL)
                    {
                        attValue += addStep;
                    }
                    else
                    {
                        attValue -= sumStep;
                    }
                    i++;
                } while (i < 20 && (currentCense > targetBerUL || currentCense < targetBerLL));

                return(attValue);
            }
        }
        protected double binarySearchTargetPoint(double StartInputPower, double LLimit, double ULimit, double targetBerLL, double targetBerUL, Attennuator tempAtt, ErrorDetector tempED, out ArrayList serchAttPoints, out ArrayList serchRxDmiPoints, out ArrayList serchBerPoints)
        {
            lock (tempAtten)
            {
                double low          = LLimit;
                double high         = ULimit;
                double currentCense = 0;
                byte   count        = 0;
                serchAttPoints   = new ArrayList();
                serchBerPoints   = new ArrayList();
                serchRxDmiPoints = new ArrayList();
                serchAttPoints.Clear();
                serchBerPoints.Clear();

                double CurrentInputPower = StartInputPower;

                tempAtt.AttnValue(((high + low) / 2).ToString(), 1);
                //Thread.Sleep(2000);
                double TempValue = tempED.RapidErrorRate();

                Log.SaveLogToTxt("RxInputPower=" + ((high + low) / 2).ToString());
                Log.SaveLogToTxt("CurrentErrorRate=" + TempValue.ToString());

                while (low <= high && count <= 20)
                {
                    if (Math.Abs(low - high) < 0.2)
                    {
                        break;
                    }

                    double mid = low + ((high - low) / 2);
                    tempAtt.AttnValue(mid.ToString(), 1);
                    double TempRxDmiPower = dut.ReadDmiRxp();



                    serchAttPoints.Add(mid);
                    serchRxDmiPoints.Add(TempRxDmiPower);
                    currentCense = tempED.RapidErrorRate();
                    //Log.SaveLogToTxt("RxInputPower=" + mid);
                    //Log.SaveLogToTxt("RxDmiPower=" + TempRxDmiPower.ToString());
                    //Log.SaveLogToTxt("CurrentErrorRate=" + currentCense.ToString());

                    serchBerPoints.Add(currentCense);
                    if (currentCense < targetBerLL)
                    {
                        high = mid;
                        count++;
                    }
                    else if (currentCense > targetBerUL)
                    {
                        low = mid;
                        count++;
                    }
                    else
                    {
                        return(mid);
                    }
                }
                return(-10000);
            }
        }
        protected bool SerchCoefPoints(Attennuator tempAtt, ErrorDetector tempED, double startAttValue, double targetBer, double addStep, double sumStep, out ArrayList AttenPoints, out ArrayList BerPints)
        {
            lock (tempAtten)
            {
                byte i = 0;

                bool   terminalFlag = false;
                double currentBer   = 0;
                bool   isEnd        = false;
                //AttenPoints[]=
                AttenPoints = new ArrayList();
                BerPints    = new ArrayList();
                AttenPoints.Clear();
                BerPints.Clear();


                tempAtt.AttnValue(startAttValue.ToString(), 0);
                Thread.Sleep(1500);
                currentBer = tempED.RapidErrorRate();

                if (currentBer < this.testBerStruct.Ber_ERP)
                {
                    this.IsCoefErrorRateUpwards = 1;
                }
                else
                {
                    this.IsCoefErrorRateUpwards = -1;
                }

                double CurrentStartAttValue = startAttValue;

                #region  Add InputPower

                terminalFlag = true;
                int Runcount = 1;

                do
                {
                    tempAtt.AttnValue(CurrentStartAttValue.ToString(), 0);
                    Thread.Sleep(1000);
                    double TempRxDmiPower = dut.ReadDmiRxp();

                    Log.SaveLogToTxt("RxInputPower=" + CurrentStartAttValue);
                    Log.SaveLogToTxt("RxDmiPower=" + TempRxDmiPower.ToString());

                    currentBer = tempED.RapidErrorRate();

                    terminalFlag = (currentBer > this.testBerStruct.CoefErrorRateLL && currentBer < this.testBerStruct.CoefErrorRateUL);

                    if (terminalFlag == true && currentBer != 0)
                    {
                        AttenPoints.Add(CurrentStartAttValue);
                        BerPints.Add(currentBer);
                    }

                    if (IsCoefErrorRateUpwards > 0 && currentBer == 0)
                    {
                        isEnd = true;
                    }

                    if (!terminalFlag)              //搜点到达边缘
                    {
                        if (AttenPoints.Count >= 5) //点数够了 可以结束
                        {
                            isEnd = true;
                        }
                        else
                        {
                            if (Runcount < 2)//点数不够,需要反方向搜寻,至少5个点
                            {
                                IsCoefErrorRateUpwards *= -1;
                                CurrentStartAttValue    = startAttValue;
                                terminalFlag            = true;
                                Runcount = 2;
                            }
                            else//已经经过来反转
                            {
                                isEnd = true;
                            }
                        }
                    }

                    if (IsCoefErrorRateUpwards > 0)
                    {
                        CurrentStartAttValue -= sumStep;
                    }
                    else
                    {
                        CurrentStartAttValue += addStep;
                    }
                } while (!isEnd);

                #endregion



                return(true);
            }
        }