@dbus.service.signal(dbus_interface="com.phidgets.Phidgets", signature="a{sv}") def Error(self, dic): """Generated when an error on a device is detected""" @dbus.service.signal(dbus_interface="com.phidgets.Phidgets", signature="sii") def Din(self, serial, pin, value): """Generated when the state of a digital input changes""" @dbus.service.signal(dbus_interface="com.phidgets.Phidgets", signature="sii") def Dout(self, serial, pin, value): """Generated when the state of a digital output changes""" @dbus.service.signal(dbus_interface="com.phidgets.Phidgets", signature="sii") def Ain(self, serial, pin, value): """Generated when the state of an analog input changes""" _handler=DBusAPIHandler() Bus.subscribe("%devices", _handler.Devices) Bus.subscribe("%device-attached", _handler.Attached) Bus.subscribe("%device-detached", _handler.Detached) Bus.subscribe("%device-error", _handler.Error) Bus.subscribe("%device-din", _handler.Din) Bus.subscribe("%device-dout", _handler.Dout) Bus.subscribe("%device-ain", _handler.Ain)
self._exitFlag=True def _hbark(self, *p): self._exitFlag=True def run(self): while not self._exitFlag: try: Bus.publish(None, "mswitch_pump") except Exception,e: Bus.publish(None, "log", "*** (MAIN) Comm exception: %s" % e) break _app=AppMainProc() Bus.subscribe("shutdown", _app._hshutdown) Bus.subscribe("%bark", _app._hbark) class AppAgent(object): APPNAME="phidgetsdbus" BASEPATH="~/.phidgetsdbus" def __init__(self): basepath=os.path.expanduser(os.path.expandvars(self.BASEPATH)) self.stdin_path="/dev/null" self.stdout_path="/dev/null" self.stderr_path=basepath+"/stderr" self.pidfile_path=basepath+"/pid" self.pidfile_timeout=2