From f00c46340f13597c58a0420a6cac0629e150c1bc Mon Sep 17 00:00:00 2001 From: elagil <x@figueroa.eu> Date: Tue, 6 Apr 2021 22:10:15 +0200 Subject: [PATCH] added sampler bit width adjustment --- controlPlatform/extensions/sampler.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/controlPlatform/extensions/sampler.py b/controlPlatform/extensions/sampler.py index 74c36e2..1b7f597 100644 --- a/controlPlatform/extensions/sampler.py +++ b/controlPlatform/extensions/sampler.py @@ -8,11 +8,30 @@ class Sampler(__Extension__): Extends a platform with ADC sampling capability """ - def __init__(self, platform, configHandler, dataHandler): + def __init__(self, platform, configHandler, dataHandler, bitWidth = 15): super().__init__(self, platform, configHandler, "Sampler") self.configHandler = configHandler self.dataHandler = dataHandler + self.adcBitFormatString = bitWidth + + @property + def adcBitFormatString(self): + return self._adcBitFormatString + + @adcBitFormatString.setter + def adcBitFormatString(self, new_bitWidth): + if new_bitWidth == 7: + self._adcBitFormatString = "int8" + + elif new_bitWidth == 8: + self._adcBitFormatString = "uint8" + + elif new_bitWidth == 16: + self._adcBitFormatString = "uint16" + + else: + self._adcBitFormatString = "int16" def configDuration(self, duration): """ @@ -43,7 +62,6 @@ class Sampler(__Extension__): Single shot sampling and storage on this platform """ # Do the sampling - self.adcBitFormatString = "int16" rawBlock = self.dataHandler.receive(leaveOpen=True, sections=[("uint32", 8), (self.adcBitFormatString, None)]) measurement = np.asarray(rawBlock) -- GitLab