Mercurial > code > home > repos > light9
annotate light8/dmxclient.py @ 134:f2f73a2171e6
many adjustments to the loops and timing
many adjustments to the loops and timing
now sends the hardware updates only when clients change, but at least 1Hz
new option to adjust the rate of the loop that considers sending changes (if
the lights have changed)
author | drewp |
---|---|
date | Sat, 14 Jun 2003 14:59:09 +0000 |
parents | b75bfbcf5979 |
children | 2dfe2c0ba052 |
rev | line source |
---|---|
0 | 1 """ module for clients to use for easy talking to the dmx |
2 server. sending levels is now a simple call to | |
3 dmxclient.outputlevels(..) | |
4 | |
5 client id is formed from sys.argv[0] and the PID. """ | |
6 | |
7 import xmlrpclib,os,sys,socket,time | |
8 _dmx=None | |
9 | |
10 _id="%s-%s" % (sys.argv[0].replace('.py','').replace('./',''),os.getpid()) | |
11 | |
120
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
12 def outputlevels(levellist): |
0 | 13 """present a list of dmx channel levels, each scaled from |
14 0..1. list can be any length- it will apply to the first len() dmx | |
15 channels. | |
16 | |
17 if the server is not found, outputlevels will block for a | |
18 second.""" | |
19 | |
20 global _dmx,_id | |
21 | |
22 if _dmx is None: | |
120
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
23 _dmx=xmlrpclib.Server("http://localhost:8030") |
0 | 24 |
120
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
25 try: |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
26 _dmx.outputlevels(_id,levellist) |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
27 except socket.error,e: |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
28 print "dmx server error %r, waiting"%e |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
29 time.sleep(1) |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
30 except xmlrpclib.Fault,e: |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
31 print "outputlevels had xml fault: %s" % e |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
32 time.sleep(1) |
0 | 33 |