This commit is contained in:
gac-x03da
2022-08-05 10:22:50 +02:00
parent 134b0e7674
commit 2721cf1b9a
4 changed files with 117 additions and 85 deletions

View File

@@ -354,7 +354,7 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonScientaSetup" pref="212" max="32767" attributes="0"/>
<Component id="buttonScientaSetup" pref="235" max="32767" attributes="0"/>
<Component id="checkImage" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="checkImageIntegration" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="checkSpectrum" alignment="0" min="-2" max="-2" attributes="0"/>
@@ -530,7 +530,7 @@
<Component id="buttonStart" max="32767" attributes="0"/>
<Component id="buttonAbort" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="10" max="32767" attributes="0"/>
<EmptySpace min="0" pref="11" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="labelAcqTime" linkSize="10" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelTotalTime" linkSize="10" alignment="0" min="-2" max="-2" attributes="0"/>

View File

@@ -36,7 +36,7 @@ public class PhotonEnergy extends ScriptProcessor {
setPersistedComponents(persistedComponents.toArray(new Component[0]));
startTimer(1000);
}
boolean running;
//boolean running;
//Overridable callbacks
@Override
@@ -71,7 +71,7 @@ public class PhotonEnergy extends ScriptProcessor {
ScanListener scanListener = new ScanListener() {
@Override
public void onScanStarted(Scan scan, String string) {
if (running) {
if (isRunning()) {
table.setRowSelectionInterval(0, 0);
SwingUtils.scrollToVisible(table, 0, 0);
}
@@ -79,7 +79,7 @@ public class PhotonEnergy extends ScriptProcessor {
@Override
public void onNewRecord(Scan scan, ScanRecord rec) {
if (running) {
if (isRunning()) {
int index = rec.getIndex() + 1;
if (index < table.getRowCount()) {
table.setRowSelectionInterval(index, index);
@@ -90,7 +90,7 @@ public class PhotonEnergy extends ScriptProcessor {
@Override
public void onScanEnded(Scan scan, Exception ex) {
if (running) {
if (isRunning()) {
table.clearSelection();
}
}
@@ -99,9 +99,9 @@ public class PhotonEnergy extends ScriptProcessor {
@Override
public void onStateChange(State state, State former) {
setEnabled(isEnabled());
if (!state.isProcessing()) {
running = false;
}
//if (!state.isProcessing()) {
// running = false;
//}
}
@Override
@@ -179,11 +179,13 @@ public class PhotonEnergy extends ScriptProcessor {
});
}
/*
@Override
public void execute() throws Exception {
super.execute();
running = true;
}
*/
@Override
public String getScript() {

View File

@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="buttonGroup1">
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@@ -333,13 +337,14 @@
<Component id="btSave" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="buttonInitialScan" linkSize="1" min="-2" max="-2" attributes="0"/>
<Component id="buttonStart" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="radioInitial" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="radioDetailed" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonDetailedScan" linkSize="1" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="checkCIS" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="32767" attributes="0"/>
<EmptySpace pref="139" max="32767" attributes="0"/>
<Component id="buttonSkip" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonAbort" linkSize="1" min="-2" max="-2" attributes="0"/>
@@ -355,14 +360,15 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonInitialScan" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonDetailedScan" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" max="-2" attributes="0"/>
<Component id="buttonSkip" alignment="3" max="-2" attributes="0"/>
<Component id="checkCIS" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="radioInitial" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="radioDetailed" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="rangeSelectionPanel" pref="0" max="32767" attributes="0"/>
<Component id="rangeSelectionPanel" pref="294" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="btLoad" alignment="1" min="-2" max="-2" attributes="0"/>
@@ -390,20 +396,12 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btSaveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonInitialScan">
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Initial Scan"/>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonInitialScanActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonDetailedScan">
<Properties>
<Property name="text" type="java.lang.String" value="Detailed Scan"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonDetailedScanActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="ch.psi.pshell.swing.RangeSelectionPanel" name="rangeSelectionPanel">
@@ -437,6 +435,23 @@
<Property name="text" type="java.lang.String" value="Constant Initial State"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="radioInitial">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Initial Scan"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="radioDetailed">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="Detailed"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@@ -17,6 +17,7 @@ import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.pshell.swing.ValueSelection;
import ch.psi.pshell.swing.ValueSelection.ValueSelectionListener;
import ch.psi.pshell.ui.ScriptProcessor;
import java.awt.Component;
import java.io.File;
import java.nio.file.Files;
@@ -24,7 +25,9 @@ import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JToggleButton;
@@ -37,7 +40,7 @@ import javax.swing.table.DefaultTableModel;
/**
*
*/
public class XPSSpectrum extends Panel {
public class XPSSpectrum extends ScriptProcessor {
boolean detailedScan;
boolean running;
@@ -244,10 +247,13 @@ public class XPSSpectrum extends Panel {
}
void updateButtons() {
buttonInitialScan.setEnabled(isEnabled());
buttonDetailedScan.setEnabled(isEnabled() && rangeSelectionPanel.getPlot().getSelectedRanges().length > 0);
buttonStart.setEnabled(isEnabled());
radioDetailed.setEnabled(isEnabled() && rangeSelectionPanel.getPlot().getSelectedRanges().length > 0);
if (!radioDetailed.isEnabled()){
radioInitial.setSelected(true);
}
btLoad.setEnabled(isEnabled());
btSave.setEnabled(buttonDetailedScan.isEnabled());
btSave.setEnabled(radioDetailed.isEnabled());
}
DeviceListener progressListener = new DeviceAdapter() {
@@ -300,7 +306,7 @@ public class XPSSpectrum extends Panel {
try{
int steps = 0;
RangeSelection[] r = rangeSelectionPanel.getRanges();
if ((buttonDetailedScan.isEnabled()) && (r.length > 0)) {
if ((radioDetailed.isEnabled()) && (r.length > 0)) {
for (int i = 0; i < r.length; i++) {
int iterations = (Integer) r[i].getVars()[2];
steps += iterations;
@@ -319,23 +325,46 @@ public class XPSSpectrum extends Panel {
getLogger().log(Level.FINE, null, ex);
}
}
@Override
public String getScript() {
return "XPSSpectrum";
}
void start() throws Context.ContextStateException {
@Override
public Map<String, Object> getArgs() {
if (radioInitial.isSelected()){
RangeSelection initialRange = new RangeSelection(valueLow.getValue(), valueHigh.getValue());
int iterations = (int) valueIterations.getValue();
initialRange.setVars(new Object[]{valueTime.getValue(), valueSize.getValue(), iterations, Double.NaN});
scanRanges = new RangeSelection[]{initialRange};
rangeSelectionPanel.clear(); //TODO: should be done in execute?
} else {
scanRanges = rangeSelectionPanel.getRanges();
}
detailedScan = !radioInitial.isSelected();
HashMap<String, Object> args = new HashMap<>();
args.put("DETAILED", !detailedScan);
args.put("ranges", scanRanges);
args.put("pass_energy", Integer.valueOf(comboPass.getSelectedItem().toString()));
args.put("save_scienta_image", checkSaveImage.isSelected());
args.put("ENDSCAN", checkEndScan.isSelected());
currentScanIndex = -1;
runAsync("XPSSpectrum", args);
//startTimer(500,10);
args.put("ENDSCAN", checkEndScan.isSelected());
return args;
}
@Override
public void execute() throws Exception {
currentScanIndex = -1;
super.execute();
running = true;
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
panelArguments = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
valueIterations = new ch.psi.pshell.swing.ValueSelection();
@@ -359,8 +388,7 @@ public class XPSSpectrum extends Panel {
jPanel2 = new javax.swing.JPanel();
btLoad = new javax.swing.JButton();
btSave = new javax.swing.JButton();
buttonInitialScan = new javax.swing.JButton();
buttonDetailedScan = new javax.swing.JButton();
buttonStart = new javax.swing.JButton();
rangeSelectionPanel = new ch.psi.pshell.swing.RangeSelectionPanel() {
protected void onSeriesChanged() {
updateButtons();
@@ -373,6 +401,8 @@ public class XPSSpectrum extends Panel {
buttonAbort = new javax.swing.JButton();
buttonSkip = new javax.swing.JButton();
checkCIS = new javax.swing.JCheckBox();
radioInitial = new javax.swing.JRadioButton();
radioDetailed = new javax.swing.JRadioButton();
panelArguments.setBorder(javax.swing.BorderFactory.createTitledBorder("Arguments"));
@@ -569,17 +599,10 @@ public class XPSSpectrum extends Panel {
}
});
buttonInitialScan.setText("Initial Scan");
buttonInitialScan.addActionListener(new java.awt.event.ActionListener() {
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonInitialScanActionPerformed(evt);
}
});
buttonDetailedScan.setText("Detailed Scan");
buttonDetailedScan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonDetailedScanActionPerformed(evt);
buttonStartActionPerformed(evt);
}
});
@@ -601,6 +624,13 @@ public class XPSSpectrum extends Panel {
checkCIS.setText("Constant Initial State");
buttonGroup1.add(radioInitial);
radioInitial.setSelected(true);
radioInitial.setText("Initial Scan");
buttonGroup1.add(radioDetailed);
radioDetailed.setText("Detailed");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
@@ -614,13 +644,14 @@ public class XPSSpectrum extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btSave))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(buttonInitialScan)
.addComponent(buttonStart)
.addGap(18, 18, 18)
.addComponent(radioInitial)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(radioDetailed)
.addGap(18, 18, 18)
.addComponent(buttonDetailedScan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(checkCIS)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 139, Short.MAX_VALUE)
.addComponent(buttonSkip)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonAbort))
@@ -628,20 +659,21 @@ public class XPSSpectrum extends Panel {
.addContainerGap())
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btLoad, btSave, buttonAbort, buttonDetailedScan, buttonInitialScan, buttonSkip});
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btLoad, btSave, buttonAbort, buttonSkip, buttonStart});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonInitialScan)
.addComponent(buttonDetailedScan)
.addComponent(buttonStart)
.addComponent(buttonAbort)
.addComponent(buttonSkip)
.addComponent(checkCIS))
.addComponent(checkCIS)
.addComponent(radioInitial)
.addComponent(radioDetailed))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rangeSelectionPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(rangeSelectionPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btLoad, javax.swing.GroupLayout.Alignment.TRAILING)
@@ -680,33 +712,14 @@ public class XPSSpectrum extends Panel {
}
}//GEN-LAST:event_buttonAbortActionPerformed
private void buttonInitialScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonInitialScanActionPerformed
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
rangeSelectionPanel.clear();
detailedScan = false;
RangeSelection initialRange = new RangeSelection(valueLow.getValue(), valueHigh.getValue());
int iterations = (int) valueIterations.getValue();
initialRange.setVars(new Object[]{valueTime.getValue(), valueSize.getValue(), iterations, Double.NaN});
scanRanges = new RangeSelection[]{initialRange};
start();
execute();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonInitialScanActionPerformed
private void buttonDetailedScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDetailedScanActionPerformed
try {
detailedScan = true;
scanRanges = rangeSelectionPanel.getRanges();
start();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonDetailedScanActionPerformed
}//GEN-LAST:event_buttonStartActionPerformed
private void btSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSaveActionPerformed
try {
@@ -814,10 +827,10 @@ public class XPSSpectrum extends Panel {
private javax.swing.JButton btLoad;
private javax.swing.JButton btSave;
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonDetailedScan;
private javax.swing.JButton buttonInitialScan;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton buttonScientaSetup;
private javax.swing.JButton buttonSkip;
private javax.swing.JButton buttonStart;
private javax.swing.JCheckBox checkCIS;
private javax.swing.JCheckBox checkEndScan;
private javax.swing.JCheckBox checkSaveImage;
@@ -833,6 +846,8 @@ public class XPSSpectrum extends Panel {
private javax.swing.JLabel labelAcqTime;
private javax.swing.JLabel labelTotalTime;
private javax.swing.JPanel panelArguments;
private javax.swing.JRadioButton radioDetailed;
private javax.swing.JRadioButton radioInitial;
private ch.psi.pshell.swing.RangeSelectionPanel rangeSelectionPanel;
private javax.swing.JLabel textTotalTime;
private ch.psi.pshell.swing.ValueSelection valueHigh;