Ejemplo n.º 1
0
        protected override bool StartTest()
        {
            logger.FlushLogBuffer();
            logoStr = "";
            if (AnalysisInputParameters(inputParameters) == false)
            {
                return(false);
            }
            if (selectedEquipList["ATTEN"] != null && selectedEquipList["ERRORDETE"] != null && selectedEquipList["DUT"] != null && selectedEquipList["POWERSUPPLY"] != null)
            {
                Powersupply tempps = (Powersupply)selectedEquipList["POWERSUPPLY"];
                // open apc
                string apcstring = null;
                dut.APCStatus(out apcstring);
                if (apcstring == "OFF" || apcstring == "FF")
                {
                    logoStr += logger.AdapterLogString(0, "Step2...Start Open apc");
                    dut.APCON();
                    logoStr += logger.AdapterLogString(0, "Power off");
                    tempps.Switch(false);
                    Thread.Sleep(200);
                    logoStr += logger.AdapterLogString(0, "Power on");
                    tempps.Switch(true);
                    Thread.Sleep(200);
                    bool isOpen = dut.APCStatus(out apcstring);
                    if (apcstring == "ON")
                    {
                        logoStr += logger.AdapterLogString(1, "APC ON");
                    }
                    else
                    {
                        logoStr += logger.AdapterLogString(3, "APC NOT ON");
                    }
                }
                // open apc
                Attennuator   tempAtten = (Attennuator)selectedEquipList["ATTEN"];
                ErrorDetector tempED    = (ErrorDetector)selectedEquipList["ERRORDETE"];
                logoStr += logger.AdapterLogString(0, "Step3...SetAttenValue");
                SetAttenValue(tempAtten, testBerStruct.CsenAlignRxPwr);
                Thread.Sleep(200);
                tempAtten.Switch(true);
                double attPoint = 0;
                logoStr += logger.AdapterLogString(0, "Step4...AutoAlaign");

                bool isAutoAlaign = tempED.AutoAlaign(true);
                if (isAutoAlaign)
                {
                    logoStr += logger.AdapterLogString(1, isAutoAlaign.ToString());
                }
                else
                {
                    logoStr += logger.AdapterLogString(4, isAutoAlaign.ToString());
                    logger.FlushLogBuffer();
                    return(isAutoAlaign);
                }

                if (isAutoAlaign)
                {
                    if (testBerStruct.IsBerQuickTest == true)
                    {
                        tempAtten.AttnValue(testBerStruct.CsenStartingRxPwr.ToString());
                        Thread.Sleep(200);
                        double sensitivity = tempED.GetErrorRate();
                        logoStr += logger.AdapterLogString(1, "SetAtten=" + testBerStruct.CsenStartingRxPwr.ToString());

                        if (sensitivity.ToString().ToUpper().Trim() == "NAN")
                        {
                            sensitivityPoint = -1000;
                            AnalysisOutputParameters(outputParameters);
                            logger.FlushLogBuffer();
                            return(false);
                        }
                        if (testBerStruct.CsenTargetBER == 1E-3)
                        {
                            if (sensitivity <= 1E-3)
                            {
                                sensitivityPoint = testBerStruct.CsenStartingRxPwr;
                            }
                            else
                            {
                                sensitivityPoint = -1000;
                                logoStr         += logger.AdapterLogString(4, "AttPoint=" + testBerStruct.CsenStartingRxPwr.ToString() + "CSENCE>1E-3 ");
                                AnalysisOutputParameters(outputParameters);
                                logger.FlushLogBuffer();
                                return(false);
                            }
                        }
                        else if (testBerStruct.CsenTargetBER == 1E-12)
                        {
                            if (sensitivity <= 1E-12)
                            {
                                sensitivityPoint = testBerStruct.CsenStartingRxPwr;
                            }
                            else
                            {
                                sensitivityPoint = -1000;
                                logoStr         += logger.AdapterLogString(4, "AttPoint=" + testBerStruct.CsenStartingRxPwr.ToString() + "CSENCE>1E-12 ");
                                AnalysisOutputParameters(outputParameters);
                                logger.FlushLogBuffer();
                                return(false);
                            }
                        }

                        sensitivityPoint = Math.Round(sensitivityPoint, 2);
                        logoStr         += logger.AdapterLogString(1, "sensitivityPoint= " + sensitivityPoint.ToString());
                        AnalysisOutputParameters(outputParameters);
                        logger.FlushLogBuffer();
                        return(true);
                    }
                    else
                    {
                        logoStr += logger.AdapterLogString(0, "Step5...SerchTargetPoint");
                        attPoint = SerchTargetPoint(tempAtten, tempED, testBerStruct.CsenStartingRxPwr, testBerStruct.SearchTargetBerLL, testBerStruct.SearchTargetBerUL, testBerStruct.SearchTargetBerAddStep, testBerStruct.SearchTargetBerSubStep);
                        logoStr += logger.AdapterLogString(1, "SetAtten=" + attPoint.ToString());
                        ArrayList attPoints;
                        ArrayList berPoints;
                        double    intercept;
                        double    slope;
                        logoStr += logger.AdapterLogString(0, "Step6...SerchCoefPoints");
                        if (testBerStruct.CsenTargetBER == 1E-3)
                        {
                            SerchCoefPointsTarget1E3(tempAtten, tempED, attPoint, testBerStruct.CsenTargetBER, testBerStruct.CoefCsenSubStep, testBerStruct.CoefCsenAddStep, out attPoints, out berPoints);
                            byte     tmepCount     = (byte)Math.Min(attPoints.Count, berPoints.Count);
                            double[] tempattPoints = new double[tmepCount];
                            double[] tempberPoints = new double[tmepCount];
                            for (byte i = 0; i < tmepCount; i++)
                            {
                                tempattPoints[i] = double.Parse(attPoints[i].ToString());
                                tempberPoints[i] = double.Parse(berPoints[i].ToString());
                                logoStr         += logger.AdapterLogString(1, "attPoints[ " + i.ToString() + "]" + double.Parse(attPoints[i].ToString()) + "  " + "berPoints[ " + i.ToString() + "]" + double.Parse(berPoints[i].ToString()));
                            }
                            algorithm.LinearRegression(algorithm.Getlog10(algorithm.GetNegative(algorithm.Getlog10(tempberPoints))), tempattPoints, out slope, out intercept);
                            sensitivityPoint = slope + (intercept * System.Math.Log10(System.Math.Log10(testBerStruct.CsenTargetBER) * (-1)));
                        }
                        else if (testBerStruct.CsenTargetBER == 1E-12)
                        {
                            SerchCoefPoints1E12(tempAtten, tempED, attPoint, testBerStruct.CsenTargetBER, testBerStruct.CoefCsenSubStep, testBerStruct.CoefCsenAddStep, out attPoints, out berPoints);
                            byte     tmepCount     = (byte)Math.Min(attPoints.Count, berPoints.Count);
                            double[] tempattPoints = new double[tmepCount];
                            double[] tempberPoints = new double[tmepCount];
                            for (byte i = 0; i < tmepCount; i++)
                            {
                                tempattPoints[i] = double.Parse(attPoints[i].ToString());
                                tempberPoints[i] = double.Parse(berPoints[i].ToString());
                                logoStr         += logger.AdapterLogString(1, "attPoints[ " + i.ToString() + "]" + double.Parse(attPoints[i].ToString()) + "  " + "berPoints[ " + i.ToString() + "]" + double.Parse(berPoints[i].ToString()));
                            }
                            algorithm.LinearRegression(algorithm.Getlog10(algorithm.GetNegative(algorithm.Getlog10(tempberPoints))), tempattPoints, out slope, out intercept);
                            sensitivityPoint = slope + (intercept * System.Math.Log10(System.Math.Log10(testBerStruct.CsenTargetBER) * (-1)));
                        }
                        if (sensitivityPoint.ToString().ToUpper().Trim() == "NAN")
                        {
                            sensitivityPoint = -1000;
                            AnalysisOutputParameters(outputParameters);
                            logger.FlushLogBuffer();
                            return(false);
                        }
                        sensitivityPoint = Math.Round(sensitivityPoint, 2);
                        logoStr         += logger.AdapterLogString(1, "sensitivityPoint= " + sensitivityPoint.ToString());
                        AnalysisOutputParameters(outputParameters);
                        logger.FlushLogBuffer();
                        return(true);
                    }
                }
                else
                {
                    logger.FlushLogBuffer();
                    return(false);
                }
            }
            else
            {
                logoStr += logger.AdapterLogString(4, "Equipments is not enough!");
                logger.FlushLogBuffer();
                return(false);
            }
        }