258 lines
14 KiB
Java
258 lines
14 KiB
Java
/*
|
|
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
|
|
*/
|
|
|
|
import ch.psi.pshell.epics.AreaDetector;
|
|
import ch.psi.pshell.ui.Panel;
|
|
import ch.psi.utils.State;
|
|
import java.util.HashMap;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public class Omega extends Panel {
|
|
|
|
public Omega() {
|
|
initComponents();
|
|
}
|
|
|
|
//Overridable callbacks
|
|
@Override
|
|
public void onInitialize(int runCount) {
|
|
panelImageCounter.setDevice(((AreaDetector)getDevice("det")).getImageCounter());
|
|
}
|
|
|
|
@Override
|
|
public void onStateChange(State state, State former) {
|
|
buttonStart.setEnabled(state == State.Ready);
|
|
buttonAbort.setEnabled(state.isRunning());
|
|
}
|
|
|
|
@Override
|
|
public void onExecutedFile(String fileName, Object result) {
|
|
}
|
|
|
|
|
|
//Callback to perform update - in event thread
|
|
@Override
|
|
protected void doUpdate() {
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
jPanel1 = new javax.swing.JPanel();
|
|
jLabel5 = new javax.swing.JLabel();
|
|
textName = new javax.swing.JTextField();
|
|
spinnerStart = new javax.swing.JSpinner();
|
|
spinnerEnd = new javax.swing.JSpinner();
|
|
spinnerPasses = new javax.swing.JSpinner();
|
|
jLabel1 = new javax.swing.JLabel();
|
|
jLabel2 = new javax.swing.JLabel();
|
|
spinnerTime = new javax.swing.JSpinner();
|
|
jLabel6 = new javax.swing.JLabel();
|
|
jLabel3 = new javax.swing.JLabel();
|
|
spinnerStep = new javax.swing.JSpinner();
|
|
jLabel4 = new javax.swing.JLabel();
|
|
buttonStart = new javax.swing.JButton();
|
|
buttonAbort = new javax.swing.JButton();
|
|
panelImageCounter = new ch.psi.pshell.swing.DeviceValuePanel();
|
|
|
|
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
|
|
|
|
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
|
jLabel5.setText("Passes:");
|
|
|
|
textName.setText("Test");
|
|
|
|
spinnerStart.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d));
|
|
|
|
spinnerEnd.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d));
|
|
|
|
spinnerPasses.setModel(new javax.swing.SpinnerNumberModel(1, 1, 10, 1));
|
|
|
|
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
|
jLabel1.setText("Start Phi (deg):");
|
|
|
|
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
|
jLabel2.setText("End Phi (deg):");
|
|
|
|
spinnerTime.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.001d, 1000.0d, 1.0d));
|
|
|
|
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
|
jLabel6.setText("Name:");
|
|
|
|
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
|
jLabel3.setText("Step Size (deg):");
|
|
|
|
spinnerStep.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.001d, 100.0d, 1.0d));
|
|
|
|
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
|
jLabel4.setText("Step Time (s):");
|
|
|
|
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()
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
.addComponent(jLabel2)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(spinnerEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
.addComponent(jLabel3)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
.addComponent(jLabel4)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
.addComponent(jLabel5)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
.addComponent(jLabel6)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(textName, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
.addComponent(jLabel1)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
|
.addContainerGap())
|
|
);
|
|
|
|
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6});
|
|
|
|
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerEnd, spinnerPasses, spinnerStart, spinnerStep, spinnerTime});
|
|
|
|
jPanel1Layout.setVerticalGroup(
|
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
.addContainerGap()
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
|
.addComponent(jLabel6)
|
|
.addComponent(textName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jLabel1)
|
|
.addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jLabel2)
|
|
.addComponent(spinnerEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jLabel3)
|
|
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jLabel4)
|
|
.addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jLabel5)
|
|
.addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addContainerGap(94, Short.MAX_VALUE))
|
|
);
|
|
|
|
buttonStart.setText("Start");
|
|
buttonStart.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
buttonStartActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
buttonAbort.setText("Abort");
|
|
buttonAbort.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
buttonAbortActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
panelImageCounter.setBorder(javax.swing.BorderFactory.createTitledBorder("Image Counter"));
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
|
this.setLayout(layout);
|
|
layout.setHorizontalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addGap(42, 42, 42)
|
|
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addGap(39, 39, 39)
|
|
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addGap(77, 77, 77)
|
|
.addComponent(panelImageCounter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
|
.addContainerGap(153, Short.MAX_VALUE))
|
|
);
|
|
layout.setVerticalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74, Short.MAX_VALUE)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(buttonStart)
|
|
.addComponent(buttonAbort))
|
|
.addContainerGap(63, Short.MAX_VALUE))
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addContainerGap()
|
|
.addComponent(panelImageCounter, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
);
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
|
|
try {
|
|
this.abort();
|
|
} catch (Exception ex) {
|
|
this.showException(ex);
|
|
}
|
|
}//GEN-LAST:event_buttonAbortActionPerformed
|
|
|
|
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
|
|
try {
|
|
if ((Double)spinnerEnd.getValue() <= (Double)spinnerStart.getValue()){
|
|
throw new Exception ("Invalid range");
|
|
}
|
|
HashMap<String, Object> pars = new HashMap<>();
|
|
pars.put("startphi", spinnerStart.getValue());
|
|
pars.put("endphi", spinnerEnd.getValue());
|
|
pars.put("time_step", spinnerTime.getValue());
|
|
pars.put("step", spinnerStep.getValue());
|
|
pars.put("passes", spinnerPasses.getValue());
|
|
pars.put("fname", textName.getText());
|
|
this.runAsync("scans/Omega", pars);
|
|
} catch (Exception ex) {
|
|
this.showException(ex);
|
|
}
|
|
}//GEN-LAST:event_buttonStartActionPerformed
|
|
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JButton buttonAbort;
|
|
private javax.swing.JButton buttonStart;
|
|
private javax.swing.JLabel jLabel1;
|
|
private javax.swing.JLabel jLabel2;
|
|
private javax.swing.JLabel jLabel3;
|
|
private javax.swing.JLabel jLabel4;
|
|
private javax.swing.JLabel jLabel5;
|
|
private javax.swing.JLabel jLabel6;
|
|
private javax.swing.JPanel jPanel1;
|
|
private ch.psi.pshell.swing.DeviceValuePanel panelImageCounter;
|
|
private javax.swing.JSpinner spinnerEnd;
|
|
private javax.swing.JSpinner spinnerPasses;
|
|
private javax.swing.JSpinner spinnerStart;
|
|
private javax.swing.JSpinner spinnerStep;
|
|
private javax.swing.JSpinner spinnerTime;
|
|
private javax.swing.JTextField textName;
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|