Update scripts and plugins to 2.0

This commit is contained in:
2025-08-04 12:38:24 +02:00
parent b45d3b4202
commit b631d4c589
44 changed files with 347 additions and 350 deletions

View File

@@ -1,18 +1,21 @@
import ch.psi.pshell.core.Context;
import ch.psi.pshell.console.App;
import ch.psi.pshell.framework.Context;
import ch.psi.pshell.framework.Setup;
import ch.psi.pshell.imaging.Overlay;
import ch.psi.pshell.imaging.Overlays.Rect;
import ch.psi.pshell.imaging.Pen;
import ch.psi.pshell.imaging.Renderer;
import ch.psi.pshell.imaging.RendererListener;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.Arr;
import ch.psi.utils.IO;
import ch.psi.utils.Serializer;
import ch.psi.utils.State;
import ch.psi.utils.Str;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.imaging.DeviceRenderer;
import ch.psi.pshell.imaging.Renderer;
import ch.psi.pshell.sequencer.Interpreter;
import ch.psi.pshell.utils.Arr;
import ch.psi.pshell.utils.IO;
import ch.psi.pshell.utils.Serializer;
import ch.psi.pshell.utils.State;
import ch.psi.pshell.swing.SwingUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
@@ -71,10 +74,10 @@ public class DataAcquisition extends Panel {
static String DEFAULT_PATH = "{data}/{year}_{month}/{date}_{seq}%03d";
final String ABSORTION_SPECTRUM_PATH = Setup.getConfigPath() + "/AbsortionSpectrum";
final String ABSORTION_SPECTRUM_EXT = "abs";
final String ROIS_PATH = Setup.getConfigPath() + "/ROIs";
final String ROIS_EXT = "roi";
final Component[] parameterControls;
@@ -108,7 +111,7 @@ public class DataAcquisition extends Panel {
}
@Override
@Override
public void onDeleted(Renderer renderer, Overlay overlay){
if (rois.contains(overlay)) {
rois.remove(overlay);
updateRoiList();
@@ -367,7 +370,7 @@ public class DataAcquisition extends Panel {
rendererRoi.abortSelection();
}
void run2Images() throws Interpreter.InterpreterStateException {
HashMap args = new HashMap();
args.put("METHOD", comboImgMethod.getSelectedItem());
@@ -384,7 +387,7 @@ public class DataAcquisition extends Panel {
args.put("NUMBER_SCANS", (comboImgMethod.getSelectedItem() == ImgMethod.Take_Image.toString()) ? ((Integer)spinnerScans.getValue()) : 1 );
runAsync("templates/Eiger2Img", args).handle((ret, t) -> {
runAsync("templates/Eiger2Img", args).handle((ret, t) -> {
if ((t != null) && (!Context.isAborted())) {
showException((Exception) t);
}
return t;
@@ -414,7 +417,7 @@ public class DataAcquisition extends Panel {
return ranges;
}
void runAbsSpectrum() throws Interpreter.InterpreterStateException {
HashMap args = new HashMap();
args.put("SAVE_SPECTRUM", checkSpecSaveSpectrum.isSelected());
args.put("SAVE_IMAGES", checkSpecSaveImages.isSelected());
@@ -428,7 +431,7 @@ public class DataAcquisition extends Panel {
args.put("ROI", getRois());
runAsync("templates/EigerAbsSpec", args).handle((ret, t) -> {
runAsync("templates/EigerAbsSpec", args).handle((ret, t) -> {
if ((t != null) && (!Context.isAborted())) {
showException((Exception) t);
}
return t;
@@ -451,12 +454,12 @@ public class DataAcquisition extends Panel {
}
}
void enableNorm(boolean enabled) throws Interpreter.InterpreterStateException {
if (!enabled) {
removeNorm();
} else {
runAsync("devices/norm", null).handle((ret, t) -> {
runAsync("devices/norm", null).handle((ret, t) -> {
if ((t != null) && (!Context.isAborted())) {
showException((Exception) t);
}
JDialog dlg = App.getInstance().getDevicePanelManager().getPanelDialog("norm");
@@ -491,9 +494,9 @@ public class DataAcquisition extends Panel {
args.put("E2", e2);
args.put("TIME", (Double) spinnerTime.getValue());
args.put("DELAY", (Double) spinnerDelay.getValue());
args.put("DELAY", (Double) spinnerDelay.getValue());
String file = Setup.expandPath("ImageOTF");
args.put("FILE", file);
args.put("FILE", file);
String folder = Setup.expandPath("{year}_{month}/{date}");
args.put("FOLDER", folder);
args.put("ROI", getRois());
args.put("EXPOSURE", spinnerImgOTFExp.getValue());
@@ -540,7 +543,7 @@ public class DataAcquisition extends Panel {
radioAvDetector = new javax.swing.JRadioButton();
radioAvPshell = new javax.swing.JRadioButton();
panelRoi = new javax.swing.JPanel();
panelRoi = new javax.swing.JPanel();
rendererRoi = new ch.psi.pshell.imaging.DeviceRenderer();
jLabel26 = new javax.swing.JLabel();
buttonRoiAdd = new javax.swing.JButton();
buttonRoiRemove = new javax.swing.JButton();
@@ -1579,7 +1582,7 @@ public class DataAcquisition extends Panel {
private void buttonImgAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonImgAbortActionPerformed
try {
try {
Context.abort();
} catch (Exception ex) {
showException(ex);
}
@@ -1603,7 +1606,7 @@ public class DataAcquisition extends Panel {
private void buttonSpecAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSpecAbortActionPerformed
try {
try {
Context.abort();
} catch (Exception ex) {
showException(ex);
}
@@ -1630,7 +1633,7 @@ public class DataAcquisition extends Panel {
private void buttonSetNormActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetNormActionPerformed
try {
try {
JFileChooser chooser = new JFileChooser(Setup.expandPath(App.getInstance().getConfig().dataPath));
FileNameExtensionFilter filter = new FileNameExtensionFilter("Image File", "tif", "tiff");
chooser.setFileFilter(filter);
chooser.setFileHidingEnabled(true);
@@ -1664,7 +1667,7 @@ public class DataAcquisition extends Panel {
private void textSelectOutliersMaskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textSelectOutliersMaskActionPerformed
try {
try {
JFileChooser chooser = new JFileChooser(Setup.expandPath(App.getInstance().getConfig().dataPath));
FileNameExtensionFilter filter = new FileNameExtensionFilter("Image File", "tif", "tiff");
chooser.setFileFilter(filter);
chooser.setFileHidingEnabled(true);
@@ -1910,7 +1913,7 @@ public class DataAcquisition extends Panel {
private javax.swing.JPanel panelSpectrum;
private javax.swing.JRadioButton radioAvDetector;
private javax.swing.JRadioButton radioAvPshell;
private javax.swing.JRadioButton radioAvPshell;
private ch.psi.pshell.imaging.DeviceRenderer rendererRoi;
private javax.swing.JSpinner spinnerDelay;
private javax.swing.JSpinner spinnerE1;
private javax.swing.JSpinner spinnerE2;