This commit is contained in:
gac-iss
2020-01-20 16:46:59 +01:00
parent 4f5fe44208
commit 3cf3479d3b
8 changed files with 211 additions and 77 deletions

View File

@@ -1,4 +1,77 @@
###################################################################################################
# Deployment specific global definitions - executed after startup.py
###################################################################################################
import ch.psi.pshell.epics.ChannelString as ChannelString
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
scienta.getDataArray().setMonitored(True)
# Handlig diagnostics
diag_channels = []
diag_channels.append(scienta.channelBegin)
diag_channels.append(scienta.channelEnd)
diag_channels.append(scienta.sliceBegin)
diag_channels.append(scienta.sliceEnd)
diag_channels.append(scienta.numSlices)
diag_channels.append(scienta.numChannels)
diag_channels.append(scienta.lowEnergy)
diag_channels.append(scienta.centerEnergy)
diag_channels.append(scienta.highEnergy)
diag_channels.append(AcquisitionMode)
diag_channels.append(EnergyMode)
diag_channels.append(LensMode)
diag_channels.append(DetectorMode)
diag_channels.append(PassEnergy)
diag_channels.append(ElementSet)
diag_channels.append(StepSize)
diag_channels.append(NumIterations)
diag_channels = sorted(diag_channels, key=lambda channel: channel.name)
def get_diag_name(diag):
return ch.psi.utils.Str.toTitleCase(diag.getName()).replace(" ", "").replace("Readback", "")
def print_diag():
for f in diag_channels:
print "%-25s %s" % (get_diag_name(f) , str(f.read()))
def create_diag_datasets(parent = None):
if parent is None:
parent = get_exec_pars().group
group = parent + "attrs/"
for f in diag_channels:
create_dataset(group+get_diag_name(f) , 's' if (type(f) is ch.psi.pshell.epics.ChannelString) else 'd')
def append_diag_datasets(parent = None):
if parent is None:
parent = get_exec_pars().group
group = parent + "attrs/"
for f in diag_channels:
try:
x = f.read()
if x is None:
x = '' if (type(f) is ch.psi.pshell.epics.ChannelString) else float('nan')
append_dataset(group+get_diag_name(f), x)
except:
log("Error sampling " + str(get_diag_name(f)) + ": " + str(sys.exc_info()[1]))
def after_readout(rec):
#if beam_ok:
if get_exec_pars().save:
#Saving only once the diag data
if rec.index == 0:
create_diag_datasets()
append_diag_datasets()
#else:
# rec.invalidate()

View File

@@ -1,20 +1,29 @@
if get_exec_pars().source == CommandSource.ui:
REGIONS = [[523.0, 527.0, 2.0], [527.0, 535.0, 4.0], [535.0, 558.0, 2.0]]
NAME = None
IOC_AUTO_SAVE = False
sensors=[i0, scienta.stats[0], scienta.getSpectrum()]
set_device_alias(scienta.getSpectrum(), "spectrum")
set_device_alias(scienta.getDataMatrix(), "image")
set_device_alias(scienta.stats[0], "sum")
sensors=[i0, scienta.stats[0], scienta.getSpectrum()] #), scienta.getDataMatrix()]
capture.write(1)
if IOC_AUTO_SAVE:
capture.write(1)
def trigger(position, scan):
scienta.start()
cienta.waitNewImage(-1)
scienta.waitNewImage(-1)
try:
rscan(energy, sensors, REGIONS, latency = 0.0, before_read=trigger)
rscan(energy, sensors, REGIONS, latency = 0.0, before_read=trigger, after_read=after_readout, name = NAME)
finally:
capture.write(0)
if IOC_AUTO_SAVE:
capture.write(0)
scienta.zeroSupplies()