Improved snapshot interface with saving snapshot files in the OP configuration. Added app support for stabilizing XTCAV. Added a BSacquisition based on BSCache
This commit is contained in:
42
ext/bscacquisition.py
Normal file
42
ext/bscacquisition.py
Normal file
@ -0,0 +1,42 @@
|
||||
import zmq
|
||||
import h5py
|
||||
|
||||
|
||||
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 = []
|
||||
for i in range(n_pulses):
|
||||
data.append(self.queue.__next__())
|
||||
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.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