def _pub(self, type, serial, pin, value): try: mswitch.publish(self.__class__, "sensor", type, str(serial), int(pin), int(value)) #print("Sensor: type(%s) serial(%s) pin(%s) value(%s)" % (type, serial, pin, value)) except Exception, e: print "!!! Signal-RX: exception: %s" % e
def main(debug=False): try: import phidgets_eventor.agents.edbus #@UnusedImport from phidgets_eventor.res import get_res_path icon_path=get_res_path() from phidgets_eventor.agents.phidgets_eventor_tray import TrayAgent _ta=TrayAgent(APP_NAME, icon_path, ICON_NAME, HELP_URL) from phidgets_eventor.agents.notifier import NotifierAgent #@Reimport _na=NotifierAgent(APP_NAME, ICON_NAME) _na.start() from phidgets_eventor.agents.clock import Clock #@Reimport clk=Clock(TIME_BASE) gobject.timeout_add(TIME_BASE, clk.tick) import phidgets_eventor.agents.receiver import phidgets_eventor.agents.debouncer mswitch.publish("__main__", "debug", debug) gtk.main() except KeyboardInterrupt: mswitch.quit() sys.exit(1) except Exception,e: notify(APP_NAME, "There was an error: %s" % e) mswitch.quit() sys.exit(1)
def tick(self, *_): """ Performs message dispatch """ tick_min=False tick_hour=False tick_day=False tick_second = (self.tick_count % self.ticks_second) == 0 self.tick_count += 1 if tick_second: self.sec_count += 1 tick_min=(self.sec_count % 60)==0 if tick_min: self.min_count += 1 tick_hour=(self.min_count % 60)==0 if tick_hour: self.hour_count += 1 tick_day=(self.hour_count % 24)==0 if tick_day: self.day_count += 1 #print "tick! ", tick_second mswitch.publish("__main__", "__tick__", self.ticks_second, tick_second, tick_min, tick_hour, tick_day, self.sec_count, self.min_count, self.hour_count, self.day_count) #(src_agent, agent_name, agent_id, # interest_map, responsesInterestList, # iq, isq, processor, low_priority_burst_size=5) quit=process_queues(False, self, "__main__", "__main__", self.interests, self.responsesInterests, self.iq, self.isq, message_processor ) ## for gobject... just in case return True
def tick(self, *_): """ Performs message dispatch """ tick_min = False tick_hour = False tick_day = False tick_second = (self.tick_count % self.ticks_second) == 0 self.tick_count += 1 if tick_second: self.sec_count += 1 tick_min = (self.sec_count % 60) == 0 if tick_min: self.min_count += 1 tick_hour = (self.min_count % 60) == 0 if tick_hour: self.hour_count += 1 tick_day = (self.hour_count % 24) == 0 if tick_day: self.day_count += 1 #print "tick! ", tick_second mswitch.publish("__main__", "__tick__", self.ticks_second, tick_second, tick_min, tick_hour, tick_day, self.sec_count, self.min_count, self.hour_count, self.day_count) #(src_agent, agent_name, agent_id, # interest_map, responsesInterestList, # iq, isq, processor, low_priority_burst_size=5) quit = process_queues(False, self, "__main__", "__main__", self.interests, self.responsesInterests, self.iq, self.isq, message_processor) ## for gobject... just in case return True
def pub(self, msgType, *pargs, **kargs): mswitch.publish("__main__", msgType, *pargs, **kargs)
def sMsg(self, info_json): #print "SignalHandlerEventor: %s" % p #print "SignalHandlerEventor: info_json: %s" % info_json mswitch.publish("__edbus__", "msg", info_json)
def exit(self, *p): mswitch.publish(self, "__quit__") gtk.main_quit()
def show(self, *_): mswitch.publish(self, "app_show")
def _pub(self, type, serial, pin, value): try: mswitch.publish(self.__class__, "sensor", type, str(serial), int(pin), int(value)) #print("Sensor: type(%s) serial(%s) pin(%s) value(%s)" % (type, serial, pin, value)) except Exception,e: print "!!! Signal-RX: exception: %s" % e