def UpdateState(self): # faults are sticky if self.get_state() == Tg.DevState.FAULT: return self.get_state() MOD = self.modmux # setup some alias to render code more readable ch = self.Channel READY = MOD.st_ready ON = self.is_power_on() if MOD.comm_fail: self.STAT.COMM_ERROR(MOD.comm_fail) elif READY is None: s = BrukerALC_ModMux.stat_instance() self.STAT.set_stat2(s.state, s.status) elif not READY: self.STAT.NOT_READY() # READY guranteed after this line elif self.is_busy(): self.update_busy() elif not MOD.st_on: self.STAT.OFF(what="power supply") elif ON: code = MOD.Imeas_state[self.Channel] if code is None: if MOD.Iref[self.Channel] is None: self.STAT.ALARM("power on but setpoint unknown!") else: self.STAT.ON_CURRENT() else: status = "".join(error_str(code)) self.STAT.ALARM(status) elif ON is None: self.STAT.UNKNOWN("ready") elif not ON: self.STAT.OFF() # otherwise the programmar made a mistake else: self.STAT.SYNTH_FAULT("ON=%r,READY=%r" % (ON, READY))
def init_device(self, cl, name): PS.PowerSupply.init_device(self, cl, name) M = self.modmux = BrukerALC_ModMux.modmux_instance() if not self.Channel: desc = "mandatory property 'Channel' not set for device %r (%s)" % (name, type(name).__name__) raise Exception(desc) try: self.Channel = int(self.Channel) except ValueError: desc = "property 'Channel' of device %r must be an integer, not %r." % (name, self.Channel) raise Exception(desc) # informs modmux of channel hname M.name[self.Channel] = self.get_name().rpartition("/")[2].upper() # communicates Izero and Ilimit to modmux offset = self._get_attr_correction("CurrentSetpoint", dflt=DEFAULT_CORRECT)["Offset"] M.Izero[self.Channel] = int(offset) Ilimit = self._correct2("Current", self.RegulationPrecision, True, dflt=DEFAULT_CORRECT) M.Ilimit[self.Channel] = int(Ilimit) self.STAT.INITIALIZED()