Closedown

This commit is contained in:
x07maop
2016-02-11 15:48:25 +01:00
parent 9a58aa78bb
commit 05de6facf7
7 changed files with 182 additions and 437 deletions
+52 -24
View File
@@ -55,17 +55,18 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel13" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace pref="10" max="32767" attributes="0"/>
<Component id="jLabel13" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerEnergies" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="separate" max="32767" attributes="0"/>
<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">
@@ -83,11 +84,6 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerEndField" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerStartField" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@@ -98,6 +94,17 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="comboMode" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel14" linkSize="5" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="spinnerStartField" linkSize="1" max="32767" attributes="0"/>
<Component id="spinnerField" linkSize="1" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
@@ -106,8 +113,13 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerStartField" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -122,7 +134,7 @@
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRampRate" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerSleep" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -132,20 +144,17 @@
<Component id="comboMode" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerOffset" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerEnergies" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="141" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="52" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerOffset" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerEnergies" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -294,6 +303,25 @@
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spinnerEnergiesStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Field:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerField">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel type="list">
<ListItem value="Hx"/>
<ListItem value="Hz"/>
</SpinnerModel>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spinnerFieldStateChanged"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
+52 -22
View File
@@ -156,12 +156,15 @@ public class HystScan extends Panel {
HashMap args = new HashMap();
args.put("FIELD", spinnerField.getValue().toString());
ArrayList<Double> energies = new ArrayList<>();
int rows = (Integer) spinnerEnergies.getValue();
((DefaultTableModel) tableEnergies.getModel()).setNumRows(rows);
for (int i = 0; i < tableEnergies.getRowCount(); i++) {
energies.add((Double) ((DefaultTableModel) tableEnergies.getModel()).getValueAt(i, 1));
}
}
args.put("ENERGIES", energies);
if (reverseScan){
@@ -234,6 +237,8 @@ public class HystScan extends Panel {
tableEnergies = new javax.swing.JTable();
jLabel13 = new javax.swing.JLabel();
spinnerEnergies = new javax.swing.JSpinner();
jLabel14 = new javax.swing.JLabel();
spinnerField = new javax.swing.JSpinner();
jPanel3 = new javax.swing.JPanel();
buttonExecute = new javax.swing.JButton();
buttonAbort = new javax.swing.JButton();
@@ -317,19 +322,30 @@ public class HystScan extends Panel {
}
});
jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel14.setText("Field:");
spinnerField.setModel(new javax.swing.SpinnerListModel(new String[] {"Hx", "Hz"}));
spinnerField.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerFieldStateChanged(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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap()
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(panelParametersLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerEnergies, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, Short.MAX_VALUE)
.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)
@@ -343,10 +359,6 @@ public class HystScan extends Panel {
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerEndField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerStartField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -354,17 +366,31 @@ public class HystScan extends Panel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(comboMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel14)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spinnerStartField)
.addComponent(spinnerField))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboMode, spinnerEndField, spinnerOffset, spinnerRampRate, spinnerSleep, spinnerStartField});
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboMode, spinnerEndField, spinnerField, spinnerOffset, spinnerRampRate, spinnerSleep, spinnerStartField});
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel13, jLabel14});
panelParametersLayout.setVerticalGroup(
panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelParametersLayout.createSequentialGroup()
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addContainerGap()
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(panelParametersLayout.createSequentialGroup()
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(spinnerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerStartField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -376,24 +402,22 @@ public class HystScan extends Panel {
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(spinnerRampRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(5, 5, 5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerSleep, 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(comboMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(spinnerOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(spinnerEnergies, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(panelParametersLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(52, Short.MAX_VALUE))
.addComponent(jLabel5)))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(spinnerOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(spinnerEnergies, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Control"));
@@ -594,6 +618,10 @@ public class HystScan extends Panel {
}
}//GEN-LAST:event_spinnerEnergiesStateChanged
private void spinnerFieldStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerFieldStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerFieldStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonDefaults;
@@ -605,6 +633,7 @@ public class HystScan extends Panel {
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
@@ -618,6 +647,7 @@ public class HystScan extends Panel {
private javax.swing.JPanel panelParameters;
private javax.swing.JSpinner spinnerEndField;
private javax.swing.JSpinner spinnerEnergies;
private javax.swing.JSpinner spinnerField;
private javax.swing.JSpinner spinnerOffset;
private javax.swing.JSpinner spinnerRampRate;
private javax.swing.JSpinner spinnerSleep;
+18 -27
View File
@@ -29,37 +29,32 @@ def getNewestFile():
return None
newest = getNewestFile()
def wait_channel(name, value, type):
print "Waiting " + str(name) + " = " + str(value)
cawait(name, value, type = type)
print "Done"
#Pre-actions
#wait_channel('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
wait_beam()
if MODE is not None:
pol_mode.write(MODE)
time.sleep(1.0)
pol_mode.write(MODE) #caput('X07MA-ID:MODE', MODE) #TODO: CAPUT
time.sleep(1.0) #TODO: Needed?
if MODE == 'LINEAR':
pol_angle.write(ALPHA)
wait_device(pol_done,"DONE")
if OFFSET is not None:
caput('X07MA-ID:ENERGY-OFFS', OFFSET)
wait_device(pol_done,"DONE")
if ALPHA is not None:
pol_angle.write(ALPHA) #TODO: CAPUT
pol_done.waitValue("DONE") #TODO: NEEDED?
if OFFSET is not None:
pol_offset.write(OFFSET) #TODO: CAPUT
pol_done.waitValue("DONE")
caput('E1', E1)
caput('E2', E2)
caput('TIME', TIME)
caput('FOLDER', FOLDER)
caputq('X07MA-PHS-E:GO.A', E1)
wait_channel('X07MA-PHS:alldone', '1', type = 's')
time.sleep(0.5)
set_energy (E1)
caput('FILE', FILE)
time.sleep(0.1)
caput('X07MA-OP-VG13:WT_SET', 'Try open')
time.sleep(5.0)
caput('X07MA-OP-VG13:WT_SET', 'Try open')
if DELAY is not None:
time.sleep(DELAY)
open_valve()
open_valve(0.0) #TODO: WHY WRITING AGAIN???
time.sleep(DELAY)
caput('START', '1')
#Post-actions
@@ -71,7 +66,6 @@ print "Finished Energy scan"
#File convertion
newName = folder + time.strftime("%Y%m%d_%H%M_", start) + FILE + "_0000.txt";
#name = caget("MSG").split(' ')[0]
name = getNewestFile()
if name == newest:
@@ -80,10 +74,7 @@ if name == newest:
if not os.path.isfile(name):
raise Exception("Data file not found: " + name)
cmd = "/sls/X07MA/data/x07maop/bin/modify_otf.pl " + name + " " + newName;
print("Converting data file: " + cmd);
import os
os.system(cmd)
convert_file(name, newName)
print("Success")
-91
View File
@@ -1,91 +0,0 @@
#Script imported from: MgE_plus.xml
#Parameters
"""
E1 = 710
E2 = 720
TIME = 1 #min
DELAY = 10.0 #s
MODE = 'CIRC +'
OFFSET = -9.0
FOLDER = '2015_04/20150417'
FILE = 'Fe_plus'
ALPHA=0
"""
print "\nStarting energy scan - Parameters: ",
print E1,E2,TIME,DELAY,MODE ,OFFSET ,FOLDER ,FILE ,ALPHA
start = time.localtime()
folder = os.path.expanduser("~/Data1/") + FOLDER + "/";
def getNewestFile():
global folder
import glob
try:
return max(glob.iglob(folder+'/*.txt'), key=os.path.getctime)
except:
return None
newest = getNewestFile()
#Pre-actions
wait_beam()
pol_mode.write(MODE) #caput('X07MA-ID:MODE', MODE) #TODO: CAPUT
time.sleep(1.0) #TODO: Needed?
if MODE == 'LINEAR':
pol_angle.write(ALPHA) #TODO: CAPUT
pol_done.waitValue("DONE") #TODO: NEEDED?
pol_offset.write(OFFSET) #TODO: CAPUT
pol_done.waitValue("DONE")
caput('E1', E1)
caput('E2', E2)
caput('TIME', TIME)
caput('FOLDER', FOLDER)
set_energy (E1)
#caputq('X07MA-PHS-E:GO.A', E1)
#wait_channel('X07MA-PHS:alldone', '1', type = 's')
#time.sleep(0.5)
caput('FILE', FILE)
time.sleep(0.1)
open_valve()
open_valve(0.0) #TODO: WHY WRITING AGAIN???
#caput('X07MA-OP-VG13:WT_SET', 'Try open')
#time.sleep(5.0)
#caput('X07MA-OP-VG13:WT_SET', 'Try open')
time.sleep(DELAY)
caput('START', '1')
#Post-actions
wait_channel('START', 'STOP', type = 's')
time.sleep(2.0)
print "Finished Energy scan"
#File convertion
newName = folder + time.strftime("%Y%m%d_%H%M_", start) + FILE + "_0000.txt";
#name = caget("MSG").split(' ')[0]
name = getNewestFile()
if name == newest:
raise Exception("Data file not created")
if not os.path.isfile(name):
raise Exception("Data file not found: " + name)
#cmd = "/sls/X07MA/data/x07maop/bin/modify_otf.pl " + name + " " + newName;
#print("Converting data file: " + cmd);
#import os
#os.system(cmd)
convert_file(name, newName)
print("Success")
+35 -103
View File
@@ -1,7 +1,6 @@
#Script imported from: Fe_hyst_plus.xml
#Parameters
"""
FIELD = "Hx"
START_FIELD = -0.1
END_FIELD = 0.1
ENERGIES = (707.90, 703.90)
@@ -13,14 +12,21 @@ OFFSET = -1.0
FIELD_PRECISION = 0.01
field = field_z if FIELD == "Hz" else field_x
field_done = field_z_done if FIELD == "Hz" else field_x_done
ramp_rate = ramp_rate_z if FIELD == "Hz" else ramp_rate_x
#Pre-actions
cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
caput('X07MA-ID:MODE', MODE)
caput('X07MA-ID:ENERGY-OFFS', OFFSET)
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
wait_beam()
if MODE is not None:
pol_mode.write(MODE)
if OFFSET is not None:
pol_offset.write(OFFSET) #caput('X07MA-ID:ENERGY-OFFS', OFFSET)
caputq('X07MA-PC:CSCALER.INPB', '1')
caputq('X07MA-PC-PS2:SET:DMD:RAMPRATE:TPM', RAMP_RATE)
#sleep(15.0)
if RAMP_RATE is not None:
ramp_rate.write(RAMP_RATE)
if len(ENERGIES) ==2:
dif_series = plot([],"Dif", context="Dif")[0].getSeries(0)
@@ -30,61 +36,24 @@ else:
set_preference(Preference.ENABLED_PLOTS, ['field', 'tey_norm', 'trans_norm'])
set_preference(Preference.PLOT_TYPES, {'tey_norm':1, 'trans_norm':1})
#scan = ManualScan(['field', 'Energy'], ['TEY', 'I0', 'trans', 'polarization', 'polAngle', 'temperature', 'RingCurrent', 'fieldAnalogX', 'tey_norm','trans_norm'])
scan = ManualScan(['field', 'Energy'], ['TEY', 'I0', 'trans', 'polarization', 'polAngle', 'temperature', 'RingCurrent', 'fieldAnalogX', 'tey_norm','trans_norm'], [0.0, ENERGIES[0]], [0.0, ENERGIES[-1]], [0, len(ENERGIES)-1])
scan.start()
#Stop condition
ramp_done = Channel('X07MA-PC-MAG:X:RAMP:DONE', type = 'i')
#Creating channels: dimension 1
#RegionPositioner field
#field = Channel('X07MA-PC:GO', type = 'd')
fieldReadback = Channel('X07MA-PC-PS2:STS:PMCURRENT', type = 'd')
#Creating channels: dimension 2
#ArrayPositioner Energy
Energy = Channel('X07MA-PHS-E:GO.A', type = 'd')
EnergyReadback = Channel('X07MA-PGM:CERBK', type = 'd')
#ScalarDetector TEY
TEY = Channel('X07MA-ES1-AI:SIGNAL0', type = 'd')
#ScalarDetector I0
I0 = Channel('X07MA-ES1-AI:SIGNAL1', type = 'd')
#ScalarDetector trans
trans = Channel('X07MA-ES1-AI:SIGNAL2', type = 'd')
#ScalarDetector polarization
polarization = Channel('X07MA-ID:MODE', type = 'd')
#ScalarDetector polAngle
polAngle = Channel('X07MA-ID:ALPHA', type = 'd')
#ScalarDetector temperature
temperature = Channel('X07MA-PC-TC:STS:T1', type = 'd')
#ScalarDetector RingCurrent
RingCurrent = Channel('ARIDI-PCT:CURRENT', type = 'd')
#ScalarDetector fieldAnalogX
fieldAnalogX = Channel('X07MA-ES1-AI:SIGNAL4', type = 'd')
print "SKIPPED Waiting for start field"
#if abs(fieldReadback.get() - START_FIELD) > FIELD_PRECISION:
# caput('X07MA-PC-PS2:M:GO.A', START_FIELD)
if abs(field.readback.read() - START_FIELD) > FIELD_PRECISION:
field.write(START_FIELD)
field_done.waitValue(1) #ramp_done.wait_for_value(1.0)
pol_done.waitValue("DONE")
#caput("X07MA-PC-MAG:X:DMD", START_FIELD)
#caput("X07MA-PC-MAG:STARTRAMP.PROC", 1)
ramp_done.wait_for_value(1.0)
cawait('X07MA-ID:DONE', 'DONE', type = 's')
caput('X07MA-OP-VG13:WT_SET', 'Try open')
time.sleep(2.0)
open(2.0)
print "Set end field"
#caput("X07MA-PC-MAG:X:DMD", END_FIELD)
#caputq("X07MA-PC-MAG:STARTRAMP.PROC", 1)
caputq('X07MA-PC-PS2:M:GO.A', END_FIELD)
field.write(END_FIELD) #caputq('X07MA-PC-PS2:M:GO.A', END_FIELD)
@@ -93,79 +62,42 @@ index = 0
while(True):
#Dimension 2START_FIELD = -0.2
#ArrayPositioner Energy
for setpoint2 in ENERGIES:
Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
for setpoint2 in ENERGIES:
#Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
energy.write(setpoint2)
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
readback2 = EnergyReadback.get()
#TODO: change to Controlled variable?
readback2 = energy_readback.read() #EnergyReadback.get()
if abs(readback2 - setpoint2) > 0.1 : # TODO: Check accuracy
raise Exception('Actor Energy could not be set to the value ' + str(setpoint2))
raise Exception('Energy could not be set to the value ' + str(setpoint2))
#Detector field readback
field_readback = fieldReadback.get()
field_readback = field.readback.read() #fieldReadback.get()
#Detector TEY
detector1 = TEY.get()
#Detector I0
detector2 = I0.get()
#Detector trans
detector3 = trans.get()
#Detector polarization
detector4 = polarization.get()
#Detector polAngle
detector5 = polAngle.get()
#Detector temperature
detector6 = temperature.get()
#Detector RingCurrent
detector7 = RingCurrent.get()
#Detector fieldAnalogX
detector8 = fieldAnalogX.get()
detector1 = signal_tey.read() #TEY.get()
detector2 = signal_i0.read() #I0.get()
detector3 = signal_trans.read() #trans.get()
detector4 = float(pol_mode.getPositions().index(pol_mode.readback.read())) #polarization.get()
detector5 = pol_angle.read() #polAngle.get()
detector6 = temperature.read() #temperature.get()
detector7 = current.read()
detector8 = signal_field_analog_x.read() # fieldAnalogX.get()
#Manipulation tey_norm
#Variable Mappings
#TODO: Move, if needed, this import to the file header: import math
tey_norm = detector1/detector2
#Manipulation trans_norm
#Variable Mappings
#TODO: Move, if needed, this import to the file header: import math
trans_norm = detector3/detector2
if dif_series is not None:
if setpoint2 == ENERGIES[0]:
first = tey_norm
else:
dif = tey_norm-first
dif_series.appendData(field_readback,dif)
#print [field_readback, setpoint2]
#print [field_readback, readback2]
#print [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, tey_norm, trans_norm]
scan.append ([field_readback, setpoint2], [field_readback, readback2], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, tey_norm, trans_norm])
#print "Field = " + str(fieldReadback.get())
if ramp_done.get() == 1: #If not ramping
if field_done.read() == 1: #If not ramping #ramp_done.get() == 1:
print "Not ramping, breaking execution"
break
index = index+1
#Closing channels
Energy.close()
EnergyReadback.close()
TEY.close()
I0.close()
trans.close()
polarization.close()
polAngle.close()
temperature.close()
RingCurrent.close()
fieldAnalogX.close()
#field.close()
fieldReadback.close()
ramp_done.close()
scan.end()
-151
View File
@@ -1,151 +0,0 @@
#Script imported from: Fe_hyst_plus.xml
#Parameters
"""
START_FIELD = -0.1
END_FIELD = 0.1
ENERGIES = (707.90, 703.90)
RAMP_RATE = 0.2
ENERGY_CHANGE_SLEEP = 0.5
MODE = 'CIRC +'
OFFSET = -1.0
"""
FIELD_PRECISION = 0.01
#Pre-actions
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
wait_beam()
pol_mode.write(MODE)
pol_offset.write(OFFSET) #caput('X07MA-ID:ENERGY-OFFS', OFFSET)
caputq('X07MA-PC:CSCALER.INPB', '1')
ramp_rate.write(RAMP_RATE)
if len(ENERGIES) ==2:
dif_series = plot([],"Dif", context="Dif")[0].getSeries(0)
else:
dif_series = None
set_preference(Preference.ENABLED_PLOTS, ['field', 'tey_norm', 'trans_norm'])
set_preference(Preference.PLOT_TYPES, {'tey_norm':1, 'trans_norm':1})
scan = ManualScan(['field', 'Energy'], ['TEY', 'I0', 'trans', 'polarization', 'polAngle', 'temperature', 'RingCurrent', 'fieldAnalogX', 'tey_norm','trans_norm'], [0.0, ENERGIES[0]], [0.0, ENERGIES[-1]], [0, len(ENERGIES)-1])
scan.start()
#Stop condition
#ramp_done = Channel('X07MA-PC-MAG:X:RAMP:DONE', type = 'i')
#Creating channels: dimension 1
#RegionPositioner field
#field = Channel('X07MA-PC:GO', type = 'd')
#fieldReadback = Channel('X07MA-PC-PS2:STS:PMCURRENT', type = 'd')
#Creating channels: dimension 2
#ArrayPositioner Energy
#Energy = Channel('X07MA-PHS-E:GO.A', type = 'd')
#EnergyReadback = Channel('X07MA-PGM:CERBK', type = 'd')
#ScalarDetector TEY
#TEY = Channel('X07MA-ES1-AI:SIGNAL0', type = 'd')
#ScalarDetector I0
#I0 = Channel('X07MA-ES1-AI:SIGNAL1', type = 'd')
#ScalarDetector trans
#trans = Channel('X07MA-ES1-AI:SIGNAL2', type = 'd')
#ScalarDetector polarization
#polarization = Channel('X07MA-ID:MODE', type = 'd')
#ScalarDetector polAngle
#polAngle = Channel('X07MA-ID:ALPHA', type = 'd')
#ScalarDetector temperature
#temperature = Channel('X07MA-PC-TC:STS:T1', type = 'd')
#ScalarDetector RingCurrent
#RingCurrent = Channel('ARIDI-PCT:CURRENT', type = 'd')
#ScalarDetector fieldAnalogX
#fieldAnalogX = Channel('X07MA-ES1-AI:SIGNAL4', type = 'd')
print "SKIPPED Waiting for start field"
if abs(field_x.readback.read() - START_FIELD) > FIELD_PRECISION:
field_x.write(START_FIELD)
#if abs(fieldReadback.get() - START_FIELD) > FIELD_PRECISION:
# caput('X07MA-PC-PS2:M:GO.A', START_FIELD)
#caput("X07MA-PC-MAG:X:DMD", START_FIELD)
#caput("X07MA-PC-MAG:STARTRAMP.PROC", 1)
field_x_done.waitValue(1) #ramp_done.wait_for_value(1.0)
pol_done.waitValue("DONE")
#caput('X07MA-OP-VG13:WT_SET', 'Try open')
#time.sleep(2.0)
open(2.0)
print "Set end field"
#caput("X07MA-PC-MAG:X:DMD", END_FIELD)
#caputq("X07MA-PC-MAG:STARTRAMP.PROC", 1)
field_x.write(END_FIELD) #caputq('X07MA-PC-PS2:M:GO.A', END_FIELD)
index = 0
while(True):
#Dimension 2START_FIELD = -0.2
#ArrayPositioner Energy
for setpoint2 in ENERGIES:
#Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
energy.write(setpoint2)
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
#TODO: change to Controlled variable?
readback2 = energy_readback.read() #EnergyReadback.get()
if abs(readback2 - setpoint2) > 0.1 : # TODO: Check accuracy
raise Exception('Energy could not be set to the value ' + str(setpoint2))
#Detector field readback
field_readback = field_x.readback.read() #fieldReadback.get()
detector1 = signal_tey.read() #TEY.get()
detector2 = signal_i0.read() #I0.get()
detector3 = signal_trans.read() #trans.get()
detector4 = float(pol_mode.getPositions().index(pol_mode.readback.read())) #polarization.get()
detector5 = pol_angle.read() #polAngle.get()
detector6 = temperature.read() #temperature.get()
detector7 = current.read()
detector8 = signal_field_analog_x.read() # fieldAnalogX.get()
tey_norm = detector1/detector2
trans_norm = detector3/detector2
if dif_series is not None:
if setpoint2 == ENERGIES[0]:
first = tey_norm
else:
dif = tey_norm-first
dif_series.appendData(field_readback,dif)
scan.append ([field_readback, setpoint2], [field_readback, readback2], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, tey_norm, trans_norm])
if field_x_done.read() == 1: #If not ramping #ramp_done.get() == 1:
print "Not ramping, breaking execution"
break
index = index+1
#Closing channels
#Energy.close()
#EnergyReadback.close()
#TEY.close()
#I0.close()
#trans.close()
#polarization.close()
#polAngle.close()
#temperature.close()
#RingCurrent.close()
#fieldAnalogX.close()
#field.close()
#fieldReadback.close()
#ramp_done.close()
scan.end()
+25 -19
View File
@@ -39,14 +39,14 @@ def getPars(element):
###################################################################################################
# PSeudo-devices
###################################################################################################
energy = None
sim_energy = None
class SimulatedEnergy(Writable):
def write(self, value):
self.put(value)
def put(self, value, timeout = None):
global energy
energy = value
global sim_energy
sim_energy = value
def close(self):
pass
@@ -54,8 +54,8 @@ class SimulatedEnergy(Writable):
class SimulatedEnergyReadback(Readable):
def read(self):
global energy
return energy;
global sim_energy
return sim_energy;
def get(self):
return self.read()
@@ -142,13 +142,13 @@ controller.addListener(Listener()) #Old listeners are cleande in startup
###################################################################################################
#TODO: Should set devices? K10, k11, k24 seem not to be defined....
keithleys = {
#name:[Setpoint, range]
"k1": [None , 'X07MA-PC-K428:1:setGain'],
"k2": [None , 'X07MA-PC-K428:2:setGain'],
"k3": [None , 'X07MA-PC-K428:3:setGain'],
"k10":['X07MA-KEI10:SETVOLTAGE' , 'X07MA-KEI10:RANGE'],
"k11":['X07MA-KEI11:SETVOLTAGE' , 'X07MA-KEI11:RANGE'],
"k24":['X07MA-KEI2400:setVoltAO', None]
#name:[Setpoint, range, Readback] #TODO
"k1": [None , 'X07MA-PC-K428:1:setGain', None],
"k2": [None , 'X07MA-PC-K428:2:setGain', None],
"k3": [None , 'X07MA-PC-K428:3:setGain', None],
"k10":['X07MA-KEI10:SETVOLTAGE' , 'X07MA-KEI10:RANGE', None],
"k11":['X07MA-KEI11:SETVOLTAGE' , 'X07MA-KEI11:RANGE', None],
"k24":['X07MA-KEI2400:setVoltAO', None, None]
}
def set_hx(field, timeout = -1):
@@ -208,7 +208,7 @@ def set_har(value):
harmonic.write(float(value))
def set_volt(keithley, value, dalay=0.1):
def set_volt(keithley, value, delay=0.1):
#keithley.write(float(value))
if not keithley in keithleys.keys(): raise Exception("Invalid keithley: " + keithley)
caput(keithleys[keithley][0], float(value))
@@ -276,14 +276,14 @@ def set_file(file_name):
FILENAME = file_name
def otf(start, end, time, delay=None):
run("EnergyScan")
def otf(start, end, time, delay=0.0):
run("EnergyScan", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":None, "OFFSET":None, "FOLDER":None, "FILE":None, "ALPHA":None})
def hyst_cont(field, init_field, final_field, ramp_speed, energies):
pass
run("HistScan",{"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_mult(field, ranges, energies):
pass
run("HistScanMult",{"FIELD":field, "RANGES":ranges, "ENERGIES":energies, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
def hyst_step(forward, field, init_field, final_field, ramp_speed, energies):
pass
@@ -292,12 +292,18 @@ def hyst_step_mult(forward, ranges, ramp_speed, energies):
pass
def scan_e(start, end, step):
pass
setpoint = Channel (energy., 'd')
readback = Channel (keithleys[keithley][2], 'd')
lscan(setpoint, readback, float(start), float(end), float(step), latency = 0.1)
def scan_e(ranges):
pass
def scan_v(keithley,start, end, step):
pass
setpoint = Channel (keithleys[keithley][0], 'd')
readback = Channel (keithleys[keithley][2], 'd')
lscan(setpoint, readback, float(start), float(end), float(step), latency = 0.1)