[python-win32] problem accessing OPC clients from thread

Jeff Peery jeffpeery at yahoo.com
Fri Dec 14 01:31:55 CET 2007


Hello,
  I've gotten my OPC client to work well under a multi threaded wxApp. Now I am trying to create a single threaded App because, from what I've learned from users on this list, it is a simpler and cleaner way to do ththings.
   
  I've setup a test script that allows me to catch DataChange events (see attached code). This seems to work well. Now I'm one step from putting it into my wxApp, and I'm wondering how can I do this? Ideally I want the OnDataChange method to be a method in my wxApp. But it is instead a method that is part of the GroupEvents class. Do I need to post an event from the GroupEvents.OnDataChange method to the wxApp so that I can catch the data change event in the wxApp? How is this typically done?
   
  Big Thanks!
   
  Jeff
   
   
  Graham Bloice <graham.bloice at trihedral.com> wrote:
  Jeff Peery wrote:
> thanks for the beta!
> 
> I think my main problem is that I don't really understand this code; I
> didn't write it. Could you recommend a book/website that describes
> what these functions like 'group.OPCItems.AddItem' do? For example,
> how do I know what a 'group' is or what the addItem() parameters are,
> or how to interpret that error code that you interpreted, and I'm not
> really sure if this code will work for other OPC servers other than
> the automation direct server.
> 
> Also, where might I go learn about how to setup the event handler for
> a data change event?
> 
> Thanks again, I appreciate your help!
> Jeff
> 
The canonical definition of the OPC Automation interface API is the OPC
DA Auto 2.02 Specification. DA stands for Data Acquisition. The
originators of this document are the OPC Foundation, at
http://www.opcfoundation.org, and the specification is *so* open you
have to become a member to download it (at a cost of USD 1500). Grrr.

However, if your Google fu is up to it you might find a copy lying
around elsewhere, as I have run across it on several OPC Vendors sites. 
I think I've also found it with several OPC Servers. I would recommend
that you get the Matrikon OPC Simulation server for testing, this
installs the Matrikon OPC Explorer which is a useful client app to work
out what's happening when your client doesn't work. This might give you
the docs. The document goes under various names such as opcda20_auto.doc.

Note that the docs are VB (VB6) based, but not too difficult to convert
to python.

You will also want to read up on creating event handlers in PyWin

-- 
Regards,

Graham Bloice



       
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20071213/75748e86/attachment.htm 


More information about the python-win32 mailing list