Ejemplo n.º 1
0
        private bool CalculatedCoefs()
        {
            switch (MyStruct.AdjustMethod)
            {
            case 0:
                string SelectCondition = "Channel=" + GlobalParameters.CurrentChannel;

                DataRow[] drArray = dtMask.Select(SelectCondition);

                if (drArray.Length < 2)
                {
                    break;
                }

                #region  TempCout>=2

                string[] TempADCArray = drArray.Select(A => A["TempADC"].ToString()).ToArray();
                double[] X            = Array.ConvertAll <String, double>(TempADCArray, s => double.Parse(s));

                string[] TargetMaskDacArray = drArray.Select(A => A["TargetMaskDac"].ToString()).ToArray();
                double[] Y = Array.ConvertAll <String, double>(TargetMaskDacArray, s => double.Parse(s));

                double[] coefArray = Algorithm.MultiLine(X, Y, X.Length, 2);

                //coefArray.Reverse();

                Array.Reverse(coefArray);
                float[] floatArray = Array.ConvertAll <double, float>(coefArray, s => float.Parse(s.ToString()));

                WriteCoef(floatArray);
                pPs.OutPutSwitch(false);
                pPs.OutPutSwitch(true);
                #endregion

                break;

            case 1:    // 无系数可写

                break;

            default:
                break;
            }



            return(true);
        }
Ejemplo n.º 2
0
        protected bool CurveVccDMIandWriteCoefs()
        {
            byte tempCOUNT;

            if (GlobalParameters.TotalVccCount <= 0)
            {
                tempCOUNT = 1;
            }
            else
            {
                tempCOUNT = GlobalParameters.TotalVccCount;
            }
            try
            {
                {
                    for (byte i = 0; i < tempVccArray.Length; i++)
                    {
                        tempVccArray[i] = tempVccArray[i] * 10000;
                    }
                    for (byte i = 0; i < tempCOUNT; i++)
                    {
                        double[] tempAdc = new double[calVccDmiStruct.ArrayListVcc.Count];

                        for (byte j = 0; j < calVccDmiStruct.ArrayListVcc.Count; j++)
                        {
                            tempAdc[j] = vccAdcArray[i, j];
                            allVccAdcArray.Add(vccAdcArray[i, j]);
                        }
                        double[] coefArray = Algorithm.MultiLine(tempAdc, tempVccArray, calVccDmiStruct.ArrayListVcc.Count, 1);
                        vccDmiCoefC = (float)coefArray[0];
                        vccDmiCoefB = (float)coefArray[1];
                        //vccDmiCoefA = (float)coefArray[2];

                        vccDmiCoefArray = ArrayList.Adapter(coefArray);
                        vccDmiCoefArray.Reverse();
                        for (byte k = 0; k < vccDmiCoefArray.Count; k++)
                        {
                            Log.SaveLogToTxt("vccDmiCoefArray[" + k.ToString() + "]=" + vccDmiCoefArray[k].ToString() + " " + Algorithm.ByteArraytoString(2, ",", Algorithm.INT16To2Bytes(vccDmiCoefArray[k])));
                        }
                        Log.SaveLogToTxt("Step4...WriteCoef");
                        #region W&R Vcccoefc
                        isWriteCoefCOk = dut.SetVcccoefc(vccDmiCoefC.ToString(), (byte)(i + 1));
                        if (isWriteCoefCOk)
                        {
                            Log.SaveLogToTxt("WritevccDmiCoefC:" + isWriteCoefCOk.ToString());
                        }
                        else
                        {
                            Log.SaveLogToTxt("WritevccDmiCoefC:" + isWriteCoefCOk.ToString());
                        }
                        #endregion
                        #region W&R Vcccoefb
                        isWriteCoefBOk = dut.SetVcccoefb(vccDmiCoefB.ToString(), (byte)(i + 1));

                        if (isWriteCoefBOk)
                        {
                            Log.SaveLogToTxt("WritevccDmiCoefB:" + isWriteCoefBOk.ToString());
                        }
                        else
                        {
                            Log.SaveLogToTxt("WritevccDmiCoefB:" + isWriteCoefBOk.ToString());
                        }
                        #endregion
                        //#region W&R Vcccoefa
                        ////isWriteCoefAOk = dut.SetVcccoefa(vccDmiCoefA.ToString(), i + 1);
                        //if (isWriteCoefAOk)
                        //{
                        //    isWriteCoefAOk = true;
                        //    Log.SaveLogToTxt("WritevccDmiCoefA:" + isWriteCoefAOk.ToString());

                        //}
                        //else
                        //{

                        //    Log.SaveLogToTxt("WritevccDmiCoefA:" + isWriteCoefAOk.ToString());
                        //}
                        //#endregion
                        if (isWriteCoefBOk & isWriteCoefCOk)
                        {
                            Log.SaveLogToTxt("isCalVccDmiOk:" + true.ToString());
                        }
                        else
                        {
                            Log.SaveLogToTxt("isCalVccDmiOk:" + false.ToString());
                            return(false);
                        }
                    }
                }
                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._0x02100, 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._0x02100, error.StackTrace);
            }
        }
