Configuration change: Context
This commit is contained in:
54
config/config.properties
Normal file
54
config/config.properties
Normal file
@@ -0,0 +1,54 @@
|
||||
#Fri Mar 04 14:28:28 CET 2022
|
||||
autoSaveScanData=true
|
||||
simulation=false
|
||||
dataScanSaveOutput=false
|
||||
userAuthenticator=
|
||||
dataScanSaveScript=false
|
||||
notifiedTasks=null
|
||||
parallelInitialization=false
|
||||
dataTransferPath=null
|
||||
scanStreamingPort=-1
|
||||
saveConsoleSessionFiles=false
|
||||
devicePoolFile={config}/devices.properties
|
||||
hostName=null
|
||||
disableEmbeddedAttributes=false
|
||||
serverPort=8080
|
||||
versionTrackingEnabled=true
|
||||
dataPath={data}/{year}/{month}/{day}/{year}_{month}{day}_{time}_{name}
|
||||
serverEnabled=true
|
||||
depthDimension=0
|
||||
logLevel=Info
|
||||
dataLayout=fda
|
||||
disableDataFileLogs=false
|
||||
sessionHandling=Off
|
||||
deviceUpdateStrategyFile={config}/update.properties
|
||||
terminalEnabled=false
|
||||
notificationLevel=Off
|
||||
terminalPort=3579
|
||||
dataTransferUser=null
|
||||
versionTrackingLogin={context}/svcusr-hlapp_robot
|
||||
noBytecodeFiles=false
|
||||
versionTrackingRemote=git@git.psi.ch\:pshell_config/x07mb.git
|
||||
commandExecutionEvents=false
|
||||
logDaysToLive=30
|
||||
logLevelConsole=Off
|
||||
filePermissionsConfig=Default
|
||||
scanStreamerPort=-1
|
||||
dataScanSaveSetpoints=false
|
||||
versionTrackingManual=true
|
||||
dataTransferMode=Off
|
||||
userManagement=false
|
||||
instanceName=
|
||||
dataServerPort=-1
|
||||
hideServerMessages=false
|
||||
dataScanReleaseRecords=true
|
||||
dataScanPreserveTypes=true
|
||||
dataScanFlushRecords=true
|
||||
logPath={logs}/{date}_{time}
|
||||
filePermissionsLogs=Default
|
||||
filePermissionsScripts=Default
|
||||
tasksFile={config}/tasks.properties
|
||||
filePermissionsData=Default
|
||||
createSessionFiles=false
|
||||
dataProvider=fda
|
||||
saveCommandStatistics=false
|
||||
28
config/devices.properties
Normal file
28
config/devices.properties
Normal file
@@ -0,0 +1,28 @@
|
||||
current=ch.psi.pshell.epics.ChannelDouble|ARIDI-PCT:CURRENT|Read||true
|
||||
ROT=ch.psi.pshell.epics.Motor|X07MB-ES-MA1:ROT|||true
|
||||
TRSCANH=ch.psi.pshell.epics.Motor|X07MA-ES3-MA1:TRSCAN|||
|
||||
TRSCANH_RBV=ch.psi.pshell.epics.ChannelDouble|X07MB-ES3-MA1:TRSCANH.RBV|||true
|
||||
ScanX=ch.psi.pshell.epics.Motor|X07MB-ES-MA1:ScanX|||true
|
||||
ScanX_RBV=ch.psi.pshell.epics.ChannelDouble|X07MB-ES-MA1:ScanX.RBV|||
|
||||
channel=ch.psi.pshell.epics.ChannelDouble|X07MB-OP2-SAI_03:CUR-MEAN|||true
|
||||
ScanY=ch.psi.pshell.epics.Motor|X07MB-ES-MA1:ScanY|||true
|
||||
ScanY_RBV=ch.psi.pshell.epics.ChannelDouble|X07MB-ES-MA1:ScanY.RBV|||
|
||||
keith_1=ch.psi.pshell.epics.ChannelDouble|X07MB-OP2-SAI_07:MEAN|||true
|
||||
keith_2=ch.psi.pshell.epics.ChannelDouble|X07MB-OP2-SAI_08:MEAN|||true
|
||||
keith_3=ch.psi.pshell.epics.ChannelDouble|X07MB-OP2-SAI_06:MEAN|||true
|
||||
mca_1=ch.psi.pshell.epics.ChannelIntegerArray|X07MB-XMAP:mca1|||true
|
||||
trigger=ch.psi.pshell.epics.ChannelInteger|X07MB-OP2:INTR-COUNT|||true
|
||||
pol_mode=ch.psi.pshell.epics.DiscretePositioner|X07MA-ID:MODE|||true
|
||||
pol_offset=ch.psi.pshell.epics.ChannelDouble|X07MA-ID:ENERGY-OFFS|||true
|
||||
pol_angle=ch.psi.pshell.epics.ChannelDouble|X07MA-ID:ALPHA|||true
|
||||
pol_done=ch.psi.pshell.epics.ChannelString|X07MA-ID:DONE|Read||true
|
||||
energy_ma=ch.psi.pshell.epics.ChannelDouble|X07MA-PHS-E:GO.A|||true
|
||||
energy_ma_rbv=ch.psi.pshell.epics.ChannelDouble|X07MA-PGM:CERBK|Read||true
|
||||
energy_ma_done=ch.psi.pshell.epics.ChannelInteger|X07MA-PHS:alldone|Read||true
|
||||
cadc1=ch.psi.pshell.epics.ChannelDouble|X07MA-ES1-AI:SIGNAL0|Read||true
|
||||
cadc2=ch.psi.pshell.epics.ChannelDouble|X07MA-ES1-AI:SIGNAL1|Read||true
|
||||
cadc3=ch.psi.pshell.epics.ChannelDouble|X07MA-ES1-AI:SIGNAL2|Read||true
|
||||
cadc4=ch.psi.pshell.epics.ChannelDouble|X07MA-ES1-AI:SIGNAL3|Read||true
|
||||
cadc5=ch.psi.pshell.epics.ChannelDouble|X07MA-ES1-AI:SIGNAL4|Read||true
|
||||
beam_status=ch.psi.pshell.epics.DiscretePositioner|ACOAU-ACCU:OP-MODE|Read||true
|
||||
id_error=ch.psi.pshell.epics.ChannelInteger|X07MA-ID-PLC:ERROR|||true
|
||||
16
config/jcae.properties
Normal file
16
config/jcae.properties
Normal file
@@ -0,0 +1,16 @@
|
||||
#Fri Jul 31 16:19:42 CEST 2020
|
||||
ch.psi.jcae.ContextFactory.maxArrayBytes=20000000
|
||||
ch.psi.jcae.impl.DefaultChannelService.timeout=1000
|
||||
ch.psi.jcae.ChannelFactory.timeout=3000
|
||||
ch.psi.jcae.ContextFactory.maxSendArrayBytes=
|
||||
ch.psi.jcae.ChannelFactory.retries=1
|
||||
ch.psi.jcae.ContextFactory.useShellVariables=true
|
||||
ch.psi.jcae.ContextFactory.addLocalBroadcastInterfaces=false
|
||||
ch.psi.jcae.ContextFactory.addressList=
|
||||
ch.psi.jcae.ContextFactory.serverPort=
|
||||
ch.psi.jcae.impl.DefaultChannelService.retries=4
|
||||
ch.psi.jcae.ContextFactory.autoAddressList=false
|
||||
ch.psi.jcae.ChannelBeanFactory.timeout=10000
|
||||
ch.psi.jcae.ChannelBeanFactory.waitTimeout=1800000
|
||||
ch.psi.jcae.ChannelBeanFactory.waitRetryPeriod=60000
|
||||
ch.psi.jcae.ChannelBeanFactory.retries=4
|
||||
9
config/mail.properties
Normal file
9
config/mail.properties
Normal file
@@ -0,0 +1,9 @@
|
||||
#Thu Nov 09 14:48:45 CET 2017
|
||||
auth=None
|
||||
from=
|
||||
host=
|
||||
port=0
|
||||
pwd=
|
||||
smsSuffix=@sms.switch.ch
|
||||
to=
|
||||
usr=
|
||||
1
config/plugins.properties
Normal file
1
config/plugins.properties
Normal file
@@ -0,0 +1 @@
|
||||
PersonalizedTheme.java=enabled
|
||||
2
config/settings.properties
Normal file
2
config/settings.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
#Fri Mar 04 14:27:17 CET 2022
|
||||
FdaBrowser=true
|
||||
23
config/setup.properties
Normal file
23
config/setup.properties
Normal file
@@ -0,0 +1,23 @@
|
||||
#Wed May 19 14:35:09 CEST 2021
|
||||
scriptPath={home}/script
|
||||
sessionsPath={outp}/sessions
|
||||
pluginsPath={home}/plugins
|
||||
configFileDevices={config}/devices.properties
|
||||
consoleSessionsPath={sessions}/console
|
||||
libraryPath={script}; {script}/Lib
|
||||
configFilePlugins={config}/plugins.properties
|
||||
contextPath={outp}/context
|
||||
extensionsPath={home}/extensions
|
||||
configPath={home}/config
|
||||
configFileSessions={config}/sessions.properties
|
||||
userSessionsPath={sessions}/user
|
||||
dataPath={outp}/data
|
||||
devicesPath={home}/devices
|
||||
configFileVariables={config}/variables.properties
|
||||
configFileSettings={config}/settings.properties
|
||||
logPath={outp}/log
|
||||
wwwPath={home}/www
|
||||
configFile={config}/config.properties
|
||||
imagesPath={outp}/images
|
||||
scriptType=py
|
||||
configFileTasks={config}/tasks.properties
|
||||
4
config/variables.properties
Normal file
4
config/variables.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
#Fri Mar 04 14:16:42 CET 2022
|
||||
LastRunDate=220304
|
||||
FileSequentialNumber=582
|
||||
DaySequentialNumber=7
|
||||
18
devices/ROT.properties
Normal file
18
devices/ROT.properties
Normal file
@@ -0,0 +1,18 @@
|
||||
#Thu Sep 19 10:34:01 CEST 2019
|
||||
defaultSpeed=1.5
|
||||
estbilizationDelay=0
|
||||
hasEnable=false
|
||||
homingType=None
|
||||
maxSpeed=NaN
|
||||
maxValue=95.5
|
||||
minSpeed=0.75
|
||||
minValue=-41.0
|
||||
monitorByPosition=false
|
||||
offset=0.0
|
||||
precision=6
|
||||
resolution=0.002
|
||||
rotation=false
|
||||
scale=1.0
|
||||
sign_bit=0
|
||||
startRetries=1
|
||||
unit=deg
|
||||
18
devices/ScanX.properties
Normal file
18
devices/ScanX.properties
Normal file
@@ -0,0 +1,18 @@
|
||||
#Thu Sep 19 10:34:01 CEST 2019
|
||||
defaultSpeed=1.0
|
||||
estbilizationDelay=0
|
||||
hasEnable=false
|
||||
homingType=None
|
||||
maxSpeed=NaN
|
||||
maxValue=30.0
|
||||
minSpeed=0.001
|
||||
minValue=-32.0
|
||||
monitorByPosition=false
|
||||
offset=0.0
|
||||
precision=6
|
||||
resolution=0.001
|
||||
rotation=false
|
||||
scale=1.0
|
||||
sign_bit=0
|
||||
startRetries=1
|
||||
unit=mm
|
||||
18
devices/ScanY.properties
Normal file
18
devices/ScanY.properties
Normal file
@@ -0,0 +1,18 @@
|
||||
#Thu Sep 19 10:34:01 CEST 2019
|
||||
defaultSpeed=0.5
|
||||
estbilizationDelay=0
|
||||
hasEnable=false
|
||||
homingType=None
|
||||
maxSpeed=NaN
|
||||
maxValue=1.6999999999999993
|
||||
minSpeed=1.0E-4
|
||||
minValue=-23.3
|
||||
monitorByPosition=false
|
||||
offset=0.0
|
||||
precision=6
|
||||
resolution=0.2
|
||||
rotation=false
|
||||
scale=1.0
|
||||
sign_bit=0
|
||||
startRetries=1
|
||||
unit=mm
|
||||
16
devices/ScanY_RBV.properties
Normal file
16
devices/ScanY_RBV.properties
Normal file
@@ -0,0 +1,16 @@
|
||||
#Wed Feb 28 15:37:17 CET 2018
|
||||
defaultSpeed=0.4
|
||||
estbilizationDelay=0
|
||||
hasEnable=false
|
||||
homingType=None
|
||||
maxSpeed=NaN
|
||||
maxValue=22.0
|
||||
minSpeed=0.0050000000000000044
|
||||
minValue=-17.0
|
||||
offset=0.0
|
||||
precision=8
|
||||
resolution=0.00125
|
||||
rotation=false
|
||||
scale=1.0
|
||||
startRetries=1
|
||||
unit=mm
|
||||
18
devices/TRSCANH.properties
Normal file
18
devices/TRSCANH.properties
Normal file
@@ -0,0 +1,18 @@
|
||||
#Thu Sep 19 10:34:01 CEST 2019
|
||||
defaultSpeed=0.4
|
||||
estbilizationDelay=0
|
||||
hasEnable=false
|
||||
homingType=None
|
||||
maxSpeed=NaN
|
||||
maxValue=22.0
|
||||
minSpeed=0.001
|
||||
minValue=-17.0
|
||||
monitorByPosition=false
|
||||
offset=0.0
|
||||
precision=8
|
||||
resolution=0.01
|
||||
rotation=false
|
||||
scale=1.0
|
||||
sign_bit=0
|
||||
startRetries=1
|
||||
unit=mm
|
||||
11
devices/dp1.properties
Normal file
11
devices/dp1.properties
Normal file
@@ -0,0 +1,11 @@
|
||||
#Mon Mar 21 10:29:45 CET 2016
|
||||
motor1=0.0|4.0|8.0|0.0
|
||||
motor2=0.0|5.0|3.0|NaN
|
||||
motor3=null
|
||||
motor4=null
|
||||
motor5=null
|
||||
motor6=null
|
||||
motor7=null
|
||||
motor8=null
|
||||
positions=Park|Ready|Out|Clear
|
||||
precision=-1
|
||||
10
devices/energy_ma.properties
Normal file
10
devices/energy_ma.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
#Thu Mar 03 14:39:23 CET 2022
|
||||
offset=0.0
|
||||
maxValue=2000.0
|
||||
rotation=false
|
||||
precision=3
|
||||
scale=1.0
|
||||
resolution=0.01
|
||||
minValue=300.0
|
||||
unit=eV
|
||||
sign_bit=0
|
||||
16
devices/m1.properties
Normal file
16
devices/m1.properties
Normal file
@@ -0,0 +1,16 @@
|
||||
#Wed Jul 22 10:07:25 CEST 2020
|
||||
offset=0.0
|
||||
maxValue=10.0
|
||||
precision=2
|
||||
rotation=false
|
||||
scale=1.0
|
||||
estbilizationDelay=0
|
||||
maxSpeed=10.0
|
||||
resolution=NaN
|
||||
startRetries=1
|
||||
minValue=-10.0
|
||||
unit=mm
|
||||
defaultSpeed=1.0
|
||||
sign_bit=0
|
||||
monitorByPosition=false
|
||||
minSpeed=0.1
|
||||
16
devices/m2.properties
Normal file
16
devices/m2.properties
Normal file
@@ -0,0 +1,16 @@
|
||||
#Wed Jul 22 10:07:25 CEST 2020
|
||||
offset=0.0
|
||||
maxValue=10.0
|
||||
precision=2
|
||||
rotation=false
|
||||
scale=1.0
|
||||
estbilizationDelay=0
|
||||
maxSpeed=10.0
|
||||
resolution=NaN
|
||||
startRetries=1
|
||||
minValue=-10.0
|
||||
unit=mm
|
||||
defaultSpeed=1.0
|
||||
sign_bit=0
|
||||
monitorByPosition=false
|
||||
minSpeed=0.1
|
||||
10
devices/p1.properties
Normal file
10
devices/p1.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
#Wed Jul 22 10:07:25 CEST 2020
|
||||
minValue=0.0
|
||||
unit=mm
|
||||
offset=0.0
|
||||
maxValue=1000.0
|
||||
precision=-1
|
||||
rotation=false
|
||||
sign_bit=0
|
||||
scale=1.0
|
||||
resolution=NaN
|
||||
16
devices/scan_y.properties
Normal file
16
devices/scan_y.properties
Normal file
@@ -0,0 +1,16 @@
|
||||
#Thu Nov 09 14:48:45 CET 2017
|
||||
defaultSpeed=0.5
|
||||
estbilizationDelay=100
|
||||
hasEnable=false
|
||||
homingType=None
|
||||
maxSpeed=NaN
|
||||
maxValue=1.6999999999999993
|
||||
minSpeed=0.05
|
||||
minValue=-23.3
|
||||
offset=0.0
|
||||
precision=6
|
||||
resolution=5.0E-4
|
||||
rotation=false
|
||||
scale=1.0
|
||||
startRetries=1
|
||||
unit=mm
|
||||
25
devices/src1.properties
Normal file
25
devices/src1.properties
Normal file
@@ -0,0 +1,25 @@
|
||||
#Wed Jul 22 10:07:25 CEST 2020
|
||||
spatialCalOffsetY=NaN
|
||||
spatialCalOffsetX=NaN
|
||||
colormapLogarithmic=false
|
||||
scale=1.0
|
||||
grayscale=false
|
||||
spatialCalScaleX=NaN
|
||||
spatialCalScaleY=NaN
|
||||
colormapMax=255.0
|
||||
rescaleOffset=0.0
|
||||
roiWidth=-1
|
||||
colormap=Temperature
|
||||
invert=false
|
||||
colormapMin=0.0
|
||||
rotation=0.0
|
||||
rotationCrop=false
|
||||
rescaleFactor=1.0
|
||||
spatialCalUnits=mm
|
||||
flipVertically=false
|
||||
roiHeight=-1
|
||||
flipHorizontally=false
|
||||
colormapAutomatic=true
|
||||
roiY=0
|
||||
roiX=0
|
||||
transpose=false
|
||||
25
devices/src2.properties
Normal file
25
devices/src2.properties
Normal file
@@ -0,0 +1,25 @@
|
||||
#Wed Jul 22 10:07:25 CEST 2020
|
||||
spatialCalOffsetY=NaN
|
||||
spatialCalOffsetX=NaN
|
||||
colormapLogarithmic=false
|
||||
scale=1.0
|
||||
grayscale=false
|
||||
spatialCalScaleX=NaN
|
||||
spatialCalScaleY=NaN
|
||||
colormapMax=255.0
|
||||
rescaleOffset=0.0
|
||||
roiWidth=-1
|
||||
colormap=Grayscale
|
||||
invert=false
|
||||
colormapMin=0.0
|
||||
rotation=0.0
|
||||
rotationCrop=false
|
||||
rescaleFactor=1.0
|
||||
spatialCalUnits=mm
|
||||
flipVertically=false
|
||||
roiHeight=-1
|
||||
flipHorizontally=false
|
||||
colormapAutomatic=true
|
||||
roiY=0
|
||||
roiX=0
|
||||
transpose=false
|
||||
467
plugins/EnergyScan.form
Normal file
467
plugins/EnergyScan.form
Normal file
@@ -0,0 +1,467 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.ButtonGroup" name="buttonGroupPlot">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="panelData" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jPanel1" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jPanel3" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="panelParameters" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
|
||||
<Component id="panelParameters" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="panelData" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel1" linkSize="11" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jPanel3" linkSize="11" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="panelParameters">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder title="Parameters"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel5" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="spinnerE1" linkSize="2" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerTime" linkSize="2" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboMode" linkSize="2" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="checkSetOffset" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel9" linkSize="4" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" linkSize="4" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" linkSize="4" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="spinnerE2" linkSize="5" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerDelay" linkSize="5" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerAlpha" linkSize="5" alignment="1" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jLabel8" linkSize="4" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="spinnerOffset" linkSize="5" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerE1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerE2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerTime" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerDelay" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboMode" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerAlpha" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerOffset" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="checkSetOffset" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="E1:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerE1">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="690.0" maximum="9999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="E2:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerE2">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="755.0" maximum="9999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="Time(min):"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerTime">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="3.0" maximum="60.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="Delay(s):"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerDelay">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="10.0" maximum="600.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="Mode:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboMode">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="3">
|
||||
<StringItem index="0" value="CIRC +"/>
|
||||
<StringItem index="1" value="CIRC -"/>
|
||||
<StringItem index="2" value="LINEAR"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboModeActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel8">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="Offset:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerOffset">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0.0" maximum="20.0" minimum="-20.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel9">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="Alpha:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerAlpha">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0.0" maximum="90.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="checkSetOffset">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Set Offset"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="checkSetOffsetActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder title="Setup"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace pref="22" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel10" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel11" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="comboRunType" linkSize="13" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="comboSetup" linkSize="13" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="buttonConfigure" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="22" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="comboSetup" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonConfigure" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboRunType" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JComboBox" name="comboSetup">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboSetupActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonConfigure">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Configure"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonConfigureActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel10">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Element:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel11">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Run Type:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboRunType">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="9">
|
||||
<StringItem index="0" value="Manual"/>
|
||||
<StringItem index="1" value="+"/>
|
||||
<StringItem index="2" value="-"/>
|
||||
<StringItem index="3" value="LH"/>
|
||||
<StringItem index="4" value="LV"/>
|
||||
<StringItem index="5" value="+/-"/>
|
||||
<StringItem index="6" value="+/-/-/+"/>
|
||||
<StringItem index="7" value="LH/LV"/>
|
||||
<StringItem index="8" value="LH/LV/LV/LH"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboRunTypeActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="panelData">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder title="File"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="textFile" max="32767" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="buttonDefaults" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="textFile" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonDefaults" alignment="3" min="-2" pref="27" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="buttonDefaults">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Default"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonDefaultsActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel6">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="File:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="textFile">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder title="Scan Control"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace pref="22" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="buttonAbort" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
<Component id="buttonExecute" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="22" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
|
||||
<Component id="buttonExecute" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="buttonExecute">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Start"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonExecuteActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonAbort">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Abort"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAbortActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
714
plugins/EnergyScan.java
Normal file
714
plugins/EnergyScan.java
Normal file
@@ -0,0 +1,714 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import java.awt.Component;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JLabel;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.DsvEditor;
|
||||
import ch.psi.utils.swing.Editor.EditorDialog;
|
||||
import ch.psi.pshell.data.PlotDescriptor;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EnergyScan extends Panel {
|
||||
|
||||
public EnergyScan() {
|
||||
initComponents();
|
||||
buttonDefaultsActionPerformed(null);
|
||||
setBackgroundUpdate(true);
|
||||
}
|
||||
double[] offsets = new double[4];
|
||||
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
super.onInitialize(runCount);
|
||||
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
setEnabled(state == State.Ready);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
}
|
||||
|
||||
void stopScan() {
|
||||
try{
|
||||
getLogger().info("Stopping scan");
|
||||
evalAsync("caput('START', 'STOP')");
|
||||
} catch (Exception ex){
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
Path getConfigFile() {
|
||||
return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties");
|
||||
}
|
||||
|
||||
enum Mode {
|
||||
|
||||
plus,
|
||||
minus,
|
||||
lh,
|
||||
lv
|
||||
}
|
||||
|
||||
Mode[] batch;
|
||||
int batchIndex;
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean value) {
|
||||
super.setEnabled(value);
|
||||
buttonExecute.setEnabled(value);
|
||||
comboSetup.setEnabled(value);
|
||||
comboRunType.setEnabled(value);
|
||||
buttonConfigure.setEnabled(value);
|
||||
textFile.setEnabled(value);
|
||||
buttonDefaults.setEnabled(value);
|
||||
checkParameterControls();
|
||||
}
|
||||
|
||||
void checkParameterControls() {
|
||||
boolean enabled = isEnabled() && (comboRunType.getSelectedIndex() == 0);
|
||||
for (Component c : panelParameters.getComponents()) {
|
||||
if (!(c instanceof JLabel)) {
|
||||
c.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
spinnerAlpha.setEnabled(enabled && comboMode.getSelectedItem().equals("LINEAR"));
|
||||
spinnerOffset.setEnabled(checkSetOffset.isSelected() && enabled);
|
||||
}
|
||||
|
||||
|
||||
void loadConfig() {
|
||||
DefaultComboBoxModel model = (DefaultComboBoxModel) comboSetup.getModel();
|
||||
model.removeAllElements();
|
||||
try {
|
||||
for (String line : Files.readAllLines(getConfigFile())) {
|
||||
if ((line != null) && (!line.trim().isEmpty())) {
|
||||
String[] tokens = line.split("=");
|
||||
if (tokens.length > 0) {
|
||||
model.addElement(tokens[0].trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
String expandPath(String path) {
|
||||
long time = System.currentTimeMillis();
|
||||
String mode;
|
||||
if (comboMode.getSelectedIndex() == 0) {
|
||||
mode = "plus";
|
||||
} else if (comboMode.getSelectedIndex() == 1) {
|
||||
mode = "minus";
|
||||
} else {
|
||||
mode = "lin_" + String.format("%1.0f", (Double) spinnerAlpha.getValue());
|
||||
}
|
||||
path = getContext().getSetup().expandPath(path);
|
||||
path = path.replaceAll("\\{el\\}", String.valueOf(comboSetup.getSelectedItem()));
|
||||
path = path.replaceAll("\\{mode\\}", mode);
|
||||
return path;
|
||||
}
|
||||
|
||||
void setMode(Mode mode) {
|
||||
switch (mode) {
|
||||
case plus:
|
||||
comboMode.setSelectedIndex(0);
|
||||
spinnerOffset.setValue(offsets[0]);
|
||||
return;
|
||||
case minus:
|
||||
comboMode.setSelectedIndex(1);
|
||||
spinnerOffset.setValue(offsets[1]);
|
||||
return;
|
||||
case lh:
|
||||
comboMode.setSelectedIndex(2);
|
||||
spinnerOffset.setValue(offsets[2]);
|
||||
spinnerAlpha.setValue(0.0);
|
||||
return;
|
||||
case lv:
|
||||
comboMode.setSelectedIndex(2);
|
||||
spinnerOffset.setValue(offsets[3]);
|
||||
spinnerAlpha.setValue(90.0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isManualRun() {
|
||||
return (comboRunType.getSelectedIndex() == 0);
|
||||
}
|
||||
|
||||
void setElement() throws Exception {
|
||||
String selection = comboSetup.getSelectedItem().toString();
|
||||
for (String line : Files.readAllLines(getConfigFile())) {
|
||||
if ((line != null) && (!line.trim().isEmpty())) {
|
||||
String[] tokens = line.split("=");
|
||||
if (tokens.length < 2) {
|
||||
throw new Exception("Invalid file format");
|
||||
}
|
||||
if (tokens[0].equals(selection)) {
|
||||
tokens = tokens[1].trim().split(";");
|
||||
if (tokens.length != 8) {
|
||||
throw new Exception("Invalid file format");
|
||||
}
|
||||
spinnerE1.setValue(Double.valueOf(tokens[0].trim()));
|
||||
spinnerE2.setValue(Double.valueOf(tokens[1].trim()));
|
||||
spinnerTime.setValue(Double.valueOf(tokens[2].trim()));
|
||||
spinnerDelay.setValue(Double.valueOf(tokens[3].trim()));
|
||||
|
||||
offsets[0] = Double.valueOf(tokens[4].trim());
|
||||
offsets[1] = Double.valueOf(tokens[5].trim());
|
||||
offsets[2] = Double.valueOf(tokens[6].trim());
|
||||
offsets[3] = Double.valueOf(tokens[7].trim());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setRunType() throws Exception {
|
||||
switch (comboRunType.getSelectedIndex()) {
|
||||
case 0: //Manual
|
||||
break;
|
||||
case 1: //+
|
||||
setMode(Mode.plus);
|
||||
break;
|
||||
case 2: //-
|
||||
setMode(Mode.minus);
|
||||
break;
|
||||
case 3: //LH
|
||||
setMode(Mode.lh);
|
||||
break;
|
||||
case 4: //LV
|
||||
setMode(Mode.lv);
|
||||
break;
|
||||
case 5: //+/-
|
||||
setMode(Mode.plus);
|
||||
break;
|
||||
case 6: //+/-/-/+
|
||||
setMode(Mode.plus);
|
||||
break;
|
||||
case 7: //LH/LV
|
||||
setMode(Mode.lh);
|
||||
break;
|
||||
case 8: //LH/LV/LV/LH
|
||||
setMode(Mode.lh);
|
||||
break;
|
||||
}
|
||||
checkParameterControls();
|
||||
}
|
||||
|
||||
void run() throws Exception {
|
||||
HashMap args = new HashMap();
|
||||
Double e1 = (Double) spinnerE1.getValue();
|
||||
Double e2 = (Double) spinnerE2.getValue();
|
||||
args.put("E1", e1);
|
||||
args.put("E2", e2);
|
||||
args.put("TIME", (Double) spinnerTime.getValue());
|
||||
args.put("DELAY", (Double) spinnerDelay.getValue());
|
||||
args.put("MODE", comboMode.getSelectedItem().toString());
|
||||
args.put("OFFSET", checkSetOffset.isSelected() ? (Double) spinnerOffset.getValue() : null);
|
||||
args.put("ALPHA", (Double) spinnerAlpha.getValue());
|
||||
|
||||
String file = expandPath(textFile.getText());
|
||||
args.put("NAME", file);
|
||||
buttonAbort.setEnabled(true);
|
||||
|
||||
runAsync("EnergyScan_ma", args).handle((ok, ex) -> {
|
||||
try{
|
||||
buttonAbort.setEnabled(false);
|
||||
if (ex != null) {
|
||||
stopScan();
|
||||
throw ex;
|
||||
} else {
|
||||
if (batch != null) {
|
||||
batchIndex++;
|
||||
if (batchIndex >= batch.length) {
|
||||
batch = null;
|
||||
} else {
|
||||
setMode(batch[batchIndex]);
|
||||
run();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable t){
|
||||
batch = null;
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
//showException((Exception)ex);
|
||||
}
|
||||
return ok;
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
buttonGroupPlot = new javax.swing.ButtonGroup();
|
||||
panelParameters = new javax.swing.JPanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
spinnerE1 = new javax.swing.JSpinner();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
spinnerE2 = new javax.swing.JSpinner();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
spinnerTime = new javax.swing.JSpinner();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
spinnerDelay = new javax.swing.JSpinner();
|
||||
jLabel5 = new javax.swing.JLabel();
|
||||
comboMode = new javax.swing.JComboBox();
|
||||
jLabel8 = new javax.swing.JLabel();
|
||||
spinnerOffset = new javax.swing.JSpinner();
|
||||
jLabel9 = new javax.swing.JLabel();
|
||||
spinnerAlpha = new javax.swing.JSpinner();
|
||||
checkSetOffset = new javax.swing.JCheckBox();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
comboSetup = new javax.swing.JComboBox();
|
||||
buttonConfigure = new javax.swing.JButton();
|
||||
jLabel10 = new javax.swing.JLabel();
|
||||
jLabel11 = new javax.swing.JLabel();
|
||||
comboRunType = new javax.swing.JComboBox();
|
||||
panelData = new javax.swing.JPanel();
|
||||
buttonDefaults = new javax.swing.JButton();
|
||||
jLabel6 = new javax.swing.JLabel();
|
||||
textFile = new javax.swing.JTextField();
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
buttonExecute = new javax.swing.JButton();
|
||||
buttonAbort = new javax.swing.JButton();
|
||||
|
||||
panelParameters.setBorder(javax.swing.BorderFactory.createTitledBorder((String)null));
|
||||
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel1.setText("E1:");
|
||||
|
||||
spinnerE1.setModel(new javax.swing.SpinnerNumberModel(690.0d, 0.0d, 9999.0d, 1.0d));
|
||||
|
||||
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel2.setText("E2:");
|
||||
|
||||
spinnerE2.setModel(new javax.swing.SpinnerNumberModel(755.0d, 0.0d, 9999.0d, 1.0d));
|
||||
|
||||
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel3.setText("Time(min):");
|
||||
|
||||
spinnerTime.setModel(new javax.swing.SpinnerNumberModel(3.0d, 0.0d, 60.0d, 1.0d));
|
||||
|
||||
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel4.setText("Delay(s):");
|
||||
|
||||
spinnerDelay.setModel(new javax.swing.SpinnerNumberModel(10.0d, 0.0d, 600.0d, 1.0d));
|
||||
|
||||
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel5.setText("Mode:");
|
||||
|
||||
comboMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "CIRC +", "CIRC -", "LINEAR" }));
|
||||
comboMode.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
comboModeActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel8.setText("Offset:");
|
||||
|
||||
spinnerOffset.setModel(new javax.swing.SpinnerNumberModel(0.0d, -20.0d, 20.0d, 1.0d));
|
||||
spinnerOffset.setEnabled(false);
|
||||
|
||||
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel9.setText("Alpha:");
|
||||
|
||||
spinnerAlpha.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 90.0d, 1.0d));
|
||||
|
||||
checkSetOffset.setText("Set Offset");
|
||||
checkSetOffset.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
checkSetOffsetActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout panelParametersLayout = new javax.swing.GroupLayout(panelParameters);
|
||||
panelParameters.setLayout(panelParametersLayout);
|
||||
panelParametersLayout.setHorizontalGroup(
|
||||
panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(spinnerE1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(spinnerTime, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(comboMode, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(checkSetOffset))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(spinnerE2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(spinnerDelay, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(spinnerAlpha, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel8)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spinnerOffset, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboMode, spinnerE1, spinnerTime});
|
||||
|
||||
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2, jLabel4, jLabel8, jLabel9});
|
||||
|
||||
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerAlpha, spinnerDelay, spinnerE2, spinnerOffset});
|
||||
|
||||
panelParametersLayout.setVerticalGroup(
|
||||
panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(spinnerE1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(spinnerE2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3)
|
||||
.addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel4)
|
||||
.addComponent(spinnerDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel5)
|
||||
.addComponent(comboMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(spinnerAlpha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel9))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel8)
|
||||
.addComponent(spinnerOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(checkSetOffset))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder((String)null));
|
||||
|
||||
comboSetup.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
comboSetupActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonConfigure.setText("Configure");
|
||||
buttonConfigure.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonConfigureActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel10.setText("Element:");
|
||||
|
||||
jLabel11.setText("Run Type:");
|
||||
|
||||
comboRunType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Manual", "+", "-", "LH", "LV", "+/-", "+/-/-/+", "LH/LV", "LH/LV/LV/LH" }));
|
||||
comboRunType.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
comboRunTypeActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap(22, Short.MAX_VALUE)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(comboRunType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(comboSetup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(buttonConfigure)))
|
||||
.addContainerGap(22, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboRunType, comboSetup});
|
||||
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(4, 4, 4)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(comboSetup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel10)
|
||||
.addComponent(buttonConfigure))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel11)
|
||||
.addComponent(comboRunType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
panelData.setBorder(javax.swing.BorderFactory.createTitledBorder((String)null));
|
||||
|
||||
buttonDefaults.setText("Default");
|
||||
buttonDefaults.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonDefaultsActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel6.setText("File:");
|
||||
|
||||
javax.swing.GroupLayout panelDataLayout = new javax.swing.GroupLayout(panelData);
|
||||
panelData.setLayout(panelDataLayout);
|
||||
panelDataLayout.setHorizontalGroup(
|
||||
panelDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelDataLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel6)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textFile)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonDefaults)
|
||||
.addContainerGap())
|
||||
);
|
||||
panelDataLayout.setVerticalGroup(
|
||||
panelDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelDataLayout.createSequentialGroup()
|
||||
.addGroup(panelDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel6)
|
||||
.addComponent(textFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonDefaults, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder((String)null));
|
||||
|
||||
buttonExecute.setText("Start");
|
||||
buttonExecute.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonExecuteActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonAbort.setText("Abort");
|
||||
buttonAbort.setEnabled(false);
|
||||
buttonAbort.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonAbortActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
||||
jPanel3.setLayout(jPanel3Layout);
|
||||
jPanel3Layout.setHorizontalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap(22, Short.MAX_VALUE)
|
||||
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonExecute, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(22, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel3Layout.setVerticalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
|
||||
.addGap(4, 4, 4)
|
||||
.addComponent(buttonExecute)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonAbort)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(panelData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGap(0, 0, 0))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(16, 16, 16)
|
||||
.addComponent(panelParameters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(panelData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jPanel1, jPanel3});
|
||||
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed
|
||||
try {
|
||||
batchIndex = 0;
|
||||
switch (comboRunType.getSelectedIndex()) {
|
||||
case 5:
|
||||
batch = new Mode[]{Mode.plus, Mode.minus};
|
||||
break;
|
||||
case 6:
|
||||
batch = new Mode[]{Mode.plus, Mode.minus, Mode.minus, Mode.plus};
|
||||
break;
|
||||
case 7:
|
||||
batch = new Mode[]{Mode.lh, Mode.lv};
|
||||
break;
|
||||
case 8:
|
||||
batch = new Mode[]{Mode.lh, Mode.lv, Mode.lv, Mode.lh};
|
||||
break;
|
||||
default:
|
||||
batch = null;
|
||||
}
|
||||
run();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonExecuteActionPerformed
|
||||
|
||||
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
|
||||
batch = null;
|
||||
try {
|
||||
abort();
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
}//GEN-LAST:event_buttonAbortActionPerformed
|
||||
|
||||
private void comboSetupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboSetupActionPerformed
|
||||
try {
|
||||
if (comboSetup.getSelectedItem() != null) {
|
||||
setElement();
|
||||
if (!isManualRun()) {
|
||||
setRunType();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_comboSetupActionPerformed
|
||||
|
||||
EditorDialog dlgConfig;
|
||||
private void buttonConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigureActionPerformed
|
||||
try {
|
||||
//Desktop.getDesktop().open(getConfigFile().toFile());
|
||||
if ((dlgConfig == null) || (!dlgConfig.isShowing())) {
|
||||
String[] columns = new String[]{"Element", "E1", "E2", "Time", "Delay", "OffPlus", "OffMinus", "OffLH", "OffLV"};
|
||||
Class[] types = new Class[]{String.class, Double.class, Double.class, Double.class, Double.class, Double.class, Double.class, Double.class, Double.class};
|
||||
DsvEditor editor = new DsvEditor(columns, types, ";");
|
||||
dlgConfig = editor.getDialog(getView(), false);
|
||||
editor.load(getConfigFile().toString());
|
||||
editor.setTitle("Energy Scan Configuration");
|
||||
dlgConfig.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
if (System.currentTimeMillis() - new File(dlgConfig.getEditor().getFileName()).lastModified() < 5000) {
|
||||
loadConfig();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
dlgConfig.setSize(680, 320);
|
||||
showWindow(dlgConfig);
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonConfigureActionPerformed
|
||||
|
||||
private void comboModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboModeActionPerformed
|
||||
checkParameterControls();
|
||||
}//GEN-LAST:event_comboModeActionPerformed
|
||||
|
||||
private void comboRunTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboRunTypeActionPerformed
|
||||
try {
|
||||
if (!isManualRun()) {
|
||||
setElement();
|
||||
}
|
||||
setRunType();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_comboRunTypeActionPerformed
|
||||
|
||||
private void buttonDefaultsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDefaultsActionPerformed
|
||||
textFile.setText("{el}_{mode}");
|
||||
}//GEN-LAST:event_buttonDefaultsActionPerformed
|
||||
|
||||
private void checkSetOffsetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkSetOffsetActionPerformed
|
||||
spinnerOffset.setEnabled(checkSetOffset.isSelected());
|
||||
}//GEN-LAST:event_checkSetOffsetActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonAbort;
|
||||
private javax.swing.JButton buttonConfigure;
|
||||
private javax.swing.JButton buttonDefaults;
|
||||
private javax.swing.JButton buttonExecute;
|
||||
private javax.swing.ButtonGroup buttonGroupPlot;
|
||||
private javax.swing.JCheckBox checkSetOffset;
|
||||
private javax.swing.JComboBox comboMode;
|
||||
private javax.swing.JComboBox comboRunType;
|
||||
private javax.swing.JComboBox comboSetup;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel10;
|
||||
private javax.swing.JLabel jLabel11;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JLabel jLabel6;
|
||||
private javax.swing.JLabel jLabel8;
|
||||
private javax.swing.JLabel jLabel9;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
private javax.swing.JPanel panelData;
|
||||
private javax.swing.JPanel panelParameters;
|
||||
private javax.swing.JSpinner spinnerAlpha;
|
||||
private javax.swing.JSpinner spinnerDelay;
|
||||
private javax.swing.JSpinner spinnerE1;
|
||||
private javax.swing.JSpinner spinnerE2;
|
||||
private javax.swing.JSpinner spinnerOffset;
|
||||
private javax.swing.JSpinner spinnerTime;
|
||||
private javax.swing.JTextField textFile;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
64
plugins/PersonalizedTheme.java
Normal file
64
plugins/PersonalizedTheme.java
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
import ch.psi.pshell.ui.Preferences;
|
||||
import ch.psi.pshell.swing.ScriptEditor;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.Font;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
public class PersonalizedTheme implements Plugin {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
try {
|
||||
Font font = new Font("Verdana", Font.PLAIN, 16);
|
||||
UIManager.put("Button.font", font);
|
||||
UIManager.put("ToggleButton.font", font);
|
||||
UIManager.put("RadioButton.font", font);
|
||||
UIManager.put("CheckBox.font", font);
|
||||
UIManager.put("ColorChooser.font", font);
|
||||
UIManager.put("ComboBox.font", font);
|
||||
UIManager.put("Label.font", font);
|
||||
UIManager.put("List.font", font);
|
||||
UIManager.put("MenuBar.font", font);
|
||||
UIManager.put("MenuItem.font", font);
|
||||
UIManager.put("RadioButtonMenuItem.font", font);
|
||||
UIManager.put("CheckBoxMenuItem.font", font);
|
||||
UIManager.put("Menu.font", font);
|
||||
UIManager.put("PopupMenu.font", font);
|
||||
UIManager.put("OptionPane.font", font);
|
||||
UIManager.put("Panel.font", font);
|
||||
UIManager.put("ProgressBar.font", font);
|
||||
UIManager.put("ScrollPane.font", font);
|
||||
UIManager.put("Viewport.font", font);
|
||||
UIManager.put("TabbedPane.font", font);
|
||||
UIManager.put("Table.font", font);
|
||||
UIManager.put("TableHeader.font", font);
|
||||
UIManager.put("TextField.font", font);
|
||||
UIManager.put("PasswordField.font", font);
|
||||
UIManager.put("TextArea.font", font);
|
||||
UIManager.put("TextPane.font", font);
|
||||
UIManager.put("EditorPane.font", font);
|
||||
UIManager.put("TitledBorder.font", font);
|
||||
UIManager.put("ToolBar.font", font);
|
||||
UIManager.put("ToolTip.font", font);
|
||||
UIManager.put("Tree.font", font);
|
||||
|
||||
SwingUtils.updateAllFrames();
|
||||
|
||||
|
||||
SwingUtils.invokeDelayed( ()->{
|
||||
Preferences preferences = getView().getPreferences();
|
||||
for (ScriptEditor editor : getView().getEditors()){
|
||||
editor.setTextPaneFont(preferences.fontEditor);
|
||||
}
|
||||
}, 250);
|
||||
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
425
script/2018_0905_090323_BeamMovementsMicroscope.py
Normal file
425
script/2018_0905_090323_BeamMovementsMicroscope.py
Normal file
@@ -0,0 +1,425 @@
|
||||
#Script imported from: 2018_0905_090323_BeamMovementsMicroscope.xml
|
||||
|
||||
#Pre-actions
|
||||
caput('X07MB-OP2:START-CSMPL', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:StopAll', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:CollectMode', '0')
|
||||
sleep(0.2)
|
||||
caput('X07MB-XMAP:Apply', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:PresetReal', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP2:TOTAL-CYCLES', '5')
|
||||
sleep(0.1)
|
||||
caput('X07MB-ES1-PP2:VO5', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP-WV1:WT_SET', '1')
|
||||
sleep(0.1)
|
||||
|
||||
#TODO: Set the diplay names of positioners and detectors
|
||||
scan = ManualScan(['Energy'], ['ScanX_set', 'ScanY_set', 'ROT_set', 'TRX1_set', 'TRZ1_set', 'DET_set', 'Energy_set', 'Mono_offset', 'I_SLS', 'I0_KEITHLEY1', 'KEITHLEY1_GAIN', 'I1_KEITHLEY2', 'KEITHLEY2_GAIN', 'KEITHLEY3', 'KEITHLEY3_GAIN', 'XBPM3_GAIN', 'XBPM3_SAI14_CUR_MEAN', 'XBPM3_SAI15_CUR_MEAN', 'XBPM3_SAI16_CUR_MEAN', 'XBPM3_SAI17_CUR_MEAN', 'XBPM3_POSX', 'XBPM3_POSY', 'XBPM4_GAIN', 'XBPM4_SAI19_CUR_MEAN', 'XBPM4_SAI20_CUR_MEAN', 'XBPM4_SAI21_CUR_MEAN', 'XBPM4_SAI22_CUR_MEAN', 'XBPM4_POSX', 'XBPM4_POSY', 'D1_Si', 'D1_ICR', 'D1_OCR', 'DD1_ELTM', 'DD1_ERTM', 'DD1_DTIM', 'Spec_1[2048]', 'MONO_THETA_TC1', 'MONO_TRX_TC1', 'MONO_C2_TC_Z', 'MONO_C2_TC_Y', 'MONO_TC1', 'MONO_TC2', 'MONO_TC3', 'MONO_TC4', 'MONO_TC5', 'MONO_TC6', 'MONO_TC7', 'MONO_TC8', 'MONO_TC9', 'MONO_TC10', 'MONO_TC11', 'MONO_TC12', 'MONO_TC13', 'MONO_TC14', 'MONO_TC15', 'MONO_TC16', 'ES1MF1', 'ES1MC1', 'OPKBMF1', 'OPSL2MF1', 'Mic_X', 'Mic_Y', 'Mic_sigma_X', 'Mic_Sigma_Y', 'Theta', 'Pitch', 'Roll', 'D1_Si_corr', 'Si_sum_cps'] , [3900.0], [5000.0], [220])
|
||||
scan.start()
|
||||
|
||||
#Creating channels: dimension 1
|
||||
#RegionPositioner Energy
|
||||
Energy = Channel('X07MB-OP-MO:E-SET', type = 'd')
|
||||
EnergyReadback = Channel('X07MB-OP-MO:E-GET', type = 'd')
|
||||
#ScalarDetector ScanX_set
|
||||
ScanX_set = Channel('X07MB-ES-MA1:ScanX.VAL', type = 'd')
|
||||
#ScalarDetector ScanY_set
|
||||
ScanY_set = Channel('X07MB-ES-MA1:ScanY.VAL', type = 'd')
|
||||
#ScalarDetector ROT_set
|
||||
ROT_set = Channel('X07MB-ES-MA1:ROT.VAL', type = 'd')
|
||||
#ScalarDetector TRX1_set
|
||||
TRX1_set = Channel('X07MB-ES-MA1:TRX1.VAL', type = 'd')
|
||||
#ScalarDetector TRZ1_set
|
||||
TRZ1_set = Channel('X07MB-ES-MA1:TRZ1.VAL', type = 'd')
|
||||
#ScalarDetector DET_set
|
||||
DET_set = Channel('X07MB-ES-RONTEC:TRX.VAL', type = 'd')
|
||||
#ScalarDetector Energy_set
|
||||
Energy_set = Channel('X07MB-OP-MO:E-SET', type = 'd')
|
||||
#ScalarDetector Mono_offset
|
||||
Mono_offset = Channel('X07MB-OP-MO:BEAM-OFS', type = 'd')
|
||||
#ScalarDetector I_SLS
|
||||
I_SLS = Channel('ARIDI-PCT:CURRENT', type = 'd')
|
||||
#ScalarDetector I0_KEITHLEY1
|
||||
I0_KEITHLEY1 = Channel('X07MB-OP2-SAI_07:MEAN', type = 'd')
|
||||
#ScalarDetector KEITHLEY1_GAIN
|
||||
KEITHLEY1_GAIN = Channel('X07MB-OP-KEITH1:setGain', type = 'd')
|
||||
#ScalarDetector I1_KEITHLEY2
|
||||
I1_KEITHLEY2 = Channel('X07MB-OP2-SAI_08:MEAN', type = 'd')
|
||||
#ScalarDetector KEITHLEY2_GAIN
|
||||
KEITHLEY2_GAIN = Channel('X07MB-OP-KEITH2:setGain', type = 'd')
|
||||
#ScalarDetector KEITHLEY3
|
||||
KEITHLEY3 = Channel('X07MB-OP2-SAI_06:MEAN', type = 'd')
|
||||
#ScalarDetector KEITHLEY3_GAIN
|
||||
KEITHLEY3_GAIN = Channel('X07MB-OP-KEITH3:setGain', type = 'd')
|
||||
#ScalarDetector XBPM3_GAIN
|
||||
XBPM3_GAIN = Channel('X07MB-OP2:LCAD3-GAIN', type = 'd')
|
||||
#ScalarDetector XBPM3_SAI14_CUR_MEAN
|
||||
XBPM3_SAI14_CUR_MEAN = Channel('X07MB-OP2-SAI_14:CUR-MEAN', type = 'd')
|
||||
#ScalarDetector XBPM3_SAI15_CUR_MEAN
|
||||
XBPM3_SAI15_CUR_MEAN = Channel('X07MB-OP2-SAI_15:CUR-MEAN', type = 'd')
|
||||
#ScalarDetector XBPM3_SAI16_CUR_MEAN
|
||||
XBPM3_SAI16_CUR_MEAN = Channel('X07MB-OP2-SAI_16:CUR-MEAN', type = 'd')
|
||||
#ScalarDetector XBPM3_SAI17_CUR_MEAN
|
||||
XBPM3_SAI17_CUR_MEAN = Channel('X07MB-OP2-SAI_17:CUR-MEAN', type = 'd')
|
||||
#ScalarDetector XBPM3_POSX
|
||||
XBPM3_POSX = Channel('X07MB-OP-BPM3:POSX', type = 'd')
|
||||
#ScalarDetector XBPM3_POSY
|
||||
XBPM3_POSY = Channel('X07MB-OP-BPM3:POSY', type = 'd')
|
||||
#ScalarDetector XBPM4_GAIN
|
||||
XBPM4_GAIN = Channel('X07MB-OP2:LCAD3-GAIN', type = 'd')
|
||||
#ScalarDetector XBPM4_SAI19_CUR_MEAN
|
||||
XBPM4_SAI19_CUR_MEAN = Channel('X07MB-OP2-SAI_19:CUR-MEAN', type = 'd')
|
||||
#ScalarDetector XBPM4_SAI20_CUR_MEAN
|
||||
XBPM4_SAI20_CUR_MEAN = Channel('X07MB-OP2-SAI_20:CUR-MEAN', type = 'd')
|
||||
#ScalarDetector XBPM4_SAI21_CUR_MEAN
|
||||
XBPM4_SAI21_CUR_MEAN = Channel('X07MB-OP2-SAI_21:CUR-MEAN', type = 'd')
|
||||
#ScalarDetector XBPM4_SAI22_CUR_MEAN
|
||||
XBPM4_SAI22_CUR_MEAN = Channel('X07MB-OP2-SAI_22:CUR-MEAN', type = 'd')
|
||||
#ScalarDetector XBPM4_POSX
|
||||
XBPM4_POSX = Channel('X07MB-OP-BPM4:POSX', type = 'd')
|
||||
#ScalarDetector XBPM4_POSY
|
||||
XBPM4_POSY = Channel('X07MB-OP-BPM4:POSY', type = 'd')
|
||||
#ScalarDetector D1_Si
|
||||
D1_Si = Channel('X07MB-XMAP:mca1.R0', type = 'd')
|
||||
#ScalarDetector D1_ICR
|
||||
D1_ICR = Channel('X07MB-XMAP:dxp1:InputCountRate', type = 'd')
|
||||
#ScalarDetector D1_OCR
|
||||
D1_OCR = Channel('X07MB-XMAP:dxp1:OutputCountRate', type = 'd')
|
||||
#ScalarDetector DD1_ELTM
|
||||
DD1_ELTM = Channel('X07MB-XMAP:mca1.ELTM', type = 'd')
|
||||
#ScalarDetector DD1_ERTM
|
||||
DD1_ERTM = Channel('X07MB-XMAP:mca1.ERTM', type = 'd')
|
||||
#ScalarDetector DD1_DTIM
|
||||
DD1_DTIM = Channel('X07MB-XMAP:mca1.DTIM', type = 'd')
|
||||
#ArrayDetector Spec_1
|
||||
Spec_1 = Channel('X07MB-XMAP:mca1.VAL', type = '[d', size = 2048)
|
||||
#ScalarDetector MONO_THETA_TC1
|
||||
MONO_THETA_TC1 = Channel('X07MB-OP-MOTHETA:TC1', type = 'd')
|
||||
#ScalarDetector MONO_TRX_TC1
|
||||
MONO_TRX_TC1 = Channel('X07MB-OP-MOTRX:TC1', type = 'd')
|
||||
#ScalarDetector MONO_C2_TC_Z
|
||||
MONO_C2_TC_Z = Channel('X07MB-OP-MOC2:TC_Z', type = 'd')
|
||||
#ScalarDetector MONO_C2_TC_Y
|
||||
MONO_C2_TC_Y = Channel('X07MB-OP-MOC2:TC_Y', type = 'd')
|
||||
#ScalarDetector MONO_TC1
|
||||
MONO_TC1 = Channel('X07MB-OP-MO:TC1', type = 'd')
|
||||
#ScalarDetector MONO_TC2
|
||||
MONO_TC2 = Channel('X07MB-OP-MO:TC2', type = 'd')
|
||||
#ScalarDetector MONO_TC3
|
||||
MONO_TC3 = Channel('X07MB-OP-MO:TC3', type = 'd')
|
||||
#ScalarDetector MONO_TC4
|
||||
MONO_TC4 = Channel('X07MB-OP-MO:TC4', type = 'd')
|
||||
#ScalarDetector MONO_TC5
|
||||
MONO_TC5 = Channel('X07MB-OP-MO:TC5', type = 'd')
|
||||
#ScalarDetector MONO_TC6
|
||||
MONO_TC6 = Channel('X07MB-OP-MO:TC6', type = 'd')
|
||||
#ScalarDetector MONO_TC7
|
||||
MONO_TC7 = Channel('X07MB-OP-MO:TC7', type = 'd')
|
||||
#ScalarDetector MONO_TC8
|
||||
MONO_TC8 = Channel('X07MB-OP-MO:TC8', type = 'd')
|
||||
#ScalarDetector MONO_TC9
|
||||
MONO_TC9 = Channel('X07MB-OP-MO:TC9', type = 'd')
|
||||
#ScalarDetector MONO_TC10
|
||||
MONO_TC10 = Channel('X07MB-OP-MO:TC10', type = 'd')
|
||||
#ScalarDetector MONO_TC11
|
||||
MONO_TC11 = Channel('X07MB-OP-MO:TC11', type = 'd')
|
||||
#ScalarDetector MONO_TC12
|
||||
MONO_TC12 = Channel('X07MB-OP-MO:TC12', type = 'd')
|
||||
#ScalarDetector MONO_TC13
|
||||
MONO_TC13 = Channel('X07MB-OP-MO:TC13', type = 'd')
|
||||
#ScalarDetector MONO_TC14
|
||||
MONO_TC14 = Channel('X07MB-OP-MO:TC14', type = 'd')
|
||||
#ScalarDetector MONO_TC15
|
||||
MONO_TC15 = Channel('X07MB-OP-MO:TC15', type = 'd')
|
||||
#ScalarDetector MONO_TC16
|
||||
MONO_TC16 = Channel('X07MB-OP-MO:TC16', type = 'd')
|
||||
#ScalarDetector ES1MF1
|
||||
ES1MF1 = Channel('X07MB-ES1-MF1:PRESSURE', type = 'd')
|
||||
#ScalarDetector ES1MC1
|
||||
ES1MC1 = Channel('X07MB-ES1-MC1:PRESSURE', type = 'd')
|
||||
#ScalarDetector OPKBMF1
|
||||
OPKBMF1 = Channel('X07MB-OP-KBMF1:PRESSURE', type = 'd')
|
||||
#ScalarDetector OPSL2MF1
|
||||
OPSL2MF1 = Channel('X07MB-OP-SL2MF1:PRESSURE', type = 'd')
|
||||
#ScalarDetector Mic_X
|
||||
Mic_X = Channel('X07MB-PC-PSCAN:CAM1-BEAMPOS_X', type = 'd')
|
||||
#ScalarDetector Mic_Y
|
||||
Mic_Y = Channel('X07MB-PC-PSCAN:CAM1-BEAMPOS_Y', type = 'd')
|
||||
#ScalarDetector Mic_sigma_X
|
||||
Mic_sigma_X = Channel('X07MB-PC-PSCAN:CAM1-SIGMA_X', type = 'd')
|
||||
#ScalarDetector Mic_Sigma_Y
|
||||
Mic_Sigma_Y = Channel('X07MB-PC-PSCAN:CAM1-SIGMA_Y', type = 'd')
|
||||
#ScalarDetector Theta
|
||||
Theta = Channel('X07MB-OP-MO:THETA.RBV', type = 'd')
|
||||
#ScalarDetector Pitch
|
||||
Pitch = Channel('X07MB-OP-MO:C2-ROX.RBV', type = 'd')
|
||||
#ScalarDetector Roll
|
||||
Roll = Channel('X07MB-OP-MO:C2-ROZ.RBV', type = 'd')
|
||||
|
||||
#Dimension 1
|
||||
#RegionPositioner Energy
|
||||
for setpoint1 in frange(3900.0, 5000.0, 5.0, True):
|
||||
#Region 1 pre-actions
|
||||
if setpoint1 == 3900.0:
|
||||
caput('X07MB-OP2:TOTAL-CYCLES', '5')
|
||||
sleep(5.0)
|
||||
Energy.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
|
||||
readback1 = EnergyReadback.get()
|
||||
if abs(readback1 - setpoint1) > 2.5 : # TODO: Check accuracy
|
||||
raise Exception('Actor Energy could not be set to the value ' + str(setpoint1))
|
||||
sleep( 3.0 ) # Settling time
|
||||
#Dimension Actions
|
||||
caputq('X07MB-XMAP:EraseStart', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.1)
|
||||
cawait('X07MB-OP2:SMPL-DONE', 1, type = 'l')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:StopAll', '1')
|
||||
sleep(0.1)
|
||||
#Detector ScanX_set
|
||||
detector1 = ScanX_set.get()
|
||||
#Detector ScanY_set
|
||||
detector2 = ScanY_set.get()
|
||||
#Detector ROT_set
|
||||
detector3 = ROT_set.get()
|
||||
#Detector TRX1_set
|
||||
detector4 = TRX1_set.get()
|
||||
#Detector TRZ1_set
|
||||
detector5 = TRZ1_set.get()
|
||||
#Detector DET_set
|
||||
detector6 = DET_set.get()
|
||||
#Detector Energy_set
|
||||
detector7 = Energy_set.get()
|
||||
#Detector Mono_offset
|
||||
detector8 = Mono_offset.get()
|
||||
#Detector I_SLS
|
||||
detector9 = I_SLS.get()
|
||||
#Detector I0_KEITHLEY1
|
||||
detector10 = I0_KEITHLEY1.get()
|
||||
#Detector KEITHLEY1_GAIN
|
||||
detector11 = KEITHLEY1_GAIN.get()
|
||||
#Detector I1_KEITHLEY2
|
||||
detector12 = I1_KEITHLEY2.get()
|
||||
#Detector KEITHLEY2_GAIN
|
||||
detector13 = KEITHLEY2_GAIN.get()
|
||||
#Detector KEITHLEY3
|
||||
detector14 = KEITHLEY3.get()
|
||||
#Detector KEITHLEY3_GAIN
|
||||
detector15 = KEITHLEY3_GAIN.get()
|
||||
#Detector XBPM3_GAIN
|
||||
detector16 = XBPM3_GAIN.get()
|
||||
#Detector XBPM3_SAI14_CUR_MEAN
|
||||
detector17 = XBPM3_SAI14_CUR_MEAN.get()
|
||||
#Detector XBPM3_SAI15_CUR_MEAN
|
||||
detector18 = XBPM3_SAI15_CUR_MEAN.get()
|
||||
#Detector XBPM3_SAI16_CUR_MEAN
|
||||
detector19 = XBPM3_SAI16_CUR_MEAN.get()
|
||||
#Detector XBPM3_SAI17_CUR_MEAN
|
||||
detector20 = XBPM3_SAI17_CUR_MEAN.get()
|
||||
#Detector XBPM3_POSX
|
||||
detector21 = XBPM3_POSX.get()
|
||||
#Detector XBPM3_POSY
|
||||
detector22 = XBPM3_POSY.get()
|
||||
#Detector XBPM4_GAIN
|
||||
detector23 = XBPM4_GAIN.get()
|
||||
#Detector XBPM4_SAI19_CUR_MEAN
|
||||
detector24 = XBPM4_SAI19_CUR_MEAN.get()
|
||||
#Detector XBPM4_SAI20_CUR_MEAN
|
||||
detector25 = XBPM4_SAI20_CUR_MEAN.get()
|
||||
#Detector XBPM4_SAI21_CUR_MEAN
|
||||
detector26 = XBPM4_SAI21_CUR_MEAN.get()
|
||||
#Detector XBPM4_SAI22_CUR_MEAN
|
||||
detector27 = XBPM4_SAI22_CUR_MEAN.get()
|
||||
#Detector XBPM4_POSX
|
||||
detector28 = XBPM4_POSX.get()
|
||||
#Detector XBPM4_POSY
|
||||
detector29 = XBPM4_POSY.get()
|
||||
#Detector D1_Si
|
||||
detector30 = D1_Si.get()
|
||||
#Detector D1_ICR
|
||||
detector31 = D1_ICR.get()
|
||||
#Detector D1_OCR
|
||||
detector32 = D1_OCR.get()
|
||||
#Detector DD1_ELTM
|
||||
detector33 = DD1_ELTM.get()
|
||||
#Detector DD1_ERTM
|
||||
detector34 = DD1_ERTM.get()
|
||||
#Detector DD1_DTIM
|
||||
detector35 = DD1_DTIM.get()
|
||||
#Detector Spec_1
|
||||
detector36 = Spec_1.get()
|
||||
#Detector MONO_THETA_TC1
|
||||
detector37 = MONO_THETA_TC1.get()
|
||||
#Detector MONO_TRX_TC1
|
||||
detector38 = MONO_TRX_TC1.get()
|
||||
#Detector MONO_C2_TC_Z
|
||||
detector39 = MONO_C2_TC_Z.get()
|
||||
#Detector MONO_C2_TC_Y
|
||||
detector40 = MONO_C2_TC_Y.get()
|
||||
#Detector MONO_TC1
|
||||
detector41 = MONO_TC1.get()
|
||||
#Detector MONO_TC2
|
||||
detector42 = MONO_TC2.get()
|
||||
#Detector MONO_TC3
|
||||
detector43 = MONO_TC3.get()
|
||||
#Detector MONO_TC4
|
||||
detector44 = MONO_TC4.get()
|
||||
#Detector MONO_TC5
|
||||
detector45 = MONO_TC5.get()
|
||||
#Detector MONO_TC6
|
||||
detector46 = MONO_TC6.get()
|
||||
#Detector MONO_TC7
|
||||
detector47 = MONO_TC7.get()
|
||||
#Detector MONO_TC8
|
||||
detector48 = MONO_TC8.get()
|
||||
#Detector MONO_TC9
|
||||
detector49 = MONO_TC9.get()
|
||||
#Detector MONO_TC10
|
||||
detector50 = MONO_TC10.get()
|
||||
#Detector MONO_TC11
|
||||
detector51 = MONO_TC11.get()
|
||||
#Detector MONO_TC12
|
||||
detector52 = MONO_TC12.get()
|
||||
#Detector MONO_TC13
|
||||
detector53 = MONO_TC13.get()
|
||||
#Detector MONO_TC14
|
||||
detector54 = MONO_TC14.get()
|
||||
#Detector MONO_TC15
|
||||
detector55 = MONO_TC15.get()
|
||||
#Detector MONO_TC16
|
||||
detector56 = MONO_TC16.get()
|
||||
#Detector ES1MF1
|
||||
detector57 = ES1MF1.get()
|
||||
#Detector ES1MC1
|
||||
detector58 = ES1MC1.get()
|
||||
#Detector OPKBMF1
|
||||
detector59 = OPKBMF1.get()
|
||||
#Detector OPSL2MF1
|
||||
detector60 = OPSL2MF1.get()
|
||||
#Detector Mic_X
|
||||
detector61 = Mic_X.get()
|
||||
#Detector Mic_Y
|
||||
detector62 = Mic_Y.get()
|
||||
#Detector Mic_sigma_X
|
||||
detector63 = Mic_sigma_X.get()
|
||||
#Detector Mic_Sigma_Y
|
||||
detector64 = Mic_Sigma_Y.get()
|
||||
#Detector Theta
|
||||
detector65 = Theta.get()
|
||||
#Detector Pitch
|
||||
detector66 = Pitch.get()
|
||||
#Detector Roll
|
||||
detector67 = Roll.get()
|
||||
#Manipulation D1_Si_corr
|
||||
#Variable Mappings
|
||||
a = detector30
|
||||
b = detector31
|
||||
c = detector32
|
||||
d = detector33
|
||||
#TODO: Move, if needed, this import to the file header: import math
|
||||
DeadTime = 1.182e-7
|
||||
ICR = b
|
||||
OCR = c
|
||||
|
||||
Test = 1.e8
|
||||
TestICR = ICR
|
||||
n = 0
|
||||
while ((Test > DeadTime) and (n < 30)):
|
||||
TrueICR = ICR * math.exp(TestICR * DeadTime)
|
||||
Test = (TrueICR - TestICR) / TestICR
|
||||
TestICR = TrueICR
|
||||
n = n + 1
|
||||
D1_Si_corr = a * TrueICR / OCR / d
|
||||
#Manipulation Si_sum_cps
|
||||
#Variable Mappings
|
||||
detector30_corr = detector33
|
||||
detector33 = detector33
|
||||
#TODO: Move, if needed, this import to the file header: import math
|
||||
DeadTime = 1.182e-7
|
||||
SUM_DET = 0.
|
||||
SUM_DET = SUM_DET + detector30_corr
|
||||
Si_sum_cps = SUM_DET
|
||||
scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, detector10, detector11, detector12, detector13, detector14, detector15, detector16, detector17, detector18, detector19, detector20, detector21, detector22, detector23, detector24, detector25, detector26, detector27, detector28, detector29, detector30, detector31, detector32, detector33, detector34, detector35, detector36, detector37, detector38, detector39, detector40, detector41, detector42, detector43, detector44, detector45, detector46, detector47, detector48, detector49, detector50, detector51, detector52, detector53, detector54, detector55, detector56, detector57, detector58, detector59, detector60, detector61, detector62, detector63, detector64, detector65, detector66, detector67, D1_Si_corr, Si_sum_cps])
|
||||
|
||||
#Closing channels
|
||||
Energy.close()
|
||||
EnergyReadback.close()
|
||||
ScanX_set.close()
|
||||
ScanY_set.close()
|
||||
ROT_set.close()
|
||||
TRX1_set.close()
|
||||
TRZ1_set.close()
|
||||
DET_set.close()
|
||||
Energy_set.close()
|
||||
Mono_offset.close()
|
||||
I_SLS.close()
|
||||
I0_KEITHLEY1.close()
|
||||
KEITHLEY1_GAIN.close()
|
||||
I1_KEITHLEY2.close()
|
||||
KEITHLEY2_GAIN.close()
|
||||
KEITHLEY3.close()
|
||||
KEITHLEY3_GAIN.close()
|
||||
XBPM3_GAIN.close()
|
||||
XBPM3_SAI14_CUR_MEAN.close()
|
||||
XBPM3_SAI15_CUR_MEAN.close()
|
||||
XBPM3_SAI16_CUR_MEAN.close()
|
||||
XBPM3_SAI17_CUR_MEAN.close()
|
||||
XBPM3_POSX.close()
|
||||
XBPM3_POSY.close()
|
||||
XBPM4_GAIN.close()
|
||||
XBPM4_SAI19_CUR_MEAN.close()
|
||||
XBPM4_SAI20_CUR_MEAN.close()
|
||||
XBPM4_SAI21_CUR_MEAN.close()
|
||||
XBPM4_SAI22_CUR_MEAN.close()
|
||||
XBPM4_POSX.close()
|
||||
XBPM4_POSY.close()
|
||||
D1_Si.close()
|
||||
D1_ICR.close()
|
||||
D1_OCR.close()
|
||||
DD1_ELTM.close()
|
||||
DD1_ERTM.close()
|
||||
DD1_DTIM.close()
|
||||
Spec_1.close()
|
||||
MONO_THETA_TC1.close()
|
||||
MONO_TRX_TC1.close()
|
||||
MONO_C2_TC_Z.close()
|
||||
MONO_C2_TC_Y.close()
|
||||
MONO_TC1.close()
|
||||
MONO_TC2.close()
|
||||
MONO_TC3.close()
|
||||
MONO_TC4.close()
|
||||
MONO_TC5.close()
|
||||
MONO_TC6.close()
|
||||
MONO_TC7.close()
|
||||
MONO_TC8.close()
|
||||
MONO_TC9.close()
|
||||
MONO_TC10.close()
|
||||
MONO_TC11.close()
|
||||
MONO_TC12.close()
|
||||
MONO_TC13.close()
|
||||
MONO_TC14.close()
|
||||
MONO_TC15.close()
|
||||
MONO_TC16.close()
|
||||
ES1MF1.close()
|
||||
ES1MC1.close()
|
||||
OPKBMF1.close()
|
||||
OPSL2MF1.close()
|
||||
Mic_X.close()
|
||||
Mic_Y.close()
|
||||
Mic_sigma_X.close()
|
||||
Mic_Sigma_Y.close()
|
||||
Theta.close()
|
||||
Pitch.close()
|
||||
Roll.close()
|
||||
|
||||
scan.end()
|
||||
|
||||
#Post-actions
|
||||
caput('X07MB-OP2:START-CSMPL', '1')
|
||||
sleep(0.1)
|
||||
31
script/CPython/GaussFit.py
Normal file
31
script/CPython/GaussFit.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import numpy as np
|
||||
import scipy.optimize
|
||||
|
||||
|
||||
# Profile statistics ####
|
||||
def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None):
|
||||
if off is None:
|
||||
off = y.min() # good enough starting point for offset
|
||||
|
||||
if com is None:
|
||||
com = x[y.argmax()]
|
||||
|
||||
if amp is None:
|
||||
amp = y.max() - off
|
||||
|
||||
# For normalised gauss curve sigma=1/(amp*sqrt(2*pi))
|
||||
if sigma is None:
|
||||
surface = np.trapz((y-off), x=x)
|
||||
sigma = surface / (amp * np.sqrt(2 * np.pi))
|
||||
try:
|
||||
popt, pcov = scipy.optimize.curve_fit(gauss_fn, x, y, p0=[off, amp, com, sigma], method='lm')
|
||||
popt[3] = abs(popt[3]) # sigma should be returned as positive
|
||||
except Exception as e:
|
||||
print("Gauss fitting not successful.\n" + str(e))
|
||||
popt = [off, amp, com, abs(sigma)]
|
||||
|
||||
return popt
|
||||
|
||||
|
||||
def gauss_fn(x, a, b, c, d):
|
||||
return a + b * np.exp(-(np.power((x - c), 2) / (2 * np.power(d, 2))))
|
||||
9
script/CPython/GaussFit_wrapper.py
Normal file
9
script/CPython/GaussFit_wrapper.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from jeputils import *
|
||||
|
||||
MODULE = "CPython/GaussFit"
|
||||
|
||||
def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None):
|
||||
ret = call_jep(MODULE, "profile_gauss_stats", [to_npa(x), to_npa(y), off, amp, com, sigma])
|
||||
return ret if ret is None or is_list(ret) else ret.data
|
||||
|
||||
|
||||
96
script/EnergyScan_ma.py
Normal file
96
script/EnergyScan_ma.py
Normal file
@@ -0,0 +1,96 @@
|
||||
#Debugging
|
||||
if get_exec_pars().args is None:
|
||||
E1 = 974
|
||||
E2 = 978
|
||||
TIME = 1 #min
|
||||
DELAY = 0.0 #s
|
||||
MODE = None #'LINEAR' #'CIRC +'
|
||||
OFFSET = None
|
||||
NAME = 'Test'
|
||||
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)
|
||||
|
||||
#Pre-actions
|
||||
wait_beam()
|
||||
wait_id_ok()
|
||||
|
||||
set_pol(MODE, ALPHA, OFFSET)
|
||||
set_energy_ma(float(E1))
|
||||
caput(energy_ma_rbv.channelName+".N", 10) # set energy readback averaging to 10 pts
|
||||
|
||||
print "Setup OTF"
|
||||
caput('E1', E1)
|
||||
caput('E2', E2)
|
||||
caput('TIME', TIME)
|
||||
caput('FOLDER', "OTF/" + get_context().setup.expandPath("OTF/{year}_{month}/{date}"))
|
||||
caput('FILE', NAME)
|
||||
|
||||
time.sleep(max(DELAY, 0.1))
|
||||
|
||||
#Scan
|
||||
print "Start OTF"
|
||||
scan_completed = False
|
||||
try:
|
||||
while True:
|
||||
caput('START', '1')
|
||||
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())
|
||||
|
||||
snaps = (pol_mode, pol_angle,pol_offset)
|
||||
diags = (current.cache) #Must use cache because mscan evensts are called from monitor callback tread (or else async=False). Sensors are automatically handled.
|
||||
sensors = [energy_ma_rbv, cadc1, cadc2, cadc3, cadc4, cadc5, norm_tey(), norm_diode(), tm]
|
||||
|
||||
tm.setAlias("time")
|
||||
cadc1.setAlias("tey_raw")
|
||||
cadc2.setAlias("i0")
|
||||
cadc3.setAlias("diode_raw")
|
||||
|
||||
def monitoring_task():
|
||||
global scan_completed
|
||||
time.sleep(1.0)
|
||||
wait_channel('START', 'STOP', type = 's')
|
||||
scan_completed = True
|
||||
get_exec_pars().currentScan.abort()
|
||||
|
||||
monitoring_future = fork(monitoring_task)[0]
|
||||
|
||||
print "Scanning...",
|
||||
try:
|
||||
mscan( energy_ma_rbv, sensors, -1, None, \
|
||||
range="auto",domain_axis=energy_ma_rbv.name, \
|
||||
enabled_plots=["norm_tey", "norm_diode", cadc1, cadc3, cadc2], \
|
||||
snaps=snaps, diags=diags)
|
||||
finally:
|
||||
monitoring_future.cancel(True)
|
||||
|
||||
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()
|
||||
print("Aborting...")
|
||||
while caget('START') == 'START':
|
||||
caput('START', '0')
|
||||
time.sleep(0.1)
|
||||
raise
|
||||
139
script/Mono_pitch.py
Normal file
139
script/Mono_pitch.py
Normal file
@@ -0,0 +1,139 @@
|
||||
#Script imported from: Mono_pitch.xml
|
||||
|
||||
#Pre-actions
|
||||
caput('X07MB-OP2:START-CSMPL', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:StopAll', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:PresetMode', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:PresetReal', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP2:TOTAL-CYCLES', '1')
|
||||
sleep(0.1)
|
||||
print('dd')
|
||||
|
||||
#TODO: Set the diplay names of positioners and detectors
|
||||
scan = ManualScan(['Pitch'], ['bm3', 'bm4', 'Filter_RY', 'Harmonic', 'TC_Y', 'TC_Z', 'T_THETA', 'Id_OFF', 'Id_energy', 'E_Mono', 'Bragg_Id_theo', 'Theta_rbv', 'Theta_offset', 'Delta_E', 'Delta_theta', 'XX'] , [-10700.0], [-10750.0], [25])
|
||||
scan.start()
|
||||
|
||||
#Creating channels: dimension 1
|
||||
#LinearPositioner Pitch
|
||||
Pitch = Channel('X07MB-OP-MO:C2-ROX.VAL', type = 'd')
|
||||
PitchReadback = Channel('X07MB-OP-MO:C2-ROX.RBV', type = 'd')
|
||||
#ScalarDetector bm3
|
||||
bm3 = Channel('X07MB-OP2-SAI_03:MEAN', type = 'd')
|
||||
#ScalarDetector bm4
|
||||
bm4 = Channel('X07MB-OP2-SAI_04:MEAN', type = 'd')
|
||||
#ScalarDetector Filter_RY
|
||||
Filter_RY = Channel('X07MB-OP-FI:ROY.VAL', type = 'd')
|
||||
#ScalarDetector Harmonic
|
||||
Harmonic = Channel('X07MA-ID:HARMONIC', type = 'd')
|
||||
#ScalarDetector TC_Y
|
||||
TC_Y = Channel('X07MB-OP-MOC2:TC_Y', type = 'd')
|
||||
#ScalarDetector TC_Z
|
||||
TC_Z = Channel('X07MB-OP-MOC2:TC_Z', type = 'd')
|
||||
#ScalarDetector T_THETA
|
||||
T_THETA = Channel('X07MB-OP-MOTHETA:TC1', type = 'd')
|
||||
#ScalarDetector Id_OFF
|
||||
Id_OFF = Channel('X07MA-ID:ENERGY-OFFS', type = 'd')
|
||||
#ScalarDetector Id_energy
|
||||
Id_energy = Channel('X07MA-ID:ENERGY', type = 'd')
|
||||
#ScalarDetector E_Mono
|
||||
E_Mono = Channel('X07MB-OP-MO:E-GET', type = 'd')
|
||||
#ScalarDetector Bragg_Id_theo
|
||||
Bragg_Id_theo = Channel('X07MB-OP-MO:BRAGG-CALC', type = 'd')
|
||||
#ScalarDetector Theta_rbv
|
||||
Theta_rbv = Channel('X07MB-OP-MO:THETA.RBV', type = 'd')
|
||||
#ScalarDetector Theta_offset
|
||||
Theta_offset = Channel('X07MB-OP-MO:THETA.OFF', type = 'd')
|
||||
|
||||
#Dimension 1
|
||||
#Dimension Guard
|
||||
cawait('ACOAU-ACCU:OP-MODE', 6, type = 'l')
|
||||
#LinearPositioner Pitch
|
||||
for setpoint1 in frange(-10700.0, -10750.0, -2.0, True):
|
||||
if setpoint1 > -10700.0 or setpoint1 < -10750.0:
|
||||
break
|
||||
Pitch.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
|
||||
readback1 = PitchReadback.get()
|
||||
if abs(readback1 - setpoint1) > 10.0 : # TODO: Check accuracy
|
||||
print readback1, setpoint1
|
||||
raise Exception('Actor Pitch could not be set to the value ' + str(setpoint1))
|
||||
#Detector bm3
|
||||
#Detector X07MB-OP2-SAI_03:MEAN pre-actions
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.1)
|
||||
cawait('X07MB-OP2:SMPL-DONE', 1, type = 'l')
|
||||
detector1 = bm3.get()
|
||||
#Detector bm4
|
||||
detector2 = bm4.get()
|
||||
#Detector Filter_RY
|
||||
detector3 = Filter_RY.get()
|
||||
#Detector Harmonic
|
||||
detector4 = Harmonic.get()
|
||||
#Detector TC_Y
|
||||
detector5 = TC_Y.get()
|
||||
#Detector TC_Z
|
||||
detector6 = TC_Z.get()
|
||||
#Detector T_THETA
|
||||
detector7 = T_THETA.get()
|
||||
#Detector Id_OFF
|
||||
detector8 = Id_OFF.get()
|
||||
#Detector Id_energy
|
||||
detector9 = Id_energy.get()
|
||||
#Detector E_Mono
|
||||
detector10 = E_Mono.get()
|
||||
#Detector Bragg_Id_theo
|
||||
detector11 = Bragg_Id_theo.get()
|
||||
#Detector Theta_rbv
|
||||
detector12 = Theta_rbv.get()
|
||||
#Detector Theta_offset
|
||||
detector13 = Theta_offset.get()
|
||||
#Manipulation Delta_E
|
||||
#Variable Mappings
|
||||
a = detector10
|
||||
b = detector9
|
||||
Delta_E = a-b
|
||||
#Manipulation Delta_theta
|
||||
#Variable Mappings
|
||||
a = detector11
|
||||
b = detector12
|
||||
Delta_theta = a-b
|
||||
#Manipulation XX
|
||||
#Variable Mappings
|
||||
a = detector11
|
||||
b = detector12
|
||||
XX = a*b
|
||||
print(XX)
|
||||
scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, detector10, detector11, detector12, detector13, Delta_E, Delta_theta, E_Mono, XX])
|
||||
|
||||
#Closing channels
|
||||
Pitch.close()
|
||||
PitchReadback.close()
|
||||
bm3.close()
|
||||
bm4.close()
|
||||
Filter_RY.close()
|
||||
Harmonic.close()
|
||||
TC_Y.close()
|
||||
TC_Z.close()
|
||||
T_THETA.close()
|
||||
Id_OFF.close()
|
||||
Id_energy.close()
|
||||
E_Mono.close()
|
||||
Bragg_Id_theo.close()
|
||||
Theta_rbv.close()
|
||||
Theta_offset.close()
|
||||
|
||||
scan.end()
|
||||
|
||||
|
||||
#Post-actions
|
||||
caput('X07MB-OP2:START-CSMPL', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP2:START-CSMPL', '1')
|
||||
sleep(0.3)
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.3)
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.3)
|
||||
333
script/Users/Camelia/Test_XAS.py
Normal file
333
script/Users/Camelia/Test_XAS.py
Normal file
@@ -0,0 +1,333 @@
|
||||
import traceback
|
||||
import imp
|
||||
import os
|
||||
from CaChannel import *
|
||||
from epicsMotor import *
|
||||
from epicsPV import *
|
||||
import time
|
||||
import string
|
||||
import sys
|
||||
import json
|
||||
|
||||
# TO DO: Energy scan has onlz 1 positioner
|
||||
# need to generalize definition of scans to several paraller positiner,
|
||||
# to be able to use Create_Channels, alteratively need a dedicate channel creation for each scan type
|
||||
# tricky, code should stay simple
|
||||
# options.
|
||||
# Define channel generation for each chanenl separatelz
|
||||
# generalze scand to 1d and 2d with seveal posittioner in each dimension.
|
||||
# this will get complicated .....
|
||||
|
||||
import X_X07MB_Pscan as PS
|
||||
import X_X07MB_lib as PL
|
||||
|
||||
imp.reload(PS) # always reload module
|
||||
imp.reload(PL) # always reload module
|
||||
|
||||
NoRead=0
|
||||
|
||||
def before_pass():
|
||||
get_context().dataManager.provider.embeddedAtributes = False
|
||||
# Called at begining pf scan
|
||||
print('before_pass')
|
||||
SC.PerformActions('Pre_Actions')
|
||||
pars=get_exec_pars()
|
||||
print('pars.output : ')
|
||||
print(pars.output)
|
||||
print('pars.scanPath: ')
|
||||
print(pars.scanPath)
|
||||
print('pars.name: (filename) ')
|
||||
print(pars.name)
|
||||
# missing
|
||||
# NEED TO SET path for Moench here
|
||||
#end before_pass
|
||||
|
||||
|
||||
def before_read():
|
||||
# Cannot call routine in class in rscan call, need to go via local routine
|
||||
#print('before_read')
|
||||
# SC.DetectorActions() excecutes all standard action as defied in GUI
|
||||
SC.PerformActions('Detector_Actions')
|
||||
#print('.... done before_read ' )
|
||||
|
||||
# alternativly use caput here explicitly...
|
||||
# if needed
|
||||
#end before read
|
||||
|
||||
def after_read(rec,scan):
|
||||
print('ENTER after_read .................' )
|
||||
# Called after reading
|
||||
# calculate default dead time corrections and writ to file
|
||||
SC.after_read_dtc(rec,scan)
|
||||
print('.... done after_read ' )
|
||||
return
|
||||
#end after_read init
|
||||
|
||||
def after_pass():
|
||||
# Called after scan
|
||||
print('after_pass')
|
||||
|
||||
SC.PerformActions('Post_Actions')
|
||||
print('................ done after_pass')
|
||||
#end after pass
|
||||
|
||||
|
||||
def before_region(index,scan):
|
||||
print (index)
|
||||
|
||||
# make some reset
|
||||
try:
|
||||
del SC
|
||||
except:
|
||||
SC=0
|
||||
#endexept
|
||||
# originbal tag for data saving
|
||||
# '{data}/{year}/{month}/{day}/{year}_{month}{day}_{time}_{name}'
|
||||
# ........... FIrst read the scan
|
||||
#
|
||||
|
||||
# ====================================================
|
||||
#
|
||||
# SCRIPT STARTS HERE
|
||||
#
|
||||
# ====================================================
|
||||
if NoRead==0:
|
||||
try:
|
||||
SD = 0
|
||||
SD = PS.get_channels('SPECTRA') # READ SCAN DEFINITION FROM GUI USING OLD CODE
|
||||
print('returned from PS.get_channels()')
|
||||
SC=0
|
||||
SC=PL.PscanLib(SD,Channel,caput,caputq,caget,cawait,get_exec_pars,create_table,append_table) # create instance of library
|
||||
|
||||
print('... done SC.Create_All_Sensors()')
|
||||
SD.update({'All_Sensors':[]})
|
||||
except:
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
raise
|
||||
# endexcept
|
||||
# endif
|
||||
|
||||
# example add new sensor, similarly add pre and postactions to existing code
|
||||
|
||||
New_Sensors=[]
|
||||
New_Sensors.append({'channel_name': 'X07MB-ES-MA1:ScanY.RBV'
|
||||
, 'Subset_1': False
|
||||
, 'Det_type': 'ScalarDetector'
|
||||
, 'alias': 'MYSCANY_RBV'
|
||||
, 'data_type': 'double'})
|
||||
|
||||
# examples add post action light on
|
||||
|
||||
SD['Post_Actions'].append({'channel_name': 'X07MB-ES1-PP2:VO5'
|
||||
, 'data_type': 'String'
|
||||
, 'alias': 'Light_ON'
|
||||
, 'operation': 'put'
|
||||
, 'delay' : 0.1
|
||||
, 'value' : 5 })
|
||||
|
||||
# END OF USER INPUT
|
||||
|
||||
# .... add new sensors to list
|
||||
try:
|
||||
try:
|
||||
del AllSensors
|
||||
except:
|
||||
AllSensors=0
|
||||
#endecsept
|
||||
All_Sensors = SC.Create_Sensor_List() # Create instance for all sensors
|
||||
SC.Add_New_Sensors(New_Sensors) # Add user sensors
|
||||
except:
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
raise
|
||||
# endexcept
|
||||
|
||||
# STRUCTUALR INCONSITENCY NEED TO CREATE List of sensors first
|
||||
# without making Channel command.... !
|
||||
#
|
||||
# TEST SAVE SCAN DEFINITION...Needs to be before definition
|
||||
# SD is full GUI definiton of the scan try to save and reread this definiton
|
||||
|
||||
SD.update({'New_Sensors' : New_Sensors})
|
||||
f=open('scandef.dat','w')
|
||||
# Method to save abnd restore full scan definition...
|
||||
with open('BaseScanDefinition.json', 'w') as fp:
|
||||
json.dump(SD, fp,ensure_ascii=True)
|
||||
#endwith
|
||||
with open('BaseScanDefinition.json', 'r') as dd:
|
||||
SD_reread=json.load(dd)
|
||||
# .. this works, reread is unicode not string, but code seems still to work if all entries are in unicode
|
||||
|
||||
|
||||
# step I: CREATE ALL SENSORS AND STORE IN A LIST
|
||||
print('++++++++++++++++++++++++++')
|
||||
AllSensors=0
|
||||
try:
|
||||
# Code for beamline save......
|
||||
SavePhoenix=PL.SavePhoenix(Channel,caput,caputq,caget,cawait) # Channel,caput,caputq,caget,cawait)
|
||||
# SavePhoenix.write_beamline_data().. Works., move to before pass...
|
||||
|
||||
SC.noprint=0 # chose printing from SD on / off
|
||||
|
||||
# Now creat all epics instances. print('... done SC.Create_All_Sensors()')
|
||||
SD.update({'All_Sensors':All_Sensors})
|
||||
SC.Create_Channels('All_Sensors')
|
||||
SC.Create_Channels('All_Positioner')
|
||||
SC.Create_Channels('Detector_Actions')
|
||||
SC.Create_Channels('Pre_Actions')
|
||||
SC.Create_Channels('Post_Actions')
|
||||
SC.Create_Channels('Energy_Scan')
|
||||
except:
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
raise
|
||||
# endexcept
|
||||
|
||||
# ... create some abbreviations...
|
||||
All_Sensors = SC.All_Sensors
|
||||
All_Positioner = SD['All_Positioner']
|
||||
Pre_Actions = SD['Pre_Actions']
|
||||
Post_Actions = SD['Post_Actions']
|
||||
Detector_Actions = SD['Detector_Actions']
|
||||
Energy_Scan = SD['Energy_Scan']
|
||||
|
||||
|
||||
#............SOME OUTPUT
|
||||
#print('----------- All_Positioner ---')
|
||||
#print(' ')
|
||||
#print(SD['All_Positioner'])
|
||||
#print(' ------------ Pre_Action -------- ')
|
||||
#print(' ')
|
||||
#print(SD['Pre_Actions'])
|
||||
#print(' ------------ Post_Action -------- ')
|
||||
#print(' ')
|
||||
#print(SD['Post_Actions'])
|
||||
#print(' ')
|
||||
#print(' ----------- Detector_Action--------- ')
|
||||
#print(' ')
|
||||
#print(SD['Detector_Actions'])
|
||||
## ............. MISSING CREATE POSTACTIONS::::::
|
||||
|
||||
# STEP II read the energy position
|
||||
print('')
|
||||
print('..................................... positioner Energy ID? readback automatically saved? ')
|
||||
print('initial energies e_i ',SD['e_i'])
|
||||
print('final energies e_f ',SD['e_f'])
|
||||
print('DELTA E e_delta ',SD['e_delta'])
|
||||
print('DWELL TIME e_n_cycles',SD['e_n_cycles'])
|
||||
print(SD['Energy_Scan']['Energy_Ranges'])
|
||||
|
||||
#try:
|
||||
# EnergyRanges,Cycles = SC.PositionerEnergyScan()
|
||||
#except:
|
||||
# traceback.print_tb(sys.exc_info()[2])
|
||||
# raise
|
||||
# endexcept nowcall
|
||||
#print(EnergyRanges,Cycles)
|
||||
|
||||
# STEP II ... read the detector actions
|
||||
|
||||
# Step IV perform the Preaction
|
||||
#P=SC.DetectorActions()
|
||||
|
||||
print(All_Sensors)
|
||||
print('Energy_Ranges')
|
||||
print(SD['Energy_Scan']['Energy_Ranges'])
|
||||
|
||||
pars=get_exec_pars()
|
||||
print('pars.output')
|
||||
print(pars.output)
|
||||
print('pars.scanPath')
|
||||
print(pars.scanPath)
|
||||
print(' ')
|
||||
print('---------------')
|
||||
print(' ')
|
||||
print(' CALL SCAN NOW ')
|
||||
print(' ')
|
||||
|
||||
p=set_exec_pars(name=SD['filename'])
|
||||
# This is one singe energy scan:
|
||||
|
||||
|
||||
# save scan definition
|
||||
|
||||
get_context().dataManager.provider.embeddedAtributes = False
|
||||
|
||||
# .. now make individual scan for all positioners as defiens in GUI
|
||||
# as we like want to have separete datasets for each scan \
|
||||
#
|
||||
for i in range(len(All_Positioner[0]['value'])): # loop in number of points
|
||||
# set all positioner
|
||||
for j in range(len(All_Positioner)): # set positioner
|
||||
t0=time.time()
|
||||
ThisPositioner = All_Positioner[j]['Channel']
|
||||
ThisPosition = All_Positioner[j]['value'][i]
|
||||
print('next,i,j',i,j)
|
||||
print('name',All_Positioner[j]['channel_name'])
|
||||
print('value',All_Positioner[j]['value'][i])
|
||||
print(time.time()-t0)
|
||||
# .............. SET NEW POSITIONER
|
||||
#ThisPositioner.write(ThisPosition)
|
||||
ThisPositioner.put(ThisPosition)
|
||||
#ThisPositioner.putq(ThisPosition) # simultaneous walk no waiting..
|
||||
print(time.time()-t0)
|
||||
#endfor loop set positioner
|
||||
# generate filename
|
||||
p=set_exec_pars(name=SD['filename']+'_'+All_Positioner[0]['label'][i])
|
||||
pars=get_exec_pars()
|
||||
print('filename this run : ')
|
||||
print(pars.name)
|
||||
|
||||
print('--------------- NEXT SCAN ----------------')
|
||||
try:
|
||||
#call rscan
|
||||
print('cal rscan ')
|
||||
#rscan(SD['Energy_Scan']['Channel']
|
||||
# , SC.get_list(All_Sensors,'Channel')
|
||||
# , regions=SD['Energy_Scan']['Energy_Ranges']
|
||||
# , latency = 0.0, relative = False
|
||||
# , before_pass = SC.PerformActions('Pre_Actions') # before_pass
|
||||
# , before_read = before_read #SC.PerformActions('Detector_Actions') # before_read
|
||||
# , after_read = SC.after_read_dtc #after_read
|
||||
# , after_pass = after_pass
|
||||
# , before_region = before_region
|
||||
# , enabled_plots=['I0_KEITHLEY1','I1_KEITHLEY2','D1_ICR','D1_OCR'])
|
||||
|
||||
#vscan(SD['Energy_Scan']['Channel']
|
||||
# , SC.get_list(All_Sensors,'Channel')
|
||||
# , vector=SD['Energy_Scan']['Energy_Scan_Positions']
|
||||
# , latency = 0.0, relative = False
|
||||
# , before_pass = SC.PerformActions('Pre_Actions') # before_pass
|
||||
# , before_read = before_read #SC.PerformActions('Detector_Actions') # before_read
|
||||
# , after_read = SC.after_read_dtc #after_read
|
||||
# , after_pass = after_pass
|
||||
# , before_region = before_region
|
||||
# , enabled_plots=['I0_KEITHLEY1','I1_KEITHLEY2','D1_ICR','D1_OCR'])
|
||||
|
||||
except:
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
raise
|
||||
# END EXecpt
|
||||
#endfor
|
||||
#endfor
|
||||
print('... scan finished ')
|
||||
#
|
||||
|
||||
#ret = lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, enabled_plots=['X07MB-OP2-SAI_07:MEAN'])
|
||||
|
||||
|
||||
#rscan("ca://X07MB-OP-MO:E-SET", sensors, [[2450.0, 2455.0, 1.0], [2456.0, 2460.0, 0.5]], latency = 0.0, relative = False)
|
||||
|
||||
|
||||
#def BeforeReadout(position, scan):
|
||||
# print "In position: " + str(pposition)
|
||||
|
||||
|
||||
#def AfterReadout(record, scan):
|
||||
# print "Aquired record: " + str(record)
|
||||
|
||||
#lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, latency=0.0, relative = False, before_read=BeforeReadout, after_read=AfterReadout)
|
||||
#rscan("ca://X07MB-OP-MO:E-SET", sensors, [[2450.0, 2455.0, 1.0], [2456.0, 2460.0, 0.5]], latency = 0.0, relative = False)
|
||||
#ascan(["ca://X07MB-OP-MO:E-SET", "X07MB-ES-MA1:ScanX.VAL"], sensors, start=[2450, 1.6], end=[2460, 1.8], steps=[2.0,0.05], latency=0.0, relative = False, zigzag = True)
|
||||
##
|
||||
#
|
||||
# Vizualization...............
|
||||
#
|
||||
1
script/Users/Thomas/BaseScanDefinition.json
Normal file
1
script/Users/Thomas/BaseScanDefinition.json
Normal file
File diff suppressed because one or more lines are too long
9
script/Users/Thomas/CreatingLocalChannelDevices.py
Normal file
9
script/Users/Thomas/CreatingLocalChannelDevices.py
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
pos = Channel('X07MB-OP-MO:E-SET', alias="POS", type='s')
|
||||
c1 = Channel('X07MB-OP2-SAI_07:MEAN', alias="TEST")
|
||||
c2 = Channel('X07MB-OP-MO:E-GET', alias="TEST2")
|
||||
sensors = [c1,c2]
|
||||
ret = lscan(pos, sensors, start=2450, end=2460, steps=10)
|
||||
|
||||
|
||||
for c in sensors: c.close()
|
||||
139
script/Users/Thomas/Mono_pitch.py
Normal file
139
script/Users/Thomas/Mono_pitch.py
Normal file
@@ -0,0 +1,139 @@
|
||||
#Script imported from: Mono_pitch.xml
|
||||
|
||||
#Pre-actions
|
||||
caput('X07MB-OP2:START-CSMPL', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:StopAll', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:PresetMode', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:PresetReal', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP2:TOTAL-CYCLES', '1')
|
||||
sleep(0.1)
|
||||
print('dd')
|
||||
|
||||
#TODO: Set the diplay names of positioners and detectors
|
||||
scan = ManualScan(['Pitch'], ['bm3', 'bm4', 'Filter_RY', 'Harmonic', 'TC_Y', 'TC_Z', 'T_THETA', 'Id_OFF', 'Id_energy', 'E_Mono', 'Bragg_Id_theo', 'Theta_rbv', 'Theta_offset', 'Delta_E', 'Delta_theta', 'XX'] , [-10700.0], [-10750.0], [25])
|
||||
scan.start()
|
||||
|
||||
#Creating channels: dimension 1
|
||||
#LinearPositioner Pitch
|
||||
Pitch = Channel('X07MB-OP-MO:C2-ROX.VAL', type = 'd')
|
||||
PitchReadback = Channel('X07MB-OP-MO:C2-ROX.RBV', type = 'd')
|
||||
#ScalarDetector bm3
|
||||
bm3 = Channel('X07MB-OP2-SAI_03:MEAN', type = 'd')
|
||||
#ScalarDetector bm4
|
||||
bm4 = Channel('X07MB-OP2-SAI_04:MEAN', type = 'd')
|
||||
#ScalarDetector Filter_RY
|
||||
Filter_RY = Channel('X07MB-OP-FI:ROY.VAL', type = 'd')
|
||||
#ScalarDetector Harmonic
|
||||
Harmonic = Channel('X07MA-ID:HARMONIC', type = 'd')
|
||||
#ScalarDetector TC_Y
|
||||
TC_Y = Channel('X07MB-OP-MOC2:TC_Y', type = 'd')
|
||||
#ScalarDetector TC_Z
|
||||
TC_Z = Channel('X07MB-OP-MOC2:TC_Z', type = 'd')
|
||||
#ScalarDetector T_THETA
|
||||
T_THETA = Channel('X07MB-OP-MOTHETA:TC1', type = 'd')
|
||||
#ScalarDetector Id_OFF
|
||||
Id_OFF = Channel('X07MA-ID:ENERGY-OFFS', type = 'd')
|
||||
#ScalarDetector Id_energy
|
||||
Id_energy = Channel('X07MA-ID:ENERGY', type = 'd')
|
||||
#ScalarDetector E_Mono
|
||||
E_Mono = Channel('X07MB-OP-MO:E-GET', type = 'd')
|
||||
#ScalarDetector Bragg_Id_theo
|
||||
Bragg_Id_theo = Channel('X07MB-OP-MO:BRAGG-CALC', type = 'd')
|
||||
#ScalarDetector Theta_rbv
|
||||
Theta_rbv = Channel('X07MB-OP-MO:THETA.RBV', type = 'd')
|
||||
#ScalarDetector Theta_offset
|
||||
Theta_offset = Channel('X07MB-OP-MO:THETA.OFF', type = 'd')
|
||||
|
||||
#Dimension 1
|
||||
#Dimension Guard
|
||||
cawait('ACOAU-ACCU:OP-MODE', 6, type = 'l')
|
||||
#LinearPositioner Pitch
|
||||
for setpoint1 in frange(-10700.0, -10750.0, -2.0, True):
|
||||
if setpoint1 > -10700.0 or setpoint1 < -10750.0:
|
||||
break
|
||||
Pitch.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
|
||||
readback1 = PitchReadback.get()
|
||||
if abs(readback1 - setpoint1) > 10.0 : # TODO: Check accuracy
|
||||
print readback1, setpoint1
|
||||
raise Exception('Actor Pitch could not be set to the value ' + str(setpoint1))
|
||||
#Detector bm3
|
||||
#Detector X07MB-OP2-SAI_03:MEAN pre-actions
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.1)
|
||||
cawait('X07MB-OP2:SMPL-DONE', 1, type = 'l')
|
||||
detector1 = bm3.get()
|
||||
#Detector bm4
|
||||
detector2 = bm4.get()
|
||||
#Detector Filter_RY
|
||||
detector3 = Filter_RY.get()
|
||||
#Detector Harmonic
|
||||
detector4 = Harmonic.get()
|
||||
#Detector TC_Y
|
||||
detector5 = TC_Y.get()
|
||||
#Detector TC_Z
|
||||
detector6 = TC_Z.get()
|
||||
#Detector T_THETA
|
||||
detector7 = T_THETA.get()
|
||||
#Detector Id_OFF
|
||||
detector8 = Id_OFF.get()
|
||||
#Detector Id_energy
|
||||
detector9 = Id_energy.get()
|
||||
#Detector E_Mono
|
||||
detector10 = E_Mono.get()
|
||||
#Detector Bragg_Id_theo
|
||||
detector11 = Bragg_Id_theo.get()
|
||||
#Detector Theta_rbv
|
||||
detector12 = Theta_rbv.get()
|
||||
#Detector Theta_offset
|
||||
detector13 = Theta_offset.get()
|
||||
#Manipulation Delta_E
|
||||
#Variable Mappings
|
||||
a = detector10
|
||||
b = detector9
|
||||
Delta_E = a-b
|
||||
#Manipulation Delta_theta
|
||||
#Variable Mappings
|
||||
a = detector11
|
||||
b = detector12
|
||||
Delta_theta = a-b
|
||||
#Manipulation XX
|
||||
#Variable Mappings
|
||||
a = detector11
|
||||
b = detector12
|
||||
XX = a*b
|
||||
print(XX)
|
||||
scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, detector10, detector11, detector12, detector13, Delta_E, Delta_theta, E_Mono, XX])
|
||||
|
||||
#Closing channels
|
||||
Pitch.close()
|
||||
PitchReadback.close()
|
||||
bm3.close()
|
||||
bm4.close()
|
||||
Filter_RY.close()
|
||||
Harmonic.close()
|
||||
TC_Y.close()
|
||||
TC_Z.close()
|
||||
T_THETA.close()
|
||||
Id_OFF.close()
|
||||
Id_energy.close()
|
||||
E_Mono.close()
|
||||
Bragg_Id_theo.close()
|
||||
Theta_rbv.close()
|
||||
Theta_offset.close()
|
||||
|
||||
scan.end()
|
||||
|
||||
|
||||
#Post-actions
|
||||
caput('X07MB-OP2:START-CSMPL', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP2:START-CSMPL', '1')
|
||||
sleep(0.3)
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.3)
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.3)
|
||||
3463
script/Users/Thomas/Pscan.py
Normal file
3463
script/Users/Thomas/Pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
19
script/Users/Thomas/PseudoScanDevices.py
Normal file
19
script/Users/Thomas/PseudoScanDevices.py
Normal file
@@ -0,0 +1,19 @@
|
||||
###################################################################################################
|
||||
# Demonstrate use of Vector Scan: one or multiple positioners set with a list or generator.
|
||||
###################################################################################################
|
||||
|
||||
|
||||
class PseudoPositioner(Writable):
|
||||
def write(self,pos):
|
||||
print "Step = " + str(pos)
|
||||
#caput()
|
||||
#cawait()
|
||||
positioner=PseudoPositioner()
|
||||
|
||||
|
||||
class Clock(Readable):
|
||||
def read(self):
|
||||
return time.clock()
|
||||
clock=Clock()
|
||||
|
||||
lscan(positioner,[clock], start=2450, end=2460, steps=10, latency=0.0, relative = False, before_read=BeforeReadout, after_read=AfterReadout)
|
||||
9
script/Users/Thomas/ScanPlotOptions.py
Normal file
9
script/Users/Thomas/ScanPlotOptions.py
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
set_exec_pars(format="h5", name="")
|
||||
|
||||
lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10)
|
||||
|
||||
|
||||
sensors=['ca://X07MB-OP2-SAI_07:MEAN', 'ca://X07MB-OP-MO:E-GET']
|
||||
ret = lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, enabled_plots=['X07MB-OP2-SAI_07:MEAN'])
|
||||
|
||||
12
script/Users/Thomas/ScanRecordCallbacks.py
Normal file
12
script/Users/Thomas/ScanRecordCallbacks.py
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
|
||||
|
||||
def BeforeReadout(position, scan):
|
||||
print "In position: " + str(position) + str(sensors)
|
||||
|
||||
|
||||
def AfterReadout(record, scan):
|
||||
print "Aquired record: " + str(record)
|
||||
|
||||
lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, latency=0.0, relative = False, before_read=BeforeReadout, after_read=AfterReadout)
|
||||
10
script/Users/Thomas/Test.py
Normal file
10
script/Users/Thomas/Test.py
Normal file
@@ -0,0 +1,10 @@
|
||||
d={'a':1,
|
||||
'b':2}
|
||||
|
||||
print(d)
|
||||
d.update({'c':5})
|
||||
print(d)
|
||||
print(type(d))
|
||||
|
||||
|
||||
|
||||
26
script/Users/Thomas/Test_thomas.py
Normal file
26
script/Users/Thomas/Test_thomas.py
Normal file
@@ -0,0 +1,26 @@
|
||||
class test:
|
||||
d=5
|
||||
d1='d'
|
||||
#endclass
|
||||
|
||||
def tt(a):
|
||||
print('2')
|
||||
#enddef
|
||||
|
||||
tt(9)
|
||||
print(test.d)
|
||||
print(test.d1)
|
||||
|
||||
box={ 'filename' : 'd'
|
||||
, 'beamline' : 'dd'}
|
||||
|
||||
print(box)
|
||||
f=[1,2,2]
|
||||
plot(f,title='f')
|
||||
f1=get_plot_snapshots()
|
||||
print(f1)
|
||||
import os
|
||||
import numpy
|
||||
|
||||
|
||||
|
||||
3642
script/Users/Thomas/X_X07MB_Pscan.py
Normal file
3642
script/Users/Thomas/X_X07MB_Pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
3434
script/Users/Thomas/X_X07MB_Pscan.py.old
Normal file
3434
script/Users/Thomas/X_X07MB_Pscan.py.old
Normal file
File diff suppressed because it is too large
Load Diff
543
script/Users/Thomas/X_X07MB_XAS_points_P1_queue.py
Normal file
543
script/Users/Thomas/X_X07MB_XAS_points_P1_queue.py
Normal file
@@ -0,0 +1,543 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
# ----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def write_xml_XAS_single_point(g,N_position,BASE_DIR):
|
||||
|
||||
|
||||
# ==================================================================================
|
||||
#
|
||||
# THIS ROUTINE CREATES THE XML FILE FOR TAKING XAS SPECTRA ON VARIOUS DATA POINTS
|
||||
#
|
||||
#
|
||||
# Author T. Huthwelker October 2011 ---
|
||||
#
|
||||
# =================================================================================
|
||||
|
||||
|
||||
filename=str(g['filename']) + '_' + str(g['p_label'][N_position])
|
||||
|
||||
number_of_executions= str(g['number_of_executions'])
|
||||
|
||||
filename_xml=BASE_DIR+"points_q_" +str(N_position)+'_'+ str(g['p_label'][N_position]) + ".xml"
|
||||
filename_xml=BASE_DIR+"points_q_" +str(N_position)+ ".xml"
|
||||
print filename
|
||||
print filename_xml
|
||||
|
||||
f = open(filename_xml, "w")
|
||||
|
||||
# ............. write header and open configuration ......................
|
||||
|
||||
f.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+'\n')
|
||||
|
||||
|
||||
f.write('<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="'+str(1)+'" failOnSensorError="true">'+'\n')
|
||||
|
||||
|
||||
# option to take the number o repeats on panel as number of excecutions for each individual run
|
||||
#num_ex=get_epicsPV('X07MB-PC-PSCAN:FdaNexec')
|
||||
#f.write('<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="'+str(int(num_ex))+'" failOnSensorError="true">'+'\n')
|
||||
|
||||
|
||||
|
||||
|
||||
f.write('<data format="txt" fileName="'+'XAS_'+filename+'"/>'+'\n')
|
||||
|
||||
|
||||
# define default Variable
|
||||
|
||||
Write_Variable_Definitions(f,g)
|
||||
|
||||
# -------------------------- general preactions..........
|
||||
|
||||
f.write('<scan> \n ')
|
||||
|
||||
|
||||
write_preactions(f,g)
|
||||
|
||||
|
||||
#___________________________________________ ______________ dimension 1 Energy
|
||||
|
||||
f.write('<dimension zigzag="false" dataGroup="false"> \n') # -..... open dimension 1
|
||||
|
||||
|
||||
# ......... open positioner
|
||||
|
||||
|
||||
write_start_positioner(f,{'Type' : 'RegionPositioner'
|
||||
,'Ch_set' : g['e_channel']
|
||||
,'Ch_done' : 'None'
|
||||
,'Ch_readback' : g['e_channel_rbv']
|
||||
,'Settling_time' : '0.2'
|
||||
,'Id' : 'Energy'})
|
||||
|
||||
ch_preaction='X07MB-OP2:TOTAL-CYCLES'
|
||||
|
||||
#print g['e_i']
|
||||
#print g['e_f']
|
||||
#print g['e_active']
|
||||
#print g['n_e']
|
||||
|
||||
for i in range(g['n_e']):
|
||||
if g['e_active'][i] == 1:
|
||||
print i
|
||||
print g['e_active'][i]
|
||||
print g['e_i'][i]
|
||||
write_region(f,{'V_ini' : g['e_i'][i]
|
||||
,'V_final' : g['e_f'][i]
|
||||
,'V_delta' : g['e_delta'][i]
|
||||
,'Ch_preaction' : ch_preaction
|
||||
,'Ch_preaction_value' : g['e_n_cycles'][i]})
|
||||
# endif
|
||||
# endfor
|
||||
|
||||
# NOw add one positioner for EXAFS with a non-linear gris spacing Currently only one range
|
||||
|
||||
print 'kkkkkkkkkk'
|
||||
print g['e_ex_e_i']
|
||||
print g['e_ex_e_f'] # Eini
|
||||
print g['e_ex_k_i'] # k ini
|
||||
print g['e_ex_k_f'] # k final
|
||||
print g['e_ex_d_i'] # Delta_E (at begin)
|
||||
print g['e_ex_ncy']
|
||||
print g['e_ex_ncy_f']
|
||||
print g['e_ex_nst']
|
||||
print g['e_ex_t']
|
||||
|
||||
write_EXAFS_region(f,g)
|
||||
|
||||
|
||||
f.write('</positioner> \n') # -..... close positoner
|
||||
|
||||
|
||||
|
||||
# ____________________________________________________ DETECTORS.............................
|
||||
|
||||
|
||||
|
||||
|
||||
# ......actions for detectors for each measurement
|
||||
|
||||
|
||||
write_detector_actions(f,g)
|
||||
|
||||
|
||||
# ... write guard, must be in first loop after detector actions...
|
||||
|
||||
#write_guard(f,{'Channel' : 'ACOAU-ACCU:OP-MODE'
|
||||
# ,'Value' : 6 })
|
||||
|
||||
|
||||
|
||||
# ...................create all entries for the detectors......
|
||||
[n_det_vortex,n_roi_vortex,channel_roi_vortex,id_roi_vortex,channel_roi_vortex_dxp,id_roi_vortex_dxp,id_icr_vortex,id_trueicr_vortex,id_ocr_vortex,id_eltm_vortex,id_ertm_vortex] =write_all_detectors(f,g)
|
||||
|
||||
|
||||
# .. other detectors...
|
||||
|
||||
|
||||
#write_detector(f,{'Det_type' : 'ScalarDetector'
|
||||
# ,'Data_type' : 'Double'
|
||||
# ,'Channel' : 'X07MB-ES1:userCalc3.VAL'
|
||||
# ,'Id' : 'T_heater_C '})
|
||||
|
||||
#write_detector(f,{'Det_type' : 'ScalarDetector'
|
||||
# ,'Data_type' : 'Double'
|
||||
# ,'Channel' : 'X07MB-ES1-PP3:PT1'
|
||||
# ,'Id' : 'T_heater_V'})
|
||||
|
||||
#write_detector(f,{'Det_type' : 'ScalarDetector'
|
||||
# ,'Data_type' : 'Double'
|
||||
# ,'Channel' : 'X07MB-ES1-PP3:PT2'
|
||||
# ,'Id' : 'T_sample_V'})
|
||||
|
||||
#write_detector(f,{'Det_type' : 'ScalarDetector'
|
||||
# ,'Data_type' : 'Double'
|
||||
# ,'Channel' : 'X07MB-ES1-PP2:VO1'
|
||||
# ,'Id' : 'U_heater_SET'})
|
||||
|
||||
|
||||
# use guard, stop DAQ if there is no light
|
||||
|
||||
|
||||
# ____________________________________________________ dimension 2 position Manipulator
|
||||
|
||||
# write positioner for default chanels onlz if thez are defined...
|
||||
print g['p_positioner_active']
|
||||
print g['p_channel']
|
||||
print g['p_id']
|
||||
print g['p_id'][0]
|
||||
print ' '
|
||||
print 'g[p_data]'
|
||||
print g['p_data']
|
||||
print ' '
|
||||
print g['p_data'][0]
|
||||
|
||||
f.write('</dimension> \n') # -..... close dimension 1
|
||||
if sum(g['p_positioner_active']) > 0:
|
||||
f.write('<dimension> \n ') # -..... open dimension 2
|
||||
print g['p_channel']
|
||||
print g['p_done_switch']
|
||||
|
||||
for i in range(len(g['p_id'])):
|
||||
write_array_positioner(f,{'Channel' : g['p_channel'][i]
|
||||
, 'Channel_rbv' : g['p_channel_rbv'][i]
|
||||
, 'Id' : g['p_id'][i]
|
||||
, 'Positions' : [g['p_data'][i][N_position]]
|
||||
, 'Channel_done': g['p_done'][i]
|
||||
, 'Use_done_value': g['p_done_switch'][i]
|
||||
}
|
||||
)
|
||||
|
||||
#endfor
|
||||
|
||||
|
||||
# ... before closing dimensions, set a guard on the beam current
|
||||
|
||||
# 31.7.2012 temp commented out........
|
||||
|
||||
|
||||
|
||||
|
||||
f.write('</dimension> \n') # -..... close dimension 2
|
||||
#endif
|
||||
|
||||
# ....................postaction after detectors
|
||||
|
||||
f.write(post_action_channel_action('X07MB-OP2:START-CSMPL','1','put','String','0.1'))
|
||||
write_default_postactions(f,g)
|
||||
|
||||
|
||||
# ==============================================================================================
|
||||
# ..........write all manipulations.... possible move away from hre into a standard routine
|
||||
# ==============================================================================================
|
||||
|
||||
# first walk through all detectors....
|
||||
|
||||
for i in range(len(g['detectors'])): # outer loop: walk through all defined detector
|
||||
# types. Only if type Vortex is defined, we write the
|
||||
# manipulations needed for dead time correction of Vortex
|
||||
#
|
||||
if (g['detectors'][i] == 'Vortex') or (g['detectors'][i] == 'ROENTEC_XMAP') or (g['detectors'][i] == 'KETEK_XMAP'):
|
||||
|
||||
# ......o.k. Vortex s defined, now make dead time corrections for
|
||||
# all rois from Vortex detector.
|
||||
|
||||
#print n_det_vortex,n_roi_vortex
|
||||
print n_roi_vortex
|
||||
print range(n_roi_vortex)
|
||||
|
||||
# manipulation to calulate the true ICR
|
||||
for j in range(n_det_vortex):
|
||||
write_manip_calc_TrueICR(f,{'Id_icr' : id_icr_vortex[j]
|
||||
, 'Id_ocr' : id_ocr_vortex[j]
|
||||
, 'Id_elapsedTime': id_ertm_vortex[j]
|
||||
, 'Id_out' : id_trueicr_vortex[j]})
|
||||
# endfor
|
||||
|
||||
# note at later stage use result from calculated true ice as input for subsequent manipulations.
|
||||
for k in range(n_roi_vortex):
|
||||
for j in range(n_det_vortex):
|
||||
|
||||
# create array with Id for all detectors for roi # k
|
||||
if j ==0:
|
||||
id_roi_for_det_sum=[id_roi_vortex[0][k]+'_corr']
|
||||
else:
|
||||
id_roi_for_det_sum.append(id_roi_vortex[j][k]+'_corr')
|
||||
# endelse
|
||||
|
||||
print ' next in loop writin manipulator..'
|
||||
print n_det_vortex,n_roi_vortex
|
||||
print i,j,k
|
||||
print id_roi_vortex[j][k]
|
||||
print id_icr_vortex
|
||||
|
||||
# ... MISSING HERE OPTION TO SET ESTIMATE FOR DEAD TIME CORRECTION FOR DIFFERENT PEAKING TIMES .............
|
||||
|
||||
write_manip_dead_time_roi(f,{'Id_roi' : id_roi_vortex[j][k]
|
||||
, 'Id_icr' : id_icr_vortex[j]
|
||||
, 'Id_ocr' : id_ocr_vortex[j]
|
||||
, 'Id_elapsedTime': id_ertm_vortex[j]
|
||||
, 'Id_out' : id_roi_vortex[j][k]+'_corr'})
|
||||
|
||||
# write manipulations for division of roi by all user detector (only of user det = on is choosen..)
|
||||
# need to add new flagg...
|
||||
|
||||
print g['User_detector_fda_id']
|
||||
|
||||
print g['detectors_to_plot']
|
||||
if 'PL_USER_DET' in g['detectors_to_plot']:
|
||||
for i_ud in range(len(g['User_detector_fda_id'])):
|
||||
print i_ud
|
||||
write_manip_divide_channels(f,{'Id_out': id_roi_vortex[j][k]+'_corr_over_'+g['User_detector_fda_id'][i_ud]
|
||||
, 'Id_1': id_roi_vortex[j][k]+'_corr'
|
||||
, 'Id_2': g['User_detector_fda_id'][i_ud]})
|
||||
# endfor i_UD
|
||||
|
||||
# endif
|
||||
|
||||
# now manipulations for all detector for this rois
|
||||
# now calculate ths sum of deadtime corrected
|
||||
# detector data
|
||||
# this_id_roi = id_roi_vortex[0][k][len(id_roi_vortex[0][k])-3:len(id_roi_vortex[0][k])] # remove D1_ from ID name
|
||||
this_id_roi = id_roi_vortex[0][k][3:len(id_roi_vortex[0][k])] # remove D1_ from ID name
|
||||
#print 'idroi ' ,id_roi_vortex
|
||||
#print 'aaa',id_roi_vortex[0][k],'bbb'
|
||||
#print 'len',len(id_roi_vortex[0][k])
|
||||
#print 'this_id_roi ',this_id_roi
|
||||
|
||||
|
||||
write_manip_sum_vortex(f,{'Id_roi' : id_roi_for_det_sum
|
||||
, 'Id_out' : this_id_roi+'_sum_cps'})
|
||||
|
||||
|
||||
|
||||
# endfor
|
||||
# endif
|
||||
# endfor
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
f.write('</scan> \n ') # -..... close scan # END OF SCAN
|
||||
|
||||
# finally add the visualization .................
|
||||
|
||||
|
||||
# plot ICR and OCR for all VORTEX DETECTORS....
|
||||
# case I vortex 4-element detector
|
||||
|
||||
if ('Vortex' in g['detectors']):
|
||||
|
||||
#if n_det_vortex == 4 :
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : 'D1_ICR D2_ICR D3_ICR D4_ICR D1_TrueICR D2_TrueICR D3_TrueICR D4_TrueICR'
|
||||
, 'Title' : 'ICR ' })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : 'D1_OCR D2_OCR D3_OCR D4_OCR'
|
||||
, 'Title' : 'OCR ' })
|
||||
|
||||
#write_visualization(f,{ 'Type': 'LinePlot'
|
||||
# , 'X' : 'Energy'
|
||||
# , 'DATA' : 'I0_KEITHLEY1'
|
||||
# , 'Title' : 'I0 (KEITHLEY 1)' })
|
||||
|
||||
#write_visualization(f,{ 'Type': 'LinePlot'
|
||||
# , 'X' : 'Energy'
|
||||
# , 'DATA' : 'I1_KEITHLEY 2'
|
||||
# , 'Title' : 'I1 (KEITHLEY 2)' })
|
||||
|
||||
|
||||
# now plot the roi for XAS
|
||||
|
||||
print 'id_roi_vortex[0]'
|
||||
print id_roi_vortex[0]
|
||||
print "g[n_roi_for_xas]"
|
||||
print g['n_roi_for_xas']
|
||||
print g['n_roi_for_xas_index']
|
||||
print id_roi_vortex[0][g['n_roi_for_xas_index']]
|
||||
|
||||
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[0][g['n_roi_for_xas_index']]
|
||||
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']] })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[1][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[1][g['n_roi_for_xas_index']]
|
||||
, 'Title' : id_roi_vortex[1][g['n_roi_for_xas_index']] })
|
||||
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[2][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[2][g['n_roi_for_xas_index']]
|
||||
, 'Title' : id_roi_vortex[2][g['n_roi_for_xas_index']] })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[3][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[3][g['n_roi_for_xas_index']]
|
||||
, 'Title' : id_roi_vortex[3][g['n_roi_for_xas_index']] })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr'
|
||||
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr' })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[1][g['n_roi_for_xas_index']]+'_corr'
|
||||
, 'Title' : id_roi_vortex[1][g['n_roi_for_xas_index']]+'_corr' })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[2][g['n_roi_for_xas_index']]+'_corr'
|
||||
, 'Title' : id_roi_vortex[2][g['n_roi_for_xas_index']]+'_corr' })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[3][g['n_roi_for_xas_index']]+'_corr'
|
||||
, 'Title' : id_roi_vortex[3][g['n_roi_for_xas_index']]+'_corr' })
|
||||
|
||||
# now also vizualize roi over user detectors if user detectors are defined..
|
||||
|
||||
if (('PL_USER_DET' in g['detectors_to_plot']) and ('USER_DET' in g['detectors'])):
|
||||
|
||||
for i_ud in range(len(g['User_detector_fda_id'])):
|
||||
print i_ud
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[3][g['n_roi_for_xas_index']]+'_corr_over_'+g['User_detector_fda_id'][i_ud]
|
||||
, 'Title' : id_roi_vortex[3][g['n_roi_for_xas_index']]+'_corr_over_'+g['User_detector_fda_id'][i_ud]}
|
||||
)
|
||||
|
||||
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
# case II Roentex via XMAP
|
||||
|
||||
if ('ROENTEC_XMAP' in g['detectors']):
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : 'D1_ICR D1_TrueICR'
|
||||
, 'Title' : 'ICR ' })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : 'D1_OCR '
|
||||
, 'Title' : 'OCR ' })
|
||||
|
||||
|
||||
# now plot the roi for XAS
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+' '+ id_roi_vortex_dxp[0][g['n_roi_for_xas_index']]
|
||||
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']] })
|
||||
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr'
|
||||
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr' })
|
||||
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
|
||||
if ('KETEK_XMAP' in g['detectors']):
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : 'D2_ICR D2_TrueICR'
|
||||
, 'Title' : 'ICR ' })
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : 'D2_OCR '
|
||||
, 'Title' : 'OCR ' })
|
||||
|
||||
|
||||
|
||||
# now plot the roi for XAS
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']] +' '+ id_roi_vortex_dxp[0][g['n_roi_for_xas_index']]
|
||||
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']] })
|
||||
|
||||
|
||||
write_visualization(f,{ 'Type': 'LinePlot'
|
||||
, 'X' : 'Energy'
|
||||
, 'DATA' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr'
|
||||
, 'Title' : id_roi_vortex[0][g['n_roi_for_xas_index']]+'_corr' })
|
||||
|
||||
|
||||
# endif
|
||||
|
||||
# finally add optional plots to data set
|
||||
|
||||
special_visualization(f,g,{'Id_X': 'Energy', 'Id_Y':'undefined', 'Type':'LinePlot' })
|
||||
|
||||
|
||||
|
||||
|
||||
f.write('</configuration>'+'\n') # close configuration # END OF CONFIGURATION
|
||||
|
||||
# END ROUTINE
|
||||
|
||||
|
||||
|
||||
from X_X07MB_Pscan import *
|
||||
import commands
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
|
||||
# from subprocess import call
|
||||
# HERE THE MaiN PRG STARTS.....
|
||||
|
||||
#detectors=[' ',' ',' ']
|
||||
#n_e=5
|
||||
#e_active = create_int_zeros(n_e)
|
||||
#e_i = create_real_zeros(n_e)
|
||||
#e_f = create_real_zeros(n_e)
|
||||
#e_delta = create_real_zeros(n_e)
|
||||
|
||||
|
||||
#n_p = 10
|
||||
#p_active = create_int_zeros(n_p)
|
||||
#p_scanx = create_real_zeros(n_p)
|
||||
##p_scany = create_real_zeros(n_p)
|
||||
#p_theta = create_real_zeros(n_p)
|
||||
#p_trx = create_real_zeros(n_p)
|
||||
#p_trz = create_real_zeros(n_p)
|
||||
|
||||
g=get_channels('SPECTRA_QUEUE')
|
||||
|
||||
|
||||
beamline='X07MB'
|
||||
|
||||
# .... check if PHOENIX is ONLINE, if offline, diconnect undulator - mono coupling....
|
||||
|
||||
#dddd
|
||||
|
||||
|
||||
if g['scan_type'] == 'SPECTRA_QUEUE':
|
||||
print 'WRITE XML FILE'
|
||||
|
||||
|
||||
#print g['p_positioner_active']
|
||||
|
||||
#print len(g['p_id'])
|
||||
i=0
|
||||
#print g['p_id']
|
||||
#print g['p_channel']
|
||||
# define base dir for tmp storage
|
||||
#BASE_DIR='/sls/X07MB/data/settings/GUI_TMP/'
|
||||
# writte directly into correct directory..
|
||||
BASE_DIR='/sls/X07MB/data/x07mbop/operation/fda/scans/users/0_Scripted/'
|
||||
for N_position in range(g['n_p']):
|
||||
print ' write xml file for point' +str(N_position)
|
||||
write_xml_XAS_single_point(g,N_position,BASE_DIR)
|
||||
print '... done'
|
||||
#endfor
|
||||
|
||||
print 'DONE WINDOW CLOSED in 3 sec '
|
||||
time.sleep(3)
|
||||
# now copy file to correct place...
|
||||
commands.getstatusoutput('ls /bin/ls')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3830
script/Users/Thomas/backup/backup_20200728_102321/X_X07MB_Pscan.py
Normal file
3830
script/Users/Thomas/backup/backup_20200728_102321/X_X07MB_Pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
2249
script/Users/Thomas/backup/backup_20200728_102321/X_X07MB_lib.py
Normal file
2249
script/Users/Thomas/backup/backup_20200728_102321/X_X07MB_lib.py
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3830
script/Users/Thomas/backup/backup_20200728_102347/X_X07MB_Pscan.py
Normal file
3830
script/Users/Thomas/backup/backup_20200728_102347/X_X07MB_Pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
2249
script/Users/Thomas/backup/backup_20200728_102347/X_X07MB_lib.py
Normal file
2249
script/Users/Thomas/backup/backup_20200728_102347/X_X07MB_lib.py
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3837
script/Users/Thomas/backup/backup_20200731_153145/X_X07MB_Pscan.py
Normal file
3837
script/Users/Thomas/backup/backup_20200731_153145/X_X07MB_Pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
2565
script/Users/Thomas/backup/backup_20200731_153145/X_X07MB_lib.py
Normal file
2565
script/Users/Thomas/backup/backup_20200731_153145/X_X07MB_lib.py
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3901
script/Users/Thomas/backup/backup_20200731_165246/X_X07MB_Pscan.py
Normal file
3901
script/Users/Thomas/backup/backup_20200731_165246/X_X07MB_Pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
2619
script/Users/Thomas/backup/backup_20200731_165246/X_X07MB_lib.py
Normal file
2619
script/Users/Thomas/backup/backup_20200731_165246/X_X07MB_lib.py
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3901
script/Users/Thomas/backup/backup_20200802_181409/X_X07MB_Pscan.py
Normal file
3901
script/Users/Thomas/backup/backup_20200802_181409/X_X07MB_Pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
2619
script/Users/Thomas/backup/backup_20200802_181409/X_X07MB_lib.py
Normal file
2619
script/Users/Thomas/backup/backup_20200802_181409/X_X07MB_lib.py
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3901
script/Users/Thomas/backup/backup_20200811_125738/X_X07MB_Pscan.py
Normal file
3901
script/Users/Thomas/backup/backup_20200811_125738/X_X07MB_Pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
2619
script/Users/Thomas/backup/backup_20200811_125738/X_X07MB_lib.py
Normal file
2619
script/Users/Thomas/backup/backup_20200811_125738/X_X07MB_lib.py
Normal file
File diff suppressed because it is too large
Load Diff
1
script/Users/Thomas/data.json
Normal file
1
script/Users/Thomas/data.json
Normal file
File diff suppressed because one or more lines are too long
1
script/Users/Thomas/lib.py
Normal file
1
script/Users/Thomas/lib.py
Normal file
@@ -0,0 +1 @@
|
||||
#!/usr/bin/env python
|
||||
21
script/Users/Thomas/plotting.py
Normal file
21
script/Users/Thomas/plotting.py
Normal file
@@ -0,0 +1,21 @@
|
||||
###################################################################################################
|
||||
# Direct creation of plots
|
||||
###################################################################################################
|
||||
|
||||
data_1d = [10.0, 20.0, 30.0, 50.0, 80.0]
|
||||
data_2d = [ data_1d, data_1d, data_1d, data_1d, data_1d]
|
||||
data_3d = [ data_2d, data_2d , data_2d, data_2d, data_2d]
|
||||
data_x = [1.0, 2.0, 3.0, 4.0, 5.0]
|
||||
data_y = [2.0, 4.0, 6.0, 8.0, 10.0]
|
||||
|
||||
#1d-plot with optional xdata
|
||||
plot(data_1d, title = "1d", xdata = data_x)
|
||||
|
||||
#2d-plot with optional xdata and ydata
|
||||
plot(data_2d, title = "2d", xdata = data_x, ydata = data_y)
|
||||
|
||||
#3d-plot
|
||||
plot(data_3d, title = "3d")
|
||||
|
||||
#3 plots in the save panel
|
||||
plot([data_1d, data_2d, data_3d], ["1d", "2d", "3d"])
|
||||
135
script/Users/Thomas/save_phoenix.txt
Normal file
135
script/Users/Thomas/save_phoenix.txt
Normal file
@@ -0,0 +1,135 @@
|
||||
Setting PHOENIX Beamline
|
||||
time Mon Jul 27 15:49:54 2020
|
||||
====================================================
|
||||
Undulator 1
|
||||
Undulator_Energy 2540.0 Undulator_Offset -1.0 Undulator_Harmonic 5
|
||||
Undulator_Gap_Set 32.653426886 Undulator_Gap_Read 70.0000664062 Undulator_Shift_Set 0.0 Undulator_Shift_Read 0.00028125
|
||||
==================================================
|
||||
-------------------Bergoz XBPM
|
||||
=================================================
|
||||
Bergoz_FBPMU_X 0.0173412680247 Bergoz_FBPMU_Y 0.0279287403677 Bergoz_FBPMD_X 0.299239429313 Bergoz_FBPMD_Y -0.593922140841
|
||||
===================================================
|
||||
Slit Frontend
|
||||
===================================================
|
||||
Fe_Slit_Hor_Center 0.0535 Fe_Slit_Hor_Size 0.809
|
||||
Fe_Slit_Ver_Center -0.18275 Fe_Slit_Ver_Size 1.0015
|
||||
---------------- Slit Frontend Dvals -------------
|
||||
Fe_Slit_Hor_Ring_TR1 -0.35 Fe_Slit_Hor_Ring_TR1_DVAL -0.35 Fe_Slit_Hor_Wall_TR2 0.45 Fe_Slit_Hor_Wall_TR2_DVAL -0.45
|
||||
Fe_Slit_Ver_Top_TR1 0.317 Fe_Slit_Ver_Top_TR1_DVAL -0.317 Fe_Slit_Ver_Down_TR2 -0.683 Fe_Slit_Ver_Down_TR2_DVAL -0.683
|
||||
----------------- Slit Frontend Offsets -----------
|
||||
Fe_Slit_Hor_Ring_TR2_OFF 0.0 Fe_Slit_Hor_Ring_TR1_OFF 0.0 Fe_Slit_Ver_Top_TR1_OFF 0.0 Fe_Slit_Ver_Down_TR2_OFF 0.0
|
||||
======================================================
|
||||
Mirror 1
|
||||
======================================================
|
||||
------------- RAW VALUES (XTREME COORDINATES---------
|
||||
M1_TRB 9.0 M1_TRB_DVAL 9.0
|
||||
M1_ROX_DVAL 0.45 M1_ROY_DVAL -0.4336 M1_ROZ_DVAL 4.14 M1_TRY_DVAL 1.4499 M1_TRZ_DVAL -0.7501
|
||||
M1_ROX 0.0 M1_ROY -0.03348 M1_ROZ 0.0 M1_TRY 0.0 M1_TRZ -0.55
|
||||
M1_Y 0.0 M1_Z -0.55 M1_Rx 0.0 M1_Ry -0.108 M1_Rz -0.0
|
||||
=======================================================
|
||||
FILTER
|
||||
=======================================================
|
||||
FILTER_ROY_DVAL 1.3 FILTER_TRX_DVAL -0.6
|
||||
========================================================
|
||||
Slit 1 (Focus)r 1
|
||||
========================================================
|
||||
Focus_Slit_Hor_Center -0.21975 Focus_Slit_Hor_Size 0.1895
|
||||
Focus_Slit_Ver_Center 0.51675 Focus_Slit_Ver_Size 0.5475
|
||||
----------------------------Slit 1 (DVALS)r 1 ------------
|
||||
Focus_Slit_Hor_Ring_TRX1 -0.314 Focus_Slit_Hor_Ring_TRX1_DVAL 19.8615 Focus_Slit_Hor_Wall_TRX2 -0.124 Focus_Slit_Hor_Wall_TRX2_DVAL 19.6885
|
||||
Focus_Slit_Ver_Top_TRY1 0.792 Focus_Slit_Ver_Top_TRY1_DVAL -17.721 Focus_Slit_Ver_Down_TRY2 0.242 Focus_Slit_Ver_Down_TRY2_DVAL -20.916
|
||||
----------------------------Slit 1 (OFFSETS) ------------
|
||||
Focus_Slit_Hor_Ring_TRX1_OFF -20.1755 Focus_Slit_Hor_Wall_TRX2_OFF 19.5645 Focus_Slit_Ver_Top_TRY1_OFF 18.513 Focus_Slit_Ver_Down_TRY2_OFF -20.674
|
||||
========================================================
|
||||
Monochromator
|
||||
========================================================
|
||||
Energy_Mono_Set 3000.4 Energy_Mono_Get 3000.40409222
|
||||
Bragg_set 41.2180011301
|
||||
------------------------- Monochromator motors
|
||||
Theta_set 41.2180011301 Theta_set_DVAL 41.3470011301
|
||||
EC_Theta1 41.34688 EC_Theta2 41.3468014063 EC_Theta2 41.3468014063 EC_Theta2 41.3468014063
|
||||
T1_set_DVAL 37.6197315303 T1_set 18.9702684697 T1_rbk 18.97
|
||||
T2_set_DVAL -37.7172540351 T2_set 16.6177459649 T2_rbk 16.618
|
||||
ROLL2 -2480.01730541 ROLL2_ENC 0.0703440909438 PITCH2 -10807.7008285 PITCH2_ENC -0.64255741207
|
||||
ROLL1 780.43 ROLL1_ENC 0.0544747081712
|
||||
Crystal_Position 3.4 Crystal_Position_DVAL -7.0325
|
||||
===============================================================
|
||||
BM 3
|
||||
===============================================================
|
||||
BM3_XRBV -5.0005 BM3_XDRBV -5.0005 BM3_XOFF 0.0
|
||||
BM3_YRBV -17.4997 BM3_YDRBV 17.4997 BM3_YOFF 0.0
|
||||
===========================================================
|
||||
Slit 2 (Exp hutch)
|
||||
===========================================================
|
||||
Sl2_Hor_Center -0.60025 Sl2_Hor_Size 1.0005
|
||||
Sl2_Ver_Center 11.55975 Sl2_Ver_Size 1.0005
|
||||
----------------------------Slit 2 (DVALS)r 1 ------------
|
||||
SL2_Hor_Ring_TRX1 -1.1 SL2_Hor_Ring_TRX1_DVAL -3.681 SL2_Hor_Wall_TRX2 -0.1 SL2_Hor_Wall_TRX2_DVAL -2.6535
|
||||
SL2_Ver_Top_TRY1 12.06 SL2_Ver_Top_TRY1_DVAL -24.127 SL2_Ver_Down_TRY2 11.06 SL2_Ver_Down_TRY2_DVAL -1.514
|
||||
----------------------------Slit 2 (OFFSETS) ------------
|
||||
SL2_Hor_Ring_TRX1_OFF 2.581 SL2_Hor_Wall_TRX2_OFF -2.7535 SL2_Ver_Top_TRY1_OFF -12.067 SL2_Ver_Down_TRY2_OFF 12.574
|
||||
===============================================================
|
||||
BM 4
|
||||
===============================================================
|
||||
BM4_XRBV 33.6762 BM4_XDRBV -18.4504 BM4_XOFF 15.2258
|
||||
BM4_YRBV -10.0159642435 BM4_YDRBV 9.6926642435 BM4_YOFF -0.3233
|
||||
===============================================================
|
||||
PHOENIX I KB System 1 (XRADIA)
|
||||
===============================================================
|
||||
PICOMOTORS
|
||||
KB_Ver_TILT 0.0148012512398 KB_Ver_TRANS 0.0160219729915 KB_Ver_BUP 0.0148012512398 KB_Ver_BDO 0.0157167925536
|
||||
|
||||
KB_Hor_TILT 0.0148012512398 KB_Hor_TRANS 0.0141908903639 KB_Hor_BUP -0.0108339055467 KB_Hor_BDO 0.0950637064164
|
||||
|
||||
ADDITIONAL MOTORS
|
||||
|
||||
OP-KB:HTILT2.RBV 0.3770032 OP-KB:HTILT2.OFF -7.79
|
||||
OP-KB:HTRX2.RBV -0.53125 OP-KB:HTRX2.OFF -13.775
|
||||
OP-KB:VTILT2.RBV 0.3318672 OP-KB:VTILT2.OFF -6.54
|
||||
OP-KB:VTRY2.VAL -0.87795 OP-KB:VTRY2.OFF -6.01
|
||||
|
||||
ES-MA1:ScanX.RBV 1.00005 ES-MA1:ScanX.OFF -6.905
|
||||
ES-MA1:ScanY.RBV 0.31645 ES-MA1:ScanY.OFF -11.08
|
||||
ES-MA1:ROT.RBV 70.00479 ES-MA1:ROT.OFF -32.03
|
||||
ES-MA1:TRX1.RBV 0.47355 ES-MA1:TRX1.OFF -0.551
|
||||
ES-MA1:TRZ1.RBV 7.8005 ES-MA1:TRZ1.OFF -16.68
|
||||
===============================================================
|
||||
PHOENIX I KB System 2 (IDT)
|
||||
===============================================================
|
||||
|
||||
Soft motors
|
||||
|
||||
KB2_Ver_TILT 0.0997900456728 KB2_Ver_TRANS -1.695 KB2_Ver_FOCUS 1.5005 KB2_Ver_ELLIP -0.5595
|
||||
KB2_Hor_TILT 0.00023873240807 KB2_Hor_TRANS -2.1355 KB2_Hor_FOCUS 2.741 KB2_Hor_ELLIP -0.195
|
||||
|
||||
===============================================================
|
||||
|
||||
Physical motors
|
||||
|
||||
ES2-KB2:HTRUP.RBV -2.136 ES2-KB2:HTRUP.OFF 0.0 ES2-KB2:HTRDN.RBV -2.135 ES2-KB2:HTRDN.OFF 0.0
|
||||
|
||||
ES2-KB2:VTRUP.RBV -1.904 ES2-KB2:VTRUP.OFF 0.0 ES2-KB2:VTRDN.RBV -1.486 ES2-KB2:VTRDN.OFF 0.0
|
||||
|
||||
===============================================================
|
||||
|
||||
========================================================
|
||||
Status BE window (ES1): 5 = open / 2 = closed
|
||||
|
||||
Be_ES1_open CLOSED
|
||||
Be_ES2_open CLOSED
|
||||
|
||||
========================================================
|
||||
========================================================
|
||||
Pressure KB and ES1
|
||||
|
||||
P_OP_KB1 9.3876712042e-08 P_ES1_MC1 0.000659409337437
|
||||
P_ES1_RVMT1 0.0607930827683 P_ES1_MF1 1.15042686082e-06
|
||||
|
||||
Pressure KB2 and ES3 (Chemistry chamber)
|
||||
|
||||
P_ES2_KB2 2.83890335648 P_ES3_MC1 0.0475109792189
|
||||
P_ES3_MF1 0.0547575046518 P_ES3_RVMT1 0.0522863481316
|
||||
|
||||
Pressure Adaptation KBS-user chamber )
|
||||
|
||||
P_ES2_KB2_MF3 2.10020304941e-07 P_ES2_MC2 0.0473135497201
|
||||
0
script/Users/Thomas/scandef.dat
Normal file
0
script/Users/Thomas/scandef.dat
Normal file
145
script/Users/Thomas/t1.py
Normal file
145
script/Users/Thomas/t1.py
Normal file
@@ -0,0 +1,145 @@
|
||||
#Script imported from: Mono_pitch.xml
|
||||
|
||||
#Pre-actions
|
||||
caput('X07MB-OP2:START-CSMPL', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:StopAll', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:PresetMode', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-XMAP:PresetReal', '0')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP2:TOTAL-CYCLES', '1')
|
||||
sleep(0.1)
|
||||
print('dd')
|
||||
|
||||
x_min = -12.3
|
||||
x_max = -12.2
|
||||
delta = 0.01
|
||||
N_step = int((x_max-x_min)/delta)
|
||||
|
||||
#TODO: Set the diplay names of positioners and detectors
|
||||
scan = ManualScan(['Pitch'], ['bm3', 'bm4', 'Filter_RY', 'Harmonic', 'TC_Y', 'TC_Z', 'T_THETA', 'Id_OFF', 'Id_energy', 'E_Mono', 'Bragg_Id_theo', 'Theta_rbv', 'Theta_offset', 'Delta_E', 'Delta_theta', 'XX'] , [x_min], [x_max], [N_step])
|
||||
scan.start()
|
||||
|
||||
|
||||
#Creating channels: dimension 1
|
||||
#LinearPositioner ScanX
|
||||
Pitch = Channel('X07MB-ES-MA1:ScanX.VAL', type = 'd')
|
||||
PitchReadback = Channel('X07MB-ES-MA1:ScanX.RBV', type = 'd')
|
||||
#ScalarDetector bm3
|
||||
bm3 = Channel('X07MB-OP2-SAI_03:MEAN', type = 'd')
|
||||
#ScalarDetector bm4
|
||||
bm4 = Channel('X07MB-OP2-SAI_04:MEAN', type = 'd')
|
||||
#ScalarDetector Filter_RY
|
||||
Filter_RY = Channel('X07MB-OP-FI:ROY.VAL', type = 'd')
|
||||
#ScalarDetector Harmonic
|
||||
Harmonic = Channel('X07MA-ID:HARMONIC', type = 'd')
|
||||
#ScalarDetector TC_Y
|
||||
TC_Y = Channel('X07MB-OP-MOC2:TC_Y', type = 'd')
|
||||
#ScalarDetector TC_Z
|
||||
TC_Z = Channel('X07MB-OP-MOC2:TC_Z', type = 'd')
|
||||
#ScalarDetector T_THETA
|
||||
T_THETA = Channel('X07MB-OP-MOTHETA:TC1', type = 'd')
|
||||
#ScalarDetector Id_OFF
|
||||
Id_OFF = Channel('X07MA-ID:ENERGY-OFFS', type = 'd')
|
||||
#ScalarDetector Id_energy
|
||||
Id_energy = Channel('X07MA-ID:ENERGY', type = 'd')
|
||||
#ScalarDetector E_Mono
|
||||
E_Mono = Channel('X07MB-OP-MO:E-GET', type = 'd')
|
||||
#ScalarDetector Bragg_Id_theo
|
||||
Bragg_Id_theo = Channel('X07MB-OP-MO:BRAGG-CALC', type = 'd')
|
||||
#ScalarDetector Theta_rbv
|
||||
Theta_rbv = Channel('X07MB-OP-MO:THETA.RBV', type = 'd')
|
||||
#ScalarDetector Theta_offset
|
||||
Theta_offset = Channel('X07MB-OP-MO:THETA.OFF', type = 'd')
|
||||
|
||||
#Dimension 1
|
||||
#Dimension Guard
|
||||
cawait('ACOAU-ACCU:OP-MODE', 6, type = 'l')
|
||||
#LinearPositioner Pitch
|
||||
for setpoint1 in frange(x_min ,x_max, delta, True):
|
||||
if setpoint1 > x_max or setpoint1 < x_min:
|
||||
break
|
||||
Pitch.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
|
||||
readback1 = PitchReadback.get()
|
||||
if abs(readback1 - setpoint1) > 10.0 : # TODO: Check accuracy
|
||||
print readback1, setpoint1
|
||||
raise Exception('Actor Pitch could not be set to the value ' + str(setpoint1))
|
||||
#Detector bm3
|
||||
#Detector X07MB-OP2-SAI_03:MEAN pre-actions
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.1)
|
||||
cawait('X07MB-OP2:SMPL-DONE', 1, type = 'l')
|
||||
detector1 = bm3.get()
|
||||
#Detector bm4
|
||||
detector2 = bm4.get()
|
||||
#Detector Filter_RY
|
||||
detector3 = Filter_RY.get()
|
||||
#Detector Harmonic
|
||||
detector4 = Harmonic.get()
|
||||
#Detector TC_Y
|
||||
detector5 = TC_Y.get()
|
||||
#Detector TC_Z
|
||||
detector6 = TC_Z.get()
|
||||
#Detector T_THETA
|
||||
detector7 = T_THETA.get()
|
||||
#Detector Id_OFF
|
||||
detector8 = Id_OFF.get()
|
||||
#Detector Id_energy
|
||||
detector9 = Id_energy.get()
|
||||
#Detector E_Mono
|
||||
detector10 = E_Mono.get()
|
||||
#Detector Bragg_Id_theo
|
||||
detector11 = Bragg_Id_theo.get()
|
||||
#Detector Theta_rbv
|
||||
detector12 = Theta_rbv.get()
|
||||
#Detector Theta_offset
|
||||
detector13 = Theta_offset.get()
|
||||
#Manipulation Delta_E
|
||||
#Variable Mappings
|
||||
a = detector10
|
||||
b = detector9
|
||||
Delta_E = a-b
|
||||
#Manipulation Delta_theta
|
||||
#Variable Mappings
|
||||
a = detector11
|
||||
b = detector12
|
||||
Delta_theta = a-b
|
||||
#Manipulation XX
|
||||
#Variable Mappings
|
||||
a = detector11
|
||||
b = detector12
|
||||
XX = a*b
|
||||
print(XX)
|
||||
scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, detector10, detector11, detector12, detector13, Delta_E, Delta_theta, E_Mono, XX])
|
||||
|
||||
#Closing channels
|
||||
Pitch.close()
|
||||
PitchReadback.close()
|
||||
bm3.close()
|
||||
bm4.close()
|
||||
Filter_RY.close()
|
||||
Harmonic.close()
|
||||
TC_Y.close()
|
||||
TC_Z.close()
|
||||
T_THETA.close()
|
||||
Id_OFF.close()
|
||||
Id_energy.close()
|
||||
E_Mono.close()
|
||||
Bragg_Id_theo.close()
|
||||
Theta_rbv.close()
|
||||
Theta_offset.close()
|
||||
|
||||
scan.end()
|
||||
|
||||
|
||||
#Post-actions
|
||||
caput('X07MB-OP2:START-CSMPL', '1')
|
||||
sleep(0.1)
|
||||
caput('X07MB-OP2:START-CSMPL', '1')
|
||||
sleep(0.3)
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.3)
|
||||
caput('X07MB-OP2:SMPL', '1')
|
||||
sleep(0.3)
|
||||
13
script/Users/Thomas/test5.py
Normal file
13
script/Users/Thomas/test5.py
Normal file
@@ -0,0 +1,13 @@
|
||||
chan='X07MB-ES-MA1:ScanX.VAL'
|
||||
d=Channel(chan)
|
||||
d.put(0)
|
||||
caput('X07MB-ES-MA1:ScanX.VAL',0.1)
|
||||
print('caput(X07MB-ES-MA1:ScanX.VAL,0.1)', d.read())
|
||||
caput('X07MB-ES-MA1:ScanX.VAL','0.2')
|
||||
print('caput(X07MB-ES-MA1:ScanX.VAL, str(0.2))', d.read() )
|
||||
d.put(0.3)
|
||||
print('d.put(0.3)',d.read())
|
||||
d.put('0.4')
|
||||
print('d.put(0.3)',d.read())
|
||||
|
||||
|
||||
25
script/Users/Thomas/test6.py
Normal file
25
script/Users/Thomas/test6.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import time
|
||||
|
||||
C=Channel('X07MB-OP2:SMPL-DONE',type='i') # readback sampling finished
|
||||
S=Channel('X07MB-OP2:SMPL') # star sampling (TTL signal)
|
||||
wait_value=1
|
||||
print(C.read)
|
||||
print('Value before pressing button' ,C.read(),'wait for', wait_value)
|
||||
|
||||
print('press button, in 2 sec,X07MB-OP2:SMPL-DONE should turn from 0 to 1 ')
|
||||
|
||||
t0=time.time()
|
||||
|
||||
print('time',time.time()-t0)
|
||||
S.putq(1)
|
||||
print('Value after pressing button before .wait_for_value',C.read(),'wait for', wait_value)
|
||||
print('time before wait ',(time.time()-t0))
|
||||
# now wait for
|
||||
#C.wait_for_value(wait_value,timeout=5)
|
||||
cawait('X07MB-OP2:SMPL-DONE',wait_value,timeout=7)
|
||||
print('time after wait ',(time.time()-t0))
|
||||
print('Value after .wait_for_valuea',C.read())
|
||||
print('..... done .... ')
|
||||
print('read X07MB-OP2:SMPL-DONE with caget',caget('X07MB-OP2:SMPL-DONE','i'))
|
||||
|
||||
|
||||
25
script/Users/Thomas/test7.py
Normal file
25
script/Users/Thomas/test7.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import time
|
||||
|
||||
c='X07MB-OP2:TOTAL-CYCLES'
|
||||
c='X07MB-OP2:SMPL'
|
||||
c='X07MB-OP2:SMPL'
|
||||
c='X07MB-OP-WV1:WT_SET'
|
||||
c='X07MB-OP-MO:E-SET.OUT'
|
||||
c='X07MB-OP2:SMPL'
|
||||
|
||||
c='X07MB-OP-KEITH3:setGain'
|
||||
c='X07MB-OP2:START-CSMPL'
|
||||
c='X07MB-OP2:SMPL-DONE'
|
||||
C=Channel(c)
|
||||
print(c)
|
||||
d=C.get()
|
||||
print('read as such' ,d)
|
||||
print(type(d))
|
||||
C=Channel(c,type='i')
|
||||
d=C.get()
|
||||
print('as int',d)
|
||||
print(type(d))
|
||||
C=Channel(c,type='d')
|
||||
d=C.get()
|
||||
print('as double',d)
|
||||
print(c)
|
||||
25
script/Users/Thomas/test78.py
Normal file
25
script/Users/Thomas/test78.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import time
|
||||
|
||||
c='X07MB-OP2:TOTAL-CYCLES'
|
||||
c='X07MB-OP2:SMPL'
|
||||
c='X07MB-OP2:SMPL'
|
||||
c='X07MB-OP-WV1:WT_SET'
|
||||
c='X07MB-OP-MO:E-SET.OUT'
|
||||
c='X07MB-OP2:SMPL'
|
||||
|
||||
c='X07MB-OP-KEITH3:setGain'
|
||||
c='X07MB-OP2:START-CSMPL'
|
||||
c='X07MB-OP2:SMPL-DONE'
|
||||
C=Channel(c)
|
||||
print(c)
|
||||
d=C.get()
|
||||
print('read as such' ,d)
|
||||
print(type(d))
|
||||
C=Channel(c,type='i')
|
||||
d=C.get()
|
||||
print('as int',d)
|
||||
print(type(d))
|
||||
C=Channel(c,type='d')
|
||||
d=C.get()
|
||||
print('as double',d)
|
||||
print(c)
|
||||
14
script/Users/Thomas/test8.py
Normal file
14
script/Users/Thomas/test8.py
Normal file
@@ -0,0 +1,14 @@
|
||||
d=0
|
||||
d=Channel('X07MB-OP2:SMPL-DONE')
|
||||
|
||||
#ee=caget('X07MB-OP2:SMPL-DONE')
|
||||
#print(ee)
|
||||
|
||||
for i in range(1000):
|
||||
time.sleep(4)
|
||||
d=0
|
||||
d=Channel('X07MB-OP2:SMPL-DONE')
|
||||
e=d.read()
|
||||
print(e)
|
||||
#endfor
|
||||
|
||||
7
script/Users/Thomas/test9.py
Normal file
7
script/Users/Thomas/test9.py
Normal file
@@ -0,0 +1,7 @@
|
||||
d=0
|
||||
d=Channel('X07MB-OP2:SMPL-DONE')
|
||||
|
||||
#ee=caget('X07MB-OP2:SMPL-DONE')
|
||||
#print(ee)
|
||||
e=d.read()
|
||||
print(e)
|
||||
4
script/Users/Thomas/test:py.py
Normal file
4
script/Users/Thomas/test:py.py
Normal file
@@ -0,0 +1,4 @@
|
||||
d={'a':1,
|
||||
'b':2}
|
||||
print(d)
|
||||
|
||||
30
script/Users/Thomas/test_dataset_save.py
Normal file
30
script/Users/Thomas/test_dataset_save.py
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
data2d = [ [1.0, 2.0, 3.0, 4.0, 5.0], [2.0, 3.0, 4.0, 5.0, 6.0, ], [3.0, 4.0, 5.0, 6.0, 7.0]]
|
||||
|
||||
#Creating a 2D data FLOAT dataset adding lines one by one
|
||||
path = "group/data1"
|
||||
create_dataset(path, 'd', False, (0,0))
|
||||
for row in data2d:
|
||||
append_dataset(path, row)
|
||||
|
||||
|
||||
#Creating a Table (compund type)
|
||||
path = "group/data2"
|
||||
names = ["a", "b", "c",]
|
||||
types = ["d", "d", "d",]
|
||||
|
||||
table = [ [1,2,3],
|
||||
[2,3,4],
|
||||
[3,4,5,] ]
|
||||
|
||||
create_table(path, names, types)
|
||||
for row in table:
|
||||
append_table(path, row)
|
||||
|
||||
set_attribute("group/data2", "att", 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1684
script/Users/Thomas/test_pscan.py
Normal file
1684
script/Users/Thomas/test_pscan.py
Normal file
File diff suppressed because it is too large
Load Diff
331
script/Users/Thomas/test_pscan.v1.py
Normal file
331
script/Users/Thomas/test_pscan.v1.py
Normal file
@@ -0,0 +1,331 @@
|
||||
import traceback
|
||||
import imp
|
||||
import os
|
||||
from CaChannel import *
|
||||
from epicsMotor import *
|
||||
from epicsPV import *
|
||||
import time
|
||||
import string
|
||||
import sys
|
||||
import json
|
||||
|
||||
# TO DO: Energy scan has onlz 1 positioner
|
||||
# need to generalize definition of scans to several paraller positiner,
|
||||
# to be able to use Create_Channels, alteratively need a dedicate channel creation for each scan type
|
||||
# tricky, code should stay simple
|
||||
# options.
|
||||
# Define channel generation for each chanenl separatelz
|
||||
# generalze scand to 1d and 2d with seveal posittioner in each dimension.
|
||||
# this will get complicated .....
|
||||
|
||||
import X_X07MB_Pscan as PS
|
||||
import X_X07MB_lib as PL
|
||||
imp.reload(PS) # always reload module
|
||||
imp.reload(PL) # always reload module
|
||||
|
||||
|
||||
NoRead=0
|
||||
|
||||
def before_pass():
|
||||
get_context().dataManager.provider.embeddedAtributes = False
|
||||
# Called at begining pf scan
|
||||
print('before_pass')
|
||||
SC.PerformActions('Pre_Actions')
|
||||
pars=get_exec_pars()
|
||||
print('pars.output : ')
|
||||
print(pars.output)
|
||||
print('pars.scanPath: ')
|
||||
print(pars.scanPath)
|
||||
print('pars.name: (filename) ')
|
||||
print(pars.name)
|
||||
# missing
|
||||
# NEED TO SET path for Moench here
|
||||
#end before_pass
|
||||
|
||||
|
||||
def before_read():
|
||||
# Cannot call routine in class in rscan call, need to go via local routine
|
||||
#print('before_read')
|
||||
# SC.DetectorActions() excecutes all standard action as defied in GUI
|
||||
SC.PerformActions('Detector_Actions')
|
||||
#print('.... done before_read ' )
|
||||
|
||||
# alternativly use caput here explicitly...
|
||||
# if needed
|
||||
#end before read
|
||||
|
||||
def after_read(rec,scan):
|
||||
print('ENTER after_read .................' )
|
||||
# Called after reading
|
||||
# calculate default dead time corrections and writ to file
|
||||
SC.after_read_dtc(rec,scan)
|
||||
print('.... done after_read ' )
|
||||
return
|
||||
#end after_read init
|
||||
|
||||
def after_pass():
|
||||
# Called after scan
|
||||
print('after_pass')
|
||||
|
||||
SC.PerformActions('Post_Actions')
|
||||
print('................ done after_pass')
|
||||
#end after pass
|
||||
|
||||
|
||||
def before_region(index,scan):
|
||||
print (index)
|
||||
|
||||
# make some reset
|
||||
try:
|
||||
del SC
|
||||
except:
|
||||
SC=0
|
||||
#endexept
|
||||
# originbal tag for data saving
|
||||
# '{data}/{year}/{month}/{day}/{year}_{month}{day}_{time}_{name}'
|
||||
# ........... FIrst read the scan
|
||||
#
|
||||
|
||||
# ====================================================
|
||||
#
|
||||
# SCRIPT STARTS HERE
|
||||
#
|
||||
# ====================================================
|
||||
if NoRead==0:
|
||||
try:
|
||||
SD = 0
|
||||
SD = PS.get_channels('SPECTRA') # READ SCAN DEFINITION FROM GUI USING OLD CODE
|
||||
print('returned from PS.get_channels()')
|
||||
SC=0
|
||||
SC=PL.PscanLib(SD,Channel,caput,caputq,caget,cawait,get_exec_pars,create_table,append_table) # create instance of library
|
||||
|
||||
print('... done SC.Create_All_Sensors()')
|
||||
SD.update({'All_Sensors':[]})
|
||||
except:
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
raise
|
||||
# endexcept
|
||||
# endif
|
||||
print('dddddddddddddddddddddddddd')
|
||||
# example add new sensor, similarly add pre and postactions to existing code
|
||||
|
||||
New_Sensors=[]
|
||||
New_Sensors.append({'channel_name': 'X07MB-ES-MA1:ScanY.RBV'
|
||||
, 'Subset_1': False
|
||||
, 'Det_type': 'ScalarDetector'
|
||||
, 'alias': 'MYSCANY_RBV'
|
||||
, 'data_type': 'double'})
|
||||
|
||||
# examples add post action light on
|
||||
|
||||
SD['Post_Actions'].append({'channel_name': 'X07MB-ES1-PP2:VO5'
|
||||
, 'data_type': 'String'
|
||||
, 'alias': 'Light_ON'
|
||||
, 'operation': 'put'
|
||||
, 'delay' : 0.1
|
||||
, 'value' : 5 })
|
||||
|
||||
# END OF USER INPUT
|
||||
|
||||
# .... add new sensors to list
|
||||
try:
|
||||
try:
|
||||
del AllSensors
|
||||
except:
|
||||
AllSensors=0
|
||||
#endecsept
|
||||
All_Sensors = SC.Create_Sensor_List() # Create instance for all sensors
|
||||
SC.Add_New_Sensors(New_Sensors) # Add user sensors
|
||||
except:
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
raise
|
||||
# endexcept
|
||||
|
||||
# STRUCTUALR INCONSITENCY NEED TO CREATE List of sensors first
|
||||
# without making Channel command.... !
|
||||
#
|
||||
# TEST SAVE SCAN DEFINITION...Needs to be before definition
|
||||
# SD is full GUI definiton of the scan try to save and reread this definiton
|
||||
|
||||
SD.update({'New_Sensors' : New_Sensors})
|
||||
f=open('scandef.dat','w')
|
||||
# Method to save abnd restore full scan definition...
|
||||
with open('BaseScanDefinition.json', 'w') as fp:
|
||||
json.dump(SD, fp,ensure_ascii=True)
|
||||
#endwith
|
||||
with open('BaseScanDefinition.json', 'r') as dd:
|
||||
SD_reread=json.load(dd)
|
||||
# .. this works, reread is unicode not string, but code seems still to work if all entries are in unicode
|
||||
|
||||
asd
|
||||
# step I: CREATE ALL SENSORS AND STORE IN A LIST
|
||||
print('++++++++++++++++++++++++++')
|
||||
AllSensors=0
|
||||
try:
|
||||
# Code for beamline save......
|
||||
SavePhoenix=PL.SavePhoenix(Channel,caput,caputq,caget,cawait) # Channel,caput,caputq,caget,cawait)
|
||||
# SavePhoenix.write_beamline_data().. Works., move to before pass...
|
||||
|
||||
SC.noprint=0 # chose printing from SD on / off
|
||||
|
||||
# Now creat all epic s instances. print('... done SC.Create_All_Sensors()')
|
||||
SD.update({'All_Sensors':All_Sensors})
|
||||
SC.Create_Channels('All_Sensors')
|
||||
SC.Create_Channels('All_Positioner')
|
||||
SC.Create_Channels('Detector_Actions')
|
||||
SC.Create_Channels('Pre_Actions')
|
||||
SC.Create_Channels('Post_Actions')
|
||||
SC.Create_Channels('Energy_Scan')
|
||||
except:
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
raise
|
||||
# endexcept
|
||||
|
||||
# ... create some abbreviations...
|
||||
All_Sensors = SC.All_Sensors
|
||||
All_Positioner = SD['All_Positioner']
|
||||
Pre_Actions = SD['Pre_Actions']
|
||||
Post_Actions = SD['Post_Actions']
|
||||
Detector_Actions = SD['Detector_Actions']
|
||||
Energy_Scan = SD['Energy_Scan']
|
||||
|
||||
|
||||
#............SOME OUTPUT
|
||||
#print('----------- All_Positioner ---')
|
||||
#print(' ')
|
||||
#print(SD['All_Positioner'])
|
||||
#print(' ------------ Pre_Action -------- ')
|
||||
#print(' ')
|
||||
#print(SD['Pre_Actions'])
|
||||
#print(' ------------ Post_Action -------- ')
|
||||
#print(' ')
|
||||
#print(SD['Post_Actions'])
|
||||
#print(' ')
|
||||
#print(' ----------- Detector_Action--------- ')
|
||||
#print(' ')
|
||||
#print(SD['Detector_Actions'])
|
||||
## ............. MISSING CREATE POSTACTIONS::::::
|
||||
|
||||
# STEP II read the energy position
|
||||
print('')
|
||||
print('..................................... positioner Energy ID? readback automatically saved? ')
|
||||
print('initial energies e_i ',SD['e_i'])
|
||||
print('final energies e_f ',SD['e_f'])
|
||||
print('DELTA E e_delta ',SD['e_delta'])
|
||||
print('DWELL TIME e_n_cycles',SD['e_n_cycles'])
|
||||
print(SD['Energy_Scan']['Energy_Ranges'])
|
||||
|
||||
#try:
|
||||
# EnergyRanges,Cycles = SC.PositionerEnergyScan()
|
||||
#except:
|
||||
# traceback.print_tb(sys.exc_info()[2])
|
||||
# raise
|
||||
# endexcept nowcall
|
||||
#print(EnergyRanges,Cycles)
|
||||
|
||||
# STEP II ... read the detector actions
|
||||
|
||||
# Step IV perform the Preaction
|
||||
#P=SC.DetectorActions()
|
||||
|
||||
print(All_Sensors)
|
||||
print('Energy_Ranges')
|
||||
print(SD['Energy_Scan']['Energy_Ranges'])
|
||||
|
||||
pars=get_exec_pars()
|
||||
print('pars.output')
|
||||
print(pars.output)
|
||||
print('pars.scanPath')
|
||||
print(pars.scanPath)
|
||||
print(' ')
|
||||
print('---------------')
|
||||
print(' ')
|
||||
print(' CALL SCAN NOW ')
|
||||
print(' ')
|
||||
|
||||
p=set_exec_pars(name=SD['filename'])
|
||||
# This is one singe energy scan:
|
||||
|
||||
|
||||
# save scan definition
|
||||
|
||||
get_context().dataManager.provider.embeddedAtributes = False
|
||||
asd
|
||||
# .. now make individual scan for all positioners as defiens in GUI
|
||||
# as we like want to have separete datasets for each scan \
|
||||
#stop
|
||||
for i in range(len(All_Positioner[0]['value'])): # loop in number of points
|
||||
# set all positioner
|
||||
for j in range(len(All_Positioner)): # set positioner
|
||||
t0=time.time()
|
||||
ThisPositioner = All_Positioner[j]['Channel']
|
||||
ThisPosition = All_Positioner[j]['value'][i]
|
||||
print('next,i,j',i,j)
|
||||
print('name',All_Positioner[j]['channel_name'])
|
||||
print('value',All_Positioner[j]['value'][i])
|
||||
print(time.time()-t0)
|
||||
# .............. SET NEW POSITIONER
|
||||
#ThisPositioner.write(ThisPosition)
|
||||
ThisPositioner.put(ThisPosition)
|
||||
#ThisPositioner.putq(ThisPosition) # simultaneous walk no waiting..
|
||||
print(time.time()-t0)
|
||||
#endfor loop set positioner
|
||||
# generate filename
|
||||
p=set_exec_pars(name=SD['filename']+'_'+All_Positioner[0]['label'][i])
|
||||
pars=get_exec_pars()
|
||||
print('filename this run : ')
|
||||
print(pars.name)
|
||||
|
||||
print('--------------- NEXT SCAN ----------------')
|
||||
try:
|
||||
rscan(SD['Energy_Scan']['Channel']
|
||||
, SC.get_list(All_Sensors,'Channel')
|
||||
, regions=SD['Energy_Scan']['Energy_Ranges']
|
||||
, latency = 0.0, relative = False
|
||||
, before_pass = SC.PerformActions('Pre_Actions') # before_pass
|
||||
, before_read = before_read #SC.PerformActions('Detector_Actions') # before_read
|
||||
, after_read = SC.after_read_dtc #after_read
|
||||
, after_pass = after_pass
|
||||
, before_region = before_region
|
||||
, enabled_plots=['I0_KEITHLEY1','I1_KEITHLEY2','D1_ICR','D1_OCR'])
|
||||
|
||||
#vscan(SD['Energy_Scan']['Channel']
|
||||
# , SC.get_list(All_Sensors,'Channel')
|
||||
# , vector=SD['Energy_Scan']['Energy_Scan_Positions']
|
||||
# , latency = 0.0, relative = False
|
||||
# , before_pass = SC.PerformActions('Pre_Actions') # before_pass
|
||||
# , before_read = before_read #SC.PerformActions('Detector_Actions') # before_read
|
||||
# , after_read = SC.after_read_dtc #after_read
|
||||
# , after_pass = after_pass
|
||||
# , before_region = before_region
|
||||
# , enabled_plots=['I0_KEITHLEY1','I1_KEITHLEY2','D1_ICR','D1_OCR'])
|
||||
|
||||
except:
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
raise
|
||||
# END EXecpt
|
||||
#endfor
|
||||
#endfor
|
||||
print('... scan finished ')
|
||||
#
|
||||
|
||||
#ret = lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, enabled_plots=['X07MB-OP2-SAI_07:MEAN'])
|
||||
|
||||
|
||||
#rscan("ca://X07MB-OP-MO:E-SET", sensors, [[2450.0, 2455.0, 1.0], [2456.0, 2460.0, 0.5]], latency = 0.0, relative = False)
|
||||
|
||||
|
||||
#def BeforeReadout(position, scan):
|
||||
# print "In position: " + str(pposition)
|
||||
|
||||
|
||||
#def AfterReadout(record, scan):
|
||||
# print "Aquired record: " + str(record)
|
||||
|
||||
#lscan("ca://X07MB-OP-MO:E-SET", sensors, start=2450, end=2460, steps=10, latency=0.0, relative = False, before_read=BeforeReadout, after_read=AfterReadout)
|
||||
#rscan("ca://X07MB-OP-MO:E-SET", sensors, [[2450.0, 2455.0, 1.0], [2456.0, 2460.0, 0.5]], latency = 0.0, relative = False)
|
||||
#ascan(["ca://X07MB-OP-MO:E-SET", "X07MB-ES-MA1:ScanX.VAL"], sensors, start=[2450, 1.6], end=[2460, 1.8], steps=[2.0,0.05], latency=0.0, relative = False, zigzag = True)
|
||||
##
|
||||
#
|
||||
# Vizualization...............
|
||||
#
|
||||
5
script/example_1.py
Normal file
5
script/example_1.py
Normal file
@@ -0,0 +1,5 @@
|
||||
c = Channel("X07MB-OP2-SAI_03:CUR-MEAN", 'd')
|
||||
|
||||
x = lscan(m1, [channel, c] , 0.0, 1.0, 10, latency = 0.1, relative = False, passes = 1, zigzag = False, before_read = None, after_read = None, title = None)
|
||||
|
||||
print "FIle: " , x.root
|
||||
3
script/local.groovy
Normal file
3
script/local.groovy
Normal file
@@ -0,0 +1,3 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Deployment specific global definitions - executed after startup.groovy
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
4
script/local.js
Normal file
4
script/local.js
Normal file
@@ -0,0 +1,4 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Deployment specific global definitions - executed after startup.js
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
140
script/local.py
Normal file
140
script/local.py
Normal file
@@ -0,0 +1,140 @@
|
||||
###################################################################################################
|
||||
# Deployment specific global definitions - executed after startup.py
|
||||
###################################################################################################
|
||||
|
||||
import ch.psi.fda.ProcessorFDA as ProcessorFDA
|
||||
import ntpath
|
||||
|
||||
NO_BEAM_CHECK = False
|
||||
ABORT_ON_ID_ERROR = False
|
||||
|
||||
|
||||
#Layout
|
||||
get_context().dataManager.provider.embeddedAtributes=False
|
||||
|
||||
|
||||
#Device initialization
|
||||
energy_ma.setBlockingWrite(True)
|
||||
pol_mode.setpoint.setBlockingWrite(True)
|
||||
pol_offset.setBlockingWrite(True)
|
||||
pol_angle.setBlockingWrite(True)
|
||||
|
||||
|
||||
#Utilities
|
||||
def run_fda(file_name, arguments={}):
|
||||
"""
|
||||
Run FDA loop
|
||||
"""
|
||||
ProcessorFDA().execute(file_name,arguments)
|
||||
|
||||
|
||||
def otf(start, end, time, delay=0.0, mode = None, offset = None, alpha = None, name = None):
|
||||
"""
|
||||
"""
|
||||
if name is None:
|
||||
name = get_exec_pars().name
|
||||
|
||||
if len(name)> 38:
|
||||
name = name[:38]
|
||||
print('WARNING: Sample name too long. Name has been truncated.')
|
||||
|
||||
run("EnergyScan_ma", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "NAME":name, "ALPHA":float(alpha) if alpha is not None else None})
|
||||
|
||||
|
||||
|
||||
|
||||
def has_beam():
|
||||
"""
|
||||
"""
|
||||
return beam_status.readback.read() !="Machine Down"
|
||||
|
||||
def wait_beam():
|
||||
"""
|
||||
"""
|
||||
if not has_beam():
|
||||
print "Waiting for beam... "
|
||||
if NO_BEAM_CHECK:
|
||||
print "Maintenence mode: disregarding beam state"
|
||||
return
|
||||
while not has_beam():
|
||||
sleep(0.1)
|
||||
print "Beam OK."
|
||||
|
||||
def wait_pol_done(delay=1.0):
|
||||
"""
|
||||
"""
|
||||
print "Waiting for pol done"
|
||||
time.sleep(delay) #Make sure value changed
|
||||
while True:
|
||||
try:
|
||||
if caget("X07MA-ID:DONE") == "DONE":
|
||||
break
|
||||
except:
|
||||
print "Error reading pol done"
|
||||
time.sleep(0.5)
|
||||
print "Done"
|
||||
|
||||
def wait_channel(name, value, timeout=None, type='s'):
|
||||
print "Waiting " + str(name) + " = " + str(value),"... "
|
||||
cawait(name, value, timeout = timeout, type=type)
|
||||
|
||||
def is_id_error():
|
||||
return (id_error.read()==0)
|
||||
|
||||
def check_id_error():
|
||||
if is_id_error():
|
||||
raise Exception ("ID error: check ID status")
|
||||
|
||||
def wait_id_ok():
|
||||
"""
|
||||
"""
|
||||
if is_id_error():
|
||||
print "ID error: waiting..."
|
||||
while True:
|
||||
time.sleep(1.0) #Make sure value changed
|
||||
try:
|
||||
if not is_id_error():
|
||||
break
|
||||
except:
|
||||
print "Error reading id error"
|
||||
print "Done"
|
||||
|
||||
def set_pol(mode=None, alpha=None, offset=None):
|
||||
if mode is not None:
|
||||
print "Set pol mode: ", mode
|
||||
pol_mode.write(mode)
|
||||
if MODE == 'LINEAR':
|
||||
if alpha is not None:
|
||||
print "Set pol alpha: ", alpha
|
||||
pol_angle.write(alpha)
|
||||
wait_pol_done(1.0)
|
||||
|
||||
if offset is not None:
|
||||
print "Set pol offset: ", offset
|
||||
pol_offset.write(offset)
|
||||
|
||||
def set_energy_ma(value):
|
||||
print "Setting energy ma to: ", value
|
||||
energy_ma.write(float(E1)) # no need to add wait command. This commands sets and waits.
|
||||
print "Done"
|
||||
|
||||
###################################################################################################
|
||||
#Default scan callbacks
|
||||
###################################################################################################
|
||||
|
||||
def before_sample(position, scan):
|
||||
pass
|
||||
|
||||
def after_sample(record=None, scan=None):
|
||||
if ABORT_ON_ID_ERROR:
|
||||
check_id_error()
|
||||
return True
|
||||
if is_id_error():
|
||||
if (record is not None):
|
||||
record.invalidate()
|
||||
print "ID error, waiting..."
|
||||
while is_id_error():
|
||||
time.sleep(1.0)
|
||||
print "ID OK"
|
||||
return False
|
||||
return True
|
||||
763
script/local_xtreme.py
Normal file
763
script/local_xtreme.py
Normal file
@@ -0,0 +1,763 @@
|
||||
###################################################################################################
|
||||
# Deployment specific global definitions - executed after startup.py
|
||||
###################################################################################################
|
||||
|
||||
import ch.psi.fda.ProcessorFDA as ProcessorFDA
|
||||
import ch.psi.pshell.data.LayoutFDA as LayoutFDA
|
||||
import ntpath
|
||||
import traceback
|
||||
import ch.psi.pshell.epics.ChannelSettlingCondition as ChannelSettlingCondition
|
||||
|
||||
WAIT_STABLE_TEMPERATURE = True # True : before energy scan and hyst scan the routine wait_temp() is launched
|
||||
NO_BEAM_CHECK = False # setting this to true disables the waiting for the beam before starting energy or hyst scan
|
||||
ABORT_ON_ID_ERROR = False
|
||||
|
||||
_SAMPLE_NAME = "DUMMY"
|
||||
|
||||
#As the folder is shared to all daily datasets, then configuration must be set to {data}/{year}_{month}/{date}
|
||||
#and the file prefix manually set as:
|
||||
LayoutFDA.setFilePrefix("{date}_{hour}{min}_{name}")
|
||||
|
||||
|
||||
energy.setBlockingWrite(True)
|
||||
pol_mode.setpoint.setBlockingWrite(True)
|
||||
pol_offset.setBlockingWrite(True)
|
||||
pol_angle.setBlockingWrite(True)
|
||||
|
||||
|
||||
energy_id.setSettlingCondition(ChannelSettlingCondition("X07MA-ID:DONE", 'DONE'))
|
||||
energy_id.settlingCondition.latency = 10
|
||||
|
||||
|
||||
#If True, then wait_beam will not check machine status
|
||||
maintenance_mode = False
|
||||
|
||||
|
||||
#Reading Energy Scan configuration file
|
||||
def getPars(element):
|
||||
f = open(get_context().setup.getConfigPath() + '/energy_scan.properties')
|
||||
try:
|
||||
for line in f:
|
||||
tokens = line.split("=")
|
||||
if tokens[0] == str(element):
|
||||
tokens = tokens[1].split(";")
|
||||
for i in range(len(tokens)):
|
||||
tokens[i] = float(tokens[i].strip())
|
||||
|
||||
return tokens
|
||||
finally:
|
||||
f.close()
|
||||
raise Exception ("Invalid element: " + str(element))
|
||||
|
||||
def is_id_error():
|
||||
return (id_error.read()==0)
|
||||
|
||||
def check_id_error():
|
||||
if is_id_error():
|
||||
raise Exception ("ID error: check ID status")
|
||||
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Pseudo-devices
|
||||
###################################################################################################
|
||||
sim_energy = None
|
||||
class SimulatedEnergy(Writable):
|
||||
def write(self, value):
|
||||
self.put(value)
|
||||
|
||||
def put(self, value, timeout = None):
|
||||
global sim_energy
|
||||
sim_energy = value
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
|
||||
class SimulatedEnergyReadback(Readable):
|
||||
def read(self):
|
||||
global sim_energy
|
||||
return sim_energy;
|
||||
|
||||
def get(self):
|
||||
return self.read()
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
sim_energy = SimulatedEnergy()
|
||||
sim_energy_readback = SimulatedEnergyReadback()
|
||||
|
||||
|
||||
|
||||
class TeyNorm(ReadonlyRegisterBase):
|
||||
def read(self):
|
||||
return signal_tey.take() / signal_i0.take();
|
||||
|
||||
class TransNorm(ReadonlyRegisterBase):
|
||||
def read(self):
|
||||
return signal_trans.take() / signal_i0.take();
|
||||
|
||||
add_device(TeyNorm("tey_norm"), True)
|
||||
add_device(TransNorm("trans_norm"), True)
|
||||
set_device_alias(temperature.readback, "temperature_readback")
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Utilities
|
||||
###################################################################################################
|
||||
|
||||
def run_fda(file_name, arguments={}):
|
||||
"""
|
||||
Run FDA loop
|
||||
"""
|
||||
ProcessorFDA().execute(file_name,arguments)
|
||||
|
||||
|
||||
run ("Accumulator")
|
||||
|
||||
def get_next_fid(folder, prefix):
|
||||
try:
|
||||
import glob
|
||||
files = glob.glob(folder + prefix + '*_*.txt')
|
||||
last = max(files)
|
||||
index = int (last[last.rfind('_')+1 : last.rfind('.')]) + 1
|
||||
return index
|
||||
except:
|
||||
return 0
|
||||
|
||||
def wait_channel(name, value, timeout=None, type='s'):
|
||||
print "Waiting " + str(name) + " = " + str(value),"... "
|
||||
cawait(name, value, timeout = timeout, type=type)
|
||||
# print "Done waiting."
|
||||
|
||||
def wait_device(dev, value, timeout=-1):
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
#print "Waiting " + dev.getName() + " = " + str(value),"... "
|
||||
dev.waitValue(value,timeout)
|
||||
# print "Done waiting."
|
||||
|
||||
def wait_device_in_range(dev, value, range, timeout=-1):
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
print "Waiting " + dev.getName() + " = " + str(value),"... "
|
||||
dev.waitValueInRange(value, range, timeout)
|
||||
# print "Done waiting."
|
||||
|
||||
#TODO:
|
||||
# - OTF outout folder should not be /sls/X07MA/data/x07maop/Data1/yyyy_mm/yyyymmdd/ but somewhere visible to e account.
|
||||
# - One option is make /sls/X07MA/data/x07maop/Data1/OTF mode 755, and configure OTF to write /sls/X07MA/data/x07maop/Data1/OTF/yyyymmdd
|
||||
# - Then e-account (and x07maop) read from there (get the newest file) and don't have to move the file there after processing.
|
||||
|
||||
def convert_file(input_file_name, output_file_name, pol = None):
|
||||
#print "Converting data file: " + input_file_name + " to " + output_file_name
|
||||
print "File converted to: ",output_file_name
|
||||
sep = "\t"
|
||||
line_sep = "\n"
|
||||
MODE = pol_mode.read()
|
||||
if pol is None:
|
||||
pol = pol_angle.read() if (MODE == "LINEAR") else pol_mode.readback.read()
|
||||
with open(input_file_name) as inp:
|
||||
lines = inp.readlines()
|
||||
with open(output_file_name, "wb") as out:
|
||||
#Original header:
|
||||
#out.write("Ecrbk" + sep + "CADC1" + sep + "CADC2" + sep + "CADC3" + sep + "CADC4" + sep + "CADC5" + sep + "MCurr" + sep + "Time" + sep + "FieldX" + sep + "FieldZ" + sep + "Pol" + sep + "Temperature" + sep + "NORMtey" + sep + "NORMdiode" + line_sep)
|
||||
#Compatible header:
|
||||
(db, st) = ("java.lang.Double", "java.lang.String")
|
||||
out.write("#Ecrbk" + sep + "CADC1" + sep + "CADC2" + sep + "CADC3" + sep + "CADC4" + sep + "CADC5" + sep + "MCurr" + sep + "Time" + sep + "FieldX" + sep + "FieldZ" + sep + "Pol" + sep + "Temperature" + sep + "NORMtey" + sep + "NORMdiode" + line_sep)
|
||||
out.write("#"+ db + sep + db + sep + db + sep + db + sep + db + sep + db + sep + db + sep + db + sep + db + sep + db + sep + st + sep + db + sep + db + sep + db + line_sep)
|
||||
s = sep
|
||||
for line in lines[1:]:
|
||||
line = line.strip()
|
||||
if line=="": break
|
||||
try:
|
||||
(Ecrbk, CADC1, CADC2, CADC3, CADC4, CADC5, MCurr, cffrbk, IDErbk, NORM, time, MAGX, MAGZ, EXPT) = line.split(" ")
|
||||
normtey=repr( float(CADC1)/float(CADC2))
|
||||
normdiode=repr(float(CADC3)/float(CADC2))
|
||||
out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + CADC4 + s + CADC5 + s + MCurr + s + time + s + MAGX + s + MAGZ + s + str(pol) + s + EXPT + s + normtey + s + normdiode + line_sep)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
os.rename(input_file_name, get_context().setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name)))
|
||||
|
||||
def plot_file(file_name, title = None):
|
||||
"""
|
||||
"""
|
||||
table = Table.load(file_name, "\t", '#')
|
||||
plots = plot(table, title = title)
|
||||
|
||||
|
||||
def elog(title, message, attachments = [], author = None, category = "Info", domain = "", logbook = "XTREME", encoding=1):
|
||||
"""
|
||||
Add entry to ELOG.
|
||||
"""
|
||||
if author is None:
|
||||
author = "pshell" #get_context().user.name
|
||||
typ = "pshell"
|
||||
entry = ""
|
||||
|
||||
cmd = 'G_CS_ELOG_add -l "' + logbook + '" '
|
||||
cmd = cmd + '-a "Author=' + author + '" '
|
||||
cmd = cmd + '-a "Type=' + typ + '" '
|
||||
cmd = cmd + '-a "Entry=' + entry + '" '
|
||||
cmd = cmd + '-a "Title=' + title + '" '
|
||||
cmd = cmd + '-a "Category=' + category + '" '
|
||||
cmd = cmd + '-a "Domain=' + domain + '" '
|
||||
for attachment in attachments:
|
||||
cmd = cmd + '-f "' + attachment + '" '
|
||||
cmd = cmd + '-n ' + str(encoding)
|
||||
cmd = cmd + ' "' + message + '"'
|
||||
#print cmd
|
||||
#os.system (cmd)
|
||||
#print os.popen(cmd).read()
|
||||
import subprocess
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
|
||||
(out, err) = proc.communicate()
|
||||
if (err is not None) and err!="":
|
||||
raise Exception(err)
|
||||
print out
|
||||
|
||||
def get_plot_snapshots(title = None, file_type = "png", temp_path = get_context().setup.getContextPath()):
|
||||
"""
|
||||
Returns list with file names of plots snapshots from a plotting context.
|
||||
"""
|
||||
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
|
||||
ret = []
|
||||
for p in get_plots(title):
|
||||
file_name = os.path.abspath(temp_path + "/" + p.getTitle() + "." + file_type)
|
||||
p.saveSnapshot(file_name , file_type)
|
||||
ret.append(file_name)
|
||||
return ret
|
||||
|
||||
|
||||
###################################################################################################
|
||||
#Default scan callbacks
|
||||
###################################################################################################
|
||||
|
||||
def before_sample(position, scan):
|
||||
pass
|
||||
|
||||
def after_sample(record=None, scan=None):
|
||||
if ABORT_ON_ID_ERROR:
|
||||
check_id_error()
|
||||
return True
|
||||
if is_id_error():
|
||||
if (record is not None):
|
||||
record.invalidate()
|
||||
print "ID error, waiting..."
|
||||
while is_id_error():
|
||||
time.sleep(1.0)
|
||||
print "ID OK"
|
||||
return False
|
||||
return True
|
||||
|
||||
###################################################################################################
|
||||
#Definitions for importing text batch files
|
||||
###################################################################################################
|
||||
#TODO: Should set devices? K10, k11, k24 seem not to be defined....
|
||||
keithleys = {
|
||||
#name:[Setpoint, range, Readback] #TODO
|
||||
# "k1": [None , 'X07MA-PC-K428:1:setGain', 'X07MA-PC-K428:1:getGain'],
|
||||
# "k2": [None , 'X07MA-PC-K428:2:setGain', 'X07MA-PC-K428:2:getGain'],
|
||||
# "k3": [None , 'X07MA-PC-K428:3:setGain', 'X07MA-PC-K428:3:getGain'],
|
||||
"k1": [None , 'X07MA-PC-K428:1:setGain', 'X07MA-PC-K428:1:getGain','X07MA-PC-K428:1:setGain10x','X07MA-PC-K428:1:getGain10x'],
|
||||
"k2": [None , 'X07MA-PC-K428:2:setGain', 'X07MA-PC-K428:2:getGain','X07MA-PC-K428:2:setGain10x','X07MA-PC-K428:2:getGain10x'],
|
||||
"k3": [None , 'X07MA-PC-K428:3:setGain', 'X07MA-PC-K428:3:getGain','X07MA-PC-K428:3:setGain10x','X07MA-PC-K428:3:getGain10x'],
|
||||
"k10":['X07MA-KEI10:SETVOLTAGE' , 'X07MA-KEI10:RANGE', None, None, None],
|
||||
"k11":['X07MA-KEI11:SETVOLTAGE' , 'X07MA-KEI11:RANGE', None, None, None],
|
||||
"k24":['X07MA-KEI2400:setVoltAO', None, None, None, None]
|
||||
}
|
||||
|
||||
def set_hx(field, timeout = -1):
|
||||
"""
|
||||
"""
|
||||
iPS = False # false for old (Cryogenics) power supply, True for new (Oxford Instr) supply
|
||||
|
||||
fieldx = field_x_ips if iPS else field_x
|
||||
field_done = None if iPS else field_x_done
|
||||
|
||||
FIELD_PRECISION = 0.01
|
||||
|
||||
# line below was field.readback.read(). Changed on Feb. 12 2019 because of error message that no readback was found
|
||||
if abs(field_x.readback.read() - field) > FIELD_PRECISION: # added in Feb. 2019 to avoid hanging when setting to current field
|
||||
print 'Setting Hx to ',field,' Tesla...'
|
||||
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
|
||||
fieldx.write(float(field))
|
||||
|
||||
#if iPS == True:
|
||||
# caput("X07MA-PC-MAG:X:DMD",float(field))
|
||||
|
||||
time.sleep(3.0) # wait 3s
|
||||
|
||||
### this waiting procedure was introduced because sometimes the field does not move and the whole script gets stuck then.
|
||||
difference = field_x.readback.read() - field
|
||||
print 'difference at beginning is ',difference,' Tesla...'
|
||||
difference0 = difference # difference0 is the field offset before entering the stabilization loop
|
||||
last_difference = difference # last_difference is updated during the stabilization loop
|
||||
while abs(difference) > FIELD_PRECISION:
|
||||
print 'difference inside while loop is ',difference,' Tesla...'
|
||||
time.sleep(5.0)
|
||||
difference = field_x.readback.read() - field
|
||||
# resend a start ramp in case nothing is happening, ie when it is stuck in this waitfield
|
||||
if abs(difference-difference0) < FIELD_PRECISION:
|
||||
caput('X07MA-PC-MAG:STARTRAMP.PROC',1)
|
||||
print('Field setting stuck: re-starting ramp')
|
||||
print 'difference after resetting is ',difference,' Tesla...'
|
||||
# also resend a start ramp in case nothing is happening wrt to the last 5 seconds
|
||||
elif abs(difference-last_difference) < FIELD_PRECISION:
|
||||
caput('X07MA-PC-MAG:STARTRAMP.PROC',1)
|
||||
print('Field setting stuck: re-starting ramp')
|
||||
print 'difference after resetting is ',difference,' Tesla...'
|
||||
last_difference = difference
|
||||
#print 'difference after resetting is ',difference,' Tesla...'
|
||||
print 'Finished while loop'
|
||||
|
||||
if iPS == True:
|
||||
field_x_ips_output.waitValue(0,timeout)
|
||||
while caget("X07MA-ES1-IPS:OUTPUT_RBV", "i") != 0 :
|
||||
time.sleep(0.1)
|
||||
#else: # removed else since loop above already checks if field is done. Had crash already by timeout below. CP 7.09.21
|
||||
# extra safety
|
||||
#try:
|
||||
#field_x_done.waitValue(1,timeout)
|
||||
#except:
|
||||
#pass
|
||||
|
||||
print "Done setting magnetic field"
|
||||
|
||||
|
||||
|
||||
def set_hz(field, timeout = -1):
|
||||
"""
|
||||
"""
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
field_z.write(float(field))
|
||||
print 'Setting Hz to',field,'Tesla...'
|
||||
time.sleep(3.0) # wait 3s
|
||||
try:
|
||||
field_z_done.waitValue(1,timeout)
|
||||
except:
|
||||
print('Timeout exceeded for setting z field!')
|
||||
|
||||
print "Done setting magnetic field"
|
||||
|
||||
def set_pol_cplus(offset = None, timeout = -1):
|
||||
"""
|
||||
"""
|
||||
print "Set x-ray polarization to c+"
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
pol_mode.write("CIRC +")
|
||||
if offset is not None:
|
||||
pol_offset.write(float(offset))
|
||||
wait_pol_done(1.0)
|
||||
print "Done setting x-ray polarization"
|
||||
|
||||
def set_pol_cminus(offset = None, timeout = -1):
|
||||
"""
|
||||
"""
|
||||
print "Set x-ray polarizaton to c-"
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
pol_mode.write("CIRC -")
|
||||
if offset is not None:
|
||||
pol_offset.write(float(offset))
|
||||
time.sleep(0.5)
|
||||
wait_pol_done(1.0)
|
||||
print "Done setting x-ray polarization"
|
||||
|
||||
def set_pol_lin(angle, offset = None, timeout = -1):
|
||||
"""
|
||||
"""
|
||||
print "Set x-ray polarization to linear"
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
pol_mode.write("LINEAR")
|
||||
pol_angle.write(float(angle))
|
||||
if offset is not None:
|
||||
pol_offset.write(float(offset))
|
||||
wait_pol_done(1.0)
|
||||
#pol_done.waitValue("DONE",timeout) # it hangs.Must use wait_device. CP June 21
|
||||
print "Done setting x-ray polarization"
|
||||
|
||||
def set_temp(value, in_position_band = None):
|
||||
"""
|
||||
"""
|
||||
print "Set sample temperature"
|
||||
temperature.write(float(value))
|
||||
if in_position_band is None:
|
||||
in_position_band = temperature.getResolution()
|
||||
#TODO: Replace when this flag works for all temperatures
|
||||
#cawait("X07MA-ES1-TEMP:STATUS", "Stable")
|
||||
#return
|
||||
#temperature.readback.waitValueInRange(float(value), in_position_band, -1)
|
||||
wait_device_in_range(temperature.readback, float(value), in_position_band, -1)
|
||||
time.sleep(600.0) # wait 10min
|
||||
print "Done setting temperature"
|
||||
|
||||
def open_valve(delay = 0.75, timeout=500.0):
|
||||
"""
|
||||
"""
|
||||
print "Opening valve"
|
||||
start = time.time()
|
||||
valve_try_open.write(1) #TODO: CAPUT
|
||||
time.sleep(0.1)
|
||||
time.sleep(float(delay))
|
||||
while caget("X07MA-OP-VG13:POSITION", "i") != 5 :
|
||||
#if (timeout>0) and (time.time()-start > timeout):
|
||||
#raise Exception("Timeout opening the valve") # it happened that script crashed at this point so commenting out. CP Sept/21
|
||||
print "Retry open valve"
|
||||
valve_try_open.write(1)
|
||||
time.sleep(1.0)
|
||||
print "Valve opened"
|
||||
|
||||
def close_valve(delay = 0.5, timeout=10.0): #TODO: Check default delay
|
||||
"""
|
||||
"""
|
||||
print "Closing valve"
|
||||
valve_try_open.write(0)
|
||||
time.sleep(0.1)
|
||||
time.sleep(float(delay))
|
||||
while caget("X07MA-OP-VG13:POSITION", "i") != 2 :
|
||||
#if (timeout>0) and (time.time()>timeout):
|
||||
#raise Exception("Timeout opening the valve")
|
||||
print "Retry close valve"
|
||||
valve_try_open.write(0)
|
||||
time.sleep(1.0)
|
||||
print "Valve closed"
|
||||
|
||||
def close_shutter(delay = 0.5): #TODO: Check default delay
|
||||
"""
|
||||
"""
|
||||
print "Close photon shutter"
|
||||
time.sleep(float(delay))
|
||||
caput("X07MA-FE-PH1:CLOSE4BL",0)
|
||||
|
||||
|
||||
def set_energy (value, delay=0.5):
|
||||
print "Set energy"
|
||||
time.sleep(float(delay))
|
||||
timeout_ms = 90000 # 1.5 minutes
|
||||
tolerance = 0.3
|
||||
energy.write(float(value))
|
||||
#try:
|
||||
#energy_done.waitValue(1, timeout_ms) # timeout is now 90 sec, was -1
|
||||
#except:
|
||||
#if abs(energy.read() - energy_readback.read()) > tolerance:
|
||||
#throw
|
||||
time.sleep(float(delay))
|
||||
print "Done setting energy"
|
||||
|
||||
|
||||
def old_set_energy (value, delay=0.5):
|
||||
"""
|
||||
"""
|
||||
print "Set energy"
|
||||
energy.write(float(value))
|
||||
energy_done.waitValue(1, -1) # timeout is now 60, was -1
|
||||
time.sleep(float(delay))
|
||||
print "Done setting energy"
|
||||
|
||||
def set_cff (value):
|
||||
"""
|
||||
"""
|
||||
cff.write(float(value))
|
||||
caput("X07MA-PGM:setE.PROC",1)
|
||||
energy_done.waitValue(1, -1)
|
||||
|
||||
def set_slit(value):
|
||||
"""
|
||||
"""
|
||||
exit_slit.write(float(value))
|
||||
|
||||
#1 or 3
|
||||
def set_har(value):
|
||||
"""
|
||||
"""
|
||||
print "Set harmonic"
|
||||
harmonic.write(float(value))
|
||||
print "Done setting harmonic"
|
||||
|
||||
#Not connected
|
||||
def set_volt(keithley, value, delay=0.1):
|
||||
"""
|
||||
"""
|
||||
#keithley.write(fl'10^'+str(8)oat(value))
|
||||
if not keithltey in keithleys.keys(): raise Exception("Invalid keithley: " + keithley)
|
||||
caput(keithleys[keithley][0], float(value))
|
||||
time.sharmonicleep(float(delay))
|
||||
|
||||
#value is int from 1 to 10
|
||||
def set_range(keithley, value):
|
||||
"""
|
||||
"""
|
||||
print "Set Keithley range"
|
||||
if not keithley in keithleys.keys(): raise Exception("Invalid keithley: " + keithley)
|
||||
v='10^'+str(value)
|
||||
if value==11:
|
||||
while True:
|
||||
caput(keithleys[keithley][1], '10^10')
|
||||
caput(keithleys[keithley][3], '10x')
|
||||
time.sleep(1.0)
|
||||
if (caget(keithleys[keithley][2],'s') == '10^10') and (caget(keithleys[keithley][4],'s') == '10x'):
|
||||
break
|
||||
else:
|
||||
while True:
|
||||
caput(keithleys[keithley][1], v)
|
||||
caput(keithleys[keithley][3], '1x')
|
||||
time.sleep(1.0)
|
||||
if (caget(keithleys[keithley][2],'s') == v) and (caget(keithleys[keithley][4],'s') == '1x'):
|
||||
break
|
||||
print "Done setting Keithley range"
|
||||
|
||||
|
||||
def set_fe(opening):
|
||||
"""
|
||||
"""
|
||||
opening = int(opening*1000)
|
||||
if opening==0:
|
||||
aperture.write("closed")
|
||||
elif opening==100:
|
||||
aperture.write("0.1x0.1 mm")
|
||||
elif opening==250:
|
||||
aperture.write("0.25x0.25 mm")
|
||||
elif opening==500:
|
||||
aperture.write("0.5x0.5 mm")
|
||||
elif opening==1000:
|
||||
aperture.write("1x1 mm")
|
||||
elif opening==1250:
|
||||
aperture.write("1.25x1.25 mm")
|
||||
elif opening==2000:
|
||||
aperture.write("2x2 mm")
|
||||
else:
|
||||
raise Exception("Invalid aperture opening: " + str(opening))
|
||||
|
||||
def refill_1k():
|
||||
"""
|
||||
"""
|
||||
#print "in refill_1k"
|
||||
run("refill_1kpot")
|
||||
|
||||
def wait_temp():
|
||||
"""
|
||||
"""
|
||||
#print "blabla"
|
||||
# if (temperature.read() < 2.0):
|
||||
# t=ct=temperature.readback.read()
|
||||
#hl=caget("X07MA-PC-HE:LEVELB", 'd') # TODO: not used
|
||||
# if (t > 3.7):
|
||||
# print "Refilling 1K pot..."
|
||||
# refill_1k()
|
||||
print "Check temperature"
|
||||
run("TEMP_wait_fill.py")
|
||||
print "Temperature OK"
|
||||
|
||||
def rampdown():
|
||||
"""
|
||||
"""
|
||||
field_x.write(0.0)
|
||||
field_z.write(0.0)
|
||||
|
||||
def shutdown():
|
||||
"""
|
||||
"""
|
||||
set_fe(0)
|
||||
rampdown()
|
||||
|
||||
|
||||
def has_beam():
|
||||
"""
|
||||
"""
|
||||
return beam_status.readback.read() !="Machine Down"
|
||||
|
||||
def wait_beam():
|
||||
"""
|
||||
"""
|
||||
print "Waiting for beam... ",
|
||||
while not has_beam():
|
||||
if maintenance_mode:
|
||||
print "Maintenence mode: disregarding beam state"
|
||||
return
|
||||
sleep(0.1)
|
||||
print "Beam OK."
|
||||
|
||||
def wait_inj (value, delay=0.5):
|
||||
"""
|
||||
"""
|
||||
wait_channel('X07MA-OP2-EVR:TOPUP-STAT', 'TOPUP-ON')
|
||||
wait_channel('X07MA-OP2-EVR:TOPUP-STAT', 'TOPUP-OFF')
|
||||
time.sleep(float(delay))
|
||||
|
||||
|
||||
def set_file(file_name):
|
||||
"""
|
||||
"""
|
||||
#set_exec_pars(name = file_name) #Increment index for each scan, and keep timestamp
|
||||
set_exec_pars(name = file_name, reset=True) #Different timestamp for each scan, index set to 0
|
||||
|
||||
class pol_mod(Readable):
|
||||
def read(self):
|
||||
mode = pol_mode.read()
|
||||
if mode == "LINEAR": return 0.0
|
||||
if mode == "CIRC +": return 1.0
|
||||
if mode == "CIRC -": return 2.0
|
||||
return -1.0
|
||||
polmod = pol_mod()
|
||||
|
||||
|
||||
def otf(start, end, time, delay=0.0, mode = None, offset = None, alpha = None, name = None):
|
||||
"""
|
||||
"""
|
||||
if name is None:
|
||||
name = get_exec_pars().name
|
||||
folder = get_context().setup.expandPath("{year}_{month}/{date}");
|
||||
|
||||
if len(name)> 38:
|
||||
name = name[:38]
|
||||
print('WARNING: Sample name too long. Name has been truncated.')
|
||||
|
||||
#run("EnergyScan", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "ALPHA":float(alpha) if alpha is not None else None})
|
||||
run("EnergyScan_v2", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "ALPHA":float(alpha) if alpha is not None else None})
|
||||
|
||||
def otf2(start, end, time, delay=0.0, mode = None, offset = None, alpha = None, name = None):
|
||||
"""
|
||||
"""
|
||||
if name is None:
|
||||
name = get_exec_pars().name
|
||||
folder = get_context().setup.expandPath("{year}_{month}/{date}");
|
||||
|
||||
if len(name)> 38:
|
||||
name = name[:38]
|
||||
print('WARNING: Sample name too long. Name has been truncated.')
|
||||
|
||||
run("EnergyScan_v2", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "ALPHA":float(alpha) if alpha is not None else None})
|
||||
|
||||
def hyst_cont(field, init_field, final_field, ramp_speed, energies):
|
||||
"""
|
||||
"""
|
||||
run("HystScan",{"FIELD":field, "START_FIELD":init_field, "END_FIELD":final_field, "ENERGIES":energies, "RAMP_RATE":ramp_speed, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
|
||||
|
||||
def hyst_cont_ESR(field, init_field, final_field, ramp_speed, energies):
|
||||
"""
|
||||
"""
|
||||
run("HystScan_ESR",{"FIELD":field, "START_FIELD":init_field, "END_FIELD":final_field, "ENERGIES":energies, "RAMP_RATE":ramp_speed, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
|
||||
|
||||
def acq_cont_ESR_N(field, init_field, datapoints, energies):
|
||||
"""
|
||||
"""
|
||||
run("TimeScan_ESR",{"FIELD":field, "START_FIELD":init_field, "ACQPOINTS":datapoints, "ACQLIM":"POINTS", "ENERGIES":energies, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
|
||||
|
||||
def acq_cont_ESR_t(field, init_field, acqtime, energies):
|
||||
"""
|
||||
"""
|
||||
run("TimeScan_ESR",{"FIELD":field, "START_FIELD":init_field, "ACQTIME_SECS":acqtime, "ACQLIM":"TIME", "ENERGIES":energies, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
|
||||
|
||||
def hyst_cont_mult(field, ranges, energies):
|
||||
"""
|
||||
"""
|
||||
run("HystScanMult",{"FIELD":field, "RANGES":ranges, "ENERGIES":energies, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
|
||||
|
||||
def hyst_step(forward, field, init_field, final_field, step, energies, energy_change_sleep = 0.5, field_change_sleep = 22.0, mode = None, offset=None):
|
||||
"""
|
||||
"""
|
||||
run("HystScanStep",{"FIELD":field, "RANGES":[(init_field, final_field, step),], "ENERGIES":energies, "ENERGY_CHANGE_SLEEP":energy_change_sleep, "FIELD_CHANGE_SLEEP":field_change_sleep, "MODE":mode, "OFFSET":offset})
|
||||
|
||||
def hyst_step_mult(forward, ranges, ramp_speed, energies, energy_change_sleep = 0.5, field_change_sleep = 22.0, mode = None, offset=None):
|
||||
"""
|
||||
"""
|
||||
run("HystScanStep",{"FIELD":field, "RANGES":ranges, "ENERGIES":energies, "ENERGY_CHANGE_SLEEP":energy_change_sleep, "FIELD_CHANGE_SLEEP":field_change_sleep, "MODE":mode, "OFFSET":offset})
|
||||
|
||||
def scan_e(start, end, step, settling_time = 0, accumulation_time = None, name = None):
|
||||
"""
|
||||
"""
|
||||
if name is not None:
|
||||
set_file(name = name)
|
||||
wait_beam()
|
||||
acc = Accumulator([signal_tey, signal_i0, signal_trans, tey_norm, trans_norm], accumulation_time)
|
||||
detectors = acc.getSensors() + [polmod, pol_angle, temperature.readback, current]
|
||||
set_preference(Preference.ENABLED_PLOTS, acc.getSensors())
|
||||
lscan(energy, detectors, float(start), float(end), float(step), latency = settling_time, before_read=before_sample, after_read=after_sample)
|
||||
|
||||
def scan_e_mult(ranges, settling_time = 0, accumulation_time = None, name = None):
|
||||
"""
|
||||
"""
|
||||
if name is not None:
|
||||
set_file(name = name)
|
||||
wait_beam()
|
||||
acc = Accumulator([energy_readback,signal_tey, signal_i0, signal_trans, tey_norm, trans_norm], accumulation_time)
|
||||
detectors = acc.getSensors() + [polmod, pol_angle, temperature.readback, current]
|
||||
set_preference(Preference.ENABLED_PLOTS, acc.getSensors())
|
||||
rscan(energy, detectors, ranges, latency = settling_time, before_read=before_sample, after_read=after_sample)
|
||||
|
||||
#not connected
|
||||
def scan_v(keithley,start, end, step):
|
||||
"""
|
||||
"""
|
||||
setpoint = Channel (keithleys[keithley][0], 'd')
|
||||
readback = Channel (keithleys[keithley][2], 'd')
|
||||
lscan(setpoint, readback, float(start), float(end), float(step), latency = 0.1, before_read=before_sample, after_read=after_sample)
|
||||
|
||||
|
||||
def set_hor(value):
|
||||
"""
|
||||
"""
|
||||
print "Set sample horizontal positon"
|
||||
sample_hor.move(float(value))
|
||||
print "Done setting horizontal position"
|
||||
|
||||
def set_vert(value):
|
||||
"""
|
||||
"""
|
||||
print "Set sample vertical position"
|
||||
sample_vert.move(float(value))
|
||||
print "Done setting vertical position"
|
||||
|
||||
def set_rot(value):
|
||||
"""
|
||||
"""
|
||||
sample_rot.move(float(value))
|
||||
|
||||
|
||||
def set_au_mesh(value):
|
||||
"""
|
||||
"""
|
||||
print "Set Au mesh positon"
|
||||
au_mesh.move(value)
|
||||
print "Done setting Au mesh"
|
||||
|
||||
|
||||
def wait_pol_done(delay=1.0):
|
||||
print "Waiting for pol done"
|
||||
time.sleep(delay) #Make sure value changed
|
||||
while True:
|
||||
try:
|
||||
if caget("X07MA-ID:DONE") == "DONE":
|
||||
break
|
||||
except:
|
||||
print "Error reading pol done"
|
||||
time.sleep(0.5)
|
||||
print "Done"
|
||||
|
||||
def get_scan_filename():
|
||||
return str(get_exec_pars().output) + str(get_exec_pars().scanPath) + ".txt"
|
||||
|
||||
def log_scan_filename(name=None):
|
||||
if name is None:
|
||||
name=get_scan_filename()
|
||||
msg = "Created data file: " + str(name)
|
||||
print msg
|
||||
log(msg)
|
||||
|
||||
def write_logs():
|
||||
log("Exit slit: "+ str(exit_slit.read()), True)
|
||||
log("Cff: " + str(cff.read()))
|
||||
log("Harm: " + str(harmonic.read()))
|
||||
log("FE: " + str(aperture.read() ))
|
||||
log("Au mesh: " + str(au_mesh.read() ))
|
||||
log("Sample temperature: " + str(temperature.readback.read() ) )
|
||||
log("Sample coord. HOR; VERT; ROT: " + str(sample_hor.read()) + "; " + str(sample_vert.read()) + "; " + str(sample_rot.read()) )
|
||||
log("Gain sample: " + str(caget(keithleys["k1"][2])))
|
||||
log("Gain i0: " + str(caget(keithleys["k2"][2])))
|
||||
log("Gain diode: " + str(caget(keithleys["k3"][2])))
|
||||
log("XBPM1:V: " + str(caget ("X07MA-FE-XBPM1:posV")))
|
||||
log("XBPM2:V: " + str(caget ("X07MA-FE-XBPM2:posV")))
|
||||
log("XBPM1:H: " + str(caget ("X07MA-FE-XBPM1:posH")))
|
||||
log("XBPM2:H: " + str(caget ("X07MA-FE-XBPM2:posH")))
|
||||
|
||||
12
script/otf.py
Normal file
12
script/otf.py
Normal file
@@ -0,0 +1,12 @@
|
||||
####################################################################################
|
||||
# Deployment specific global definitions - executed after startup.py
|
||||
###################################################################################################
|
||||
|
||||
c = Channel("X07MB-OP2-SAI_03:CUR-MEAN", 'd')
|
||||
|
||||
dd="X07MB-OP2-SAI_03:CUR-MEAN"
|
||||
|
||||
f=caget("X07MB-OP2-SAI_03:CUR-MEAN")
|
||||
tscan(c, 100, .1, before_read = None, after_read = None, title = None)
|
||||
|
||||
print d
|
||||
1206
script/points_q_0.py
Normal file
1206
script/points_q_0.py
Normal file
File diff suppressed because it is too large
Load Diff
6
script/test.py
Normal file
6
script/test.py
Normal file
@@ -0,0 +1,6 @@
|
||||
c = Channel("X07MB-OP2-SAI_03:CUR-MEAN", 'd')
|
||||
|
||||
dd="X07MB-OP2-SAI_03:CUR-MEAN"
|
||||
|
||||
f=caget("X07MB-OP2-SAI_03:CUR-MEAN")
|
||||
tscan(c, 100, .1, before_read = None, after_read = None, title = None)
|
||||
146
script/test/Blade_scan.py
Normal file
146
script/test/Blade_scan.py
Normal file
@@ -0,0 +1,146 @@
|
||||
#Number of cycles must be small otherwise generates a following error
|
||||
def before_read(position, scan):
|
||||
global total_time, steps,d_output
|
||||
import time
|
||||
if d_output ==1:
|
||||
print('enter before_read')
|
||||
start = time.time()
|
||||
caput("X07MB-OP2:SMPL",1)
|
||||
time.sleep(0.75)
|
||||
if d_output ==1:
|
||||
print "Waiting..."
|
||||
cawait ("X07MB-OP2:SMPL-DONE",1, 10000)
|
||||
print "Done"
|
||||
t = time.time()-start
|
||||
if d_output ==1:
|
||||
print t
|
||||
if t > (total_time/steps):
|
||||
print "Before took too long, step = ", (total_time/steps)
|
||||
if d_output ==1:
|
||||
print('leave before_read')
|
||||
# end before_read
|
||||
print(t)
|
||||
|
||||
|
||||
def after(record, scan):
|
||||
pass
|
||||
|
||||
from mathutils import *
|
||||
from plotutils import *
|
||||
|
||||
#setup_plotting(line_plots = [mca_1])
|
||||
|
||||
print('running')
|
||||
# scan definition
|
||||
#centre = -0.858 # Vertical
|
||||
centre = 5 # for hor scan)
|
||||
cycles = 3
|
||||
stepsize = 0.001
|
||||
d_range=0.02
|
||||
|
||||
|
||||
x0 =centre-d_range
|
||||
x1 =centre+d_range
|
||||
|
||||
|
||||
# General definitions
|
||||
|
||||
Motor = ScanX
|
||||
RBV = ScanX_RBV
|
||||
#Motor = ScanY
|
||||
#RBV = ScanY_RBV
|
||||
speed=0
|
||||
d_output=0 # 1+ debugging output
|
||||
# general preactions
|
||||
caput("X07MB-OP2:START-CSMPL",0) # cont sampling off
|
||||
time.sleep(0.1)
|
||||
caput("X07MB-OP2:TOTAL-CYCLES",1)
|
||||
time.sleep(0.1)
|
||||
caput("X07MB-OP2:SMPL",1) # start one cycle to get system in defined state
|
||||
time.sleep(0.1)
|
||||
|
||||
#cscan(ScanX, [keith_1] , 18, 18.3, 100, latency = 0.0, time = 2.0, before_read = before_read, after_read = None)
|
||||
|
||||
n_cycles=cycles+1
|
||||
dwell=(n_cycles)*0.2 # time per step
|
||||
|
||||
steps=int(abs((x1-x0)/stepsize))
|
||||
total_time=steps*dwell
|
||||
#caput(Motor.getChannelName()+".VBAS",speed*.5)
|
||||
|
||||
caput("X07MB-OP2:TOTAL-CYCLES",cycles)
|
||||
print(' parameters for scan ')
|
||||
print('range',x0,x1)
|
||||
print('total time',total_time)
|
||||
print('stepsize',stepsize)
|
||||
print('steps ',steps, ' cycles ' ,cycles)
|
||||
|
||||
print('speed',speed)
|
||||
|
||||
print(x0,x1,dwell,total_time,steps,speed,speed*0.5)
|
||||
|
||||
#ScanX.config.minSpeed = speed*.5
|
||||
#ScanX.config.save()
|
||||
|
||||
# OTF
|
||||
#ret = cscan(Motor, [keith_1,keith_2,keith_3,RBV] , x0, x1, steps=steps, latency =0.0, time = total_time, before_read = before_read, after_read = None, domain_axis="Time")
|
||||
#ret = cscan(Motor, [keith_1,keith_2,keith_3,RBV] , x0, x1, steps=steps, latency =0.0, time = total_time, before_read = before_read, after_read = None)
|
||||
|
||||
# step by step
|
||||
ret = lscan(Motor, [keith_1,keith_2, RBV] , x0, x1, steps, latency = 0.0, relative = False, passes = 1, zigzag = False, before_read = before_read, after_read = None, title = None)
|
||||
|
||||
#General postactions
|
||||
|
||||
caput(Motor.getChannelName()+'.VBAS',0.125)
|
||||
|
||||
caput("X07MB-OP2:TOTAL-CYCLES",5)
|
||||
time.sleep(0.1)
|
||||
caput("X07MB-OP2:START-CSMPL",1)
|
||||
time.sleep(0.1)
|
||||
caput("X07MB-OP2:SMPL",1)
|
||||
|
||||
|
||||
|
||||
# now plot the data
|
||||
|
||||
|
||||
# read data from data set
|
||||
|
||||
y = ret.getReadable(1)
|
||||
x = ret.getPositions(0)
|
||||
|
||||
# create processed tab
|
||||
p = plot(y, xdata=x, title="Processed")[0]
|
||||
|
||||
#function = interpolate(y,x,"cubic")
|
||||
|
||||
d = deriv(y,x) # calc derivative
|
||||
|
||||
plot_function(p, interpolate(d,x,"cubic"), "Deriv", x)
|
||||
|
||||
p.setLegendVisible(True)
|
||||
(normalization, mean_val, sigma) = fit_gaussian(y, x)
|
||||
print (' ===================================== ')
|
||||
print ('RESULT GAUISSIAN FIT')
|
||||
print ('sigma',sigma)
|
||||
print ('position',mean_val)
|
||||
|
||||
|
||||
fitted_gaussian_function = Gaussian(normalization, mean_val, sigma)
|
||||
plot_function(p, fitted_gaussian_function, "Fit", x)
|
||||
|
||||
p.addText(min(x), max(y)+1, ' '+get_exec_pars().path, Color.YELLOW)
|
||||
p.addText(min(x), max(y)-10, ' sigma '+str(sigma), Color.YELLOW)
|
||||
|
||||
|
||||
#plots = get_plot_snapshots("Processed")
|
||||
#p2 = plot(y, xdata=x, title="Processed_2")[0]
|
||||
#plot_function(p2, interpolate(d,x,"cubic"), "Deriv", x)
|
||||
|
||||
plots = get_plot_snapshots("Processed")
|
||||
|
||||
print plots
|
||||
|
||||
|
||||
|
||||
|
||||
42
script/test/ContinuousScan.py
Normal file
42
script/test/ContinuousScan.py
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
#Number of cycles must be small otherwise generates a following error
|
||||
def before_read(position, scan):
|
||||
global total_time, steps
|
||||
import time
|
||||
start = time.time()
|
||||
caput("X07MB-OP2:SMPL",1)
|
||||
time.sleep(0.1)
|
||||
print "Waiting..."
|
||||
cawait ("X07MB-OP2:SMPL-DONE",1, 10000)
|
||||
print "Done"
|
||||
t = time.time()-start
|
||||
print t
|
||||
if t > (total_time/steps):
|
||||
print "Before took too long, step = ", (total_time/steps)
|
||||
|
||||
def after(record, scan):
|
||||
pass
|
||||
|
||||
#setup_plotting(line_plots = [mca_1])
|
||||
|
||||
print('running')
|
||||
|
||||
|
||||
#cscan(ScanX, [keith_1] , 18, 18.3, 100, latency = 0.0, time = 2.0, before_read = before_read, after_read = None)
|
||||
x0=16
|
||||
x1=16.3
|
||||
cycles = 1
|
||||
dwell=(1+cycles)*0.2 # time per step
|
||||
total_time=20.0
|
||||
steps=int(total_time/dwell/4.)
|
||||
speed=(x1-x0)/total_time
|
||||
print(x0,x1,dwell,total_time,steps,speed,speed*0.5)
|
||||
|
||||
caput("X07MB-OP2:TOTAL-CYCLES",cycles)
|
||||
caput("X07MB-ES-MA1:ScanX.VBAS",speed*.5)
|
||||
#ScanX.config.minSpeed = speed*.5
|
||||
#ScanX.config.save()
|
||||
|
||||
ret = cscan(ScanX, [keith_1,keith_2,keith_3,ScanX_RBV] , x0, x1, steps=steps, latency =0.0, time = total_time, before_read = before_read, after_read = None, domain_axis="Time")
|
||||
caput("X07MB-ES-MA1:ScanX.VBAS",0.3)
|
||||
|
||||
15
script/test/DemoCpython.py
Normal file
15
script/test/DemoCpython.py
Normal file
@@ -0,0 +1,15 @@
|
||||
run("CPython/GaussFit_wrapper")
|
||||
|
||||
x=[-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208]
|
||||
y=[11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0]
|
||||
|
||||
[off, amp, com, sigma] = profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None)
|
||||
print "Gauss: ", [off, amp, com, sigma]
|
||||
from mathutils import Gaussian
|
||||
|
||||
#Plotting results
|
||||
from mathutils import Gaussian
|
||||
g = Gaussian(amp, com, sigma)
|
||||
fit = [g.value(i)+off for i in x]
|
||||
|
||||
plot([y, fit], ["data", "fit"], xdata = x)
|
||||
4
script/test/DemoStartFDA.py
Normal file
4
script/test/DemoStartFDA.py
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
run_fda( "users/0_Translate_to_PSHELL/Mono_pitch.xml",
|
||||
{"Pitch.Start" : -10600.0, "Pitch.End" : -10700.0})
|
||||
20
script/test/DiscreteScan.py
Normal file
20
script/test/DiscreteScan.py
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
#Line scan
|
||||
|
||||
d = Channel("X07MB-OP2-SAI_08:MEAN", 'd')
|
||||
set_device_alias(d, "dev1")
|
||||
|
||||
|
||||
def before(position, scan):
|
||||
caput("X07MB-OP2:SMPL.PROC",1)
|
||||
cawait ("X07MB-OP2:SMPL-DONE",1, 10000)
|
||||
|
||||
def after(record, scan):
|
||||
pass
|
||||
|
||||
setup_plotting(line_plots = [mca_1])
|
||||
|
||||
lscan(scan_y, [keith_1, d, mca_1], -10.0, -9.0, 10, latency = 0.01, before_read=before, after_read=after)
|
||||
|
||||
|
||||
25
script/test/MonitorScan.py
Normal file
25
script/test/MonitorScan.py
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#Number of cycles must be small otherwise generates a following error
|
||||
|
||||
start = -10.0
|
||||
end = -5.0
|
||||
acc_distance = 1.0
|
||||
|
||||
def before(position, scan):
|
||||
time.sleep(0.1)
|
||||
|
||||
def after(record, scan):
|
||||
global start, end
|
||||
if scan_y.position < start:
|
||||
record.invalidate()
|
||||
if scan_y.position > end:
|
||||
scan.abort()
|
||||
|
||||
#setup_plotting(line_plots = [mca_1])
|
||||
|
||||
scan_y.move(start - acc_distance)
|
||||
scan_y.moveAsync(end + acc_distance)
|
||||
|
||||
mscan(trigger, [scan_y.readback, keith_1], 1000, timeout = None, before_read = before, after_read = after)
|
||||
|
||||
|
||||
133
script/test/OTF_cont_sample.py
Normal file
133
script/test/OTF_cont_sample.py
Normal file
@@ -0,0 +1,133 @@
|
||||
#Number of cycles must be small otherwise generates a following error
|
||||
def before_read(position, scan):
|
||||
global total_time, steps,d_output
|
||||
import time
|
||||
if d_output ==1:
|
||||
print('enter before_read')
|
||||
start = time.time()
|
||||
caput("X07MB-OP2:SMPL",1)
|
||||
time.sleep(0.75)
|
||||
if d_output ==1:
|
||||
print "Waiting..."
|
||||
cawait ("X07MB-OP2:SMPL-DONE",1, 10000)
|
||||
print "Done"
|
||||
t = time.time()-start
|
||||
if d_output ==1:
|
||||
print t
|
||||
if t > (total_time/steps):
|
||||
print "Before took too long, step = ", (total_time/steps)
|
||||
if d_output ==1:
|
||||
print('leave before_read')
|
||||
# end before_read
|
||||
print(t)
|
||||
|
||||
|
||||
def after(record, scan):
|
||||
pass
|
||||
|
||||
from mathutils import *
|
||||
from plotutils import *
|
||||
|
||||
#setup_plotting(line_plots = [mca_1])
|
||||
|
||||
print('running')
|
||||
# scan definition
|
||||
|
||||
x0=-0.84
|
||||
|
||||
x1=-0.875
|
||||
cycles = 4
|
||||
total_time=20.
|
||||
# General definitions
|
||||
Motor = ScanY
|
||||
RBV = ScanY_RBV
|
||||
|
||||
d_output=0 # 1+ debugging output
|
||||
# general preactions
|
||||
caput("X07MB-OP2:START-CSMPL",0) # cont sampling off
|
||||
time.sleep(0.1)
|
||||
caput("X07MB-OP2:TOTAL-CYCLES",1)
|
||||
time.sleep(0.1)
|
||||
caput("X07MB-OP2:SMPL",1) # start one cycle to get system in defined state
|
||||
time.sleep(0.1)
|
||||
|
||||
#cscan(ScanX, [keith_1] , 18, 18.3, 100, latency = 0.0, time = 2.0, before_read = before_read, after_read = None)
|
||||
n_cycles=cycles+1
|
||||
dwell=(n_cycles)*0.2 # time per step
|
||||
|
||||
steps=int(total_time/dwell)
|
||||
speed=(x1-x0)/total_time
|
||||
#caput(Motor.getChannelName()+".VBAS",speed*.5)
|
||||
|
||||
caput("X07MB-OP2:TOTAL-CYCLES",cycles)
|
||||
print(' parameters for scan ')
|
||||
print('range',x0,x1)
|
||||
print('total time',total_time)
|
||||
print('steps ',steps, ' cycles ' ,cycles)
|
||||
print('speed',speed)
|
||||
|
||||
print(x0,x1,dwell,total_time,steps,speed,speed*0.5)
|
||||
|
||||
#ScanX.config.minSpeed = speed*.5
|
||||
#ScanX.config.save()
|
||||
|
||||
# OTF
|
||||
#ret = cscan(Motor, [keith_1,keith_2,keith_3,RBV] , x0, x1, steps=steps, latency =0.0, time = total_time, before_read = before_read, after_read = None, domain_axis="Time")
|
||||
#ret = cscan(Motor, [keith_1,keith_2,keith_3,RBV] , x0, x1, steps=steps, latency =0.0, time = total_time, before_read = before_read, after_read = None)
|
||||
|
||||
# step by step
|
||||
ret = lscan(Motor, [keith_1,keith_2, RBV] , x0, x1, steps, latency = 0.0, relative = False, passes = 1, zigzag = False, before_read = before_read, after_read = None, title = None)
|
||||
|
||||
#General postactions
|
||||
|
||||
caput(Motor.getChannelName()+'.VBAS',0.125)
|
||||
|
||||
caput("X07MB-OP2:TOTAL-CYCLES",5)
|
||||
time.sleep(0.1)
|
||||
caput("X07MB-OP2:START-CSMPL",1)
|
||||
time.sleep(0.1)
|
||||
caput("X07MB-OP2:SMPL",1)
|
||||
|
||||
|
||||
|
||||
# now plot the data
|
||||
|
||||
|
||||
# read data from data set
|
||||
|
||||
y = ret.getReadable(1)
|
||||
x = ret.getPositions(0)
|
||||
|
||||
# create processed tab
|
||||
p = plot(y, xdata=x, title="Processed")[0]
|
||||
|
||||
#function = interpolate(y,x,"cubic")
|
||||
|
||||
d = deriv(y,x) # calc derivative
|
||||
|
||||
plot_function(p, interpolate(d,x,"cubic"), "Deriv", x)
|
||||
|
||||
p.setLegendVisible(True)
|
||||
(normalization, mean_val, sigma) = fit_gaussian(y, x)
|
||||
print (' ===================================== ')
|
||||
print ('RESULT GAUISSIAN FIT')
|
||||
print ('sigma',sigma)
|
||||
print ('position',mean_val)
|
||||
|
||||
|
||||
fitted_gaussian_function = Gaussian(normalization, mean_val, sigma)
|
||||
plot_function(p, fitted_gaussian_function, "Fit", x)
|
||||
|
||||
p.addText(min(x), max(y), get_exec_pars().path, Color.RED)
|
||||
|
||||
#plots = get_plot_snapshots("Processed")
|
||||
#p2 = plot(y, xdata=x, title="Processed_2")[0]
|
||||
#plot_function(p2, interpolate(d,x,"cubic"), "Deriv", x)
|
||||
|
||||
plots = get_plot_snapshots("Processed")
|
||||
|
||||
print plots
|
||||
|
||||
|
||||
|
||||
|
||||
23
script/test/ScanPlot.py
Normal file
23
script/test/ScanPlot.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from mathutils import *
|
||||
from plotutils import *
|
||||
|
||||
|
||||
y = [0,1,2,3,5,15, 60, 17, 14,6,3,2] #ret.getReadable(0)
|
||||
x = [0,1,2,3,4,5,6,7,8,9,10,11] #ret.getPositions(0)
|
||||
|
||||
p = plot(y, xdata=x, title="Processed")[0]
|
||||
|
||||
#function = interpolate(y,x,"cubic")
|
||||
d = deriv(y,x)
|
||||
plot_function(p, interpolate(d,x,"cubic"), "Deriv", x)
|
||||
|
||||
p.setLegendVisible(True)
|
||||
(normalization, mean_val, sigma) = fit_gaussian(y, x)
|
||||
fitted_gaussian_function = Gaussian(normalization, mean_val, sigma)
|
||||
plot_function(p, fitted_gaussian_function, "Fit", x)
|
||||
|
||||
p.addText(x[5], max(y)+2, get_exec_pars().path, Color.RED)
|
||||
|
||||
plots = get_plot_snapshots("Processed")
|
||||
print plots
|
||||
|
||||
57
script/test/TestMscan.py
Normal file
57
script/test/TestMscan.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#Pre-actions
|
||||
#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())
|
||||
|
||||
snaps = (pol_mode, pol_angle,pol_offset)
|
||||
diags = (current.cache)
|
||||
sensors = [energy_ma_rbv, cadc1, cadc2, cadc3, cadc4, cadc5, norm_tey(), norm_diode(), tm]
|
||||
|
||||
tm.setAlias("time")
|
||||
cadc1.setAlias("tey_raw")
|
||||
cadc2.setAlias("i0")
|
||||
cadc3.setAlias("diode_raw")
|
||||
|
||||
def monitoring_task():
|
||||
global scan_completed
|
||||
time.sleep(5.0)
|
||||
scan_completed = True
|
||||
get_exec_pars().currentScan.abort()
|
||||
|
||||
monitoring_future = fork(monitoring_task)[0]
|
||||
|
||||
print "Scanning...",
|
||||
try:
|
||||
mscan( energy_ma_rbv, sensors, -1, None, \
|
||||
enabled_plots=["norm_tey", "norm_diode", cadc1, cadc3, cadc2], \
|
||||
snaps=snaps, diags=diags)
|
||||
finally:
|
||||
monitoring_future.cancel(True)
|
||||
|
||||
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()
|
||||
print("Aborting...")
|
||||
raise
|
||||
15
script/test/TestSmplDone.py
Normal file
15
script/test/TestSmplDone.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import sys
|
||||
name = 'X07MB-OP2:SMPL-DONE'
|
||||
#name = 'X07MB-OP2-SAI_07:SUM'
|
||||
try:
|
||||
for i in range(1000):
|
||||
print i
|
||||
|
||||
with Channel(name) as c:
|
||||
for j in range(200):
|
||||
c.get()
|
||||
time.sleep(0.00)
|
||||
except:
|
||||
print sys.exc_info()
|
||||
finally:
|
||||
print i,j
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user