reduce update rate on error
[uccdoor.git] / client-signal.py
1 # UCC Door Server - example synchronous client
2 # David Adam <[email protected]>
3 # Released under an MIT-style license; see COPYING for details.
4
5 import dbus
6 import gobject
7
8 def signal_handler(new_status, path):
9     door = path.split('/')[-1:][0]
10     # globals!
11     if door in doors:
12         print "Received new status %d from %s" % (new_status, door)
13
14 if __name__ == '__main__':
15     
16     from dbus.mainloop.glib import DBusGMainLoop
17     DBusGMainLoop(set_as_default=True)
18     # get on the bus
19     system_bus = dbus.SystemBus()
20     
21     doors = {'uccdoor': None, 'unisfadoor': None, 'chdoor': None, 'mrdoor': None, 'uccpir': None}
22     
23     # According to the D-BUS documentation, you shouldn't create an object just
24     # to listen to a signal, as this may cause server activation. However, your
25     # client might like to do more clever things with the object.
26     for door in doors.keys():
27         doors[door] = system_bus.get_object('au.asn.ucc.DoorServer', '/au/asn/ucc/doors/%s' % door)
28     
29     for door, remote_object in doors.items():
30         remote_object.connect_to_signal('status_changed', signal_handler,
31                                         dbus_interface='au.asn.ucc.DoorInterface',
32                                         path_keyword='path')
33     
34     # engage!
35     loop = gobject.MainLoop()
36     loop.run()

UCC git Repository :: git.ucc.asn.au