This commit is contained in:
@@ -93,11 +93,14 @@ def dummy_trigger_scienta():
|
||||
"""
|
||||
Trigger detector to update the array sizes and calibration
|
||||
"""
|
||||
print "Dummy trigger... "
|
||||
iterations = scienta.getIterations()
|
||||
scienta.setIterations(1)
|
||||
try:
|
||||
trigger_scienta()
|
||||
finally:
|
||||
scienta.setIterations(iterations)
|
||||
print "Done"
|
||||
|
||||
|
||||
def clear_output():
|
||||
App.getInstance().mainFrame.clearScanDisplays()
|
||||
|
||||
@@ -18,7 +18,9 @@ print "REGIONS: ", REGIONS
|
||||
print "PASSES: ", PASSES
|
||||
|
||||
IOC_AUTO_SAVE = False
|
||||
DUMMY_TRIGGER = True
|
||||
DUMMY_TRIGGER = False
|
||||
SPLIT_PASSES = False
|
||||
|
||||
|
||||
set_device_alias(scienta.getSpectrum(), "spectrum")
|
||||
set_device_alias(scienta.getDataMatrix(), "image")
|
||||
@@ -29,6 +31,7 @@ sensors=[i0, scienta.stats[0], scienta.getSpectrum()] #), scienta.getDataMatrix(
|
||||
def before_read(position, scan):
|
||||
trigger_scienta()
|
||||
|
||||
clear_output()
|
||||
if DUMMY_TRIGGER:
|
||||
dummy_trigger_scienta()
|
||||
|
||||
@@ -37,7 +40,9 @@ if IOC_AUTO_SAVE:
|
||||
capture.write(1)
|
||||
|
||||
try:
|
||||
rscan(energy, sensors, REGIONS, latency = 0.0, passes=PASSES, split=True, before_read=before_read, after_read=after_readout, name = NAME)
|
||||
rscan(energy, sensors, REGIONS, latency = 0.0, passes=PASSES, split=SPLIT_PASSES, \
|
||||
before_read=before_read, after_read=after_readout, \
|
||||
name=NAME, lazy=not DUMMY_TRIGGER)
|
||||
finally:
|
||||
if IOC_AUTO_SAVE:
|
||||
capture.write(0)
|
||||
|
||||
@@ -13,7 +13,8 @@ if FILE:
|
||||
NAME , SCANS= cfg[0], cfg[1]
|
||||
print "FILE: ", FILE
|
||||
print "SCANS: ", SCANS
|
||||
|
||||
|
||||
DUMMY_TRIGGER=False
|
||||
|
||||
"""
|
||||
scienta.getState().assertReady()
|
||||
@@ -37,12 +38,13 @@ sensors=[i0, scienta.getSpectrum()]
|
||||
def before_read(position, scan):
|
||||
trigger_scienta()
|
||||
|
||||
|
||||
dummy_trigger_scienta()
|
||||
clear_output()
|
||||
if DUMMY_TRIGGER:
|
||||
dummy_trigger_scienta()
|
||||
|
||||
|
||||
try:
|
||||
tscan(sensors, SCANS, 0.001, before_read=before_read, after_read=after_readout, name = NAME)
|
||||
tscan(sensors, SCANS, 0.001, before_read=before_read, after_read=after_readout, name=NAME, lazy=not DUMMY_TRIGGER)
|
||||
finally:
|
||||
scienta.zeroSupplies()
|
||||
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
import json
|
||||
|
||||
CURRENT_REGION = ""
|
||||
CURRENT_INDEX = -1
|
||||
|
||||
if get_exec_pars().debug:
|
||||
print "Setting debug parameters"
|
||||
NAME = None
|
||||
FILE = None
|
||||
PASSES = 1
|
||||
R1 = """{
|
||||
"scienta.acquisitionMode" : "Swept",
|
||||
"scienta.elementSet" : "HiPPHAXPES",
|
||||
"scienta.lensMode" : "T_HiPPHAXPES",
|
||||
"scienta.lowEnergy" : 387.0,
|
||||
"scienta.acquisitionMode" : "Swept",
|
||||
"scienta.slices" : 1.0,
|
||||
"scienta.stepSize" : 0.25,
|
||||
"scienta.passEnergy" : 2,
|
||||
"scienta.detectorMode" : "ADC",
|
||||
"scienta.energyMode" : "Kinetic",
|
||||
"scienta.centerEnergy" : 397.0,
|
||||
"scienta.passEnergy" : 2,
|
||||
"scienta.lowEnergy" : 387.0,
|
||||
"scienta.centerEnergy" : 397.0,
|
||||
"scienta.highEnergy" : 407.0,
|
||||
"scienta.slices" : 1.0,
|
||||
"scienta.stepSize" : 0.25,
|
||||
"scienta.stepTime" : 1.0,
|
||||
"scienta.highEnergy" : 407.0,
|
||||
"scienta.iterations" : 1.0
|
||||
} """
|
||||
|
||||
@@ -29,17 +27,31 @@ if FILE:
|
||||
FILE = get_context().setup.expandPath("{home}/parameters/" + FILE)
|
||||
with open(FILE) as json_file:
|
||||
cfg = json.load(json_file)
|
||||
NAME , REGIONS= cfg[0][0][0], cfg[1]
|
||||
NAME , REGIONS, PASSES= cfg[0][0][0], cfg[1], cfg[2]
|
||||
print "FILE: ", FILE
|
||||
print "NAME: ", NAME
|
||||
#print "REGIONS: ", REGIONS
|
||||
|
||||
|
||||
print "PASSES: ", PASSES
|
||||
|
||||
DUMMY_TRIGGER = False
|
||||
CURRENT_REGION = ""
|
||||
CURRENT_INDEX = -1
|
||||
PLOT_TYPES={"spectrum":1, "energy":1}
|
||||
|
||||
|
||||
for r in REGIONS:
|
||||
name=r[0]
|
||||
pars = json.loads(r[1])
|
||||
for k,v in pars.items():
|
||||
if (v is None) or (v== float("NaN")):
|
||||
raise Exception ("Invalid value in region: ", r, " parameter: ", k)
|
||||
|
||||
set_device_alias(scienta.getSpectrum(), "spectrum")
|
||||
set_device_alias(scienta.getSpectrumScale(), "energy")
|
||||
set_device_alias(scienta.getDataMatrix(), "image")
|
||||
set_device_alias(scienta.stats[0], "sum")
|
||||
|
||||
sensors=[i0, scienta.stats[0], scienta.getSpectrum()]
|
||||
sensors=[i0, scienta.stats[0], scienta.getSpectrum(), scienta.getSpectrumScale()] #), scienta.getDataMatrix()]
|
||||
|
||||
|
||||
def apply_pars(pars):
|
||||
@@ -49,36 +61,50 @@ def apply_pars(pars):
|
||||
scienta.energyMode = scienta.energyMode.valueOf(pars["scienta.energyMode"])
|
||||
scienta.acquisitionMode = scienta.acquisitionMode.valueOf(pars["scienta.acquisitionMode"])
|
||||
scienta.passEnergy = pars["scienta.passEnergy"]
|
||||
scienta.getLowEnergy().writeAsync(pars["scienta.centerEnergy"])
|
||||
scienta.getCenterEnergy().writeAsync(pars["scienta.passEnergy"])
|
||||
scienta.getLowEnergy().writeAsync(pars["scienta.lowEnergy"])
|
||||
scienta.getCenterEnergy().writeAsync(pars["scienta.centerEnergy"])
|
||||
scienta.getHighEnergy().writeAsync(pars["scienta.highEnergy"])
|
||||
scienta.getSlices().writeAsync(pars["scienta.slices"])
|
||||
scienta.getStepSize().writeAsync(pars["scienta.stepSize"])
|
||||
scienta.getStepTime().writeAsync(pars["scienta.stepTime"])
|
||||
scienta.setIterations(int(pars["scienta.iterations"]))
|
||||
|
||||
|
||||
|
||||
def set_region_index(index):
|
||||
global REGIONS, CURRENT_REGION, CURRENT_INDEX
|
||||
r=REGIONS[index]
|
||||
name=r[0]
|
||||
pars = json.loads(r[1])
|
||||
CURRENT_REGION = name
|
||||
CURRENT_INDEX = CURRENT_INDEX+1
|
||||
print "Region: ", name
|
||||
print "Pars: ", pars
|
||||
apply_pars(pars)
|
||||
|
||||
def before_read(position, scan):
|
||||
#trigger_scienta()
|
||||
#set_region_index(scan.getRecordIndexInPass()-1)
|
||||
#time.sleep(0.5)
|
||||
trigger_scienta()
|
||||
pass
|
||||
|
||||
|
||||
#dummy_trigger_scienta()
|
||||
|
||||
clear_output()
|
||||
|
||||
try:
|
||||
for r in REGIONS:
|
||||
name=r[0]
|
||||
pars = json.loads(r[1])
|
||||
CURRENT_REGION = name
|
||||
CURRENT_INDEX = CURRENT_INDEX+1
|
||||
print "Region: ", name
|
||||
print "Pars: ", pars
|
||||
apply_pars(pars)
|
||||
time.sleep(5.0)
|
||||
|
||||
#tscan(sensors, 1, 0.001, before_read=before_read, after_read=after_readout, name = NAME)
|
||||
finally:
|
||||
scienta.zeroSupplies()
|
||||
for i in range(len(REGIONS)):
|
||||
set_region_index(i)
|
||||
#tscan(sensors, len(REGIONS), 0.1, \
|
||||
#passes=PASSES, split=SPLIT_PASSES, \
|
||||
#before_read=before_read, after_read=after_readout, name = NAME)
|
||||
if DUMMY_TRIGGER:
|
||||
dummy_trigger_scienta()
|
||||
|
||||
tscan(sensors, PASSES, 0.1, tag=CURRENT_REGION, \
|
||||
before_read=before_read, after_read=after_readout, \
|
||||
name=NAME, lazy=not DUMMY_TRIGGER, plot_types=PLOT_TYPES)
|
||||
|
||||
finally:
|
||||
print "Finalizing"
|
||||
scienta.zeroSupplies()
|
||||
print "Quit script"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user