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;
                }
            }
        }
 protected void SetAttenValue(Attennuator tempAtt, double attValue)
 {
     lock (tempAtten)
     {
         tempAtt.AttnValue(attValue.ToString());
     }
 }
Пример #3
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);
        }
Пример #4
0
        public override bool SelectEquipment(EquipmentList aEquipList)
        {
            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("ATTEN"))
                    {
                        selectedEquipList.Add("ATTEN", tempValues[i]);
                        isOK = true;
                    }
                    if (tempKeys[i].ToUpper().Contains("POWERSUPPLY"))
                    {
                        selectedEquipList.Add("POWERSUPPLY", tempValues[i]);
                        isOK = true;
                    }
                    if (tempKeys[i].ToUpper().Contains("NA_OPTICALSWITCH"))
                    {
                        tempValues[i].CheckEquipmentRole(2, GlobalParameters.CurrentChannel);
                    }
                }
                tempAtten = (Attennuator)selectedEquipList["ATTEN"];
                tempps    = (Powersupply)selectedEquipList["POWERSUPPLY"];
                if (tempAtten != null && tempps != null)
                {
                    isOK = true;
                }
                else
                {
                    if (tempAtten == null)
                    {
                        Log.SaveLogToTxt("ATTEN =NULL");
                    }
                    if (tempps == null)
                    {
                        Log.SaveLogToTxt("POWERSUPPLY =NULL");
                    }

                    OutPutandFlushLog();
                    isOK = false;
                }
                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                    return(isOK);
                }
                return(isOK);
            }
        }
Пример #5
0
        public override bool SelectEquipment(EquipmentList equipmentList)
        {
            selectedEquipList.Clear();

            if (equipmentList.Count == 0)
            {
                selectedEquipList.Add("DUT", dut);
                return(false);
            }
            else
            {
                bool isOK = false;

                for (byte i = 0; i < equipmentList.Count; i++)
                {
                    if (equipmentList.Keys[i].ToUpper().Contains("POWERSUPPLY"))
                    {
                        supply = (Powersupply)equipmentList.Values[i];
                        isOK   = true;
                    }

                    if (equipmentList.Keys[i].ToUpper().Contains("AQ2211ATTEN"))
                    {
                        attennuator = (Attennuator)equipmentList.Values[i];
                        isOK        = true;
                    }

                    if (equipmentList.Keys[i].ToUpper().Contains("NA_OPTICALSWITCH"))
                    {
                        equipmentList.Values[i].CheckEquipmentRole(1, GlobalParameters.CurrentChannel);
                    }
                }

                if (supply != null)
                {
                    isOK = true;
                }
                else
                {
                    if (supply == null)
                    {
                        Log.SaveLogToTxt("POWERSUPPLY =NULL");
                    }
                    isOK = false;
                    OutPutandFlushLog();
                }

                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                }
                return(isOK);
            }
        }
Пример #6
0
 private bool LOSAQuickTest(Attennuator inputatt, double startAttValue, bool isLosAINput)
 {
     lock (tempAtten)
     {
         bool isLosA = isLosAINput;
         inputatt.AttnValue(startAttValue.ToString(), 1);
         Thread.Sleep(300);
         isLosA = dut.ChkRxLos();
         losA   = startAttValue;
         return(isLosA);
     }
 }
Пример #7
0
        private bool LOSDQuickTest(Attennuator inputatt, double startAttValue, bool isLosDinput)
        {
            bool isLosD = isLosDinput;

            inputatt.AttnValue(startAttValue.ToString());
            Thread.Sleep(200);
            isLosD = dut.ChkRxLos();
            Thread.Sleep(1000);
            isLosD = dut.ChkRxLos();
            losD   = startAttValue;
            return(isLosD == false);
        }
        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;
                }
            }
        }
Пример #9
0
        private bool LOSDDetailTest(Attennuator inputatt, double startAttValue, bool isLosDinput)
        {
            bool isLosD = isLosDinput;
            int  i      = 0;

            do
            {
                inputatt.AttnValue(startAttValue.ToString());
                Thread.Sleep(200);
                isLosD = dut.ChkRxLos();
                Thread.Sleep(1000);
                isLosD = dut.ChkRxLos();

                if (isLosD == true)
                {
                    startAttValue += testRXLosADStruct.LosADStep;
                }
                losD = startAttValue;
            } while (isLosD == true && startAttValue <= testRXLosADStruct.LosDMax && i < 30);
            return(isLosD == false);
        }