Ejemplo n.º 3
0
        protected bool CurveAPDandWriteCoefs()
        {
            try
            {
                #region  CurveCoef

                string SelectCondition = "Channel=" + GlobalParameters.CurrentChannel;

                DataRow[] drArray = dtProcess.Select(SelectCondition);


                if (drArray.Length >= 2)
                {
                    double[] Y = new double[drArray.Length];
                    double[] X = new double[drArray.Length];

                    for (byte i = 0; i < drArray.Length; i++)
                    {
                        Y[i] = double.Parse(drArray[i]["APDDAC"].ToString());
                        X[i] = double.Parse(drArray[i]["Formula_X"].ToString());  //Formula_X
                    }

                    for (int i = 0; i < X.Length; i++)
                    {
                        Log.SaveLogToTxt("X[" + i.ToString() + "]=" + X[i].ToString() + " " + "Y[" + i.ToString() + "]=" + Y[i].ToString());
                    }
                    double[] coefArray = Algorithm.MultiLine(X, Y, tempratureADCArray.Count, 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++)
                    {
                        Log.SaveLogToTxt("apdCoefArray[" + i.ToString() + "]=" + apdCoefArray[i].ToString() + " " + Algorithm.ByteArraytoString(2, ",", Algorithm.FloatToIEE754(apdCoefArray[i])));
                    }
                    Log.SaveLogToTxt("Step9...WriteCoef");

                    #region W&R Apddaccoefc
                    isWriteCoefCOk = dut.SetAPDdaccoefc(apdPowerCoefC.ToString());
                    if (isWriteCoefCOk)
                    {
                        Log.SaveLogToTxt("isWriteCoefCOk:" + isWriteCoefCOk.ToString());
                    }
                    else
                    {
                        Log.SaveLogToTxt("isWriteCoefCOk:" + isWriteCoefCOk.ToString());
                    }
                    #endregion
                    #region W&R Apddaccoefb
                    isWriteCoefBOk = dut.SetAPDdaccoefb(apdPowerCoefB.ToString());
                    if (isWriteCoefBOk)
                    {
                        Log.SaveLogToTxt("isWriteCoefBOk:" + isWriteCoefBOk.ToString());
                    }
                    else
                    {
                        Log.SaveLogToTxt("isWriteCoefBOk:" + isWriteCoefBOk.ToString());
                    }
                    #endregion
                    #region W&R Apddaccoefa
                    isWriteCoefAOk = dut.SetAPDdaccoefa(apdPowerCoefA.ToString());

                    if (isWriteCoefAOk)
                    {
                        Log.SaveLogToTxt("isWriteCoefAOk:" + isWriteCoefAOk.ToString());
                    }
                    else
                    {
                        Log.SaveLogToTxt("isWriteCoefAOk:" + isWriteCoefAOk.ToString());
                    }
                    #endregion
                    if (isWriteCoefAOk & isWriteCoefBOk & isWriteCoefCOk)
                    {
                        Log.SaveLogToTxt("isCalApdPowerOk:" + true.ToString());
                    }
                    else
                    {
                        Log.SaveLogToTxt("isCalApdPowerOk:" + false.ToString());
                        return(false);
                    }
                }

                #endregion
                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._0x02100, 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._0x02100, error.StackTrace);
            }
        }
