Exemplo n.º 1
0
        //ABB
        private void myImgComplete4(object sender, CogCompleteEventArgs e)              //定义ABB的相机
        {
            CogToolBlock myToolBlock;
            CogToolBlock myRunToolblock3;             //= myToolBlock.Tools("MyToolBlock3")

            int  numReadyVal   = 0;
            int  numPendingVal = 0;
            bool busyVal       = false;

            CogToolGroup myTG = (CogToolGroup)myJob.VisionTool;

            myToolBlock     = (CogToolBlock)myTG.Tools["AcquireImageAndProcessLeft"];
            myRunToolblock3 = (CogToolBlock)myToolBlock.Tools["MyToolBlock3"];

            CogAcqInfo info         = new CogAcqInfo();
            ICogImage  CurrentImage = default(ICogImage);

            // static int numAcqs = 0;
            try
            {
                AcqFifoTool4.Operator.GetFifoState(out numPendingVal, out numReadyVal, out busyVal);
                if (numReadyVal > 0)
                {
                    CurrentImage = (ICogImage)(AcqFifoTool4.Operator.CompleteAcquireEx(info));
                }
                else
                {
                    //Throw New CogAcqAbnormalException("Ready count is not greater than 0.")
                }
                myImgComplete4_numAcqs++;

                // We need to run the garbage collector on occasion to cleanup
                // images that are no longer being used.
                if (myImgComplete4_numAcqs > 4)
                {
                    GC.Collect();
                    myImgComplete4_numAcqs = 0;
                }
                ModuleCard.d1000_out_bit((short)10, (short)1);
                // Issue another acquisition request if we are in manual trigger mode.
                if (!ReferenceEquals(CurrentImage, null))
                {
                    myRunToolblock3.Inputs["Input2dImage"].Value = CurrentImage;
                    myRunToolblock3.Run();
                }
                // CogRecordDisplay1.Image = CurrentImage
            }
            catch (Exception)
            {
            }
        }
 /// <summary>
 /// Auto-Triggerring
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CogAcqFifo_Complete(object sender, CogCompleteEventArgs e)
 {
     lock (_lockFifoComplete)
     {
         _lastCogImage = null;
         try
         {
             do
             {
                 Stopwatch sw       = Stopwatch.StartNew();
                 ICogImage cogImage = WaitForImage(-1);
                 if (cogImage == null)
                 {
                     return;
                 }
                 _lastCogImage = cogImage;
                 if (ShowImageInWindows)
                 {
                     AssignImageToWindows(cogImage);
                 }
                 D.ObjectEventHandler delCallback = GetNextCallback();
                 if (delCallback != null)
                 {
                     delCallback(_lastCogImage);
                 }
                 _waitForImage.Set();
             } while (true);
         }
         catch (Exception ex)
         {
             U.LogError(ex, "Error in obtaining image");
             System.Diagnostics.Debug.WriteLine(string.Format("Error in obtaining image {0}", Name));
         }
         _waitForImage.Set();
     }
 }