bonjour
Voici le fichier g=E9g=E9r=E9 par makepy pour obtenir les m=E9thodes afin
d'utilier l'interface COM pour d=E9velopper un client OPC
********************
# -*- coding: mbcs -*-
# Created by makepy.py version 0.4.95
# By python version 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310
32 bit (Intel)]
# From type library 'OPCDAAuto.dll'
# On Wed May 09 08:26:18 2007
"""Matrikon OPC Automation 2.0"""
makepy_version =3D '0.4.95'
python_version =3D 0x20500f0
import win32com.client.CLSIDToClass, pythoncom
import win32com.client.util
from pywintypes import IID
from win32com.client import Dispatch
# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing, .Empty and .ArgNotFound
defaultNamedOptArg=3Dpythoncom.Empty
defaultNamedNotOptArg=3Dpythoncom.Empty
defaultUnnamedArg=3Dpythoncom.Empty
class constants:
OPCReadable =3D0x1 # from enum OPCAccessRights
OPCWritable =3D0x2 # from enum OPCAccessRights
OPCCache =3D0x1 # from enum OPCDataSource
OPCDevice =3D0x2 # from enum OPCDataSource
OPCBadRights =3D-1073479674 # from enum OPCErrors
OPCBadType =3D-1073479676 # from enum OPCErrors
OPCClamp =3D0x4000e # from enum OPCErrors
OPCDuplicateName =3D-1073479668 # from enum OPCErrors
OPCInuse =3D0x4000f # from enum OPCErrors
OPCInvalidConfig =3D-1073479664 # from enum OPCErrors
OPCInvalidFilter =3D-1073479671 # from enum OPCErrors
OPCInvalidHandle =3D-1073479679 # from enum OPCErrors
OPCInvalidItemID =3D-1073479672 # from enum OPCErrors
OPCInvalidPID =3D-1073479165 # from enum OPCErrors
OPCNotFound =3D-1073479663 # from enum OPCErrors
OPCPublic =3D-1073479675 # from enum OPCErrors
OPCRange =3D-1073479669 # from enum OPCErrors
OPCUnknownItemID =3D-1073479673 # from enum OPCErrors
OPCUnknownPath =3D-1073479670 # from enum OPCErrors
OPCUnsupportedRate =3D0x4000d # from enum OPCErrors
OPCFlat =3D0x2 # from enum
OPCNamespaceTypes
OPCHierarchical =3D0x1 # from enum
OPCNamespaceTypes
OPCQualityBad =3D0x0 # from enum OPCQuality
OPCQualityGood =3D0xc0 # from enum OPCQuality
OPCQualityMask =3D0xc0 # from enum OPCQuality
OPCQualityUncertain =3D0x40 # from enum OPCQuality
OPCLimitConst =3D0x3 # from enum
OPCQualityLimits
OPCLimitHigh =3D0x2 # from enum
OPCQualityLimits
OPCLimitLow =3D0x1 # from enum
OPCQualityLimits
OPCLimitMask =3D0x3 # from enum
OPCQualityLimits
OPCLimitOk =3D0x0 # from enum
OPCQualityLimits
OPCStatusCommFailure =3D0x18 # from enum
OPCQualityStatus
OPCStatusConfigError =3D0x4 # from enum
OPCQualityStatus
OPCStatusDeviceFailure =3D0xc # from enum
OPCQualityStatus
OPCStatusEGUExceeded =3D0x54 # from enum
OPCQualityStatus
OPCStatusLastKnown =3D0x14 # from enum
OPCQualityStatus
OPCStatusLastUsable =3D0x44 # from enum
OPCQualityStatus
OPCStatusLocalOverride =3D0xd8 # from enum
OPCQualityStatus
OPCStatusMask =3D0xfc # from enum
OPCQualityStatus
OPCStatusNotConnected =3D0x8 # from enum
OPCQualityStatus
OPCStatusOutOfService =3D0x1c # from enum
OPCQualityStatus
OPCStatusSensorCal =3D0x50 # from enum
OPCQualityStatus
OPCStatusSensorFailure =3D0x10 # from enum
OPCQualityStatus
OPCStatusSubNormal =3D0x58 # from enum
OPCQualityStatus
OPCDisconnected =3D0x6 # from enum OPCServerState
OPCFailed =3D0x2 # from enum OPCServerState
OPCNoconfig =3D0x3 # from enum OPCServerState
OPCRunning =3D0x1 # from enum OPCServerState
OPCSuspended =3D0x4 # from enum OPCServerState
OPCTest =3D0x5 # from enum OPCServerState
class DIOPCGroupEvent:
"""OPC Group Events"""
CLSID =3D CLSID_Sink =3D IID('{F8582D2B-88FB-11D0-B850-00C0F0104305}')
coclass_clsid =3D IID('{F8582D30-88FB-11D0-B850-00C0F0104305}')
_public_methods_ =3D [] # For COM Server support
_dispid_to_func_ =3D {
4 : "OnAsyncCancelComplete",
1 : "OnDataChange",
2 : "OnAsyncReadComplete",
3 : "OnAsyncWriteComplete",
}
def __init__(self, oobj =3D None):
if oobj is None:
self._olecp =3D None
else:
import win32com.server.util
from win32com.server.policy import EventHandlerPolicy
=09
cpc=3Doobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer)
cp=3Dcpc.FindConnectionPoint(self.CLSID_Sink)
cookie=3Dcp.Advise(win32com.server.util.wrap(self,
usePolicy=3DEventHandlerPolicy))
self._olecp,self._olecp_cookie =3D cp,cookie
def __del__(self):
try:
self.close()
except pythoncom.com_error:
pass
def close(self):
if self._olecp is not None:
cp,cookie,self._olecp,self._olecp_cookie =3D
self._olecp,self._olecp_cookie,None,None
cp.Unadvise(cookie)
def _query_interface_(self, iid):
import win32com.server.util
if iid=3D=3Dself.CLSID_Sink: return win32com.server.util.wrap(self)
# Event Handlers
# If you create handlers, they should have the following prototypes:
# def OnAsyncCancelComplete(self, CancelID=3DdefaultNamedNotOptArg):
# def OnDataChange(self, TransactionID=3DdefaultNamedNotOptArg,
NumItems=3DdefaultNamedNotOptArg, ClientHandles=3DdefaultNamedNotOptArg,
ItemValues=3DdefaultNamedNotOptArg
# , Qualities=3DdefaultNamedNotOptArg,
TimeStamps=3DdefaultNamedNotOptArg):
# def OnAsyncReadComplete(self, TransactionID=3DdefaultNamedNotOptArg,
NumItems=3DdefaultNamedNotOptArg, ClientHandles=3DdefaultNamedNotOptArg,
ItemValues=3DdefaultNamedNotOptArg
# , Qualities=3DdefaultNamedNotOptArg,
TimeStamps=3DdefaultNamedNotOptArg, Errors=3DdefaultNamedNotOptArg):
# def OnAsyncWriteComplete(self, TransactionID=3DdefaultNamedNotOptArg,
NumItems=3DdefaultNamedNotOptArg, ClientHandles=3DdefaultNamedNotOptArg,
Errors=3DdefaultNamedNotOptArg):
class DIOPCGroupsEvent:
"""OPC Groups Event"""
CLSID =3D CLSID_Sink =3D IID('{F8582D29-88FB-11D0-B850-00C0F0104305}')
coclass_clsid =3D IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}')
_public_methods_ =3D [] # For COM Server support
_dispid_to_func_ =3D {
1 : "OnGlobalDataChange",
}
def __init__(self, oobj =3D None):
if oobj is None:
self._olecp =3D None
else:
import win32com.server.util
from win32com.server.policy import EventHandlerPolicy
=09
cpc=3Doobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer)
cp=3Dcpc.FindConnectionPoint(self.CLSID_Sink)
cookie=3Dcp.Advise(win32com.server.util.wrap(self,
usePolicy=3DEventHandlerPolicy))
self._olecp,self._olecp_cookie =3D cp,cookie
def __del__(self):
try:
self.close()
except pythoncom.com_error:
pass
def close(self):
if self._olecp is not None:
cp,cookie,self._olecp,self._olecp_cookie =3D
self._olecp,self._olecp_cookie,None,None
cp.Unadvise(cookie)
def _query_interface_(self, iid):
import win32com.server.util
if iid=3D=3Dself.CLSID_Sink: return win32com.server.util.wrap(self)
# Event Handlers
# If you create handlers, they should have the following prototypes:
# def OnGlobalDataChange(self, TransactionID=3DdefaultNamedNotOptArg,
GroupHandle=3DdefaultNamedNotOptArg, NumItems=3DdefaultNamedNotOptArg,
ClientHandles=3DdefaultNamedNotOptArg
# , ItemValues=3DdefaultNamedNotOptArg,
Qualities=3DdefaultNamedNotOptArg, TimeStamps=3DdefaultNamedNotOptArg):
class DIOPCServerEvent:
"""OPC Server Event"""
CLSID =3D CLSID_Sink =3D IID('{F8582D26-88FB-11D0-B850-00C0F0104305}')
coclass_clsid =3D IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}')
_public_methods_ =3D [] # For COM Server support
_dispid_to_func_ =3D {
1 : "OnServerShutDown",
}
def __init__(self, oobj =3D None):
if oobj is None:
self._olecp =3D None
else:
import win32com.server.util
from win32com.server.policy import EventHandlerPolicy
=09
cpc=3Doobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer)
cp=3Dcpc.FindConnectionPoint(self.CLSID_Sink)
cookie=3Dcp.Advise(win32com.server.util.wrap(self,
usePolicy=3DEventHandlerPolicy))
self._olecp,self._olecp_cookie =3D cp,cookie
def __del__(self):
try:
self.close()
except pythoncom.com_error:
pass
def close(self):
if self._olecp is not None:
cp,cookie,self._olecp,self._olecp_cookie =3D
self._olecp,self._olecp_cookie,None,None
cp.Unadvise(cookie)
def _query_interface_(self, iid):
import win32com.server.util
if iid=3D=3Dself.CLSID_Sink: return win32com.server.util.wrap(self)
# Event Handlers
# If you create handlers, they should have the following prototypes:
# def OnServerShutDown(self, Reason=3DdefaultNamedNotOptArg):
from win32com.client import DispatchBaseClass
class IOPCAutoServer(DispatchBaseClass):
"""OPCServer Object"""
CLSID =3D IID('{F8582D25-88FB-11D0-B850-00C0F0104305}')
coclass_clsid =3D IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}')
def Connect(self, ProgID=3DdefaultNamedNotOptArg,
Node=3DdefaultNamedOptArg):
"""Connect to a named OPC Server"""
return self._oleobj_.InvokeTypes(1610743826, LCID, 1, (24, 0), ((8,
1), (12, 17)),ProgID
, Node)
# Result is of type OPCBrowser
def CreateBrowser(self):
"""Create a new OPCBrowser Object"""
ret =3D self._oleobj_.InvokeTypes(1610743828, LCID, 1, (9, 0), (),)
if ret is not None:
ret =3D Dispatch(ret, 'CreateBrowser', '{F8582D27-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
def GetErrorString(self, ErrorCode=3DdefaultNamedNotOptArg):
"""Convert an error code to a descriptive string"""
# Result is a Unicode object - return as-is for this version of
Python
return self._oleobj_.InvokeTypes(1610743829, LCID, 1, (8, 0), ((3,
1),),ErrorCode
)
def GetOPCServers(self, Node=3DdefaultNamedOptArg):
"""Returns an array of Server names, optionally on another node"""
return self._ApplyTypes_(1610743825, 1, (12, 0), ((12, 17),),
'GetOPCServers', None,Node
)
class IOPCGroups(DispatchBaseClass):
"""Collection of OPC Group objects"""
CLSID =3D IID('{F8582D28-88FB-11D0-B850-00C0F0104305}')
coclass_clsid =3D IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}')
# Result is of type OPCGroup
def Add(self, Name=3DdefaultNamedOptArg):
"""Adds an OPCGroup to the collection"""
ret =3D self._oleobj_.InvokeTypes(1610743822, LCID, 1, (13, 0), ((12,
17),),Name
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret =3D ret.QueryInterface(pythoncom.IID_IDispatch)
except pythoncom.error:
return ret
ret =3D Dispatch(ret, 'Add', '{F8582D30-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
# Result is of type OPCGroup
def ConnectPublicGroup(self, Name=3DdefaultNamedNotOptArg):
"""Adds an existing public OPCGroup to the collection"""
ret =3D self._oleobj_.InvokeTypes(1610743826, LCID, 1, (13, 0), ((8,
1),),Name
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret =3D ret.QueryInterface(pythoncom.IID_IDispatch)
except pythoncom.error:
return ret
ret =3D Dispatch(ret, 'ConnectPublicGroup', '{F8582D30-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
# Result is of type OPCGroup
def GetOPCGroup(self, ItemSpecifier=3DdefaultNamedNotOptArg):
"""Returns an OPCGroup specified by server handle or name"""
ret =3D self._oleobj_.InvokeTypes(1610743823, LCID, 1, (13, 0), ((12,
1),),ItemSpecifier
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret =3D ret.QueryInterface(pythoncom.IID_IDispatch)
except pythoncom.error:
return ret
ret =3D Dispatch(ret, 'GetOPCGroup', '{F8582D30-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
# Result is of type OPCGroup
def Item(self, ItemSpecifier=3DdefaultNamedNotOptArg):
"""Returns an OPCGroup by index (starts at 1) or name"""
ret =3D self._oleobj_.InvokeTypes(0, LCID, 1, (13, 0), ((12,
1),),ItemSpecifier
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret =3D ret.QueryInterface(pythoncom.IID_IDispatch)
except pythoncom.error:
return ret
ret =3D Dispatch(ret, 'Item', '{F8582D30-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
def Remove(self, ItemSpecifier=3DdefaultNamedNotOptArg):
"""Removes an OPCGroup specified by server handle or name"""
return self._oleobj_.InvokeTypes(1610743825, LCID, 1, (24, 0), ((12,
1),),ItemSpecifier
)
def RemoveAll(self):
"""Remove all groups and their items"""
return self._oleobj_.InvokeTypes(1610743824, LCID, 1, (24, 0), (),)
def RemovePublicGroup(self, ItemSpecifier=3DdefaultNamedNotOptArg):
"""Removes a public OPCGroup specified by server handle or name"""
return self._oleobj_.InvokeTypes(1610743827, LCID, 1, (24, 0), ((12,
1),),ItemSpecifier
)
_prop_map_get_ =3D {
"Count": (1610743819, 2, (3, 0), (), "Count", None),
"DefaultGroupDeadband": (1610743813, 2, (4, 0), (),
"DefaultGroupDeadband", None),
"DefaultGroupIsActive": (1610743809, 2, (11, 0), (),
"DefaultGroupIsActive", None),
"DefaultGroupLocaleID": (1610743815, 2, (3, 0), (),
"DefaultGroupLocaleID", None),
"DefaultGroupTimeBias": (1610743817, 2, (3, 0), (),
"DefaultGroupTimeBias", None),
"DefaultGroupUpdateRate": (1610743811, 2, (3, 0), (),
"DefaultGroupUpdateRate", None),
# Method 'Parent' returns object of type 'IOPCAutoServer'
"Parent": (1610743808, 2, (9, 0), (), "Parent", '{F8582D25-88FB-11D0-
B850-00C0F0104305}'),
}
_prop_map_put_ =3D {
"DefaultGroupDeadband": ((1610743813, LCID, 4, 0),()),
"DefaultGroupIsActive": ((1610743809, LCID, 4, 0),()),
"DefaultGroupLocaleID": ((1610743815, LCID, 4, 0),()),
"DefaultGroupTimeBias": ((1610743817, LCID, 4, 0),()),
"DefaultGroupUpdateRate": ((1610743811, LCID, 4, 0),()),
}
# Default method for this class is 'Item'
def __call__(self, ItemSpecifier=3DdefaultNamedNotOptArg):
"""Returns an OPCGroup by index (starts at 1) or name"""
ret =3D self._oleobj_.InvokeTypes(0, LCID, 1, (13, 0), ((12,
1),),ItemSpecifier
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret =3D ret.QueryInterface(pythoncom.IID_IDispatch)
except pythoncom.error:
return ret
ret =3D Dispatch(ret, '__call__', '{F8582D30-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
# str(ob) and int(ob) will use __call__
def __unicode__(self, *args):
try:
return unicode(self.__call__(*args))
except pythoncom.com_error:
return repr(self)
def __str__(self, *args):
return str(self.__unicode__(*args))
def __int__(self, *args):
return int(self.__call__(*args))
def __iter__(self):
"Return a Python iterator for this object"
ob =3D self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),())
return win32com.client.util.Iterator(ob)
def _NewEnum(self):
"Create an enumerator from this object"
return
win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13,
10),()),'{F8582D30-88FB-11D0-B850-00C0F0104305}')
def __getitem__(self, index):
"Allow this class to be accessed as a collection"
if not self.__dict__.has_key('_enum_'):
self.__dict__['_enum_'] =3D self._NewEnum()
return self._enum_.__getitem__(index)
#This class has Count() property - allow len(ob) to provide this
def __len__(self):
return self._ApplyTypes_(*(1610743819, 2, (3, 0), (), "Count",
None))
#This class has a __len__ - this is needed so 'if object:' always
returns TRUE.
def __nonzero__(self):
return True
class OPCBrowser(DispatchBaseClass):
"""OPC Browser"""
CLSID =3D IID('{F8582D27-88FB-11D0-B850-00C0F0104305}')
coclass_clsid =3D None
def GetAccessPaths(self, ItemID=3DdefaultNamedNotOptArg):
"""Returns an array of Access Paths for an ItemID"""
return self._ApplyTypes_(1610743827, 1, (12, 0), ((8, 1),),
'GetAccessPaths', None,ItemID
)
def GetItemID(self, Leaf=3DdefaultNamedNotOptArg):
"""Converts a leaf name to an ItemID"""
# Result is a Unicode object - return as-is for this version of
Python
return self._oleobj_.InvokeTypes(1610743826, LCID, 1, (8, 0), ((8,
1),),Leaf
)
def Item(self, ItemSpecifier=3DdefaultNamedNotOptArg):
# Result is a Unicode object - return as-is for this version of
Python
return self._oleobj_.InvokeTypes(1610743819, LCID, 1, (8, 0), ((12,
1),),ItemSpecifier
)
def MoveDown(self, Branch=3DdefaultNamedNotOptArg):
"""Move down into this branch"""
return self._oleobj_.InvokeTypes(1610743824, LCID, 1, (24, 0), ((8,
1),),Branch
)
def MoveTo(self, Branches=3DdefaultNamedNotOptArg):
"""Move to this absolute position"""
return self._oleobj_.InvokeTypes(1610743825, LCID, 1, (24, 0),
((24584, 1),),Branches
)
def MoveToRoot(self):
"""Move up to the top (root) of the tree"""
return self._oleobj_.InvokeTypes(1610743823, LCID, 1, (24, 0), (),)
def MoveUp(self):
"""Move up a level in the tree"""
return self._oleobj_.InvokeTypes(1610743822, LCID, 1, (24, 0), (),)
def ShowBranches(self):
"""Get all of the branch names that match the filter"""
return self._oleobj_.InvokeTypes(1610743820, LCID, 1, (24, 0), (),)
def ShowLeafs(self, Flat=3DdefaultNamedOptArg):
"""Get all of the leaf names that match the filter"""
return self._oleobj_.InvokeTypes(1610743821, LCID, 1, (24, 0), ((12,
17),),Flat
)
_prop_map_get_ =3D {
"AccessRights": (1610743813, 2, (3, 0), (), "AccessRights", None),
"Count": (1610743817, 2, (3, 0), (), "Count", None),
"CurrentPosition": (1610743815, 2, (8, 0), (), "CurrentPosition",
None),
"DataType": (1610743811, 2, (2, 0), (), "DataType", None),
"Filter": (1610743809, 2, (8, 0), (), "Filter", None),
"Organization": (1610743808, 2, (3, 0), (), "Organization", None),
}
_prop_map_put_ =3D {
"AccessRights": ((1610743813, LCID, 4, 0),()),
"CurrentPosition": ((1610743815, LCID, 4, 0),()),
"DataType": ((1610743811, LCID, 4, 0),()),
"Filter": ((1610743809, LCID, 4, 0),()),
}
def __iter__(self):
"Return a Python iterator for this object"
ob =3D self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),())
return win32com.client.util.Iterator(ob)
def _NewEnum(self):
"Create an enumerator from this object"
return
win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13,
10),()),None)
def __getitem__(self, index):
"Allow this class to be accessed as a collection"
if not self.__dict__.has_key('_enum_'):
self.__dict__['_enum_'] =3D self._NewEnum()
return self._enum_.__getitem__(index)
#This class has Count() property - allow len(ob) to provide this
def __len__(self):
return self._ApplyTypes_(*(1610743817, 2, (3, 0), (), "Count",
None))
#This class has a __len__ - this is needed so 'if object:' always
returns TRUE.
def __nonzero__(self):
return True
class OPCItems(DispatchBaseClass):
"""Collection of OPC Item objects"""
CLSID =3D IID('{F8582D2C-88FB-11D0-B850-00C0F0104305}')
coclass_clsid =3D None
# Result is of type OPCItem
def AddItem(self, ItemID=3DdefaultNamedNotOptArg,
ClientHandle=3DdefaultNamedNotOptArg):
"""Adds an OPCItem object to the collection"""
ret =3D self._oleobj_.InvokeTypes(1610743819, LCID, 1, (9, 0), ((8,
1), (3, 1)),ItemID
, ClientHandle)
if ret is not None:
ret =3D Dispatch(ret, 'AddItem', '{F8582D2D-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
# Result is of type OPCItem
def GetOPCItem(self, ServerHandle=3DdefaultNamedNotOptArg):
"""Returns an OPCItem specified by server handle"""
ret =3D self._oleobj_.InvokeTypes(1610743818, LCID, 1, (9, 0), ((3,
1),),ServerHandle
)
if ret is not None:
ret =3D Dispatch(ret, 'GetOPCItem', '{F8582D2D-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
# Result is of type OPCItem
def Item(self, ItemSpecifier=3DdefaultNamedNotOptArg):
"""Returns an OPCItem by index (starts at 1)"""
ret =3D self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((12,
1),),ItemSpecifier
)
if ret is not None:
ret =3D Dispatch(ret, 'Item', '{F8582D2D-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
_prop_map_get_ =3D {
"Count": (1610743815, 2, (3, 0), (), "Count", None),
"DefaultAccessPath": (1610743811, 2, (8, 0), (),
"DefaultAccessPath", None),
"DefaultIsActive": (1610743813, 2, (11, 0), (), "DefaultIsActive",
None),
"DefaultRequestedDataType": (1610743809, 2, (2, 0), (),
"DefaultRequestedDataType", None),
# Method 'Parent' returns object of type 'OPCGroup'
"Parent": (1610743808, 2, (13, 0), (), "Parent",
'{F8582D30-88FB-11D0-B850-00C0F0104305}'),
}
_prop_map_put_ =3D {
"DefaultAccessPath": ((1610743811, LCID, 4, 0),()),
"DefaultIsActive": ((1610743813, LCID, 4, 0),()),
"DefaultRequestedDataType": ((1610743809, LCID, 4, 0),()),
}
# Default method for this class is 'Item'
def __call__(self, ItemSpecifier=3DdefaultNamedNotOptArg):
"""Returns an OPCItem by index (starts at 1)"""
ret =3D self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((12,
1),),ItemSpecifier
)
if ret is not None:
ret =3D Dispatch(ret, '__call__', '{F8582D2D-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=3D0)
return ret
# str(ob) and int(ob) will use __call__
def __unicode__(self, *args):
try:
return unicode(self.__call__(*args))
except pythoncom.com_error:
return repr(self)
def __str__(self, *args):
return str(self.__unicode__(*args))
def __int__(self, *args):
return int(self.__call__(*args))
def __iter__(self):
"Return a Python iterator for this object"
ob =3D self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),())
return win32com.client.util.Iterator(ob)
def _NewEnum(self):
"Create an enumerator from this object"
return
win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13,
10),()),'{F8582D2D-88FB-11D0-B850-00C0F0104305}')
def __getitem__(self, index):
"Allow this class to be accessed as a collection"
if not self.__dict__.has_key('_enum_'):
self.__dict__['_enum_'] =3D self._NewEnum()
return self._enum_.__getitem__(index)
#This class has Count() property - allow len(ob) to provide this
def __len__(self):
return self._ApplyTypes_(*(1610743815, 2, (3, 0), (), "Count",
None))
#This class has a __len__ - this is needed so 'if object:' always
returns TRUE.
def __nonzero__(self):
return True
from win32com.client import CoClassBaseClass
class OPCGroup(CoClassBaseClass): # A CoClass
# OPC Automation Group
CLSID =3D IID('{F8582D30-88FB-11D0-B850-00C0F0104305}')
coclass_sources =3D [
DIOPCGroupEvent,
]
default_source =3D DIOPCGroupEvent
coclass_interfaces =3D [
IOPCGroup,
]
default_interface =3D IOPCGroup
class OPCGroups(CoClassBaseClass): # A CoClass
# OPC Automation Groups Collection
CLSID =3D IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}')
coclass_sources =3D [
DIOPCGroupsEvent,
]
default_source =3D DIOPCGroupsEvent
coclass_interfaces =3D [
IOPCGroups,
]
default_interface =3D IOPCGroups
# This CoClass is known by the name 'Matrikon.OPC.Automation.1'
class OPCServer(CoClassBaseClass): # A CoClass
# OPC Automation Server
CLSID =3D IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}')
coclass_sources =3D [
DIOPCServerEvent,
]
default_source =3D DIOPCServerEvent
coclass_interfaces =3D [
IOPCAutoServer,
]
default_interface =3D IOPCAutoServer
bonjour Voici le fichier gégéré par makepy pour obtenir les méthodes afin d'utilier l'interface COM pour développer unclientOPC
********************
# -*- coding: mbcs -*- # Created by makepy.py version 0.4.95 # Bypythonversion 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] # From type library 'OPCDAAuto.dll' # On Wed May 09 08:26:18 2007 """MatrikonOPCAutomation 2.0""" makepy_version = '0.4.95' python_version = 0x20500f0
import win32com.client.CLSIDToClass, pythoncom import win32com.client.util from pywintypes import IID from win32com.clientimport Dispatch
# The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing, .Empty and .ArgNotFound defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty
class constants: OPCReadable =0x1 # from enum OPCAccess Rights OPCWritable =0x2 # from enum OPCAccess Rights OPCCache =0x1 # from enum OPCDataSo urce OPCDevice =0x2 # from enum OPCDataSo urce OPCBadRights =-1073479674 # from enum OPCErrors OPCBadType =-1073479676 # from enum OPCErrors OPCClamp =0x4000e # from enum OPCErrors OPCDuplicateName =-1073479668 # from enum OPCErrors OPCInuse =0x4000f # from enum OPCErrors OPCInvalidConfig =-1073479664 # from enum OPCErrors OPCInvalidFilter =-1073479671 # from enum OPCErrors OPCInvalidHandle =-1073479679 # from enum OPCErrors OPCInvalidItemID =-1073479672 # from enum OPCErrors OPCInvalidPID =-1073479165 # from enum OPCErrors OPCNotFound =-1073479663 # from enum OPCErrors OPCPublic =-1073479675 # from enum OPCErrors OPCRange =-1073479669 # from enum OPCErrors OPCUnknownItemID =-1073479673 # from enum OPCErrors OPCUnknownPath =-1073479670 # from enum OPCErrors OPCUnsupportedRate =0x4000d # from enum OPCErrors OPCFlat =0x2 # from enum OPCNamespaceTypes OPCHierarchical =0x1 # from enum OPCNamespaceTypes OPCQualityBad =0x0 # from enum OPCQuality OPCQualityGood =0xc0 # from enum OPCQuality OPCQualityMask =0xc0 # from enum OPCQuality OPCQualityUncertain =0x40 # from enum OPCQuality OPCLimitConst =0x3 # from enum OPCQualityLimits OPCLimitHigh =0x2 # from enum OPCQualityLimits OPCLimitLow =0x1 # from enum OPCQualityLimits OPCLimitMask =0x3 # from enum OPCQualityLimits OPCLimitOk =0x0 # from enum OPCQualityLimits OPCStatusCommFailure =0x18 # from enum OPCQualityStatus OPCStatusConfigError =0x4 # from enum OPCQualityStatus OPCStatusDeviceFailure =0xc # from enum OPCQualityStatus OPCStatusEGUExceeded =0x54 # from enum OPCQualityStatus OPCStatusLastKnown =0x14 # from enum OPCQualityStatus OPCStatusLastUsable =0x44 # from enum OPCQualityStatus OPCStatusLocalOverride =0xd8 # from enum OPCQualityStatus OPCStatusMask =0xfc # from enum OPCQualityStatus OPCStatusNotConnected =0x8 # from enum OPCQualityStatus OPCStatusOutOfService =0x1c # from enum OPCQualityStatus OPCStatusSensorCal =0x50 # from enum OPCQualityStatus OPCStatusSensorFailure =0x10 # from enum OPCQualityStatus OPCStatusSubNormal =0x58 # from enum OPCQualityStatus OPCDisconnected =0x6 # from enum OPCServer State OPCFailed =0x2 # from enum OPCServer State OPCNoconfig =0x3 # from enum OPCServer State OPCRunning =0x1 # from enum OPCServer State OPCSuspended =0x4 # from enum OPCServer State OPCTest =0x5 # from enum OPCServer State
class DIOPCGroupEvent: """OPCGroup Events""" CLSID = CLSID_Sink = IID('{F8582D2B-88FB-11D0-B850-00C0F01043 05}') coclass_clsid = IID('{F8582D30-88FB-11D0-B850-00C0F0104305}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 4 : "OnAsyncCancelComplete", 1 : "OnDataChange", 2 : "OnAsyncReadComplete", 3 : "OnAsyncWriteComplete", }
def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers # If you create handlers, they should have the following prototyp es: # def OnAsyncCancelComplete(self, CancelIDÞfaultNamedNotOptArg): # def OnDataChange(self, TransactionIDÞfaultNamedNotOptArg, NumItemsÞfaultNamedNotOptArg, ClientHandlesÞfaultNamedNotOptArg, ItemValuesÞfaultNamedNotOptArg # , QualitiesÞfaultNamedNotOptArg, TimeStampsÞfaultNamedNotOptArg): # def OnAsyncReadComplete(self, TransactionIDÞfaultNamedNotOptA rg, NumItemsÞfaultNamedNotOptArg, ClientHandlesÞfaultNamedNotOptArg, ItemValuesÞfaultNamedNotOptArg # , QualitiesÞfaultNamedNotOptArg, TimeStampsÞfaultNamedNotOptArg, ErrorsÞfaultNamedNotOptArg): # def OnAsyncWriteComplete(self, TransactionIDÞfaultNamedNotOpt Arg, NumItemsÞfaultNamedNotOptArg, ClientHandlesÞfaultNamedNotOptArg, ErrorsÞfaultNamedNotOptArg):
class DIOPCGroupsEvent: """OPCGroups Event""" CLSID = CLSID_Sink = IID('{F8582D29-88FB-11D0-B850-00C0F01043 05}') coclass_clsid = IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 1 : "OnGlobalDataChange", }
def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers # If you create handlers, they should have the following prototyp es: # def OnGlobalDataChange(self, TransactionIDÞfaultNamedNotOptAr g, GroupHandleÞfaultNamedNotOptArg, NumItemsÞfaultNamedNotOptArg, ClientHandlesÞfaultNamedNotOptArg # , ItemValuesÞfaultNamedNotOptArg, QualitiesÞfaultNamedNotOptArg, TimeStampsÞfaultNamedNotOptArg):
class DIOPCServerEvent: """OPCServer Event""" CLSID = CLSID_Sink = IID('{F8582D26-88FB-11D0-B850-00C0F01043 05}') coclass_clsid = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 1 : "OnServerShutDown", }
def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers # If you create handlers, they should have the following prototyp es: # def OnServerShutDown(self, ReasonÞfaultNamedNotOptArg):
from win32com.clientimport DispatchBaseClass class IOPCAutoServer(DispatchBaseClass): """OPCServer Object""" CLSID = IID('{F8582D25-88FB-11D0-B850-00C0F0104305}') coclass_clsid = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}')
# Result is of type OPCBrowser def CreateBrowser(self): """Create a new OPCBrowser Object""" ret = self._oleobj_.InvokeTypes(1610743828, LCID, 1, (9 , 0), (),) if ret is not None: ret = Dispatch(ret, 'CreateBrowser', '{F8582D27 -88FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
def GetErrorString(self, ErrorCodeÞfaultNamedNotOptArg): """Convert an error code to a descriptive string""" # Result is a Unicode object - return as-is for this vers ion ofPython return self._oleobj_.InvokeTypes(1610743829, LCID, 1, (8, 0), ((3, 1),),ErrorCode )
def GetOPCServers(self, NodeÞfaultNamedOptArg): """Returns an array of Server names, optionally on anothe r node""" return self._ApplyTypes_(1610743825, 1, (12, 0), ((12, 17 ),), 'GetOPCServers', None,Node )
# Result is of type OPCGroup def Add(self, NameÞfaultNamedOptArg): """Adds an OPCGroup to the collection""" ret = self._oleobj_.InvokeTypes(1610743822, LCID, 1, (1 3, 0), ((12, 17),),Name ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, 'Add', '{F8582D30-88FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCGroup def ConnectPublicGroup(self, NameÞfaultNamedNotOptArg): """Adds an existing public OPCGroup to the collection""" ret = self._oleobj_.InvokeTypes(1610743826, LCID, 1, (1 3, 0), ((8, 1),),Name ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, 'ConnectPublicGroup', '{F85 82D30-88FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCGroup def GetOPCGroup(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCGroup specified by server handle or name """ ret = self._oleobj_.InvokeTypes(1610743823, LCID, 1, (1 3, 0), ((12, 1),),ItemSpecifier ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, 'GetOPCGroup', '{F8582D30-8 8FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCGroup def Item(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCGroup by index (starts at 1) or name""" ret = self._oleobj_.InvokeTypes(0, LCID, 1, (13, 0), (( 12, 1),),ItemSpecifier ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, 'Item', '{F8582D30-88FB-11D 0- B850-00C0F0104305}', UnicodeToString=0) return ret
def Remove(self, ItemSpecifierÞfaultNamedNotOptArg): """Removes an OPCGroup specified by server handle or name """ return self._oleobj_.InvokeTypes(1610743825, LCID, 1, (24 , 0), ((12, 1),),ItemSpecifier )
def RemoveAll(self): """Remove all groups and their items""" return self._oleobj_.InvokeTypes(1610743824, LCID, 1, (24 , 0), (),)
def RemovePublicGroup(self, ItemSpecifierÞfaultNamedNotOptArg ): """Removes a public OPCGroup specified by server handle o r name""" return self._oleobj_.InvokeTypes(1610743827, LCID, 1, (24 , 0), ((12, 1),),ItemSpecifier )
_prop_map_get_ = { "Count": (1610743819, 2, (3, 0), (), "Count", None), "DefaultGroupDeadband": (1610743813, 2, (4, 0), (), "DefaultGroupDeadband", None), "DefaultGroupIsActive": (1610743809, 2, (11, 0), (), "DefaultGroupIsActive", None), "DefaultGroupLocaleID": (1610743815, 2, (3, 0), (), "DefaultGroupLocaleID", None), "DefaultGroupTimeBias": (1610743817, 2, (3, 0), (), "DefaultGroupTimeBias", None), "DefaultGroupUpdateRate": (1610743811, 2, (3, 0), (), "DefaultGroupUpdateRate", None), # Method 'Parent' returns object of type 'IOPCAutoServer' "Parent": (1610743808, 2, (9, 0), (), "Parent", '{F8582D2 5-88FB-11D0- B850-00C0F0104305}'), } _prop_map_put_ = { "DefaultGroupDeadband": ((1610743813, LCID, 4, 0),()), "DefaultGroupIsActive": ((1610743809, LCID, 4, 0),()), "DefaultGroupLocaleID": ((1610743815, LCID, 4, 0),()), "DefaultGroupTimeBias": ((1610743817, LCID, 4, 0),()), "DefaultGroupUpdateRate": ((1610743811, LCID, 4, 0),()), } # Default method for this class is 'Item' def __call__(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCGroup by index (starts at 1) or name""" ret = self._oleobj_.InvokeTypes(0, LCID, 1, (13, 0), (( 12, 1),),ItemSpecifier ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, '__call__', '{F8582D30-88FB -11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(self.__call__(*args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) def __iter__(self): "Return aPythoniterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),'{F8582D30-88FB-11D0-B850-00C0F0104305}') def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) #This class has Count() property - allow len(ob) to provide this def __len__(self): return self._ApplyTypes_(*(1610743819, 2, (3, 0), (), "Co unt", None)) #This class has a __len__ - this is needed so 'if object:' always returns TRUE. def __nonzero__(self): return True
class OPCBrowser(DispatchBaseClass): """OPCBrowser""" CLSID = IID('{F8582D27-88FB-11D0-B850-00C0F0104305}') coclass_clsid = None
def GetAccessPaths(self, ItemIDÞfaultNamedNotOptArg): """Returns an array of Access Paths for an ItemID""" return self._ApplyTypes_(1610743827, 1, (12, 0), ((8, 1), ), 'GetAccessPaths', None,ItemID )
def GetItemID(self, LeafÞfaultNamedNotOptArg): """Converts a leaf name to an ItemID""" # Result is a Unicode object - return as-is for this vers ion ofPython return self._oleobj_.InvokeTypes(1610743826, LCID, 1, (8, 0), ((8, 1),),Leaf )
def Item(self, ItemSpecifierÞfaultNamedNotOptArg): # Result is a Unicode object - return as-is for this vers ion ofPython return self._oleobj_.InvokeTypes(1610743819, LCID, 1, (8, 0), ((12, 1),),ItemSpecifier )
def MoveDown(self, BranchÞfaultNamedNotOptArg): """Move down into this branch""" return self._oleobj_.InvokeTypes(1610743824, LCID, 1, (24 , 0), ((8, 1),),Branch )
def MoveTo(self, BranchesÞfaultNamedNotOptArg): """Move to this absolute position""" return self._oleobj_.InvokeTypes(1610743825, LCID, 1, (24 , 0), ((24584, 1),),Branches )
def MoveToRoot(self): """Move up to the top (root) of the tree""" return self._oleobj_.InvokeTypes(1610743823, LCID, 1, (24 , 0), (),)
def MoveUp(self): """Move up a level in the tree""" return self._oleobj_.InvokeTypes(1610743822, LCID, 1, (24 , 0), (),)
def ShowBranches(self): """Get all of the branch names that match the filter""" return self._oleobj_.InvokeTypes(1610743820, LCID, 1, (24 , 0), (),)
def ShowLeafs(self, FlatÞfaultNamedOptArg): """Get all of the leaf names that match the filter""" return self._oleobj_.InvokeTypes(1610743821, LCID, 1, (24 , 0), ((12, 17),),Flat )
_prop_map_get_ = { "AccessRights": (1610743813, 2, (3, 0), (), "AccessRights ", None), "Count": (1610743817, 2, (3, 0), (), "Count", None), "CurrentPosition": (1610743815, 2, (8, 0), (), "CurrentPo sition", None), "DataType": (1610743811, 2, (2, 0), (), "DataType", None), "Filter": (1610743809, 2, (8, 0), (), "Filter", None), "Organization": (1610743808, 2, (3, 0), (), "Organization ", None), } _prop_map_put_ = { "AccessRights": ((1610743813, LCID, 4, 0),()), "CurrentPosition": ((1610743815, LCID, 4, 0),()), "DataType": ((1610743811, LCID, 4, 0),()), "Filter": ((1610743809, LCID, 4, 0),()), } def __iter__(self): "Return aPythoniterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) #This class has Count() property - allow len(ob) to provide this def __len__(self): return self._ApplyTypes_(*(1610743817, 2, (3, 0), (), "Co unt", None)) #This class has a __len__ - this is needed so 'if object:' always returns TRUE. def __nonzero__(self): return True
class OPCItem(DispatchBaseClass): """OPCItem object""" CLSID = IID('{F8582D2D-88FB-11D0-B850-00C0F0104305}') coclass_clsid = None
# Result is of type OPCItem def AddItem(self, ItemIDÞfaultNamedNotOptArg, ClientHandleÞfaultNamedNotOptArg): """Adds an OPCItem object to the collection""" ret = self._oleobj_.InvokeTypes(1610743819, LCID, 1, (9 , 0), ((8, 1), (3, 1)),ItemID , ClientHandle) if ret is not None: ret = Dispatch(ret, 'AddItem', '{F8582D2D-88FB- 11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCItem def GetOPCItem(self, ServerHandleÞfaultNamedNotOptArg): """Returns an OPCItem specified by server handle""" ret = self._oleobj_.InvokeTypes(1610743818, LCID, 1, (9 , 0), ((3, 1),),ServerHandle ) if ret is not None: ret = Dispatch(ret, 'GetOPCItem', '{F8582D2D-88 FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCItem def Item(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCItem by index (starts at 1)""" ret = self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((1 2, 1),),ItemSpecifier ) if ret is not None: ret = Dispatch(ret, 'Item', '{F8582D2D-88FB-11D 0- B850-00C0F0104305}', UnicodeToString=0) return ret
_prop_map_get_ = { "Count": (1610743815, 2, (3, 0), (), "Count", None), "DefaultAccessPath": (1610743811, 2, (8, 0), (), "DefaultAccessPath", None), "DefaultIsActive": (1610743813, 2, (11, 0), (), "DefaultI sActive", None), "DefaultRequestedDataType": (1610743809, 2, (2, 0), (), "DefaultRequestedDataType", None), # Method 'Parent' returns object of type 'OPCGroup' "Parent": (1610743808, 2, (13, 0), (), "Parent", '{F8582D30-88FB-11D0-B850-00C0F0104305}'), } _prop_map_put_ = { "DefaultAccessPath": ((1610743811, LCID, 4, 0),()), "DefaultIsActive": ((1610743813, LCID, 4, 0),()), "DefaultRequestedDataType": ((1610743809, LCID, 4, 0),()), } # Default method for this class is 'Item' def __call__(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCItem by index (starts at 1)""" ret = self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((1 2, 1),),ItemSpecifier ) if ret is not None: ret = Dispatch(ret, '__call__', '{F8582D2D-88FB -11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(self.__call__(*args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) def __iter__(self): "Return aPythoniterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),'{F8582D2D-88FB-11D0-B850-00C0F0104305}') def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) #This class has Count() property - allow len(ob) to provide this def __len__(self): return self._ApplyTypes_(*(1610743815, 2, (3, 0), (), "Co unt", None)) #This class has a __len__ - this is needed so 'if object:' always returns TRUE. def __nonzero__(self): return True
from win32com.clientimport CoClassBaseClass class OPCGroup(CoClassBaseClass): # A CoClass #OPCAutomation Group CLSID = IID('{F8582D30-88FB-11D0-B850-00C0F0104305}') coclass_sources = [ DIOPCGroupEvent, ] default_source = DIOPCGroupEvent coclass_interfaces = [ IOPCGroup, ] default_interface = IOPCGroup
class OPCGroups(CoClassBaseClass): # A CoClass #OPCAutomation Groups Collection CLSID = IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}') coclass_sources = [ DIOPCGroupsEvent, ] default_source = DIOPCGroupsEvent coclass_interfaces = [ IOPCGroups, ] default_interface = IOPCGroups
# This CoClass is known by the name 'Matrikon.OPC.Automation.1' class OPCServer(CoClassBaseClass): # A CoClass #OPCAutomation Server CLSID = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}') coclass_sources = [ DIOPCServerEvent, ] default_source = DIOPCServerEvent coclass_interfaces = [ IOPCAutoServer, ] default_interface = IOPCAutoServer
bonjour
Voici le fichier gégéré par makepy pour obtenir les méthodes afin
d'utilier l'interface COM pour développer unclientOPC
********************
# -*- coding: mbcs -*-
# Created by makepy.py version 0.4.95
# Bypythonversion 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310
32 bit (Intel)]
# From type library 'OPCDAAuto.dll'
# On Wed May 09 08:26:18 2007
"""MatrikonOPCAutomation 2.0"""
makepy_version = '0.4.95'
python_version = 0x20500f0
import win32com.client.CLSIDToClass, pythoncom
import win32com.client.util
from pywintypes import IID
from win32com.clientimport Dispatch
# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing, .Empty and .ArgNotFound
defaultNamedOptArg=pythoncom.Empty
defaultNamedNotOptArg=pythoncom.Empty
defaultUnnamedArg=pythoncom.Empty
class constants:
OPCReadable =0x1 # from enum OPCAccess Rights
OPCWritable =0x2 # from enum OPCAccess Rights
OPCCache =0x1 # from enum OPCDataSo urce
OPCDevice =0x2 # from enum OPCDataSo urce
OPCBadRights =-1073479674 # from enum OPCErrors
OPCBadType =-1073479676 # from enum OPCErrors
OPCClamp =0x4000e # from enum OPCErrors
OPCDuplicateName =-1073479668 # from enum OPCErrors
OPCInuse =0x4000f # from enum OPCErrors
OPCInvalidConfig =-1073479664 # from enum OPCErrors
OPCInvalidFilter =-1073479671 # from enum OPCErrors
OPCInvalidHandle =-1073479679 # from enum OPCErrors
OPCInvalidItemID =-1073479672 # from enum OPCErrors
OPCInvalidPID =-1073479165 # from enum OPCErrors
OPCNotFound =-1073479663 # from enum OPCErrors
OPCPublic =-1073479675 # from enum OPCErrors
OPCRange =-1073479669 # from enum OPCErrors
OPCUnknownItemID =-1073479673 # from enum OPCErrors
OPCUnknownPath =-1073479670 # from enum OPCErrors
OPCUnsupportedRate =0x4000d # from enum OPCErrors
OPCFlat =0x2 # from enum
OPCNamespaceTypes
OPCHierarchical =0x1 # from enum
OPCNamespaceTypes
OPCQualityBad =0x0 # from enum OPCQuality
OPCQualityGood =0xc0 # from enum OPCQuality
OPCQualityMask =0xc0 # from enum OPCQuality
OPCQualityUncertain =0x40 # from enum OPCQuality
OPCLimitConst =0x3 # from enum
OPCQualityLimits
OPCLimitHigh =0x2 # from enum
OPCQualityLimits
OPCLimitLow =0x1 # from enum
OPCQualityLimits
OPCLimitMask =0x3 # from enum
OPCQualityLimits
OPCLimitOk =0x0 # from enum
OPCQualityLimits
OPCStatusCommFailure =0x18 # from enum
OPCQualityStatus
OPCStatusConfigError =0x4 # from enum
OPCQualityStatus
OPCStatusDeviceFailure =0xc # from enum
OPCQualityStatus
OPCStatusEGUExceeded =0x54 # from enum
OPCQualityStatus
OPCStatusLastKnown =0x14 # from enum
OPCQualityStatus
OPCStatusLastUsable =0x44 # from enum
OPCQualityStatus
OPCStatusLocalOverride =0xd8 # from enum
OPCQualityStatus
OPCStatusMask =0xfc # from enum
OPCQualityStatus
OPCStatusNotConnected =0x8 # from enum
OPCQualityStatus
OPCStatusOutOfService =0x1c # from enum
OPCQualityStatus
OPCStatusSensorCal =0x50 # from enum
OPCQualityStatus
OPCStatusSensorFailure =0x10 # from enum
OPCQualityStatus
OPCStatusSubNormal =0x58 # from enum
OPCQualityStatus
OPCDisconnected =0x6 # from enum OPCServer State
OPCFailed =0x2 # from enum OPCServer State
OPCNoconfig =0x3 # from enum OPCServer State
OPCRunning =0x1 # from enum OPCServer State
OPCSuspended =0x4 # from enum OPCServer State
OPCTest =0x5 # from enum OPCServer State
class DIOPCGroupEvent:
"""OPCGroup Events"""
CLSID = CLSID_Sink = IID('{F8582D2B-88FB-11D0-B850-00C0F01043 05}')
coclass_clsid = IID('{F8582D30-88FB-11D0-B850-00C0F0104305}')
_public_methods_ = [] # For COM Server support
_dispid_to_func_ = {
4 : "OnAsyncCancelComplete",
1 : "OnDataChange",
2 : "OnAsyncReadComplete",
3 : "OnAsyncWriteComplete",
}
def __init__(self, oobj = None):
if oobj is None:
self._olecp = None
else:
import win32com.server.util
from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r)
cp=cpc.FindConnectionPoint(self.CLSID_Sink)
cookie=cp.Advise(win32com.server.util.wrap(self,
usePolicy=EventHandlerPolicy))
self._olecp,self._olecp_cookie = cp,cookie
def __del__(self):
try:
self.close()
except pythoncom.com_error:
pass
def close(self):
if self._olecp is not None:
cp,cookie,self._olecp,self._olecp_cookie =
self._olecp,self._olecp_cookie,None,None
cp.Unadvise(cookie)
def _query_interface_(self, iid):
import win32com.server.util
if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers
# If you create handlers, they should have the following prototyp es:
# def OnAsyncCancelComplete(self, CancelID=defaultNamedNotOptArg):
# def OnDataChange(self, TransactionID=defaultNamedNotOptArg,
NumItems=defaultNamedNotOptArg, ClientHandles=defaultNamedNotOptArg,
ItemValues=defaultNamedNotOptArg
# , Qualities=defaultNamedNotOptArg,
TimeStamps=defaultNamedNotOptArg):
# def OnAsyncReadComplete(self, TransactionID=defaultNamedNotOptA rg,
NumItems=defaultNamedNotOptArg, ClientHandles=defaultNamedNotOptArg,
ItemValues=defaultNamedNotOptArg
# , Qualities=defaultNamedNotOptArg,
TimeStamps=defaultNamedNotOptArg, Errors=defaultNamedNotOptArg):
# def OnAsyncWriteComplete(self, TransactionID=defaultNamedNotOpt Arg,
NumItems=defaultNamedNotOptArg, ClientHandles=defaultNamedNotOptArg,
Errors=defaultNamedNotOptArg):
class DIOPCGroupsEvent:
"""OPCGroups Event"""
CLSID = CLSID_Sink = IID('{F8582D29-88FB-11D0-B850-00C0F01043 05}')
coclass_clsid = IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}')
_public_methods_ = [] # For COM Server support
_dispid_to_func_ = {
1 : "OnGlobalDataChange",
}
def __init__(self, oobj = None):
if oobj is None:
self._olecp = None
else:
import win32com.server.util
from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r)
cp=cpc.FindConnectionPoint(self.CLSID_Sink)
cookie=cp.Advise(win32com.server.util.wrap(self,
usePolicy=EventHandlerPolicy))
self._olecp,self._olecp_cookie = cp,cookie
def __del__(self):
try:
self.close()
except pythoncom.com_error:
pass
def close(self):
if self._olecp is not None:
cp,cookie,self._olecp,self._olecp_cookie =
self._olecp,self._olecp_cookie,None,None
cp.Unadvise(cookie)
def _query_interface_(self, iid):
import win32com.server.util
if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers
# If you create handlers, they should have the following prototyp es:
# def OnGlobalDataChange(self, TransactionID=defaultNamedNotOptAr g,
GroupHandle=defaultNamedNotOptArg, NumItems=defaultNamedNotOptArg,
ClientHandles=defaultNamedNotOptArg
# , ItemValues=defaultNamedNotOptArg,
Qualities=defaultNamedNotOptArg, TimeStamps=defaultNamedNotOptArg):
class DIOPCServerEvent:
"""OPCServer Event"""
CLSID = CLSID_Sink = IID('{F8582D26-88FB-11D0-B850-00C0F01043 05}')
coclass_clsid = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}')
_public_methods_ = [] # For COM Server support
_dispid_to_func_ = {
1 : "OnServerShutDown",
}
def __init__(self, oobj = None):
if oobj is None:
self._olecp = None
else:
import win32com.server.util
from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r)
cp=cpc.FindConnectionPoint(self.CLSID_Sink)
cookie=cp.Advise(win32com.server.util.wrap(self,
usePolicy=EventHandlerPolicy))
self._olecp,self._olecp_cookie = cp,cookie
def __del__(self):
try:
self.close()
except pythoncom.com_error:
pass
def close(self):
if self._olecp is not None:
cp,cookie,self._olecp,self._olecp_cookie =
self._olecp,self._olecp_cookie,None,None
cp.Unadvise(cookie)
def _query_interface_(self, iid):
import win32com.server.util
if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers
# If you create handlers, they should have the following prototyp es:
# def OnServerShutDown(self, Reason=defaultNamedNotOptArg):
from win32com.clientimport DispatchBaseClass
class IOPCAutoServer(DispatchBaseClass):
"""OPCServer Object"""
CLSID = IID('{F8582D25-88FB-11D0-B850-00C0F0104305}')
coclass_clsid = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}')
# Result is of type OPCBrowser
def CreateBrowser(self):
"""Create a new OPCBrowser Object"""
ret = self._oleobj_.InvokeTypes(1610743828, LCID, 1, (9 , 0), (),)
if ret is not None:
ret = Dispatch(ret, 'CreateBrowser', '{F8582D27 -88FB-11D0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
def GetErrorString(self, ErrorCode=defaultNamedNotOptArg):
"""Convert an error code to a descriptive string"""
# Result is a Unicode object - return as-is for this vers ion ofPython
return self._oleobj_.InvokeTypes(1610743829, LCID, 1, (8, 0), ((3,
1),),ErrorCode
)
def GetOPCServers(self, Node=defaultNamedOptArg):
"""Returns an array of Server names, optionally on anothe r node"""
return self._ApplyTypes_(1610743825, 1, (12, 0), ((12, 17 ),),
'GetOPCServers', None,Node
)
# Result is of type OPCGroup
def Add(self, Name=defaultNamedOptArg):
"""Adds an OPCGroup to the collection"""
ret = self._oleobj_.InvokeTypes(1610743822, LCID, 1, (1 3, 0), ((12,
17),),Name
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret = ret.QueryInterface(pythoncom.IID_ IDispatch)
except pythoncom.error:
return ret
ret = Dispatch(ret, 'Add', '{F8582D30-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
# Result is of type OPCGroup
def ConnectPublicGroup(self, Name=defaultNamedNotOptArg):
"""Adds an existing public OPCGroup to the collection"""
ret = self._oleobj_.InvokeTypes(1610743826, LCID, 1, (1 3, 0), ((8,
1),),Name
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret = ret.QueryInterface(pythoncom.IID_ IDispatch)
except pythoncom.error:
return ret
ret = Dispatch(ret, 'ConnectPublicGroup', '{F85 82D30-88FB-11D0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
# Result is of type OPCGroup
def GetOPCGroup(self, ItemSpecifier=defaultNamedNotOptArg):
"""Returns an OPCGroup specified by server handle or name """
ret = self._oleobj_.InvokeTypes(1610743823, LCID, 1, (1 3, 0), ((12,
1),),ItemSpecifier
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret = ret.QueryInterface(pythoncom.IID_ IDispatch)
except pythoncom.error:
return ret
ret = Dispatch(ret, 'GetOPCGroup', '{F8582D30-8 8FB-11D0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
# Result is of type OPCGroup
def Item(self, ItemSpecifier=defaultNamedNotOptArg):
"""Returns an OPCGroup by index (starts at 1) or name"""
ret = self._oleobj_.InvokeTypes(0, LCID, 1, (13, 0), (( 12,
1),),ItemSpecifier
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret = ret.QueryInterface(pythoncom.IID_ IDispatch)
except pythoncom.error:
return ret
ret = Dispatch(ret, 'Item', '{F8582D30-88FB-11D 0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
def Remove(self, ItemSpecifier=defaultNamedNotOptArg):
"""Removes an OPCGroup specified by server handle or name """
return self._oleobj_.InvokeTypes(1610743825, LCID, 1, (24 , 0), ((12,
1),),ItemSpecifier
)
def RemoveAll(self):
"""Remove all groups and their items"""
return self._oleobj_.InvokeTypes(1610743824, LCID, 1, (24 , 0), (),)
def RemovePublicGroup(self, ItemSpecifier=defaultNamedNotOptArg ):
"""Removes a public OPCGroup specified by server handle o r name"""
return self._oleobj_.InvokeTypes(1610743827, LCID, 1, (24 , 0), ((12,
1),),ItemSpecifier
)
_prop_map_get_ = {
"Count": (1610743819, 2, (3, 0), (), "Count", None),
"DefaultGroupDeadband": (1610743813, 2, (4, 0), (),
"DefaultGroupDeadband", None),
"DefaultGroupIsActive": (1610743809, 2, (11, 0), (),
"DefaultGroupIsActive", None),
"DefaultGroupLocaleID": (1610743815, 2, (3, 0), (),
"DefaultGroupLocaleID", None),
"DefaultGroupTimeBias": (1610743817, 2, (3, 0), (),
"DefaultGroupTimeBias", None),
"DefaultGroupUpdateRate": (1610743811, 2, (3, 0), (),
"DefaultGroupUpdateRate", None),
# Method 'Parent' returns object of type 'IOPCAutoServer'
"Parent": (1610743808, 2, (9, 0), (), "Parent", '{F8582D2 5-88FB-11D0-
B850-00C0F0104305}'),
}
_prop_map_put_ = {
"DefaultGroupDeadband": ((1610743813, LCID, 4, 0),()),
"DefaultGroupIsActive": ((1610743809, LCID, 4, 0),()),
"DefaultGroupLocaleID": ((1610743815, LCID, 4, 0),()),
"DefaultGroupTimeBias": ((1610743817, LCID, 4, 0),()),
"DefaultGroupUpdateRate": ((1610743811, LCID, 4, 0),()),
}
# Default method for this class is 'Item'
def __call__(self, ItemSpecifier=defaultNamedNotOptArg):
"""Returns an OPCGroup by index (starts at 1) or name"""
ret = self._oleobj_.InvokeTypes(0, LCID, 1, (13, 0), (( 12,
1),),ItemSpecifier
)
if ret is not None:
# See if this IUnknown is really an IDispatch
try:
ret = ret.QueryInterface(pythoncom.IID_ IDispatch)
except pythoncom.error:
return ret
ret = Dispatch(ret, '__call__', '{F8582D30-88FB -11D0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
# str(ob) and int(ob) will use __call__
def __unicode__(self, *args):
try:
return unicode(self.__call__(*args))
except pythoncom.com_error:
return repr(self)
def __str__(self, *args):
return str(self.__unicode__(*args))
def __int__(self, *args):
return int(self.__call__(*args))
def __iter__(self):
"Return aPythoniterator for this object"
ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),())
return win32com.client.util.Iterator(ob)
def _NewEnum(self):
"Create an enumerator from this object"
return
win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13,
10),()),'{F8582D30-88FB-11D0-B850-00C0F0104305}')
def __getitem__(self, index):
"Allow this class to be accessed as a collection"
if not self.__dict__.has_key('_enum_'):
self.__dict__['_enum_'] = self._NewEnum()
return self._enum_.__getitem__(index)
#This class has Count() property - allow len(ob) to provide this
def __len__(self):
return self._ApplyTypes_(*(1610743819, 2, (3, 0), (), "Co unt",
None))
#This class has a __len__ - this is needed so 'if object:' always
returns TRUE.
def __nonzero__(self):
return True
class OPCBrowser(DispatchBaseClass):
"""OPCBrowser"""
CLSID = IID('{F8582D27-88FB-11D0-B850-00C0F0104305}')
coclass_clsid = None
def GetAccessPaths(self, ItemID=defaultNamedNotOptArg):
"""Returns an array of Access Paths for an ItemID"""
return self._ApplyTypes_(1610743827, 1, (12, 0), ((8, 1), ),
'GetAccessPaths', None,ItemID
)
def GetItemID(self, Leaf=defaultNamedNotOptArg):
"""Converts a leaf name to an ItemID"""
# Result is a Unicode object - return as-is for this vers ion ofPython
return self._oleobj_.InvokeTypes(1610743826, LCID, 1, (8, 0), ((8,
1),),Leaf
)
def Item(self, ItemSpecifier=defaultNamedNotOptArg):
# Result is a Unicode object - return as-is for this vers ion ofPython
return self._oleobj_.InvokeTypes(1610743819, LCID, 1, (8, 0), ((12,
1),),ItemSpecifier
)
def MoveDown(self, Branch=defaultNamedNotOptArg):
"""Move down into this branch"""
return self._oleobj_.InvokeTypes(1610743824, LCID, 1, (24 , 0), ((8,
1),),Branch
)
def MoveTo(self, Branches=defaultNamedNotOptArg):
"""Move to this absolute position"""
return self._oleobj_.InvokeTypes(1610743825, LCID, 1, (24 , 0),
((24584, 1),),Branches
)
def MoveToRoot(self):
"""Move up to the top (root) of the tree"""
return self._oleobj_.InvokeTypes(1610743823, LCID, 1, (24 , 0), (),)
def MoveUp(self):
"""Move up a level in the tree"""
return self._oleobj_.InvokeTypes(1610743822, LCID, 1, (24 , 0), (),)
def ShowBranches(self):
"""Get all of the branch names that match the filter"""
return self._oleobj_.InvokeTypes(1610743820, LCID, 1, (24 , 0), (),)
def ShowLeafs(self, Flat=defaultNamedOptArg):
"""Get all of the leaf names that match the filter"""
return self._oleobj_.InvokeTypes(1610743821, LCID, 1, (24 , 0), ((12,
17),),Flat
)
_prop_map_get_ = {
"AccessRights": (1610743813, 2, (3, 0), (), "AccessRights ", None),
"Count": (1610743817, 2, (3, 0), (), "Count", None),
"CurrentPosition": (1610743815, 2, (8, 0), (), "CurrentPo sition",
None),
"DataType": (1610743811, 2, (2, 0), (), "DataType", None),
"Filter": (1610743809, 2, (8, 0), (), "Filter", None),
"Organization": (1610743808, 2, (3, 0), (), "Organization ", None),
}
_prop_map_put_ = {
"AccessRights": ((1610743813, LCID, 4, 0),()),
"CurrentPosition": ((1610743815, LCID, 4, 0),()),
"DataType": ((1610743811, LCID, 4, 0),()),
"Filter": ((1610743809, LCID, 4, 0),()),
}
def __iter__(self):
"Return aPythoniterator for this object"
ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),())
return win32com.client.util.Iterator(ob)
def _NewEnum(self):
"Create an enumerator from this object"
return
win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13,
10),()),None)
def __getitem__(self, index):
"Allow this class to be accessed as a collection"
if not self.__dict__.has_key('_enum_'):
self.__dict__['_enum_'] = self._NewEnum()
return self._enum_.__getitem__(index)
#This class has Count() property - allow len(ob) to provide this
def __len__(self):
return self._ApplyTypes_(*(1610743817, 2, (3, 0), (), "Co unt",
None))
#This class has a __len__ - this is needed so 'if object:' always
returns TRUE.
def __nonzero__(self):
return True
class OPCItem(DispatchBaseClass):
"""OPCItem object"""
CLSID = IID('{F8582D2D-88FB-11D0-B850-00C0F0104305}')
coclass_clsid = None
# Result is of type OPCItem
def AddItem(self, ItemID=defaultNamedNotOptArg,
ClientHandle=defaultNamedNotOptArg):
"""Adds an OPCItem object to the collection"""
ret = self._oleobj_.InvokeTypes(1610743819, LCID, 1, (9 , 0), ((8,
1), (3, 1)),ItemID
, ClientHandle)
if ret is not None:
ret = Dispatch(ret, 'AddItem', '{F8582D2D-88FB- 11D0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
# Result is of type OPCItem
def GetOPCItem(self, ServerHandle=defaultNamedNotOptArg):
"""Returns an OPCItem specified by server handle"""
ret = self._oleobj_.InvokeTypes(1610743818, LCID, 1, (9 , 0), ((3,
1),),ServerHandle
)
if ret is not None:
ret = Dispatch(ret, 'GetOPCItem', '{F8582D2D-88 FB-11D0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
# Result is of type OPCItem
def Item(self, ItemSpecifier=defaultNamedNotOptArg):
"""Returns an OPCItem by index (starts at 1)"""
ret = self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((1 2,
1),),ItemSpecifier
)
if ret is not None:
ret = Dispatch(ret, 'Item', '{F8582D2D-88FB-11D 0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
_prop_map_get_ = {
"Count": (1610743815, 2, (3, 0), (), "Count", None),
"DefaultAccessPath": (1610743811, 2, (8, 0), (),
"DefaultAccessPath", None),
"DefaultIsActive": (1610743813, 2, (11, 0), (), "DefaultI sActive",
None),
"DefaultRequestedDataType": (1610743809, 2, (2, 0), (),
"DefaultRequestedDataType", None),
# Method 'Parent' returns object of type 'OPCGroup'
"Parent": (1610743808, 2, (13, 0), (), "Parent",
'{F8582D30-88FB-11D0-B850-00C0F0104305}'),
}
_prop_map_put_ = {
"DefaultAccessPath": ((1610743811, LCID, 4, 0),()),
"DefaultIsActive": ((1610743813, LCID, 4, 0),()),
"DefaultRequestedDataType": ((1610743809, LCID, 4, 0),()),
}
# Default method for this class is 'Item'
def __call__(self, ItemSpecifier=defaultNamedNotOptArg):
"""Returns an OPCItem by index (starts at 1)"""
ret = self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((1 2,
1),),ItemSpecifier
)
if ret is not None:
ret = Dispatch(ret, '__call__', '{F8582D2D-88FB -11D0-
B850-00C0F0104305}', UnicodeToString=0)
return ret
# str(ob) and int(ob) will use __call__
def __unicode__(self, *args):
try:
return unicode(self.__call__(*args))
except pythoncom.com_error:
return repr(self)
def __str__(self, *args):
return str(self.__unicode__(*args))
def __int__(self, *args):
return int(self.__call__(*args))
def __iter__(self):
"Return aPythoniterator for this object"
ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),())
return win32com.client.util.Iterator(ob)
def _NewEnum(self):
"Create an enumerator from this object"
return
win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13,
10),()),'{F8582D2D-88FB-11D0-B850-00C0F0104305}')
def __getitem__(self, index):
"Allow this class to be accessed as a collection"
if not self.__dict__.has_key('_enum_'):
self.__dict__['_enum_'] = self._NewEnum()
return self._enum_.__getitem__(index)
#This class has Count() property - allow len(ob) to provide this
def __len__(self):
return self._ApplyTypes_(*(1610743815, 2, (3, 0), (), "Co unt",
None))
#This class has a __len__ - this is needed so 'if object:' always
returns TRUE.
def __nonzero__(self):
return True
from win32com.clientimport CoClassBaseClass
class OPCGroup(CoClassBaseClass): # A CoClass
#OPCAutomation Group
CLSID = IID('{F8582D30-88FB-11D0-B850-00C0F0104305}')
coclass_sources = [
DIOPCGroupEvent,
]
default_source = DIOPCGroupEvent
coclass_interfaces = [
IOPCGroup,
]
default_interface = IOPCGroup
class OPCGroups(CoClassBaseClass): # A CoClass
#OPCAutomation Groups Collection
CLSID = IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}')
coclass_sources = [
DIOPCGroupsEvent,
]
default_source = DIOPCGroupsEvent
coclass_interfaces = [
IOPCGroups,
]
default_interface = IOPCGroups
# This CoClass is known by the name 'Matrikon.OPC.Automation.1'
class OPCServer(CoClassBaseClass): # A CoClass
#OPCAutomation Server
CLSID = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}')
coclass_sources = [
DIOPCServerEvent,
]
default_source = DIOPCServerEvent
coclass_interfaces = [
IOPCAutoServer,
]
default_interface = IOPCAutoServer
bonjour Voici le fichier gégéré par makepy pour obtenir les méthodes afin d'utilier l'interface COM pour développer unclientOPC
********************
# -*- coding: mbcs -*- # Created by makepy.py version 0.4.95 # Bypythonversion 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] # From type library 'OPCDAAuto.dll' # On Wed May 09 08:26:18 2007 """MatrikonOPCAutomation 2.0""" makepy_version = '0.4.95' python_version = 0x20500f0
import win32com.client.CLSIDToClass, pythoncom import win32com.client.util from pywintypes import IID from win32com.clientimport Dispatch
# The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing, .Empty and .ArgNotFound defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty
class constants: OPCReadable =0x1 # from enum OPCAccess Rights OPCWritable =0x2 # from enum OPCAccess Rights OPCCache =0x1 # from enum OPCDataSo urce OPCDevice =0x2 # from enum OPCDataSo urce OPCBadRights =-1073479674 # from enum OPCErrors OPCBadType =-1073479676 # from enum OPCErrors OPCClamp =0x4000e # from enum OPCErrors OPCDuplicateName =-1073479668 # from enum OPCErrors OPCInuse =0x4000f # from enum OPCErrors OPCInvalidConfig =-1073479664 # from enum OPCErrors OPCInvalidFilter =-1073479671 # from enum OPCErrors OPCInvalidHandle =-1073479679 # from enum OPCErrors OPCInvalidItemID =-1073479672 # from enum OPCErrors OPCInvalidPID =-1073479165 # from enum OPCErrors OPCNotFound =-1073479663 # from enum OPCErrors OPCPublic =-1073479675 # from enum OPCErrors OPCRange =-1073479669 # from enum OPCErrors OPCUnknownItemID =-1073479673 # from enum OPCErrors OPCUnknownPath =-1073479670 # from enum OPCErrors OPCUnsupportedRate =0x4000d # from enum OPCErrors OPCFlat =0x2 # from enum OPCNamespaceTypes OPCHierarchical =0x1 # from enum OPCNamespaceTypes OPCQualityBad =0x0 # from enum OPCQuality OPCQualityGood =0xc0 # from enum OPCQuality OPCQualityMask =0xc0 # from enum OPCQuality OPCQualityUncertain =0x40 # from enum OPCQuality OPCLimitConst =0x3 # from enum OPCQualityLimits OPCLimitHigh =0x2 # from enum OPCQualityLimits OPCLimitLow =0x1 # from enum OPCQualityLimits OPCLimitMask =0x3 # from enum OPCQualityLimits OPCLimitOk =0x0 # from enum OPCQualityLimits OPCStatusCommFailure =0x18 # from enum OPCQualityStatus OPCStatusConfigError =0x4 # from enum OPCQualityStatus OPCStatusDeviceFailure =0xc # from enum OPCQualityStatus OPCStatusEGUExceeded =0x54 # from enum OPCQualityStatus OPCStatusLastKnown =0x14 # from enum OPCQualityStatus OPCStatusLastUsable =0x44 # from enum OPCQualityStatus OPCStatusLocalOverride =0xd8 # from enum OPCQualityStatus OPCStatusMask =0xfc # from enum OPCQualityStatus OPCStatusNotConnected =0x8 # from enum OPCQualityStatus OPCStatusOutOfService =0x1c # from enum OPCQualityStatus OPCStatusSensorCal =0x50 # from enum OPCQualityStatus OPCStatusSensorFailure =0x10 # from enum OPCQualityStatus OPCStatusSubNormal =0x58 # from enum OPCQualityStatus OPCDisconnected =0x6 # from enum OPCServer State OPCFailed =0x2 # from enum OPCServer State OPCNoconfig =0x3 # from enum OPCServer State OPCRunning =0x1 # from enum OPCServer State OPCSuspended =0x4 # from enum OPCServer State OPCTest =0x5 # from enum OPCServer State
class DIOPCGroupEvent: """OPCGroup Events""" CLSID = CLSID_Sink = IID('{F8582D2B-88FB-11D0-B850-00C0F01043 05}') coclass_clsid = IID('{F8582D30-88FB-11D0-B850-00C0F0104305}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 4 : "OnAsyncCancelComplete", 1 : "OnDataChange", 2 : "OnAsyncReadComplete", 3 : "OnAsyncWriteComplete", }
def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers # If you create handlers, they should have the following prototyp es: # def OnAsyncCancelComplete(self, CancelIDÞfaultNamedNotOptArg): # def OnDataChange(self, TransactionIDÞfaultNamedNotOptArg, NumItemsÞfaultNamedNotOptArg, ClientHandlesÞfaultNamedNotOptArg, ItemValuesÞfaultNamedNotOptArg # , QualitiesÞfaultNamedNotOptArg, TimeStampsÞfaultNamedNotOptArg): # def OnAsyncReadComplete(self, TransactionIDÞfaultNamedNotOptA rg, NumItemsÞfaultNamedNotOptArg, ClientHandlesÞfaultNamedNotOptArg, ItemValuesÞfaultNamedNotOptArg # , QualitiesÞfaultNamedNotOptArg, TimeStampsÞfaultNamedNotOptArg, ErrorsÞfaultNamedNotOptArg): # def OnAsyncWriteComplete(self, TransactionIDÞfaultNamedNotOpt Arg, NumItemsÞfaultNamedNotOptArg, ClientHandlesÞfaultNamedNotOptArg, ErrorsÞfaultNamedNotOptArg):
class DIOPCGroupsEvent: """OPCGroups Event""" CLSID = CLSID_Sink = IID('{F8582D29-88FB-11D0-B850-00C0F01043 05}') coclass_clsid = IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 1 : "OnGlobalDataChange", }
def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers # If you create handlers, they should have the following prototyp es: # def OnGlobalDataChange(self, TransactionIDÞfaultNamedNotOptAr g, GroupHandleÞfaultNamedNotOptArg, NumItemsÞfaultNamedNotOptArg, ClientHandlesÞfaultNamedNotOptArg # , ItemValuesÞfaultNamedNotOptArg, QualitiesÞfaultNamedNotOptArg, TimeStampsÞfaultNamedNotOptArg):
class DIOPCServerEvent: """OPCServer Event""" CLSID = CLSID_Sink = IID('{F8582D26-88FB-11D0-B850-00C0F01043 05}') coclass_clsid = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 1 : "OnServerShutDown", }
def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPo licy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContaine r) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util. wrap(self)
# Event Handlers # If you create handlers, they should have the following prototyp es: # def OnServerShutDown(self, ReasonÞfaultNamedNotOptArg):
from win32com.clientimport DispatchBaseClass class IOPCAutoServer(DispatchBaseClass): """OPCServer Object""" CLSID = IID('{F8582D25-88FB-11D0-B850-00C0F0104305}') coclass_clsid = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}')
# Result is of type OPCBrowser def CreateBrowser(self): """Create a new OPCBrowser Object""" ret = self._oleobj_.InvokeTypes(1610743828, LCID, 1, (9 , 0), (),) if ret is not None: ret = Dispatch(ret, 'CreateBrowser', '{F8582D27 -88FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
def GetErrorString(self, ErrorCodeÞfaultNamedNotOptArg): """Convert an error code to a descriptive string""" # Result is a Unicode object - return as-is for this vers ion ofPython return self._oleobj_.InvokeTypes(1610743829, LCID, 1, (8, 0), ((3, 1),),ErrorCode )
def GetOPCServers(self, NodeÞfaultNamedOptArg): """Returns an array of Server names, optionally on anothe r node""" return self._ApplyTypes_(1610743825, 1, (12, 0), ((12, 17 ),), 'GetOPCServers', None,Node )
# Result is of type OPCGroup def Add(self, NameÞfaultNamedOptArg): """Adds an OPCGroup to the collection""" ret = self._oleobj_.InvokeTypes(1610743822, LCID, 1, (1 3, 0), ((12, 17),),Name ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, 'Add', '{F8582D30-88FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCGroup def ConnectPublicGroup(self, NameÞfaultNamedNotOptArg): """Adds an existing public OPCGroup to the collection""" ret = self._oleobj_.InvokeTypes(1610743826, LCID, 1, (1 3, 0), ((8, 1),),Name ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, 'ConnectPublicGroup', '{F85 82D30-88FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCGroup def GetOPCGroup(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCGroup specified by server handle or name """ ret = self._oleobj_.InvokeTypes(1610743823, LCID, 1, (1 3, 0), ((12, 1),),ItemSpecifier ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, 'GetOPCGroup', '{F8582D30-8 8FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCGroup def Item(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCGroup by index (starts at 1) or name""" ret = self._oleobj_.InvokeTypes(0, LCID, 1, (13, 0), (( 12, 1),),ItemSpecifier ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, 'Item', '{F8582D30-88FB-11D 0- B850-00C0F0104305}', UnicodeToString=0) return ret
def Remove(self, ItemSpecifierÞfaultNamedNotOptArg): """Removes an OPCGroup specified by server handle or name """ return self._oleobj_.InvokeTypes(1610743825, LCID, 1, (24 , 0), ((12, 1),),ItemSpecifier )
def RemoveAll(self): """Remove all groups and their items""" return self._oleobj_.InvokeTypes(1610743824, LCID, 1, (24 , 0), (),)
def RemovePublicGroup(self, ItemSpecifierÞfaultNamedNotOptArg ): """Removes a public OPCGroup specified by server handle o r name""" return self._oleobj_.InvokeTypes(1610743827, LCID, 1, (24 , 0), ((12, 1),),ItemSpecifier )
_prop_map_get_ = { "Count": (1610743819, 2, (3, 0), (), "Count", None), "DefaultGroupDeadband": (1610743813, 2, (4, 0), (), "DefaultGroupDeadband", None), "DefaultGroupIsActive": (1610743809, 2, (11, 0), (), "DefaultGroupIsActive", None), "DefaultGroupLocaleID": (1610743815, 2, (3, 0), (), "DefaultGroupLocaleID", None), "DefaultGroupTimeBias": (1610743817, 2, (3, 0), (), "DefaultGroupTimeBias", None), "DefaultGroupUpdateRate": (1610743811, 2, (3, 0), (), "DefaultGroupUpdateRate", None), # Method 'Parent' returns object of type 'IOPCAutoServer' "Parent": (1610743808, 2, (9, 0), (), "Parent", '{F8582D2 5-88FB-11D0- B850-00C0F0104305}'), } _prop_map_put_ = { "DefaultGroupDeadband": ((1610743813, LCID, 4, 0),()), "DefaultGroupIsActive": ((1610743809, LCID, 4, 0),()), "DefaultGroupLocaleID": ((1610743815, LCID, 4, 0),()), "DefaultGroupTimeBias": ((1610743817, LCID, 4, 0),()), "DefaultGroupUpdateRate": ((1610743811, LCID, 4, 0),()), } # Default method for this class is 'Item' def __call__(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCGroup by index (starts at 1) or name""" ret = self._oleobj_.InvokeTypes(0, LCID, 1, (13, 0), (( 12, 1),),ItemSpecifier ) if ret is not None: # See if this IUnknown is really an IDispatch try: ret = ret.QueryInterface(pythoncom.IID_ IDispatch) except pythoncom.error: return ret ret = Dispatch(ret, '__call__', '{F8582D30-88FB -11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(self.__call__(*args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) def __iter__(self): "Return aPythoniterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),'{F8582D30-88FB-11D0-B850-00C0F0104305}') def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) #This class has Count() property - allow len(ob) to provide this def __len__(self): return self._ApplyTypes_(*(1610743819, 2, (3, 0), (), "Co unt", None)) #This class has a __len__ - this is needed so 'if object:' always returns TRUE. def __nonzero__(self): return True
class OPCBrowser(DispatchBaseClass): """OPCBrowser""" CLSID = IID('{F8582D27-88FB-11D0-B850-00C0F0104305}') coclass_clsid = None
def GetAccessPaths(self, ItemIDÞfaultNamedNotOptArg): """Returns an array of Access Paths for an ItemID""" return self._ApplyTypes_(1610743827, 1, (12, 0), ((8, 1), ), 'GetAccessPaths', None,ItemID )
def GetItemID(self, LeafÞfaultNamedNotOptArg): """Converts a leaf name to an ItemID""" # Result is a Unicode object - return as-is for this vers ion ofPython return self._oleobj_.InvokeTypes(1610743826, LCID, 1, (8, 0), ((8, 1),),Leaf )
def Item(self, ItemSpecifierÞfaultNamedNotOptArg): # Result is a Unicode object - return as-is for this vers ion ofPython return self._oleobj_.InvokeTypes(1610743819, LCID, 1, (8, 0), ((12, 1),),ItemSpecifier )
def MoveDown(self, BranchÞfaultNamedNotOptArg): """Move down into this branch""" return self._oleobj_.InvokeTypes(1610743824, LCID, 1, (24 , 0), ((8, 1),),Branch )
def MoveTo(self, BranchesÞfaultNamedNotOptArg): """Move to this absolute position""" return self._oleobj_.InvokeTypes(1610743825, LCID, 1, (24 , 0), ((24584, 1),),Branches )
def MoveToRoot(self): """Move up to the top (root) of the tree""" return self._oleobj_.InvokeTypes(1610743823, LCID, 1, (24 , 0), (),)
def MoveUp(self): """Move up a level in the tree""" return self._oleobj_.InvokeTypes(1610743822, LCID, 1, (24 , 0), (),)
def ShowBranches(self): """Get all of the branch names that match the filter""" return self._oleobj_.InvokeTypes(1610743820, LCID, 1, (24 , 0), (),)
def ShowLeafs(self, FlatÞfaultNamedOptArg): """Get all of the leaf names that match the filter""" return self._oleobj_.InvokeTypes(1610743821, LCID, 1, (24 , 0), ((12, 17),),Flat )
_prop_map_get_ = { "AccessRights": (1610743813, 2, (3, 0), (), "AccessRights ", None), "Count": (1610743817, 2, (3, 0), (), "Count", None), "CurrentPosition": (1610743815, 2, (8, 0), (), "CurrentPo sition", None), "DataType": (1610743811, 2, (2, 0), (), "DataType", None), "Filter": (1610743809, 2, (8, 0), (), "Filter", None), "Organization": (1610743808, 2, (3, 0), (), "Organization ", None), } _prop_map_put_ = { "AccessRights": ((1610743813, LCID, 4, 0),()), "CurrentPosition": ((1610743815, LCID, 4, 0),()), "DataType": ((1610743811, LCID, 4, 0),()), "Filter": ((1610743809, LCID, 4, 0),()), } def __iter__(self): "Return aPythoniterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) #This class has Count() property - allow len(ob) to provide this def __len__(self): return self._ApplyTypes_(*(1610743817, 2, (3, 0), (), "Co unt", None)) #This class has a __len__ - this is needed so 'if object:' always returns TRUE. def __nonzero__(self): return True
class OPCItem(DispatchBaseClass): """OPCItem object""" CLSID = IID('{F8582D2D-88FB-11D0-B850-00C0F0104305}') coclass_clsid = None
# Result is of type OPCItem def AddItem(self, ItemIDÞfaultNamedNotOptArg, ClientHandleÞfaultNamedNotOptArg): """Adds an OPCItem object to the collection""" ret = self._oleobj_.InvokeTypes(1610743819, LCID, 1, (9 , 0), ((8, 1), (3, 1)),ItemID , ClientHandle) if ret is not None: ret = Dispatch(ret, 'AddItem', '{F8582D2D-88FB- 11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCItem def GetOPCItem(self, ServerHandleÞfaultNamedNotOptArg): """Returns an OPCItem specified by server handle""" ret = self._oleobj_.InvokeTypes(1610743818, LCID, 1, (9 , 0), ((3, 1),),ServerHandle ) if ret is not None: ret = Dispatch(ret, 'GetOPCItem', '{F8582D2D-88 FB-11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# Result is of type OPCItem def Item(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCItem by index (starts at 1)""" ret = self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((1 2, 1),),ItemSpecifier ) if ret is not None: ret = Dispatch(ret, 'Item', '{F8582D2D-88FB-11D 0- B850-00C0F0104305}', UnicodeToString=0) return ret
_prop_map_get_ = { "Count": (1610743815, 2, (3, 0), (), "Count", None), "DefaultAccessPath": (1610743811, 2, (8, 0), (), "DefaultAccessPath", None), "DefaultIsActive": (1610743813, 2, (11, 0), (), "DefaultI sActive", None), "DefaultRequestedDataType": (1610743809, 2, (2, 0), (), "DefaultRequestedDataType", None), # Method 'Parent' returns object of type 'OPCGroup' "Parent": (1610743808, 2, (13, 0), (), "Parent", '{F8582D30-88FB-11D0-B850-00C0F0104305}'), } _prop_map_put_ = { "DefaultAccessPath": ((1610743811, LCID, 4, 0),()), "DefaultIsActive": ((1610743813, LCID, 4, 0),()), "DefaultRequestedDataType": ((1610743809, LCID, 4, 0),()), } # Default method for this class is 'Item' def __call__(self, ItemSpecifierÞfaultNamedNotOptArg): """Returns an OPCItem by index (starts at 1)""" ret = self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((1 2, 1),),ItemSpecifier ) if ret is not None: ret = Dispatch(ret, '__call__', '{F8582D2D-88FB -11D0- B850-00C0F0104305}', UnicodeToString=0) return ret
# str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(self.__call__(*args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) def __iter__(self): "Return aPythoniterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),'{F8582D2D-88FB-11D0-B850-00C0F0104305}') def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) #This class has Count() property - allow len(ob) to provide this def __len__(self): return self._ApplyTypes_(*(1610743815, 2, (3, 0), (), "Co unt", None)) #This class has a __len__ - this is needed so 'if object:' always returns TRUE. def __nonzero__(self): return True
from win32com.clientimport CoClassBaseClass class OPCGroup(CoClassBaseClass): # A CoClass #OPCAutomation Group CLSID = IID('{F8582D30-88FB-11D0-B850-00C0F0104305}') coclass_sources = [ DIOPCGroupEvent, ] default_source = DIOPCGroupEvent coclass_interfaces = [ IOPCGroup, ] default_interface = IOPCGroup
class OPCGroups(CoClassBaseClass): # A CoClass #OPCAutomation Groups Collection CLSID = IID('{F8582D2F-88FB-11D0-B850-00C0F0104305}') coclass_sources = [ DIOPCGroupsEvent, ] default_source = DIOPCGroupsEvent coclass_interfaces = [ IOPCGroups, ] default_interface = IOPCGroups
# This CoClass is known by the name 'Matrikon.OPC.Automation.1' class OPCServer(CoClassBaseClass): # A CoClass #OPCAutomation Server CLSID = IID('{F8582D2E-88FB-11D0-B850-00C0F0104305}') coclass_sources = [ DIOPCServerEvent, ] default_source = DIOPCServerEvent coclass_interfaces = [ IOPCAutoServer, ] default_interface = IOPCAutoServer