Пример #10
0
        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;
                }
            }
        }
Пример #11
0
        private bool LOSADetailTest(Attennuator inputatt, double startAttValue, bool isLosAINput)
        {
            bool isLosA = isLosAINput;
            int  i      = 0;

            do
            {
                inputatt.AttnValue(startAttValue.ToString());
                Thread.Sleep(200);
                isLosA = dut.ChkRxLos();
                Thread.Sleep(1000);
                isLosA = dut.ChkRxLos();
                if (isLosA == false)
                {
                    startAttValue -= testRXLosADStruct.LosADStep;
                    i++;
                }

                losA = startAttValue;
            } while (isLosA == false && startAttValue >= testRXLosADStruct.LosAMin && i < 30);
            return(isLosA);
        }
Пример #12
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);
        }
Пример #13
0
        private bool LOSADetailTest(Attennuator inputatt, double startAttValue, bool isLosAINput)
        {
            lock (tempAtten)
            {
                bool isLosA   = isLosAINput;
                int  i        = 0;
                int  RunCount = Convert.ToInt16((testRXLosADStruct.LosDMax + 1 - testRXLosADStruct.LosAMin) / testRXLosADStruct.LosADStep);
                do
                {
                    inputatt.AttnValue(startAttValue.ToString());
                    isLosA = dut.ChkRxLos();
                    Thread.Sleep(100);
                    isLosA = dut.ChkRxLos();
                    if (isLosA == false)
                    {
                        startAttValue -= testRXLosADStruct.LosADStep;
                        i++;
                    }

                    losA = startAttValue;
                } while (isLosA == false && startAttValue >= testRXLosADStruct.LosAMin && i < RunCount);
                return(isLosA);
            }
        }
Пример #14
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"))
                    {
                        pED = (ErrorDetector)aEquipList.Values[i];
                    }
                    if (tempKeys[i].ToUpper().Contains("ATTEN"))
                    {
                        // selectedEquipList.Add("ATTEN", tempValues[i]);
                        pAtt = (Attennuator)aEquipList.Values[i];
                    }
                    if (tempKeys[i].ToUpper().Contains("POWERSUPPLY"))
                    {
                        pPS = (Powersupply)aEquipList.Values[i];
                    }
                    if (tempKeys[i].ToUpper().Contains("NA_OPTICALSWITCH"))
                    {
                        tempValues[i].CheckEquipmentRole(2, GlobalParameters.CurrentChannel);
                    }
                    //OpticalSwitch
                }

                if (pED != null && pAtt != null && pPS != null)
                {
                    isOK = true;
                }
                else
                {
                    if (pED == null)
                    {
                        Log.SaveLogToTxt("ERRORDETE =NULL");
                    }
                    if (pAtt == null)
                    {
                        Log.SaveLogToTxt("ATTEN =NULL");
                    }
                    if (pPS == null)
                    {
                        Log.SaveLogToTxt("POWERSUPPLY =NULL");
                    }
                    isOK = false;
                    OutPutandFlushLog();
                }
                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                }
                return(isOK);
            }
        }
Пример #15
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("PPG"))
                    {
                        selectedEquipList.Add("PPG", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("ERRORDETE"))
                    {
                        selectedEquipList.Add("ERRORDETE", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("ATTEN_RX"))
                    {
                        selectedEquipList.Add("ATTEN_RX", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("ATTEN_TX"))
                    {
                        selectedEquipList.Add("ATTEN_TX", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("POWERMETER"))
                    {
                        selectedEquipList.Add("POWERMETER", 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);
                    }
                }

                tempPPG        = (PPG)selectedEquipList["PPG"];
                tempED         = (ErrorDetector)selectedEquipList["ERRORDETE"];
                tempAttenRX    = (Attennuator)selectedEquipList["ATTEN_RX"];
                tempAttenTX    = (Attennuator)selectedEquipList["ATTEN_TX"];
                tempPowerMeter = (PowerMeter)selectedEquipList["POWERMETER"];
                tempps         = (Powersupply)selectedEquipList["POWERSUPPLY"];
                if (tempPPG != null && tempED != null && tempAttenRX != null && tempAttenTX != null && tempPowerMeter != null && tempps != null)
                {
                    isOK = true;
                }
                else
                {
                    if (tempPPG == null)
                    {
                        Log.SaveLogToTxt("PPG =NULL");
                    }
                    if (tempED == null)
                    {
                        Log.SaveLogToTxt("ERRORDETE =NULL");
                    }
                    if (tempAttenRX == null)
                    {
                        Log.SaveLogToTxt("ATTEN_RX =NULL");
                    }
                    if (tempAttenTX == null)
                    {
                        Log.SaveLogToTxt("ATTEN_TX =NULL");
                    }
                    if (tempPowerMeter == null)
                    {
                        Log.SaveLogToTxt("POWERMETER =NULL");
                    }
                    if (tempps == null)
                    {
                        Log.SaveLogToTxt("POWERSUPPLY =NULL");
                    }
                    isOK = false;
                    OutPutandFlushLog();
                    isOK = false;
                }
                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                }
                else
                {
                    isOK = false;
                }
                return(isOK);
            }
        }
