[python-win32] COM Event Question
Steve Goldman
steve_g@ix.netcom.com
Sun, 9 Mar 2003 23:33:24 -0500
Mark,
Thank you for your response.
The classes in the COM object are as follows:
OPCBrowser(DispatchBaseClass)
IOPCGroups(DispatchBaseClass)
IOPCGroup(DispatchBaseClass)
DIOPCGroupEvent - an Event Class
OPCItems(DispatchBaseClass)
OPCItem(DispatchBaseClass)
OPCServer(CoClassBaseClass)-the registered COM automation object
(OPC.Automation.1)
OPCGroup(CoClassBaseClass)- the automation object I'm trying to get events
from
DIOPCGroupsEvent - an Event Class
OPCGroups(CoClassBaseClass)- a collection of the automation objects I'm
trying to get events from
IOPCAutoServer(DispatchBaseClass)
DIOPCServerEvent - an Event Class
There are 3 event classes in the type library and 3 "automation object"
classes that are associated with them. Based on what you said, I should have
3 separate user-defined event handlers in my code. I have changed my code
to do that, and I will see how it works as I get further.
I tried to dispatch the OPCGroup object as you suggested.
> > groups=OPC.OPCGroups
> > group=groups.Add('Group 1')
> group = DispatchWithEvents(group, ClassName)
That threw an AttributeError, because my "group" didn't have a
.GetTypeInfo() method. I also tried dispatching the OPCGroup object using
the CLSID from the type library, but I got a COM error (object not
registered). So I'm still stuck on how to dispatch my OPCGroup with events.
A separate problem, but one that may be related, is that I can't get all the
methods in the type library to work. Many of them do, but not all. It
seems that methods that pass "dynamically sized arrays" aren't working for
me. I get a COM error, with an SCode value of E_INVALIDARG. Since most of
the events also pass these arrays, I wonder if that creates a problem.
I'd appreciate any additional pointers you might have on how to further
troubleshoot this. I'd also like to say that I really appreciate the tools
and documentation that you've developed. I'm reading your book, and I'm
just having a lot of fun using python with Windows. Thanks.