Esempio n. 1
0
 /// <summary>
 /// 断开仪器连接
 /// </summary>
 public override bool Disconnect()
 {
     if (omTalkObject != null)
     {
         omTalkObject.EndOMNIC();
         omTalkObject = null;
     }
     System.Diagnostics.Process[] tp = (System.Diagnostics.Process.GetProcessesByName("omnic32"));
     if (tp.Count() > 0)
     {
         for (int i = 0; i < tp.Length; i++)
         {
             tp[i].Kill();
         }
     }
     System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("OmTalk");
     if (processes.Length > 0)
     {
         for (int i = 0; i < processes.Length; i++)
         {
             processes[i].Kill();
         }
     }
     return(true);
 }
Esempio n. 2
0
        /// <summary>
        /// 加载Omnic
        /// </summary>
        /// <param name="forceReload"></param>
        /// <returns></returns>
        private bool InitOmnicTalk(bool forceReload = false)
        {
            try
            {
                //if (forceReload && omTalkObject != null)
                //{
                //    omTalkObject.EndOMNIC();
                //    omTalkObject = null;
                //}

                if (omTalkObject == null)
                {
                    //System.Windows.Forms.MessageBox.Show("Init");
                    omTalkObject = new OmTalk.OmTalkClass();
                    omTalkObject.LoadOmTalk();
                    //System.Windows.Forms.MessageBox.Show("Start");
                    //Minimized with out focus
                    var result = omTalkObject.StartOMNIC(7, null);
                    //System.Windows.Forms.MessageBox.Show("StartEnd "+result);
                }
                return(true);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                System.Windows.Forms.MessageBox.Show(ErrorMessage);
                return(false);
            }
        }