This commit is contained in:
gac-x09la
2021-12-07 21:41:15 +01:00
parent f48a107a2e
commit f98650d664
18 changed files with 900 additions and 182 deletions

View File

@@ -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<Integer> 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<String> 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;