private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            #region CognexShutDown
            try
            {
                //Close all open Framegrabbers due to RuntimeError R6025
                CogFrameGrabbers frameGrabbers = new CogFrameGrabbers();
                foreach (ICogFrameGrabber fg in frameGrabbers)
                {
                    fg.Disconnect(false);
                }

                //End Starting of Cognex in separate Thread
                if (cognexLoader != null)
                {
                    cognexLoader.Abort();
                }
                // Be sure to shudown the CogJobManager!!
                if (myJobManager != null)
                {
                    myJobManager.Shutdown();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Vision-Pro shutdown. Excepiton:" + ex.Message);
            }
            #endregion
        }
Exemplo n.º 2
0
 private void Form1_Closing(object sender, CancelEventArgs e)
 {
     myJobManager.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(myJobManager_UserResultAvailable);
     cogRecordDisplay1.Dispose();
     // Be sure to shudown the CogJobManager!!
     myJobManager.Shutdown();
 }
Exemplo n.º 3
0
        /// <summary>
        /// This function is called as the application is closing.  It
        /// contains some important details about properly cleaning up
        /// an applicaiton that utilizes the CogJobManager.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            // UNregister handler for Stopped event
            myJobManager.Stopped -=
                new CogJobManager.CogJobManagerStoppedEventHandler(
                    myJobManager_Stopped);

            // UNregister handler for UserResultAvailable event
            myJobManager.UserResultAvailable -=
                new CogJobManager.CogUserResultAvailableEventHandler(
                    myJobManager_UserResultAvailable);

            // This line prevents a deadlock that can occur
            // if a UserResult becomes available after
            // Form1_FormClosing() is called but before we unregister
            // the UserResultAvailable event.
            Application.DoEvents();

            // Be sure to shutdown the CogJobManager!!
            myJobManager.Shutdown();

            // Explictly Dispose of all VisionPro controls
            cogDisplayStatusBar1.Dispose();
            cogRecordDisplay1.Dispose();
        }
