diff --git a/config/config.properties b/config/config.properties
index 2f5b3e6..565d3ec 100644
--- a/config/config.properties
+++ b/config/config.properties
@@ -1,48 +1,48 @@
-#Thu Sep 02 10:52:56 CEST 2021
-hostName=
-userManagement=false
-disableEmbeddedAttributes=false
-instanceName=SIS
+#Tue Nov 16 14:43:26 CET 2021
autoSaveScanData=true
simulation=false
-dataServerPort=-1
-hideServerMessages=false
+dataScanSaveOutput=false
+userAuthenticator=
+dataScanSaveScript=false
+notifiedTasks=
+parallelInitialization=true
+dataTransferPath=
+saveConsoleSessionFiles=false
+hostName=
+disableEmbeddedAttributes=false
serverPort=8080
versionTrackingEnabled=true
dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name}
-serverEnabled=false
-logDaysToLive=7
-dataScanReleaseRecords=false
+serverEnabled=true
depthDimension=0
-dataScanPreserveTypes=true
-dataScanSaveOutput=false
logLevel=Info
-dataScanFlushRecords=false
-logPath={logs}/{date}_{time}
-filePermissionsLogs=Default
dataLayout=default
disableDataFileLogs=false
sessionHandling=Off
terminalEnabled=false
notificationLevel=Off
-filePermissionsScripts=Default
-userAuthenticator=
-logLevelConsole=Off
terminalPort=3579
-filePermissionsConfig=Default
-scanStreamerPort=-1
-dataScanSaveScript=false
dataTransferUser=
-dataScanSaveSetpoints=false
-notifiedTasks=
-filePermissionsData=Default
-parallelInitialization=true
-dataTransferPath=
-saveConsoleSessionFiles=false
versionTrackingLogin={context}/svcusr-hlapp_robot
noBytecodeFiles=false
-versionTrackingManual=true
versionTrackingRemote=git@git.psi.ch\:pshell_config/x09la.git
-dataProvider=h5
+logDaysToLive=7
+logLevelConsole=Off
+filePermissionsConfig=Public
+scanStreamerPort=-1
+dataScanSaveSetpoints=false
+versionTrackingManual=true
dataTransferMode=Off
+userManagement=false
+instanceName=SIS
+dataServerPort=-1
+hideServerMessages=false
+dataScanReleaseRecords=false
+dataScanPreserveTypes=true
+dataScanFlushRecords=false
+logPath={logs}/{date}_{time}
+filePermissionsLogs=Public
+filePermissionsScripts=Public
+filePermissionsData=Default
+dataProvider=h5
saveCommandStatistics=false
diff --git a/config/devices.properties b/config/devices.properties
index da5ed89..2d25ecf 100644
--- a/config/devices.properties
+++ b/config/devices.properties
@@ -1,7 +1,8 @@
-scienta=Scienta|X09LA-SCIENTA|||true
+scienta=Scienta|X09LA-SCIENTA false|||true
current=ch.psi.pshell.epics.ChannelDouble|ARIDI-PCT:CURRENT 6|Read||true
keithley10=ch.psi.pshell.epics.ChannelDouble|X09LA-KEI10:READOUT|Read||true
keithley11=ch.psi.pshell.epics.ChannelDouble|X09LA-KEI11:READOUT|Read||true
+$chamber=ch.psi.pshell.epics.ChannelString|X09LA-MA-REQ:SET|||true
$x=ch.psi.pshell.epics.Motor|X09LA-ES1-MA:TRX|||true
$y=ch.psi.pshell.epics.Motor|X09LA-ES1-MA:TRY|||true
$z=ch.psi.pshell.epics.Motor|X09LA-ES1-MA:TRZ|||true
@@ -11,8 +12,11 @@ $tilt=ch.psi.pshell.epics.Motor|X09LA-ES1-MA:TLT|||true
manipulator=ch.psi.pshell.device.MotorGroupBase|x y z phi theta tilt|||true
id_mode=ch.psi.pshell.epics.DiscretePositioner|X09LA-ID:MODE|||true
id_status=ch.psi.pshell.epics.ChannelString|X09LA-ID:OFFS-MNTR|Read||true
-$shutter=ch.psi.pshell.epics.DiscretePositioner|X09LA-SIS:OPEN|||true
-$energy=ch.psi.pshell.epics.Positioner|X09LA-PHS:E_SP X09LA-PGM:rbkenergy|||true
+shutter=ch.psi.pshell.epics.DiscretePositioner|X09LA-SIS:OPEN|||true
+grating=ch.psi.pshell.epics.DiscretePositioner|X09LA-PGM-GRCH:GRATING X09LA-PGM:grating|||true
+pgm_cff=ch.psi.pshell.epics.Positioner|X09LA-PGM:cff.A.SETP X09LA-PGM:cff.A.VAL|||true
+$photon_energy=ch.psi.pshell.epics.Positioner|X09LA-PHS:E_SP X09LA-PGM:rbkenergy|||true
+oper_mode=ch.psi.pshell.epics.DiscretePositioner|X09LA-PHS-E:OPT|||true
temp_cryostat=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-PC-LAKESHORE:TEMP_RBV|Read||false
temp_sample1=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-PC-LAKESHORE:TEMP-B|Read||
temp_headmech=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-PC-LAKESHORE:TEMP-C|Read||
@@ -24,9 +28,10 @@ temp_cryopump=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-PC-LAKESHORE:TEM
helium_valve=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-PC-LAKESHORE:ANALOG-OUT_RBV.VAL|Read||
acmi=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-ES1-ACMI:PRESSURE|Read||
tcmp=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-ES1-TCMP:PRESSURE|Read||false
-exit_slit=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-OP2-SL:TRY.VAL|Read||
-fe_vert_width=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-FE-SVsize|Read||
-fe_horiz_width=ch.psi.pshell.epics.ReadonlyProcessVariable|X09LA-FE-SHsize|Read||
+exit_slit=ch.psi.pshell.epics.Positioner|X09LA-OP2-SL:TRY.VAL X09LA-OP2-SL:TRY.RBV|||true
+fe_vert_width=ch.psi.pshell.epics.ProcessVariable|X09LA-FE-SVsize|||true
+fe_horiz_width=ch.psi.pshell.epics.ProcessVariable|X09LA-FE-SHsize|||true
+fe_state=ch.psi.pshell.epics.DiscretePositioner|X09LA-FE-DSAPER|||true
master=ch.psi.pshell.device.MasterPositioner|tilt x y z|||
image=ch.psi.pshell.imaging.CameraSource|scienta|||true
cam1=ch.psi.pshell.imaging.MjpegSource|http://129.129.117.82/axis-cgi/mjpg/video.cgi?camera=1||-200|
diff --git a/config/scicat.properties b/config/scicat.properties
new file mode 100644
index 0000000..b53b99a
--- /dev/null
+++ b/config/scicat.properties
@@ -0,0 +1,11 @@
+#Tue Nov 16 14:38:27 CET 2021
+environment=prod
+testParameters=-testenv -user slssim\:slssim
+sourceFolder=/sls/X09LA/Data1/X09LA/pshell
+prodParameters=\ -user slssim\:slssim
+devParameters=-devenv -user slssim\:slssim
+ownerGroup=
+type=raw
+parameters=-ingest -allowexistingsource -noninteractive -autoarchive
+creationLocation=/PSI/SLS/SIS
+principalInvestigator=
diff --git a/config/session_metadata.properties b/config/session_metadata.properties
new file mode 100644
index 0000000..4c78892
--- /dev/null
+++ b/config/session_metadata.properties
@@ -0,0 +1,4 @@
+#Tue Nov 16 14:32:36 CET 2021
+Sample=String
+Contact=String;gobbo_a
+User=String
diff --git a/config/sessions.properties b/config/sessions.properties
new file mode 100644
index 0000000..e798900
--- /dev/null
+++ b/config/sessions.properties
@@ -0,0 +1,2 @@
+#Tue Nov 16 14:38:00 CET 2021
+SessionCounter=1
diff --git a/config/variables.properties b/config/variables.properties
index 057e20b..a483c7e 100644
--- a/config/variables.properties
+++ b/config/variables.properties
@@ -1,4 +1,4 @@
-#Thu Sep 30 11:47:34 CEST 2021
-LastRunDate=210930
-DaySequentialNumber=7
-FileSequentialNumber=53
+#Tue Dec 07 14:58:23 CET 2021
+LastRunDate=211207
+DaySequentialNumber=1
+FileSequentialNumber=80
diff --git a/devices/cff.properties b/devices/cff.properties
new file mode 100644
index 0000000..3894d8d
--- /dev/null
+++ b/devices/cff.properties
@@ -0,0 +1,10 @@
+#Tue Dec 07 11:50:14 CET 2021
+offset=0.0
+maxValue=2.25
+rotation=false
+precision=2
+scale=1.0
+resolution=NaN
+minValue=2.25
+unit=
+sign_bit=0
diff --git a/devices/energy.properties b/devices/energy.properties
index e2a15e4..9a79895 100644
--- a/devices/energy.properties
+++ b/devices/energy.properties
@@ -1,10 +1,10 @@
-#Wed Apr 21 09:48:12 CEST 2021
+#Fri Nov 12 15:40:11 CET 2021
offset=0.0
maxValue=350.0
rotation=false
precision=3
scale=1.0
resolution=0.01
-minValue=19.5
+minValue=0.0
unit=eV
sign_bit=0
diff --git a/devices/exit_slit.properties b/devices/exit_slit.properties
index 0904d57..d607b24 100644
--- a/devices/exit_slit.properties
+++ b/devices/exit_slit.properties
@@ -1,6 +1,10 @@
-#Mon Sep 27 17:45:37 CEST 2021
-unit=800.0000000
+#Tue Dec 07 21:38:48 CET 2021
offset=0.0
-precision=800
-sign_bit=0
+maxValue=200.0
+precision=1
+rotation=false
scale=1.0
+resolution=NaN
+unit=um
+minValue=0.0
+sign_bit=0
diff --git a/devices/fe_horiz_width.properties b/devices/fe_horiz_width.properties
index 0e8fc6e..aca63da 100644
--- a/devices/fe_horiz_width.properties
+++ b/devices/fe_horiz_width.properties
@@ -1,6 +1,9 @@
-#Mon Sep 27 17:45:37 CEST 2021
+#Tue Dec 07 13:44:36 CET 2021
unit=mm
+minValue=NaN
offset=0.0
+maxValue=NaN
precision=3
sign_bit=0
scale=1.0
+resolution=NaN
diff --git a/devices/fe_vert_width.properties b/devices/fe_vert_width.properties
index 0e8fc6e..aca63da 100644
--- a/devices/fe_vert_width.properties
+++ b/devices/fe_vert_width.properties
@@ -1,6 +1,9 @@
-#Mon Sep 27 17:45:37 CEST 2021
+#Tue Dec 07 13:44:36 CET 2021
unit=mm
+minValue=NaN
offset=0.0
+maxValue=NaN
precision=3
sign_bit=0
scale=1.0
+resolution=NaN
diff --git a/devices/pgm_cff.properties b/devices/pgm_cff.properties
new file mode 100644
index 0000000..8d04da8
--- /dev/null
+++ b/devices/pgm_cff.properties
@@ -0,0 +1,10 @@
+#Tue Dec 07 16:46:29 CET 2021
+minValue=2.25
+unit=2.250
+offset=0.0
+maxValue=2.25
+rotation=false
+precision=2
+sign_bit=0
+scale=1.0
+resolution=NaN
diff --git a/devices/photon_energy.properties b/devices/photon_energy.properties
new file mode 100644
index 0000000..c54d98f
--- /dev/null
+++ b/devices/photon_energy.properties
@@ -0,0 +1,10 @@
+#Fri Nov 12 15:14:31 CET 2021
+offset=0.0
+maxValue=2000.0
+rotation=false
+precision=-1
+scale=1.0
+resolution=NaN
+minValue=0.0
+unit=eV
+sign_bit=0
diff --git a/plugins/SIStem.form b/plugins/SIStem.form
index ebe958f..a93ce6e 100644
--- a/plugins/SIStem.form
+++ b/plugins/SIStem.form
@@ -156,7 +156,7 @@
-
+
@@ -637,7 +637,7 @@
-
+
@@ -806,8 +806,8 @@
-
-
+
+
@@ -816,27 +816,55 @@
-
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -848,7 +876,7 @@
-
+
@@ -896,6 +924,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -912,11 +1056,11 @@
-
+
-
+
-
+
@@ -957,6 +1101,9 @@
+
+
+
@@ -985,6 +1132,9 @@
+
+
+
@@ -1006,16 +1156,18 @@
-
+
+
+
+
@@ -1036,13 +1188,13 @@
-
+
-
+
-
+
-
+
diff --git a/plugins/SIStem.java b/plugins/SIStem.java
index 443802e..3cba2e9 100644
--- a/plugins/SIStem.java
+++ b/plugins/SIStem.java
@@ -1,12 +1,17 @@
import ch.psi.pshell.core.Context;
import ch.psi.pshell.core.JsonSerializer;
+import ch.psi.pshell.device.DiscretePositioner;
+import ch.psi.pshell.device.MasterPositioner;
import ch.psi.pshell.device.Motor;
import ch.psi.pshell.device.Positioner;
+import ch.psi.pshell.device.ProcessVariable;
import ch.psi.pshell.device.ReadonlyProcessVariable;
+import ch.psi.pshell.device.Register;
import ch.psi.pshell.plot.MatrixPlotSeries;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.swing.DataPanel;
+import ch.psi.pshell.swing.DevicePanel;
import ch.psi.pshell.ui.PanelProcessor;
import ch.psi.pshell.ui.QueueProcessor;
import ch.psi.utils.Arr;
@@ -27,12 +32,14 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.DefaultComboBoxModel;
import javax.swing.DropMode;
import javax.swing.JComboBox;
import javax.swing.JComponent;
@@ -41,6 +48,7 @@ import javax.swing.JFileChooser;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
import javax.swing.TransferHandler;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
@@ -54,6 +62,7 @@ public class SIStem extends PanelProcessor {
final DefaultTableModel modelInactive;
final DefaultTableModel modelFixed;
final DefaultTableModel modelScanned;
+ final DefaultTableModel modelMaster;
QueueProcessor queueProcessor;
JDialog dataDialog;
@@ -62,12 +71,16 @@ public class SIStem extends PanelProcessor {
final JTextField[] scientaIntFields;
final JComboBox[] scientaCombos;
final JTextField[] scientaRangeFields;
+ final JComboBox[] deviceCombos;
+
+ boolean intialized;
public SIStem() {
initComponents();
modelInactive = (DefaultTableModel) tableInactive.getModel();
modelFixed = (DefaultTableModel) tableFixed.getModel();
modelScanned = (DefaultTableModel) tableScanned.getModel();
+ modelMaster = (DefaultTableModel) tableMaster.getModel();
abstract class PositinerTransferHandler extends TransferHandler {
@@ -97,17 +110,20 @@ public class SIStem extends PanelProcessor {
try {
JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
String name = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor);
- Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
DefaultTableModel model = ((DefaultTableModel) ((JTable) support.getComponent()).getModel());
- addPositioner(pos, model, dl.getRow(), getRowData(pos));
+ ProcessVariable pos = getContext().getDevicePool().getByName(name, ProcessVariable.class);
+ if (pos != null) {
+ addDevice(pos, model, dl.getRow(), getRowData(pos));
+ }
} catch (Exception ex) {
+ ex.printStackTrace();
return false;
}
}
return true;
}
- abstract Object[] getRowData(Positioner pos);
+ abstract Object[] getRowData(ProcessVariable pos);
};
tableInactive.setDragEnabled(true);
@@ -115,8 +131,8 @@ public class SIStem extends PanelProcessor {
tableInactive.setFillsViewportHeight(true);
tableInactive.setTransferHandler(new PositinerTransferHandler() {
@Override
- Object[] getRowData(Positioner pos) {
- return new Object[]{pos.getName()};
+ Object[] getRowData(ProcessVariable dev) {
+ return new Object[]{dev.getName()};
}
});
@@ -125,8 +141,8 @@ public class SIStem extends PanelProcessor {
tableFixed.setFillsViewportHeight(true);
tableFixed.setTransferHandler(new PositinerTransferHandler() {
@Override
- Object[] getRowData(Positioner pos) {
- return new Object[]{pos.getName(), Double.NaN, pos.getUnit()};
+ Object[] getRowData(ProcessVariable dev) {
+ return new Object[]{dev.getName(), Double.NaN, dev.getUnit()};
}
});
@@ -135,8 +151,8 @@ public class SIStem extends PanelProcessor {
tableScanned.setFillsViewportHeight(true);
tableScanned.setTransferHandler(new PositinerTransferHandler() {
@Override
- Object[] getRowData(Positioner pos) {
- return new Object[]{pos.getName(), Double.NaN, Double.NaN, 0, Double.NaN, pos.getUnit()};
+ Object[] getRowData(ProcessVariable dev) {
+ return new Object[]{dev.getName(), Double.NaN, Double.NaN, 0, dev.getUnit()};
}
});
@@ -145,6 +161,7 @@ public class SIStem extends PanelProcessor {
scientaIntFields = new JTextField[]{textSlices, textChannels};
scientaRangeFields = new JTextField[]{textXChannelMax, textXChannelMin, textYChannelMax, textYChannelMin};
scientaCombos = new JComboBox[]{comboPass, comboAcquisition, comboEnergy, comboLens, comboDetMode};
+ deviceCombos = new JComboBox[]{comboPol, comboGrating};
try {
Class scienta = getContext().getClassByName("Scienta");
@@ -166,20 +183,20 @@ public class SIStem extends PanelProcessor {
clear();
}
- void addPositioner(Positioner pos, DefaultTableModel model, int row, Object[] data) {
+ void addDevice(ProcessVariable dev, DefaultTableModel model, int row, Object[] data) {
if (row < 0) {
row = model.getRowCount();
}
model.insertRow(row, data);
- removePositioner(pos, modelInactive, (model == modelInactive) ? row : -1);
- removePositioner(pos, modelFixed, (model == modelFixed) ? row : -1);
- removePositioner(pos, modelScanned, (model == modelScanned) ? row : -1);
+ removeDevice(dev, modelInactive, (model == modelInactive) ? row : -1);
+ removeDevice(dev, modelFixed, (model == modelFixed) ? row : -1);
+ removeDevice(dev, modelScanned, (model == modelScanned) ? row : -1);
}
- void removePositioner(Positioner pos, DefaultTableModel model, int except) {
+ void removeDevice(ProcessVariable dev, DefaultTableModel model, int except) {
for (int i = 0; i < model.getRowCount(); i++) {
if ((except < 0) || (i != except)) {
- if (model.getValueAt(i, 0).equals(pos.getName())) {
+ if (model.getValueAt(i, 0).equals(dev.getName())) {
model.removeRow(i);
break;
}
@@ -193,10 +210,45 @@ public class SIStem extends PanelProcessor {
if (runCount == 0) {
clear();
}
+ if (getState()==State.Ready){
+ onStateChange(State.Ready, State.Initializing);
+ }
+ updateMaster();
}
@Override
public void onStateChange(State state, State former) {
+ if (!intialized) {
+ if ((state == State.Ready) && (former == State.Initializing)) {
+ try {
+ Class enumClass = (Class) eval("scienta.getLensModeClass()");
+ String[] mode_position = (String[]) eval("id_mode.getPositions()");
+ String[] grating_position = (String[]) eval("grating.getPositions()");
+ SwingUtilities.invokeLater(() -> {
+ try {
+ SwingUtils.setEnumCombo(comboLens, enumClass, true);
+ SwingUtils.insertCombo(comboLens, "", 0);
+ comboLens.setSelectedIndex(0);
+
+ comboPol.setModel(new DefaultComboBoxModel(mode_position));
+ SwingUtils.insertCombo(comboPol, "", 0);
+ comboPol.setSelectedIndex(0);
+
+ comboGrating.setModel(new DefaultComboBoxModel(grating_position));
+ SwingUtils.insertCombo(comboGrating, "", 0);
+ comboGrating.setSelectedIndex(0);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ });
+ intialized = true;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
updateControls();
}
@@ -254,8 +306,14 @@ public class SIStem extends PanelProcessor {
currentFile = new File(fileName);
Map preActions = new LinkedHashMap();
+
+ for (JComboBox combo : deviceCombos) {
+ if ((combo.isVisible()) && (combo.getSelectedIndex() > 0)) {
+ preActions.put(combo.getName(), String.valueOf(combo.getSelectedItem()));
+ }
+ }
for (JComboBox combo : scientaCombos) {
- if ((combo.isVisible()) &&(combo.getSelectedIndex() > 0)) {
+ if ((combo.isVisible()) && (combo.getSelectedIndex() > 0)) {
preActions.put(combo.getName(), String.valueOf(combo.getSelectedItem()));
}
}
@@ -265,7 +323,7 @@ public class SIStem extends PanelProcessor {
}
}
for (JTextField text : scientaIntFields) {
- if ((text.isVisible()) &&(!text.getText().isBlank())) {
+ if ((text.isVisible()) && (!text.getText().isBlank())) {
preActions.put(text.getName(), Integer.valueOf(text.getText().trim()));
}
}
@@ -330,6 +388,12 @@ public class SIStem extends PanelProcessor {
List steps = (List) config.get("STEPS");
for (String name : preActions.keySet()) {
+ for (JComboBox combo : deviceCombos) {
+ if (name.equals(combo.getName())) {
+ combo.setSelectedItem(String.valueOf(preActions.get(name)));
+ break;
+ }
+ }
for (JComboBox combo : scientaCombos) {
if (name.equals(combo.getName())) {
combo.setSelectedItem(String.valueOf(preActions.get(name)));
@@ -349,14 +413,14 @@ public class SIStem extends PanelProcessor {
}
Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
if (pos != null) {
- addPositioner(pos, modelFixed, -1, new Object[]{name, preActions.get(name), pos.getUnit()});
+ addDevice(pos, modelFixed, -1, new Object[]{name, preActions.get(name), pos.getUnit()});
}
}
for (int i = 0; i < positioners.size(); i++) {
String name = positioners.get(i);
Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
if (pos != null) {
- addPositioner(pos, modelScanned, -1, new Object[]{name, start.get(i), stop.get(i), steps.get(i) + 1, 0, pos.getUnit()});
+ addDevice(pos, modelScanned, -1, new Object[]{name, start.get(i), stop.get(i), steps.get(i) + 1, pos.getUnit()});
}
}
@@ -377,6 +441,9 @@ public class SIStem extends PanelProcessor {
@Override
public void clear() {
currentFile = null;
+ for (JComboBox combo : deviceCombos) {
+ combo.setSelectedIndex(0);
+ }
for (JComboBox combo : scientaCombos) {
combo.setSelectedIndex(0);
}
@@ -408,13 +475,13 @@ public class SIStem extends PanelProcessor {
checkZigzag.setSelected(false);
checkCompression.setSelected(true);
updateControls();
- if (isLoaded()){
+ if (isLoaded()) {
updateDetectorPlot();
try {
updateLens();
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
- }
+ }
}
}
@@ -440,15 +507,24 @@ public class SIStem extends PanelProcessor {
void initInactive() {
modelInactive.setRowCount(0);
- Positioner[] positioners = getContext().getDevicePool().getAllDevicesOrderedByName(Positioner.class);
- for (Positioner pos : positioners) {
- modelInactive.addRow(new Object[]{pos.getName()});
+ List names = new ArrayList<>();
+ names.addAll(Arrays.asList(getContext().getDevicePool().getAllNamesOrderedByName(Motor.class)));
+ names.addAll(Arrays.asList(getContext().getDevicePool().getAllNamesOrderedByName(MasterPositioner.class)));
+ names.add("energy");
+ names.add("exit_slit");
+ names.add("fe_vert_width");
+ names.add("fe_horiz_width");
+ names.add("cff");
+
+ for (String name : names) {
+ modelInactive.addRow(new Object[]{name});
}
}
@Override
public void execute() throws Exception {
checkValues();
+ checkBeamline();
save();
if (currentFile == null) {
return;
@@ -474,12 +550,12 @@ public class SIStem extends PanelProcessor {
if (currentFile != null) {
scan = IO.getPrefix(currentFile);
String home = getContext().getSetup().expandPath(getHomePath());
- String path = IO.getRelativePath(currentFile.getParentFile().getPath(), home);
- if ((path!=null) && (!path.isBlank()) && !path.equals("/")){
- if (!path.endsWith("/")){
- path=path+"/";
+ String path = IO.getRelativePath(currentFile.getParentFile().getPath(), home);
+ if ((path != null) && (!path.isBlank()) && !path.equals("/")) {
+ if (!path.endsWith("/")) {
+ path = path + "/";
}
- scan=path+scan;
+ scan = path + scan;
}
}
return scan;
@@ -502,44 +578,89 @@ public class SIStem extends PanelProcessor {
buttonAddToQueue.setEnabled(((state == State.Ready) && (currentFile != null)) || isDetached());
buttonAbort.setEnabled(state.isProcessing());
buttonScienta.setEnabled(state.isInitialized());
+
+ boolean selected = tableMaster.getSelectedRow() >= 0;
+ boolean enabled = state.isInitialized();
+ buttonEditMaster.setEnabled(enabled && selected);
+
}
-
- void updateLens() throws Exception{
+
+ void updateMaster() {
+ modelMaster.setNumRows(0);
+ for (MasterPositioner dev : getContext().getDevicePool().getAllDevices(MasterPositioner.class)) {
+ try {
+ Positioner[] slaves = dev.getSlaves();
+ String[] names = new String[slaves.length];
+ for (int i = 0; i < slaves.length; i++) {
+ names[i] = slaves[i].getName();
+ }
+
+ modelMaster.addRow(new Object[]{dev.getName(), dev.getMaster().getName(), String.join(", ", names)});
+ } catch (Exception ex) {
+ Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ updateControls();
+ }
+
+ void updateLens() throws Exception {
String lens = (String) comboLens.getSelectedItem();
- boolean empty = ((lens==null)||(lens.isBlank()));
+ boolean empty = ((lens == null) || (lens.isBlank()));
//if (empty){
- //lens = (String) eval("str(scienta.lensMode)", true);
+ //lens = (String) eval("str(scienta.lensMode)", true);
//}
boolean visibleX = empty || lens.startsWith("A") || lens.startsWith("D");
boolean visibleY = empty || lens.startsWith("D");
panelX.setVisible(visibleX);
- for (Component c : SwingUtils.getComponentsByType(panelX, Component.class)){
+ for (Component c : SwingUtils.getComponentsByType(panelX, Component.class)) {
c.setVisible(visibleX);
}
panelY.setVisible(visibleY);
- for (Component c : SwingUtils.getComponentsByType(panelY, Component.class)){
+ for (Component c : SwingUtils.getComponentsByType(panelY, Component.class)) {
c.setVisible(visibleY);
}
-
+
}
void checkValues() {
for (int i = 0; i < modelFixed.getRowCount(); i++) {
- if (Double.isNaN((Double) modelFixed.getValueAt(i, 1))) {
- throw new IllegalArgumentException("Invalid value for " + modelFixed.getValueAt(i, 0));
+ String positioner = (String) modelFixed.getValueAt(i, 0);
+ Double value = (Double) modelFixed.getValueAt(i, 1);
+ if (Double.isNaN(value)) {
+ throw new IllegalArgumentException("Invalid value for " + positioner);
}
+ Positioner dev = (Positioner) getDevice(positioner);
+ dev.assertValidValue(value);
}
for (int i = 0; i < modelScanned.getRowCount(); i++) {
- if (Double.isNaN((Double) modelScanned.getValueAt(i, 1))) {
- throw new IllegalArgumentException("Invalid start for " + modelFixed.getValueAt(i, 0));
+ Double start = (Double) modelScanned.getValueAt(i, 1);
+ Double end = (Double) modelScanned.getValueAt(i, 2);
+ Integer points = (Integer) modelScanned.getValueAt(i, 3);
+ String positioner = (String) modelScanned.getValueAt(i, 0);
+ /*
+ if ((start == null) || Double.isNaN(start)) {
+ throw new IllegalArgumentException("Invalid start for " + positioner);
}
- if (Double.isNaN((Double) modelScanned.getValueAt(i, 2))) {
- throw new IllegalArgumentException("Invalid stop for " + modelFixed.getValueAt(i, 0));
+ if ((end == null) || Double.isNaN(end)) {
+ throw new IllegalArgumentException("Invalid stop for " + positioner);
}
- if (((Integer) modelScanned.getValueAt(i, 3)) < 1) {
- throw new IllegalArgumentException("Invalid points for " + modelFixed.getValueAt(i, 0));
+ */
+
+ Positioner dev = (Positioner) getDevice(positioner);
+ dev.assertValidValue(start);
+ dev.assertValidValue(end);
+ /*
+ double min = Math.min(start, end);
+ double max = Math.max(start, end);
+ if ((min < dev.getMinValue()) || (max > dev.getMaxValue())) {
+ throw new IllegalArgumentException("Invalid scan range for " + positioner);
}
+ if ((points == null) || (points < 1)) {
+ throw new IllegalArgumentException("Invalid points for " + positioner);
+ }
+ */
}
+
for (JTextArea text : new JTextArea[]{textSensors, textDiagnostics, textSnapshots, textMonitors}) {
for (String name : getDevices(text)) {
try {
@@ -584,52 +705,87 @@ public class SIStem extends PanelProcessor {
}
}
+ void checkBeamline() {
+ Register chamber = (Register) getDevice("chamber");
+ if (!chamber.isSimulated()) {
+ if (!"AC".equals(chamber.take())) {
+ throw new IllegalArgumentException("Manipulator not in AC");
+ }
+ }
+ }
+
void onTabChanged() {
}
void updateDetectorPlot() {
- try {
- int[] sensor = (int[]) eval("scienta.getSensorSize()", true);
- int[] roi = (int[]) eval("scienta.getROI()", true);
- roi=new int[]{roi[0], roi[1], roi[2] + roi[0], roi[3] + roi[1]};//Change to xmin, ymin, xmax, ymax
- try{
- roi[0]=Integer.valueOf(textXChannelMin.getText());
- } catch (Exception ex){
- }
- try{
- roi[1]=Integer.valueOf(textYChannelMin.getText());
- } catch (Exception ex){
- }
- try{
- roi[2]=Integer.valueOf(textXChannelMax.getText());
- } catch (Exception ex){
- }
- try{
- roi[3]=Integer.valueOf(textYChannelMax.getText());
- } catch (Exception ex){
- }
-
- detectorPlot.getAxis(Plot.AxisId.X).setRange(0, sensor[0] - 1);
- detectorPlot.getAxis(Plot.AxisId.Y).setRange(0, sensor[1] - 1);
-
- if (detectorPlot.getNumberOfSeries()==0){
- double[][] arr = new double[][]{new double[]{Double.NaN}};
- detectorPlot.addSeries(new MatrixPlotSeries(""));
- detectorPlot.getSeries(0).setData(arr);
- }
-
- detectorPlot.removeMarker(null);
- detectorPlot.addMarker(roi[0], Plot.AxisId.X, "", Color.GREEN);
- detectorPlot.addMarker(roi[1], Plot.AxisId.Y, "", Color.GREEN);
- detectorPlot.addMarker(roi[2], Plot.AxisId.X, "", Color.GREEN);
- detectorPlot.addMarker(roi[3], Plot.AxisId.Y, "", Color.GREEN);
- } catch (Exception ex) {
- getLogger().log(Level.WARNING, null, ex);
+ if (getState().isInitialized()) {
+ new Thread(() -> {
+ try {
+ int[] sensor = (int[]) eval("scienta.getSensorSize()", true);
+ int[] _roi = (int[]) eval("scienta.getROI()", true);
+ SwingUtilities.invokeAndWait(() -> {
+ int[] roi = _roi;
+ roi = new int[]{roi[0], roi[1], roi[2] + roi[0], roi[3] + roi[1]};//Change to xmin, ymin, xmax, ymax
+ try {
+ roi[0] = Integer.valueOf(textXChannelMin.getText());
+ } catch (Exception ex) {
+ }
+ try {
+ roi[1] = Integer.valueOf(textYChannelMin.getText());
+ } catch (Exception ex) {
+ }
+ try {
+ roi[2] = Integer.valueOf(textXChannelMax.getText());
+ } catch (Exception ex) {
+ }
+ try {
+ roi[3] = Integer.valueOf(textYChannelMax.getText());
+ } catch (Exception ex) {
+ }
+
+ detectorPlot.getAxis(Plot.AxisId.X).setRange(0, sensor[0] - 1);
+ detectorPlot.getAxis(Plot.AxisId.Y).setRange(0, sensor[1] - 1);
+
+ if (detectorPlot.getNumberOfSeries() == 0) {
+ double[][] arr = new double[][]{new double[]{Double.NaN}};
+ detectorPlot.addSeries(new MatrixPlotSeries(""));
+ detectorPlot.getSeries(0).setData(arr);
+ }
+
+ detectorPlot.removeMarker(null);
+ detectorPlot.addMarker(roi[0], Plot.AxisId.X, "", Color.GREEN);
+ detectorPlot.addMarker(roi[1], Plot.AxisId.Y, "", Color.GREEN);
+ detectorPlot.addMarker(roi[2], Plot.AxisId.X, "", Color.GREEN);
+ detectorPlot.addMarker(roi[3], Plot.AxisId.Y, "", Color.GREEN);
+ });
+ } catch (Exception ex) {
+ getLogger().log(Level.WARNING, null, ex);
+ }
+
+ }).start();
+
}
}
- void plotImage() throws Exception {
+ /*
+ String getMastersFile(){
+ return getContext().getSetup().expandPath("{config}/masters.json");
+ }
+ void saveMasters() throws IOException{
+ Vector vector = modelMaster.getDataVector();
+ String json = JsonSerializer.encode(vector, true);
+ Files.write(Paths.get(getMastersFile()), json.getBytes());
+ }
+ void loadMasters() throws IOException{
+ String json = new String(Files.readAllBytes(Paths.get(getMastersFile())));
+ Vector vector = (Vector) JsonSerializer.decode(json, Vector.class);
+ Vector header = new Vector<>();
+ Collections.addAll(header, SwingUtils.getTableColumnNames(tableMaster));
+ modelMaster.setDataVector(vector, header);
+ }
+ */
+ void plotImage() throws Exception {
double[][] arr = new double[][]{new double[]{Double.NaN}};
int[] sensor = (int[]) eval("scienta.getSensorSize()", true);
int[] roi = (int[]) eval("scienta.getROI()", true);
@@ -737,6 +893,14 @@ public class SIStem extends PanelProcessor {
jLabel8 = new javax.swing.JLabel();
jLabel22 = new javax.swing.JLabel();
checkCompression = new javax.swing.JCheckBox();
+ jLabel21 = new javax.swing.JLabel();
+ comboPol = new javax.swing.JComboBox();
+ comboGrating = new javax.swing.JComboBox();
+ jLabel23 = new javax.swing.JLabel();
+ jPanel6 = new javax.swing.JPanel();
+ jScrollPane8 = new javax.swing.JScrollPane();
+ tableMaster = new javax.swing.JTable();
+ buttonEditMaster = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
tableInactive = new javax.swing.JTable();
@@ -1053,7 +1217,7 @@ public class SIStem extends PanelProcessor {
.addComponent(panelX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(18, Short.MAX_VALUE))
+ .addContainerGap(100, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -1174,7 +1338,7 @@ public class SIStem extends PanelProcessor {
.addComponent(textChannels, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(butonPlot))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(detectorPlot, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
+ .addComponent(detectorPlot, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
.addContainerGap())
);
@@ -1233,12 +1397,25 @@ public class SIStem extends PanelProcessor {
jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel22.setText("Compression:");
+ jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel21.setText("Polarization:");
+
+ comboPol.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " " }));
+ comboPol.setToolTipText("");
+ comboPol.setName("id_mode"); // NOI18N
+
+ comboGrating.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " " }));
+ comboGrating.setName("grating"); // NOI18N
+
+ jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel23.setText("Grating:");
+
javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
jPanel11.setLayout(jPanel11Layout);
jPanel11Layout.setHorizontalGroup(
jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel11Layout.createSequentialGroup()
- .addContainerGap(294, Short.MAX_VALUE)
+ .addContainerGap(175, Short.MAX_VALUE)
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel22)
.addComponent(jLabel8)
@@ -1246,28 +1423,50 @@ public class SIStem extends PanelProcessor {
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(checkCompression)
+ .addGroup(jPanel11Layout.createSequentialGroup()
+ .addComponent(checkCompression)
+ .addGap(59, 59, 59))
+ .addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(checkZigzag)
- .addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(319, Short.MAX_VALUE))
+ .addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(139, 139, 139)
+ .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel21)
+ .addComponent(jLabel23))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(comboPol, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(comboGrating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(175, Short.MAX_VALUE))
);
jPanel11Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerLatency, spinnerPasses});
jPanel11Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel22, jLabel4, jLabel8});
+ jPanel11Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboGrating, comboPol});
+
jPanel11Layout.setVerticalGroup(
jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel11Layout.createSequentialGroup()
- .addGap(20, 20, 20)
- .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(checkCompression)
- .addComponent(jLabel22))
- .addGap(18, 18, 18)
- .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(checkZigzag)
- .addComponent(jLabel8))
+ .addGap(52, 52, 52)
+ .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel11Layout.createSequentialGroup()
+ .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(checkCompression)
+ .addComponent(jLabel22))
+ .addGap(18, 18, 18)
+ .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(checkZigzag)
+ .addComponent(jLabel8)))
+ .addGroup(jPanel11Layout.createSequentialGroup()
+ .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel21)
+ .addComponent(comboPol, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel23)
+ .addComponent(comboGrating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
@@ -1276,11 +1475,84 @@ public class SIStem extends PanelProcessor {
.addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(99, Short.MAX_VALUE))
+ .addContainerGap(134, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Scan", jPanel11);
+ jScrollPane8.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
+
+ tableMaster.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+
+ },
+ new String [] {
+ "Name", "Master", "Slaves"
+ }
+ ) {
+ Class[] types = new Class [] {
+ java.lang.String.class, java.lang.String.class, java.lang.String.class
+ };
+ boolean[] canEdit = new boolean [] {
+ false, false, false
+ };
+
+ public Class getColumnClass(int columnIndex) {
+ return types [columnIndex];
+ }
+
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return canEdit [columnIndex];
+ }
+ });
+ tableMaster.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+ tableMaster.getTableHeader().setReorderingAllowed(false);
+ tableMaster.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mouseClicked(java.awt.event.MouseEvent evt) {
+ tableMasterMouseClicked(evt);
+ }
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ tableMasterMousePressed(evt);
+ }
+ });
+ tableMaster.addKeyListener(new java.awt.event.KeyAdapter() {
+ public void keyReleased(java.awt.event.KeyEvent evt) {
+ tableMasterKeyReleased(evt);
+ }
+ });
+ jScrollPane8.setViewportView(tableMaster);
+
+ buttonEditMaster.setText("Edit");
+ buttonEditMaster.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonEditMasterActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
+ jPanel6.setLayout(jPanel6Layout);
+ jPanel6Layout.setHorizontalGroup(
+ jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel6Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
+ .addGap(18, 18, 18)
+ .addComponent(buttonEditMaster, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+ jPanel6Layout.setVerticalGroup(
+ jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel6Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel6Layout.createSequentialGroup()
+ .addComponent(buttonEditMaster)
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)))
+ );
+
+ jTabbedPane1.addTab("Master Axis", jPanel6);
+
jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Inactive"));
tableInactive.setModel(new javax.swing.table.DefaultTableModel(
@@ -1307,6 +1579,7 @@ public class SIStem extends PanelProcessor {
}
});
tableInactive.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+ tableInactive.getTableHeader().setReorderingAllowed(false);
jScrollPane1.setViewportView(tableInactive);
jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Fixed"));
@@ -1335,6 +1608,7 @@ public class SIStem extends PanelProcessor {
}
});
tableFixed.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+ tableFixed.getTableHeader().setReorderingAllowed(false);
jScrollPane2.setViewportView(tableFixed);
jScrollPane3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scanned"));
@@ -1344,14 +1618,14 @@ public class SIStem extends PanelProcessor {
},
new String [] {
- "Name", "Start", "Stop", "Points", "Step", "Units"
+ "Name", "Start", "Stop", "Points", "Units"
}
) {
Class[] types = new Class [] {
- java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Integer.class, java.lang.Double.class, java.lang.String.class
+ java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Integer.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
- false, true, true, true, false, false
+ false, true, true, true, false
};
public Class getColumnClass(int columnIndex) {
@@ -1363,6 +1637,7 @@ public class SIStem extends PanelProcessor {
}
});
tableScanned.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+ tableScanned.getTableHeader().setReorderingAllowed(false);
jScrollPane3.setViewportView(tableScanned);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
@@ -1371,11 +1646,11 @@ public class SIStem extends PanelProcessor {
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, 0)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
+ .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE))
+ .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -1424,13 +1699,13 @@ public class SIStem extends PanelProcessor {
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(0, 0, 0)
- .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
+ .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
+ .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
+ .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
+ .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
jPanel3Layout.setVerticalGroup(
@@ -1702,6 +1977,35 @@ public class SIStem extends PanelProcessor {
}
}//GEN-LAST:event_comboLensActionPerformed
+ private void buttonEditMasterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEditMasterActionPerformed
+ try {
+ String name = (String) modelMaster.getValueAt(tableMaster.getSelectedRow(), 0);
+ DevicePanel pn = showDevicePanel(name);
+ SwingUtils.getWindow(pn).setLocationRelativeTo(this);
+
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }//GEN-LAST:event_buttonEditMasterActionPerformed
+
+ private void tableMasterKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableMasterKeyReleased
+ updateControls();
+ }//GEN-LAST:event_tableMasterKeyReleased
+
+ private void tableMasterMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMasterMousePressed
+ updateControls();
+ }//GEN-LAST:event_tableMasterMousePressed
+
+ private void tableMasterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMasterMouseClicked
+ try {
+ if ((evt.getClickCount() % 2) == 0) {
+ buttonEditMasterActionPerformed(null);
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }//GEN-LAST:event_tableMasterMouseClicked
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton butonPlot;
@@ -1709,6 +2013,7 @@ public class SIStem extends PanelProcessor {
private javax.swing.JButton buttonAddToQueue;
private javax.swing.JButton buttonClear;
private javax.swing.JButton buttonData;
+ private javax.swing.JButton buttonEditMaster;
private javax.swing.JButton buttonOpen;
private javax.swing.JButton buttonSave;
private javax.swing.JButton buttonScienta;
@@ -1718,8 +2023,10 @@ public class SIStem extends PanelProcessor {
private javax.swing.JComboBox comboAcquisition;
private javax.swing.JComboBox comboDetMode;
private javax.swing.JComboBox comboEnergy;
+ private javax.swing.JComboBox comboGrating;
private javax.swing.JComboBox comboLens;
private javax.swing.JComboBox comboPass;
+ private javax.swing.JComboBox comboPol;
private ch.psi.pshell.plot.MatrixPlotJFree detectorPlot;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
@@ -1733,7 +2040,9 @@ public class SIStem extends PanelProcessor {
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel20;
+ private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
+ private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
@@ -1751,6 +2060,7 @@ public class SIStem extends PanelProcessor {
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
+ private javax.swing.JPanel jPanel6;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
@@ -1758,6 +2068,7 @@ public class SIStem extends PanelProcessor {
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JScrollPane jScrollPane7;
+ private javax.swing.JScrollPane jScrollPane8;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JPanel panelEnergy;
private javax.swing.JPanel panelX;
@@ -1766,6 +2077,7 @@ public class SIStem extends PanelProcessor {
private javax.swing.JSpinner spinnerPasses;
private javax.swing.JTable tableFixed;
private javax.swing.JTable tableInactive;
+ private javax.swing.JTable tableMaster;
private javax.swing.JTable tableScanned;
private javax.swing.JTextField textCenterEnergy;
private javax.swing.JTextField textCenterThetaX;
diff --git a/script/local.py b/script/local.py
index e169993..3c87455 100644
--- a/script/local.py
+++ b/script/local.py
@@ -7,9 +7,171 @@
###################################################################################################
# Device initialization
###################################################################################################
+class Energy(PositionerBase):
+ def __init__(self, name, config):
+ ControlledVariableBase.__init__(self, name, photon_energy.config)
+ self.setReadback(photon_energy.getReadback())
+
+ def doRead(self):
+ return photon_energy.read()
+
+ def doWrite(self, val):
+ if not photon_energy.isInPosition(val):
+ change_photon_pars(_photon_energy=val)
+
+ def getMinValue(self):
+ er=get_energy_range()
+ return er[0] if er is not None else sys.maxint
+
+ def getMaxValue(self):
+ er=get_energy_range()
+ return er[1] if er is not None else -sys.maxint
+add_device(Energy("energy", None), True)
+
+def get_energy_range():
+ md,gr = id_mode.read(), grating.read()
+ if gr.startswith("G1"):
+ if md in ["CIRC+", "CIRC-", "LH"]:
+ return (20,360)
+ if md in ["LV"]:
+ return (200,360)
+ if md in ["LV low E"]:
+ return (40,120)
+ if md in ["LHQ"]:
+ return (20,200)
+ if md in ["OFF"]:
+ return (20,50)
+ elif gr.startswith("G2"):
+ if md in ["CIRC+", "CIRC-", "LH"]:
+ return (80,800)
+ if md in ["LV"]:
+ return (200,800)
+ if md in ["LV low E"]:
+ return (80,120)
+ if md in ["LHQ"]:
+ return (80,200)
+ elif gr.startswith("NIM"):
+ if md in ["CIRC+", "CIRC-"]:
+ return (20,30)
+ if md in ["LH", "LHQ"]:
+ return (10,30)
+ return None
-#scienta.getDataArray().setMonitored(True)
+class Cff(PositionerBase):
+ def __init__(self, name, config):
+ ControlledVariableBase.__init__(self, name, pgm_cff.config)
+ self.setReadback(pgm_cff.getReadback())
+
+ def doRead(self):
+ return pgm_cff.read()
+
+ def doWrite(self, val):
+ if not pgm_cff.isInPosition(val):
+ change_photon_pars(_cff=val)
+
+ def getMinValue(self):
+ return pgm_cff.getMinValue()
+
+ def getMaxValue(self):
+ return pgm_cff.getMaxValue()
+
+add_device(Cff("cff", None), True)
+
+class FeSettlingCondition(SettlingCondition):
+ def doWait(self):
+ time.sleep(0.5)
+ cawait("X09LA-FE-SV1:TR1.DMOV", 1)
+ cawait("X09LA-FE-SV1:TR2.DMOV", 1)
+ cawait("X09LA-FE-SH1:TR1.DMOV", 1)
+ cawait("X09LA-FE-SH1:TR2.DMOV", 1)
+
+class IdSettlingCondition(SettlingCondition):
+ def doWait(self):
+ time.sleep(0.5)
+ id_status.waitValue("done", -1)
+
+class GrSettlingCondition(SettlingCondition):
+ def doWait(self):
+ time.sleep(0.5)
+ cawait("X09LA:m4.DMOV", 1)
+
+class CffSettlingCondition(SettlingCondition):
+ def doWait(self):
+ caput("X09LA-PGM:setE.PROC",1)
+ time.sleep(0.5)
+ cawait("X09LA:m1.DMOV", 1)
+ cawait("X09LA:m2.DMOV", 1)
+
+
+#fe_state.getSetpoint().setBlockingWrite(True)
+fe_state.setSettlingCondition(FeSettlingCondition())
+oper_mode.getSetpoint().setBlockingWrite(True)
+photon_energy.setSettlingCondition(IdSettlingCondition())
+id_mode.setSettlingCondition(IdSettlingCondition())
+grating.setSettlingCondition(GrSettlingCondition())
+pgm_cff.setSettlingCondition(CffSettlingCondition())
+
+
+def change_photon_pars(_photon_energy=None, _id_mode=None, _grating=None, _cff=None):
+ if (_photon_energy is not None) and (photon_energy.isInPosition(_photon_energy)):
+ _photon_energy = None
+ if _id_mode == id_mode.read():
+ _id_mode=None
+ if _grating == grating.read():
+ _grating=None
+ if _cff == pgm_cff.read():
+ _cff=None
+ if _photon_energy == _id_mode == _grating == _cff == None:
+ return
+ log("Changing photon parameters: photon_energy=" + str(_photon_energy) + " id_mode=" + str(_id_mode) + " grating=" + str(_grating) + " cff=" + str(_cff))
+
+ initial_fe_state = fe_state.read()
+ initial_oper_mode = oper_mode.read()
+ initial_v = fe_vert_width.read();
+ initial_h = fe_horiz_width.read()
+
+ try:
+ #Set front end to “Closed” state
+ fe_state.move("Closed")
+
+ #Set operation mode to “PGM”
+ oper_mode.move("PGM")
+
+
+ if _id_mode is not None:
+ #Set polarization mode
+ print "Setting id_mode="+str(_id_mode)
+ id_mode.move("OFF")
+ id_mode.move(_id_mode)
+
+ if _grating is not None:
+ #Set grating
+ print "Setting grating="+str(_grating)
+ grating.move(_grating)
+
+ if _photon_energy is not None:
+ #Set insertion device energy
+ print "Setting photon_energy="+str(_photon_energy)
+ photon_energy.move(_photon_energy)
+
+ if _cff is not None:
+ #Set cff
+ print "Setting cff="+str(_cff)
+ pgm_cff.move(_cff)
+
+ finally:
+ #Return operation mode to original value (e.g. “PGM+ID”)
+ oper_mode.move(initial_oper_mode)
+
+ #Return front end to original state (e.g. “2x2”)
+ fe_state.move(initial_fe_state)
+ #IF (initial_h, initial_v) does not correspond to a predefined setting
+ if (initial_h!=initial_v) or \
+ not initial_h in [-15.0,0.0,0.25,0.5,1.0,1.5,2.0]:
+ fe_vert_width.write(initial_v);
+ fe_horiz_width.write(initial_h);
+ fe_settling_condition.waitSettled()
class AcquisitionMode(Readable.ReadableString):
def read(self):
diff --git a/script/scans/scan5.json b/script/scans/scan5.json
new file mode 100644
index 0000000..1372594
--- /dev/null
+++ b/script/scans/scan5.json
@@ -0,0 +1,19 @@
+{
+ "PASSES" : 1,
+ "STOP" : [ 50.0 ],
+ "DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
+ "PRE_ACTIONS" : {
+ "id_mode" : "CIRC+",
+ "grating" : "G2 1200"
+ },
+ "COMPRESSION" : true,
+ "SENSORS" : [ "scienta.dataMatrix" ],
+ "ZIGZAG" : false,
+ "SETTLING_TIME" : 0.0,
+ "MONITORS" : [ "current" ],
+ "START" : [ 21.0 ],
+ "RANGE" : [ null, null, null, null ],
+ "POSITIONERS" : [ "energy" ],
+ "STEPS" : [ 9 ],
+ "SNAPS" : [ "acmi", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "photon_energy", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
+}
\ No newline at end of file
diff --git a/script/templates/SIStem.py b/script/templates/SIStem.py
index 5bff4fc..da90e62 100644
--- a/script/templates/SIStem.py
+++ b/script/templates/SIStem.py
@@ -41,6 +41,16 @@ passes = int(PASSES)
zigzag = bool(ZIGZAG)
+#Change photon parameters
+_id_mode=_grating=None
+if "id_mode" in PRE_ACTIONS.keys():
+ _id_mode=PRE_ACTIONS.pop("id_mode")
+if "grating" in PRE_ACTIONS.keys():
+ _grating=PRE_ACTIONS.pop("grating")
+if (_id_mode is not None) or (_grating is not None):
+ print _id_mode, _grating
+ change_photon_pars(_id_mode=_id_mode, _grating=_grating)
+1/0
#Execute pre-actions
for key in PRE_ACTIONS.keys():
if key=="eval":
@@ -78,5 +88,6 @@ try:
snaps=SNAPS, diags=DIAGS, monitors=MONITORS)
finally:
scienta.zeroSupplies()
+ pass