diff --git a/controlPlatform/extensions/sampler.py b/controlPlatform/extensions/sampler.py index 74c36e296dd7f70387d1d314ec189d03a6a28698..1b7f59771c9277a8c709205086edffd6ab019a85 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)