Exemple #1
0
        protected UInt32 EnumMethod(UInt32[] inPutArray, DUT dut, ErrorDetector ed, byte substep, out ArrayList berArray, out ArrayList apdDacArray, out double minBer)
        {
            berArray    = new ArrayList();
            apdDacArray = new ArrayList();
            UInt32 minimumDAC;

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

            minBer = -1;
            byte minIndex = 0;

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

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

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


            #endregion
            return(minimumDAC);
        }
        private byte GetTargetPointIndex(Double TypcalValue, Double[] Y)
        {
            byte index;

            ArrayList Diff = new ArrayList();

            for (int i = 0; i < Y.Length; i++)
            {
                Diff.Add(Math.Abs(TypcalValue - Y[i]));
            }
            Algorithm.SelectMinValue(Diff, out index);

            return(index);
        }
Exemple #3
0
        /// <summary>
        /// 精细查找最好的那个点
        /// </summary>
        /// <param name="ScanArray">采样数组</param>
        /// <returns></returns>
        protected Int32 SearchBestPoint(Int32[] ScanArray)
        {
            double[] ErrorRate = new double[ScanArray.Length];
            ushort[] rxADCs    = new ushort[ScanArray.Length];

            try
            {
                ArrayList StrLog = new ArrayList();
                for (int i = 0; i < ScanArray.Length; i++)
                {
                    dut.WriteAPDDac(ScanArray[i]);
                    Thread.Sleep(200);
                    ErrorRate[i] = pED.GetErrorRate();
                    dut.ReadRxpADC(out rxADCs[i]);
                    StrLog.Add("ScanArray[" + i + "] = " + ScanArray[i] + " " + " ErrorRate[" + i + "] = " + ErrorRate[i] + " RxADC[" + i + "] = " + rxADCs[i]);
                }



                for (int i = 0; i < StrLog.Count; i++)
                {
                    Log.SaveLogToTxt(StrLog[i].ToString());
                }

                byte bIndex;


                ArrayList TempArray = new ArrayList();
                TempArray.Clear();
                for (int i = 0; i < ScanArray.Length; i++)
                {
                    TempArray.Add(ErrorRate[i]);
                }


                Algorithm.SelectMinValue(TempArray, out bIndex);

                Log.SaveLogToTxt("BestAPD =" + ScanArray[bIndex].ToString());
                Log.SaveLogToTxt("MinErrorRate =" + ErrorRate[bIndex].ToString());
                //Log.SaveLogToTxt("ErrorRate[" + bIndex + "] =" + TempValue);

                if (referenceRxADC == null)
                {
                    referenceRxADC = new ushort[GlobalParameters.TotalChCount];
                    referenceTemp  = GlobalParameters.CurrentTemp;
                }

                if (referenceTemp == GlobalParameters.CurrentTemp)
                {
                    referenceRxADC[GlobalParameters.CurrentChannel - 1] = rxADCs[bIndex];
                    return(int.Parse(ScanArray[bIndex].ToString()));
                }

                ushort deltaRxADC = 65535;
                int    index      = bIndex;
                for (int i = 0; i < ErrorRate.Length; i++)
                {
                    if (Math.Abs(ErrorRate[i] - ErrorRate[bIndex]) < 10 * ErrorRate[bIndex])
                    {
                        int delta = Math.Abs(rxADCs[i] - referenceRxADC[GlobalParameters.CurrentChannel - 1]);
                        if (delta < deltaRxADC)
                        {
                            deltaRxADC = (ushort)delta;
                            index      = i;
                        }
                    }
                }
                Log.SaveLogToTxt("BestAPD = " + ScanArray[index] + " ErrorRate = " + ErrorRate[index] + " RxADC = " + rxADCs[index]);

                return(int.Parse(ScanArray[index].ToString()));
            }
            catch (InnoExCeption ex)//from driver
            {
                //Log.SaveLogToTxt(ex.ID + ": " + ex.Message + "\r\n" + ex.StackTrace);
                exceptionList.Add(ex);
                return(InnoExCeption.NaN);
            }
            catch (Exception error)//from itself
            {
                //one way: deal this exception itself
                InnoExCeption ex = new InnoExCeption(ExceptionDictionary.Code._0x02108, error.StackTrace);
                //Log.SaveLogToTxt(ex.ID + ": " + ex.Message + "\r\n" + ex.StackTrace);
                exceptionList.Add(ex);
                return(InnoExCeption.NaN);
                //the other way is: should throw exception, rather than the above three code. see below:
                //throw new InnoExCeption(ExceptionDictionary.Code._0x02108, error.StackTrace);
            }
        }
