def data_arr(self, payload, name, channels): try: self.logger.debug("received values '%s'" % str(payload)) bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError, e: self.logger.error("data receive error: %s" % str(e)) return
def status_cb(payload, logger, statusProxy): global statusFromGen2, lock try: bnch = Monitor.unpack_payload(payload) if bnch.path != 'mon.status': return with lock: logger.debug('status updated: %s' % (time.strftime("%H:%M:%S", time.localtime()))) statusFromGen2.update(bnch.value) except Monitor.MonitorError, e: logger.error('monitor error: %s' % (str(e)))
def arr_sessinfo(self, payload, name, channels): self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % ( str(payload), str(e))) return if bnch.path == ('mon.session.%s' % self.sessionName): info = bnch.value
def status_cb(self, payload, name, channels): try: bnch = Monitor.unpack_payload(payload) if bnch.path != 'mon.status': return with self.lock: ## print "status updated: %s" % (time.strftime("%H:%M:%S", ## time.localtime())) self.statusDict.update(bnch.value) self.logger.debug("Status updated: %s" % str(bnch.value)) except Monitor.MonitorError, e: print "monitor error: %s" % (str(e))
def anon_arr(self, payload, name, channels): self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % (str(payload), str(e))) return try: ast_id = bnch.value['ast_id'] return self.process_ast(ast_id, bnch.value) except KeyError: return self.process_task(bnch.path, bnch.value)
def arr_fitsinfo(self, payload, name, channels): self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % ( str(payload), str(e))) return # Find out the source of this information by examining the path match = regex_frame.match(bnch.path) if match: (frameid, subsys) = match.groups() try: # See if there is method to handle this information # in the 'fits' object method = getattr(self.fits, '%s_hdlr' % subsys) except AttributeError: self.logger.debug("No handler for '%s' subsystem" % subsys) return # check if this is a frame from an instrument that is # allocated match = regex_frameid.match(frameid) if match: inscode = match.group(1).upper() if not (inscode in self.inscodes): return try: # Get all the saved items under this path to report to # the handler vals = self.monitor.getitems_suffixOnly(bnch.path) method(frameid, vals) return except Exception, e: self.logger.error("Error processing '%s': %s" % ( str(bnch.path), str(e))) return
def anon_arr(self, payload, name, channels): self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % (str(payload), str(e))) return try: ast_id = bnch.value['ast_id'] # because gtk thread handling sucks gobject.idle_add(self.process_ast, ast_id, bnch.value) except KeyError: gobject.idle_add(self.process_task, bnch.path, bnch.value)
def arr_taskinfo(self, payload, name, channels): self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % ( str(payload), str(e))) return if not bnch.has_key('value'): # delete (vaccuum) packet return vals = bnch.value if vals.has_key('ast_id'): # SkMonitorPage update on some abstract or device dependent command self.gui.process_ast(vals['ast_id'], vals) elif vals.has_key('subpath'): # SkMonitorPage update on some subcommand self.gui.process_subcommand(bnch.path, vals['subpath'], vals) # possible SkMonitorPage update on some command status change else: self.gui.process_task(bnch.path, vals) if vals.has_key('task_code'): res = vals['task_code'] # Interpret task results: # task_code == 0 --> OK task_code != 0 --> ERROR if res == 0: ## self.gui.gui_do(self.gui.feedback_ok, ## tmtrans.queueName, tmtrans, res) pass else: # If there was a problem, let the gui know about it ## self.gui.gui_do(self.gui.feedback_error, ## tmtrans.queueName, tmtrans, str(res)) if res == 3: self.logger.info("Task cancelled (%s)" % bnch.path) self.gui.cancel_dialog(bnch.path)
def anon_arr(self, payload, names, channels): self.logger.debug("received values '%s'" % (str(payload))) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % (str(payload), str(e))) return info = bnch.value #self.logger.debug("info is: %s" % (str(info.keys()))) self.playSound(info['buffer'], filename=info['filename'], decode=True, format=info['format'], decompress=info['compressed'], priority=info['priority'])
def arr_status(self, payload, name, channels): """Called when new status information arrives at the periodic interval. """ #self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % ( str(payload), str(e))) return if bnch.path != 'mon.status': return statusInfo = bnch.value self.update_statusInfo(statusInfo)
def arr_loginfo(self, payload, name, channels): self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % ( str(payload), str(e))) return # Find out the log for this information by examining the path match = regex_log.match(bnch.path) if match: logname = match.group(1) # Remove any non-ascii characters that won't go into # a standard text buffer # this is now handled at the sending end....EJ #buf = bnch.value['msgstr'] #bnch.value['msgstr'] = buf.translate(None, self.deletechars) self.gui.update_loginfo(logname, bnch.value)
def anon_arr(self, payload, name, channels): try: bnch = Monitor.unpack_payload(payload) if self.monpath and (not bnch.path.startswith(self.monpath)): return except Monitor.MonitorError: return try: with StatIO.lock: #self.logger.debug('bnch val %s' %bnch.value) newvaldict.update((k, bnch.value[k]) for k in newvaldict.keys() if k in bnch.value) #self.logger.debug('update newvaldict ... %s' %newvaldict) except Exception, e: self.logger.error('status updating error %s' % e) return
def arr_obsinfo(self, payload, name, channels): self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) except Monitor.MonitorError: self.logger.error("malformed packet '%s': %s" % ( str(payload), str(e))) return vals = bnch.value if vals.has_key('obsinfo'): statusDict = bnch.value['obsinfo'] self.update_integgui(statusDict) elif vals.has_key('ready'): self.gui.update_statusMsg("TaskManager is ready.") self.playSound(common.sound.tm_ready, priority=22)
def status_cb(payload, logger, statusProxy, svConfig, statusValHistory, soundsink): global statusFromGen2, lock try: bnch = Monitor.unpack_payload(payload) if bnch.path != 'mon.status': return with lock: logger.debug('status updated: %s' % (time.strftime("%H:%M:%S", time.localtime()))) statusFromGen2.update(bnch.value) statusValHistory.update(svConfig, statusFromGen2) # statusValHistory.report() statusValHistory.reportAlarms(svConfig, soundsink) updateStatusForGUI(statusProxy, statusValHistory, logger) updateStatusForSTS(statusProxy, svConfig, statusValHistory, logger) except Monitor.MonitorError, e: logger.error('monitor error: %s' % (str(e)))
def status_cb(payload, logger, mainWindow, svConfig): global statusFromGen2, lock try: bnch = Monitor.unpack_payload(payload) if bnch.path != 'mon.status': return with lock: logger.debug('status updated: %s' % (time.strftime("%H:%M:%S", time.localtime()))) statusDict = bnch.value statusFromGen2.update(statusDict) logger.debug( "status updated: %d items time:%s" % (len(statusDict), time.strftime("%H:%M:%S", time.localtime()))) if mainWindow: updateAlarmWindow(mainWindow, svConfig, statusDict) except Monitor.MonitorError, e: logger.error('monitor error: %s' % (str(e)))
def anon_arr(self, payload, name, channels): #recvtime = time.time() try: bnch = Monitor.unpack_payload(payload) if self.monpath and (not bnch.path.startswith(self.monpath)): return try: # update status values as soon as they are changed self.stat_val.update((k,bnch.value[k]) for k in self.stat_val.keys() if k in bnch.value) self.coordinator.stat_dict=self.stat_val self.logger.debug('stat val %s' %self.stat_val) except Exception, e: self.logger.error('status updating error %s' %e) return except Monitor.MonitorError: return
def anon_arr(self, payload, name, channels): recvtime = time.time() self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) if self.monpath and (not bnch.path.startswith(self.monpath)): return except Monitor.MonitorError: return #print bnch with self.lock: if self.monpath: tree = bnch.value self.queue.put((self.monpath, tree, recvtime)) else: tree = self.monitor.getTree(bnch.path) self.queue.put((bnch.path, tree, recvtime))
def anon_arr(self, payload, name, channels): recvtime = time.time() self.logger.debug("received values '%s'" % str(payload)) try: bnch = Monitor.unpack_payload(payload) if self.monpath and (not bnch.path.startswith(self.monpath)): return except Monitor.MonitorError: return #print bnch with self.lock: if self.monpath: if not self.history: tree = bnch.value else: tree = self.monitor.getTree(self.monpath) self.queue.put((self.monpath, tree, recvtime)) elif self.watch_execs: match = regex_exec.match(bnch.path) #print match, bnch.path if match: path = match.group(1) tree = self.monitor.getTree(path) self.queue.put((path, tree, recvtime)) else: if not self.history: tree = bnch.value else: tree = self.monitor.getTree(bnch.path) self.queue.put((bnch.path, tree, recvtime))
def status_cb(payload, logger, out_f): """Receive a status update. - payload is the payload data received from the pub/sub system - out_f is an open descriptor to a file to write the information """ global status, lock try: bnch = Monitor.unpack_payload(payload) if bnch.path != 'mon.status': return with lock: statusDict = bnch.value statusDict['STS.TIME2'] = time.time() status.update(statusDict) logger.debug( "status updated: %d items time:%s" % (len(statusDict), time.strftime("%H:%M:%S", time.localtime()))) #logger.debug("status: %s" % (str(statusDict))) write_sts(statusDict, logger, out_f) except Monitor.MonitorError, e: logger.error("monitor error: %s" % (str(e)))