Author Topic: Custom Component Debugging  (Read 2713 times)

seth350

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Custom Component Debugging
« on: June 27, 2017, 03:11:32 PM »
I have been working on creating a component for a Cognex Dataman BCR using the Dataman SDK.
Initial tests proved that I could add the component, set the IP address in the properties and once the application was started I could start receiving the scanned bar codes in AdvancedHMI.

My question is, I need to add another scanner component to the application. How would I go about debugging the two components separately? I am able to debug the component code during runtime, but it seems it is only showing me the running code for the last declared component. If that makes sense?

*Edit*
Or should the component (in my case), add a .vb file to the Solution Explorer for Scanner1 and Scanner2, respectively?
Since each scanner is it's own entity, it can't necessarily be running from one .vb file? Or can it?

I.E.,
In MainForm.Designer.vb
Code: [Select]
Friend WithEvents Scanner1 As CognexDatamanControl.CognexDataman
Friend WithEvents Scanner2 As CognexDatamanControl.CognexDataman ' Last declared component

Also, shouldn't these be initialized as:
Code: [Select]
Friend WithEvents Scanner1 As New CognexDatamanControl.CognexDataman
Friend WithEvents Scanner2 As New CognexDatamanControl.CognexDataman

Perhaps I do not fully understand how the component is built behind the scenes?
« Last Edit: June 27, 2017, 03:15:39 PM by seth350 »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Custom Component Debugging
« Reply #1 on: June 27, 2017, 03:37:45 PM »
Go down to the middle of the page to this section "Setting Up the Project for Design-Time Debugging" and see if this explains the debugging process for custom controls:

https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/walkthrough-debugging-custom-windows-forms-controls-at-design-time

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Custom Component Debugging
« Reply #2 on: June 27, 2017, 03:41:03 PM »
When you have multiple instances, debugging can get tricky because you have to check the name property to see which instance you are currently in.

seth350

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Custom Component Debugging
« Reply #3 on: June 27, 2017, 04:32:38 PM »
Thank you Archie, I will give that read.

I am connected to both scanners and I am receiving the strings from both and they are making it to my MainForm.

Although I am sure they are not gracefully being planted there. lol

I do at times get exceptions that I would like to see where they are goofing up at, hence why I asked.


One other thing while I have your attention Archie, this Cognex Dataman SDK includes events for various different actions. The SDK is wrote in C# and I have not been able to "subscribe" to events like they do.

How would I "subscribe" to a built-in event in an SDK?

I.E.,
Code: [Select]
Cognex.Dataman.SDK.ReadStringArrivedEventArgs
Cognex.Dataman.SDK.ReadStringArrivedHandler

*Edit*

Just had a quick read on Inherited controls and the way you must access the base class.

Code: [Select]

Public Shared Event SystemConnected As Cognex.Dataman.SDK.SystemConnectedHandler 'SystemConnected is an event from the SDK
Private Shared Sub OnSystemConnected(sender As Object, args As EventArgs) Handles cgnxSystem.SystemConnected
**code**
End Sub
« Last Edit: June 27, 2017, 06:09:18 PM by seth350 »

seth350

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Custom Component Debugging
« Reply #4 on: June 27, 2017, 09:20:34 PM »
I have it working now. Thank you Archie for the link.

shsobsidianlilly

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Custom Component Debugging
« Reply #5 on: January 19, 2018, 09:44:40 AM »
Seth350 Do you have the component working? I am also trying to connect and retrive data from 2 Cognex BCR's. Any help would be appreciated.

seth350

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Custom Component Debugging
« Reply #6 on: January 25, 2018, 09:22:08 PM »
I did get it working. However I scrapped using the Cognex SDK and just handled the scanner comms in the PLC. A lot cleaner and simpler.
One thing the SDK does not address is wireless scanners going into hibernation and losing connectivity. It would require the app to be restarted or call the disconnect sub and then the connect sub.

What I have is just a component built from the SDK that includes some properties to allow you to set the scanner IP address and also pick a label on your form to where the scanned string would show.

It wasn’t very difficult and would just require you to download the SDK and then reference it in your project.

Then add this at the top of your code.
Imports Cognex.Dataman.SDK

There are other things naturally that need to be set and the SDK includes a sample project that shows the code and how to set it up.

I can help when I can. I just have other things going on too.
« Last Edit: January 25, 2018, 09:30:56 PM by seth350 »