Startup
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.epics.ChannelDouble;
|
||||
import ch.psi.pshell.epics.Epics;
|
||||
import ch.psi.pshell.plot.LinePlotSeries;
|
||||
import ch.psi.pshell.plot.Plot;
|
||||
@@ -14,17 +15,29 @@ import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class WireScan extends Panel {
|
||||
final String[] seriesNames = new String[]{"bpm1_x", "bpm1_y", "bpm1_q", "bpm2_x", "bpm2_y", "bpm2_q"};
|
||||
final JComboBox[] bpmCombos;
|
||||
final int[] seriesYAxis = new int[]{1, 1, 2, 1, 1, 2};
|
||||
LinePlotSeries[] series = new LinePlotSeries[seriesNames.length];
|
||||
boolean homed;
|
||||
|
||||
public WireScan() {
|
||||
initComponents();
|
||||
@@ -35,15 +48,19 @@ public class WireScan extends Panel {
|
||||
plot.getAxis(Plot.AxisId.X).setLabel("Position");
|
||||
plot.getAxis(Plot.AxisId.Y).setLabel("mm");
|
||||
plot.getAxis(Plot.AxisId.Y2).setLabel("pc");
|
||||
plot.setLegendVisible(true);
|
||||
plot.setLegendVisible(true);
|
||||
bpmCombos = new JComboBox[]{comboBpm1, comboBpm2, comboBpm3};
|
||||
}
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
try {
|
||||
startTimer(1000, 10);
|
||||
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||
eval("run('Devices/Elements')", true);
|
||||
model.addElement("");
|
||||
List<String> ret = (List<String>) ((Plugin)this).eval("get_wire_scans()", true);
|
||||
for (String scan: ret){
|
||||
model.addElement(scan);
|
||||
@@ -53,33 +70,72 @@ public class WireScan extends Panel {
|
||||
model = new DefaultComboBoxModel();
|
||||
ret = (List<String>) ((Plugin)this).eval("WireScanner.Selection", true);
|
||||
for (String scan: ret){
|
||||
model.addElement(scan);
|
||||
if (!scan.equals("GARAGE")){
|
||||
model.addElement(scan);
|
||||
}
|
||||
}
|
||||
comboSelection.setModel(model);
|
||||
comboWireScanActionPerformed(null);
|
||||
|
||||
model = new DefaultComboBoxModel();
|
||||
ret = (List<String>) ((Plugin)this).eval("get_bpms()", true);
|
||||
model.addElement("");
|
||||
for (String scan: ret){
|
||||
model.addElement(scan);
|
||||
|
||||
ret = (List<String>) ((Plugin)this).eval("get_bpms()", true);
|
||||
for (JComboBox cb : bpmCombos){
|
||||
model = new DefaultComboBoxModel();
|
||||
model.addElement("");
|
||||
for (String scan: ret){
|
||||
model.addElement(scan);
|
||||
}
|
||||
cb.setModel(model);
|
||||
}
|
||||
comboBpm3.setModel(model);
|
||||
if (App.hasArgument("ws")){
|
||||
comboWireScan.setSelectedItem(App.getArgumentValue("ws"));
|
||||
}
|
||||
|
||||
}
|
||||
comboWireScanActionPerformed(null);
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onTimer(){
|
||||
try{
|
||||
boolean validWireScan = !comboWireScan.getSelectedItem().toString().isEmpty();
|
||||
if (validWireScan){
|
||||
homed = (Epics.get(comboWireScan.getSelectedItem().toString() + ":MOTOR_1_HOMED", Integer.class) == 1);
|
||||
if (homed){
|
||||
ledHomed.setColor(Color.GREEN);
|
||||
} else if (Epics.get(comboWireScan.getSelectedItem().toString() + ":MOTOR_1_HOMING", Integer.class) == 1){
|
||||
ledHomed.setColor(Color.YELLOW);
|
||||
} else {
|
||||
ledHomed.setColor(Color.RED);
|
||||
}
|
||||
} else {
|
||||
ledHomed.setColor(Color.darkGray);
|
||||
homed = false;
|
||||
}
|
||||
onStateChange(getState(), getState());
|
||||
} catch (Exception ex){
|
||||
}
|
||||
}
|
||||
//S20CB01-DWSC440:MOTOR_1_HOME.PROC
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
buttonMoveStart.setEnabled(state==State.Ready);
|
||||
buttonScan.setEnabled(state==State.Ready);
|
||||
boolean validWireScan = !comboWireScan.getSelectedItem().toString().isEmpty();
|
||||
buttonMoveStart.setEnabled((state==State.Ready) && validWireScan && homed);
|
||||
buttonPark.setEnabled((state==State.Ready) && validWireScan && homed);
|
||||
buttonScan.setEnabled((state==State.Ready) && validWireScan && homed);
|
||||
buttonAbort.setEnabled(state==State.Busy);
|
||||
comboSelection.setEnabled(validWireScan);
|
||||
comboBpm1.setEnabled(validWireScan);
|
||||
comboBpm2.setEnabled(validWireScan);
|
||||
comboBpm3.setEnabled(validWireScan);
|
||||
buttonMotorPanel.setEnabled(validWireScan);
|
||||
buttonScannerPanel.setEnabled(validWireScan);
|
||||
buttonHoming.setEnabled(validWireScan);
|
||||
for (Component c: SwingUtils.getComponentsByType(this, JSpinner.class)){
|
||||
c.setEnabled(validWireScan);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,8 +191,6 @@ public class WireScan extends Panel {
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
comboSelection = new javax.swing.JComboBox();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
textBpm1 = new javax.swing.JTextField();
|
||||
textBpm2 = new javax.swing.JTextField();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
jLabel5 = new javax.swing.JLabel();
|
||||
comboBpm3 = new javax.swing.JComboBox();
|
||||
@@ -154,6 +208,16 @@ public class WireScan extends Panel {
|
||||
spinnerCycles = new javax.swing.JSpinner();
|
||||
panelStatus = new ch.psi.pshell.swing.DeviceValuePanel();
|
||||
plot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
comboBpm1 = new javax.swing.JComboBox();
|
||||
comboBpm2 = new javax.swing.JComboBox();
|
||||
buttonPark = new javax.swing.JButton();
|
||||
jLabel11 = new javax.swing.JLabel();
|
||||
panelPosition = new ch.psi.pshell.swing.DeviceValuePanel();
|
||||
buttonMotorPanel = new javax.swing.JButton();
|
||||
buttonScannerPanel = new javax.swing.JButton();
|
||||
jLabel12 = new javax.swing.JLabel();
|
||||
ledHomed = new ch.psi.pshell.swing.Led();
|
||||
buttonHoming = new javax.swing.JButton();
|
||||
|
||||
comboWireScan.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
@@ -176,10 +240,6 @@ public class WireScan extends Panel {
|
||||
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel3.setText("BPM 1:");
|
||||
|
||||
textBpm1.setEditable(false);
|
||||
|
||||
textBpm2.setEditable(false);
|
||||
|
||||
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel4.setText("BPM 2:");
|
||||
|
||||
@@ -232,37 +292,74 @@ public class WireScan extends Panel {
|
||||
|
||||
plot.setTitle("");
|
||||
|
||||
buttonPark.setText("Park");
|
||||
buttonPark.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonParkActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel11.setText("Position:");
|
||||
|
||||
buttonMotorPanel.setText("Motor Panel");
|
||||
buttonMotorPanel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonMotorPanelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonScannerPanel.setText("Scanner Panel");
|
||||
buttonScannerPanel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonScannerPanelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel12.setText("Homed:");
|
||||
|
||||
ledHomed.setForeground(java.awt.Color.darkGray);
|
||||
ledHomed.setLedSize(18);
|
||||
|
||||
buttonHoming.setText("Homing");
|
||||
buttonHoming.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonHomingActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboWireScan, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(jLabel8)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(buttonMoveStart, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(buttonPark)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonScan, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonMoveStart)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(buttonScan)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonAbort))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(comboSelection, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(textBpm1)
|
||||
.addComponent(textBpm2)
|
||||
.addComponent(comboBpm3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -278,13 +375,34 @@ public class WireScan extends Panel {
|
||||
.addComponent(jLabel9)
|
||||
.addGap(8, 8, 8)
|
||||
.addComponent(spinnerCycles))))
|
||||
.addComponent(panelStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addComponent(panelStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(comboBpm1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(comboBpm2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jLabel11)
|
||||
.addComponent(jLabel12))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(panelPosition, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(ledHomed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonHoming)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(buttonMotorPanel, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(buttonScannerPanel, javax.swing.GroupLayout.Alignment.TRAILING))))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 451, Short.MAX_VALUE)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 457, Short.MAX_VALUE)
|
||||
.addGap(11, 11, 11))
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel10, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8, jLabel9});
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel10, jLabel11, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8, jLabel9});
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonMoveStart, buttonPark, buttonScan});
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonMotorPanel, buttonScannerPanel});
|
||||
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -315,48 +433,81 @@ public class WireScan extends Panel {
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3)
|
||||
.addComponent(textBpm1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(comboBpm1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel4)
|
||||
.addComponent(textBpm2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(comboBpm2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel4))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel5)
|
||||
.addComponent(comboBpm3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 95, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(comboBpm3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel5))
|
||||
.addGap(18, 18, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
|
||||
.addComponent(jLabel11)
|
||||
.addComponent(panelPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonScannerPanel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
|
||||
.addComponent(jLabel12)
|
||||
.addComponent(ledHomed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonMotorPanel)
|
||||
.addComponent(buttonHoming))
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
|
||||
.addComponent(jLabel10)
|
||||
.addComponent(panelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(18, 18, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonAbort)
|
||||
.addComponent(buttonScan)
|
||||
.addComponent(buttonMoveStart)))
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE))
|
||||
.addComponent(buttonMoveStart)
|
||||
.addComponent(buttonPark)))
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 416, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void comboWireScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboWireScanActionPerformed
|
||||
try {
|
||||
List<String> ret = (List<String>) ((Plugin)this).eval("get_wire_scans_bpms('" + comboWireScan.getSelectedItem().toString()+ "')", true);
|
||||
textBpm1.setText((ret==null) ? "" : ret.get(0));
|
||||
textBpm2.setText((ret==null) ? "" : ret.get(1));
|
||||
|
||||
comboSelection.setSelectedIndex(Epics.get(comboWireScan.getSelectedItem().toString() + ":WIRE_SP", Integer.class));
|
||||
spinnerVel.setValue(Epics.get(comboWireScan.getSelectedItem().toString() + ":SCAN_VELO_SP", Double.class));
|
||||
spinnerCycles.setValue(Epics.get(comboWireScan.getSelectedItem().toString() + ":NB_CYCL_SP", Integer.class));
|
||||
if (panelStatus.getDevice()!=null){
|
||||
panelStatus.getDevice().close();
|
||||
panelStatus.setDevice(null);
|
||||
}
|
||||
Device dev= (Device)eval("newScanInfoDevice(None, '" + comboWireScan.getSelectedItem().toString()+ "')", true);
|
||||
panelStatus.setDevice(dev);
|
||||
|
||||
} catch (Exception ex) {
|
||||
panelStatus.setDevice(null);
|
||||
if (panelPosition.getDevice()!=null){
|
||||
panelPosition.getDevice().close();
|
||||
panelPosition.setDevice(null);
|
||||
}
|
||||
ledHomed.setColor(Color.darkGray);
|
||||
homed = false;
|
||||
|
||||
if ( comboWireScan.getSelectedItem().toString().isEmpty()){
|
||||
for (JComboBox cb : bpmCombos){
|
||||
cb.setSelectedItem("");
|
||||
}
|
||||
} else {
|
||||
List<String> ret = (List<String>) ((Plugin)this).eval("get_wire_scans_bpms('" + comboWireScan.getSelectedItem().toString()+ "')", true);
|
||||
comboBpm1.setSelectedItem((ret==null) ? "" : ret.get(0));
|
||||
comboBpm2.setSelectedItem((ret==null) ? "" : ret.get(1));
|
||||
comboSelection.setSelectedIndex(Epics.get(comboWireScan.getSelectedItem().toString() + ":WIRE_SP", Integer.class));
|
||||
spinnerVel.setValue(Epics.get(comboWireScan.getSelectedItem().toString() + ":SCAN_VELO_SP", Double.class));
|
||||
spinnerCycles.setValue(Epics.get(comboWireScan.getSelectedItem().toString() + ":NB_CYCL_SP", Integer.class));
|
||||
Device dev= (Device)eval("newScanInfoDevice(None, '" + comboWireScan.getSelectedItem().toString()+ "')", true);
|
||||
panelStatus.setDevice(dev);
|
||||
|
||||
dev = new ChannelDouble (null, comboWireScan.getSelectedItem().toString() + ":ENC_1_BS", 3);
|
||||
dev.setMonitored(true);
|
||||
dev.initialize();
|
||||
panelPosition.setDevice(dev);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
comboWireScan.setSelectedItem("");
|
||||
for (JComboBox cb : bpmCombos){
|
||||
cb.setSelectedItem("");
|
||||
}
|
||||
}
|
||||
onStateChange(getState(), getState());
|
||||
}//GEN-LAST:event_comboWireScanActionPerformed
|
||||
|
||||
private void comboSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboSelectionActionPerformed
|
||||
@@ -377,7 +528,12 @@ public class WireScan extends Panel {
|
||||
parameters.add(spinnerEnd.getValue());
|
||||
parameters.add(spinnerCycles.getValue());
|
||||
parameters.add(spinnerVel.getValue());
|
||||
parameters.add(comboBpm3.getSelectedItem().toString().isEmpty() ? null: comboBpm3.getSelectedItem().toString());
|
||||
ArrayList bpms = new ArrayList();
|
||||
for (JComboBox cb : bpmCombos){
|
||||
if (!cb.getSelectedItem().toString().isEmpty()){
|
||||
bpms.add(cb.getSelectedItem().toString());
|
||||
}
|
||||
}
|
||||
getContext().addScanListener(scanListener);
|
||||
try {
|
||||
runAsync("Diagnostics/WireScan", parameters).handle((ret, ex) -> {
|
||||
@@ -385,7 +541,15 @@ public class WireScan extends Panel {
|
||||
getLogger().info("Exception executing scan: " + ex);
|
||||
showException((Exception) ex);
|
||||
} else {
|
||||
SwingUtils.showMessage(WireScan.this, "Success", "Data file: \n" + getContext().getDataManager().getLastOutput());
|
||||
//SwingUtils.showMessage(WireScan.this, "Success", "Data file: \n" + getContext().getDataManager().getLastOutput());
|
||||
JPanel pn = new JPanel(new BorderLayout());
|
||||
((BorderLayout) pn.getLayout()).setHgap(5);
|
||||
pn.add(new JLabel("Generated data file:"), BorderLayout.NORTH);
|
||||
JTextField tf = new JTextField(getContext().getDataManager().getLastOutput());
|
||||
tf.setPreferredSize(new Dimension(600, tf.getPreferredSize().height));
|
||||
tf.setEditable(false);
|
||||
pn.add(tf, BorderLayout.SOUTH);
|
||||
JOptionPane.showOptionDialog(WireScan.this, pn, "Success", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
@@ -410,15 +574,59 @@ public class WireScan extends Panel {
|
||||
}
|
||||
}//GEN-LAST:event_buttonMoveStartActionPerformed
|
||||
|
||||
private void buttonParkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonParkActionPerformed
|
||||
try {
|
||||
Epics.putq(comboWireScan.getSelectedItem().toString() + ":GARAGE_SEL.PROC", 1);
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonParkActionPerformed
|
||||
|
||||
String caqtdm = "caqtdm -noMsg -stylefile sfop.qss -attach";
|
||||
private void buttonMotorPanelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMotorPanelActionPerformed
|
||||
try {
|
||||
String cmd = caqtdm + " -macro 'P=" + comboWireScan.getSelectedItem() + ":,M=MOTOR_1' /sf/common/config/qt/motorx_all.ui";
|
||||
Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd.toString()});
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonMotorPanelActionPerformed
|
||||
|
||||
private void buttonScannerPanelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScannerPanelActionPerformed
|
||||
try {
|
||||
String cmd = caqtdm + " -macro 'DEVICE=" + comboWireScan.getSelectedItem() + "' /sf/op/config/qt/S_DI_WSC.ui";
|
||||
Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd.toString()});
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_buttonScannerPanelActionPerformed
|
||||
|
||||
private void buttonHomingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonHomingActionPerformed
|
||||
try {
|
||||
Epics.putq(comboWireScan.getSelectedItem().toString() + ":MOTOR_1_HOME.PROC", 1);
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonHomingActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonAbort;
|
||||
private javax.swing.JButton buttonHoming;
|
||||
private javax.swing.JButton buttonMotorPanel;
|
||||
private javax.swing.JButton buttonMoveStart;
|
||||
private javax.swing.JButton buttonPark;
|
||||
private javax.swing.JButton buttonScan;
|
||||
private javax.swing.JButton buttonScannerPanel;
|
||||
private javax.swing.JComboBox comboBpm1;
|
||||
private javax.swing.JComboBox comboBpm2;
|
||||
private javax.swing.JComboBox comboBpm3;
|
||||
private javax.swing.JComboBox comboSelection;
|
||||
private javax.swing.JComboBox comboWireScan;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel10;
|
||||
private javax.swing.JLabel jLabel11;
|
||||
private javax.swing.JLabel jLabel12;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
@@ -427,13 +635,13 @@ public class WireScan extends Panel {
|
||||
private javax.swing.JLabel jLabel7;
|
||||
private javax.swing.JLabel jLabel8;
|
||||
private javax.swing.JLabel jLabel9;
|
||||
private ch.psi.pshell.swing.Led ledHomed;
|
||||
private ch.psi.pshell.swing.DeviceValuePanel panelPosition;
|
||||
private ch.psi.pshell.swing.DeviceValuePanel panelStatus;
|
||||
private ch.psi.pshell.plot.LinePlotJFree plot;
|
||||
private javax.swing.JSpinner spinnerCycles;
|
||||
private javax.swing.JSpinner spinnerEnd;
|
||||
private javax.swing.JSpinner spinnerStart;
|
||||
private javax.swing.JSpinner spinnerVel;
|
||||
private javax.swing.JTextField textBpm1;
|
||||
private javax.swing.JTextField textBpm2;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user