Exemplo n.º 1
0
        protected bool SerchCoefPoints1E12(Attennuator tempAtt, ErrorDetector tempED, double startAttValue, double targetBer, double addStep, double sumStep, out ArrayList AttenPoints, out ArrayList BerPints)
        {
            byte   i          = 0;
            double currentBer = 0;

            //AttenPoints[]=
            AttenPoints = new ArrayList();
            BerPints    = new ArrayList();
            AttenPoints.Clear();
            BerPints.Clear();
            do
            {
                tempAtt.AttnValue(startAttValue.ToString());
                Thread.Sleep(200);
                currentBer = tempED.GetErrorRate();
                if (currentBer != 0)
                {
                    AttenPoints.Add(startAttValue);
                    BerPints.Add(currentBer);
                }
                if (currentBer > targetBer)
                {
                    startAttValue += addStep;
                }
                else
                {
                    startAttValue -= sumStep;
                }
                i++;
            } while (i < 8 && (currentBer > (targetBer * 100)));

            return(true);
        }
        protected void GettingCurvingPointsandFitting(Attennuator tempAtten, ErrorDetector tempED)
        {
            lock (tempAtten)
            {
                try
                {
                    double intercept;
                    double slope;
                    byte   tmepCount = 0;
                    Log.SaveLogToTxt("Step6...SerchCoefPoints");
                    {
                        SerchCoefPoints(tempAtten, tempED, attPoint, ber_erp, testBerStruct.CoefCsenAddStep, testBerStruct.CoefCsenSubStep, out attPoints, out berPoints);
                        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());
                            Log.SaveLogToTxt("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(ber_erp) * (-1)));

                        Log.SaveLogToTxt("LinearSlope=" + intercept + " LinearOffset= " + slope);// 因为Offset 和 Slope 的幅值颠倒 Leo
                    }
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 3
0
        protected UInt32 EnumMethod(UInt32[] inPutArray, DUT dut, ErrorDetector ed, byte substep, out ArrayList berArray, out ArrayList apdDacArray, out double minBer)
        {
            berArray    = new ArrayList();
            apdDacArray = new ArrayList();
            UInt32 minimumDAC;

            for (byte i = 0; i < inPutArray.Length; i++)
            {
                // add write APD
                dut.WriteAPDDac(inPutArray[i]);
                apdDacArray.Add(inPutArray[i]);
                ed.GetErrorRate();
                berArray.Add(ed.GetErrorRate());
            }

            minBer = -1;
            byte minIndex = 0;

            #region Select minimum value
            minBer     = Algorithm.SelectMinValue(berArray, out minIndex);
            minimumDAC = inPutArray[minIndex];
            #endregion

            #region Fine Tune Target Value
            dut.WriteAPDDac(Algorithm.Uint16DataConvertoBytes((UInt16)(inPutArray[minIndex] + substep)));

            double tempBer1 = ed.GetErrorRate();
            dut.WriteAPDDac(Algorithm.Uint16DataConvertoBytes((UInt16)(inPutArray[minIndex] - substep)));
            double tempBer2   = ed.GetErrorRate();
            double mintempBer = Math.Min(tempBer1, tempBer2);
            if (mintempBer == tempBer1)
            {
                if (minBer > tempBer1)
                {
                    minimumDAC = Convert.ToUInt16(minimumDAC + substep);
                    apdDacArray.Add(minimumDAC);
                    dut.WriteAPDDac(minimumDAC);
                    minBer = ed.GetErrorRate();
                    berArray.Add(minBer);
                }
            }
            else
            {
                if (minBer > tempBer2)
                {
                    minimumDAC = Convert.ToUInt16(minimumDAC - substep);
                    apdDacArray.Add(minimumDAC);
                    dut.WriteAPDDac(minimumDAC);
                    minBer = ed.GetErrorRate();
                    berArray.Add(minBer);
                }
            }


            #endregion
            return(minimumDAC);
        }
Exemplo n.º 4
0
        public override bool SelectEquipment(EquipmentList aEquipList)
        {
            pPS = null;

            pED = null;
            selectedEquipList.Clear();
            if (aEquipList.Count == 0)
            {
                selectedEquipList.Add("DUT", dut);
                return(false);
            }
            else
            {
                bool isOK = false;
                selectedEquipList.Clear();
                IList <string>        tempKeys   = aEquipList.Keys;
                IList <EquipmentBase> tempValues = aEquipList.Values;
                for (byte i = 0; i < aEquipList.Count; i++)
                {
                    if (tempKeys[i].ToUpper().Contains("ERRORDETE"))

                    {
                        selectedEquipList.Add("ERRORDETE", tempValues[i]);
                        pED = (ErrorDetector)tempValues[i];
                    }

                    if (tempKeys[i].ToUpper().Contains("POWERSUPPLY"))
                    {
                        selectedEquipList.Add("POWERSUPPLY", tempValues[i]);
                        pPS = (Powersupply)tempValues[i];
                    }
                }
                if (pPS != null && pED != null)
                {
                    isOK = true;
                }
                else
                {
                    isOK = false;
                }
                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                }
                else
                {
                    isOK = false;
                }
                return(isOK);
            }
        }
        protected bool SerchTargetBer(Attennuator tempAtten, ErrorDetector tempED)
        {
            lock (tempAtten)
            {
                try
                {
                    Log.SaveLogToTxt("Step5...SerchTargetPoint");

                    switch (testBerStruct.SearchTargetBerMethod)
                    {
                    case 1:
                        attPoint = StepSearchTargetPoint(testBerStruct.CsenStartingRxPwr, testBerStruct.FirstPointRxPowerLL, testBerStruct.FirstPointRxPowerUL, testBerStruct.FirstPointErrorRateLL, testBerStruct.FirstPointErrorRateUL, tempAtten, tempED, out serchAttPoints, out serchRxDmidPoints, out serchBerPoints);

                        break;

                    default:
                        attPoint = binarySearchTargetPoint(testBerStruct.CsenStartingRxPwr, testBerStruct.FirstPointRxPowerLL, testBerStruct.FirstPointRxPowerUL, testBerStruct.FirstPointErrorRateLL, testBerStruct.FirstPointErrorRateUL, tempAtten, tempED, out serchAttPoints, out serchRxDmidPoints, out serchBerPoints);
                        break;
                    }


                    Log.SaveLogToTxt("SetAtten=" + attPoint.ToString());
                    for (byte i = 0; i < serchAttPoints.Count; i++)
                    {
                        Log.SaveLogToTxt("serchAttPoints[ " + i.ToString() + "]" + double.Parse(serchAttPoints[i].ToString()) + "  " + "serchRxDmidPoints[ " + i.ToString() + "]" + double.Parse(serchRxDmidPoints[i].ToString()) + "  " + "serchBerPoints[ " + i.ToString() + "]" + double.Parse(serchBerPoints[i].ToString()));
                    }
                    if (attPoint == -10000)
                    {
                        sensitivityPoint = -10000;
                        AnalysisOutputProcData(procData);
                        AnalysisOutputParameters(outputParameters);

                        return(false);
                    }
                    return(true);
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }
            }
        }
        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;
                }
            }
        }
