Added support for adaptive orbit feedback and spectral analysis
This commit is contained in:
51
app/spectralanalysis.py
Normal file
51
app/spectralanalysis.py
Normal 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
|
||||
|
||||
|
Reference in New Issue
Block a user