02.2026
This commit is contained in:
@@ -2,15 +2,17 @@
|
||||
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.App;
|
||||
import ch.psi.pshell.app.Setup;
|
||||
import ch.psi.pshell.framework.Context;
|
||||
import ch.psi.pshell.plot.Plot;
|
||||
import ch.psi.pshell.swing.ChannelSelector;
|
||||
import ch.psi.pshell.ui.App;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.Chrono;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionResult;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionType;
|
||||
import ch.psi.pshell.framework.Panel;
|
||||
import ch.psi.pshell.utils.State;
|
||||
import ch.psi.pshell.utils.Chrono;
|
||||
import ch.psi.pshell.swing.SwingUtils;
|
||||
import ch.psi.pshell.swing.SwingUtils.OptionResult;
|
||||
import ch.psi.pshell.swing.SwingUtils.OptionType;
|
||||
import java.awt.Component;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
@@ -86,14 +88,14 @@ public class Correlation2 extends Panel {
|
||||
//DecimalFormat formatter = new DecimalFormat("0.##E0");
|
||||
void updateResults(){
|
||||
try{
|
||||
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr"))));
|
||||
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)Context.getSequencer().getInterpreterVariable("corr"))));
|
||||
} catch (Exception ex){
|
||||
textCorrelation.setText("");
|
||||
}
|
||||
|
||||
if (checkLinear.isSelected()){
|
||||
try{
|
||||
List pars = (List)getContext().getInterpreterVariable("pars_lin");
|
||||
List pars = (List)Context.getSequencer().getInterpreterVariable("pars_lin");
|
||||
//textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
|
||||
textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
|
||||
} catch (Exception ex){
|
||||
@@ -103,7 +105,7 @@ public class Correlation2 extends Panel {
|
||||
|
||||
if (checkQuadratic.isSelected()){
|
||||
try{
|
||||
List pars = (List)getContext().getInterpreterVariable("pars_quad");
|
||||
List pars = (List)Context.getSequencer().getInterpreterVariable("pars_quad");
|
||||
//textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
|
||||
textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
|
||||
//textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));
|
||||
@@ -112,11 +114,11 @@ public class Correlation2 extends Panel {
|
||||
textQuadratic.setText("");
|
||||
}
|
||||
try{
|
||||
String peak = (String)getContext().getInterpreterVariable("pos_peak");
|
||||
String peak = (String)Context.getSequencer().getInterpreterVariable("pos_peak");
|
||||
if (peak!=null){
|
||||
textPeak.setText(peak + " (max)");
|
||||
} else {
|
||||
peak = (String)getContext().getInterpreterVariable("neg_peak");
|
||||
peak = (String)Context.getSequencer().getInterpreterVariable("neg_peak");
|
||||
if (peak!=null){
|
||||
textPeak.setText(peak + " (min)");
|
||||
} else {
|
||||
@@ -449,15 +451,15 @@ public class Correlation2 extends Panel {
|
||||
if (isRunning()){
|
||||
//abort();
|
||||
//Stooping smootly so displayed variables get updated.
|
||||
getContext().setInterpreterVariable("stop_exec", true);
|
||||
Context.getSequencer().setInterpreterVariable("stop_exec", true);
|
||||
Chrono chrono = new Chrono();
|
||||
while (!chrono.isTimeout(500)){
|
||||
if (!Boolean.TRUE.equals(getContext().getInterpreterVariable("stop_exec"))){
|
||||
if (!Boolean.TRUE.equals(Context.getSequencer().getInterpreterVariable("stop_exec"))){
|
||||
break;
|
||||
}
|
||||
Thread.sleep(1);
|
||||
}
|
||||
if (Boolean.TRUE.equals(getContext().getInterpreterVariable("stop_exec"))){
|
||||
if (Boolean.TRUE.equals(Context.getSequencer().getInterpreterVariable("stop_exec"))){
|
||||
System.out.println("Timeout stopping script - aborting...");
|
||||
abort();
|
||||
}
|
||||
@@ -515,7 +517,7 @@ public class Correlation2 extends Panel {
|
||||
|
||||
private void buttonElogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonElogActionPerformed
|
||||
try{
|
||||
String snapshotFile = getContext().getSetup().expandPath("{context}/correlation_plot.png");
|
||||
String snapshotFile = Setup.expandPath("{context}/correlation_plot.png");
|
||||
plot.saveSnapshot(snapshotFile, "png");
|
||||
JPanel panel = new JPanel();
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
|
||||
Reference in New Issue
Block a user