From b631d4c5894f5c9b1cc85deaabfe3013e32c24ca Mon Sep 17 00:00:00 2001 From: gobbo_a Date: Mon, 4 Aug 2025 12:38:24 +0200 Subject: [PATCH] Update scripts and plugins to 2.0 --- config/config.properties | 129 +++++++++--------- config/settings.properties | 50 +++---- plugins/Align_TranslationFilter.java | 4 +- plugins/Beamline.form | 4 +- plugins/Beamline.java | 17 +-- plugins/BeamlineInit.java | 4 +- plugins/Cooling.java | 6 +- plugins/DataAcquisition.form | 2 +- plugins/DataAcquisition.java | 57 ++++---- plugins/DelayScan.java | 17 +-- plugins/DelayScanBase.form | 74 +++++----- plugins/DelayScanBase.java | 10 +- plugins/Eiger.form | 2 +- plugins/Eiger.java | 8 +- plugins/EnergyScan.java | 12 +- plugins/EnergyScanBase.java | 9 +- plugins/EnergyScan_TBT.java | 12 +- plugins/Imaging.form | 2 +- plugins/Imaging.java | 17 +-- plugins/Initialization.java | 5 +- plugins/OTFScanBase.java | 9 +- plugins/Settings.java | 71 +++++----- plugins/ShiftsIO.java | 4 +- plugins/Test.java | 11 +- plugins/TestLuka.java | 4 +- plugins/XPEEM_Settings.java | 17 +-- .../Pos-PEEMCAM-Scan/TestVscan.py | 2 +- .../Armin/Manipulator_Control/TestVscan_AK.py | 2 +- script/Users/PEEM/Armin/PEEM_slit.py | 4 +- .../Users/PEEM/Armin/TestUserScript_Armin.py | 2 +- script/devices/eiger.py | 9 +- script/imaging/shifts.py | 6 +- script/local.py | 31 ++--- script/old_scripts/localXtreme.py | 18 +-- script/templates/Eiger2Img.py | 8 +- .../templates/Eiger2Img_Hannes_valve_close.py | 18 +-- script/templates/Eiger2Img_Original.py | 18 +-- script/templates/EigerAbsSpec.py | 4 +- script/templates/EnergyScan_img.py | 2 +- script/test/BenchGrab.py | 2 +- script/test/Simu2Img.py | 8 +- script/test/SimuAbsSpec.py | 2 +- script/test/TestVscan.py | 2 +- script/utils.py | 2 +- 44 files changed, 347 insertions(+), 350 deletions(-) diff --git a/config/config.properties b/config/config.properties index f23ff1b..2493554 100755 --- a/config/config.properties +++ b/config/config.properties @@ -1,67 +1,74 @@ -#Thu Jul 31 10:11:47 CEST 2025 +#Thu Jul 31 10:58:50 CEST 2025 autoSaveScanData=true -simulation=false -xscanCrlogicChannel=null -dataScanSaveOutput=false -userAuthenticator= -dataScanSaveScript=false -notifiedTasks=EigerAbsSpec|Eiger2Img -parallelInitialization=true -fdaSerialization=true -dataTransferPath=~/Data1 -scanStreamingPort=-1 -xscanAppendSuffix=true -saveConsoleSessionFiles=false -devicePoolFile={config}/devices.properties -hostName=null -disableEmbeddedAttributes=false -serverPort=8080 -versionTrackingEnabled=true -dataPath={data}/{year}_{month}/{date}/{date}_{seq}%04d_{name} -serverEnabled=false -depthDimension=0 -logLevel=Fine -dataLayout=table -disableDataFileLogs=false -dataScanSaveTimestamps=false -sessionHandling=On -deviceUpdateStrategyFile={config}/update.properties -terminalEnabled=false -notificationLevel=Completion -terminalPort=3579 -dataTransferUser= -xscanContinuousUpdate=false -versionTrackingLogin={context}/pshell_user -noBytecodeFiles=false -versionTrackingRemote=https\://gitea.psi.ch/pshell_config/x11ma.git -dataScanLazyTableCreation=false -pythonHome= -xscanMoveTimeout=600 -imageSourcesFile={config}/imaging.properties commandExecutionEvents=true -logDaysToLive=7 -xscanCrlogicSimulated=false -logLevelConsole=Off -filePermissionsConfig=Public -scanStreamerPort=-1 -dataScanSaveSetpoints=false -versionTrackingManual=true -dataTransferMode=Off -userManagement=true -instanceName=SIM -dataServerPort=-1 -hideServerMessages=false -dataScanReleaseRecords=false -dataScanPreserveTypes=false +createSessionFiles=false +dataDepthDimension=0 +dataFormat=tiff +dataLayout=table +dataPath={data}/{year}_{month}/{date}/{date}_{seq}%04d_{name} +dataScanAutoSave=true dataScanFlushRecords=true -logPath={logs}/{date}_{time} +dataScanLazyTableCreation=false +dataScanPreserveTypes=false +dataScanReleaseRecords=false +dataScanSaveLogs=true +dataScanSaveOutput=false +dataScanSaveScript=false +dataScanSaveSetpoints=false +dataScanSaveTimestamps=false +dataScanStreamerPort=-1 +dataServerPort=-1 +dataTransferMode=Off +dataTransferPath=~/Data1 +dataTransferUser= +depthDimension=0 +devicePoolFile={config}/devices.properties +deviceUpdateStrategyFile={config}/update.properties +disableDataFileLogs=false +disableEmbeddedAttributes=false +fdaSerialization=true +filePermissionsConfig=Public +filePermissionsData=Default filePermissionsLogs=Public filePermissionsScripts=Public -xscanCrlogicPrefix=null -tasksFile={config}/tasks.properties -filePermissionsData=Default -xscanCrlogicAbortable=true -createSessionFiles=false -dataProvider=tiff -xscanCrlogicIoc=null +hideServerMessages=false +hostName=null +imageSourcesFile={config}/imaging.properties +instanceName=SIM +logDaysToLive=7 +logLevel=Fine +logLevelConsole=Off +logPath={logs}/{date}_{time} +noBytecodeFiles=false +notificationLevel=Completion +notificationTasks=EigerAbsSpec|Eiger2Img +notifiedTasks= +parallelInitialization=true +pythonHome= +pythonNoBytecodeFiles=false saveCommandStatistics=false +saveConsoleSessionFiles=false +scanStreamerPort=-1 +serverCommandsHidden=false +serverEnabled=false +serverHostName=null +serverPort=8080 +sessionHandling=On +simulation=false +tasksFile={config}/tasks.properties +terminalEnabled=false +terminalPort=3579 +userAuthenticator= +userManagement=true +versionTrackingEnabled=true +versionTrackingLogin={context}/pshell_user +versionTrackingManual=true +versionTrackingRemote=https\://gitea.psi.ch/pshell_config/x11ma.git +xscanAppendSuffix=true +xscanContinuousUpdate=false +xscanCrlogicAbortable=true +xscanCrlogicChannel=null +xscanCrlogicIoc=null +xscanCrlogicPrefix=null +xscanCrlogicSimulated=false +xscanMoveTimeout=600 diff --git a/config/settings.properties b/config/settings.properties index df438a3..66b4552 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,29 +1,29 @@ -#Thu Jul 31 09:47:37 CEST 2025 -RSYNC_USER= -OUTLIERS_THRESHOLD=1000000000 -AUTO_SWITCH_VALVE=false -NORM_FILE=/sls/X11MA/data/e20816/Data1/2023_06/20230615/654 -DRY_RUN=true -POL_ID_2=Circ_Minus -OFFSET_ID_2=-2.0 -ID=PGM_ID2 -proposal=proposal -ENERGY=565 -proposer=proposer -image_shift_angle=1.0963912950426833 -POS_H_DIR=POS -RSYNC_HOST= -sample=sample -RSYNC_PATH= -AUTO_SWITCH_BEAMLINE=false -pgroup=pgroup -POS_V_DIR=POS -AUTO_SWITCH_SHUTTER=true +#Mon Aug 04 12:37:53 CEST 2025 ALPHA_ID_2=0.0 -TILT_H_DIR=POS -RSYNC_DEL=true -image_shift_scale=3.296579966879864 +AUTO_SWITCH_BEAMLINE=false +AUTO_SWITCH_SHUTTER=true +AUTO_SWITCH_VALVE=false AVERAGING_DETECTOR=true +DRY_RUN=true +ENERGY=565 FdaBrowser=false -authors=author1|author2 HARMONIC_ID_2=1 +ID=PGM_ID2 +NORM_FILE=/sls/X11MA/data/e20816/Data1/2023_06/20230615/654 +OFFSET_ID_2=-2.0 +OUTLIERS_THRESHOLD=1000000000 +POL_ID_2=Circ_Minus +POS_H_DIR=POS +POS_V_DIR=POS +RSYNC_DEL=true +RSYNC_HOST= +RSYNC_PATH= +RSYNC_USER= +TILT_H_DIR=POS +authors=author1|author2 +image_shift_angle=1.0963912950426833 +image_shift_scale=3.296579966879864 +pgroup=pgroup +proposal=proposal +proposer=proposer +sample=sample diff --git a/plugins/Align_TranslationFilter.java b/plugins/Align_TranslationFilter.java index 416c0cb..06254a7 100644 --- a/plugins/Align_TranslationFilter.java +++ b/plugins/Align_TranslationFilter.java @@ -9,8 +9,8 @@ import ij.io.SaveDialog; import java.util.ArrayList; import java.io.IOException; import java.io.File; -import jmatio.types.*; -import jmatio.io.*; +import com.jmatio.types.*; //jmatio.types.*; +import com.jmatio.io.*; //jmatio.io.*; import ij.gui.GenericDialog; import ij.IJ; import ij.Prefs; diff --git a/plugins/Beamline.form b/plugins/Beamline.form index 2b4c614..9e044d1 100755 --- a/plugins/Beamline.form +++ b/plugins/Beamline.form @@ -42,7 +42,7 @@ - + @@ -635,7 +635,7 @@ - + diff --git a/plugins/Beamline.java b/plugins/Beamline.java index 7fe8a33..08982e6 100755 --- a/plugins/Beamline.java +++ b/plugins/Beamline.java @@ -1,10 +1,11 @@ -import ch.psi.pshell.core.Context; +import ch.psi.pshell.framework.Context; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.sequencer.Interpreter; import ch.psi.pshell.swing.DeviceValuePanel; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.Arr; -import ch.psi.utils.State; -import ch.psi.utils.Str; -import ch.psi.utils.swing.SwingUtils; +import ch.psi.pshell.utils.Arr; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.utils.Str; +import ch.psi.pshell.swing.SwingUtils; import java.awt.Component; import java.awt.Font; import java.io.IOException; @@ -197,13 +198,13 @@ public class Beamline extends Panel { args.put("CFF", spinnerCff.getValue()); } - void applyBeamline() throws Context.ContextStateException { + void applyBeamline() throws Interpreter.InterpreterStateException { HashMap args = new HashMap(); setBeamlineArgs(args); runAsync("templates/SetupBeamline", args).handle((ret, t) -> { - if ((t != null) && (!getContext().isAborted())) { + if ((t != null) && (!Context.isAborted())) { showException((Exception) t); } return t; diff --git a/plugins/BeamlineInit.java b/plugins/BeamlineInit.java index 0178116..4b91211 100644 --- a/plugins/BeamlineInit.java +++ b/plugins/BeamlineInit.java @@ -1,6 +1,6 @@ -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.utils.State; import javax.swing.JButton; /** diff --git a/plugins/Cooling.java b/plugins/Cooling.java index 01f537a..5525e0c 100644 --- a/plugins/Cooling.java +++ b/plugins/Cooling.java @@ -2,9 +2,9 @@ import ch.psi.pshell.epics.GenericChannel; import ch.psi.pshell.swing.DevicePanel; import ch.psi.pshell.swing.RegisterPanel; -import ch.psi.pshell.ui.Panel; -import ch.psi.pshell.ui.StripChart; -import ch.psi.utils.State; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.stripchart.StripChart; +import ch.psi.pshell.utils.State; import java.io.File; import java.io.IOException; import java.util.logging.Level; diff --git a/plugins/DataAcquisition.form b/plugins/DataAcquisition.form index 6517f17..703131a 100755 --- a/plugins/DataAcquisition.form +++ b/plugins/DataAcquisition.form @@ -385,7 +385,7 @@ - + diff --git a/plugins/DataAcquisition.java b/plugins/DataAcquisition.java index 29edbc4..e71aa02 100644 --- a/plugins/DataAcquisition.java +++ b/plugins/DataAcquisition.java @@ -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.utils.swing.SwingUtils; +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 = getContext().getSetup().getConfigPath() + "/AbsortionSpectrum"; + final String ABSORTION_SPECTRUM_PATH = Setup.getConfigPath() + "/AbsortionSpectrum"; final String ABSORTION_SPECTRUM_EXT = "abs"; - final String ROIS_PATH = getContext().getSetup().getConfigPath() + "/ROIs"; + 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 - public void onDeleted(Renderer renderer, Overlay overlay) { + 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 Context.ContextStateException { + 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) -> { - if ((t != null) && (!getContext().isAborted())) { + if ((t != null) && (!Context.isAborted())) { showException((Exception) t); } return t; @@ -414,7 +417,7 @@ public class DataAcquisition extends Panel { return ranges; } - void runAbsSpectrum() throws Context.ContextStateException { + 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) -> { - if ((t != null) && (!getContext().isAborted())) { + if ((t != null) && (!Context.isAborted())) { showException((Exception) t); } return t; @@ -451,12 +454,12 @@ public class DataAcquisition extends Panel { } } - void enableNorm(boolean enabled) throws Context.ContextStateException { + void enableNorm(boolean enabled) throws Interpreter.InterpreterStateException { if (!enabled) { removeNorm(); } else { runAsync("devices/norm", null).handle((ret, t) -> { - if ((t != null) && (!getContext().isAborted())) { + 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()); - String file = getContext().getSetup().expandPath("ImageOTF"); + String file = Setup.expandPath("ImageOTF"); args.put("FILE", file); - String folder = getContext().getSetup().expandPath("{year}_{month}/{date}"); + 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(); - rendererRoi = new ch.psi.pshell.imaging.Renderer(); + 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 { - getContext().abort(); + 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 { - getContext().abort(); + 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 { - JFileChooser chooser = new JFileChooser(getContext().getSetup().expandPath(getContext().getConfig().dataPath)); + 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 { - JFileChooser chooser = new JFileChooser(getContext().getSetup().expandPath(getContext().getConfig().dataPath)); + 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 ch.psi.pshell.imaging.Renderer rendererRoi; + private ch.psi.pshell.imaging.DeviceRenderer rendererRoi; private javax.swing.JSpinner spinnerDelay; private javax.swing.JSpinner spinnerE1; private javax.swing.JSpinner spinnerE2; diff --git a/plugins/DelayScan.java b/plugins/DelayScan.java index 277beb8..19095a4 100755 --- a/plugins/DelayScan.java +++ b/plugins/DelayScan.java @@ -8,19 +8,12 @@ import java.nio.file.Paths; import java.util.HashMap; import java.util.logging.Level; import javax.swing.JLabel; -import ch.psi.utils.State; -import ch.psi.utils.swing.Editor.EditorDialog; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.Editor.EditorDialog; import ch.psi.pshell.plot.LinePlotBase; import ch.psi.pshell.plot.LinePlotSeries; -import ch.psi.pshell.plot.Plot; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.swing.DsvEditor; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.File; -import java.nio.file.Files; -import java.util.logging.Logger; -import javax.swing.DefaultComboBoxModel; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.framework.Setup; /** * @@ -55,7 +48,7 @@ public class DelayScan extends Panel { } Path getConfigFile() { - return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties"); + return Paths.get(Setup.getConfigPath(), "energy_scan.properties"); } LinePlotBase scanPlot; diff --git a/plugins/DelayScanBase.form b/plugins/DelayScanBase.form index 84fb992..953b397 100755 --- a/plugins/DelayScanBase.form +++ b/plugins/DelayScanBase.form @@ -69,49 +69,53 @@ - - - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + - - - - - - - - - - - - + + + + + - - - - - diff --git a/plugins/DelayScanBase.java b/plugins/DelayScanBase.java index 599c367..bf81321 100755 --- a/plugins/DelayScanBase.java +++ b/plugins/DelayScanBase.java @@ -8,12 +8,12 @@ import java.nio.file.Paths; import java.util.HashMap; import java.util.logging.Level; import javax.swing.JLabel; -import ch.psi.utils.State; -import ch.psi.utils.swing.Editor.EditorDialog; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.Editor.EditorDialog; import ch.psi.pshell.plot.LinePlotBase; import ch.psi.pshell.plot.LinePlotSeries; -import ch.psi.pshell.ui.Panel; -import java.util.logging.Logger; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.framework.Setup; /** @@ -49,7 +49,7 @@ public class DelayScanBase extends Panel { } Path getConfigFile() { - return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties"); + return Paths.get(Setup.getConfigPath(), "energy_scan.properties"); } LinePlotBase scanPlot; diff --git a/plugins/Eiger.form b/plugins/Eiger.form index 4f6d041..9f199e4 100755 --- a/plugins/Eiger.form +++ b/plugins/Eiger.form @@ -172,7 +172,7 @@ - + diff --git a/plugins/Eiger.java b/plugins/Eiger.java index 227c89c..7dc1d2f 100755 --- a/plugins/Eiger.java +++ b/plugins/Eiger.java @@ -1,8 +1,8 @@ import ch.psi.pshell.epics.ChannelDouble; import ch.psi.pshell.epics.ChannelInteger; import ch.psi.pshell.imaging.ColormapSource; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.utils.State; import java.io.IOException; import java.util.logging.Level; import java.util.concurrent.TimeUnit; @@ -113,7 +113,7 @@ public class Eiger extends Panel { // //GEN-BEGIN:initComponents private void initComponents() { - renderer = new ch.psi.pshell.imaging.Renderer(); + renderer = new ch.psi.pshell.imaging.DeviceRenderer(); jLabel1 = new javax.swing.JLabel(); comboDepth = new javax.swing.JComboBox<>(); jLabel2 = new javax.swing.JLabel(); @@ -612,7 +612,7 @@ public class Eiger extends Panel { private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; - private ch.psi.pshell.imaging.Renderer renderer; + private ch.psi.pshell.imaging.DeviceRenderer renderer; private javax.swing.JSpinner spinnerExposure; private javax.swing.JSpinner spinnerMax; private javax.swing.JSpinner spinnerMin; diff --git a/plugins/EnergyScan.java b/plugins/EnergyScan.java index 799d45b..39131ec 100755 --- a/plugins/EnergyScan.java +++ b/plugins/EnergyScan.java @@ -8,18 +8,18 @@ import java.nio.file.Paths; import java.util.HashMap; import java.util.logging.Level; import javax.swing.JLabel; -import ch.psi.utils.State; -import ch.psi.utils.swing.Editor.EditorDialog; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.Editor.EditorDialog; import ch.psi.pshell.plot.LinePlotBase; import ch.psi.pshell.plot.LinePlotSeries; import ch.psi.pshell.plot.Plot; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.swing.DsvEditor; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.framework.Setup; +import ch.psi.pshell.swing.DsvEditor; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.nio.file.Files; -import java.util.logging.Logger; import javax.swing.DefaultComboBoxModel; /** @@ -61,7 +61,7 @@ public class EnergyScan extends Panel { } Path getConfigFile() { - return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties"); + return Paths.get(Setup.getConfigPath(), "energy_scan.properties"); } LinePlotBase scanPlot; diff --git a/plugins/EnergyScanBase.java b/plugins/EnergyScanBase.java index 3b41308..49c8463 100755 --- a/plugins/EnergyScanBase.java +++ b/plugins/EnergyScanBase.java @@ -8,12 +8,13 @@ import java.nio.file.Paths; import java.util.HashMap; import java.util.logging.Level; import javax.swing.JLabel; -import ch.psi.utils.State; -import ch.psi.utils.swing.Editor.EditorDialog; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.Editor.EditorDialog; import ch.psi.pshell.plot.LinePlotBase; import ch.psi.pshell.plot.LinePlotSeries; import ch.psi.pshell.plot.Plot; -import ch.psi.pshell.ui.Panel; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.framework.Setup; import java.util.logging.Logger; /** @@ -54,7 +55,7 @@ public class EnergyScanBase extends Panel { } Path getConfigFile() { - return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties"); + return Paths.get(Setup.getConfigPath(), "energy_scan.properties"); } LinePlotBase scanPlot; diff --git a/plugins/EnergyScan_TBT.java b/plugins/EnergyScan_TBT.java index 3ef05e0..cba0ad2 100755 --- a/plugins/EnergyScan_TBT.java +++ b/plugins/EnergyScan_TBT.java @@ -8,18 +8,18 @@ import java.nio.file.Paths; import java.util.HashMap; import java.util.logging.Level; import javax.swing.JLabel; -import ch.psi.utils.State; -import ch.psi.utils.swing.Editor.EditorDialog; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.Editor.EditorDialog; import ch.psi.pshell.plot.LinePlotBase; import ch.psi.pshell.plot.LinePlotSeries; import ch.psi.pshell.plot.Plot; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.swing.DsvEditor; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.framework.Setup; +import ch.psi.pshell.swing.DsvEditor; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.nio.file.Files; -import java.util.logging.Logger; import javax.swing.DefaultComboBoxModel; /** @@ -61,7 +61,7 @@ public class EnergyScan_TBT extends Panel { } Path getConfigFile() { - return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties"); + return Paths.get(Setup.getConfigPath(), "energy_scan.properties"); } LinePlotBase scanPlot; diff --git a/plugins/Imaging.form b/plugins/Imaging.form index e9d7584..b151e02 100644 --- a/plugins/Imaging.form +++ b/plugins/Imaging.form @@ -60,7 +60,7 @@ - + diff --git a/plugins/Imaging.java b/plugins/Imaging.java index 75c542a..be657c7 100644 --- a/plugins/Imaging.java +++ b/plugins/Imaging.java @@ -1,10 +1,11 @@ -import ch.psi.pshell.core.Context; +import ch.psi.pshell.framework.Context; import ch.psi.pshell.imaging.Overlay; import ch.psi.pshell.imaging.Overlays.Rect; -import ch.psi.pshell.imaging.Renderer; +import ch.psi.pshell.imaging.DeviceRenderer; import ch.psi.pshell.imaging.RendererListener; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.imaging.Renderer; +import ch.psi.pshell.utils.State; import java.awt.Rectangle; import java.util.HashMap; @@ -135,7 +136,7 @@ public class Imaging extends Panel { private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); - renderer = new ch.psi.pshell.imaging.Renderer(); + renderer = new ch.psi.pshell.imaging.DeviceRenderer(); jPanel4 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); buttonStartAutoIntensity = new javax.swing.JButton(); @@ -712,7 +713,7 @@ public class Imaging extends Panel { ", exposure=" + (Double.isNaN(exposure) ? "None" : exposure) + ")"; this.evalAsync(cmd).handle((ret, t) -> { - if ((t != null) && (!getContext().isAborted())) { + if ((t != null) && (!Context.isAborted())) { showException((Exception) t); } return t; @@ -807,7 +808,7 @@ public class Imaging extends Panel { ", exposure=" + (Double.isNaN(exposure) ? "None" : exposure) + ")"; this.evalAsync(cmd).handle((ret, t) -> { - if ((t != null) && (!getContext().isAborted())) { + if ((t != null) && (!Context.isAborted())) { showException((Exception) t); } return t; @@ -868,7 +869,7 @@ public class Imaging extends Panel { private javax.swing.JRadioButton radioObjective; private javax.swing.JRadioButton radioStigA; private javax.swing.JRadioButton radioStigB; - private ch.psi.pshell.imaging.Renderer renderer; + private ch.psi.pshell.imaging.DeviceRenderer renderer; private javax.swing.JSpinner spinnerAverage; private javax.swing.JSpinner spinnerExposition; private javax.swing.JSpinner spinnerExpositionIntensity; diff --git a/plugins/Initialization.java b/plugins/Initialization.java index 849dcc8..b47393a 100644 --- a/plugins/Initialization.java +++ b/plugins/Initialization.java @@ -1,5 +1,6 @@ -import ch.psi.pshell.ui.Panel; +import ch.psi.pshell.framework.Context; +import ch.psi.pshell.framework.Panel; import javax.swing.JButton; /* @@ -65,7 +66,7 @@ public class Initialization extends Panel { if (ex != null) { showException((Exception) ex); } else { - getContext().scriptingLog(String.format("Shell command '%s' return value: %s", shellCommand, String.valueOf(ret))); + Context.getInterpreter().scriptingLog(String.format("Shell command '%s' return value: %s", shellCommand, String.valueOf(ret))); } return ret; }); diff --git a/plugins/OTFScanBase.java b/plugins/OTFScanBase.java index 81bea31..7aa6b09 100755 --- a/plugins/OTFScanBase.java +++ b/plugins/OTFScanBase.java @@ -8,12 +8,13 @@ import java.nio.file.Paths; import java.util.HashMap; import java.util.logging.Level; import javax.swing.JLabel; -import ch.psi.utils.State; -import ch.psi.utils.swing.Editor.EditorDialog; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.Editor.EditorDialog; import ch.psi.pshell.plot.LinePlotBase; import ch.psi.pshell.plot.LinePlotSeries; import ch.psi.pshell.plot.Plot; -import ch.psi.pshell.ui.Panel; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.framework.Setup; import java.util.logging.Logger; /** @@ -54,7 +55,7 @@ public class OTFScanBase extends Panel { } Path getConfigFile() { - return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties"); + return Paths.get(Setup.getConfigPath(), "energy_scan.properties"); } LinePlotBase scanPlot; diff --git a/plugins/Settings.java b/plugins/Settings.java index f56d810..c2d5389 100755 --- a/plugins/Settings.java +++ b/plugins/Settings.java @@ -1,10 +1,13 @@ -import ch.psi.pshell.core.Configuration.NotificationLevel; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; -import ch.psi.utils.swing.SwingUtils; -import ch.psi.utils.swing.SwingUtils.OptionResult; -import ch.psi.utils.swing.SwingUtils.OptionType; +import ch.psi.pshell.console.App; +import ch.psi.pshell.framework.Context; +import ch.psi.pshell.framework.Setup; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.notification.NotificationManager.NotificationLevel; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.SwingUtils; +import ch.psi.pshell.swing.SwingUtils.OptionResult; +import ch.psi.pshell.swing.SwingUtils.OptionType; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; @@ -30,7 +33,7 @@ public class Settings extends Panel { SwingUtilities.invokeLater(() -> { undo(); }); - textNamePattern.setText(getContext().getConfig().dataPath); + textNamePattern.setText(App.getInstance().getConfig().dataPath); } @Override @@ -50,12 +53,12 @@ public class Settings extends Panel { void undo() { try { - textDataPath.setText(getContext().getSetup().expandPath(getContext().getConfig().dataPath)); - textPGroup.setText(getContext().getSetting("pgroup") == null ? "" : getContext().getSetting("pgroup")); - textProposal.setText(getContext().getSetting("proposal") == null ? "" : getContext().getSetting("proposal")); - textProposer.setText(getContext().getSetting("proposer") == null ? "" : getContext().getSetting("proposer")); - textSamples.setText(getContext().getSetting("sample") == null ? "" : getContext().getSetting("sample")); - textAuthors.setText(getContext().getSetting("authors") == null ? "" : getContext().getSetting("authors").replace("|", "\n")); + textDataPath.setText(Setup.expandPath(App.getInstance().getConfig().dataPath)); + textPGroup.setText(Context.getSetting("pgroup") == null ? "" : Context.getSetting("pgroup")); + textProposal.setText(Context.getSetting("proposal") == null ? "" : Context.getSetting("proposal")); + textProposer.setText(Context.getSetting("proposer") == null ? "" : Context.getSetting("proposer")); + textSamples.setText(Context.getSetting("sample") == null ? "" : Context.getSetting("sample")); + textAuthors.setText(Context.getSetting("authors") == null ? "" : Context.getSetting("authors").replace("|", "\n")); } catch (Exception ex) { getLogger().log(Level.SEVERE, null, ex); } @@ -71,11 +74,11 @@ public class Settings extends Panel { String samples = textSamples.getText().trim(); String authors = textAuthors.getText().trim().replace("\n", "|"); - getContext().setSetting("pgroup", pgroup); - getContext().setSetting("proposal", proposal); - getContext().setSetting("proposer", proposer); - getContext().setSetting("sample", samples); - getContext().setSetting("authors", authors); + Context.setSetting("pgroup", pgroup); + Context.setSetting("proposal", proposal); + Context.setSetting("proposer", proposer); + Context.setSetting("sample", samples); + Context.setSetting("authors", authors); } catch (Exception ex) { getLogger().log(Level.SEVERE, null, ex); @@ -134,8 +137,8 @@ public class Settings extends Panel { void updateNotify() { try { updatingControls = true; - comboNotification.setSelectedItem(getContext().getConfig().notificationLevel); - textRecipients.setText(getContext().getNotificationManager().getConfig().to); + comboNotification.setSelectedItem(App.getInstance().getConfig().notificationLevel); + textRecipients.setText(Context.getNotificationManager().getConfig().to); } finally { updatingControls = false; } @@ -148,14 +151,14 @@ public class Settings extends Panel { textNamePattern.setEnabled(editable); spinnerSeq.setEnabled(editable); buttonDefaultPath.setEnabled(editable && !textNamePattern.getText().equals(DEFAULT_PATH)); - buttonSetPath.setEnabled(editable && !textNamePattern.getText().equals(getContext().getConfig().dataPath)); - buttonUndoPath.setEnabled(editable && !textNamePattern.getText().equals(getContext().getConfig().dataPath)); - buttonSetSeq.setEnabled(editable && !spinnerSeq.getValue().equals(getContext().getFileSequentialNumber())); - buttonUndoSeq.setEnabled(editable && !spinnerSeq.getValue().equals(getContext().getFileSequentialNumber())); + buttonSetPath.setEnabled(editable && !textNamePattern.getText().equals(App.getInstance().getConfig().dataPath)); + buttonUndoPath.setEnabled(editable && !textNamePattern.getText().equals(App.getInstance().getConfig().dataPath)); + buttonSetSeq.setEnabled(editable && !spinnerSeq.getValue().equals(Context.getFileSequentialNumber())); + buttonUndoSeq.setEnabled(editable && !spinnerSeq.getValue().equals(Context.getFileSequentialNumber())); buttonApply.setEnabled(editable); - spinnerSeq.setValue(getContext().getFileSequentialNumber()); - textDataPath.setText(getContext().getSetup().expandPath(getContext().getConfig().dataPath)); + spinnerSeq.setValue(Context.getFileSequentialNumber()); + textDataPath.setText(Setup.expandPath(App.getInstance().getConfig().dataPath)); } @SuppressWarnings("unchecked") @@ -673,7 +676,7 @@ public class Settings extends Panel { private void buttonSetSeqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetSeqActionPerformed try { - getContext().setFileSequentialNumber(((Number) spinnerSeq.getValue()).intValue()); + Context.setFileSequentialNumber(((Number) spinnerSeq.getValue()).intValue()); updateControls(); } catch (Exception ex) { showException(ex); @@ -682,7 +685,7 @@ public class Settings extends Panel { private void buttonUndoSeqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoSeqActionPerformed try { - spinnerSeq.setValue(getContext().getFileSequentialNumber()); + spinnerSeq.setValue(Context.getFileSequentialNumber()); updateControls(); } catch (Exception ex) { showException(ex); @@ -696,8 +699,8 @@ public class Settings extends Panel { private void buttonSetPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetPathActionPerformed try { - getContext().getConfig().dataPath = textNamePattern.getText(); - getContext().getConfig().save(); + App.getInstance().getConfig().dataPath = textNamePattern.getText(); + App.getInstance().getConfig().save(); updateControls(); } catch (Exception ex) { showException(ex); @@ -706,7 +709,7 @@ public class Settings extends Panel { private void buttonUndoPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoPathActionPerformed try { - textNamePattern.setText(getContext().getConfig().dataPath); + textNamePattern.setText(App.getInstance().getConfig().dataPath); updateControls(); } catch (Exception ex) { showException(ex); @@ -830,9 +833,9 @@ public class Settings extends Panel { throw new Exception("To enable notifications please set the recepient list."); } } - getContext().getConfig().notificationLevel =level; - getContext().getNotificationManager().setRecipients(to.split(";")); - getContext().getNotificationManager().initialize(); //Remove this when fix setRecipients + App.getInstance().getConfig().notificationLevel =level; + Context.getNotificationManager().setRecipients(to.split(";")); + Context.getNotificationManager().initialize(); //Remove this when fix setRecipients } catch (Exception ex) { showException(ex); } diff --git a/plugins/ShiftsIO.java b/plugins/ShiftsIO.java index 9c3daff..72f8e37 100644 --- a/plugins/ShiftsIO.java +++ b/plugins/ShiftsIO.java @@ -3,8 +3,8 @@ import ij.io.SaveDialog; import java.util.ArrayList; import java.io.IOException; import java.io.File; -import jmatio.types.*; -import jmatio.io.*; +import com.jmatio.types.*; //jmatio.types.*; +import com.jmatio.io.*; //jmatio.io.*; import ij.gui.GenericDialog; import ij.IJ; import ij.Prefs; diff --git a/plugins/Test.java b/plugins/Test.java index 375369e..e7876d6 100755 --- a/plugins/Test.java +++ b/plugins/Test.java @@ -2,15 +2,8 @@ * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. */ -import ch.psi.pshell.core.Context; -import ch.psi.pshell.ui.Panel; -import ch.psi.pshell.ui.Plugin; -import ch.psi.utils.State; -import ch.psi.utils.swing.SwingUtils; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.script.ScriptException; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.utils.State; /** * diff --git a/plugins/TestLuka.java b/plugins/TestLuka.java index 14a92f2..9a7c84a 100644 --- a/plugins/TestLuka.java +++ b/plugins/TestLuka.java @@ -1,5 +1,5 @@ -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.utils.State; /** * diff --git a/plugins/XPEEM_Settings.java b/plugins/XPEEM_Settings.java index df03110..4bf0d5b 100644 --- a/plugins/XPEEM_Settings.java +++ b/plugins/XPEEM_Settings.java @@ -1,9 +1,10 @@ -import ch.psi.pshell.core.CommandSource; -import ch.psi.pshell.core.Context; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; -import ch.psi.utils.swing.SwingUtils; +import ch.psi.pshell.framework.Context; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.sequencer.CommandSource; +import ch.psi.pshell.sequencer.Interpreter; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.SwingUtils; import java.awt.Component; import java.util.logging.Level; import java.util.logging.Logger; @@ -266,7 +267,7 @@ public class XPEEM_Settings extends Panel { private void buttonRunSelectedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRunSelectedActionPerformed try { - getContext().startExecution(CommandSource.plugin, null, null,null, false); + Context.getInterpreter().startExecution(CommandSource.plugin, null, null,null, false); new Thread(()->{ try{ if (checkSetting1.isSelected()==true){ @@ -286,8 +287,8 @@ public class XPEEM_Settings extends Panel { getLogger().log(Level.WARNING, null, ex); } finally{ try { - getContext().endExecution(); - } catch (Context.ContextStateException ex) { + Context.getInterpreter().endExecution(); + } catch (Interpreter.InterpreterStateException ex) { getLogger().log(Level.SEVERE, null, ex); } } diff --git a/script/Users/PEEM/Armin/Manipulator_Control/Pos-PEEMCAM-Scan/TestVscan.py b/script/Users/PEEM/Armin/Manipulator_Control/Pos-PEEMCAM-Scan/TestVscan.py index 3a43f1a..7ec0039 100644 --- a/script/Users/PEEM/Armin/Manipulator_Control/Pos-PEEMCAM-Scan/TestVscan.py +++ b/script/Users/PEEM/Armin/Manipulator_Control/Pos-PEEMCAM-Scan/TestVscan.py @@ -28,7 +28,7 @@ if SHOW_COMPOSITE_IMG: def before_read(pos, scan): trigger_peemcam() - ProviderTIFF.setMetadata(get_diags()) + FormatTIFF.setMetadata(get_diags()) def after_read(rec, scan): x,y = rec.index%bins_x, rec.index/bins_x diff --git a/script/Users/PEEM/Armin/Manipulator_Control/TestVscan_AK.py b/script/Users/PEEM/Armin/Manipulator_Control/TestVscan_AK.py index 8583ed9..b467b32 100644 --- a/script/Users/PEEM/Armin/Manipulator_Control/TestVscan_AK.py +++ b/script/Users/PEEM/Armin/Manipulator_Control/TestVscan_AK.py @@ -32,7 +32,7 @@ if SHOW_COMPOSITE_IMG: def before_read(pos, scan): trigger_peemcam() - ProviderTIFF.setMetadata(get_diags()) + FormatTIFF.setMetadata(get_diags()) def after_read(rec, scan): x,y = rec.index%bins_x, rec.index/bins_x diff --git a/script/Users/PEEM/Armin/PEEM_slit.py b/script/Users/PEEM/Armin/PEEM_slit.py index 9ed8b76..5b55045 100644 --- a/script/Users/PEEM/Armin/PEEM_slit.py +++ b/script/Users/PEEM/Armin/PEEM_slit.py @@ -24,6 +24,6 @@ #roi_contrast.read() #image_contrast.read() -lscan([slit_motion], [image.contrast], [-10500.0], [-6500.0], [100.0], latency=0.0, relative=False, passes=1, zigzag=False, title='slit', keep=False, name='test', layout='table', provider='txt') +lscan([slit_motion], [image.contrast], [-10500.0], [-6500.0], [100.0], latency=0.0, relative=False, passes=1, zigzag=False, title='slit', keep=False, name='test', layout='table', format='txt') #cscan([slit_motion], ['ca://X11MA-PC-ET7000:SW-K3'], [-9700.0], [-9500.0], [1.0], latency=2.0, time=1.0, relative=False, passes=1, zigzag=False, title='testslit', keep=False, name='Unknown') -#lscan([objective], ['ca://X11MA-ES1-PREP:PRESSURE'], [1475.0], [1485.0], [2.0], latency=10.0, relative=False, passes=1, zigzag=False, title='test', keep=False, name='testt', layout='default', provider='txt') \ No newline at end of file +#lscan([objective], ['ca://X11MA-ES1-PREP:PRESSURE'], [1475.0], [1485.0], [2.0], latency=10.0, relative=False, passes=1, zigzag=False, title='test', keep=False, name='testt', layout='default', format='txt') \ No newline at end of file diff --git a/script/Users/PEEM/Armin/TestUserScript_Armin.py b/script/Users/PEEM/Armin/TestUserScript_Armin.py index 5567a45..efe3f23 100644 --- a/script/Users/PEEM/Armin/TestUserScript_Armin.py +++ b/script/Users/PEEM/Armin/TestUserScript_Armin.py @@ -25,7 +25,7 @@ abs_spec(ranges="Fe_L3_fine", roi="test", switch_pol=False, scans=1, exposure=EX #eiger_threshold.write(7500) #eiger.start() -#tscan(['ca://X11MA-PC-ET7000:SW-K'], points=10, interval=1.0, title='temperature', keep=False, name='tewsst', layout='table', provider='txt', auto_range=True, domain_axis='Time') +#tscan(['ca://X11MA-PC-ET7000:SW-K'], points=10, interval=1.0, title='temperature', keep=False, name='tewsst', layout='table', format='txt', auto_range=True, domain_axis='Time') #Direct functions to change energy, pol, offset: #change_energy(700) diff --git a/script/devices/eiger.py b/script/devices/eiger.py index bf609bd..5446487 100644 --- a/script/devices/eiger.py +++ b/script/devices/eiger.py @@ -5,7 +5,7 @@ import ch.psi.pshell.imaging.Pen as Pen import java.awt.Rectangle as Rectangle import ch.psi.pshell.imaging.Data as Data import ch.psi.pshell.device.Camera.DataType as DataType -import ch.psi.utils.Chrono as Chrono +import ch.psi.pshell.utils.Chrono as Chrono import subprocess #GRAB_MIN_TIME = 1000 @@ -463,10 +463,9 @@ if False: add_device(RoiIntensity("Region1", image, 10, 5, 20, 10), True) add_device(RoiIntensity("Region2", image, 10, 5, 40, 20), True) - - import ch.psi.pshell.data.ProviderCSV as ProviderCSV - ProviderCSV.setDefaultItemSeparator(" ") - tscan((Region1, Region2), 10, 0.1, layout="table", provider = "csv") + + FormatCSV.setDefaultItemSeparator(" ") + tscan((Region1, Region2), 10, 0.1, layout="table", format = "csv") ret = grab_frames(image, 10, sleep=0.1) av = integrate_frames(ret) diff --git a/script/imaging/shifts.py b/script/imaging/shifts.py index c854281..151911c 100644 --- a/script/imaging/shifts.py +++ b/script/imaging/shifts.py @@ -39,9 +39,9 @@ def load_corr_stack(title="Corr", show=False): return load_stack(title, file_list, show) def instantiate_dynamic_class(name): - if get_context().getPluginManager().getDynamicClass(name) is None: - get_context().getPluginManager().loadInitializePlugin(name + ".java") - return get_context().getClassByName(name).newInstance() + if get_plugin_manager().getDynamicClass(name) is None: + get_plugin_manager().loadInitializePlugin(name + ".java") + return Context.getClassByName(name).newInstance() def complex_edge_filtering(imp, complex=True, g_sigma=3.0, g_resolution=1e-4, show=False, java_code=False): diff --git a/script/local.py b/script/local.py index 6f0bc52..1d5af2a 100644 --- a/script/local.py +++ b/script/local.py @@ -1,16 +1,5 @@ -################################################################################################### -# Deployment specific global definitions - executed after startup.py -################################################################################################### -import ntpath -import traceback -from rsync import * -from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list, Gaussian -from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks -from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator -from collections import OrderedDict - -ProviderCSV.setDefaultItemSeparator(", ") -get_context().dataManager.createLogs=False +FormatCSV.setDefaultItemSeparator(", ") +get_data_manager().createLogs=False IMAGING_ROI = None @@ -226,7 +215,7 @@ def convert_file(input_file_name, output_file_name, pol = None): out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + normtey + s + normdiode + line_sep) except: traceback.print_exc() - #os.rename(input_file_name, get_context().setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) + #os.rename(input_file_name, Setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) def convert_file_full(input_file_name, output_file_name, pol = None): print "Converting data file: " + input_file_name + " to " + output_file_name @@ -258,7 +247,7 @@ def convert_file_full(input_file_name, output_file_name, pol = None): out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + CADC4 + s + CADC5 + s + mcurr + s + time + s + fieldx + s + fieldz + s + str(pol) + s + temp + s + normtey + s + normdiode + line_sep) except: traceback.print_exc() - #os.rename(input_file_name, get_context().setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) + #os.rename(input_file_name, Setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) ################################################################################################### #Scan commands @@ -268,7 +257,7 @@ def otf(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None, """ if name is None: name = get_exec_pars().name - #folder = get_context().setup.expandPath("{year}_{month}/{date}"); + #folder = Setup.expandPath("{year}_{month}/{date}"); run("templates/EnergyScan", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "ALPHA":float(alpha) if alpha is not None else None}) def otf2(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None, name = None, folder = 'TEST'): @@ -280,7 +269,7 @@ def otf2(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None run("templates/EnergyScan_v4", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "TAG":name, "ALPHA":float(alpha) if alpha is not None else None}) def otf_img(start, end, time, delay = 0.0, exposure=0.2, roi=None, name = None, save_images=False): - folder = get_context().setup.expandPath("{year}_{month}/{date}"); + folder = Setup.expandPath("{year}_{month}/{date}"); if is_string(roi): with open(expand_path("{config}/ROIs/" + roi + ".roi"), 'rb') as f: roi = OrderedDict() @@ -698,12 +687,12 @@ def on_change_data_path(path): #Sounds ################################################################################################### def on_command_started(info): - if not get_context().isLocalMode(): + if not get_interpreter().isLocalMode(): if info.script and not info.background: play_sound("start") def on_command_finished(info): - if not get_context().isLocalMode(): + if not get_interpreter().isLocalMode(): if info.script and not info.background: if (info.isError()): if not info.isAborted(): @@ -712,12 +701,12 @@ def on_command_finished(info): play_sound("success") -import ch.psi.utils.Audio as Audio +import ch.psi.pshell.utils.Audio as Audio import java.io.File as File def play_sound(name): try: - Audio.playFile(File(get_context().setup.expandPath("{home}/sounds/" + name + ".wav")), False) + Audio.playFile(File(Setup.expandPath("{home}/sounds/" + name + ".wav")), False) except: #TODO: sound does not work when logged as e-account if not Sys.getUserName().startswith("e"): diff --git a/script/old_scripts/localXtreme.py b/script/old_scripts/localXtreme.py index cf82892..7143a16 100755 --- a/script/old_scripts/localXtreme.py +++ b/script/old_scripts/localXtreme.py @@ -33,12 +33,12 @@ class DataLayout( ch.psi.pshell.data.LayoutTable): data_file = time.strftime('%Y%m%d_%H%M') + '_' + get_exec_pars().name + '_' + str(get_exec_pars().count).zfill(4) print "Opened data file: " + get_exec_pars().path + "/" + data_file return data_file -get_context().dataManager.setLayout(DataLayout()) +get_data_manager.setLayout(DataLayout()) """ #Reading Energy Scan configuration file def getPars(element): - f = open(get_context().setup.getConfigPath() + '/energy_scan.properties') + f = open(Setup.getConfigPath() + '/energy_scan.properties') try: for line in f: tokens = line.split("=") @@ -157,7 +157,7 @@ def convert_file(input_file_name, output_file_name, pol = None): out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + CADC4 + s + CADC5 + s + MCurr + s + time + s + MAGX + s + MAGZ + s + str(pol) + s + EXPT + s + normtey + s + normdiode + line_sep) except: traceback.print_exc() - os.rename(input_file_name, get_context().setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) + os.rename(input_file_name, Setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) def plot_file(file_name, title = None): """ @@ -171,7 +171,7 @@ def elog(title, message, attachments = [], author = None, category = "Info", dom Add entry to ELOG. """ if author is None: - author = "pshell" #get_context().user.name + author = "pshell" #Context.getUserName() typ = "pshell" entry = "" @@ -196,7 +196,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 = get_context().setup.getContextPath()): +def get_plot_snapshots(title = None, file_type = "png", temp_path = Setup.getContextPath()): """ Returns list with file names of plots snapshots from a plotting context. """ @@ -214,12 +214,12 @@ def get_plot_snapshots(title = None, file_type = "png", temp_path = get_context( # Controller state listener ################################################################################################### -#class Listener(ControllerListener): -# def onControllerStateChanged(self, state, former): +#class Listener(InterpreterListener): +# def onStateChanged(self, state, former): # global FILENAME # if former == State.Busy: # FILENAME = None -#get_context().addListener(Listener()) #Old listeners are cleande in startup +#get_interpreter().addListener(Listener()) #Old listeners are cleande in startup ################################################################################################### @@ -444,7 +444,7 @@ def otf(start, end, time, delay=0.0, mode = None, offset = None, alpha = None, n """ if name is None: name = get_exec_pars().name - folder = get_context().setup.expandPath("{year}_{month}/{date}"); + folder = Setup.expandPath("{year}_{month}/{date}"); run("EnergyScan", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "ALPHA":alpha}) def hyst_cont(field, init_field, final_field, ramp_speed, energies): diff --git a/script/templates/Eiger2Img.py b/script/templates/Eiger2Img.py index 2c2b33e..69b6153 100644 --- a/script/templates/Eiger2Img.py +++ b/script/templates/Eiger2Img.py @@ -45,7 +45,7 @@ def get_image_file_name(cycle=-1, frame_index=0, short_name=False, shifted=False root = "" if short_name else (data_path + "/") abs_index=run_index + frame_index max_index= max(max_index, frame_index) - prefix = get_context().setup.expandPath("i{date}%02d_" + ("%03d" % (abs_index,))) + prefix = Setup.expandPath("i{date}%02d_" + ("%03d" % (abs_index,))) if cycle < 0: if (shifted): @@ -54,7 +54,7 @@ def get_image_file_name(cycle=-1, frame_index=0, short_name=False, shifted=False else: prefix = prefix + ("_corr/c" if shifted else "/") ret= root + prefix + "i{date}%02d"+ ("_%03d#%03d" % (abs_index,cycle)) + ".tif" - return get_context().setup.expandPath(ret) + return Setup.expandPath(ret) """ @@ -126,7 +126,7 @@ def save_image_file(frame, cycle=-1, frame_index=0, processed_shift=False): init_eiger(exposure=EXPOSURE) -run_index = get_context().getDaySequentialNumber() +run_index = Context.getDaySequentialNumber() print " ---- Run index : %d" %(run_index,) max_index=0 @@ -244,7 +244,7 @@ try: print " ---- New un index : %d" %(run_index,) finally: for i in range(max_index): - get_context().incrementDaySequentialNumber() + Context.incrementDaySequentialNumber() if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": close_vg10() if not get_dry_run() and str(get_setting("AUTO_SWITCH_SHUTTER")).lower() == "true": diff --git a/script/templates/Eiger2Img_Hannes_valve_close.py b/script/templates/Eiger2Img_Hannes_valve_close.py index 2501c6f..6479cb0 100644 --- a/script/templates/Eiger2Img_Hannes_valve_close.py +++ b/script/templates/Eiger2Img_Hannes_valve_close.py @@ -36,12 +36,12 @@ threads = [] #path = "{data}/{year}_{month}/{date}" + "/" + "{seq}%03d_" + METHOD #set_exec_pars(path= path, format="txt", layout="table", open=True) -#data_path = get_context().setup.expandPath(path) +#data_path = Setup.expandPath(path) data_path = "{data}/{year}_{month}/{date}/{date}_{name}" set_exec_pars(name=METHOD, path = data_path, format="txt", layout="table", open=True) #data_path = get_exec_pars().path -#get_context().incrementFileSequentialNumber() +Context.incrementFileSequentialNumber() def get_image_file_name(cycle=-1, frame_index=0, short_name=False): @@ -49,17 +49,17 @@ def get_image_file_name(cycle=-1, frame_index=0, short_name=False): if (METHOD == "Two_Pol") and (SEQUENCE == "A") and (frame_index<2) and ((cycle%2)==0): #Swapped frame_index = 0 if frame_index else 1 root = "" if short_name else (data_path + "/") - #prefix = get_context().setup.expandPath("i{seq}%03d" + "_" + ("%d" % frame_index)) + #prefix = Setup.expandPath("i{seq}%03d" + "_" + ("%d" % frame_index)) abs_index=run_index + frame_index max_index= max(max_index, frame_index) - #prefix = get_context().setup.expandPath("i{date}%02d_{seq}%03d") - prefix = get_context().setup.expandPath("i{date}%02d_" + ("%03d" % (abs_index,))) + #prefix = Setup.expandPath("i{date}%02d_{seq}%03d") + prefix = Setup.expandPath("i{date}%02d_" + ("%03d" % (abs_index,))) if cycle < 0: ret = root + prefix + ".tif" else: ret= root + prefix + "/i{date}%02d"+ ("_%03d#%03d" % (abs_index,cycle)) + ".tif" - return get_context().setup.expandPath(ret) + return Setup.expandPath(ret) @@ -102,7 +102,7 @@ def save_image_file(frame, cycle=-1, frame_index=0): init_eiger(exposure=EXPOSURE) -run_index = get_context().getDaySequentialNumber() +run_index = Context.getDaySequentialNumber() print " ---- Run index : %d" %(run_index,) max_index=0 @@ -213,7 +213,7 @@ try: #set_exec_pars(then_success="run('templates/Eiger2Img')") """ - get_context().incrementDaySequentialNumber() + Context.incrementDaySequentialNumber() set_exec_pars(open=False) set_exec_pars(open=True) @@ -234,7 +234,7 @@ try: print " ---- New un index : %d" %(run_index,) finally: for i in range(max_index): - get_context().incrementDaySequentialNumber() + Context.incrementDaySequentialNumber() if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": close_vg10() if not get_dry_run() and str(get_setting("AUTO_SWITCH_SHUTTER")).lower() == "true": diff --git a/script/templates/Eiger2Img_Original.py b/script/templates/Eiger2Img_Original.py index 5900b4e..c750244 100644 --- a/script/templates/Eiger2Img_Original.py +++ b/script/templates/Eiger2Img_Original.py @@ -36,12 +36,12 @@ threads = [] #path = "{data}/{year}_{month}/{date}" + "/" + "{seq}%03d_" + METHOD #set_exec_pars(path= path, format="txt", layout="table", open=True) -#data_path = get_context().setup.expandPath(path) +#data_path = Setup.expandPath(path) data_path = "{data}/{year}_{month}/{date}/{date}_{name}" set_exec_pars(name=METHOD, path = data_path, format="txt", layout="table", open=True) #data_path = get_exec_pars().path -#get_context().incrementFileSequentialNumber() +#Context.incrementFileSequentialNumber() def get_image_file_name(cycle=-1, frame_index=0, short_name=False): @@ -49,17 +49,17 @@ def get_image_file_name(cycle=-1, frame_index=0, short_name=False): if (METHOD == "Two_Pol") and (SEQUENCE == "A") and (frame_index<2) and ((cycle%2)==0): #Swapped frame_index = 0 if frame_index else 1 root = "" if short_name else (data_path + "/") - #prefix = get_context().setup.expandPath("i{seq}%03d" + "_" + ("%d" % frame_index)) + #prefix = Setup.expandPath("i{seq}%03d" + "_" + ("%d" % frame_index)) abs_index=run_index + frame_index max_index= max(max_index, frame_index) - #prefix = get_context().setup.expandPath("i{date}%02d_{seq}%03d") - prefix = get_context().setup.expandPath("i{date}%02d_" + ("%03d" % (abs_index,))) + #prefix = Setup.expandPath("i{date}%02d_{seq}%03d") + prefix = Setup.expandPath("i{date}%02d_" + ("%03d" % (abs_index,))) if cycle < 0: ret = root + prefix + ".tif" else: ret= root + prefix + "/i{date}%02d"+ ("_%03d#%03d" % (abs_index,cycle)) + ".tif" - return get_context().setup.expandPath(ret) + return Setup.expandPath(ret) @@ -101,7 +101,7 @@ def save_image_file(frame, cycle=-1, frame_index=0): init_eiger(exposure=EXPOSURE) -run_index = get_context().getDaySequentialNumber() +run_index = Context.getDaySequentialNumber() print " ---- Run index : %d" %(run_index,) max_index=0 @@ -207,7 +207,7 @@ try: #set_exec_pars(then_success="run('templates/Eiger2Img')") """ - get_context().incrementDaySequentialNumber() + Context.incrementDaySequentialNumber() set_exec_pars(open=False) set_exec_pars(open=True) @@ -228,7 +228,7 @@ try: print " ---- New un index : %d" %(run_index,) finally: for i in range(max_index): - get_context().incrementDaySequentialNumber() + Context.incrementDaySequentialNumber() if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": close_vg10() if not get_dry_run() and str(get_setting("AUTO_SWITCH_SHUTTER")).lower() == "true": diff --git a/script/templates/EigerAbsSpec.py b/script/templates/EigerAbsSpec.py index f3980da..91d95a5 100644 --- a/script/templates/EigerAbsSpec.py +++ b/script/templates/EigerAbsSpec.py @@ -69,14 +69,14 @@ def grab_image(position, scan): #Scan_Nr = (scan.recordIndex-1)/NUMBER_SCANS #filename = get_exec_pars().path + "/" + ("%02d" % Scan_Nr) + "/s" + "{seq}%03d" + "_" + ("%03d.tif" % scan.recordIndex) filename = get_exec_pars().path + "/" + str(scan.currentPass) + "/s" + "{seq}%03d" + "_" + ("%03d.tif" % scan.recordIndex) - filename = get_context().setup.expandPath(filename) + filename = Setup.expandPath(filename) print filename metadata = get_diags() if SAVE_DIAGS else {} save_as_tiff(av, filename, metadata=metadata) if DRIFT_CORRECTION and (calc_roi is not None): global ref_image filename = get_exec_pars().path + "/" + str(scan.currentPass) + "_corr/cs" + "{seq}%03d" + "_" + ("%03d.tif" % scan.recordIndex) - filename = get_context().setup.expandPath(filename) + filename = Setup.expandPath(filename) if ref_image is None: ref_image = av save_as_tiff(av, filename, metadata=metadata) diff --git a/script/templates/EnergyScan_img.py b/script/templates/EnergyScan_img.py index 30537ef..0686c30 100644 --- a/script/templates/EnergyScan_img.py +++ b/script/templates/EnergyScan_img.py @@ -4,7 +4,7 @@ if (get_exec_pars().source == CommandSource.ui) and (get_exec_pars().script == " E2 = 820 TIME = 1 #min DELAY = 0.1 #s - FOLDER = get_context().setup.expandPath("{year}_{month}/{date}") + FOLDER = Setup.expandPath("{year}_{month}/{date}") FILE = 'ImageOTF' ROI = {"Region1": [286, 86, 79, 70], "Region2": [153, 279, 95, 82]} SAVE_IMAGES=True diff --git a/script/test/BenchGrab.py b/script/test/BenchGrab.py index b667297..270fbba 100755 --- a/script/test/BenchGrab.py +++ b/script/test/BenchGrab.py @@ -13,7 +13,7 @@ def grab_image(position, scan): av = average_frames(frames) if True: filename = get_exec_pars().path + "/" + ("%03d.tif" % scan.recordIndex) - filename = get_context().setup.expandPath(filename) + filename = Setup.expandPath(filename) print filename save_as_tiff(av, filename, parallel=True) diff --git a/script/test/Simu2Img.py b/script/test/Simu2Img.py index 583bab5..ccc602d 100644 --- a/script/test/Simu2Img.py +++ b/script/test/Simu2Img.py @@ -38,8 +38,8 @@ threads = [] path = "{data}/{year}_{month}/{date}" + "/" + "{seq}%03d_" + METHOD set_exec_pars(path= path, format="txt", layout="table", open=True) -data_path = get_context().setup.expandPath(path) -#get_context().incrementFileSequentialNumber() +data_path = Setup.expandPath(path) +#Context.incrementFileSequentialNumber() def get_image_file_name(cycle=-1, frame_index=0, short_name=False): root = "" if short_name else (data_path + "/") @@ -47,7 +47,7 @@ def get_image_file_name(cycle=-1, frame_index=0, short_name=False): ret = root + "i"+"{seq}%03d" + "_" + ("%d" % frame_index) + ".tif" else: ret= root + ("%d/" % frame_index) + "i"+"{seq}%03d" + "_" + str(cycle) + ("_%d" % frame_index) + ".tif" - ret = get_context().setup.expandPath(ret) + ret = Setup.expandPath(ret) return ret @@ -59,7 +59,7 @@ def getLEEM(): LEEMtemp=getLEEMtemp() """ set_exec_pars(path= path, format="txt", layout="table", open=True) -data_path = get_context().setup.expandPath(path) +data_path = Setup.expandPath(path) diff --git a/script/test/SimuAbsSpec.py b/script/test/SimuAbsSpec.py index 2adc41f..59caca8 100644 --- a/script/test/SimuAbsSpec.py +++ b/script/test/SimuAbsSpec.py @@ -67,7 +67,7 @@ def grab_image(position, scan): #Scan_Nr = (scan.recordIndex-1)/NUMBER_SCANS #filename = get_exec_pars().path + "/" + ("%02d" % Scan_Nr) + "/s" + "{seq}%03d" + "_" + ("%03d.tif" % scan.recordIndex) filename = get_exec_pars().path + "/" + str(scan.currentPass) + "/s" + "{seq}%03d" + "_" + ("%03d.tif" % scan.recordIndex) - filename = get_context().setup.expandPath(filename) + filename = Setup.expandPath(filename) print filename save_as_tiff(av, filename, metadata=(get_diags() if SAVE_DIAGS else {})) diff --git a/script/test/TestVscan.py b/script/test/TestVscan.py index 3a43f1a..7ec0039 100644 --- a/script/test/TestVscan.py +++ b/script/test/TestVscan.py @@ -28,7 +28,7 @@ if SHOW_COMPOSITE_IMG: def before_read(pos, scan): trigger_peemcam() - ProviderTIFF.setMetadata(get_diags()) + FormatTIFF.setMetadata(get_diags()) def after_read(rec, scan): x,y = rec.index%bins_x, rec.index/bins_x diff --git a/script/utils.py b/script/utils.py index fdd2b83..5a7d656 100755 --- a/script/utils.py +++ b/script/utils.py @@ -44,7 +44,7 @@ def convert_file(input_file_name, output_file_name, pol = None): out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + normtey + s + str(pol) + line_sep) except: traceback.print_exc() - os.rename(input_file_name, get_context().setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) + os.rename(input_file_name, Setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) """ ##################### Plotting function ############################# """