From 1f220ec323ad29bedea8e403c493a2747a1a3720 Mon Sep 17 00:00:00 2001 From: Philipp Dijkstal Date: Wed, 9 Jul 2025 10:54:19 +0200 Subject: [PATCH] add Maloja end station spectrometer --- app/spectralanalysis.py | 45 ++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/app/spectralanalysis.py b/app/spectralanalysis.py index dbcfb9a..cdef543 100644 --- a/app/spectralanalysis.py +++ b/app/spectralanalysis.py @@ -15,10 +15,30 @@ channel_dict = { 'PSSS LB incl gasd': ['SARFE10-PSSS059-LB:SPECTRUM_Y', aramis_uncalibrated, aramis_calibrated], 'PMOS Maloja EEHG': ['SATOP21-PMOS127-2D:SPECTRUM_Y', eehg_spectrometer], 'PMOS Furka EEHG': ['SATOP31-PMOS132-2D:SPECTRUM_Y', eehg_spectrometer], + 'Maloja end station': ['SATES24-CAMS161-M1.projection_signal', athos_uncalibrated, athos_calibrated], } -names = ['PSSS', 'PMOS Maloja', 'PMOS Furka', 'PSSS LB', 'PSSS incl gasd', 'PSSS LB incl gasd', 'PMOS Maloja EEHG','PMOS Furka EEHG'] +names = ['PSSS', 'PMOS Maloja', 'PMOS Furka', 'PSSS LB', 'PSSS incl gasd', 'PSSS LB incl gasd', 'PMOS Maloja EEHG','PMOS Furka EEHG', 'Maloja end station'] -class SpectralAnalysis: + +class SpectralAnalysisBase: + def connect_x_axis(self): + try: + self.pv = PV(self.channel[0].replace('_Y','_X')) + except Exception as e: + print('could not read X axis PV') + print(e) + self.pv = None + + def read_spectrum_axis(self): + if self.pv: + return self.pv.value + else: + return None + + def getSpectrometerName(self): + return self.channel + +class SpectralAnalysis(SpectralAnalysisBase): def __init__(self): self.bs = BSCache(100000,receive_timeout=10000) # 100 second timeout, size for 10 second data taken self.bs.stop() @@ -42,13 +62,14 @@ class SpectralAnalysis: except ValueError: print('Cannot find requested channels in BS stream') self.hasBStream=False - self.pv = PV(self.channel[0].replace('_Y','_X')) + self.connect_x_axis() def terminate(self): print('Stopping BSStream Thread...') self.bs.stop() self.bs.pt.running.clear() # for some reason I have to - self.pv.disconnect() + if self.pv: + self.pv.disconnect() def flush(self): self.bs.flush() @@ -56,13 +77,7 @@ class SpectralAnalysis: def read(self): return next(self.bs) - def read_spectrum_axis(self): - return self.pv.value - - def getSpectrometerName(self): - return self.channel - -class SpectralAnalysis2: +class SpectralAnalysis2(SpectralAnalysisBase): def __init__(self): self.bs1 = BSCache(100000, receive_timeout=10000) self.bs2 = BSCache(100000, receive_timeout=10000) @@ -85,10 +100,7 @@ class SpectralAnalysis2: 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 + self.connect_x_axis() def flush(self): for _bs in self.bs1, self.bs2: @@ -102,5 +114,6 @@ class SpectralAnalysis2: for _bs in self.bs1, self.bs2: _bs.stop() _bs.pt.running.clear() # for some reason I have to - self.pv.disconnect() + if self.pv: + self.pv.disconnect()