Пример #1
0
        protected override bool StartTest()
        {
            lock (tempAtten)
            {
                logoStr = "";
                if (AnalysisInputParameters(inputParameters) == false)
                {
                    OutPutandFlushLog();
                    return(false);
                }

                if (tempps != null && tempAtten != null)
                {
                    // open apc
                    //CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODON));
                    // open apc
                    Log.SaveLogToTxt("Step3...Start Test RxDmi");
                    double[] tempRxPowerDmiArray    = new double[testRxPowerDmiStruct.ArrayListRxInputPower.Count];
                    double[] tempRxPowerErrArray    = new double[testRxPowerDmiStruct.ArrayListRxInputPower.Count];
                    double[] tempRxPowerErrRawArray = new double[testRxPowerDmiStruct.ArrayListRxInputPower.Count];
                    tempAtten.AttnValue(testRxPowerDmiStruct.ArrayListRxInputPower[0].ToString(), 1);
                    Thread.Sleep(3000);
                    for (byte i = 0; i < testRxPowerDmiStruct.ArrayListRxInputPower.Count; i++)
                    {
                        tempAtten.AttnValue(testRxPowerDmiStruct.ArrayListRxInputPower[i].ToString(), 1);
                        tempRxPowerDmiArray[i]    = dut.ReadDmiRxp();
                        tempRxPowerErrArray[i]    = Math.Abs(Convert.ToDouble(testRxPowerDmiStruct.ArrayListRxInputPower[i].ToString()) - tempRxPowerDmiArray[i]);
                        tempRxPowerErrRawArray[i] = Convert.ToDouble(testRxPowerDmiStruct.ArrayListRxInputPower[i].ToString()) - tempRxPowerDmiArray[i];
                        Log.SaveLogToTxt("testRxPowerDmiStruct.ArrayListRxInputPower[" + i.ToString() + "]:" + testRxPowerDmiStruct.ArrayListRxInputPower[i].ToString() + "tempRxPowerDmiArray[" + i.ToString() + "]:" + tempRxPowerDmiArray[i].ToString() + "tempRxPowerErrArray[" + i.ToString() + "]" + tempRxPowerErrArray[i].ToString());
                    }
                    byte maxIndex;
                    Algorithm.SelectMaxValue(ArrayList.Adapter(tempRxPowerErrArray), out maxIndex);
                    MaxErr      = tempRxPowerErrRawArray[maxIndex];
                    ErrMaxPoint = Convert.ToDouble(testRxPowerDmiStruct.ArrayListRxInputPower[maxIndex].ToString());
                    Log.SaveLogToTxt("ErrMaxPoint=" + ErrMaxPoint.ToString() + "  MaxErr" + MaxErr.ToString());
                    tempAtten.OutPutSwitch(false);
                    Thread.Sleep(2000);
                    RxNopticalPoint = dut.ReadDmiRxp();
                    tempAtten.OutPutSwitch(true);

                    OutPutandFlushLog();
                    return(true);
                }
                else
                {
                    Log.SaveLogToTxt("Equipments are not enough!");
                    OutPutandFlushLog();
                    return(false);
                }
            }
        }
Пример #2
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);
        }
Пример #3
0
        public override bool Test()
        {
            try
            {
                logoStr = "";
                //// 是否要测试需要添加判定

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

                if (PrepareEnvironment(selectedEquipList) == false)
                {
                    OutPutandFlushLog();
                    return(false);
                }

                if (supply != null)
                {
                    // open apc
                    CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODON));
                    if (attRx != null)
                    {
                        Log.SaveLogToTxt("Step3...Set AttValue" + Convert.ToString(vcmiVecStruct.SensePoint) + "DBM");
                        attRx.AttnValue(Convert.ToString(vcmiVecStruct.SensePoint), 1);
                    }
                    Log.SaveLogToTxt("Step4...StartTest Electricl Eye EW and Vec");
                    Log.SaveLogToTxt("EWVecTest");

                    RxEyeVecEWTest();

                    OutPutandFlushLog();
                    return(true);
                }
                else
                {
                    Log.SaveLogToTxt("Equipments are not enough!");
                    OutPutandFlushLog();
                    return(false);
                }
            }
            catch (InnoExCeption ex)//from driver
            {
                //Log.SaveLogToTxt(ex.ID + ": " + ex.Message + "\r\n" + ex.StackTrace);
                exceptionList.Add(ex);
                return(false);
            }
            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);
                return(false);
                //the other way is: should throw exception, rather than the above three code. see below:
                //throw new InnoExCeption(ExceptionDictionary.Code._0xFFFFF, error.StackTrace);
            }
        }
 protected void SetAttenValue(Attennuator tempAtt, double attValue)
 {
     lock (tempAtten)
     {
         tempAtt.AttnValue(attValue.ToString());
     }
 }
