示例#1
0
 public static void SetBackgroundBKList(string toggleDetector)
 {
     if (toggleDetector.Contains("Top"))
     {
         if (File.Exists(GlobalFunc.topScriptSet.BackgrounData))
         {
             List <Roi> roiList1 = GlobalFunc.GetRoiData(GlobalFunc.topScriptSet.BackgrounData);
             if (roiList1.Count > 0)
             {
                 BKManager.bkList = BKManager.CalBk(roiList1, ref BKManager.dt, ref BKManager.lifeTime, 1);
             }
         }
     }
     else if (toggleDetector.Contains("Bottom"))
     {
         List <Roi> roiList2 = GlobalFunc.GetRoiData(GlobalFunc.bottomScriptSet.BackgrounData);
         if (roiList2.Count > 0)
         {
             BKManager.bkList = BKManager.CalBk(roiList2, ref BKManager.dt, ref BKManager.lifeTime, 1);
         }
     }
     else if (toggleDetector.Contains("Dual"))
     {
         List <Roi> roiList1 = GlobalFunc.GetRoiData(GlobalFunc.topScriptSet.BackgrounData);
         List <Roi> roiList2 = GlobalFunc.GetRoiData(GlobalFunc.bottomScriptSet.BackgrounData);
         if (roiList1.Count > 0)
         {
             BKManager.bkList = BKManager.CalDualBk(roiList1, roiList2, ref BKManager.dt, ref BKManager.lifeTime, 1);
         }
     }
 }
示例#2
0
        public void GetDetector2Temp()
        {
            if (GlobalFunc.getTemp == true)
            {
                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.Math45Pt1(Convert.ToDouble(thisTemp));
                            retry = false;
                        }
                        else
                        {
                            retry = true;
                            retryCount++;
                        }
                        axUCONN21.Close();
                    }
                    catch (Exception ex)
                    {
                        retryCount++;
                    }
                    if (retryCount == 5)
                    {
                        try
                        {
                            axUDROP1.SelIndex = 1;
                            axUCONN21.Address = axUDROP1.SelAddress;
                        }
                        catch { }
                    }
                    if (retryCount == 10)
                    {
                        break;
                    }
                }
            }
        }
示例#3
0
        public void UpdateDetector2Temp()
        {
            bool retry      = true;
            int  retryCount = 0;

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

                    GlobalFunc.axUCONN22.Open();
                    if (GlobalFunc.axUCONN22.ID == 2)
                    {
                        string thisTemp = GlobalFunc.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)
                {
                    GlobalFunc.axUDROP2.SelIndex = 1;
                    GlobalFunc.axUCONN22.Address = axUDROP1.SelAddress;
                }
                if (retryCount == 10)
                {
                    break;
                }
            }
        }