Ejemplo n.º 4
0
        protected bool CurveTempDmiandWriteCoefs()
        {
            try
            {
                int tempCount = 0;
                if (GlobalParameters.TotalTempCount <= 0)
                {
                    tempCount = Math.Min(tempratureADCArray.Count / 1, realTempratureArray.Count / 1);
                }
                else
                {
                    tempCount = Math.Min(tempratureADCArray.Count / GlobalParameters.TotalTempCount, realTempratureArray.Count / GlobalParameters.TotalTempCount);
                }
                double[,] tempTempAdcArray;
                double[,] tempTempValueArray;
                if (GlobalParameters.TotalTempCount <= 0)
                {
                    tempTempAdcArray   = new double[1, tempCount];
                    tempTempValueArray = new double[1, tempCount];
                }
                else
                {
                    tempTempAdcArray   = new double[GlobalParameters.TotalTempCount, tempCount];
                    tempTempValueArray = new double[GlobalParameters.TotalTempCount, tempCount];
                }
                byte totalTempCount;
                if (GlobalParameters.TotalTempCount <= 0)
                {
                    totalTempCount = 1;
                }
                else
                {
                    totalTempCount = GlobalParameters.TotalTempCount;
                }
                Log.SaveLogToTxt("Step4...Start Fitting Curve");
                {
                    for (byte i = 0; i < totalTempCount; i++)
                    {
                        int tempcount1 = 0;
                        for (byte j = 0; j < Math.Min(realTempratureArray.Count, tempratureADCArray.Count); j++)
                        {
                            int    tempstr2   = tempratureADCArray.Keys[j].ToUpper().Length;
                            string tempstring = tempratureADCArray.Keys[j].ToUpper().Substring(tempratureADCArray.Keys[j].ToUpper().Length - 1, 1);
                            string iStr       = i.ToString().ToUpper().Trim();
                            if (tempstring == iStr)
                            {
                                tempTempAdcArray[i, tempcount1]   = double.Parse(tempratureADCArray.Values[j]);
                                tempTempValueArray[i, tempcount1] = double.Parse(realTempratureArray.Values[j]);
                                tempcount1++;
                            }
                        }
                    }
                    for (byte i = 0; i < totalTempCount; i++)
                    {
                        for (byte j = 0; j < tempCount; j++)
                        {
                            tempTempValueArray[i, j] = tempTempValueArray[i, j] * 256;
                        }
                    }
                    double[] adcArray  = new double[tempCount];
                    double[] realArray = new double[tempCount];
                    {
                        for (byte i = 0; i < totalTempCount; i++)
                        {
                            for (byte j = 0; j < tempCount; j++)
                            {
                                adcArray[j]  = tempTempAdcArray[i, j];
                                realArray[j] = tempTempValueArray[i, j];
                            }

                            for (byte k = 0; k < adcArray.Length; k++)
                            {
                                Log.SaveLogToTxt("adcArray[" + k.ToString() + "]=" + adcArray[k].ToString() + " " + "realArray[" + k.ToString() + "]=" + realArray[k].ToString());
                            }


                            double[] coefArray = Algorithm.MultiLine(adcArray, realArray, tempCount, 1);

                            tempDmiCoefC = Convert.ToSingle(coefArray[0]);
                            tempDmiCoefB = Convert.ToSingle(coefArray[1]);

                            tempDmiCoefArray = ArrayList.Adapter(coefArray);
                            tempDmiCoefArray.Reverse();
                            for (byte k = 0; k < tempDmiCoefArray.Count; k++)
                            {
                                // Log.SaveLogToTxt("tempDmiCoefArray[" + k.ToString() + "]=" + tempDmiCoefArray[k].ToString() + " " + Algorithm.ByteArraytoString(2, ",", Algorithm.INT16To2Bytes(tempDmiCoefArray[k])));
                                Log.SaveLogToTxt("tempDmiCoefArray[" + k.ToString() + "]=" + tempDmiCoefArray[k].ToString() + " " + Algorithm.ByteArraytoString(4, ",", Algorithm.FloatToIEE754(tempDmiCoefArray[k])));
                            }
                            Log.SaveLogToTxt("Step5...WriteCoef");
                            #region W&R Tempcoefc
                            isWriteCoefCOk = dut.SetTempcoefc(tempDmiCoefC.ToString(), (byte)(i + 1));

                            if (isWriteCoefCOk)
                            {
                                Log.SaveLogToTxt("WritetempDmiCoefC:" + isWriteCoefCOk.ToString());
                            }
                            else
                            {
                                Log.SaveLogToTxt("WritetempDmiCoefC:" + isWriteCoefCOk.ToString());
                            }
                            #endregion
                            #region W&R Tempcoefb
                            isWriteCoefBOk = dut.SetTempcoefb(tempDmiCoefB.ToString(), (byte)(i + 1));

                            if (isWriteCoefBOk)
                            {
                                Log.SaveLogToTxt("WritetempDmiCoefB:" + isWriteCoefBOk.ToString());
                            }
                            else
                            {
                                Log.SaveLogToTxt("WritetempDmiCoefB:" + isWriteCoefBOk.ToString());
                            }
                            #endregion

                            if (isWriteCoefBOk & isWriteCoefCOk)
                            {
                                Log.SaveLogToTxt("isCalTempDmiOk:" + true.ToString());
                            }
                            else
                            {
                                Log.SaveLogToTxt("isCalTempDmiOk:" + false.ToString());
                                return(false);
                            }
                        }
                    }
                }
                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._0x02100, 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._0x02100, error.StackTrace);
            }
        }
        protected bool CurveTempDmiandWriteCoefs()
        {
            try
            {
                int tempCount = 0;
                if (GlobalParameters.TotalTempCount <= 0)
                {
                    tempCount = Math.Min(dieTempratureArray.Count / 1, realTempratureArray.Count / 1);
                }
                else
                {
                    tempCount = Math.Min(dieTempratureArray.Count / GlobalParameters.TotalTempCount, realTempratureArray.Count / GlobalParameters.TotalTempCount);
                }
                double[,] tempdieTempArray;
                double[,] tempTempValueArray;
                if (GlobalParameters.TotalTempCount <= 0)
                {
                    tempdieTempArray   = new double[1, tempCount];
                    tempTempValueArray = new double[1, tempCount];
                }
                else
                {
                    tempdieTempArray   = new double[GlobalParameters.TotalTempCount, tempCount];
                    tempTempValueArray = new double[GlobalParameters.TotalTempCount, tempCount];
                }
                byte totalTempCount;
                if (GlobalParameters.TotalTempCount <= 0)
                {
                    totalTempCount = 1;
                }
                else
                {
                    totalTempCount = GlobalParameters.TotalTempCount;
                }
                Log.SaveLogToTxt("Step4...Start Fitting Curve");
                {
                    for (byte i = 0; i < totalTempCount; i++)
                    {
                        int tempcount1 = 0;
                        for (byte j = 0; j < Math.Min(realTempratureArray.Count, dieTempratureArray.Count); j++)
                        {
                            int    tempstr2   = dieTempratureArray.Keys[j].ToUpper().Length;
                            string tempstring = dieTempratureArray.Keys[j].ToUpper().Substring(dieTempratureArray.Keys[j].ToUpper().Length - 1, 1);
                            string iStr       = i.ToString().ToUpper().Trim();
                            if (tempstring == iStr)
                            {
                                tempdieTempArray[i, tempcount1]   = double.Parse(dieTempratureArray.Values[j]);
                                tempTempValueArray[i, tempcount1] = double.Parse(realTempratureArray.Values[j]);
                                tempcount1++;
                            }
                        }
                    }
                    for (byte i = 0; i < totalTempCount; i++)
                    {
                        for (byte j = 0; j < tempCount; j++)
                        {
                            tempTempValueArray[i, j] = tempTempValueArray[i, j] * 256;
                        }
                    }
                    double[] dieTempArray = new double[tempCount];
                    double[] realArray    = new double[tempCount];
                    {
                        for (byte i = 0; i < totalTempCount; i++)
                        {
                            for (byte j = 0; j < tempCount; j++)
                            {
                                dieTempArray[j] = tempdieTempArray[i, j];
                                realArray[j]    = tempTempValueArray[i, j];
                            }

                            for (byte k = 0; k < dieTempArray.Length; k++)
                            {
                                Log.SaveLogToTxt("dieTempArray[" + k.ToString() + "]=" + dieTempArray[k].ToString() + " " + "realArray[" + k.ToString() + "]=" + realArray[k].ToString());
                            }

                            double[] coefArray = Algorithm.MultiLine(dieTempArray, realArray, tempCount, 1);

                            tempDmiCoefC = Convert.ToSingle(coefArray[0]);
                            tempDmiCoefB = Convert.ToSingle(coefArray[1]);

                            tempDmiCoefArray = ArrayList.Adapter(coefArray);
                            tempDmiCoefArray.Reverse();
                            for (byte k = 0; k < tempDmiCoefArray.Count; k++)
                            {
                                // Log.SaveLogToTxt("tempDmiCoefArray[" + k.ToString() + "]=" + tempDmiCoefArray[k].ToString() + " " + Algorithm.ByteArraytoString(2, ",", Algorithm.INT16To2Bytes(tempDmiCoefArray[k])));
                                Log.SaveLogToTxt("tempDmiCoefArray[" + k.ToString() + "]=" + tempDmiCoefArray[k].ToString() + " " + Algorithm.ByteArraytoString(4, ",", Algorithm.FloatToIEE754(tempDmiCoefArray[k])));
                            }
                            Log.SaveLogToTxt("Step5...WriteCoef");
                            #region W&R Tempcoefc
                            isWriteCoefCOk = dut.SetTempcoefc(tempDmiCoefC.ToString(), (byte)(i + 1));

                            if (isWriteCoefCOk)
                            {
                                Log.SaveLogToTxt("WritetempDmiCoefC:" + isWriteCoefCOk.ToString());
                            }
                            else
                            {
                                Log.SaveLogToTxt("WritetempDmiCoefC:" + isWriteCoefCOk.ToString());
                            }
                            #endregion
                            #region W&R Tempcoefb
                            isWriteCoefBOk = dut.SetTempcoefb(tempDmiCoefB.ToString(), (byte)(i + 1));

                            if (isWriteCoefBOk)
                            {
                                Log.SaveLogToTxt("WritetempDmiCoefB:" + isWriteCoefBOk.ToString());
                            }
                            else
                            {
                                Log.SaveLogToTxt("WritetempDmiCoefB:" + isWriteCoefBOk.ToString());
                            }
                            #endregion

                            if (isWriteCoefBOk & isWriteCoefCOk)
                            {
                                Log.SaveLogToTxt("isCalTempDmiOk:" + true.ToString());
                            }
                            else
                            {
                                Log.SaveLogToTxt("isCalTempDmiOk:" + false.ToString());
                                return(false);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }