def read_attribute(self, attr, qual_fun=None, valfun=None): def read1(bend): aname = attr.get_name() if not bend.okay: return None try: aval = bend.read_attribute(attr.get_name()) return aval except Exception: self.log.error('read1 %s', aname, exc_info=1) return None # read_attribute begins here try: if time()<self.next_update_t: attr.set_quality(AQ_INVALID) return aname = attr.get_name() aval1 = read1(self.bend1) aval2 = read1(self.bend2) if aval1 is None or aval2 is None: attr.set_quality(AQ_INVALID) return quality = PS.combine_aq(aval1.quality, aval2.quality) timestamp = min(tv2time(aval1.time),tv2time(aval2.time)) if qual_fun is None: quality = self.distill_ne_quality(quality, aval1, aval2) else: quality = qual_fun(quality, aval1, aval2) if valfun is None: valfun = self.shiver if aval1.value is None or aval2.value is None: x = None else: x = valfun(aname, aval1.value, aval2.value) vdq = PS.VDQ(x, q=quality) setattr(self, '_a'+aname, vdq) vdq.set_attr(attr) # calculate and set write values (for writeable attributes) try: attr_rw = BrukerBend_PS_Class.attr_list[aname][0][2] if attr_rw in (Tg.WRITE, Tg.READ_WRITE): w = valfun(aname+'_W', aval1.w_value, aval2.w_value) if not w is None: attr.set_write_value(w) except Exception: self.log.warn('read_attribute write_value', exc_info=1) except Tg.DevFailed: self.delay_update() raise
av1 = self.bend1['WaveStatus'] av2 = self.bend2['WaveStatus'] except Tg.DevFailed, df: err = df[-1] attr.set_value_date_quality(err.desc, time(), AQ_ALARM) return except Exception, exc: attr.set_value_date_quality(str(exc).desc, time(), AQ_ALARM) return value = 'not updated' timestamp = min(tv2time(av1.time),tv2time(av2.time)) quality = PS.combine_aq(av1.quality, av2.quality) v1, seconds1 = strip_s(av1.value) v2, seconds2 = strip_s(av2.value) seconds = max(seconds1, seconds2) if v1==v2: value = v1 if seconds: value += ' %.2fs' % seconds else: value = v1 + ' / ' + v2 attr.set_value_date_quality(value, timestamp, quality) def read_WaveDuration(self, attr): self.read_attribute(attr)