Cognex OPC Server with VB.NET Client

recondaddy

Member
Join Date
Apr 2006
Location
Atlanta, GA
Posts
77
Hello,

I've been wrestling for two days with an issue and wanted to see if any of you gurus had any insight.

I have Cognex OPC Server 4.5 running. I'm writing an OPC client in VB.NET. It's not my first time writing an OPC client, but I'm no pro at it, either.

I have two OPC groups -- a trigger group and a data group. I am subscribed to the trigger group, and whenever the OPC server generates a data change event for that group, in the event handler, I call a subroutine that performs an asynchronous read of the data group. Simple enough, right?

Here's the crazy part. If I turn off the subscription to the trigger group and initiate an asynchronous read using the click of a button, everything goes off without a hitch. However, if I call the asynchronous read subroutine from the data change event handler of the trigger group, it never completes the read and locks up my GUI.

It's has nothing to do with my asynchronous read subroutine -- it works fine. It has to do with the manner in which it is being called. Call from a button click? Works fine. Call from a data change event? Locks up.

I'm stumped.
 
The data change event can possibly be called on a different thread than the main UI. If you access the main UI or perform actions on the main UI in a different thread, it can potentially get you into troubles.

I would use a delegate and invoke the subroutine from the data change event. If you search ".NET delegate", you can find lots of examples.
 
Thanks Archie.

The thought crossed my mind that it might be a threading issue. I'll take a look at that, tomorrow.

Again, thanks for the reply!
 
Hey Archie,

Talked to a guy from Cognex who also suggested it might be a threading issue. So, in the data change event handler, I put a message box display to tell me whether the data change event was on the same thread as the GUI (main thread).

In the data change event handler, there is but one line of code:

MessageBox.Show(Me.Label1.InvokeRequired.ToString)

When the data change event fires, the message box pops up and says, "False".

This tells me, if I did the test correctly, that the data change event is on the same thread as Label1, the main thread.

I've been surprised, a few times, at how little these guys know about their own product. Anyway, the search continues. I'll post back if I get a definitive answer.
 

Similar Topics

Hello, I have problem to trigger Cognex InSight 7010. Im running OPC server on laptop and cameras are connected to Ethernet. All is working fine...
Replies
4
Views
2,903
Hi, the second question of the day :) I have a CIMPLCITY 6.1 project that communicates with a Cognex camera, trought their OPC. I'm trying...
Replies
2
Views
3,546
We finally replaced our Cognex Checker with an IV-3 and I'm wondering if can replace the s/w in the monitor with anything else. I haven't been...
Replies
0
Views
96
Thank you for any and all responses/help. I have an RSLogix 5000 v20 and a Cognex In-Sight v5.9 spreadsheet (8502P). I can not figure out how to...
Replies
0
Views
118
Which signals do I have to use to get data from camera. For example camera detects a defect and sends signal to controller. Power cable: CCB-PWRIO-05
Replies
1
Views
177
Back
Top Bottom