Пример #5
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);
     }
 }
Пример #6
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);
        }
Пример #7
0
        private bool SetTargetPower(double TargerPower)
        {
            double TempValue;

            tempAttenTX.AttnValue(TargerPower.ToString());

            TempValue = tempPowerMeter.ReadPower();

            int i = 0;

            while (Math.Abs(TempValue - TargerPower) > 0.5)
            {
                tempAttenTX.AttnValue((TargerPower + (TargerPower - TempValue)).ToString());
                StartTxPwr = TargerPower + (TargerPower - TempValue);
                TempValue  = tempPowerMeter.ReadPower();
                i++;
                if (i > 10)
                {
                    return(false);
                }
            }

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

                double CurrentInputPower = StartInputPower;

                // tempAtt

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

                    if (currentCense < targetBerLL)// 误码太小->光太大->减小光
                    {
                        CurrentInputPower -= testBerStruct.FirstPointStep;
                        Rcount++;
                    }
                    else if (currentCense > targetBerUL)// 误码太大->光太小->加大入射光
                    {
                        CurrentInputPower += testBerStruct.FirstPointStep;
                        Rcount++;
                    }
                    else
                    {
                        return(CurrentInputPower);
                    }
                }
                return(-10000);
            }
        }
Пример #9
0
        protected override bool StartTest()
        {
            logoStr = "";
            //// 是否要测试需要添加判定

            if (AnalysisInputParameters(inputParameters) == false)
            {
                OutPutandFlushLog();
                return(false);
            }
            if (PrepareEnvironment(selectedEquipList) == false)
            {
                OutPutandFlushLog();
                return(false);
            }

            if (tempps != null)
            {
                // open apc

                {
                    CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODON));
                }

                // open apc
                if (tempAtten != null)
                {
                    Log.SaveLogToTxt("Step3...Set AttValue" + Convert.ToString(TestEleEyeStruct.CensePoint) + "DBM");
                    tempAtten.AttnValue(Convert.ToString(TestEleEyeStruct.CensePoint), 1);
                }
                Log.SaveLogToTxt("Step4...StartTest Electricl Eye");

                Log.SaveLogToTxt("ElecEyeTest");
                ElecTest();

                OutPutandFlushLog();
                return(true);
            }
            else
            {
                Log.SaveLogToTxt("Equipments are not enough!");
                OutPutandFlushLog();
                return(false);
            }
        }
Пример #10
0
        public override bool Test()
        {
            logoStr = "";
            //// 是否要测试需要添加判定

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

            if (PrepareEnvironment(selectedEquipList) == false)
            {
                OutPutandFlushLog();
                return(false);
            }

            if (supply != null)
            {
                // open apc
                CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODON));
                if (attRx != null)
                {
                    Log.SaveLogToTxt("Step3...Set AttValue" + Convert.ToString(vcmiVecStruct.CensePoint) + "DBM");
                    attRx.AttnValue(Convert.ToString(vcmiVecStruct.CensePoint), 1);
                }
                Log.SaveLogToTxt("Step4...StartTest Electricl Eye Vcmi and Vec");
                Log.SaveLogToTxt("VcmiVecTest");

                VcmiVecTest();

                OutPutandFlushLog();
                return(true);
            }
            else
            {
                Log.SaveLogToTxt("Equipments are not enough!");
                OutPutandFlushLog();
                return(false);
            }
        }
Пример #11
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);
        }
        private bool SingleChannelTest()
        {
            ushort tempRxPowerADC = 0;

            pAtt.AttnValue(RxInputPower.ToString(), 1);

            Thread.Sleep(2000);

            for (byte i = 0; i < ReadRxPowerAdcCount; i++)
            {
                Thread.Sleep(200);
                dut.ReadRxpADC(out tempRxPowerADC);
                Log.SaveLogToTxt("tempRxPowerADCArray:" + tempRxPowerADC.ToString());
            }

            Responsivity = Algorithm.CalculateRxResponsivity(Convert.ToDouble(RxInputPower), Convert.ToDouble(tempRxPowerADC), Vref, Rref, Resolution, Ratio);

            Log.SaveLogToTxt("Responsivity= " + Responsivity.ToString());

            return(true);
        }
