This commit is contained in:
281
plugins/Pointing.java
Normal file
281
plugins/Pointing.java
Normal file
@@ -0,0 +1,281 @@
|
||||
|
||||
import ch.psi.pshell.ui.CamServerViewer;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.State;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Pointing extends Panel {
|
||||
|
||||
public Pointing() {
|
||||
initComponents();
|
||||
try {
|
||||
viewer.initialize(CamServerViewer.SourceSelecionMode.Single);
|
||||
viewer.setCameraServerUrl("sf-daqsync-01:8888");
|
||||
viewer.setPipelineServerUrl("sf-daqsync-01:8889");
|
||||
viewer.setStartupStream(TOOL_TIP_TEXT_KEY);
|
||||
viewer.setToolbarVisible(false);
|
||||
viewer.setZoom(2.0);
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
try {
|
||||
viewer.setStream("SAROP21-PPRM094_sp");
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
this.startTimer(1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
buttonStart.setEnabled(state.isReady());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTimer() {
|
||||
try{
|
||||
Object img = viewer.getStreamDevice().take().getValue("image");
|
||||
this.setGlobalVar("plugin_img", img);
|
||||
Object ret = eval("get_saturated_pixels(plugin_img)", true);
|
||||
textSaturated.setText((ret==null) ? "" : ret.toString());
|
||||
} catch (Exception ex){
|
||||
textSaturated.setText("");
|
||||
this.getLogger().severe(ex.getMessage());
|
||||
}
|
||||
|
||||
if (ckOffsetCheck.isSelected()){
|
||||
try{
|
||||
Object ret = this.run("pointing/check_offset", null, true);
|
||||
List offset = (List) ret;
|
||||
Double offX = (Double) offset.get(0);
|
||||
Double offY = (Double) offset.get(1);
|
||||
textOffX.setText(String.format("%1.3f",offX));
|
||||
textOffY.setText(String.format("%1.3f",offY));
|
||||
} catch (Exception ex){
|
||||
textOffX.setText("");
|
||||
textOffY.setText("");
|
||||
//showException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoaded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUnloaded() {
|
||||
|
||||
}
|
||||
|
||||
//Invoked by 'update()' to update components in the event thread
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
viewer = new ch.psi.pshell.ui.CamServerViewer();
|
||||
processVariablePanel1 = new ch.psi.pshell.swing.ProcessVariablePanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
textSaturated = new javax.swing.JTextField();
|
||||
buttonStart = new javax.swing.JButton();
|
||||
buttonRefOffAp = new javax.swing.JButton();
|
||||
buttonEnd = new javax.swing.JButton();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
textOffX = new javax.swing.JTextField();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
textOffY = new javax.swing.JTextField();
|
||||
ckOffsetCheck = new javax.swing.JCheckBox();
|
||||
|
||||
processVariablePanel1.setDeviceName("attenuator");
|
||||
processVariablePanel1.setShowLimitButtons(false);
|
||||
processVariablePanel1.setShowSlider(false);
|
||||
processVariablePanel1.setShowStop(false);
|
||||
processVariablePanel1.setStepIncrement(0.01);
|
||||
processVariablePanel1.setStepSize(0.01);
|
||||
|
||||
jLabel1.setText("Saturated Pixels:");
|
||||
|
||||
textSaturated.setEditable(false);
|
||||
textSaturated.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
|
||||
buttonStart.setText("Start");
|
||||
buttonStart.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonStartActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonRefOffAp.setText("Reference Offset Aperture");
|
||||
buttonRefOffAp.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonRefOffApActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonEnd.setText("End");
|
||||
buttonEnd.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonEndActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel2.setText("Off X:");
|
||||
|
||||
textOffX.setEditable(false);
|
||||
textOffX.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
|
||||
jLabel3.setText("Off Y:");
|
||||
|
||||
textOffY.setEditable(false);
|
||||
textOffY.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
|
||||
ckOffsetCheck.setText("Enable Offset Check");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(viewer, javax.swing.GroupLayout.PREFERRED_SIZE, 469, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(processVariablePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(75, 75, 75)
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textSaturated, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 181, Short.MAX_VALUE))))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(130, 130, 130)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(buttonRefOffAp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonEnd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(ckOffsetCheck)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel3)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textOffY))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textOffX, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)))))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(165, 165, 165)
|
||||
.addComponent(buttonStart)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonEnd, buttonRefOffAp, buttonStart});
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textOffX, textOffY, textSaturated});
|
||||
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(viewer, javax.swing.GroupLayout.PREFERRED_SIZE, 716, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(86, 86, 86)
|
||||
.addComponent(buttonStart)
|
||||
.addGap(73, 73, 73)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(textSaturated, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(processVariablePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(97, 97, 97)
|
||||
.addComponent(buttonRefOffAp)
|
||||
.addGap(74, 74, 74)
|
||||
.addComponent(ckOffsetCheck)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(textOffX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(3, 3, 3)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3)
|
||||
.addComponent(textOffY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonEnd)))
|
||||
.addContainerGap(106, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
|
||||
try{
|
||||
runAsync("pointing/start").handle((ret,ex)->{
|
||||
return ret;
|
||||
});
|
||||
} catch (Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonStartActionPerformed
|
||||
|
||||
private void buttonRefOffApActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRefOffApActionPerformed
|
||||
try{
|
||||
runAsync("pointing/reference_offset").handle((ret,ex)->{
|
||||
return ret;
|
||||
});
|
||||
} catch (Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonRefOffApActionPerformed
|
||||
|
||||
private void buttonEndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEndActionPerformed
|
||||
try{
|
||||
runAsync("pointing/end").handle((ret,ex)->{
|
||||
return ret;
|
||||
});
|
||||
} catch (Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonEndActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonEnd;
|
||||
private javax.swing.JButton buttonRefOffAp;
|
||||
private javax.swing.JButton buttonStart;
|
||||
private javax.swing.JCheckBox ckOffsetCheck;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel1;
|
||||
private javax.swing.JTextField textOffX;
|
||||
private javax.swing.JTextField textOffY;
|
||||
private javax.swing.JTextField textSaturated;
|
||||
private ch.psi.pshell.ui.CamServerViewer viewer;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
Reference in New Issue
Block a user