Пример #16
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);
            }
        }
Пример #17
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);
            }
        }
Пример #18
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);
            }
        }
Пример #19
0
        protected override bool StartTest()
        {
            logger.FlushLogBuffer();
            logoStr = "";
            if (AnalysisInputParameters(inputParameters) == false)
            {
                logger.FlushLogBuffer();
                return(false);
            }
            if (selectedEquipList["DUT"] != null && selectedEquipList["ATTEN"] != null && selectedEquipList["POWERSUPPLY"] != null)
            {
                Attennuator tempAtt = (Attennuator)selectedEquipList["ATTEN"];
                Powersupply tempps  = (Powersupply)selectedEquipList["POWERSUPPLY"];
                // close apc
                string apcstring = null;
                dut.APCStatus(out apcstring);
                if (apcstring == "ON" || apcstring == "FF")
                {
                    logoStr += logger.AdapterLogString(0, "Step2...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 NOT OFF");
                    }
                }
                // close apc
                logoStr += logger.AdapterLogString(0, "Step3...Start Adjust LosA");
                if (adjustLosStruct.islosalosdcombin)
                {
                    logoStr += logger.AdapterLogString(1, "Set LosA RxPower:" + adjustLosStruct.LosAInputPower.ToString());
                    tempAtt.AttnValue(adjustLosStruct.LosAInputPower.ToString());
                    isLosA   = LosAEqualLosDAdjust(adjustLosStruct.LosAVoltageStartValue, adjustLosStruct.LosAVoltageTuneStep, adjustLosStruct.LosAVoltageUperLimit, adjustLosStruct.LosAVoltageLowLimit, dut, adjustLosStruct.LosToleranceStep, out targetLosAac);
                    logoStr += logger.AdapterLogString(1, "targetLosADac=" + targetLosDac.ToString());
                    logoStr += logger.AdapterLogString(1, isLosA.ToString());
                }
                else
                {
                    logoStr += logger.AdapterLogString(1, "Set LosA RxPower:" + adjustLosStruct.LosAInputPower.ToString());

                    tempAtt.AttnValue(adjustLosStruct.LosAInputPower.ToString());
                    isLosA   = OneSectionMethodLosAdjust(adjustLosStruct.LosAVoltageStartValue, adjustLosStruct.LosAVoltageTuneStep, adjustLosStruct.LosAVoltageUperLimit, adjustLosStruct.LosAVoltageLowLimit, dut, adjustLosStruct.LosToleranceStep, out targetLosDac);
                    logoStr += logger.AdapterLogString(1, "targetLosADac=" + targetLosDac.ToString());
                    logoStr += logger.AdapterLogString(1, isLosA.ToString());
                    logoStr += logger.AdapterLogString(0, "Step4...Start Adjust LosD");
                    logoStr += logger.AdapterLogString(1, "Set LosD RxPower:" + adjustLosStruct.LosDInputPower.ToString());

                    tempAtt.AttnValue(adjustLosStruct.LosDInputPower.ToString());
                    isLosD = OneSectionMethodLosDAdjust(adjustLosStruct.LosDVoltageStartValue, adjustLosStruct.LosDVoltageTuneStep, adjustLosStruct.LosDVoltageUperLimit, adjustLosStruct.LosDVoltageLowLimit, dut, adjustLosStruct.LosToleranceStep, out targetLosDac);

                    logoStr += logger.AdapterLogString(1, "targetLosDDac=" + targetLosDac.ToString());
                    logoStr += logger.AdapterLogString(1, isLosD.ToString());
                }

                AnalysisOutputParameters(outputParameters);
                if (adjustLosStruct.islosalosdcombin)
                {
                    logger.FlushLogBuffer();
                    return(isLosA);
                }
                else
                {
                    logger.FlushLogBuffer();
                    return(isLosA == true && isLosD == true);
                }
            }
            else
            {
                logoStr += logger.AdapterLogString(4, "Equipments is not enough!");
                logger.FlushLogBuffer();
                return(false);
            }
        }