Пример #13
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;
                }
            }
        }
Пример #14
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);
        }
Пример #15
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);
        }
Пример #16
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);
            }
        }
Пример #17
0
        protected override bool StartTest()
        {
            RxPowerArray.Clear();
            BerArray.Clear();

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

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

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

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

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

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

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

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

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

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


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

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

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

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


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

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

                return(false);
            }
        }
Пример #18
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);
            }
        }
Пример #19
0
        protected override bool StartTest()
        {
            lock (tempAtten)
            {
                logoStr = "";
                GenerateSpecList(SpecNameArray);
                if (AnalysisInputParameters(inputParameters) == false || LoadPNSpec() == false)
                {
                    OutPutandFlushLog();
                    return(false);
                }
                bool   isLosA = false;
                bool   isLosD = true;
                double tempRxPoint;
                tempRxPoint = testRXLosADStruct.LosDMax;

                if (tempAtten != null && tempps != null)
                {
                    // open apc

                    {
                        CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODON));
                    }

                    // open apc

                    Log.SaveLogToTxt("Step3...TestLosA");
                    tempAtten.AttnValue("-6");
                    dut.ChkRxLos();//清理Luanch
                    if (testRXLosADStruct.isLosDetail)
                    {
                        isLosA = LOSADetailTest(tempAtten, tempRxPoint, false);
                    }
                    else
                    {
                        isLosA = LOSAQuickTest(tempAtten, testRXLosADStruct.LosAMin, false);
                    }

                    if (isLosA == false)
                    {
                        Log.SaveLogToTxt("losA=" + isLosA.ToString());
                        losH = losD - losA;
                    }
                    tempRxPoint = losA;
                    Log.SaveLogToTxt("losA=" + losA.ToString());
                    Log.SaveLogToTxt("Step5...TestLosD");
                    if (testRXLosADStruct.isLosDetail)
                    {
                        isLosD = LOSDDetailTest(tempAtten, tempRxPoint, true);
                    }
                    else
                    {
                        isLosD = LOSDQuickTest(tempAtten, testRXLosADStruct.LosDMax, true);
                    }

                    if (isLosD == false)
                    {
                        Log.SaveLogToTxt("losD=" + (!isLosD).ToString());
                        losH = losD - losA;
                        OutPutandFlushLog();
                        return(true);
                    }
                    losH = losD - losA;
                    Log.SaveLogToTxt("losD=" + losD.ToString() + "losH=" + losH.ToString());
                    OutPutandFlushLog();
                    return(true);
                }
                else
                {
                    Log.SaveLogToTxt("Equipments are not enough!");
                    OutPutandFlushLog();
                    return(false);
                }
            }
        }
