diff --git a/script/keithley.py b/script/keithley.py index 70b5e7ff..dc46b000 100644 --- a/script/keithley.py +++ b/script/keithley.py @@ -131,21 +131,20 @@ class Keithley(object): - float: current limit in A. values between 2e-11 and 2e-3 set a fixed range. values greater than 0.02 select AUTO. - - str: state label of EPICS channel (cf. self.RANGE_STATES) - - int: state index of EPICS channel + - str: state label of EPICS channel (cf. self.RANGE_STATES). + must be one of the state labels, otherwise a ValueError is raised. + - int: state index of EPICS channel (0...10) """ if isinstance(value, float): try: - v = int(-math.log10(value / 2)) - 1 - v = max(v, 0) - v = min(v, len(self.RANGE_STATES)-1) + value = int(-math.log10(value / 2)) - 1 + value = max(value, 0) + value = min(value, len(self.RANGE_STATES)-1) except ValueError: - v = 0 - print "set_range({fv}) -> set_range({iv})".format(fv=value, iv=v) + value = 0 elif isinstance(value, str): value = self.RANGE_STATES.index(value) self.rangeCh.write(value) - KeiSample = Keithley("SampleKeithley", "X03DA-KEITHLEY-1:") KeiReference = Keithley("ReferenceKeithley", "X03DA-KEITHLEY-2:")