Пример #20
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);
            }
        }
        protected override bool StartTest()
        {
            logger.FlushLogBuffer();
            logoStr = "";
            if (!channelArray.ContainsKey(GlobalParameters.CurrentChannel.ToString().Trim().ToUpper()))
            {
                channelArray.Add(GlobalParameters.CurrentChannel.ToString().Trim().ToUpper(), GlobalParameters.CurrentChannel.ToString().Trim().ToUpper());
            }
            else
            {
                logger.AdapterLogString(0, "Curren Channel had exist");
                return(true);
            }
            if (AnalysisInputParameters(inputParameters) == false)
            {
                logger.FlushLogBuffer();
                return(false);
            }
            if (selectedEquipList["ATTEN"] != null && selectedEquipList["DUT"] != null && selectedEquipList["POWERSUPPLY"] != null)
            {
                bool isWriteCoefCOk = false;
                bool isWriteCoefBOk = false;
                bool isWriteCoefAOk = false;

                Attennuator tempAtten = (Attennuator)selectedEquipList["ATTEN"];
                Powersupply tempps    = (Powersupply)selectedEquipList["POWERSUPPLY"];
                // close apc
                string apcstring = null;
                dut.APCStatus(out apcstring);
                if (apcstring == "ON" || apcstring == "FF")
                {
                    logoStr += logger.AdapterLogString(0, "Step2...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(500);
                    bool isclosed = dut.APCStatus(out apcstring);
                    if (apcstring == "OFF")
                    {
                        logoStr += logger.AdapterLogString(1, "APC OFF");
                    }
                    else
                    {
                        logoStr += logger.AdapterLogString(3, "APC NOT OFF");
                    }
                }
                // close apc
                rxPoweruwArray  = new double[calRxDmiStruct.ArrayListRxPower.Count];
                rxPowerAdcArray = new double[calRxDmiStruct.ArrayListRxPower.Count];
                for (byte i = 0; i < calRxDmiStruct.ArrayListRxPower.Count; i++)
                {
                    rxPoweruwArray[i] = algorithm.ChangeDbmtoUw(Convert.ToDouble(calRxDmiStruct.ArrayListRxPower[i])) * 10;
                    tempAtten.AttnValue(calRxDmiStruct.ArrayListRxPower[i].ToString());
                    Thread.Sleep(1000);
                    UInt16 Temp;
                    dut.ReadRxpADC(out Temp);
                    rxPowerAdcArray[i] = Convert.ToDouble(Temp);
                }
                logoStr += logger.AdapterLogString(0, "Step3...Start Fitting Curve");
                if (calRxDmiStruct.is1Stor2StorPid == 1)
                {
                    double[] coefArray = algorithm.MultiLine(rxPowerAdcArray, rxPoweruwArray, calRxDmiStruct.ArrayListRxPower.Count, 1);
                    rxDmiCoefC = (float)coefArray[0];
                    rxDmiCoefB = (float)coefArray[1];
                    double[] tempCoefArray = new double[2] {
                        rxDmiCoefC, rxDmiCoefB
                    };

                    rxDmiCoefArray = ArrayList.Adapter(tempCoefArray);
                    rxDmiCoefArray.Reverse();
                    for (byte i = 0; i < rxDmiCoefArray.Count; i++)
                    {
                        logoStr += logger.AdapterLogString(1, "rxDmiCoefArray[" + i.ToString() + "]=" + rxDmiCoefArray[i].ToString() + " " + algorithm.ByteArraytoString(2, ",", algorithm.INT16To2Bytes(rxDmiCoefArray[i])));
                    }
                    logoStr += logger.AdapterLogString(0, "Step4...WriteCoef");
                    #region W&RRxpcoefc
                    isWriteCoefCOk = dut.SetRxpcoefc(rxDmiCoefC.ToString());

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

                        logoStr += logger.AdapterLogString(3, "WriterxDmiCoefC:" + isWriteCoefCOk.ToString());
                    }
                    #endregion
                    #region W&R Rxpcoefb
                    isWriteCoefBOk = dut.SetRxpcoefb(rxDmiCoefB.ToString());

                    if (isWriteCoefBOk)
                    {
                        isWriteCoefBOk = true;
                        logoStr       += logger.AdapterLogString(1, "WriterxDmiCoefB:" + isWriteCoefBOk.ToString());
                    }
                    else
                    {
                        isWriteCoefCOk = false;
                        logoStr       += logger.AdapterLogString(3, "WriterxDmiCoefB:" + isWriteCoefBOk.ToString());
                    }
                    #endregion
                    if (isWriteCoefCOk & isWriteCoefBOk)
                    {
                        isCalRxDmiOk = true;
                        logoStr     += logger.AdapterLogString(1, "isCalRxDmiOk:" + isCalRxDmiOk.ToString());
                    }
                    else
                    {
                        isCalRxDmiOk = false;
                        logoStr     += logger.AdapterLogString(3, "isCalRxDmiOk:" + isCalRxDmiOk.ToString());
                    }
                }
                else if (calRxDmiStruct.is1Stor2StorPid == 2)
                {
                    double[] coefArray = algorithm.MultiLine(rxPowerAdcArray, rxPoweruwArray, calRxDmiStruct.ArrayListRxPower.Count, 2);
                    rxDmiCoefC     = (float)coefArray[0];
                    rxDmiCoefB     = (float)coefArray[1];
                    rxDmiCoefA     = (float)coefArray[2];
                    rxDmiCoefArray = ArrayList.Adapter(coefArray);
                    rxDmiCoefArray.Reverse();
                    for (byte i = 0; i < rxDmiCoefArray.Count; i++)
                    {
                        logoStr += logger.AdapterLogString(1, "rxDmiCoefArray[" + i.ToString() + "]=" + rxDmiCoefArray[i].ToString() + " " + algorithm.ByteArraytoString(2, ",", algorithm.INT16To2Bytes(rxDmiCoefArray[i])));
                    }
                    logoStr += logger.AdapterLogString(0, "Step4...WriteCoef");

                    #region W&RRxpcoefc
                    isWriteCoefCOk = dut.SetRxpcoefc(rxDmiCoefC.ToString());

                    if (isWriteCoefCOk)
                    {
                        isWriteCoefCOk = true;
                        logoStr       += logger.AdapterLogString(1, "WriterxDmiCoefC:" + isWriteCoefCOk.ToString());
                    }
                    else
                    {
                        isWriteCoefCOk = false;
                        logoStr       += logger.AdapterLogString(3, "WriterxDmiCoefC:" + isWriteCoefCOk.ToString());
                    }
                    #endregion
                    #region W&R Rxpcoefb
                    isWriteCoefBOk = dut.SetRxpcoefb(rxDmiCoefB.ToString());
                    //dut.ReadRxpcoefb(out tempString);
                    if (isWriteCoefBOk)
                    {
                        isWriteCoefBOk = true;
                        logoStr       += logger.AdapterLogString(1, "WriterxDmiCoefB:" + isWriteCoefBOk.ToString());
                    }
                    else
                    {
                        isWriteCoefCOk = false;
                        logoStr       += logger.AdapterLogString(3, "WriterxDmiCoefB:" + isWriteCoefBOk.ToString());
                    }
                    #endregion
                    #region W&R Rxpcoefa
                    isWriteCoefAOk = dut.SetRxpcoefa(rxDmiCoefA.ToString());

                    if (isWriteCoefAOk)
                    {
                        isWriteCoefAOk = true;
                        logoStr       += logger.AdapterLogString(1, "WriterxDmiCoefA:" + isWriteCoefAOk.ToString());
                    }
                    else
                    {
                        isWriteCoefAOk = false;
                        logoStr       += logger.AdapterLogString(3, "WriterxDmiCoefA:" + isWriteCoefAOk.ToString());
                    }
                    #endregion
                    if (isWriteCoefCOk & isWriteCoefBOk & isWriteCoefAOk)
                    {
                        isCalRxDmiOk = true;
                        logoStr     += logger.AdapterLogString(1, "isCalRxDmiOk:" + isCalRxDmiOk.ToString());
                    }
                    else
                    {
                        isCalRxDmiOk = false;
                        logoStr     += logger.AdapterLogString(3, "isCalRxDmiOk:" + isCalRxDmiOk.ToString());
                    }
                }
            }
            else
            {
                isCalRxDmiOk = false;
                logoStr     += logger.AdapterLogString(4, "Equipments is not enough!");
                logger.FlushLogBuffer();
                return(isCalRxDmiOk);
            }
            AnalysisOutputParameters(outputParameters);
            logger.FlushLogBuffer();
            return(isCalRxDmiOk);
        }
