Exemplo n.º 1
0
 private bool GetResult3(ref Result3 result)
 {
     if (null == myJobManager3)
     {
         return false;
     }
     ICogRecord tmpRecord;
     ICogRecord topRecord;
     try
     {
         topRecord = myJobManager3.UserResult();
         if (null == topRecord)
         {
             return false;
         }
         if (null != cogRecordDisplay3)
         {
             tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
             tmpRecord = tmpRecord.SubRecords["LastRun"];
             tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"];
             if (null != tmpRecord.Content)
             {
                 cogRecordDisplay3.Record = tmpRecord;
             }
             cogRecordDisplay3.AutoFit = true;
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        // public bool GetResultShow(int numOfSource)
        // {
        //     if (myJobManager == null)
        //     {
        //         return false;
        //     }
        //     ICogRecord tmpRecord;
        //     ICogRecord topRecord = myJobManager.UserResult();
        //     if (null != cogRecordDisplay)
        //     {
        //         tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
        //         tmpRecord = tmpRecord.SubRecords["LastRun"];
        //         tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"];
        //         if (null != tmpRecord.Content)
        //         {
        //             cogRecordDisplay[numOfSource].Record = tmpRecord;
        //         }
        //         cogRecordDisplay[numOfSource].Fit(true);
        //     }
        //     return true;
        // }
        /// <summary>
        /// Get All Results together
        /// </summary>
        /// <param name="resultin"></param>
        /// <param name="resultout"></param>
        /// <returns></returns>
        public bool GetResult(List <string> resultin, ref List <double> resultout)
        {
            if (null == myJobManager)
            {
                return(false);
            }
            ICogRecord tmpRecord;
            ICogRecord topRecord = myJobManager.UserResult();

            if (null == topRecord)
            {
                return(false);
            }
            if (null == resultin)
            {
                for (int i = 0; i < resultin.Count; i++)
                {
                    if (null == resultin[i])
                    {
                        return(false);
                    }
                    else
                    {
                        ResultRequest[i] = "@\"" + resultin[i] + "\"";
                        tmpRecord        = topRecord.SubRecords[ResultRequest[i]];                            resultout[i] = (double)tmpRecord.Content;
                        ResultRequest[i] = null;
                    }
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
 private bool GetResult1(ref Result1 result)
 {
     if (null == myJobManager1)
     {
         return false;
     }
     ICogRecord tmpRecord;
     ICogRecord topRecord;
     try
     {
         topRecord = myJobManager1.UserResult();
         if (null == topRecord)
         {
             return false;
         }
         tmpRecord = topRecord.SubRecords[@"Angle"];
         if (null != tmpRecord.Content)
         {
             result.ResultAngle = (double)tmpRecord.Content;
         }
         tmpRecord = topRecord.SubRecords[@"Tilt"];
         if (null != tmpRecord.Content)
         {
             result.ResultTilt = (double)tmpRecord.Content;
         }
         tmpRecord = topRecord.SubRecords[@"Distance"];
         if (null != tmpRecord.Content)
         {
             result.ResultDistance = (double)tmpRecord.Content;
         }
         if (null != cogRecordDisplay1)
         {
             tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
             tmpRecord = tmpRecord.SubRecords["LastRun"];
             tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"];
             if (null != tmpRecord.Content)
             {
                 cogRecordDisplay1.Record = tmpRecord;
             }
             cogRecordDisplay1.Fit(true);
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 6
0
 private bool GetResult0(ref Result0 result)
 {
     if (null == myJobManager0)
     {
         return false;
     }
     ICogRecord tmpRecord;
     ICogRecord topRecord;
     try
     {
         topRecord = myJobManager0.UserResult();
         if (null == topRecord)
         {
             return false;
         }
         tmpRecord = topRecord.SubRecords[@"X"];
         if (null != tmpRecord.Content) 
         {
             result.ResultX = (double)tmpRecord.Content;
         }
         tmpRecord = topRecord.SubRecords[@"Y"];
         if (null != tmpRecord.Content)
         {
             result.ResultY = (double)tmpRecord.Content;
         }
         tmpRecord = topRecord.SubRecords[@"Angle"];
         if (null != tmpRecord.Content)
         {
             result.ResultAngle = (double)tmpRecord.Content;
         }
         if (null != cogRecordDisplay0)
         {
             tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
             tmpRecord = tmpRecord.SubRecords["LastRun"];
             tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"];
             if (null != tmpRecord.Content)
             {
                 cogRecordDisplay0.Record = tmpRecord;
             }
             cogRecordDisplay0.Fit(true);
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Get All Results together
        /// </summary>
        /// <param name="resultin"></param>
        /// <param name="resultout"></param>
        /// <returns></returns>
        public bool GetResult(List <string> resultin, ref List <double> resultout)
        {
            if (null == myJobManager)
            {
                return(false);
            }
            ICogRecord tmpRecord;
            ICogRecord topRecord = myJobManager.UserResult();

            if (null == topRecord)
            {
                return(false);
            }
            if (null != resultin)
            {
                for (int i = 0; i < resultin.Count; i++)
                {
                    if (null == resultin[i])
                    {
                        return(false);
                    }
                    else
                    {
                        ResultRequest[i] = "@\"" + resultin[i] + "\"";
                        tmpRecord        = topRecord.SubRecords[ResultRequest[i]];
                        resultout[i]     = (double)tmpRecord.Content;
                        ResultRequest[i] = null;
                    }
                }
                return(true);
            }
            if (null != cogRecordDisplay)
            {
                tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
                tmpRecord = tmpRecord.SubRecords["LastRun"];
                tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"];
                if (null != tmpRecord.Content)
                {
                    cogRecordDisplay.Record = tmpRecord;
                }
                cogRecordDisplay.Fit(true);
            }
            return(false);
        }
Exemplo n.º 8
0
 private bool GetResult2(ref Result2 result)
 {
     if (null == myJobManager2)
     {
         return false;
     }
     ICogRecord tmpRecord;
     ICogRecord topRecord;
     try
     {
         topRecord = myJobManager2.UserResult();
         if (null == topRecord)
         {
             return false;
         }
         tmpRecord = topRecord.SubRecords[@"QRCode"];
         if (null != tmpRecord.Content) 
         {
             result.ResultQRCode = (string)tmpRecord.Content;
         }
         if (null != cogRecordDisplay2)
         {
             tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
             tmpRecord = tmpRecord.SubRecords["LastRun"];
             tmpRecord = tmpRecord.SubRecords["CogImageFileTool1.OutputImage"];
             if (null != tmpRecord.Content)
             {
                 cogRecordDisplay2.Record = tmpRecord;
             }
             cogRecordDisplay2.Fit(true);
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 9
0
        // This method grabs the blob count from the
        // Job Manager User Queue and displays it on the GUI.
        private void UpdateGUI()
        {
            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"];

            if (tmpRecord != null)
            {
                count            = (int)tmpRecord.Content;
                myCountText.Text = count.ToString();

                // Assume that the required "image" record is present, and go get it.
                tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
                if (tmpRecord != null)
                {
                    tmpRecord = tmpRecord.SubRecords["LastRun"];
                    if (tmpRecord != null)
                    {
                        tmpRecord = tmpRecord.SubRecords["Image Source.OutputImage"];
                        if (tmpRecord != null)
                        {
                            cogRecordDisplay1.Record = tmpRecord;
                            cogRecordDisplay1.Fit(true);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取结果
        /// </summary>
        ///
        /// <param name="result">< 结构体用于储存结果 ></param>
        ///
        /// <returns>< bool判定是否获取成功 ></returns>
        private bool GetResult(ref Result result)
        {
            bool IsResult1 = false;
            bool IsResult2 = false;
            bool IsResult3 = false;
            bool IsDispaly = false;

            if (myJobManager == null)
            {
                return(false);
            }
            ICogRecord tmpRecord;
            ICogRecord topRecord = myJobManager.UserResult();

            if (topRecord == null)
            {
                return(false);
            }
            try
            {
                tmpRecord = topRecord.SubRecords[@"X"];
                if (tmpRecord.Content != null)
                {
                    result.X  = (double)tmpRecord.Content;
                    IsResult1 = true;
                }
            }
            catch
            {
                IsResult1 = false;
            }
            try
            {
                tmpRecord = topRecord.SubRecords[@"Y"];
                if (tmpRecord.Content != null)
                {
                    result.Y  = (double)tmpRecord.Content;
                    IsResult2 = true;
                }
            }
            catch
            {
                IsResult2 = false;
            }
            try
            {
                tmpRecord = topRecord.SubRecords[@"Angle"];
                if (tmpRecord.Content != null)
                {
                    result.Angle = (double)tmpRecord.Content;
                    IsResult3    = true;
                }
            }
            catch
            {
                IsResult3 = false;
            }
            try
            {
                if (null != cogRecordDisplay)
                {
                    tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"];
                    tmpRecord = tmpRecord.SubRecords["LastRun"];
                    tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"];
                    if (null != tmpRecord.Content)
                    {
                        cogRecordDisplay.Record = tmpRecord;
                        IsDispaly = true;
                    }
                    cogRecordDisplay.AutoFit = true;
                }
            }
            catch
            {
                IsDispaly = false;
            }
            if (IsResult1 && IsResult2 && IsResult3 && IsDispaly)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }