예제 #1
0
    // Allows you to add or modify the contents of the last run record when it is
    // created.  For example, you might add custom graphics to the run record here.
    public override void ModifyLastRunRecord(Cognex.VisionPro.ICogRecord lastRecord)
    {
        foreach (CogGraphicLabel label in BaslerLabels)
        {
            toolGroup.AddGraphicToRunRecord(label, lastRecord, "CalBasler.OutputImage", "script");
        }

        foreach (CogGraphicLabel lbl in AreaLabel)
        {
            toolGroup.AddGraphicToRunRecord(lbl, lastRecord, "CalBasler.OutputImage", "script");
        }

        foreach (CogGraphicLabel label in FlirLabels)
        {
            toolGroup.AddGraphicToRunRecord(label, lastRecord, "CalFlir.OutputImage", "script");
        }

        foreach (CogRectangleAffine rectangle in FlirRectangles)
        {
            toolGroup.AddGraphicToRunRecord(rectangle, lastRecord, "CalFlir.OutputImage", "script");
        }

        foreach (CogPointMarker marker in Crosshairs)
        {
            toolGroup.AddGraphicToRunRecord(marker, lastRecord, "CalBasler.OutputImage", "script");
        }
    }
예제 #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 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);
        }
예제 #4
0
 private void DisplayResult(CogRecordDisplay Display, CogToolBlock checker)
 {
     if (checker.RunStatus.Result != 0)
     {
         Display.Image = (checker.Outputs["OutputImage"].Value as Cognex.VisionPro.ICogImage);
         Display.Fit(false);
     }
     else
     {
         Cognex.VisionPro.ICogRecord record = checker.CreateLastRunRecord();
         Display.Image  = (checker.Outputs["OutputImage"].Value as Cognex.VisionPro.ICogImage);
         Display.Record = record;
         Display.Fit(false);
     }
 }
예제 #5
0
        public void ToolBlock_PrintInfor(CogToolBlock toolblock)
        {
            int numTools = toolblock.Tools.Count;

            Console.WriteLine($"-------------Toolblock {toolblock.Name} begin----------------");
            Console.WriteLine("-------------element");
            for (int i = 0; i < numTools; i++)
            {
                Console.WriteLine($"{toolblock.Tools[i].Name}");

                //cur record
                Cognex.VisionPro.ICogRecord tmpRecord = toolblock.Tools[i].CreateCurrentRecord();
                Console.WriteLine($"\ttmpRecord currentRecord = {tmpRecord.Annotation}");
                for (int j = 0; j < tmpRecord.SubRecords.Count; j++)
                {
                    Console.WriteLine($"\t\tj = {j}: {tmpRecord.SubRecords[j].Annotation}");
                }


                //lastest record
                tmpRecord = toolblock.Tools[i].CreateLastRunRecord();
                Console.WriteLine($"\ttmpRecord LastRecord = {tmpRecord.Annotation}");
                for (int j = 0; j < tmpRecord.SubRecords.Count; j++)
                {
                    Console.WriteLine($"\t\tj = {j}: {tmpRecord.SubRecords[j].Annotation}");
                }
            }

            Console.WriteLine("-------------input");
            int numInputs = toolblock.Inputs.Count;

            for (int i = 0; i < numInputs; i++)
            {
                Console.WriteLine($"{toolblock.Inputs[i].Name}");
            }

            Console.WriteLine("-------------output");
            int numOutputs = toolblock.Outputs.Count;

            for (int i = 0; i < numOutputs; i++)
            {
                Console.WriteLine($"{toolblock.Outputs[i].Name}");
            }

            Console.WriteLine($"-------------Toolblock {toolblock.Name} end----------------");
        }
예제 #6
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);
                        }
                    }
                }
            }
        }
예제 #7
0
 public override void ModifyCurrentRunRecord(Cognex.VisionPro.ICogRecord currentRecord)
 {
 }
 public void RanToolBlock(ToolBlockPowerSuite toolBlockPowerSuite, Canvas cnv, Cognex.VisionPro.ICogRecord irc, object Outputs)
 {
     cnv.Display(irc);
     if (toolBlockPowerSuite.Passed)
     {
         OKOccured(toolBlockPowerSuite, cnv, irc, Outputs);
     }
     else
     {
         App.nNGNum++;
         string NGDescription = NGOccured(toolBlockPowerSuite, cnv, irc, Outputs);
         new Thread((ThreadStart) delegate
         {
             CaptureCurrentImage(toolBlockPowerSuite, NGDescription);
         }).Start();
     }
 }
 private void OKOccured(ToolBlockPowerSuite toolBlockPowerSuite, Canvas cnv, Cognex.VisionPro.ICogRecord irc, object Outputs)
 {
     //cnv.DisplayText(1, text);
 }
 private string NGOccured(ToolBlockPowerSuite toolBlockPowerSuite, Canvas cnv, Cognex.VisionPro.ICogRecord irc, object Outputs)
 {
     return("未找到特征");
 }