示例#4
0
 public static void ShowDetectorError(string toggleDetector)
 {
     if (toggleDetector == "Top" && !GlobalFunc.connectedToDetector1)
     {
         GlobalFunc.SetAlarmBox(6);
         string buttonID = CustomMessageBox.Show(GlobalFunc.rm.GetString("failConnectDetector1"), GlobalFunc.rm.GetString("noticeMsg"), GlobalFunc.rm.GetString("yesBtnTxt"), "", false, 0);
         if (buttonID == "1")
         {
             GlobalFunc.settingForm.Invoke(new MethodInvoker(delegate { GlobalFunc.settingForm.Enabled = true;
                                                                        GlobalFunc.settingForm.EnableControl(); }));
             GlobalFunc.SetAlarmBox(0);
             GlobalFunc.settingForm.UpdateStatusLabel("Alarm", 255, 0, 0);
         }
     }
     else if (toggleDetector == "Bottom" && !GlobalFunc.connectedToDetector2)
     {
         GlobalFunc.SetAlarmBox(6);
         string buttonID = CustomMessageBox.Show(GlobalFunc.rm.GetString("failConnectDetector2"), GlobalFunc.rm.GetString("noticeMsg"), GlobalFunc.rm.GetString("yesBtnTxt"), "", false, 0);
         if (buttonID == "1")
         {
             GlobalFunc.settingForm.Invoke(new MethodInvoker(delegate { GlobalFunc.settingForm.Enabled = true;
                                                                        GlobalFunc.settingForm.EnableControl(); }));
             GlobalFunc.SetAlarmBox(0);
             GlobalFunc.settingForm.UpdateStatusLabel("Alarm", 255, 0, 0);
         }
     }
     else
     {
         if (!GlobalFunc.connectedToDetector1 && !GlobalFunc.connectedToDetector2)
         {
             GlobalFunc.SetAlarmBox(6);
             string buttonID = CustomMessageBox.Show(GlobalFunc.rm.GetString("failConnectDetector1") + System.Environment.NewLine + GlobalFunc.rm.GetString("failConnectDetector2"), GlobalFunc.rm.GetString("noticeMsg"), GlobalFunc.rm.GetString("yesBtnTxt"), "", false, 0);
             if (buttonID == "1")
             {
                 GlobalFunc.settingForm.Invoke(new MethodInvoker(delegate { GlobalFunc.settingForm.Enabled = true;
                                                                            GlobalFunc.settingForm.EnableControl(); }));
                 GlobalFunc.settingForm.UpdateStatusLabel("Alarm", 255, 0, 0);
                 GlobalFunc.SetAlarmBox(0);
             }
         }
     }
 }
示例#5
0
 public void GetDetector1Temp()
 {
     if (GlobalFunc.getTemp == true)
     {
         bool retry      = true;
         int  retryCount = 0;
         while (retry)
         {
             try
             {
                 if (GlobalFunc.axUCONN21.IsOpen)
                 {
                     GlobalFunc.axUCONN21.Close();
                 }
                 GlobalFunc.axUCONN21.Open();
                 if (GlobalFunc.axUCONN21.ID == 1)
                 {
                     string thisTemp = GlobalFunc.axUCONN21.Comm("SHOW_DET_TEMP");
                     thisTemp             = thisTemp.Replace("DET_TEMP ", "");
                     GlobalFunc.det1_temp = GlobalFunc.Math45Pt1(Convert.ToDouble(thisTemp));
                 }
                 else
                 {
                     retry = true;
                     retryCount++;
                 }
                 retry = false;
             }
             catch (Exception ex)
             {
                 retryCount++;
             }
             if (retryCount == 10)
             {
                 break;
             }
         }
     }
 }
示例#6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            GlobalFunc.logManager.CreateLogFile();
            GlobalFunc.logManager.CreateUserLogFile();
            GlobalFunc.assembly = Assembly.Load("LCMS");

            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "defaultSetting"))
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "defaultSetting");
            }



            BKManager.SetLiveTime();
            GlobalFunc.SetMeasureSetting();
            GlobalFunc.tc = new TestConnection();

            Application.Run(new SplashScreen());
        }
示例#7
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            GlobalFunc.logManager.WriteLog("Open LCMS");
            int countTime = 0;

            #region loading basic.xml
            try
            {
                XmlSerializer deserializer1 = new XmlSerializer(typeof(BasicSetting));
                TextReader    textReader    = new StreamReader(@Directory.GetCurrentDirectory() + @"\xml\Basic.xml");
                GlobalFunc.basicSetting = (BasicSetting)deserializer1.Deserialize(textReader);
                textReader.Close();
                if (GlobalFunc.basicSetting.Lang == "Zn")
                {
                    GlobalFunc.rm = new ResourceManager("LCMS.Lang.LangZn", GlobalFunc.assembly);
                }
                else
                {
                    GlobalFunc.rm = new ResourceManager("LCMS.Lang.LangEn", GlobalFunc.assembly);
                }

                noticeLabel.Invoke(new MethodInvoker(delegate { noticeLabel.Text = GlobalFunc.rm.GetString("loadBasicXML"); }));

                countTime += 50;
                if (GlobalFunc.basicSetting.GetTemp.ToLower() == "on")
                {
                    GlobalFunc.getTemp = true;
                }
                else if (GlobalFunc.basicSetting.GetTemp.ToLower() == "off")
                {
                    GlobalFunc.getTemp = false;
                }
                countTime += 50;


                XmlSerializer deserializer2 = new XmlSerializer(typeof(ScriptSet));
                TextReader    textReader2   = new StreamReader(@Directory.GetCurrentDirectory() + @"\xml\DualScript.xml");
                GlobalFunc.dualScriptSet = (ScriptSet)deserializer2.Deserialize(textReader2);
                textReader2.Close();
                countTime += 50;

                XmlSerializer deserializer3 = new XmlSerializer(typeof(ScriptSet));
                TextReader    textReader3   = new StreamReader(@Directory.GetCurrentDirectory() + @"\xml\TopScript.xml");
                GlobalFunc.topScriptSet = (ScriptSet)deserializer3.Deserialize(textReader3);
                textReader3.Close();
                countTime += 50;

                XmlSerializer deserializer4 = new XmlSerializer(typeof(ScriptSet));
                TextReader    textReader4   = new StreamReader(@Directory.GetCurrentDirectory() + @"\xml\BottomScript.xml");
                GlobalFunc.bottomScriptSet = (ScriptSet)deserializer4.Deserialize(textReader4);
                textReader4.Close();
                countTime += 50;

                GlobalFunc.LoadRoiElement();
                GlobalFunc.LoadIsotopXML();

                if (GlobalFunc.basicSetting.InsalledIO.ToLower() == "true")
                {
                    GlobalFunc.intIOAddress = Convert.ToInt32(GlobalFunc.basicSetting.IoAddress, 16);
                    try
                    {
                        //reset to only led #1 on
                        PortAccess.Output(GlobalFunc.intIOAddress, 0);
                    }
                    catch
                    {
                        MessageBox.Show("IO Address not found");
                    }

                    #region check inpot32.dll is existed
                    noticeLabel.Invoke(new MethodInvoker(delegate { noticeLabel.Text = GlobalFunc.rm.GetString("checkIO"); }));
                    if (!File.Exists(@"C:\Windows\System32\inpout32.dll"))
                    {
                        if (File.Exists(@Directory.GetCurrentDirectory() + @"\inpout32.dll"))
                        {
                            noticeLabel.Invoke(new MethodInvoker(delegate
                            {
                                MessageBox.Show(@"Please copy inpout32.dll from C:\LCMS to C:\Windows\System32");
                            }));
                        }
                        else
                        {
                            noticeLabel.Invoke(new MethodInvoker(delegate
                            {
                                MessageBox.Show("Can't find inpout32.dll in program directory");
                            }));
                        }
                    }
                    countTime += 50;
                    Thread.Sleep(1000);
                    #endregion
                }
                countTime += 50;
                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion

            #region check exe path is correct
            //no more use mca32
            //backgroundWorker.ReportProgress(30);
            //if (!File.Exists(GlobalFunc.basicSetting.ExePath))
            //{
            //    for (int k = 0; k < 10; k++)
            //    {
            //        noticeLabel.Invoke(new MethodInvoker(delegate { noticeLabel.Text = GlobalFunc.rm.GetString("exeNotFound"); }));
            //        Thread.Sleep(1000);
            //    }
            //}
            //Thread.Sleep(3000); //wait 5 second to start connect
            #endregion

            if (GlobalFunc.basicSetting.PresetDetector.ToLower() == "top" || GlobalFunc.basicSetting.PresetDetector.ToLower() == "dual")
            {
                #region Detector 1
                noticeLabel.Invoke(new MethodInvoker(delegate { noticeLabel.Text = GlobalFunc.rm.GetString("connectDetector1"); }));
                backgroundWorker.ReportProgress(50);
                countTime += 50;
                noticeLabel.Invoke(new MethodInvoker(delegate
                {
                    GlobalFunc.tc.checkDetector1Connection();
                }));
                if (!GlobalFunc.connectedToDetector1)
                {
                    detectorLabel1.Invoke(new MethodInvoker(delegate { detectorLabel1.Text = GlobalFunc.rm.GetString("failConnectDetector1"); }));
                }
                else
                {
                    detectorLabel1.Invoke(new MethodInvoker(delegate
                    {
                        detectorLabel1.Text = GlobalFunc.rm.GetString("successDetector1");
                        GlobalFunc.tc.GetDetector1ICR();
                    }));
                    detectorLabel1.ForeColor = Color.Blue;
                }
                #endregion
                Thread.Sleep(3000);
            }

            if (GlobalFunc.basicSetting.PresetDetector.ToLower() == "bottom" || GlobalFunc.basicSetting.PresetDetector.ToLower() == "dual")
            {
                #region Detector 2
                noticeLabel.Invoke(new MethodInvoker(delegate { noticeLabel.Text = GlobalFunc.rm.GetString("connectDetector2"); }));
                backgroundWorker.ReportProgress(50);
                countTime += 50;
                noticeLabel.Invoke(new MethodInvoker(delegate
                {
                    GlobalFunc.tc.checkDetector2Connection();
                }));
                if (!GlobalFunc.connectedToDetector2)
                {
                    detectorLabel2.Invoke(new MethodInvoker(delegate { detectorLabel2.Text += GlobalFunc.rm.GetString("failConnectDetector2"); }));
                }
                else
                {
                    detectorLabel2.Invoke(new MethodInvoker(delegate
                    {
                        detectorLabel2.Text += GlobalFunc.rm.GetString("successDetector2");
                        GlobalFunc.tc.GetDetector2ICR();
                    }));
                    detectorLabel2.ForeColor = Color.Blue;
                }
                #endregion
            }

            for (int i = 0; i < 1000 - countTime; i++)
            {
                Thread.Sleep(10);
                backgroundWorker.ReportProgress(i);
            }
        }
