From 964da0a16f9e3b763a21fd5eff0075dedb57f7ee Mon Sep 17 00:00:00 2001 From: Philipp Dijkstal Date: Fri, 24 Jan 2025 18:41:31 +0100 Subject: [PATCH] add new class for simultaneous acquisition of PSSS and gas detector values --- app/spectralanalysis.py | 50 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/app/spectralanalysis.py b/app/spectralanalysis.py index 5dc67bf..3b461a6 100644 --- a/app/spectralanalysis.py +++ b/app/spectralanalysis.py @@ -6,12 +6,14 @@ athos_calibrated = 'SATFE10-PEPG046:FCUP-INTENSITY-CAL' aramis_uncalibrated = 'SARFE10-PBIG050-EVR0:CALCI' aramis_calibrated = 'SARFE10-PBPG050:HAMP-INTENSITY-CAL' channel_dict = { - 'PSSS': ['SARFE10-PSSS059:SPECTRUM_Y', aramis_uncalibrated, aramis_calibrated], + 'PSSS': ['SARFE10-PSSS059:SPECTRUM_Y'], 'PMOS Maloja': ['SATOP21-PMOS127-2D:SPECTRUM_Y', athos_uncalibrated, athos_calibrated], 'PMOS Furka': ['SATOP31-PMOS132-2D:SPECTRUM_Y', athos_uncalibrated, athos_calibrated], - 'PSSS LB': ['SARFE10-PSSS059-LB:SPECTRUM_Y'], #, aramis_uncalibrated], #, aramis_calibrated], + 'PSSS LB': ['SARFE10-PSSS059-LB:SPECTRUM_Y'], + 'PSSS incl gasd': ['SARFE10-PSSS059:SPECTRUM_Y', aramis_uncalibrated, aramis_calibrated], + 'PSSS LB incl gasd': ['SARFE10-PSSS059-LB:SPECTRUM_Y', aramis_uncalibrated, aramis_calibrated], } -names = ['PSSS', 'PMOS Maloja', 'PMOS Furka', 'PSSS LB'] +names = ['PSSS', 'PMOS Maloja', 'PMOS Furka', 'PSSS LB', 'PSSS incl gasd', 'PSSS LB incl gasd'] class SpectralAnalysis: def __init__(self): @@ -57,3 +59,45 @@ class SpectralAnalysis: def getSpectrometerName(self): return self.channel +class SpectralAnalysis2: + def __init__(self): + self.bs1 = BSCache(100000, 10000) + self.bs2 = BSCache(100000, 10000) + self.bs1.stop() + self.bs2.stop() + self.hasBStream=False + + def connect_name(self, name): + channels = channel_dict[name] + self.bs1.channels.clear() + self.hasBStream = True + try: + self.bs1.get_vars(channels[:1]) # this starts the stream into the cache + except ValueError: + print('Cannot find requested channel %s in BS stream' % channels[0]) + self.hasBStream=False + if len(channels) > 1: + try: + self.bs2.get_vars(channels[1:]) # this starts the stream into the cache + except ValueError: + print('Cannot find requested channel %s in BS stream' % channels[1:]) + self.hasBStream=False + self.pv = PV(channels[0].replace('_Y','_X')) + + def read_spectrum_axis(self): + return self.pv.value + + def flush(self): + for _bs in self.bs1, self.bs2: + _bs.flush() + + def read(self): + return next(self.bs1), next(self.bs2) + + def terminate(self): + print('Stopping BSStream Thread...') + for _bs in self.bs1, self.bs2: + _bs.stop() + _bs.pt.running.clear() # for some reason I have to + self.pv.disconnect() +