Exemplo n.º 4
0
 /// <summary>
 /// 关闭
 /// </summary>
 public bool Close()
 {
     if (null != myJobManager)
     {
         try
         {
             myJob.Reset();
             myJobManager.Stop();
             myJobManager.Shutdown();
             myJob            = null;
             myJobManager     = null;
             myJobIndependent = null;
             Imagein.Dispose();
             return(true);
         }
         catch
         {
             return(false);
         }
         GC.Collect();
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 5
0
 private void Form1_Closing(object sender, CancelEventArgs e)
 {
     timer1.Stop();
     cogRecordDisplay1.Dispose();
     // Be sure to shudown the CogJobManager!
     myJobManager.Shutdown();
     thread1.Abort();
 }
Exemplo n.º 6
0
 static void unload()
 {
     if (manager != null)
     {
         manager.Shutdown();
     }
     manager = null;
 }
Exemplo n.º 7
0
        private void CogForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (m_JobManager != null)
            {
                m_JobManager.Shutdown();
            }
            cogDisplay1.Dispose();
            CogFrameGrabbers grabbers = new CogFrameGrabbers();

            foreach (ICogFrameGrabber fg in grabbers)
            {
                fg.Disconnect(false);
            }
        }
Exemplo n.º 8
0
 public bool Close()
 {
     if (null != myJobManager)
     {
         myJob.Reset();
         myJobManager.Stop();
         myJobManager.Shutdown();
         myJob            = null;
         myJobManager     = null;
         myJobIndependent = null;
         return(true);
     }
     GC.Collect();
     return(false);
 }
Exemplo n.º 9
0
 public bool Close()
 {
     if (null != myJobManager)
     {
         for (int i = 0; i < myJob.Count; i++)
         {
             myJob[i].Reset();
             myJobManager.Stop();
             myJobManager.Shutdown();
             myJob[i]            = null;
             myJobManager        = null;
             myJobIndependent[i] = null;
         }
         return(true);
     }
     GC.Collect();
     return(false);
 }
Exemplo n.º 10
0
 public bool Close()
 {
     bool closeS1 = false;
     bool closeS2 = false;
     bool closeS3 = false;
     bool closeS4 = false;
     if (null != myJobManager0)
     {
         try
         {
             myJob0.Reset();
             myJobManager0.Stop();
             myJobManager0.Shutdown();
             myJob0 = null;
             myJobManager0 = null;
             myJobIndependent0 = null;
             closeS1 = true;
         }
         catch
         {}
     }
     else
     {
         closeS1 = false;
     }
     if (null != myJobManager1)
     {
         try
         {
             myJob1.Reset();
             myJobManager1.Stop();
             myJobManager1.Shutdown();
             myJob1 = null;
             myJobManager1 = null;
             myJobIndependent1 = null;
             closeS2 = true;
         }
         catch
         {}
     }
     else
     {
         closeS2 = false;
     }
     if (null != myJobManager2)
     {
         try
         {
             myJob2.Reset();
             myJobManager2.Stop();
             myJobManager2.Shutdown();
             myJob2 = null;
             myJobManager2 = null;
             myJobIndependent2 = null;
             closeS3 = true;
         }
         catch
         {}
     }
     else
     {
         closeS3 = false;
     }
     if (null != myJobManager3)
     {
         try
         {
             myJob3.Reset();
             myJobManager3.Stop();
             myJobManager3.Shutdown();
             myJob3 = null;
             myJobManager3 = null;
             myJobIndependent3 = null;
             closeS4= true;
         }
         catch
         {}
     }
     else
     {
         closeS4 = false;
     }
     GC.Collect();
     if (closeS1 == true && closeS2 == true && closeS3 == true && closeS4 == true)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemplo n.º 11
0
        static int Main(string[] args)
        {
            //     1          2             3          4
            // bix source.vpp [--bin|--xml] target.vpp [option]
            string help = "usage: bix source.vpp [--bin|--xml] target.vpp [option]\n\t option: min, results, all";

            if (args.Length < 3 || args.Length > 4)
            {
                //foreach (var s in args)
                //{
                //Console.WriteLine(s);
                //}
                Console.WriteLine(help);
                return(-1);
            }
            var           source = args[0];
            var           type   = args[1].Replace("-", "").ToLower();
            var           target = args[2];
            var           option = args.Length == 4 ? args[3].ToLower() : "";
            CogJobManager vpro   = null;

            try
            {
                if (!System.IO.File.Exists(source))
                {
                    Console.WriteLine("source does not exits.");
                    return(-1);
                }
                vpro = (CogJobManager)CogSerializer.LoadObjectFromFile(source);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(-1);
            }
            if (string.IsNullOrEmpty(option))
            {
                try
                {
                    CogSerializer.SaveObjectToFile(vpro, target, type == "xml" ? typeof(SoapFormatter) : typeof(BinaryFormatter));
                }
                catch (System.Runtime.Serialization.SerializationException ex)
                {
                    Console.WriteLine(ex.Message);
                    return(-1);
                }
                Console.WriteLine("converted");
            }
            else
            {
                Dictionary <string, CogSerializationOptionsConstants> options = new Dictionary <string, CogSerializationOptionsConstants>
                {
                    { "min", CogSerializationOptionsConstants.Minimum },
                    { "results", CogSerializationOptionsConstants.Results },
                    { "all", CogSerializationOptionsConstants.All }
                };
                try
                {
                    CogSerializer.SaveObjectToFile(vpro, target,
                                                   type == "xml" ? typeof(SoapFormatter) : typeof(BinaryFormatter),
                                                   options[option]
                                                   );
                }
                catch (System.Runtime.Serialization.SerializationException ex)
                {
                    Console.WriteLine(ex.Message);
                    return(-1);
                }
                Console.WriteLine("converted (" + option + ")");
            }
            vpro.Shutdown();
            return(0);
            //Console.ReadKey();
        }