status 2024-12-03
This commit is contained in:
@ -11,6 +11,8 @@ class BSCAcquisition(Acquisition):
|
|||||||
|
|
||||||
def _acquire(self, filename, channels=None, data_base_dir=None, scan_info=None, n_pulses=100, **kwargs):
|
def _acquire(self, filename, channels=None, data_base_dir=None, scan_info=None, n_pulses=100, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
|
print('*** Reading out the cache ****')
|
||||||
queue =channels[0] # abusing interface since BSAcquisition assume a list of channels
|
queue =channels[0] # abusing interface since BSAcquisition assume a list of channels
|
||||||
|
|
||||||
# allocating space
|
# allocating space
|
||||||
@ -27,7 +29,7 @@ class BSCAcquisition(Acquisition):
|
|||||||
for chn in chns:
|
for chn in chns:
|
||||||
data[chn]['data'][i] = msg[chn]
|
data[chn]['data'][i] = msg[chn]
|
||||||
data['pulse_id'][i]=msg['pid']
|
data['pulse_id'][i]=msg['pid']
|
||||||
|
print(msg['pid'])
|
||||||
# write out the data file
|
# write out the data file
|
||||||
hid = h5py.File(filename,'w')
|
hid = h5py.File(filename,'w')
|
||||||
hid.create_dataset('pulse_id', data = data['pulse_id'])
|
hid.create_dataset('pulse_id', data = data['pulse_id'])
|
||||||
|
@ -12,3 +12,4 @@ from .slic import SlicScan
|
|||||||
from .slic import importSlicScan
|
from .slic import importSlicScan
|
||||||
from .doocs import doocsread
|
from .doocs import doocsread
|
||||||
from .doocs import doocswrite
|
from .doocs import doocswrite
|
||||||
|
|
||||||
|
@ -5,21 +5,24 @@ def loadDataset(filename):
|
|||||||
hid = h5py.File(filename, "r")
|
hid = h5py.File(filename, "r")
|
||||||
icount = 0
|
icount = 0
|
||||||
snap = loadSnap(hid)
|
snap = loadSnap(hid)
|
||||||
data =[]
|
data={}
|
||||||
act = []
|
act= {}
|
||||||
|
maxID = 0
|
||||||
for key in hid.keys():
|
for key in hid.keys():
|
||||||
if 'scan' in key:
|
if 'scan' in key:
|
||||||
ID = int(key.split('_')[1])
|
ID = int(key.split('_')[1])
|
||||||
|
if ID > maxID:
|
||||||
|
maxID = ID
|
||||||
print('Reading scan_%d' % ID)
|
print('Reading scan_%d' % ID)
|
||||||
data.append(loadData(hid,ID))
|
data[ID]=loadData(hid,ID)
|
||||||
act.append(loadActuator(hid,ID))
|
act[ID]=loadActuator(hid,ID)
|
||||||
icount +=1
|
icount +=1
|
||||||
hid.close()
|
hid.close()
|
||||||
if icount == 0:
|
if icount == 0:
|
||||||
return None, None, None
|
return None, None, None
|
||||||
elif icount == 1:
|
elif icount == 1:
|
||||||
return data[0], act[0],snap
|
return data[0], act[0],snap
|
||||||
return data,act,snap
|
return [data[j] for j in range(maxID+1)],[act[j] for j in range(maxID+1)],snap
|
||||||
|
|
||||||
def loadSnap(hid):
|
def loadSnap(hid):
|
||||||
snap={}
|
snap={}
|
||||||
|
@ -19,7 +19,7 @@ def getDatasetFileName(program='Unknown'):
|
|||||||
path = '%s/%s' % (path,day)
|
path = '%s/%s' % (path,day)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
datetag = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S_%f')
|
datetag = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||||
filename=('%s/%s_%s' % (path, program.replace(' ','_'), datetag))
|
filename=('%s/%s_%s' % (path, program.replace(' ','_'), datetag))
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
@ -73,10 +73,12 @@ def getSnapVal(pvs=None):
|
|||||||
if not pvs:
|
if not pvs:
|
||||||
return None
|
return None
|
||||||
ret={}
|
ret={}
|
||||||
val = [pv.value for pv in pvs]
|
val = [pv.get(timeout=0.1) for pv in pvs]
|
||||||
for i,pv in enumerate(pvs):
|
for i,pv in enumerate(pvs):
|
||||||
if not val[i] is None: # filter out None values
|
if not val[i] is None: # filter out None values
|
||||||
ret[pv.pvname]=float(val[i])
|
ret[pv.pvname]=float(val[i])
|
||||||
|
else:
|
||||||
|
print('Timeout:',pv.pvname)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def saveSnap(pvs={},label="", comment = "generated by application",reqfile = "SF_settings.yaml"):
|
def saveSnap(pvs={},label="", comment = "generated by application",reqfile = "SF_settings.yaml"):
|
||||||
|
Reference in New Issue
Block a user