Пример #22
0
        public override bool SelectEquipment(EquipmentList eqList)
        {
            selectedEquipList.Clear();
            if (eqList.Count == 0)
            {
                selectedEquipList.Add("DUT", dut);
                return(false);
            }
            else
            {
                bool isOK = false;
                selectedEquipList.Clear();
                IList <string>        tempKeys   = eqList.Keys;
                IList <EquipmentBase> tempValues = eqList.Values;
                for (byte i = 0; i < eqList.Count; i++)
                {
                    if (tempKeys[i].ToUpper().Contains("ATTEN_RX"))
                    {
                        selectedEquipList.Add("ATTEN_RX", tempValues[i]);
                        isOK = true;
                    }

                    if (tempKeys[i].ToUpper().Contains("SCOPE"))
                    {
                        selectedEquipList.Add("SCOPE", tempValues[i]);
                        isOK = true;
                    }

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

                attRx  = (Attennuator)selectedEquipList["ATTEN_RX"];
                scope  = (Scope)selectedEquipList["SCOPE"];
                supply = (Powersupply)selectedEquipList["POWERSUPPLY"];

                if (attRx != null && scope != null && supply != null)
                {
                    isOK = true;
                }
                else
                {
                    if (attRx == null)
                    {
                        Log.SaveLogToTxt("attRx =NULL");
                    }

                    if (scope == null)
                    {
                        Log.SaveLogToTxt("scope =NULL");
                    }

                    if (supply == null)
                    {
                        Log.SaveLogToTxt("supply =NULL");
                    }

                    OutPutandFlushLog();
                    isOK = false;
                }
                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                    return(isOK);
                }
                return(isOK);
            }
        }