Exemplo n.º 7
0
        protected double SerchTargetPoint(Attennuator tempAtt, ErrorDetector tempED, double attValue, double targetBerLL, double targetBerUL, double addStep, double sumStep)
        {
            byte   i            = 0;
            double currentCense = 0;

            do
            {
                tempAtt.AttnValue(attValue.ToString());
                Thread.Sleep(200);
                currentCense = tempED.GetErrorRate();
                if (currentCense > targetBerUL)
                {
                    attValue += addStep;
                }
                else
                {
                    attValue -= sumStep;
                }
                i++;
            } while (i < 20 && (currentCense > targetBerUL || currentCense < targetBerLL));

            return(attValue);
        }
Exemplo n.º 8
0
        public override bool SelectEquipment(EquipmentList aEquipList)
        {
            selectedEquipList.Clear();
            if (aEquipList.Count == 0)
            {
                return(false);
            }
            else
            {
                bool isOK = false;
                selectedEquipList.Clear();
                IList <string>        tempKeys   = aEquipList.Keys;
                IList <EquipmentBase> tempValues = aEquipList.Values;
                for (byte i = 0; i < aEquipList.Count; i++)
                {
                    if (tempKeys[i].ToUpper().Contains("ERRORDETE"))

                    {
                        selectedEquipList.Add("ERRORDETE", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("ATTEN"))

                    {
                        selectedEquipList.Add("ATTEN", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("POWERSUPPLY"))
                    {
                        selectedEquipList.Add("POWERSUPPLY", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("NA_OPTICALSWITCH"))
                    {
                        tempValues[i].CheckEquipmentRole(2, GlobalParameters.CurrentChannel);
                    }
                }
                tempAtten = (Attennuator)selectedEquipList["ATTEN"];
                tempED    = (ErrorDetector)selectedEquipList["ERRORDETE"];
                tempps    = (Powersupply)selectedEquipList["POWERSUPPLY"];
                if (tempAtten != null && tempED != null && tempps != null)
                {
                    isOK = true;
                }
                else
                {
                    if (tempED == null)
                    {
                        Log.SaveLogToTxt("ERRORDETE =NULL");
                    }
                    if (tempAtten == null)
                    {
                        Log.SaveLogToTxt("ATTEN =NULL");
                    }
                    if (tempps == null)
                    {
                        Log.SaveLogToTxt("POWERSUPPLY =NULL");
                    }
                    isOK = false;
                    OutPutandFlushLog();
                    isOK = false;
                }
                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                }
                else
                {
                    isOK = false;
                }
                return(isOK);
            }
        }
Exemplo n.º 9
0
        protected override bool StartTest()
        {
            logger.FlushLogBuffer();
            logoStr = "";
            if (AnalysisInputParameters(inputParameters) == false)
            {
                logger.FlushLogBuffer();
                return(false);
            }

            if (selectedEquipList["ERRORDETE"] != null && selectedEquipList["ATTEN"] != null && selectedEquipList["DUT"] != null && selectedEquipList["POWERSUPPLY"] != null)
            {
                bool isWriteCoefCOk = false;
                bool isWriteCoefBOk = false;
                bool isWriteCoefAOk = false;

                ErrorDetector tempED  = (ErrorDetector)selectedEquipList["ERRORDETE"];
                Attennuator   tempAtt = (Attennuator)selectedEquipList["ATTEN"];
                Powersupply   tempps  = (Powersupply)selectedEquipList["POWERSUPPLY"];
                // add logo infor
                logoStr += logger.AdapterLogString(0, "Setp2...SetAttenPoint:" + adjustAPDStruct.ApdCalPoint.ToString());
                // add logo infor
                bool ok = tempAtt.AttnValue(adjustAPDStruct.ApdCalPoint.ToString());
                // add logo infor
                logoStr += logger.AdapterLogString(0, ok.ToString());
                // close apc
                string apcstring = null;
                dut.APCStatus(out apcstring);
                if (apcstring == "ON" || apcstring == "FF")
                {
                    logoStr += logger.AdapterLogString(0, "Step3...Start close apc");
                    dut.APCOFF();
                    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 isclosed = dut.APCStatus(out apcstring);
                    if (apcstring == "OFF")
                    {
                        logoStr += logger.AdapterLogString(1, "APC OFF");
                    }
                    else
                    {
                        logoStr += logger.AdapterLogString(3, "APC OFF");
                    }
                }
                // close apc

                UInt32[] tempApdArray = new UInt32[adjustAPDStruct.ArrayListApdBiasPoints.Count];
                for (byte i = 0; i < adjustAPDStruct.ArrayListApdBiasPoints.Count; i++)
                {
                    tempApdArray[i] = Convert.ToUInt32(adjustAPDStruct.ArrayListApdBiasPoints[i].ToString());
                }
                logoStr += logger.AdapterLogString(0, "Step4...StartCalApd");
                ArrayList tempBerArray    = new ArrayList();
                ArrayList tempApdDacArray = new ArrayList();
                double    minBer          = -1;
                UInt32    targetAPDAC     = EnumMethod(tempApdArray, dut, tempED, adjustAPDStruct.ApdBiasStep, out tempBerArray, out tempApdDacArray, out minBer);
                minBer = Math.Round(minBer, 5);
                for (byte i = 0; i < Math.Min(tempBerArray.Count, tempApdDacArray.Count); i++)
                {
                    logoStr += logger.AdapterLogString(1, GlobalParameters.CurrentChannel.ToString());
                    logoStr += logger.AdapterLogString(1, tempApdDacArray[i].ToString() + "  " + tempApdDacArray[i].ToString());
                }
                logoStr      += logger.AdapterLogString(1, "minApdDac=" + targetAPDAC.ToString() + "  minBer=" + minBer.ToString());
                isApdAdjustOK = true;
                #region  CheckTempChange
                if (!tempratureADCArray.ContainsKey(GlobalParameters.CurrentTemp.ToString().Trim().ToUpper()))
                {
                    logoStr += logger.AdapterLogString(0, "Step4...TempChanged Read tempratureADC");
                    logoStr += logger.AdapterLogString(1, "realtemprature=" + GlobalParameters.CurrentTemp.ToString());

                    UInt16 tempratureADC;
                    dut.ReadTempADC(out tempratureADC, 1);
                    logoStr += logger.AdapterLogString(1, "tempratureADC=" + tempratureADC.ToString());
                    tempratureADCArray.Add(GlobalParameters.CurrentTemp.ToString().Trim().ToUpper(), tempratureADC.ToString().Trim());
                    tempratureADCArrayList.Add(tempratureADC);
                }
                #endregion
                #region  add current channel
                if (!adjustAPDtValueRecordsStruct.ContainsKey(GlobalParameters.CurrentChannel.ToString().Trim().ToUpper()))
                {
                    logoStr += logger.AdapterLogString(0, "Step6...add current channel records");
                    logoStr += logger.AdapterLogString(1, "GlobalParameters.CurrentChannel=" + GlobalParameters.CurrentChannel.ToString());
                    adjustAPDtValueRecordsStruct.Add(GlobalParameters.CurrentChannel.ToString().Trim().ToUpper(), new ArrayList());
                    adjustAPDtValueRecordsStruct[GlobalParameters.CurrentChannel.ToString().Trim().ToUpper()].Add(targetAPDAC);
                }
                else
                {
                    adjustAPDtValueRecordsStruct[GlobalParameters.CurrentChannel.ToString().Trim().ToUpper()].Add(targetAPDAC);
                }


                #endregion
                #region  CurveCoef

                if (adjustAPDtValueRecordsStruct.ContainsKey(GlobalParameters.CurrentChannel.ToString().Trim().ToUpper()))
                {
                    if (tempratureADCArray.Count >= 2 && adjustAPDtValueRecordsStruct[GlobalParameters.CurrentChannel.ToString().Trim().ToUpper()].Count >= 2)
                    {
                        int      tempCount        = Math.Min(tempratureADCArray.Count, adjustAPDtValueRecordsStruct[GlobalParameters.CurrentChannel.ToString().Trim().ToUpper()].Count);
                        double[] tempAPDDacArray  = new double[tempCount];
                        double[] tempTempAdcArray = new double[tempCount];
                        for (byte i = 0; i < tempCount; i++)
                        {
                            tempAPDDacArray[i]  = double.Parse(adjustAPDtValueRecordsStruct[GlobalParameters.CurrentChannel.ToString().Trim().ToUpper()][i].ToString());
                            tempTempAdcArray[i] = double.Parse(tempratureADCArrayList[i].ToString());
                        }
                        logoStr += logger.AdapterLogString(0, "Step8...Start Fitting Curve");

                        if (adjustAPDStruct.is1Stor2StorPid == 2)
                        {
                            double[] coefArray = algorithm.MultiLine(tempTempAdcArray, tempAPDDacArray, tempratureADCArray.Count, 2);
                            apdPowerCoefC = (float)coefArray[0];
                            apdPowerCoefB = (float)coefArray[1];
                            apdPowerCoefA = (float)coefArray[2];
                            apdCoefArray  = ArrayList.Adapter(coefArray);
                            apdCoefArray.Reverse();
                            for (byte i = 0; i < apdCoefArray.Count; i++)
                            {
                                logoStr += logger.AdapterLogString(1, "apdCoefArray[" + i.ToString() + "]=" + apdCoefArray[i].ToString() + " " + algorithm.ByteArraytoString(2, ",", algorithm.FloatToIEE754(apdCoefArray[i])));
                            }
                            logoStr += logger.AdapterLogString(0, "Step9...WriteCoef");

                            #region W&R Apddaccoefc
                            isWriteCoefCOk = dut.SetBiasdaccoefc(apdPowerCoefC.ToString());
                            if (isWriteCoefCOk)
                            {
                                isWriteCoefCOk = true;
                                logoStr       += logger.AdapterLogString(1, "isWriteCoefCOk:" + isWriteCoefCOk.ToString());
                            }
                            else
                            {
                                isWriteCoefCOk = false;
                                logoStr       += logger.AdapterLogString(3, "isWriteCoefCOk:" + isWriteCoefCOk.ToString());
                            }
                            #endregion
                            #region W&R Apddaccoefb
                            isWriteCoefBOk = dut.SetBiasdaccoefb(apdPowerCoefB.ToString());
                            if (isWriteCoefBOk)
                            {
                                isWriteCoefBOk = true;
                                logoStr       += logger.AdapterLogString(1, "isWriteCoefBOk:" + isWriteCoefBOk.ToString());
                            }
                            else
                            {
                                isWriteCoefBOk = false;
                                logoStr       += logger.AdapterLogString(3, "isWriteCoefBOk:" + isWriteCoefBOk.ToString());
                            }
                            #endregion
                            #region W&R Apddaccoefa
                            isWriteCoefAOk = dut.SetBiasdaccoefa(apdPowerCoefA.ToString());

                            if (isWriteCoefAOk)
                            {
                                isWriteCoefAOk = true;
                                logoStr       += logger.AdapterLogString(1, "isWriteCoefAOk:" + isWriteCoefAOk.ToString());
                            }
                            else
                            {
                                isWriteCoefAOk = false;
                                logoStr       += logger.AdapterLogString(3, "isWriteCoefAOk:" + isWriteCoefAOk.ToString());
                            }
                            #endregion
                            if (isWriteCoefAOk & isWriteCoefBOk & isWriteCoefCOk)
                            {
                                isCalApdPowerOk = true;
                                logoStr        += logger.AdapterLogString(1, "isCalApdPowerOk:" + isCalApdPowerOk.ToString());
                            }
                            else
                            {
                                isCalApdPowerOk = false;
                                logoStr        += logger.AdapterLogString(3, "isCalApdPowerOk:" + isCalApdPowerOk.ToString());
                            }
                        }
                        else if (adjustAPDStruct.is1Stor2StorPid == 1)
                        {
                            double[] coefArray = algorithm.MultiLine(tempTempAdcArray, tempAPDDacArray, tempratureADCArray.Count, 1);
                            apdPowerCoefC = (float)coefArray[0];
                            apdPowerCoefB = (float)coefArray[1];
                            apdPowerCoefA = (float)coefArray[2];
                            apdCoefArray  = ArrayList.Adapter(coefArray);
                            apdCoefArray.Reverse();
                            for (byte i = 0; i < apdCoefArray.Count; i++)
                            {
                                logoStr += logger.AdapterLogString(1, "apdCoefArray[" + i.ToString() + "]=" + apdCoefArray[i].ToString() + " " + algorithm.ByteArraytoString(2, ",", algorithm.FloatToIEE754(apdCoefArray[i])));
                            }
                            logoStr += logger.AdapterLogString(0, "Step9...WriteCoef");

                            #region W&R Apddaccoefc
                            isWriteCoefCOk = dut.SetBiasdaccoefc(apdPowerCoefC.ToString());

                            if (isWriteCoefCOk)
                            {
                                isWriteCoefCOk = true;
                                logoStr       += logger.AdapterLogString(1, "isWriteCoefCOk:" + isWriteCoefCOk.ToString());
                            }
                            else
                            {
                                isWriteCoefCOk = false;
                                logoStr       += logger.AdapterLogString(3, "isWriteCoefCOk:" + isWriteCoefCOk.ToString());
                            }
                            #endregion
                            #region W&R Apddaccoefb
                            isWriteCoefBOk = dut.SetBiasdaccoefb(apdPowerCoefB.ToString());
                            if (isWriteCoefBOk)
                            {
                                isWriteCoefBOk = true;
                                logoStr       += logger.AdapterLogString(0, "isWriteCoefBOk:" + isWriteCoefBOk.ToString());
                            }
                            else
                            {
                                isWriteCoefBOk = false;
                                logoStr       += logger.AdapterLogString(3, "isWriteCoefBOk:" + isWriteCoefBOk.ToString());
                            }
                            #endregion

                            if (isWriteCoefBOk & isWriteCoefCOk)
                            {
                                isCalApdPowerOk = true;
                                logoStr        += logger.AdapterLogString(1, "isCalApdPowerOk:" + isCalApdPowerOk.ToString());
                            }
                            else
                            {
                                isCalApdPowerOk = false;
                                logoStr        += logger.AdapterLogString(3, "isCalApdPowerOk:" + isCalApdPowerOk.ToString());
                            }
                        }
                    }
                }

                #endregion
                AnalysisOutputParameters(outputParameters);
                logger.FlushLogBuffer();
                return(isApdAdjustOK);
            }
            else
            {
                logoStr      += logger.AdapterLogString(4, "Equipments is not enough!");
                isApdAdjustOK = false;
                logger.FlushLogBuffer();
                return(isApdAdjustOK);
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        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);
            }
        }