From d4e6a3d046f82b8e478eecfee129f6a686932de7 Mon Sep 17 00:00:00 2001 From: panepucci Date: Fri, 15 Apr 2016 15:24:36 +0200 Subject: [PATCH] Startup --- config/config.properties | 10 +++-- config/devices.properties | 2 +- config/jcae.properties | 10 ++++- devices/img1.properties | 6 +-- devices/th1.properties | 4 +- devices/th2.properties | 4 +- script/check_rock.py | 4 +- script/diode_scan.py | 2 +- script/local.py | 11 +++-- script/rock.py | 4 +- script/sete.py | 8 ++-- script/seteq.py | 93 ++++++++++++++++++++------------------- 12 files changed, 87 insertions(+), 71 deletions(-) diff --git a/config/config.properties b/config/config.properties index b00f00c..64379d4 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,16 +1,18 @@ -#Thu Mar 17 10:55:30 CET 2016 +#Fri Apr 15 15:24:21 CEST 2016 autoSaveScanData=true createSessionFiles=false dataLayout=default dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name} dataProvider=default dataScanFlushRecords=true +dataServerPort=-1 devicePoolFile={config}/devices.properties deviceUpdateStrategyFile={config}/update.properties logDaysToLive=-1 logLevel=Info logLevelConsole=Off logPath={logs}/{date}_{time} +scanStreamerPort=-1 scanStreamingPort=-1 serverEnabled=true serverPort=8080 @@ -21,6 +23,6 @@ terminalPort=3579 userAuthenticator= userManagement=false versionTrackingEnabled=true -versionTrackingLogin= -versionTrackingManual=true -versionTrackingRemote=https\://git.psi.ch/pshell_config/x06da.git +versionTrackingLogin={context}/svcusr-hlapp_robot\u200E +versionTrackingManual=false +versionTrackingRemote=git@git.psi.ch\:pshell_config/x06da.git diff --git a/config/devices.properties b/config/devices.properties index 59a36c8..60304e9 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -4,7 +4,7 @@ current=ch.psi.pshell.epics.ChannelDouble|ARIDI-PCT:CURRENT|Read||true i0=ch.psi.pshell.epics.ChannelDouble|X06DA-ES-I0:READOUT 6|Read||true diode=ch.psi.pshell.epics.ChannelDouble|X06DA-ES-DIODE:READOUT|Read||true cats_block=ch.psi.pshell.epics.BinaryPositioner|X06DA-ES-CATS:BLOCKED|Read||true -exp_shutter=ch.psi.pshell.epics.BinaryPositioner|X06DA-ES-PH1:SET X06DA-ES-PH1:GET|Read||true +exp_shutter=ch.psi.pshell.epics.BinaryPositioner|X06DA-ES-PH1:SET X06DA-ES-PH1:GET|||true ketek=ch.psi.pshell.epics.BinaryPositioner|X06DA-ES-FD:SET-POS X06DA-ES-FD:GET-POS|Read||true beam_stop_pos=ch.psi.pshell.epics.BinaryPositioner|X06DA-ES-BS:SET-POS X06DA-ES-BS:GET-POS|Read||true det_cover=ch.psi.pshell.epics.DiscretePositioner|X06DA-ES-PILCOV:SET|Read||true diff --git a/config/jcae.properties b/config/jcae.properties index 6ddb88f..5bd559c 100644 --- a/config/jcae.properties +++ b/config/jcae.properties @@ -1 +1,9 @@ -ch.psi.jcae.ContextFactory.maxArrayBytes=10000000 \ No newline at end of file +#Fri Apr 15 15:21:04 CEST 2016 +ch.psi.jcae.ContextFactory.maxArrayBytes=10000000 +ch.psi.jcae.ContextFactory.addressList= +ch.psi.jcae.ChannelFactory.retries=1 +ch.psi.jcae.ChannelFactory.timeout=500 +ch.psi.jcae.impl.DefaultChannelService.retries=2 +ch.psi.jcae.impl.DefaultChannelService.timeout=500 +ch.psi.jcae.impl.DefaultChannelService.waitTimeout= +ch.psi.jcae.impl.DefaultChannelService.waitRetryPeriod=10000 diff --git a/devices/img1.properties b/devices/img1.properties index 9a5a3bd..43aa54b 100644 --- a/devices/img1.properties +++ b/devices/img1.properties @@ -1,13 +1,13 @@ -#Tue Nov 24 11:34:27 CET 2015 +#Fri Apr 15 14:05:22 CEST 2016 colormap=Grayscale colormapAutomatic=false colormapMax=255.0 colormapMin=0.0 flipHorizontally=false -flipVertically=false +flipVertically=true grayscale=false invert=false rescaleFactor=1.0 rescaleOffset=0.0 -rotation=0.0 +rotation=90.0 scale=1.0 diff --git a/devices/th1.properties b/devices/th1.properties index f33c7c7..e531e3c 100644 --- a/devices/th1.properties +++ b/devices/th1.properties @@ -1,4 +1,4 @@ -#Fri Dec 18 10:06:09 CET 2015 +#Fri Apr 15 10:41:00 CEST 2016 defaultSpeed=0.05000000074505806 estbilizationDelay=0 hasEnable=false @@ -9,6 +9,6 @@ minSpeed=0.00800000037997961 minValue=-26.0 offset=0.0 precision=5 -resolution=1.0E-4 +resolution=5.0E-4 scale=1.0 unit=deg diff --git a/devices/th2.properties b/devices/th2.properties index a7b9133..bfd7d3e 100644 --- a/devices/th2.properties +++ b/devices/th2.properties @@ -1,4 +1,4 @@ -#Thu Nov 26 16:06:20 CET 2015 +#Fri Apr 15 10:41:27 CEST 2016 defaultSpeed=0.05000000074505806 estbilizationDelay=0 hasEnable=false @@ -9,6 +9,6 @@ minSpeed=0.00800000037997961 minValue=-1.0149999856948853 offset=0.0 precision=5 -resolution=3.9999998989515007E-5 +resolution=5.0E-4 scale=1.0 unit=deg diff --git a/script/check_rock.py b/script/check_rock.py index cd45756..fb4a41d 100644 --- a/script/check_rock.py +++ b/script/check_rock.py @@ -16,7 +16,7 @@ if int(ENERGY) < 6: # if theta1 and theta2 differ too much (>0.01deg), rock won't work well, sete should be used in this case # 20130614, change threshold from 0.015 to 0.02 -if abs(THETA1 - THETA2) > 0.02: +if abs(THETA1 + THETA2) > 0.02: raise Exception("Two mono crystals are not synchronized, please use 'sete()'") # # check the flux @@ -82,7 +82,7 @@ POSV = int(BPM1POSV * 1000) if POSV <= -6 or POSV >= 6 : print "Beam is not aligned at E-BOX BPM1" print "lets fix it." - fbm() + #fbm() time.sleep(2) else : print "Beam is aligned at E-BOX BPM1," diff --git a/script/diode_scan.py b/script/diode_scan.py index bf58a66..b1ae215 100644 --- a/script/diode_scan.py +++ b/script/diode_scan.py @@ -1,6 +1,6 @@ """ Diode scan """ - + asd #Execute the scan: 200 steps, a1 from 0 to 40 a= lscan(ao1, (diode,current), 0, 40, 200, 0.01) diff --git a/script/local.py b/script/local.py index 7c8127e..d01bfc4 100644 --- a/script/local.py +++ b/script/local.py @@ -163,11 +163,16 @@ def flux_diode(): """ run("flux_diode") -def sete(e, all=True, wavelengt=False): - run("sete", {"e":e, "all":all, "wavelengt":wavelengt}) +def sete(e, all=True, wavelength=False): + run("sete", {"e":e, "all":all, "wavelength":wavelength}) def seteq(e): - runq("seteq", {"e":e}) + run("seteq", {"e":e}) + + +def check_rock(): + run("check_rock") + import ch.psi.pshell.device.ReadonlyRegisterBase as ReadonlyRegisterBase class EnergyReader(ReadonlyRegisterBase): diff --git a/script/rock.py b/script/rock.py index 0e2f080..2913590 100644 --- a/script/rock.py +++ b/script/rock.py @@ -38,10 +38,10 @@ def rock(axis = th1, tt = 0.2, seti0 = False, dx = None, noref = False): br = mono_beam.read() mono_beam_ref.write(br) print 'rock_success new mono beam at ' + str(br) + ' at' + str(e) + ' keV' - return true + return True else: print 'fit failed - centering on maximum' max_x= xdata[ydata.index(max(ydata))] axis.move(max_x) - return false + return False \ No newline at end of file diff --git a/script/sete.py b/script/sete.py index 12f8445..597b3ff 100644 --- a/script/sete.py +++ b/script/sete.py @@ -37,14 +37,14 @@ act = 0 # do a setenergy to move theta 1 and 2 to calculated position in case they are not synchronized. theta1 = th1.read() #TODO: setpoint? -etheta1 = a2e(abs(theta1),1,1,1,True) +etheta1 = a2e(abs(theta1),1,1,1,deg=True,ln=True) theta2 = th2.read() -etheta2 = a2e(ABS(theta2),1,1,1,True) +etheta2 = a2e(abs(theta2),1,1,1,deg=True,ln=False) if abs (etheta1-etheta2) > 0.01: set_energy(e) -while abs(e-e0) > 3e-5/tan(angle(e, deg=False)): #TODO: deg==false? WHILE ABS(e-e0) GT 3e-5/TAN(ANGLE(e)) DO BEGIN +while abs(e-e0) > 3e-5/math.tan(angle(e, deg=False)): #TODO: deg==false? WHILE ABS(e-e0) GT 3e-5/TAN(ANGLE(e)) DO BEGIN set_energy(e) e0 = get_energy(False) @@ -75,7 +75,7 @@ rock() e0 = get_energy() print e0 mono_energy.write(e0) -print caget(mono_energy.read()) +print mono_energy.read() caput(beam_err, 'Finito') caput(beam_set, 'DONE') diff --git a/script/seteq.py b/script/seteq.py index bac7b41..44ed6c7 100644 --- a/script/seteq.py +++ b/script/seteq.py @@ -33,59 +33,60 @@ print "X06DA-ES-BPM1:POSV BEFORE" + str(eboxbpm0) #--------------- setting theta 1, 2 -------------------- # adjust 'Retry deadband' to 0.0001 (from 0.00004) and 'Retries Max' to 1 (from 5) -caput(th1.channelName +'.RDBD',0.00001) -caput(th2.channelName +'.RDBD',0.00001) -caput(th1.channelName +'.RTRY',1) -caput(th2.channelName +'.RTRY',1) +try: + caput(th1.channelName +'.RDBD',0.00001) + caput(th2.channelName +'.RDBD',0.00001) + caput(th1.channelName +'.RTRY',1) + caput(th2.channelName +'.RTRY',1) -#in order to do a small energy change without rock, -# 1) move theta2 to calculated angle -# 2) move theta1 to exact amount as theta2 moved -# -while abs(e-e0) > (3e-5 / math.tan(angle(e, deg=False)))): #TODO: deg==false? WHILE ABS(e-e0) GT 3e-5/TAN(ANGLE(e)) DO BEGIN - t1v = th1.read() #TODO: setpoint? - t2v = th2.read() - t2s = angle(float(e),1,1,1) - dt2 = t2s-t2v - dt1 = -dt2 - t1p = t1v+dt1 - t2p = t2s # which is t2v+dt2 - print 'set angles th1, th2, relative move dt1, dt2 ', t1p, t2p, dt1, dt2 - th1.move(t1p) - th2.move(t2p) - eo=get_energy(False) - time.sleep(2.0) - Inow = mono_beam.read() - print e, Istart, Inow + #in order to do a small energy change without rock, + # 1) move theta2 to calculated angle + # 2) move theta1 to exact amount as theta2 moved + while (abs(e-e0) > (3e-5 / math.tan(angle(e, deg=False)))): + t1v = th1.read() #TODO: setpoint? + t2v = th2.read() + t2s = angle(float(e),1,1,1, deg=True) + dt2 = t2s-t2v + dt1 = -dt2 + t1p = t1v+dt1 + t2p = t2s # which is t2v+dt2 + print 'set angles th1, th2, relative move dt1, dt2 ', t1p, t2p, dt1, dt2 + th1.move(t1p) + th2.move(t2p) + e0=get_energy(False) + time.sleep(2.0) + Inow = mono_beam.read() + print e, Istart, Inow + + # feedback at BPM5 + eboxbpm = es_beam_posv.read() + while abs(eboxbpm-eboxbpm0) > 0.002: + if (eboxbpm-eboxbpm0) >0: + th1.moveRel(-0.00004) + else: + th1.moveRel(0.00004) + + time.sleep(1.0) + eboxbpm = es_beam_posv.read() + # if BPM1:POSV is too off, stop it + if eboxbpm > 0.050: + raise Exception("BPM1:POSV is too off") + + # put 'Retry deadband' to 0.00004 and 'Retries Max' to 5 + # wait a bit until motor movement finished (of course, this won't work if move across large energy range. but who use seteq to do that.) + time.sleep(0.2) -# feedback at BPM5 -eboxbpm = es_beam_posv.read() -while abs(eboxbpm-eboxbpm0) > 0.002: - if (eboxbpm-eboxbpm0) >0: - th1.moveRel(-0.00004) - else: - th1.moveRel(0.00004) - -time.sleep(1.0) -eboxbpm = es_beam_posv.read() -# if BPM1:POSV is too off, stop it -if eboxbpm > 0.050: - raise Exception("BPM1:POSV is too off") - - -# put 'Retry deadband' to 0.00004 and 'Retries Max' to 5 -# wait a bit until motor movement finished (of course, this won't work if move across large energy range. but who use seteq to do that.) -time.sleep(0.2) -caput(th1.channelName +'.RDBD',0.00004) -caput(th2.channelName +'.RDBD',0.00004) -caput(th1.channelName +'.RTRY',5) -caput(th2.channelName +'.RTRY',5) +finally: + caput(th1.channelName +'.RDBD',0.00004) + caput(th2.channelName +'.RDBD',0.00004) + caput(th1.channelName +'.RTRY',5) + caput(th2.channelName +'.RTRY',5) e0 = get_energy() print e0 mono_energy.write(e0) -print caget(mono_energy.read()) +print mono_energy.read() # release the token!