added slowadc to python

This commit is contained in:
Erik Frojdh
2020-09-10 12:16:25 +02:00
parent 34043c358f
commit a95d8f664a
4 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,25 @@
from .utils import element_if_equal
from .enums import dacIndex
class SlowAdcProxy:
"""
Proxy class to allow for more intuitive reading the slow ADCs
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
dac_index = dacIndex(int(dacIndex.SLOW_ADC0)+key)
return element_if_equal(self.det.getSlowADC(dac_index))
def __repr__(self):
rstr = ''
for i in range(7):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
rstr += ' '.join(f'{item} mV' for item in r)
else:
rstr += f'{i}: {r} mV\n'
return rstr.strip('\n')