This commit is contained in:
2023-05-01 11:28:04 +02:00
parent 3a83f3cf34
commit abe3bcb19c
265 changed files with 28663 additions and 1295 deletions

103
script/otf.py Normal file
View File

@@ -0,0 +1,103 @@
#Debugging
if get_exec_pars().innerArgs is None:
E1 = 975
E2 = 985
TIME = 1 #min
DELAY = 0.0 #s
MODE = None #'LINEAR' #'CIRC +'
OFFSET = None
NAME = 'predefined'
ALPHA= None #0
print "\nStart energy scan..."
print E1,"eV ->",E2,"eV,",TIME,"min duration,",DELAY,"sec delay,",str(MODE),(str(ALPHA)+"deg") if (MODE=="LINEAR") else ""
set_exec_pars(reset=True, name= NAME)
call_mscan=True
move_mono=False # if true, X-Tremeo runs, if false channel defiend under Ch runs
#Scan
print "Start OTF"
scan_completed = False
try:
while True:
waiting = True
class Time(Readable):
def __init__(self):
self.start = time.time()
def read(self):
return time.time()-self.start
tm = Time()
class norm_tey(Readable):
def read(self):
return float(cadc1.take())/float(cadc2.take())
class norm_diode(Readable):
def read(self):
return float(cadc3.take())/float(cadc2.take())
# define channels for PGM paramters
position=sin
snaps = ()
diags = () #Must use cache because mscan evensts are called from monitor callback tread (or else async=False). Sensors are automatically handled.
sensors = [position,out]
def monitoring_task():
global scan_completed
time.sleep(3.0)
scan_completed = True
print('Scan completed ' + str(get_exec_pars().currentScan))
global scans
scans.append(get_exec_pars().currentScan)
get_exec_pars().currentScan.abort()
print('after abort ')
def before_pass(pass_num, scan):
print "Starting scan: " + str(scan)
monitoring_future = fork(monitoring_task)[0]
print("Scanning...\n")
try:
if call_mscan==True:
print('call mscan ')
mscan( position, sensors, -1, None, \
range="auto",domain_axis=position.name,
snaps=snaps, diags=diags, before_pass=before_pass)
else:
print('-------------------------------------')
print('DO NOT CALL mscan ')
print('-------------------------------------')
#endelse
finally:
print('.....mscan done ')
if not scan_completed:
print('... cancel monitoring_future..')
monitoring_future.cancel(True)
print('monitoring is done',monitoring_future.isDone())
print "Finished Energy scan."
if after_sample(): #Repeat if id error and not ABORT_ON_ID_ERROR:
break
except:
if not scan_completed:
print sys.exc_info()
raise
#endif
#endexcept
print('-------DONE --------------')
# Finally, if mon is not use
# return to initial position