From 4f1850787c9af8e9beaf9bf541fa52fbd5b310a1 Mon Sep 17 00:00:00 2001 From: sfop Date: Fri, 16 Dec 2016 08:33:18 +0100 Subject: [PATCH] Startup --- plugins/Cameras.java | 6 +++--- plugins/Correlation.java | 6 +++--- plugins/GunSolenoidAlignment.java | 4 ++-- plugins/LaserGunAlignment.java | 4 ++-- plugins/ScreenPanel.java | 18 +++++++++--------- script/local.py | 10 +++++----- script/test/bs.py | 21 ++++++++++++++++----- 7 files changed, 40 insertions(+), 29 deletions(-) diff --git a/plugins/Cameras.java b/plugins/Cameras.java index 69fde93..d3425c8 100644 --- a/plugins/Cameras.java +++ b/plugins/Cameras.java @@ -2,7 +2,7 @@ * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. */ -import ch.psi.pshell.core.Controller; +import ch.psi.pshell.core.Context; import java.io.File; import java.io.IOException; import java.nio.file.Paths; @@ -63,7 +63,7 @@ public class Cameras extends Panel { public Cameras() { initComponents(); - renderer.setPersistenceFile(Paths.get(getController().getSetup().getContextPath(), "Renderer_Cameras.bin")); + renderer.setPersistenceFile(Paths.get(getContext().getSetup().getContextPath(), "Renderer_Cameras.bin")); setPersistedComponents(new Component[]{checkCamtool}); comboCameras.setEnabled(false); if (App.hasArgument("poll")) { @@ -497,7 +497,7 @@ public class Cameras extends Panel { } double[] fitGaussianScript(int[] y, int[] x) { - ScriptManager sm = Controller.getInstance().getScriptManager(); + ScriptManager sm = Context.getInstance().getScriptManager(); ArrayProperties pY = ArrayProperties.get(y); sm.setVar("y", y); sm.setVar("x", x); diff --git a/plugins/Correlation.java b/plugins/Correlation.java index 77b45cc..7077732 100644 --- a/plugins/Correlation.java +++ b/plugins/Correlation.java @@ -66,14 +66,14 @@ public class Correlation extends Panel { //DecimalFormat formatter = new DecimalFormat("0.##E0"); void updateResults(){ try{ - textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getController().getInterpreterVariable("corr")))); + textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr")))); } catch (Exception ex){ textCorrelation.setText(""); } if (checkLinear.isSelected()){ try{ - List pars = (List)getController().getInterpreterVariable("pars_lin"); + List pars = (List)getContext().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){ @@ -83,7 +83,7 @@ public class Correlation extends Panel { if (checkQuadratic.isSelected()){ try{ - List pars = (List)getController().getInterpreterVariable("pars_quad"); + List pars = (List)getContext().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))); diff --git a/plugins/GunSolenoidAlignment.java b/plugins/GunSolenoidAlignment.java index 10dfccc..e74b916 100644 --- a/plugins/GunSolenoidAlignment.java +++ b/plugins/GunSolenoidAlignment.java @@ -52,7 +52,7 @@ public class GunSolenoidAlignment extends Panel { @Override public void onInitialize(int runCount) { progressBar.setValue(0); - getController().addScanListener(scanListener); + getContext().addScanListener(scanListener); centroidPlot.getAxis(Plot.AxisId.X).setLabel("Centroid Excursion"); } @@ -100,7 +100,7 @@ public class GunSolenoidAlignment extends Panel { //Add ELOG entry if (checkElog.isSelected()) { - String file = Paths.get(getController().getSetup().getContextPath(), "CentroidPlot.jpg").toString(); + String file = Paths.get(getContext().getSetup().getContextPath(), "CentroidPlot.jpg").toString(); try { Thread.sleep(250); //Some time to plot update centroidPlot.saveSnapshot(file , "jpg"); diff --git a/plugins/LaserGunAlignment.java b/plugins/LaserGunAlignment.java index 9e8a1eb..98d98af 100644 --- a/plugins/LaserGunAlignment.java +++ b/plugins/LaserGunAlignment.java @@ -52,7 +52,7 @@ public class LaserGunAlignment extends Panel { @Override public void onInitialize(int runCount) { progressBar.setValue(0); - getController().addScanListener(scanListener); + getContext().addScanListener(scanListener); centroidPlot.getAxis(Plot.AxisId.X).setLabel("Centroid Excursion"); } @@ -99,7 +99,7 @@ public class LaserGunAlignment extends Panel { hull.setData((double[]) Convert.toDouble(x), (double[]) Convert.toDouble(y)); //Add ELOG entry if (checkElog.isSelected()) { - String file = Paths.get(getController().getSetup().getContextPath(), "CentroidPlot.jpg").toString(); + String file = Paths.get(getContext().getSetup().getContextPath(), "CentroidPlot.jpg").toString(); try { Thread.sleep(250); //Some time to plot update centroidPlot.saveSnapshot(file , "jpg"); diff --git a/plugins/ScreenPanel.java b/plugins/ScreenPanel.java index 40f2429..d464d68 100644 --- a/plugins/ScreenPanel.java +++ b/plugins/ScreenPanel.java @@ -2,7 +2,7 @@ * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. */ -import ch.psi.pshell.core.Controller; +import ch.psi.pshell.core.Context; import java.io.File; import java.io.IOException; import java.nio.file.Paths; @@ -104,7 +104,7 @@ public class ScreenPanel extends Panel { public ScreenPanel() { initComponents(); - renderer.setPersistenceFile(Paths.get(getController().getSetup().getContextPath(), "Renderer_Cameras.bin")); + renderer.setPersistenceFile(Paths.get(getContext().getSetup().getContextPath(), "Renderer_Cameras.bin")); setPersistedComponents(new Component[]{buttonCamtool, buttonDirect}); comboCameras.setEnabled(false); if (App.hasArgument("poll")) { @@ -943,7 +943,7 @@ public class ScreenPanel extends Panel { } double[] fitGaussianScript(int[] y, int[] x) { - ScriptManager sm = Controller.getInstance().getScriptManager(); + ScriptManager sm = Context.getInstance().getScriptManager(); ArrayProperties pY = ArrayProperties.get(y); sm.setVar("y", y); sm.setVar("x", x); @@ -2052,21 +2052,21 @@ public class ScreenPanel extends Panel { private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed try { - String snapshotFile = getController().getSetup().expandPath("{images}/snapshot.png"); + String snapshotFile = getContext().getSetup().expandPath("{images}/snapshot.png"); renderer.saveSnapshot(snapshotFile, "png", true); - getController().setExecutionContext("snapshot", null, null, null, null, null, null, null); - getController().getDataManager().setDataset("/data", renderer.getData().getMatrix(), renderer.getData().isUnsigned()); - getController().getDataManager().closeOutput(); + getContext().setExecutionContext("snapshot", null, null, null, null, null, null, null); + getContext().getDataManager().setDataset("/data", renderer.getData().getMatrix(), renderer.getData().isUnsigned()); + getContext().getDataManager().closeOutput(); StringBuilder message = new StringBuilder(); message.append("Camera: ").append(cameraName).append(" ("). append((camera instanceof Camtool) ? "camtool" : "direct").append(")").append("\n"); - message.append("Data file: ").append(getController().getExecutionContext().getPath()).append("\n"); + message.append("Data file: ").append(getContext().getExecutionContext().getPath()).append("\n"); if ((fitOv != null) && (fitOv.length > 3)) { Overlays.Text text = (Overlays.Text) fitOv[3]; message.append(text.getText()).append("\n"); } elog("ScreenPanel Snapshot", message.toString(), new String[]{snapshotFile}); - SwingUtils.showMessage(getTopLevel(), "Success", "Generated data file:\n" + getController().getExecutionContext().getPath(), 5000); + SwingUtils.showMessage(getTopLevel(), "Success", "Generated data file:\n" + getContext().getExecutionContext().getPath(), 5000); } catch (Exception ex) { ex.printStackTrace(); diff --git a/script/local.py b/script/local.py index c1a3ed8..b541a75 100755 --- a/script/local.py +++ b/script/local.py @@ -131,7 +131,7 @@ def elog(title, message, attachments = [], author = None, category = "Info", dom Add entry to ELOG. """ if author is None: - author = "pshell" #controller.getUser().name + author = "pshell" #context.getUser().name typ = "pshell" entry = "" @@ -156,7 +156,7 @@ def elog(title, message, attachments = [], author = None, category = "Info", dom raise Exception(err) print out -def get_plot_snapshots(title = None, file_type = "png", temp_path = controller.setup.getContextPath()): +def get_plot_snapshots(title = None, file_type = "png", temp_path = context.setup.getContextPath()): """ Returns list with file names of plots snapshots from a plotting context. """ @@ -184,7 +184,7 @@ center_x.setPolling(100) center_y.setPolling(100) -if not controller.isLocalMode(): +if not context.isLocalMode(): try: run("camtool") add_device(CamTool("image_stats", prefix = "SINEG01-DSCR190:", latch = True, camera = "SINEG01-DSCR190", gauss = False), True) @@ -255,13 +255,13 @@ avy = create_averager(comy, 5, 0.001) #CAS -if controller.isServerEnabled(): +if context.isServerEnabled(): import ch.psi.pshell.epics.CAS as CAS #CAS.setServerPort(5062) class ServerUrl(ReadonlyRegisterBase): def doRead(self): - return controller.server.baseURL + return context.server.baseURL d = ServerUrl() d.initialize() diff --git a/script/test/bs.py b/script/test/bs.py index 435848f..1078646 100644 --- a/script/test/bs.py +++ b/script/test/bs.py @@ -10,14 +10,25 @@ st1 = Stream("st1", dispatcher) st1.addScalar("scpu", "SINDI01-RLLE-STA:SLAVE1-CPUTIMER", 10, 0) st1.addScalar("mcpu", "SINDI01-RLLE-STA:MASTER-CPUTIMER", 10, 0) - -st1.addWaveform("amp", "SINDI01-RCIR-PUP10:SIG-AMPLT", 10, 0, 2048) - +st1.addWaveform("amp", "SINDI01-RCIR-PUP10:SIG-AMPLT", 10, 0) st1.initialize() -st1.start(True) + +#st1.start(True) + + +class PseudoPositioner(Writable): + def write(self,pos): + print "Step = " + str(pos) +pseudo_motor = PseudoPositioner() + try: + #Dumps to file all pulse IDs bscan (st1, 10, title="bscan") - tscan (st1.getReadables(), 10,0.1, title="tscan") + + #When sampling the stream waits for next value in normal scans/ + #tscan (st1.getReadables(), 10,0.1) + + #lscan (pseudo_motor, [gsx,] + st1.getReadables(), 0, 10, 10, latency=0.1) finally: st1.close()