Hello, all,
I am so pleased to be on the mail list and hope to be able to
contribute to the project.
I have enjoyed the benefits of comtypes over other solutions very much
and had great success on XP + Python 2.5
I am currently working on Windows 7, Python 2.6.5, comtypes 0.6.2. (or
whatever the latest fetch from CVS was (thank you, Thomas for all your
hard work).
My current undertaking is wrapping the SensorAPI -
http://msdn.microsoft.com/en-us/library/dd318953%28VS.85%29.aspx which
does not have an associated typelib (yet?) and does not support
TypeInfo. I generated most of the components from the sibling
LocationAPI and have hand written the rest of the interface. I am
currenly implementing the SensorDevKitDiagnosticApp in wxPython.
The trickiest thing has been getting events to hookup and release
properly. I have complete initial testing and am quite happy with the
results.
I can also share my wx subclasses if anyone is interested. Here's the
pure python part:
## Forward Declaration
##
## MIDL_INTERFACE("5D8DCC91-4641-47E7-B7C3-B74F48A6C391")
## ISensorEvents : public IUnknown
## {
class ISensorEvents(IUnknown):
_iid_ = GUID("{5D8DCC91-4641-47E7-B7C3-B74F48A6C391}")
## MIDL_INTERFACE("5FA08F80-2657-458E-AF75-46F73FA6AC5C")
## ISensor : public IUnknown
## {
class ISensor(IUnknown):
_iid_ = GUID("{5FA08F80-2657-458E-AF75-46F73FA6AC5C}")
_methods_ = [...]
ISensorEvents._methods_ = [
## public:
## virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE
OnStateChanged(
## /* [in] */ __RPC__in_opt ISensor *pSensor,
## /* [in] */ SensorState state) = 0;
COMMETHOD([helpstring(u'method OnStateChanged')], HRESULT,
'OnStateChanged',
( ['in'], POINTER(ISensor), 'pSensor' ),
( ['in'], SensorStateEnum, 'state' )),
## virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE
OnDataUpdated(
## /* [in] */ __RPC__in_opt ISensor *pSensor,
## /* [in] */ __RPC__in_opt ISensorDataReport *pNewData) = 0;
COMMETHOD([helpstring(u'method OnDataUpdated')], HRESULT,
'OnDataUpdated',
( ['in'], POINTER(ISensor), 'pSensor' ),
( ['in'], POINTER(ISensorDataReport), 'pNewData' )),
## virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE OnEvent(
## /* [in] */ __RPC__in_opt ISensor *pSensor,
## /* [in] */ __RPC__in REFGUID eventID,
## /* [in] */ __RPC__in_opt IPortableDeviceValues
*pEventData) = 0;
COMMETHOD([helpstring(u'method OnEvent')], HRESULT, 'OnEvent',
( ['in'], POINTER(ISensor), 'pSensor' ),
( ['in'], REFGUID, 'eventID' ),
( ['in'], POINTER(IPortableDeviceValues), 'pEventData' )),
## virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE OnLeave(
## /* [in] */ __RPC__in REFSENSOR_ID ID) = 0;
COMMETHOD([helpstring(u'method OnLeave')], HRESULT, 'OnLeave',
( ['out'], POINTER(SENSOR_ID), 'pID' )),
## };
]
class SensorEventsBase(COMObject):
u'SensorEvents Class'
_com_interfaces_ = [ISensorEvents]
def OnStateChanged(self, this, *args):
print "OnStateChanged", args
def OnDataUpdated(self, this, *args):
print "OnDataUpdated", args
def OnEvent(self, this, *args):
print "OnEvent", args
def OnLeave(self, this, *args):
print "OnLeave", args
def SensorManager():
## hr = CoCreateInstance( __uuidof(SensorManager),
//CLSID_SensorManager,
## NULL,
## CLSCTX_INPROC_SERVER,
## __uuidof(ISensorManager), //IID_ISensorManager,
## (LPVOID*)&this->m_pSensorManager );
return CoCreateInstance(CLSID_SensorManager, ISensorManager,
CLSCTX_INPROC_SERVER)
sm = SensorManager()
sensCollPtr = sm.GetSensorsByType(SENSOR_TYPE_ACCELEROMETER_3D)
Accelerometer = sensCollPtr.GetAt(0)
Accelerometer.SetEventSink(SensorEventsBase()) # no need to keep a
reference to the sink
In order for the sink to be released properly, the sensor must be told
to stop delivering events:
nullEvtSink = POINTER(ISensorEvents)()
Accelerometer.SetEventSink(nullEvtSink)
I hope to generate some interest in this project and share my interface
files,
Barton
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
comtypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/comtypes-users