From 4cdf8c788f4d33d3ec2862d01f72a73c1656c924 Mon Sep 17 00:00:00 2001 From: X11MA Date: Thu, 15 Sep 2016 16:42:23 +0200 Subject: [PATCH] Startup --- config/devices.properties | 1 + config/energy_scan.properties | 9 +++-- config/setup.properties | 3 +- devices/p1.properties | 8 ++++ plugins/DelayScan.form | 25 ++++++++++-- plugins/DelayScan.java | 27 +++++++++++-- script/DelayScan.py | 73 +++++++++++++++++++++-------------- script/EnergyScan.py | 5 ++- 8 files changed, 110 insertions(+), 41 deletions(-) create mode 100644 devices/p1.properties diff --git a/config/devices.properties b/config/devices.properties index 0088f43..940796e 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -1,3 +1,4 @@ +SLS_freq=ch.psi.pshell.epics.ChannelDouble|AGARF-TIM:BO-FREQ-GET|Read||true ThetaComplete=ch.psi.pshell.epics.ChannelString|X11MA-ES2-scan1.SMSG|Read||true BucketSize=ch.psi.pshell.epics.ChannelDouble|ACORF-FILL:MRF-INTEG|Read||true FillingPattern=ch.psi.pshell.epics.ChannelDoubleArray|ACORF-FILL:UnsortComp|Read||true diff --git a/config/energy_scan.properties b/config/energy_scan.properties index b491348..dd9bc1e 100644 --- a/config/energy_scan.properties +++ b/config/energy_scan.properties @@ -1,4 +1,7 @@ -Fe_FE1.25x1.25=680.0;750.0;2.0;10.0;-5.0;-4.0 +V&O_lin_FE1.25x1.25=505.0;560.0;2.0;10.0;-1.2;-2.5 +V&O=505.0;560.0;2.0;10.0;-4.0;-7.0 +V_FE_1.25x1.25=505.0;550.0;2.0;10.0;-5.0;-5.0 +Fe_FE1.25x1.25=680.0;750.0;0.5;10.0;-5.0;-4.0 MCP test=778.0;779.0;0.2;0.0;-8.8;-9.5 Cr2x2=560.0;610.0;2.0;10.0;1.9;0.9 V=505.0;540.0;2.0;10.0;-7.5;-8.5 @@ -7,7 +10,7 @@ Ni Linear=825.0;890.0;2.0;10.0;-3.5;-5.5 O=500.0;560.0;2.0;10.0;-7.5;-8.5 Gd=1170.0;1240.0;2.0;10.0;-13.0;-11.5 Cr=560.0;610.0;2.0;10.0;-6.2;-7.2 -Co=750.0;825.0;2.0;10.0;-8.8;-9.5 +Co=750.0;825.0;2.0;10.0;-5.5;-6.0 Mn=620.0;670.0;2.0;10.0;-6.7;-8.1 -Fe=680.0;750.0;0.5;10.0;-10.0;-11.5 +Fe=680.0;750.0;2.0;10.0;-5.0;-5.0 Fe Linear=680.0;750.0;2.0;10.0;1.2;2.9 diff --git a/config/setup.properties b/config/setup.properties index f068414..1b34796 100644 --- a/config/setup.properties +++ b/config/setup.properties @@ -1,4 +1,4 @@ -#Tue Oct 27 16:16:33 CET 2015 +#Thu Sep 15 16:42:05 CEST 2016 configFile={config}/config.properties configFileDevices={config}/devices.properties configFileImageSources={config}/imaging.properties @@ -10,6 +10,7 @@ contextPath={home}/context dataPath={home}/data devicesPath={home}/devices extensionsPath={home}/extensions +imagesPath={outp}/images libraryPath={script}; {script}/Lib logPath={home}/log pluginsPath={home}/plugins diff --git a/devices/p1.properties b/devices/p1.properties new file mode 100644 index 0000000..bc32032 --- /dev/null +++ b/devices/p1.properties @@ -0,0 +1,8 @@ +#Wed Aug 31 13:43:05 CEST 2016 +maxValue=1000.0 +minValue=0.0 +offset=0.0 +precision=-1 +resolution=NaN +scale=1.0 +unit=mm diff --git a/plugins/DelayScan.form b/plugins/DelayScan.form index 9c52da5..41e5f1e 100644 --- a/plugins/DelayScan.form +++ b/plugins/DelayScan.form @@ -381,7 +381,10 @@ - + + + + @@ -409,8 +412,16 @@ - - + + + + + + + + + + @@ -552,6 +563,14 @@ + + + + + + + + diff --git a/plugins/DelayScan.java b/plugins/DelayScan.java index 2562d92..4e517b3 100644 --- a/plugins/DelayScan.java +++ b/plugins/DelayScan.java @@ -97,6 +97,7 @@ public class DelayScan extends Panel { args.put("RUNTYPE", comboRunType.getSelectedItem().toString()); args.put("ROUNDS", (Integer) spinnerRounds.getValue()); args.put("SET_OFFSETS", jCheckBox1.isSelected() ? 1 : 2); + args.put("SET_DELAY", jCheckBox5.isSelected() ? 1 : 2); args.put("ID1", jRadioButton1.isSelected() ? 1 : 2); args.put("ID2", jRadioButton2.isSelected() ? 1 : 2); args.put("MCP_1", jCheckBox2.isSelected() ? 1 : 2); @@ -169,6 +170,7 @@ public class DelayScan extends Panel { jLabel14 = new javax.swing.JLabel(); jLabel15 = new javax.swing.JLabel(); jCheckBox4 = new javax.swing.JCheckBox(); + jCheckBox5 = new javax.swing.JCheckBox(); panelSetup = new javax.swing.JPanel(); jLabel10 = new javax.swing.JLabel(); jTextField2 = new javax.swing.JTextField(); @@ -385,6 +387,13 @@ public class DelayScan extends Panel { jCheckBox4.setText("Save array data"); + jCheckBox5.setText("set delay"); + jCheckBox5.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckBox5ActionPerformed(evt); + } + }); + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( @@ -424,7 +433,9 @@ public class DelayScan extends Panel { .addComponent(buttonExecute, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) - .addComponent(jCheckBox1)) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jCheckBox1) + .addComponent(jCheckBox5))) .addComponent(jLabel15)) .addContainerGap()) ); @@ -446,8 +457,13 @@ public class DelayScan extends Panel { .addComponent(jCheckBox1) .addComponent(jRadioButton1) .addComponent(jCheckBox2)) - .addGap(16, 16, 16) - .addComponent(buttonAbort)) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGap(16, 16, 16) + .addComponent(buttonAbort)) + .addGroup(jPanel3Layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jCheckBox5)))) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -553,6 +569,10 @@ public class DelayScan extends Panel { // TODO add your handling code here: }//GEN-LAST:event_jTextField2ActionPerformed + private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox5ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jCheckBox5ActionPerformed + EditorDialog dlgConfig; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonAbort; @@ -564,6 +584,7 @@ public class DelayScan extends Panel { private javax.swing.JCheckBox jCheckBox2; private javax.swing.JCheckBox jCheckBox3; private javax.swing.JCheckBox jCheckBox4; + private javax.swing.JCheckBox jCheckBox5; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; diff --git a/script/DelayScan.py b/script/DelayScan.py index 6fb72df..79b1d1a 100644 --- a/script/DelayScan.py +++ b/script/DelayScan.py @@ -4,11 +4,38 @@ import math import time print "\nStarting delay scan - Parameters: ", -print START,END,SIZE,ENERGIES,RUNTYPE +print START,END,STEP,ENERGIES,RUNTYPE ############################################################################### # Preparing for the Scan ############################################################################### +LPP_DELAY_NEW = 0 +LPP_FINE_DELAY_NEW = 0 + + +def Convert_LPP_Delays(NewDelay): + global LPP_DELAY_NEW, LPP_FINE_DELAY_NEW + LPP_DELAY_NEW = math.trunc(((-NewDelay*100.0+DELAY*(1E9/SLS_freq.read())*100+FINEDELAY)/100.0)/(1E9/SLS_freq.read())) + LPP_FINE_DELAY_NEW = math.trunc(-NewDelay*100.0+DELAY*1E9/SLS_freq.read()*100+FINEDELAY-LPP_DELAY_NEW*(1E9/SLS_freq.read()*100.0)) + +def Timing(New_Time): + caput (TIME_DELAY_SET, New_Time) + caput (TIME_DELAY_START, 1) + Convert_LPP_Delays(New_Time) + caput (LPP_DELAY, LPP_DELAY_NEW) + caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW) + wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout=10+abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10) + + +if str(SET_DELAY) == "1": + print "Setting delay" + Timing(END) + print "Delay is set" + import sys + sys.exit(0) +else: + print "Running full script" + if str(SET_OFFSETS) == "1": print "Setting offsets" if RUNTYPE in ["+/-", "+" , "-"]: @@ -32,13 +59,13 @@ if str(SET_OFFSETS) == "1": sys.exit(0) else: print "Running full script" - -'''if ID1 == 1: + +"""if ID1 == 1: caput ("X11PHS-E:OPT","PGM+ID1") elif ID2 == 1: caput ("X11PHS-E:OPT","PGM+ID2") else: - caput ("X11PHS-E:OPT","PGM+ID1+ID2")''' + caput ("X11PHS-E:OPT","PGM+ID1+ID2")""" file_prefix = time.strftime("%y%m%d") input_path = PATH+file_prefix+"/" @@ -71,17 +98,12 @@ def switchpol(activeID, runtype): else: raise Exception("Invalid parameter") -'''LPP_DELAY_NEW = 0 -LPP_FINE_DELAY_NEW = 0''' -def Convert_LPP_Delays(NewDelay): - global LPP_DELAY_NEW, LPP_FINE_DELAY_NEW - LPP_DELAY_NEW = math.trunc(((NewDelay*100.0+DELAY*BucketSize.read()*100+FINEDELAY)/100.0)/BucketSize.read()) - LPP_FINE_DELAY_NEW = math.trunc(NewDelay*100.0+DELAY*BucketSize.read()*100+FINEDELAY-LPP_DELAY_NEW*BucketSize.read()*100.0) - -pol_str = None +pol_str = NoneMCP_1_ polswitch = 1 number_of_scans = 1 -fid = get_next_fid(input_path, "d" + file_prefix) +fid1 = get_next_fid(input_path, "MCP_1_d" + file_prefix) +fid2 = get_next_fid(input_path, "MCP_2_d" + file_prefix) +fid = max(fid1,fid2) if RUNTYPE in ["+/-","+,-", "+", "-"]: caput(OTF_MODE1,1) # circ + in ID1 @@ -124,14 +146,6 @@ else: caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW) wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10) -def Timing(New_Time): - caput (TIME_DELAY_SET, New_Time) - caput (TIME_DELAY_START, 1) - Convert_LPP_Delays(New_Time) - caput (LPP_DELAY, LPP_DELAY_NEW) - caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW) - wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout=10+abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10) - def Scan(Dtime,ser): e = energy.read() @@ -149,16 +163,19 @@ def Scan(Dtime,ser): CamaP = CamaP + aPr[z] aK1norm = aK1 * CamaP / SumaP t_end = time.time()+ACQTIME + a1r = [0]*960 + a2r = [0]*960 + while time.time() < t_end: + a1t = MCPArray1.read().tolist() + a1r = [a1r[i]+a1t[i] for i in xrange(len(a1t))] + a2t = MCPArray2.read().tolist() + a2r = [a2r[i]+a2t[i] for i in xrange(len(a2t))] + time.sleep(SamplingTime.read()*0.001) if MCP_1 == 1: '''a1=MCPArray1.read() a1r = [] for i in a1: a1r.append(i)''' - a1r = [0]*960 - while time.time() < t_end: - a1t = MCPArray1.read().tolist() - a1r = [a1r[i]+a1t[i] for i in xrange(len(a1t))] - time.sleep(SamplingTime.read()*0.001) Sum1a1 = 0 Cam1a1 = 0 Sum2a1 = 0 @@ -188,10 +205,8 @@ def Scan(Dtime,ser): a2r = [] for j in a2: a2r.append(j)''' - a2r = [0]*960 while time.time() < t_end: - a2t = MCPArray2.read().tolist() - a2r = [a2r[i]+a2t[i] for i in xrange(len(a2t))] + time.sleep(SamplingTime.read()*0.001) Sum1a2 = 0 Cam1a2 = 0 diff --git a/script/EnergyScan.py b/script/EnergyScan.py index c6a7555..0515ac0 100644 --- a/script/EnergyScan.py +++ b/script/EnergyScan.py @@ -57,8 +57,7 @@ print E1,E2,TIME,DELAY,OFFSET1,OFFSET2,RUNTYPE#,ALPHA1,ALPHA2 task = None running = False -MCP1 = [] -MCP2 = [] + def _startPlot(type): global running @@ -70,6 +69,8 @@ def _startPlot(type): s = p.getSeries(0) cur = 0 time.sleep(3.0) + MCP1 = [] + MCP2 = [] while running: try: if otf_start.read() == 0: