Пример #1
0
        /// <summary>
        /// This method is the event handler for the user result available
        /// event of the CogjobManger.  When this method is called the
        /// CogJobManager is telling us that one of the jobs has run and has
        /// genreated a new UserResult record packet.  This packet contians
        /// information about which job, if it passed or failed, or any
        /// other information, objects, or images that were added to the
        /// PostedItems section of QuickBuild.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Note that this app updates the GUI every time a new result is
        /// available.  Processor time is used every time the GUI is updated.
        /// For applications that require very high throughput it might not
        /// make sense to update the GUI for each run of the job as it will not
        /// be noticeable to a user, and can slow down your overall throughput.
        ///
        /// For high-throughput applications it will often make sense to
        /// consider options like only updating the GUI for every other result
        /// for example.
        /// </remarks>
        private void myJobManager_UserResultAvailable(object sender,
                                                      CogJobManagerActionEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new myJobManagerDelegate(
                           myJobManager_UserResultAvailable), new object[]
                       { sender, e });

                return;
            }

            Cognex.VisionPro.ICogRecord topRecord =
                myJobManager.UserResult();
            RunStatusTextBox.Text =
                topRecord.SubRecords["UserResultTag"].Content + ": "
                + topRecord.SubRecords["JobName"].Content + " --> "
                + topRecord.SubRecords["RunStatus"].Content.ToString();


            Cognex.VisionPro.ICogRecord tmpRecord;
            // Assume the required record is present and get it.
            tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
            tmpRecord = tmpRecord.SubRecords["LastRun"];
            tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"];
            cogRecordDisplay1.Record = tmpRecord;
            cogRecordDisplay1.Fit(true);
        }
Пример #2
0
        //	If it is called by a worker thread,
        //	InvokeRequired is true, as described above.  When this occurs, a delegate is constructed
        //	which is really a pointer to the method that the GUI thread should call.
        //	BeginInvoke is then called, with this delegate and the Image parameter.
        //	Notice that this subroutine tells the GUI thread to call the same subroutine!
        //	When the GUI calls this method on its own thread, InvokeRequired will be false and the
        //	CogRecordDisplay is updated with the info.
        // This method handles the UserResultAvailable Event. The user packet
        // has been configured to contain the blob tool input image, which we retrieve and display.
        private void myJobManager_UserResultAvailable(object sender, CogJobManagerActionEventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new UserResultDelegate(myJobManager_UserResultAvailable), new object[] { sender, e });
                return;
            }
            Cognex.VisionPro.ICogRecord tmpRecord;
            Cognex.VisionPro.ICogRecord topRecord = myJobManager.UserResult();

            // check to be sure results are available
            if (topRecord == null)
            {
                return;
            }

            // Assume that the required "count" record is present, and go get it.
            tmpRecord = topRecord.SubRecords[@"Tools.Item[""CogBlobTool1""].CogBlobTool.Results.GetBlobs().Count"];
            int count = (int)tmpRecord.Content;

            myCountText.Text = count.ToString();

            // Assume that the required "image" record is present, and go get it.
            tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
            tmpRecord = tmpRecord.SubRecords["LastRun"];
            tmpRecord = tmpRecord.SubRecords["Image Source.OutputImage"];
            cogRecordDisplay1.Record = tmpRecord;
            cogRecordDisplay1.Fit(true);
        }
Пример #3
0
        /// <summary>
        ///  This function handles the stopped event from the CogJobManager
        ///  When the Job is stopped it re-enables the Run Buttons. Note that
        ///  this function uses Invoke() as described in the beginning of
        ///  this document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void myJobManager_Stopped(object sender,
                                          CogJobManagerActionEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new myJobManagerDelegate(myJobManager_Stopped),
                       new object[] { sender, e });

                return;
            }

            RunOnceButton.Enabled   = true;
            RunContCheckBox.Enabled = true;  // Enable when stopped
        }