Пример #23
0
        protected override bool StartTest()
        {
            logger.FlushLogBuffer();
            logoStr = "";
            if (AnalysisInputParameters(inputParameters) == false)
            {
                logger.FlushLogBuffer();
                return(false);
            }
            if (selectedEquipList["DUT"] != null && selectedEquipList["ATTEN"] != null && selectedEquipList["POWERSUPPLY"] != null)
            {
                Powersupply tempps    = (Powersupply)selectedEquipList["POWERSUPPLY"];
                Attennuator tempAtten = (Attennuator)selectedEquipList["ATTEN"];
                // 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(500);
                    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
                logoStr += logger.AdapterLogString(0, "Step3...Start Test RxDmi");
                double[] tempRxPowerDmiArray = new double[testRxPowerDmiStruct.ArrayListRxInputPower.Count];
                double[] tempRxPowerErrArray = new double[testRxPowerDmiStruct.ArrayListRxInputPower.Count];
                for (byte i = 0; i < testRxPowerDmiStruct.ArrayListRxInputPower.Count; i++)
                {
                    tempAtten.AttnValue(testRxPowerDmiStruct.ArrayListRxInputPower[i].ToString());
                    Thread.Sleep(1000);
                    tempRxPowerDmiArray[i] = dut.ReadDmiRxp();
                    tempRxPowerErrArray[i] = Math.Abs(Convert.ToDouble(testRxPowerDmiStruct.ArrayListRxInputPower[i].ToString()) - tempRxPowerDmiArray[i]);
                    logoStr += logger.AdapterLogString(1, "testRxPowerDmiStruct.ArrayListRxInputPower[" + i.ToString() + "]:" + testRxPowerDmiStruct.ArrayListRxInputPower[i].ToString() + "tempRxPowerDmiArray[" + i.ToString() + "]:" + tempRxPowerDmiArray[i].ToString() + "tempRxPowerErrArray[" + i.ToString() + "]" + tempRxPowerErrArray[i].ToString());
                }
                byte maxIndex;
                MaxErr      = algorithm.SelectMaxValue(ArrayList.Adapter(tempRxPowerErrArray), out maxIndex);
                ErrMaxPoint = Convert.ToDouble(testRxPowerDmiStruct.ArrayListRxInputPower[maxIndex].ToString());
                logoStr    += logger.AdapterLogString(1, "ErrMaxPoint=" + ErrMaxPoint.ToString() + "  MaxErr" + MaxErr.ToString());
                AnalysisOutputParameters(outputParameters);
                logger.FlushLogBuffer();
                return(true);
            }
            else
            {
                logoStr += logger.AdapterLogString(4, "Equipments is not enough!");
                logger.FlushLogBuffer();
                return(false);
            }
        }
