Exemplo n.º 1
0
        public void UpdateDetector2Temp()
        {
            bool retry      = true;
            int  retryCount = 0;

            axUDROP1.SelIndex = 2;
            while (retry)
            {
                try
                {
                    if (axUCONN21.IsOpen)
                    {
                        axUCONN21.Close();
                    }

                    axUCONN21.Address = axUDROP1.SelAddress;
                    axUCONN21.Open();
                    axUCONN21.Comm("SHOW_VERSION");
                    axUCONN21.Comm("ENAB_HV");
                    if (axUCONN21.ID == 2)
                    {
                        string thisTemp = GlobalFunc.tc.axUCONN21.Comm("SHOW_DET_TEMP");
                        thisTemp             = thisTemp.Replace("DET_TEMP ", "");
                        GlobalFunc.det2_temp = GlobalFunc.Math45(Convert.ToDouble(thisTemp));
                        retry = false;
                    }
                    else
                    {
                        retry = true;
                        retryCount++;
                    }
                    axUCONN21.Close();
                }
                catch (Exception ex)
                {
                    retryCount++;
                }
                if (retryCount == 5)
                {
                    axUDROP1.SelIndex = 1;
                    axUCONN21.Address = axUDROP1.SelAddress;
                }
                if (retryCount == 10)
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public List <float> Calibration_MatrixD(List <double> Background1_cps, List <double> Background2_cps, List <double> Nuclide1_cps, List <double> Nuclide2_cps,
                                                List <double> Activity, List <double> HalfTime, List <DateTime> Ref1_Date, List <DateTime> Ref2_Date, List <DateTime> Report1_Date, List <DateTime> Report2_Date)
        {
            int           size               = Background1_cps.Count;
            List <double> Activity_Current   = new List <double>();
            List <double> Background_cps     = new List <double>();
            List <float>  List_MatrixElement = new List <float>();

            float[,] MatrixElement = new float[size, size];
            double[,] ROI_cps      = new double[size, size];

            // calculate current activity and background of each nuclide
            for (int i = 0; i < size; i++)
            {
                Activity_Current.Add((DecayEq(Activity[i] * 1000, Ref1_Date[i], Report1_Date[i], HalfTime[i]) +
                                      DecayEq(Activity[i] * 1000, Ref2_Date[i], Report2_Date[i], HalfTime[i])) / 2);
                Background_cps.Add(Background1_cps[i] + Background2_cps[i]);

                GlobalFunc.logManager.WriteLog("Cal: Activity[" + i + "] " + Activity[i] * 1000);
                GlobalFunc.logManager.WriteLog("Cal: HalfTime[" + i + "] " + HalfTime[i]);

                GlobalFunc.logManager.WriteLog("Cal: Ref1_Date[" + i + "] " + Ref1_Date[i]);
                GlobalFunc.logManager.WriteLog("Cal: Report1_Date[" + i + "] " + Report1_Date[i]);
                GlobalFunc.logManager.WriteLog("Cal: Ref2_Date[" + i + "] " + Ref2_Date[i]);
                GlobalFunc.logManager.WriteLog("Cal: Report2_Date[" + i + "] " + Report1_Date[i]);

                GlobalFunc.logManager.WriteLog("Cal: Background1_cps[" + i + "] " + Background1_cps[i]);
                GlobalFunc.logManager.WriteLog("Cal: Background2_cps[" + i + "] " + Background2_cps[i]);
            }

            // transform into array format
            int k = 0;

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    ROI_cps[i, j] = Nuclide1_cps[k] + Nuclide2_cps[k];

                    k++;
                }
            }

            // calculate matrix element
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    GlobalFunc.logManager.WriteLog("Cal: ROI_cps[" + i + ", " + j + "] " + ROI_cps[i, j]);
                    GlobalFunc.logManager.WriteLog("Cal: Background_cps[" + j + "] " + Background_cps[j]);
                    GlobalFunc.logManager.WriteLog("Cal: Activity_Current[" + i + "] " + GlobalFunc.Math45(Activity_Current[i]));
                    GlobalFunc.logManager.WriteLog("Cal: Martix:" + (ROI_cps[i, j] - Background_cps[j]) + " / " + Activity_Current[i]);

                    //MatrixElement[j, i] = (ROI_cps[i, j] - Background_cps[j]) / GlobalFunc.Math45(Activity_Current[i]);
                    if ((ROI_cps[i, j] - Background_cps[j]) < 0)
                    {
                        MatrixElement[j, i] = 0;
                        GlobalFunc.logManager.WriteLog("Cal: MatrixElement[" + i + ", " + j + "] is negative -> to zero");
                    }
                    else
                    {
                        MatrixElement[j, i] = (Convert.ToSingle(ROI_cps[i, j]) - Convert.ToSingle(Background_cps[j])) / Convert.ToSingle(Activity_Current[i]);
                    }
                    GlobalFunc.logManager.WriteLog("Cal: MatrixElement[" + j + ", " + i + "] " + MatrixElement[j, i]);
                }
            }

            // transform into list format
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    List_MatrixElement.Add(MatrixElement[i, j]);
                }
            }

            /*for (int i = 0; i < List_MatrixElement.Count; i++)
             * {
             *  if (List_MatrixElement[i] < 0.0)
             *  {
             *      List_MatrixElement[i] = 0.0;
             *  }
             *  List_MatrixElement[i] = GlobalFunc.Math45(List_MatrixElement[i]);
             * }*/

            return(List_MatrixElement);
        }