Modified BSCAcquisition, so that the Cache is an argument of the function _acquire
This commit is contained in:
@ -90,13 +90,13 @@ class Dispersion:
|
||||
# adjustable
|
||||
self.adjSV = 'SATCB01-RSYS:SET-BEAM-PHASE'
|
||||
self.adjRB = 'SATCB01-RSYS:GET-BEAM-PHASE'
|
||||
self.adj = PVAdjustable(self.adjSV,pvname_readback = self.adjRB, accuracy = 0.1)
|
||||
self.adj = PVAdjustable(self.adjSV,pvname_readback = self.adjRB, accuracy = 0.1,ID = self.adjSV, name = "SATCB01-Linac")
|
||||
self.amp = 30 # the amplitude of the scan, which can be scaled
|
||||
# acquisition
|
||||
sensor1 = getBSChannels('SATBD02-DBPM.*:Y2$')
|
||||
sensor2 = getBSChannels('SATCB.*-RLLE-DSP:.*-VS$')
|
||||
self.sensor = sensor1+sensor2
|
||||
self.acq = [BSCAcquisition(".",pgroup, default_channels=self.sensor)]
|
||||
self.acq = [BSAcquisition(".",pgroup, default_channels=self.sensor)]
|
||||
# auxiliar data to be read one
|
||||
self.aux = self.getRFCalibrationChannels(sensor2,'SATCL01-MBND100:ENERGY-OP')
|
||||
|
||||
@ -115,7 +115,7 @@ class Dispersion:
|
||||
# adjustable
|
||||
self.adjSV = 'S30:SET-E-GAIN-OP'
|
||||
self.adjRB = 'S30:GET-E-GAIN-OP'
|
||||
self.adj = PVAdjustable(self.adjSV,pvname_readback = self.adjRB, accuracy = 0.1)
|
||||
self.adj = PVAdjustable(self.adjSV,pvname_readback = self.adjRB, accuracy = 0.1,ID = self.adjSV, name = "Linac3")
|
||||
self.amp = 20 # the amplitude of the scan, which can be scaled
|
||||
# acquisition
|
||||
sensor1 = getBSChannels('SAR.*DBPM.*:[XY]1$')
|
||||
@ -142,7 +142,7 @@ class Dispersion:
|
||||
# adjustable
|
||||
self.adjSV = 'S20:SET-E-GAIN-OP'
|
||||
self.adjRB = 'S20:GET-E-GAIN-OP'
|
||||
self.adj = PVAdjustable(self.adjSV,pvname_readback = self.adjRB, accuracy = 0.1)
|
||||
self.adj = PVAdjustable(self.adjSV,pvname_readback = self.adjRB, accuracy = 0.1,ID = self.adjSV, name = "Linac 2 and 3")
|
||||
# self.adj2SV = 'S30:SET-E-GAIN-OP'
|
||||
# self.adj2RB = 'S30:GET-E-GAIN-OP'
|
||||
# self.adj2 = PVAdjustable(self.adj2SV,pvname_readback = self.adj2RB, accuracy = 0.1)
|
||||
@ -159,7 +159,7 @@ class Dispersion:
|
||||
|
||||
def setup(self,scl = 1, Nsteps=5, Nsamples=5):
|
||||
val = self.adj.get_current_value(readback=False)
|
||||
dval = self.amp*scl
|
||||
# dval = self.amp*scl
|
||||
dval = 0 ######## edit this
|
||||
self.N = Nsteps
|
||||
self.Ns= Nsamples
|
||||
@ -180,10 +180,10 @@ class Dispersion:
|
||||
self.sc=self.scanner.ascan_list(self.adj,self.values,
|
||||
filename=self.branch,start_immediately = False,
|
||||
n_pulses=self.Ns,return_to_initial_values=True)
|
||||
# self.preaction() ######
|
||||
# self.preaction() ######
|
||||
self.sc.run()
|
||||
self.auxdata = getAux(self.aux)
|
||||
# self.postaction() #######
|
||||
# self.auxdata = getAux(self.aux)
|
||||
# self.postaction() #######
|
||||
|
||||
|
||||
def stop(self):
|
||||
|
@ -1,42 +1,40 @@
|
||||
import zmq
|
||||
|
||||
import h5py
|
||||
import numpy as np
|
||||
|
||||
|
||||
from bstrd import BSCache
|
||||
from slic.core.acquisition.acquisition import Acquisition
|
||||
from slic.core.acquisition import BSAcquisition, PVAcquisition
|
||||
|
||||
|
||||
# class using the BSQueue to avoid to reestablish a stream for each step.
|
||||
|
||||
class BSCAcquisition(Acquisition):
|
||||
|
||||
def release(self):
|
||||
if not self.queue == None:
|
||||
del self.queue
|
||||
self.queue = None
|
||||
|
||||
def _acquire(self, filename, channels=None, data_base_dir=None, scan_info=None, n_pulses=100, **kwargs):
|
||||
if not hasattr(self,'queue'):
|
||||
self.queue = getStream(channels)
|
||||
elif not self.queue:
|
||||
self.queue = getStream(channels)
|
||||
|
||||
self.queue.flush()
|
||||
print('Acquiring',n_pulses,'samples')
|
||||
data = []
|
||||
|
||||
queue =channels[0] # abusing interface since BSAcquisition assume a list of channels
|
||||
|
||||
# allocating space
|
||||
data={}
|
||||
chns = queue.channels
|
||||
for chn in chns:
|
||||
data[chn]={'data':np.zeros((n_pulses))}
|
||||
data['pulse_id']=np.zeros((n_pulses))
|
||||
|
||||
# clear the queue
|
||||
queue.flush()
|
||||
for i in range(n_pulses):
|
||||
data.append(self.queue.__next__())
|
||||
msg = queue.__next__() # pull data from cache
|
||||
for chn in chns:
|
||||
data[chn]['data'][i] = msg[chn]
|
||||
data['pulse_id'][i]=msg['pid']
|
||||
|
||||
# write out the data file
|
||||
hid = h5py.File(filename,'w')
|
||||
gid = hid.create_group(channels[0])
|
||||
for key in data[0].keys():
|
||||
gid.create_dataset(key, data = [rec[key].value for rec in data])
|
||||
hid.create_dataset('pulse_id', data = data['pulse_id'])
|
||||
for chn in chns:
|
||||
gid = hid.create_group(chn)
|
||||
for key in data[chn].keys():
|
||||
gid.create_dataset(key, data = data[chn][key])
|
||||
hid.close()
|
||||
|
||||
|
||||
def getStream(channels):
|
||||
print('Generating stream with channels:',channels)
|
||||
bs = BSCache(100000,10000) # 1 second time out, capazity for 100 second.
|
||||
bs.get_vars(channels)
|
||||
return bs
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user