Пример #24
0
        public override bool SelectEquipment(EquipmentList aEquipList)
        {
            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("TX_ATTEN"))
                    {
                        selectedEquipList.Add("ATTEN_TX", tempValues[i]);
                        isOK = true;
                    }

                    if (tempKeys[i].ToUpper().Contains("POWERMETER"))
                    {
                        selectedEquipList.Add("POWERMETER", tempValues[i]);
                        isOK = true;
                    }
                    if (tempKeys[i].ToUpper().Contains("SCOPE"))
                    {
                        selectedEquipList.Add("SCOPE", tempValues[i]);
                        isOK = true;
                    }
                    if (tempKeys[i].ToUpper().Contains("TX_PPG"))
                    {
                        selectedEquipList.Add("PPG", tempValues[i]);
                        isOK = true;
                    }
                    if (tempKeys[i].ToUpper().Contains("NA_OPTICALSWITCH"))
                    {
                        tempValues[i].CheckEquipmentRole(2, GlobalParameters.CurrentChannel);
                        pOpticalSwitch = (OpticalSwitch)selectedEquipList["NA_OPTICALSWITCH"];
                    }
                }
                // tempps = (Powersupply)selectedEquipList["POWERSUPPLY"];
                pAtt        = (Attennuator)selectedEquipList["ATTEN_TX"];
                pPowerMeter = (PowerMeter)selectedEquipList["POWERMETER"];
                pPPG        = (PPG)selectedEquipList["PPG"];
                pScope      = (Scope)selectedEquipList["SCOPE"];

                // pOpticalSwitch = (OpticalSwitch)selectedEquipList["NA_OPTICALSWITCH"];

                if (pAtt != null && pPowerMeter != null && pPPG != null && pScope != null)
                {
                    isOK = true;
                }
                else
                {
                    if (pAtt == null)
                    {
                        Log.SaveLogToTxt("ATTEN =NULL");
                    }
                    if (pPowerMeter == null)
                    {
                        Log.SaveLogToTxt("pPowerMeter =NULL");
                    }
                    if (pPPG == null)
                    {
                        Log.SaveLogToTxt("pPPG =NULL");
                    }
                    if (pScope == null)
                    {
                        Log.SaveLogToTxt("pScope =NULL");
                    }



                    OutPutandFlushLog();
                    isOK = false;
                }
                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                    return(isOK);
                }
                return(isOK);
            }
        }
Пример #25
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);
            }
        }
