Startup
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import ch.psi.pshell.device.Motor;
|
||||
import ch.psi.pshell.device.Positionable;
|
||||
import ch.psi.pshell.imaging.Overlay;
|
||||
import ch.psi.pshell.imaging.Overlays;
|
||||
@@ -59,6 +60,11 @@ public class Microscope extends Panel {
|
||||
button90 = new javax.swing.JButton();
|
||||
button180 = new javax.swing.JButton();
|
||||
button270 = new javax.swing.JButton();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
buttonLeft = new javax.swing.JButton();
|
||||
buttonRight = new javax.swing.JButton();
|
||||
buttonUp = new javax.swing.JButton();
|
||||
buttonDown = new javax.swing.JButton();
|
||||
|
||||
renderer.setAutoscrolls(true);
|
||||
renderer.setDeviceName("mic-high");
|
||||
@@ -142,35 +148,104 @@ public class Microscope extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
buttonLeft.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
|
||||
buttonLeft.setText("<");
|
||||
buttonLeft.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonLeftActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonRight.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
|
||||
buttonRight.setText(">");
|
||||
buttonRight.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonRightActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonUp.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
|
||||
buttonUp.setText("^");
|
||||
buttonUp.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonUpActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonDown.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
|
||||
buttonDown.setText("v");
|
||||
buttonDown.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonDownActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap(96, Short.MAX_VALUE)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(buttonLeft)
|
||||
.addGap(42, 42, 42)
|
||||
.addComponent(buttonRight))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(44, 44, 44)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(buttonDown)
|
||||
.addComponent(buttonUp))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(104, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap(20, Short.MAX_VALUE)
|
||||
.addComponent(buttonUp)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonRight)
|
||||
.addComponent(buttonLeft))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonDown)
|
||||
.addContainerGap(48, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(123, 123, 123)
|
||||
.addComponent(buttonDefineBeam))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motorPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(processVariablePanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(processVariablePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(123, 123, 123)
|
||||
.addComponent(buttonDefineBeam))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(motorPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(processVariablePanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(processVariablePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(checkHighDef))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(button0)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(button90)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(button180)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(button270)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(checkHighDef))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(button0)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(button90)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(button180)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(button270)))
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@@ -197,7 +272,9 @@ public class Microscope extends Panel {
|
||||
.addComponent(button90)
|
||||
.addComponent(button180)
|
||||
.addComponent(button270))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 158, Short.MAX_VALUE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(checkHighDef)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonDefineBeam)
|
||||
@@ -284,13 +361,63 @@ public class Microscope extends Panel {
|
||||
}
|
||||
}//GEN-LAST:event_button270ActionPerformed
|
||||
|
||||
double step = 0.01;
|
||||
private void buttonLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLeftActionPerformed
|
||||
try{
|
||||
((ch.psi.pshell.epics.Positionable)getDevice("x")).moveRelAsync(-step);
|
||||
} catch (Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonLeftActionPerformed
|
||||
|
||||
private void buttonRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRightActionPerformed
|
||||
try{
|
||||
((ch.psi.pshell.epics.Positionable)getDevice("x")).moveRelAsync(step);
|
||||
} catch (Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonRightActionPerformed
|
||||
|
||||
private void buttonUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpActionPerformed
|
||||
try{
|
||||
doVerticalStep(step);
|
||||
} catch (Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonUpActionPerformed
|
||||
|
||||
private void buttonDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDownActionPerformed
|
||||
try{
|
||||
doVerticalStep(-step);
|
||||
} catch (Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_buttonDownActionPerformed
|
||||
|
||||
public void doVerticalStep(double offset) throws Exception
|
||||
{
|
||||
|
||||
double omega = Math.toRadians((Double) ((Positionable)getDevice("omega")).getPosition());
|
||||
double y = -offset * Math.sin(omega);
|
||||
double z = offset * Math.cos(omega);
|
||||
((Motor)getDevice("cy")).moveRelAsync(y);
|
||||
((Motor)getDevice("cz")).moveRelAsync(z);
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton button0;
|
||||
private javax.swing.JButton button180;
|
||||
private javax.swing.JButton button270;
|
||||
private javax.swing.JButton button90;
|
||||
private javax.swing.JButton buttonDefineBeam;
|
||||
private javax.swing.JButton buttonDown;
|
||||
private javax.swing.JButton buttonLeft;
|
||||
private javax.swing.JButton buttonRight;
|
||||
private javax.swing.JButton buttonUp;
|
||||
private javax.swing.JCheckBox checkHighDef;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private ch.psi.pshell.swing.MotorPanel motorPanel1;
|
||||
private ch.psi.pshell.swing.MotorPanel motorPanel2;
|
||||
private ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel1;
|
||||
|
||||
Reference in New Issue
Block a user