Пример #20
0
        protected override bool StartTest()
        {
            logoStr = "";
            GenerateSpecList(SpecNameArray);
            if (AnalysisInputParameters(inputParameters) == false)
            {
                OutPutandFlushLog();
                return(false);
            }
            if (!LoadPNSpec())
            {
                OutPutandFlushLog();
                return(false);
            }

            if (tempAtt != null && tempps != null)
            {
                if (adjustLosStruct.isAdjustLosA)
                {
                    //clear loss status before adjust
                    for (int i = 0; i < 10; i++)
                    {
                        tempAtt.AttnValue("0");
                        Thread.Sleep(100);
                        dut.WriteLOSDac(adjustLosStruct.LosAVoltageStartValue);
                        Thread.Sleep(100);
                        if (dut.ChkRxLos() == false)
                        {
                            break;
                        }
                        Thread.Sleep(100);
                    }

                    Log.SaveLogToTxt("Step3...Start Adjust LosA");

                    Log.SaveLogToTxt("Set LosA RxPower:" + adjustLosStruct.LosASetPower.ToString());
                    tempAtt.AttnValue(adjustLosStruct.LosASetPower.ToString(), 1);
                    dut.WriteLOSDac(adjustLosStruct.LosAVoltageStartValue);
                    dut.StoreLOSDac(adjustLosStruct.LosAVoltageStartValue);
                    Thread.Sleep(100);
                    bool isLos = dut.ChkRxLos();
                    Thread.Sleep(50);
                    isLos = dut.ChkRxLos();

                    if (!isLos)

                    {
                        isLosA = OneSectionMethodLosAdjust(adjustLosStruct.LosAVoltageStartValue, adjustLosStruct.LosAVoltageTuneStep, adjustLosStruct.LosAVoltageUperLimit, adjustLosStruct.LosAVoltageLowLimit, dut, out targetLosADac);
                        // isLosA = OneSectionMethodLosAdjust(losAMax, adjustLosStruct.LosAVoltageTuneStep, adjustLosStruct.LosAVoltageUperLimit, adjustLosStruct.LosAVoltageLowLimit, dut,  out targetLosADac);
                        Log.SaveLogToTxt("targetLosADac=" + targetLosADac.ToString());
                        Log.SaveLogToTxt(isLosA.ToString());
                    }
                    else
                    {
                        isLosA = false;
                    }
                }
                if (adjustLosStruct.isAdjustLosD)
                {
                    Log.SaveLogToTxt("Step3...Start Adjust LosD");
                    Log.SaveLogToTxt("Set LosA RxPower:" + adjustLosStruct.LosDSetPower.ToString());
                    tempAtt.AttnValue(adjustLosStruct.LosDSetPower.ToString());
                    dut.WriteLOSDDac(adjustLosStruct.LosDVoltageStartValue);
                    dut.StoreLOSDDac(adjustLosStruct.LosDVoltageStartValue);
                    Thread.Sleep(100);
                    bool isLos = dut.ChkRxLos();
                    Thread.Sleep(50);
                    isLos = dut.ChkRxLos();
                    if (isLos)

                    {
                        isLosD = OneSectionMethodLosDAdjust(adjustLosStruct.LosDVoltageStartValue, adjustLosStruct.LosDVoltageTuneStep, adjustLosStruct.LosDVoltageUperLimit, adjustLosStruct.LosDVoltageLowLimit, dut, out targetLosDDac);
                        Log.SaveLogToTxt("targetLosDDac=" + targetLosDDac.ToString());
                        Log.SaveLogToTxt(isLosD.ToString());
                    }
                    else
                    {
                        isLosD = false;
                    }
                }
                if (!adjustLosStruct.isAdjustLosD && !adjustLosStruct.isAdjustLosA)
                {
                    Log.SaveLogToTxt("Set LosA RxPower:" + adjustLosStruct.LosAVoltageStartValue.ToString());
                    Log.SaveLogToTxt("Set LosD RxPower:" + adjustLosStruct.LosDVoltageStartValue.ToString());
                    isLosA = WriteFixedLosValue(dut);
                    Log.SaveLogToTxt("targetLosADac=" + targetLosADac.ToString());
                    Log.SaveLogToTxt("targetLosDDac=" + targetLosDDac.ToString());
                }
                OutPutandFlushLog();
                if (adjustLosStruct.isAdjustLosA || adjustLosStruct.isAdjustLosD)
                {
                    return(isLosA || isLosD);
                }
                else
                {
                    return(isLosA);
                }
            }
            else
            {
                Log.SaveLogToTxt("Equipments are not enough!");
                OutPutandFlushLog();
                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);
        }
        protected override bool StartTest()
        {
            bool flagLos = false;

            byte[] StepArray = new byte[] { 64, 16, 4, 1 };

            logoStr = "";
            GenerateSpecList(SpecNameArray);
            if (AnalysisInputParameters(inputParameters) == false)
            {
                OutPutandFlushLog();
                return(false);
            }
            if (!LoadPNSpec())
            {
                OutPutandFlushLog();
                return(false);
            }

            if (tempAtt != null && tempps != null)
            {
                if (GlobalParameters.CurrentChannel == 1)
                {
                    dut.WriteLOSDac(0);
                }

                byte[] Dac = new byte[1];
                // dut.ReadLOSDac(1,out Dac);
                //dut.ReadLOSDac();
                byte startValue = Convert.ToByte(dut.ReadLOSDac());

                //switch(GlobalParameters.CurrentChannel)
                //{
                //    case 1:
                //        startValue = Convert.ToByte(Dac[0] & 0x3F);
                //        break;
                //    case 2:
                //        startValue = Convert.ToByte(Dac[0] & 0x3F);
                //        break;
                //    default:
                //        break;
                //}

                //  GlobalParameters.CurrentChannel

                tempAtt.AttnValue(adjustLosStruct.LosASetPower.ToString());
                Thread.Sleep(2000);
                Log.SaveLogToTxt("Step3...Start Adjust LosA");
                byte i = GlobalParameters.CurrentChannel;

                //for (int i = 1; i < 5; i++)
                //{
                int AdjustCout = 0;
                dut.ChangeChannel(i.ToString());
                Thread.Sleep(100);
                flagLos = dut.ChkRxLos();
                Thread.Sleep(50);
                flagLos = dut.ChkRxLos();
                //byte[]Dac= new byte[1];
                //dut.ReadLOSDac(1,out Dac);



                while (!flagLos && AdjustCout < 4)
                {
                    AdjustCout++;

                    startValue += StepArray[i - 1];

                    dut.WriteLOSDac(startValue);
                    Thread.Sleep(100);
                    dut.ChkRxLos();
                    Thread.Sleep(50);
                    flagLos = dut.ChkRxLos();
                }
                dut.StoreLOSDac(startValue);
                if (AdjustCout > 2)
                {
                    adjustLosStruct.isAdjustLosA = false;
                }
                else
                {
                    adjustLosStruct.isAdjustLosA = true;
                }
                // adjustLosStruct.isAdjustLosA
                // }
                //if (adjustLosStruct.isAdjustLosA)
                //{
                //    Log.SaveLogToTxt("Set LosA RxPower:" + adjustLosStruct.LosASetPower.ToString());
                //    tempAtt.AttnValue(adjustLosStruct.LosASetPower.ToString(), 1);
                //    dut.WriteLOSDac(adjustLosStruct.LosAVoltageStartValue);
                //    dut.StoreLOSDac(adjustLosStruct.LosAVoltageStartValue);
                //    Thread.Sleep(100);
                //    bool isLos = dut.ChkRxLos();
                //    Thread.Sleep(50);
                //    isLos = dut.ChkRxLos();
                //    if (!isLos)
                //    {
                //        isLosA = OneSectionMethodLosAdjust(adjustLosStruct.LosAVoltageStartValue, adjustLosStruct.LosAVoltageTuneStep, adjustLosStruct.LosAVoltageUperLimit, adjustLosStruct.LosAVoltageLowLimit, dut, out targetLosADac);
                //        // isLosA = OneSectionMethodLosAdjust(losAMax, adjustLosStruct.LosAVoltageTuneStep, adjustLosStruct.LosAVoltageUperLimit, adjustLosStruct.LosAVoltageLowLimit, dut,  out targetLosADac);
                //        Log.SaveLogToTxt("targetLosADac=" + targetLosDDac.ToString());
                //        Log.SaveLogToTxt(isLosA.ToString());
                //    }


                //}
                //if (adjustLosStruct.isAdjustLosD)
                //{
                //    Log.SaveLogToTxt("Set LosA RxPower:" + losDMin.ToString());
                //    tempAtt.AttnValue(losDMin.ToString(), 0);
                //    dut.WriteLOSDac(adjustLosStruct.LosAVoltageStartValue);
                //    dut.StoreLOSDac(adjustLosStruct.LosAVoltageStartValue);
                //    Thread.Sleep(100);
                //    bool isLos = dut.ChkRxLos();
                //    Thread.Sleep(50);
                //    isLos = dut.ChkRxLos();
                //    if (isLos)
                //    {
                //        isLosD = OneSectionMethodLosDAdjust(losDMin, adjustLosStruct.LosDVoltageTuneStep, adjustLosStruct.LosDVoltageUperLimit, adjustLosStruct.LosDVoltageLowLimit, dut, out targetLosDDac);
                //        Log.SaveLogToTxt("targetLosADac=" + targetLosDDac.ToString());
                //        Log.SaveLogToTxt(isLosD.ToString());
                //    }
                //}
                //if (!adjustLosStruct.isAdjustLosD && !adjustLosStruct.isAdjustLosA)
                //{
                //    Log.SaveLogToTxt("Set LosA RxPower:" + adjustLosStruct.LosAVoltageStartValue.ToString());
                //    Log.SaveLogToTxt("Set LosD RxPower:" + adjustLosStruct.LosDVoltageStartValue.ToString());
                //    isLosA = WriteFixedLosValue(dut);
                //    Log.SaveLogToTxt("targetLosDDac=" + targetLosADac.ToString());
                //    Log.SaveLogToTxt("targetLosDDac=" + targetLosDDac.ToString());

                //}
                OutPutandFlushLog();
                if (adjustLosStruct.isAdjustLosA || adjustLosStruct.isAdjustLosD)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Log.SaveLogToTxt("Equipments are not enough!");
                OutPutandFlushLog();
                return(false);
            }
        }