示例#8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            /*ScriptSet dualScript = new ScriptSet();
             *
             * XmlSerializer serializer = new XmlSerializer(typeof(ScriptSet), "");
             * TextWriter textWriter = new StreamWriter(@Directory.GetCurrentDirectory() + @"\xml\BottomScript.xml");
             * using (TextWriter tw = new Utf8StringWriter())
             * {
             *  serializer.Serialize(textWriter, dualScript);
             * }
             * textWriter.Close();*/

            GlobalFunc.logManager.CreateLogFile();
            GlobalFunc.logManager.CreateUserLogFile();
            GlobalFunc.assembly = Assembly.Load("LCMS");

            if (!Directory.Exists(@"C:\LCMS\defaultSetting"))
            {
                Directory.CreateDirectory(@"C:\LCMS\defaultSetting");
            }

            try
            {
                XmlSerializer deserializer1 = new XmlSerializer(typeof(BasicSetting));
                TextReader    textReader    = new StreamReader(@Directory.GetCurrentDirectory() + @"\xml\Basic.xml");
                GlobalFunc.basicSetting = (BasicSetting)deserializer1.Deserialize(textReader);
                textReader.Close();

                if (GlobalFunc.basicSetting.GetTemp.ToLower() == "on")
                {
                    GlobalFunc.getTemp = true;
                }
                else if (GlobalFunc.basicSetting.GetTemp.ToLower() == "off")
                {
                    GlobalFunc.getTemp = false;
                }

                GlobalFunc.intIOAddress = Convert.ToInt32(GlobalFunc.basicSetting.IoAddress, 16);

                XmlSerializer deserializer2 = new XmlSerializer(typeof(ScriptSet));
                TextReader    textReader2   = new StreamReader(@Directory.GetCurrentDirectory() + @"\xml\DualScript.xml");
                GlobalFunc.dualScriptSet = (ScriptSet)deserializer2.Deserialize(textReader2);
                textReader2.Close();

                XmlSerializer deserializer3 = new XmlSerializer(typeof(ScriptSet));
                TextReader    textReader3   = new StreamReader(@Directory.GetCurrentDirectory() + @"\xml\TopScript.xml");
                GlobalFunc.topScriptSet = (ScriptSet)deserializer3.Deserialize(textReader3);
                textReader3.Close();

                XmlSerializer deserializer4 = new XmlSerializer(typeof(ScriptSet));
                TextReader    textReader4   = new StreamReader(@Directory.GetCurrentDirectory() + @"\xml\BottomScript.xml");
                GlobalFunc.bottomScriptSet = (ScriptSet)deserializer4.Deserialize(textReader4);
                textReader4.Close();

                GlobalFunc.LoadIsotopXML();

                #region check inpot32.dll is existed
                if (!File.Exists(@"C:\Windows\System32\inpout32.dll"))
                {
                    if (File.Exists(@Directory.GetCurrentDirectory() + @"\inpout32.dll"))
                    {
                        MessageBox.Show(@"Please copy inpout32.dll from C:\LCMS to C:\Windows\System32");
                    }
                    else
                    {
                        MessageBox.Show("Can't find inpout32.dll in program directory");
                    }
                }
                #endregion

                if (GlobalFunc.basicSetting.InsalledIO.ToLower() == "true")
                {
                    try
                    {
                        //reset to only led #1 on
                        PortAccess.Output(GlobalFunc.intIOAddress, 0);
                    }
                    catch
                    {
                        MessageBox.Show("IO Addresws not found");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (GlobalFunc.basicSetting.Lang == "Zn")
            {
                GlobalFunc.rm = new ResourceManager("LCMS.Lang.LangZn", GlobalFunc.assembly);
            }
            else
            {
                GlobalFunc.rm = new ResourceManager("LCMS.Lang.LangEn", GlobalFunc.assembly);
            }
            //string text = (1.3 * Math.Pow(10, 9) * 365).ToString();

            BKManager.SetLiveTime();
            GlobalFunc.SetMeasureSetting();
            GlobalFunc.tc = new TestConnection();

            Application.Run(new SplashScreen());

            //Application.Run(GlobalFunc.tc);
            //Application.Run(new SettingForm());
            //Application.Run(new OutputWord());
            //Application.Run(new MainForm());
            //Application.Run(new LoginForm());
        }
示例#9
0
        public static Profile LoadProfile(string fileName)
        {
            try
            {
                Profile loadProfile = new Profile();
                string  line;
                string  path = @"C:\LCMS\Profile\" + fileName;
                using (StreamReader reader = File.OpenText(path))
                {
                    bool   matrixTopOn    = false;
                    bool   matrixBottomOn = false;
                    bool   matrixDual     = false;
                    IsoSeq ise            = new IsoSeq();
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Contains("Profile Name:"))
                        {
                            loadProfile.ProfileName = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Detector:"))
                        {
                            loadProfile.Detector = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Location:"))
                        {
                            loadProfile.Location = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Alarm Type:"))
                        {
                            loadProfile.Alarm = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("No. of Region:"))
                        {
                            loadProfile.NoOfRegion = Convert.ToInt32(line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1)));
                        }
                        else if (line.Contains("Date:"))
                        {
                            loadProfile.Date = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Roi Path1:"))
                        {
                            loadProfile.RoiPath1 = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Roi Path2:"))
                        {
                            loadProfile.RoiPath2 = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Live Time:"))
                        {
                            loadProfile.LiveTime = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Background Top CPS:"))
                        {
                            string inner = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                            if (inner != "")
                            {
                                loadProfile.BkTopCPS = inner.Split(',').ToList();
                            }
                        }
                        else if (line.Contains("Background Bottom CPS:"))
                        {
                            string inner = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                            if (inner != "")
                            {
                                loadProfile.BKBottomCPS = inner.Split(',').ToList();
                            }
                        }
                        else if (line.Contains("Quantity of Isotope:"))
                        {
                            loadProfile.Qty = Convert.ToInt32(line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1)));
                        }
                        else if (line.Contains("Roi#"))
                        {
                            ise        = new IsoSeq();
                            ise.Number = Convert.ToInt32(line.Substring(line.IndexOf("#") + 1, 1));
                            ise.Name   = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Activity:"))
                        {
                            ise.Activity = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                            ise.Activity = (Convert.ToDouble(ise.Activity) / 1000).ToString();
                        }
                        else if (line.Contains("Ref Datetime:"))
                        {
                            ise.RefDateTime = DateTime.Parse(line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1)));
                        }
                        else if (line.Contains("Measure Time:"))
                        {
                            ise.MeasureTime = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("DIL"))
                        {
                            ise.DIL = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("AL") && !line.Contains("%"))
                        {
                            ise.AL = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("AL%"))
                        {
                            ise.AL_PC = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Top CPS:") && !line.Contains("Bakcground"))
                        {
                            ise.TopCPS = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                        }
                        else if (line.Contains("Bottom CPS:") && !line.Contains("Background"))
                        {
                            ise.BottomCPS = line.Substring(line.IndexOf(":") + 1, line.Length - (line.IndexOf(":") + 1));
                            loadProfile.IsoSeqList.Add(ise);
                        }
                        else if (line.Contains("Matrix Top:"))
                        {
                            matrixTopOn    = true;
                            matrixBottomOn = false;
                            matrixDual     = false;
                        }
                        else if (matrixTopOn)
                        {
                            if (!line.Contains("Matrix Top:") && line != "" && !line.Contains("Matrix Bottom:") && !line.Contains("Matrix Dual:"))
                            {
                                string[] mTop = line.Split(',');
                                for (int i = 0; i < mTop.Length; i++)
                                {
                                    if (mTop[i] != "")
                                    {
                                        loadProfile.MatrixTop.Add(Convert.ToSingle(mTop[i]));
                                    }
                                }
                            }
                            else if (line.Contains("Matrix Bottom:"))
                            {
                                matrixTopOn    = false;
                                matrixBottomOn = true;
                                matrixDual     = false;
                            }
                        }
                        else if (line.Contains("Matrix Bottom:"))
                        {
                            matrixTopOn    = false;
                            matrixBottomOn = true;
                            matrixDual     = false;
                        }
                        else if (matrixBottomOn)
                        {
                            if (!line.Contains("Matrix Bottom:") && line != "" && !line.Contains("Matrix Top:") && !line.Contains("Matrix Dual:"))
                            {
                                string[] mBottom = line.Split(',');
                                for (int i = 0; i < mBottom.Length; i++)
                                {
                                    if (mBottom[i] != "")
                                    {
                                        loadProfile.MatrixBottom.Add(Convert.ToSingle(mBottom[i]));
                                    }
                                }
                            }
                            else if (line.Contains("Matrix Dual:"))
                            {
                                matrixTopOn    = false;
                                matrixBottomOn = false;
                                matrixDual     = true;
                            }
                        }
                        else if (line.Contains("Matrix Dual:"))
                        {
                            matrixTopOn    = false;
                            matrixBottomOn = false;
                            matrixDual     = true;
                        }
                        else if (matrixDual)
                        {
                            if (!line.Contains("Matrix Dual:") && line != "" && !line.Contains("Matrix Top:") && !line.Contains("Matrix Bottom:"))
                            {
                                string[] mDual = line.Split(',');
                                for (int i = 0; i < mDual.Length; i++)
                                {
                                    if (mDual[i] != "")
                                    {
                                        loadProfile.MatrixDual.Add(Convert.ToSingle(mDual[i]));
                                    }
                                }
                            }
                        }
                    }
                }

                GlobalFunc.LoadIsotopXML();
                for (int i = 0; i < loadProfile.IsoSeqList.Count; i++)
                {
                    loadProfile.Activity.Add(Convert.ToDouble(loadProfile.IsoSeqList[i].Activity));
                    loadProfile.Ref_Date.Add(loadProfile.IsoSeqList[i].RefDateTime);
                    if (loadProfile.Alarm == "DIL")
                    {
                        loadProfile.AlarmLevel.Add(Convert.ToDouble(loadProfile.IsoSeqList[i].DIL));
                        loadProfile.AlarmPCLevel.Add(Convert.ToDouble(loadProfile.IsoSeqList[i].AL_PC));
                    }
                    else if (loadProfile.Alarm == "AL")
                    {
                        loadProfile.AlarmLevel.Add(Convert.ToDouble(loadProfile.IsoSeqList[i].AL));
                        loadProfile.AlarmPCLevel.Add(Convert.ToDouble(loadProfile.IsoSeqList[i].AL_PC));
                    }
                    loadProfile.AlarmPCLevel.Add(Convert.ToDouble(loadProfile.IsoSeqList[i].AL_PC));
                    for (int j = 0; j < GlobalFunc.isotopeList1.Count; j++)
                    {
                        if (loadProfile.IsoSeqList[i].Name == GlobalFunc.isotopeList1[j].Code)
                        {
                            loadProfile.HalfTime.Add(Convert.ToDouble(GlobalFunc.isotopeList1[j].HalfLife));
                            loadProfile.RatioPeak.Add(Convert.ToDouble(GlobalFunc.isotopeList1[j].Bop));

                            break;
                        }
                    }
                }

                if (loadProfile.Detector == "Dual")
                {
                    for (int i = 0; i < loadProfile.BkTopCPS.Count; i++)
                    {
                        double value = Convert.ToDouble(loadProfile.BkTopCPS[i]) + Convert.ToDouble(loadProfile.BKBottomCPS[i]);
                        //string strValue = Math.Round(value, 2).ToString();
                        loadProfile.FinalBkCPS.Add(value);
                    }
                    loadProfile.FinalMatrix = loadProfile.MatrixDual;
                }
                else if (loadProfile.Detector == "Top")
                {
                    for (int i = 0; i < loadProfile.BkTopCPS.Count; i++)
                    {
                        loadProfile.FinalBkCPS.Add(Convert.ToDouble(loadProfile.BkTopCPS[i]));
                    }
                    loadProfile.FinalMatrix = loadProfile.MatrixTop;
                }
                else if (loadProfile.Detector == "Bottom")
                {
                    for (int i = 0; i < loadProfile.BKBottomCPS.Count; i++)
                    {
                        loadProfile.FinalBkCPS.Add(Convert.ToDouble(loadProfile.BKBottomCPS[i]));
                    }
                    loadProfile.FinalMatrix = loadProfile.MatrixBottom;
                }
                loadProfile.FinalBkCPS.RemoveAt(loadProfile.FinalBkCPS.Count - 1);
                return(loadProfile);
            }
            catch (Exception ex)
            {
                GlobalFunc.logManager.WriteLog("load profile error:" + ex.Message);
                return(null);
            }
        }
示例#10
0
        public static void SetTemp(int isotopeNumber, string toggleDetector, string originScriptName, string roiPath1, string roiPath2)
        {
            string tempName = "";
            string path     = "";

            if (File.Exists(originScriptName))
            {
                path     = originScriptName.Substring(0, originScriptName.LastIndexOf(@"\"));
                tempName = "temp_" + originScriptName.Substring(originScriptName.LastIndexOf(@"\") + 1, originScriptName.Length - (originScriptName.LastIndexOf(@"\") + 1));

                string fullName = path + "\\" + tempName;

                if (File.Exists(fullName))
                {
                    File.Delete(fullName);
                }

                File.Copy(originScriptName, fullName);
                tempRunScript = fullName;

                //Edit bkscript
                GlobalFunc.EditScript("SET_PRESET_LIVE", tempRunScript, Convert.ToString(supposeSecond), true, "RECALL_ROI");

                if (isotopeNumber == 4)
                {
                    if (toggleDetector == "Top")
                    {
                        if (roiPath1 != "")
                        {
                            GlobalFunc.EditScript(@"C:\LCMS\ROI\DET1_ROI5.ROI", tempRunScript, "\"" + roiPath1 + "\"", true, "RECALL_ROI");
                        }
                    }
                    else if (toggleDetector == "Bottom")
                    {
                        if (roiPath2 != "")
                        {
                            GlobalFunc.EditScript(@"C:\LCMS\ROI\DET2_ROI5.ROI", tempRunScript, "\"" + roiPath2 + "\"", true, "RECALL_ROI");
                        }
                    }
                    else
                    {
                        if (roiPath1 != "" && roiPath2 != "")
                        {
                            GlobalFunc.EditScript(@"C:\LCMS\ROI\DET1_ROI5.ROI", tempRunScript, "\"" + roiPath1 + "\"", true, "RECALL_ROI");
                            GlobalFunc.EditScript(@"C:\LCMS\ROI\DET2_ROI5.ROI", tempRunScript, "\"" + roiPath2 + "\"", true, "RECALL_ROI");
                        }
                    }
                }
                else if (isotopeNumber == 5)
                {
                    if (toggleDetector == "Top")
                    {
                        if (roiPath1 != "")
                        {
                            GlobalFunc.EditScript(@"C:\LCMS\ROI\DET1_ROI5.ROI", tempRunScript, "\"" + roiPath1 + "\"", true, "RECALL_ROI");
                        }
                    }
                    else if (toggleDetector == "Bottom")
                    {
                        if (roiPath2 != "")
                        {
                            GlobalFunc.EditScript(@"C:\LCMS\ROI\DET2_ROI5.ROI", tempRunScript, "\"" + roiPath2 + "\"", true, "RECALL_ROI");
                        }
                    }
                    else
                    {
                        if (roiPath1 != "" && roiPath2 != "")
                        {
                            GlobalFunc.EditScript(@"C:\LCMS\ROI\DET1_ROI5.ROI", tempRunScript, "\"" + roiPath1 + "\"", true, "RECALL_ROI");
                            GlobalFunc.EditScript(@"C:\LCMS\ROI\DET2_ROI5.ROI", tempRunScript, "\"" + roiPath2 + "\"", true, "RECALL_ROI");
                        }
                    }
                }
                else if (isotopeNumber == 6)
                {
                    if (toggleDetector == "Top")
                    {
                        GlobalFunc.EditScript(@"C:\LCMS\ROI\DET1_ROI5.ROI", tempRunScript, "\"" + roiPath1 + "\"", true, "RECALL_ROI");
                    }
                    else if (toggleDetector == "Bottom")
                    {
                        GlobalFunc.EditScript(@"C:\LCMS\ROI\DET2_ROI5.ROI", tempRunScript, "\"" + roiPath2 + "\"", true, "RECALL_ROI");
                    }
                    else
                    {
                        GlobalFunc.EditScript(@"C:\LCMS\ROI\DET1_ROI5.ROI", tempRunScript, "\"" + roiPath1 + "\"", true, "RECALL_ROI");
                        GlobalFunc.EditScript(@"C:\LCMS\ROI\DET2_ROI5.ROI", tempRunScript, "\"" + roiPath2 + "\"", true, "RECALL_ROI");
                    }
                }
            }
        }
示例#11
0
文件: Cal.cs 项目: man0551hk/ficom
        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);
        }