Пример #26
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("SCOPE"))
                    {
                        selectedEquipList.Add("SCOPE", tempValues[i]);
                        isOK = true;
                    }
                    if (tempKeys[i].ToUpper().Contains("POWERSUPPLY"))
                    {
                        selectedEquipList.Add("POWERSUPPLY", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("ATTEN"))
                    {
                        selectedEquipList.Add("ATTEN", tempValues[i]);
                    }
                    if (tempKeys[i].ToUpper().Contains("NA_OPTICALSWITCH"))
                    {
                        tempValues[i].CheckEquipmentRole(2, GlobalParameters.CurrentChannel);
                    }
                }
                tempps = (Powersupply)selectedEquipList["POWERSUPPLY"];
                try
                {
                    if (selectedEquipList["ATTEN"] == null)
                    {
                        tempAtten = null;
                    }
                    else
                    {
                        tempAtten = (Attennuator)selectedEquipList["ATTEN"];
                    }
                }
                catch (InnoExCeption ex)//from driver
                {
                    //Log.SaveLogToTxt(ex.ID + ": " + ex.Message + "\r\n" + ex.StackTrace);
                    exceptionList.Add(ex);
                }
                catch (Exception error)//from itself
                {
                    //one way: deal this exception itself
                    InnoExCeption ex = new InnoExCeption(ExceptionDictionary.Code._0xFFFFF, error.StackTrace);
                    //Log.SaveLogToTxt(ex.ID + ": " + ex.Message + "\r\n" + ex.StackTrace);
                    exceptionList.Add(ex);
                    //the other way is: should throw exception, rather than the above three code. see below:
                    //throw new InnoExCeption(ExceptionDictionary.Code._0xFFFFF, error.StackTrace);
                }
                // if (selectedEquipList["ATTEN"]==null)
                //{
                //    tempAtten = null;
                //}
                //else
                //{
                //    tempAtten = (Attennuator)selectedEquipList["ATTEN"];
                //}
                tempScope = (Scope)selectedEquipList["SCOPE"];
                if (tempps != null && tempScope != null)
                {
                    if (tempAtten == null)
                    {
                        Log.SaveLogToTxt("ATTEN =NULL");
                    }

                    isOK = true;
                }
                else
                {
                    if (tempScope == null)
                    {
                        Log.SaveLogToTxt("SCOPE =NULL");
                    }
                    if (tempAtten == null)
                    {
                        Log.SaveLogToTxt("ATTEN =NULL");
                    }
                    if (tempps == null)
                    {
                        Log.SaveLogToTxt("POWERSUPPLY =NULL");
                    }

                    OutPutandFlushLog();
                    isOK = false;
                }
                if (isOK)
                {
                    selectedEquipList.Add("DUT", dut);
                    return(isOK);
                }

                return(isOK);
            }
        }
Пример #27
0
        protected override bool StartTest()
        {
            logger.FlushLogBuffer();
            logoStr = "";
            if (AnalysisInputParameters(inputParameters) == false)
            {
                logger.FlushLogBuffer();
                return(false);
            }
            bool   isLosA = false;
            bool   isLosD = true;
            double tempRxPoint;

            tempRxPoint = testRXLosADStruct.LosAMax;
            if (selectedEquipList["DUT"] != null && selectedEquipList["ATTEN"] != 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(0, "APC ON");
                    }
                    else
                    {
                        logoStr += logger.AdapterLogString(3, "APC NOT ON");
                    }
                }
                // open apc
                Attennuator tempAtten = (Attennuator)selectedEquipList["ATTEN"];
                logoStr += logger.AdapterLogString(0, "Step3...TestLosA");
                if (testRXLosADStruct.isLosDetail)
                {
                    isLosA = LOSADetailTest(tempAtten, tempRxPoint, false);
                }
                else
                {
                    isLosA = LOSAQuickTest(tempAtten, testRXLosADStruct.LosAMin, false);
                }

                if (isLosA == false)
                {
                    logoStr += logger.AdapterLogString(3, "losA=" + isLosA.ToString());
                    return(false);
                }
                tempRxPoint = losA;
                logoStr    += logger.AdapterLogString(1, "losA=" + losA.ToString());
                logoStr    += logger.AdapterLogString(0, "Step5...TestLosD");
                if (testRXLosADStruct.isLosDetail)
                {
                    isLosD = LOSDDetailTest(tempAtten, tempRxPoint, true);
                }
                else
                {
                    isLosD = LOSDQuickTest(tempAtten, testRXLosADStruct.LosDMax, true);
                }

                if (isLosD == false)
                {
                    logoStr += logger.AdapterLogString(3, "losD=" + (!isLosD).ToString());
                    return(false);
                }
                losH     = losD - losA;
                logoStr += logger.AdapterLogString(1, "losD=" + losD.ToString() + "losH=" + losH.ToString());
                AnalysisOutputParameters(outputParameters);
                logger.FlushLogBuffer();
                return((isLosD == true) && (isLosA == true));
            }
            else
            {
                logoStr += logger.AdapterLogString(4, "Equipments is not enough!");
                logger.FlushLogBuffer();
                return(false);
            }
        }