diff --git a/config/devices.properties b/config/devices.properties index f1290d2..d2c76e5 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -1,6 +1,6 @@ i0=ch.psi.pshell.epics.ChannelDouble|X07DB-KEI10:READOUT|Read||true capture=ch.psi.pshell.epics.ChannelInteger|NAPP-SCIENTA:HDF1:Capture|||true -energy=ch.psi.pshell.epics.Positioner|X07DB-OP-MONO:ENERGY X07DB-OP-MONO:ERBK|||true +$energy=ch.psi.pshell.epics.Positioner|X07DB-OP-MONO:ENERGY X07DB-OP-MONO:ERBK|||true scienta=Scienta|NAPP-SCIENTA|||true spectrum=ch.psi.pshell.imaging.CameraSource|scienta|||true AcquisitionMode=ch.psi.pshell.epics.ChannelString|NAPP-SCIENTA:cam1:ACQ_MODE_RBV||| @@ -11,5 +11,5 @@ PassEnergy=ch.psi.pshell.epics.ChannelString|NAPP-SCIENTA:cam1:PASS_ENERGY_RBV|| ElementSet=ch.psi.pshell.epics.ChannelString|NAPP-SCIENTA:cam1:ELEMENT_SET_RBV||| StepSize=ch.psi.pshell.epics.ChannelDouble|NAPP-SCIENTA:cam1:STEP_SIZE_RBV||| NumIterations=ch.psi.pshell.epics.ChannelDouble|NAPP-SCIENTA:cam1:NumExposures_RBV||| -EntranceSlit=ch.psi.pshell.epics.ChannelDouble|X07DB-OP-SH1:TR1||| -ExitSlit=ch.psi.pshell.epics.ChannelDouble|X07DB-OP-SH2:TR1||| +$EntranceSlit=ch.psi.pshell.epics.ChannelDouble|X07DB-OP-SH1:TR1||| +$ExitSlit=ch.psi.pshell.epics.ChannelDouble|X07DB-OP-SH2:TR1||| diff --git a/config/preferences.json b/config/preferences.json index eca334b..37b09b4 100644 --- a/config/preferences.json +++ b/config/preferences.json @@ -52,10 +52,11 @@ "noVariableEvaluationPropagation" : false, "processingScripts" : [ ], "asyncViewersUpdate" : false, + "asyncHistoryPlotsUpdate" : false, "scanPlotDisabled" : false, "scanTableDisabled" : false, "cachedDataPanel" : false, - "dataExtensions" : "", + "dataExtensions" : "ens", "dataSubFiles" : "", "hideFileName" : false, "showEmergencyStop" : false, diff --git a/config/variables.properties b/config/variables.properties index 6c33120..7b38302 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Thu Dec 15 00:41:53 CET 2022 -LastRunDate=221215 -FileSequentialNumber=73 -DaySequentialNumber=2 +#Wed Jan 11 10:35:51 CET 2023 +LastRunDate=230111 +FileSequentialNumber=99 +DaySequentialNumber=6 diff --git a/plugins/EnergyScan.form b/plugins/EnergyScan.form index 7886cd9..ce2be2e 100644 --- a/plugins/EnergyScan.form +++ b/plugins/EnergyScan.form @@ -1,293 +1,342 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
- - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - -
-
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + +
+
diff --git a/plugins/EnergyScan.java b/plugins/EnergyScan.java index e244864..acd24b9 100644 --- a/plugins/EnergyScan.java +++ b/plugins/EnergyScan.java @@ -1,7 +1,6 @@ - -import ch.psi.pshell.core.JsonSerializer; import ch.psi.pshell.epics.Positioner; -import ch.psi.pshell.ui.PanelProcessor; +import ch.psi.pshell.ui.ScriptProcessor; +import ch.psi.utils.EncoderJson; import ch.psi.utils.IO; import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; @@ -12,6 +11,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; @@ -21,7 +21,7 @@ import javax.swing.table.DefaultTableModel; /** * */ -public class EnergyScan extends PanelProcessor { +public class EnergyScan extends ScriptProcessor { final DefaultTableModel model; Positioner energy; @@ -38,6 +38,11 @@ public class EnergyScan extends PanelProcessor { return "Energy Scan"; } + @Override + public boolean canSave() { + return true; + } + @Override public boolean createMenuNew() { return true; @@ -71,9 +76,10 @@ public class EnergyScan extends PanelProcessor { @Override public void onStateChange(State state, State former) { - buttonStart.setEnabled(state == State.Ready); - buttonAbort.setEnabled(state.isProcessing()); + buttonStart.setEnabled(state == State.Ready); + buttonAbort.setEnabled((state == State.Busy) && isRunning()); buttonScienta.setEnabled(state.isInitialized()); + buttonAddToQueue.setEnabled(buttonStart.isEnabled()); updateSeq(); } @@ -104,9 +110,11 @@ public class EnergyScan extends PanelProcessor { Double stop = (Double) model.getValueAt(i, 1); Double step = (Double) model.getValueAt(i, 2); if (Double.isNaN(start) || Double.isNaN(stop) || Double.isNaN(step) - || (start >= stop) || (step < 0) + || (step < 0) || (start < energy.getMinValue()) - || (stop > energy.getMaxValue())) { + || (stop > energy.getMaxValue()) + || (start > energy.getMaxValue()) + || (stop < energy.getMinValue())) { throw new IllegalArgumentException(); } } @@ -118,11 +126,66 @@ public class EnergyScan extends PanelProcessor { } @Override - public void execute() throws Exception { - checkValues(); - String lastOutput = getContext().getDataManager().getLastOutput(); + public void saveAs(String fileName) throws IOException { + currentFile = new File(fileName); + ArrayList data = new ArrayList(); + data.add(new Object[][]{new Object[]{textName.getText()}}); + data.add(model.getDataVector()); + data.add(spinnerPasses.getValue()); + String json = EncoderJson.encode(data, true); + Files.write(currentFile.toPath(), json.getBytes()); + } - HashMap args = new HashMap(); + @Override + public void open(String fileName) throws IOException { + if (fileName==null){ + currentFile = null; + textName.setText(""); + model.setRowCount(0); + spinnerPasses.setValue(1); + } else { + Path path = Paths.get(fileName); + String json = new String(Files.readAllBytes(path)); + currentFile = path.toFile(); + Object[][][] vector = (Object[][][]) EncoderJson.decode(json, Object[][][].class); + textName.setText(String.valueOf(vector[0][0][0])); + model.setDataVector(vector[1], SwingUtils.getTableColumnNames(table)); + spinnerPasses.setValue((vector.length>2) ? (Integer)vector[2][0][0] : 1); + } + } + + String lastOutput; + + @Override + protected void onStartingExecution(Map args){ + getLogger().warning(this.getFileName()); + lastOutput = getContext().getDataManager().getLastOutput(); + } + + @Override + protected void onFinishedExecution(Map args, Object ret, Throwable t){ + if (checkAutoSaveArgs.isSelected()) { + //Save scan attributes + String output = getContext().getDataManager().getLastOutput(); + if ((output != null) && !output.isEmpty() && !output.equals(lastOutput)) { + try { + saveAs(output + "." + FILE_EXTENSION); + } catch (IOException e) { + Logger.getLogger(EnergyScan.class.getName()).log(Level.WARNING, null, e); + } + } + } + } + + @Override + public String getScript() { + return "templates/EnergyScan"; + } + + @Override + public Map getArgs() { + HashMap args = new HashMap<>(); + checkValues(); ArrayList regions = new ArrayList(); for (int i = 0; i < model.getRowCount(); i++) { ArrayList region = new ArrayList(); @@ -133,51 +196,11 @@ public class EnergyScan extends PanelProcessor { } args.put("FILE", null); args.put("NAME", getScanName()); - args.put("REGIONS", regions); - this.runAsync("templates/EnergyScan", args).handle((ret, ex) -> { - if (ex != null) { - } - if (checkAutoSaveArgs.isSelected()) { - //Save scan attributes - String output = getContext().getDataManager().getLastOutput(); - if ((output != null) && !output.isEmpty() && !output.equals(lastOutput)) { - try { - saveAs(output + "." + FILE_EXTENSION); - } catch (IOException e) { - Logger.getLogger(EnergyScan.class.getName()).log(Level.WARNING, null, e); - } - } - } - return ret; - }); + args.put("REGIONS", regions); + args.put("PASSES", spinnerPasses.getValue()); + return args; } - - @Override - public void saveAs(String fileName) throws IOException { - currentFile = new File(fileName); - ArrayList data = new ArrayList(); - data.add(new Object[][]{new Object[]{textName.getText()}}); - data.add(model.getDataVector()); - String json = JsonSerializer.encode(data, true); - Files.write(currentFile.toPath(), json.getBytes()); - } - - @Override - public void open(String fileName) throws IOException { - if (fileName==null){ - currentFile = null; - textName.setText(""); - model.setRowCount(0); - } else { - Path path = Paths.get(fileName); - String json = new String(Files.readAllBytes(path)); - currentFile = path.toFile(); - Object[][][] vector = (Object[][][]) JsonSerializer.decode(json, Object[][][].class); - textName.setText(String.valueOf(vector[0][0][0])); - model.setDataVector(vector[1], SwingUtils.getTableColumnNames(table)); - } - } - + @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -198,6 +221,10 @@ public class EnergyScan extends PanelProcessor { jLabel1 = new javax.swing.JLabel(); buttonOpen = new javax.swing.JButton(); buttonSave = new javax.swing.JButton(); + buttonAddToQueue = new javax.swing.JButton(); + jLabel3 = new javax.swing.JLabel(); + spinnerPasses = new javax.swing.JSpinner(); + buttonClear = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); textFileId = new javax.swing.JTextField(); buttonResetId = new javax.swing.JButton(); @@ -285,7 +312,7 @@ public class EnergyScan extends PanelProcessor { jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonAdd) @@ -309,6 +336,24 @@ public class EnergyScan extends PanelProcessor { } }); + buttonAddToQueue.setText("Add To Queue"); + buttonAddToQueue.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonAddToQueueActionPerformed(evt); + } + }); + + jLabel3.setText("Passes:"); + + spinnerPasses.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100, 1)); + + buttonClear.setText("Clear"); + buttonClear.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonClearActionPerformed(evt); + } + }); + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( @@ -316,17 +361,31 @@ public class EnergyScan extends PanelProcessor { .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(jLabel1) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textName) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonClear) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonOpen) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonSave))) + .addContainerGap()) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textName) - .addGap(18, 18, 18) - .addComponent(buttonOpen) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonSave))) - .addContainerGap()) + .addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonAddToQueue) + .addGap(26, 26, 26)))) ); + + jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonClear, buttonOpen, buttonSave}); + jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() @@ -335,10 +394,16 @@ public class EnergyScan extends PanelProcessor { .addComponent(textName) .addComponent(buttonOpen) .addComponent(buttonSave) - .addComponent(jLabel1)) + .addComponent(jLabel1) + .addComponent(buttonClear)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(12, 12, 12)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonAddToQueue) + .addComponent(jLabel3) + .addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) ); jLabel2.setText("File ID:"); @@ -362,11 +427,11 @@ public class EnergyScan extends PanelProcessor { .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addGap(0, 0, Short.MAX_VALUE) + .addGap(0, 9, Short.MAX_VALUE) .addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(33, 33, 33) .addComponent(buttonAbort) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(19, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() @@ -401,7 +466,7 @@ public class EnergyScan extends PanelProcessor { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonScienta) .addComponent(buttonResetId)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 32, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonStart) .addComponent(buttonAbort)) @@ -497,9 +562,27 @@ public class EnergyScan extends PanelProcessor { } }//GEN-LAST:event_buttonResetIdActionPerformed + private void buttonAddToQueueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAddToQueueActionPerformed + try { + queue(); //TODO: Data/file + } catch (Exception ex) { + showException( ex); + } + }//GEN-LAST:event_buttonAddToQueueActionPerformed + + private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed + try { + open(null); + } catch (Exception ex) { + showException( ex); + } + }//GEN-LAST:event_buttonClearActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonAbort; private javax.swing.JButton buttonAdd; + private javax.swing.JButton buttonAddToQueue; + private javax.swing.JButton buttonClear; private javax.swing.JButton buttonDelete; private javax.swing.JButton buttonOpen; private javax.swing.JButton buttonResetId; @@ -510,10 +593,12 @@ public class EnergyScan extends PanelProcessor { private javax.swing.JEditorPane jEditorPane1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JSpinner spinnerPasses; private javax.swing.JTable table; private javax.swing.JTextField textFileId; private javax.swing.JTextField textName; diff --git a/plugins/TimeResolved.form b/plugins/TimeResolved.form index a6f19ad..659a5a6 100644 --- a/plugins/TimeResolved.form +++ b/plugins/TimeResolved.form @@ -147,6 +147,11 @@ + + + + + @@ -164,7 +169,9 @@ - + + + @@ -205,6 +212,14 @@ + + + + + + + + diff --git a/plugins/TimeResolved.java b/plugins/TimeResolved.java index afcec4f..b3164df 100644 --- a/plugins/TimeResolved.java +++ b/plugins/TimeResolved.java @@ -1,7 +1,7 @@ -import ch.psi.pshell.core.JsonSerializer; import ch.psi.pshell.scan.Scan; -import ch.psi.pshell.ui.PanelProcessor; +import ch.psi.pshell.ui.ScriptProcessor; +import ch.psi.utils.EncoderJson; import ch.psi.utils.IO; import ch.psi.utils.State; import java.io.File; @@ -11,18 +11,17 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; -import java.util.concurrent.CompletableFuture; +import java.util.Map; import java.util.logging.Level; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; /** * */ -public class TimeResolved extends PanelProcessor { +public class TimeResolved extends ScriptProcessor { File currentFile; public static final String FILE_EXTENSION = "tmr"; - CompletableFuture taskFuture; public TimeResolved() { initComponents(); @@ -33,6 +32,11 @@ public class TimeResolved extends PanelProcessor { return "Time Resolved"; } + @Override + public boolean canSave() { + return true; + } + @Override public boolean createMenuNew() { return true; @@ -67,15 +71,16 @@ public class TimeResolved extends PanelProcessor { @Override public void onStateChange(State state, State former) { buttonStart.setEnabled(state == State.Ready); - buttonAbort.setEnabled(state.isProcessing()); + buttonAbort.setEnabled((state == State.Busy) && isRunning()); buttonScienta.setEnabled(state.isInitialized()); + buttonAddToQueue.setEnabled(buttonStart.isEnabled()); updateSeq(); } @Override public void onTimer() { try{ - if (taskFuture!=null){ + if (isRunning()){ Scan scan = getContext().getExecutionPars().getCurrentScan(); if (scan!=null){ int index = scan.getRecordIndex(); @@ -112,29 +117,26 @@ public class TimeResolved extends PanelProcessor { } @Override - public void execute() throws Exception { - String lastOutput = getContext().getDataManager().getLastOutput(); + public String getScript() { + return "templates/TimeResolved"; + } - HashMap args = new HashMap(); + @Override + public Map getArgs() { + HashMap args = new HashMap<>(); args.put("FILE", null); args.put("NAME", getScanName()); args.put("SCANS", spinnerScans.getValue()); - taskFuture = runAsync("templates/TimeResolved", args); - taskFuture.handle((ret, ex) -> { - if (ex != null) { - } - taskFuture = null; - return ret; - }); + return args; } - + @Override public void saveAs(String fileName) throws IOException { currentFile = new File(fileName); ArrayList data = new ArrayList(); data.add(textName.getText()); data.add(spinnerScans.getValue()); - String json = JsonSerializer.encode(data, true); + String json = EncoderJson.encode(data, true); Files.write(currentFile.toPath(), json.getBytes()); } @@ -148,7 +150,7 @@ public class TimeResolved extends PanelProcessor { Path path = Paths.get(fileName); String json = new String(Files.readAllBytes(path)); currentFile = path.toFile(); - Object[] vector = (Object[]) JsonSerializer.decode(json, Object[].class); + Object[] vector = (Object[]) EncoderJson.decode(json, Object[].class); textName.setText(String.valueOf(vector[0])); spinnerScans.setValue(vector[1]); } @@ -170,6 +172,7 @@ public class TimeResolved extends PanelProcessor { textName = new javax.swing.JTextField(); buttonOpen = new javax.swing.JButton(); buttonSave = new javax.swing.JButton(); + buttonAddToQueue = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); textFileId = new javax.swing.JTextField(); buttonResetId = new javax.swing.JButton(); @@ -221,6 +224,13 @@ public class TimeResolved extends PanelProcessor { } }); + buttonAddToQueue.setText("Add To Queue"); + buttonAddToQueue.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonAddToQueueActionPerformed(evt); + } + }); + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( @@ -241,6 +251,10 @@ public class TimeResolved extends PanelProcessor { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonSave))) .addGap(14, 14, 14)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonAddToQueue) + .addContainerGap()) ); jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel3}); @@ -258,7 +272,9 @@ public class TimeResolved extends PanelProcessor { .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(spinnerScans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(100, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE) + .addComponent(buttonAddToQueue) + .addContainerGap()) ); jLabel2.setText("File ID:"); @@ -404,8 +420,17 @@ public class TimeResolved extends PanelProcessor { } }//GEN-LAST:event_buttonSaveActionPerformed + private void buttonAddToQueueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAddToQueueActionPerformed + try { + queue(); //TODO: Data/file + } catch (Exception ex) { + showException( ex); + } + }//GEN-LAST:event_buttonAddToQueueActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonAbort; + private javax.swing.JButton buttonAddToQueue; private javax.swing.JButton buttonOpen; private javax.swing.JButton buttonResetId; private javax.swing.JButton buttonSave; diff --git a/script/templates/EnergyScan.py b/script/templates/EnergyScan.py index 203be50..042d192 100644 --- a/script/templates/EnergyScan.py +++ b/script/templates/EnergyScan.py @@ -1,6 +1,7 @@ if get_exec_pars().debug: print "Setting debug parameters" REGIONS = [[523.0, 527.0, 2.0], [527.0, 535.0, 4.0], [535.0, 558.0, 2.0]] + PASSES = 1 NAME = None FILE = None @@ -10,9 +11,11 @@ if FILE: with open(FILE) as json_file: cfg = json.load(json_file) NAME , REGIONS= cfg[0][0][0], cfg[1] + PASSES = 1 if len(cfg<3) else cfg[2] print "FILE: ", FILE print "NAME: ", NAME print "REGIONS: ", REGIONS +print "PASSES: ", PASSES IOC_AUTO_SAVE = False DUMMY_TRIGGER = True @@ -34,7 +37,7 @@ if IOC_AUTO_SAVE: capture.write(1) try: - rscan(energy, sensors, REGIONS, latency = 0.0, before_read=before_read, after_read=after_readout, name = NAME) + rscan(energy, sensors, REGIONS, latency = 0.0, passes=PASSES, split=True, before_read=before_read, after_read=after_readout, name = NAME) finally: if IOC_AUTO_SAVE: capture.write(0)