Exemple #4
0
        protected bool SearchTargetPoint(out byte Index)
        {
            Index = 0;
            ArrayList serchAttPointsTemp = new ArrayList();

            serchAttPointsTemp.Clear();
            ArrayList serchAttPoints = serchAttPointsTemp;
            ArrayList serchBerPoints = serchAttPointsTemp;



            try
            {
                //double currentCense = 0;
                //byte count = 0;
                serchAttPoints = new ArrayList();
                serchBerPoints = new ArrayList();
                serchAttPoints.Clear();
                serchBerPoints.Clear();

                ArrayList StrLog = new ArrayList();
                ushort[]  rxADCs = new ushort[adjustAPDStruct.SetPoints.Length];
                int       count  = 0;
                for (int i = 0; i < adjustAPDStruct.SetPoints.Length; i++)
                {
                    dut.WriteAPDDac(adjustAPDStruct.SetPoints[i]);
                    serchAttPoints.Add(adjustAPDStruct.SetPoints[i]);
                    Thread.Sleep(200);

                    double TempValue = pED.GetErrorRate();

                    if (Math.Abs(TempValue - 9.999E+17) < 1.0E-6)
                    {
                        count++;//记录误码不通的数量
                    }

                    serchBerPoints.Add(TempValue);
                    dut.ReadRxpADC(out rxADCs[i]);
                    StrLog.Add("adjustAPDStruct.SetPoints[" + i + "] = " + adjustAPDStruct.SetPoints[i].ToString() + " " + " serchBerPoints[" + i + "] = " + TempValue + " RxADC[" + i + "] = " + rxADCs[i]);
                }

                for (int i = 0; i < StrLog.Count; i++)
                {
                    Log.SaveLogToTxt(StrLog[i].ToString());
                }

                if (count == adjustAPDStruct.SetPoints.Length)//如果全部不通
                {
                    return(false);
                }
                // byte Index;

                Algorithm.SelectMinValue(serchBerPoints, out Index);

                if (referenceRxADC_First == null)
                {
                    referenceRxADC_First = new ushort[GlobalParameters.TotalChCount];
                    referenceTemp        = GlobalParameters.CurrentTemp;
                }

                if (referenceTemp == GlobalParameters.CurrentTemp)
                {
                    referenceRxADC_First[GlobalParameters.CurrentChannel - 1] = rxADCs[Index];
                    return(true);
                }

                ushort deltaRxADC = 65535;
                int    index      = Index;
                for (int i = 0; i < serchBerPoints.Count; i++)
                {
                    if (Math.Abs(Convert.ToDouble(serchBerPoints[i]) - Convert.ToDouble(serchBerPoints[Index])) < 10 * Convert.ToDouble(serchBerPoints[Index]))
                    {
                        int delta = Math.Abs(rxADCs[i] - referenceRxADC_First[GlobalParameters.CurrentChannel - 1]);
                        if (delta < deltaRxADC)
                        {
                            deltaRxADC = (ushort)delta;
                            index      = i;
                        }
                    }
                }
                Log.SaveLogToTxt("BestAPD = " + adjustAPDStruct.SetPoints[index] + " serchBerPoints = " + serchBerPoints[index] + " RxADC = " + rxADCs[index]);

                Index = (byte)index;
                return(true);
            }
            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._0x02108, 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._0x02108, error.StackTrace);
            }
        }
        protected byte SearchMaskPoint(Int32[] ScanArray, out double[] Item)
        {
            Item = new double[ScanArray.Length];

            try
            {
                ArrayList StrLog = new ArrayList();

                for (int i = 0; i < ScanArray.Length; i++)
                {
                    dut.WriteMaskDac(ScanArray[i]);

                    Thread.Sleep(200);


                    Item[i] = GetMask();

                    StrLog.Add("ScanArray[" + i + "] =" + ScanArray[i].ToString() + " " + "Mask[" + i + "] =" + Item[i].ToString());
                }



                for (int i = 0; i < StrLog.Count; i++)
                {
                    Log.SaveLogToTxt(StrLog[i].ToString());
                }

                byte bIndex;


                ArrayList TempArray = new ArrayList();
                TempArray.Clear();
                for (int i = 0; i < ScanArray.Length; i++)
                {
                    TempArray.Add(Item[i]);
                }


                Algorithm.SelectMinValue(TempArray, out bIndex);

                Log.SaveLogToTxt("ScanMaskDAC =" + ScanArray[bIndex].ToString());
                Log.SaveLogToTxt("ScanMask =" + Item[bIndex].ToString());
                //Log.SaveLogToTxt("ErrorRate[" + bIndex + "] =" + TempValue);

                return(bIndex);
            }
            catch (InnoExCeption ex) //from driver
            {
                //Log.SaveLogToTxt(ex.ID + ": " + ex.Message + "\r\n" + ex.StackTrace);
                exceptionList.Add(ex);
                return(0);
            }
            catch (Exception error) //from itself
            {
                //one way: deal this exception itself
                InnoExCeption ex = new InnoExCeption(ExceptionDictionary.Code._0x02108, error.StackTrace);
                //Log.SaveLogToTxt(ex.ID + ": " + ex.Message + "\r\n" + ex.StackTrace);
                exceptionList.Add(ex);
                return(0);
                //the other way is: should throw exception, rather than the above three code. see below:
                //throw new InnoExCeption(ExceptionDictionary.Code._0x02108, error.StackTrace);
            }
        }