This commit is contained in:
98
plugins/LaserUEPanel.java
Normal file
98
plugins/LaserUEPanel.java
Normal file
@@ -0,0 +1,98 @@
|
||||
import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.swing.DevicePanel;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class LaserUEPanel extends DevicePanel {
|
||||
|
||||
public LaserUEPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDevice(Device device){
|
||||
super.setDevice(device);
|
||||
if (device!=null){
|
||||
historyChart.addDevice("Laser Distance", device);
|
||||
} else {
|
||||
for (Device d: historyChart.getDevices()){
|
||||
historyChart.removeDevice(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void execute(String statement, boolean showReturn){
|
||||
try {
|
||||
Context.getInstance().evalLineBackgroundAsync(statement).handle((ret, ex) -> {
|
||||
if (LaserUEPanel.this.isShowing()){
|
||||
if (ex != null){
|
||||
showException((Exception)ex);
|
||||
} else if (showReturn){
|
||||
if (ret == null){
|
||||
SwingUtils.showMessage(this, "Return", "No code detected", 20000);
|
||||
} else {
|
||||
SwingUtils.showMessage(this, "Return", "Detected code: " +ret, 20000);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
deviceStatePanel2 = new ch.psi.pshell.swing.DeviceStatePanel();
|
||||
try {
|
||||
historyChart = new ch.psi.pshell.swing.HistoryChart();
|
||||
} catch (java.lang.ClassNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (java.lang.InstantiationException e2) {
|
||||
e2.printStackTrace();
|
||||
} catch (java.lang.IllegalAccessException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
deviceValuePanel1 = new ch.psi.pshell.swing.DeviceValuePanel();
|
||||
|
||||
deviceStatePanel2.setDeviceName("ue");
|
||||
|
||||
deviceValuePanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Value"));
|
||||
deviceValuePanel1.setDeviceName("ue");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(historyChart, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(deviceStatePanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(historyChart, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(deviceStatePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private ch.psi.pshell.swing.DeviceStatePanel deviceStatePanel2;
|
||||
private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel1;
|
||||
private ch.psi.pshell.swing.HistoryChart historyChart;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
Reference in New Issue
Block a user