Пример #23
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);
            }
        }
Пример #24
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);
            }
        }
Пример #25
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);
            }
        }
Пример #26
0
        public override bool Test()

        {
            logoStr = "";
            GenerateSpecList(SpecNameArray);
            AddCurrentTemprature();
            if (AnalysisInputParameters(inputParameters) == false)
            {
                OutPutandFlushLog();
                return(false);
            }
            if (!LoadPNSpec())
            {
                OutPutandFlushLog();
                return(false);
            }
            if (pED != null && pAtt != null && pPS != null)
            {
                // close apc

                {
                    CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODOFF));
                }
                // close apc

                bool isAutoAlaign = pED.AutoAlaign(true);

                if (isAutoAlaign)
                {
                    Log.SaveLogToTxt(isAutoAlaign.ToString());
                }
                else
                {
                    Log.SaveLogToTxt(isAutoAlaign.ToString());

                    OutPutandFlushLog();
                    return(isAutoAlaign);
                }
                pAtt.AttnValue(adjustAPDStruct.RxInputPower.ToString());

                ArrayList serchTargetAtts = new ArrayList();
                ArrayList serchTargetBers = new ArrayList();
                serchTargetAtts.Clear();
                serchTargetBers.Clear();


                switch (adjustAPDStruct.AdjustMethod)
                {
                case 1:
                    if (!AdjustAPDMethod1())
                    {
                        return(false);
                    }
                    break;

                default:
                    if (!AdjustAPDMethod1())
                    {
                        return(false);
                    }
                    break;
                }

                DataRow dr = dtProcess.NewRow();

                dr["Temp"]    = GlobalParameters.CurrentTemp;
                dr["Channel"] = GlobalParameters.CurrentChannel;
                dr["APDDAC"]  = targetApd;

                ushort k;

                switch (adjustAPDStruct.Formula_X_Type)
                { //0=TempAdc;1=ApdTempAdc;2=Current*256
                case 0:
                    dut.ReadTempADC(out k);
                    dr["Formula_X"] = k;
                    break;

                case 1:
                    int TempK;
                    dut.ReadAPDTempAdc(out TempK);
                    dr["Formula_X"] = TempK;
                    break;

                default:
                    dut.ReadTempADC(out k);
                    dr["Formula_X"] = k;
                    break;
                }
                //dr["Formula_X"] = k;

                dtProcess.Rows.Add(dr);



                if (!CurveAPDandWriteCoefs())
                {
                    OutPutandFlushLog();
                }
                OutPutandFlushLog();
                return(true);
            }
            else
            {
                Log.SaveLogToTxt("Equipments are not enough!");
                isApdAdjustOK = false;
                OutPutandFlushLog();
                return(isApdAdjustOK);
            }
        }
