keithley428 API confusing
Property getter returns something difference from what is set, which is confusing:
class keithley428:
@property
def gain(self):
""" Set/query Gain """
result = self.putget("U0X")
pos = result.index("R") + 1
result = int(result[pos : pos + 2])
return result, self._gainStringArray[result]
@gain.setter
def gain(self, value):
if value not in self._gainStringArray:
raise ValueError(f"Gain value {value} out of range (3-10)")
self.put(f"R{value}X")
Proposal: make two properties
class keithley428:
@property
def gain(self): # other whatever you want to call it
return self._gainStringArray[self.gain]
@property
def log10gain(self): # other whatever you want to call it
""" Set/query Gain """
result = self.putget("U0X")
pos = result.index("R") + 1
result = int(result[pos : pos + 2])
return result
@log10gain.setter
def log10gain(self, value): # other whatever you want to call it
if value not in self._gainStringArray:
raise ValueError(f"Gain value {value} out of range (3-10)")
self.put(f"R{value}X")
Additionally it is strange that the k428 has a different API from the other keithley's. I know the underlying implementation is different but that doesn't prevent us from having one API. For example gain in V/A and Imax in A exist no matter the keithley version. Maybe have a common abstract base class for all ammeters? Will be important down the line for quantification.
Edited by Wout De Nolf