Added support for adaptive orbit feedback and spectral analysis

This commit is contained in:
2023-05-31 11:57:13 +02:00
parent b82b023f33
commit f22a17852c
8 changed files with 327 additions and 437 deletions

51
app/spectralanalysis.py Normal file
View File

@ -0,0 +1,51 @@
import time
import numpy as np
from bstrd import BSCache
from bstrd.bscache import make_channel_config, is_available
from epics import PV
class SpectralAnalysis:
"""
Wrapper class to bundle all daq/io needed for adaptive orbit feedback.
"""
def __init__(self):
self.bs = BSCache()
self.bs.stop()
self.channel = ''
self.channels = ['SARFE10-PSSS059:SPECTRUM_Y',
'SATOP21-PMOS127-2D:SPECTRUM_Y',
'SATOP31-PMOS132-2D:SPECTRUM_Y']
self.isConnected = False
def connect(self,ich):
if ich < 0 or ich >= len(self.channels):
return False
self.channel = self.channels[ich]
print('Connecting to BS-Channel:',self.channel)
self.bs.channels.clear()
self.bs.get_var(self.channel) # this starts the stream into the cache
self.pv = PV(self.channel.replace('_Y','_X'))
def terminate(self):
print('Stopping BSStream Thread...')
self.bs.stop()
self.bs.pt.running.clear() # for some reason I have to
def flush(self):
with self.bs.pt.queue.mutex:
self.bs.pt.queue.queue.clear()
def read(self):
data=self.bs.__next__()
return data['pid'],data[self.channel]
def readPV(self):
return self.pv.value
def getSpectrometerName(self):
return self.channel