Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        private bool WriteCoef(float[] Coef)
        {
            float CoefA = (float)Coef[0];
            float CoefB = (float)Coef[1];
            float CoefC = (float)Coef[2];


            Log.SaveLogToTxt("CoefA=" + CoefA + " " + Algorithm.ByteArraytoString(2, ",", Algorithm.FloatToIEE754(CoefA)));
            Log.SaveLogToTxt("CoefB=" + CoefB + " " + Algorithm.ByteArraytoString(2, ",", Algorithm.FloatToIEE754(CoefB)));
            Log.SaveLogToTxt("CoefC=" + CoefC + " " + Algorithm.ByteArraytoString(2, ",", Algorithm.FloatToIEE754(CoefC)));


            if (!dut.SetMaskcoefa(CoefA))
            {
                Log.SaveLogToTxt("CoefA Write Error!");

                return(false);
            }
            if (!dut.SetMaskcoefb(CoefB))
            {
                Log.SaveLogToTxt("CoefB Write Error!");

                return(false);
            }

            if (!dut.SetMaskcoefc(CoefC))
            {
                Log.SaveLogToTxt("CoefC Write Error!");

                return(false);
            }

            return(true);
        }
        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;
            }
        }