Re: [python-win32] polling values from physical sensors

2005-07-07 Thread Ludovic Reenaers
Actually, I discovered that such sensor can be mounted on a serial or
parralel port. I guess It should exists a python interface for one of
these port. I'm still wondering about protocols but I assume could write
some.

-- 
Ludovic Reenaers
|if (getLife(ME)==Null):ME.Life.magnify()|


>> I'm currently trying to write service in python (prototyping),
>> this service will, ideally, poll physical sensors (such as temperature
> sensor,
>> light sensor,...) to get range of values. I want to write it on a Win32
> platform.
>> But, My problem is: I don't have any idea of the necessary hardware and,
>> never the less, I don't know which python/win32 module I will have to
>> use
>> in order to communicate with those sensor.
>
> You will need to answer this question without considering Python - eg, how
> would you talk to the hardware from *any* language.  I assume it depends
> on
> the specific sensors.  Once you can answer that question, we can help you
> apply the solution to Python - it is quite likely you would need to use
> the
> ctypes module for this, but you need to answer that generic question
> first.
>
> Mark
> ___
> Python-win32 mailing list
> Python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>


___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM server AddIn

2005-07-07 Thread Johannes Brunen
Hi Mark,

now I have made some progress! Using the win32traceutil worked well.

However the real essential part was the addition of the _typelib_guid_ 
variable
to the server class. Below, I have added the working example. Could you
confirm that this is the proper way of using the modules?

Two questions remains:
1.) The following code line seems to be unnecessary. The AddIn sever works 
without it as well. What is
the idea for this line? Do I need it?
universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 
2, ['ICADdyAddIn'])

2.) Debugging the server gives me now the following lines in the trace debug 
window, which I don't understand. Can you explain what their
meaning is?
Object with win32trace dispatcher created (object=None)
in ._QueryInterface_ with unsupported 
IID IMarshal ({0003---C000-0046})
in ._QueryInterface_ with unsupported 
IID IMarshal ({0003---C000-0046})
in ._QueryInterface_ with unsupported 
IID {001B---C000-0046} 
({001B---C000-0046})
in ._QueryInterface_ with unsupported 
IID IStdMarshalInfo ({0018---C000-0046})
in ._QueryInterface_ with unsupported 
IID IExternalConnection ({0019---C000-0046})
in ._QueryInterface_ with unsupported 
IID {4C1E39E1-E3E3-4296-AA86-EC938D896E92} 
({4C1E39E1-E3E3-4296-AA86-EC938D896E92})

Thank you very much for your supporting help and time!!

Best wishes

Johannes

##
## Addin1.py - A very simple CADdy++ AddIn server
##
from win32com import universal
from win32com.server.exception import COMException
from win32com.client import gencache
import pythoncom
import sys

#
# Support for COM objects we use.
#
gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, 
bForDemand=True) # CADdy.tlb

#
# The TLB defining the interfaces we implement
#
#universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 
1, 2, ['ICADdyAddIn'])

class AddIn1:
_com_interfaces_  = ['ICADdyAddIn']
_public_methods_  = []
_reg_clsctx_  = pythoncom.CLSCTX_INPROC_SERVER
_reg_clsid_   = "{AB6C657A-2C26-4BD0-ABB8-D777BC91F199}"
_reg_progid_  = "CADdyAddIn.PythonTest1"
_reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy"
_typelib_guid_= '{9C3BB401-114D-11D4-AC72-00105A4925FC}'

def __init__(self):
self.appHostApp = None
self.CLSID   = "{AB6C657A-2C26-4BD0-ABB8-D777BC91F199}"
self.ProgId  = "CADdyAddIn.PythonTest1"
self.Description = "CADdyAddIn.PythonTest1"

def Exit(self):
"""method Exit"""
self.appHostApp = None
def Init(self, theCADdy):
"""method Init"""
self.appHostApp = theCADdy
pUIManager = theCADdy.UIManager
pUIManager.Information("Init Python Test AddIn1...")

def RegisterAddin(klass):
pass

def UnregisterAddin(klass):
pass

if __name__ == '__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(AddIn1)
if "--unregister" in sys.argv:
UnregisterAddin(AddIn1)
else:
RegisterAddin(AddIn1)




___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM server AddIn

2005-07-07 Thread Mark Hammond
Glad you spotted that - if you feel there is something I could add to the
docs or examples to make that error less likely in the future, please let me
know.

> Two questions remains:
> 1.) The following code line seems to be unnecessary. The
> AddIn sever works
> without it as well. What is
> the idea for this line? Do I need it?
> universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4
> 925FC}', 0, 1,
> 2, ['ICADdyAddIn'])

You will (probably!) find that line is needed when makepy has not been run
over the module (ie, delete your win32com\gen_py directory and try again).
It is similar to a gencache.EnsureModule call.  Please try it and let me
know if that is not true :)

> 2.) Debugging the server gives me now the following lines in
> the trace debug
> window, which I don't understand. Can you explain what their
> meaning is?
> Object with win32trace dispatcher created (object=None)
> in ._QueryInterface_
> with unsupported
> IID IMarshal ({0003---C000-0046})

The short version: it is recording every unsupported QueryInterface call
made on your (Python)COM object.

Longer: It means that something, somewhere is querying your object to see
what interfaces it supports.  Things like IMarshall are queried by COM
itself, whereas others will be called by your host application.  The ones
with names as well as IIDs are known by win32com - the ones with the IID
repeated twice are not known.  In many cases, the caller is quite prepared
for the object to not support the interface, so things continue as normal -
ie, in most cases they can be ignored - but in other cases can give you good
clues about what the host application is expecting of you.

> Thank you very much for your supporting help and time!!

My pleasure - I like to see people get this stuff working :)

Mark

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM server AddIn

2005-07-07 Thread Johannes Brunen
Hi Mark,

"Mark Hammond" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
> Glad you spotted that - if you feel there is something I could add to the
> docs or examples to make that error less likely in the future, please let 
> me
> know.
For me a well written example with sufficient documentation works best.
Originally, I have had a bad time because our CADdy COM server has had a
intrinsically implementation error. After removing that I made good 
progress.
What is really important for me, is that the examples are correct and state 
of the art.
However, I'm unable to make a judgement for the given ones.

>> Two questions remains:
>> 1.) The following code line seems to be unnecessary. The
>> AddIn sever works
>> without it as well. What is
>> the idea for this line? Do I need it?
>> universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4
>> 925FC}', 0, 1,
>> 2, ['ICADdyAddIn'])
>
> You will (probably!) find that line is needed when makepy has not been run
> over the module (ie, delete your win32com\gen_py directory and try again).
> It is similar to a gencache.EnsureModule call.  Please try it and let me
> know if that is not true :)
I do not have any problem with removing the cache directory. But I always 
run the

gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, 
bForDemand=True) # CADdy.tlb

statement to ensure at runtime the existence of the typelibrary wrapper
modules. Actually, I won't run makepy.py at all.

Thank you very much

Johannes 



___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32