Пример #27
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);
            }
        }
Пример #28
0
        protected override bool StartTest()
        {
            RxPowerArray.Clear();
            BerArrayRX.Clear();
            TxPowerArray.Clear();
            BerArrayTX.Clear();


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

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

                tempAttenTX.OutPutSwitch(false);

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

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

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

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

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

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

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

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

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

                    double value = 11.5;

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

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

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

                    TxReturnLosTolerance = value;

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

                return(false);
            }
        }
Пример #29
0
        protected override bool StartTest()
        {
            logoStr = "";

            sInputPowerArray = "";
            sRXDmiPowArray   = "";
            sDiffArray       = "";
            if (AnalysisInputParameters(inputParameters) == false)
            {
                OutPutandFlushLog();
                return(false);
            }

            if (tempps != null && tempAtten != null)
            {
                // open apc
                //CloseandOpenAPC(Convert.ToByte(APCMODE.IBAISandIMODON));
                // open apc
                Log.SaveLogToTxt("Step3...Start Test TestRxDmiPowErrorCurve");

                int    TestCount;
                double countMol = (Math.Abs(testRxDmiPowErrorCurveStruct.RxInputPowerMax - testRxDmiPowErrorCurveStruct.RxInputPowerMin)) % testRxDmiPowErrorCurveStruct.AttStep;
                if (countMol == 0)
                {
                    TestCount = Convert.ToInt32((Math.Abs(testRxDmiPowErrorCurveStruct.RxInputPowerMax - testRxDmiPowErrorCurveStruct.RxInputPowerMin)) / testRxDmiPowErrorCurveStruct.AttStep);
                }
                else
                {
                    TestCount = Convert.ToInt32((Math.Abs(testRxDmiPowErrorCurveStruct.RxInputPowerMax - testRxDmiPowErrorCurveStruct.RxInputPowerMin) - countMol) / testRxDmiPowErrorCurveStruct.AttStep) + 1;
                }

                InputPowerArray = new double[TestCount + 1];
                RXDmiPowArray   = new double[TestCount + 1];
                DiffArray       = new double[TestCount + 1];
                DiffRawArray    = new double[TestCount + 1];

                for (int i = 0; i < TestCount + 1; i++)
                {
                    if (i != TestCount)
                    {
                        InputPowerArray[i] = testRxDmiPowErrorCurveStruct.RxInputPowerMax - i * testRxDmiPowErrorCurveStruct.AttStep;
                    }
                    else
                    {
                        if (testRxDmiPowErrorCurveStruct.RxInputPowerMax - i * testRxDmiPowErrorCurveStruct.AttStep < testRxDmiPowErrorCurveStruct.RxInputPowerMin)
                        {
                            InputPowerArray[i] = testRxDmiPowErrorCurveStruct.RxInputPowerMin;
                        }
                        else
                        {
                            InputPowerArray[i] = testRxDmiPowErrorCurveStruct.RxInputPowerMax - i * testRxDmiPowErrorCurveStruct.AttStep;
                        }
                    }
                }

                tempAtten.AttnValue(InputPowerArray[0].ToString(), 1);
                Thread.Sleep(3000);
                for (int j = 0; j < InputPowerArray.Length; j++)
                {
                    tempAtten.AttnValue(InputPowerArray[j].ToString(), 1);
                    RXDmiPowArray[j] = dut.ReadDmiRxp();
                    DiffArray[j]     = Math.Abs(InputPowerArray[j] - RXDmiPowArray[j]);
                    DiffRawArray[j]  = InputPowerArray[j] - RXDmiPowArray[j];

                    if (j != InputPowerArray.Length - 1)
                    {
                        sInputPowerArray += InputPowerArray[j] + ",";
                        sRXDmiPowArray   += RXDmiPowArray[j] + ",";
                        sDiffArray       += DiffArray[j] + ",";
                    }
                    else
                    {
                        sInputPowerArray += InputPowerArray[j];
                        sRXDmiPowArray   += RXDmiPowArray[j];
                        sDiffArray       += DiffArray[j];
                    }

                    Log.SaveLogToTxt("InputPowerArray[" + j.ToString() + "]:" + InputPowerArray[j].ToString() + "RXDmiPowArray[" + j.ToString() + "]:" + RXDmiPowArray[j].ToString() + "DiffArray[" + j.ToString() + "]" + DiffArray[j].ToString());
                }
                byte maxIndex;
                Algorithm.SelectMaxValue(ArrayList.Adapter(DiffArray), out maxIndex);
                MaxErr      = DiffRawArray[maxIndex];
                ErrMaxPoint = InputPowerArray[maxIndex];
                Log.SaveLogToTxt("ErrMaxPoint=" + ErrMaxPoint.ToString() + "  MaxErr" + MaxErr.ToString());
                //tempAtten.OutPutSwitch(false);
                //Thread.Sleep(2000);
                //RxNopticalPoint=dut.ReadDmiRxp();
                //tempAtten.OutPutSwitch(true);

                OutPutandFlushLog();
                return(true);
            }
            else
            {
                Log.SaveLogToTxt("Equipments are not enough!");
                OutPutandFlushLog();
                return(false);
            }
        }
Пример #30
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);
            }
        }