diff --git a/config/config.properties b/config/config.properties index 70c7eec..8f00aab 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,46 +1,47 @@ -#Thu Aug 07 10:14:16 CEST 2025 -autoSaveScanData=true +#Thu Aug 07 15:22:56 CEST 2025 commandExecutionEvents=false createSessionFiles=true +dataDepthDimension=0 +dataFormat=txt dataLayout=table dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name} -dataProvider=txt +dataScanAutoSave=true dataScanFlushRecords=true dataScanLazyTableCreation=false dataScanPreserveTypes=false dataScanReleaseRecords=false +dataScanSaveLogs=false dataScanSaveOutput=false dataScanSaveScript=false dataScanSaveSetpoints=false dataScanSaveTimestamps=false +dataScanStreamerPort=-1 dataServerPort=-1 dataTransferMode=Off dataTransferPath= dataTransferUser= -depthDimension=0 -disableDataFileLogs=false disableEmbeddedAttributes=false fdaSerialization=false filePermissionsConfig=Default filePermissionsData=Default filePermissionsLogs=Default filePermissionsScripts=Default -hideServerMessages=true hostName=null instanceName=X06DA logDaysToLive=30 logLevel=Fine logLevelConsole=Off logPath={logs}/{date}_{time} -noBytecodeFiles=false notificationLevel=Off -notifiedTasks= +notificationTasks= parallelInitialization=false pythonHome= +pythonNoBytecodeFiles=false saveCommandStatistics=true saveConsoleSessionFiles=false -scanStreamerPort=-1 +serverCommandsHidden=true serverEnabled=true +serverHostName=null serverPort=22222 sessionHandling=Off simulation=false diff --git a/config/plugins.properties b/config/plugins.properties index d3f5fef..7b4a16d 100644 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -1,5 +1,6 @@ +MXSC-2.0.0.jar=disabled MXSC-1.21.0.jar=disabled -Image_Correlator.java=disabled +Image_Correlator.java=enabled MXSC-1.14.0.jar=disabled MXSC-1.15.0.jar=disabled Commands.java=disabled @@ -12,7 +13,7 @@ HexiposiPanel.java=enabled MjpegSource2.java=enabled LN2.java=disabled Hexiposi.java=disabled -RobotPanel.java=disabled +RobotPanel.java=enabled SmartMagnetConfig.java=disabled SmartMagnetPanel.java=enabled LaserUE.java=enabled diff --git a/config/settings.properties b/config/settings.properties index 0b03b20..fc8a433 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,4 +1,4 @@ -#Thu Aug 07 10:14:45 CEST 2025 +#Fri Aug 08 10:40:26 CEST 2025 barcode_reader_scan_pucks=false beamline_status_enabled=false cold_position_timeout=3600 diff --git a/devices/cover_detection.properties b/devices/cover_detection.properties index 63391f4..20080ee 100644 --- a/devices/cover_detection.properties +++ b/devices/cover_detection.properties @@ -1,4 +1,4 @@ -#Thu Aug 07 10:14:47 CEST 2025 +#Fri Aug 08 10:40:27 CEST 2025 border_dewar=0.56 center_x=1020.0 center_y=1047.0 diff --git a/plugins/BarcodeReaderPanel.java b/plugins/BarcodeReaderPanel.java index d6dabed..65e9a76 100644 --- a/plugins/BarcodeReaderPanel.java +++ b/plugins/BarcodeReaderPanel.java @@ -1,7 +1,7 @@ -import ch.psi.pshell.core.Context; +import ch.psi.pshell.framework.Context; import ch.psi.pshell.device.Device; import ch.psi.pshell.swing.DevicePanel; -import ch.psi.utils.swing.SwingUtils; +import ch.psi.pshell.swing.SwingUtils; import java.util.concurrent.CompletableFuture; /** @@ -32,7 +32,7 @@ public class BarcodeReaderPanel extends DevicePanel { public void onTimer(){ if ((getDevice()!=null) && enabled){ if ((future==null) || (future.isDone())){ - future = Context.getInstance().evalLineBackgroundAsync(getDevice().getName() + ".get()"); + future = Context.getInterpreter().evalLineBackgroundAsync(getDevice().getName() + ".get()"); } } } @@ -40,7 +40,7 @@ public class BarcodeReaderPanel extends DevicePanel { void execute(String statement, boolean showReturn){ try { - Context.getInstance().evalLineBackgroundAsync(statement).handle((ret, ex) -> { + Context.getInterpreter().evalLineBackgroundAsync(statement).handle((ret, ex) -> { if (BarcodeReaderPanel.this.isShowing()){ if (ex != null){ showException((Exception)ex); diff --git a/plugins/Commands.java b/plugins/Commands.java index fb37d24..211ae70 100644 --- a/plugins/Commands.java +++ b/plugins/Commands.java @@ -3,11 +3,12 @@ */ import ch.psi.pshell.device.Device; -import ch.psi.pshell.device.DeviceAdapter; +import ch.psi.pshell.device.DeviceListener; import ch.psi.pshell.device.GenericDevice; -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.utils.State; +import ch.psi.pshell.swing.SwingUtils; import java.awt.Component; import java.io.IOException; import java.util.logging.Level; @@ -29,8 +30,8 @@ public class Commands extends Panel { try{ - spinnerDryTime.setValue(getContext().getScriptManager().getVar("DEFAULT_DRY_HEAT_TIME")); - spinnerDrySpeed.setValue(getContext().getScriptManager().getVar("DEFAULT_DRY_SPEED")); + spinnerDryTime.setValue(Context.getInterpreter().getScriptManager().getVar("DEFAULT_DRY_HEAT_TIME")); + spinnerDrySpeed.setValue(Context.getInterpreter().getScriptManager().getVar("DEFAULT_DRY_SPEED")); } catch(Exception ex){ this.showException(ex); } @@ -41,7 +42,7 @@ public class Commands extends Panel { public void onInitialize(int runCount) { GenericDevice basePlate = getDevice("BasePlate"); if (basePlate != null){ - basePlate.addListener(new DeviceAdapter() { + basePlate.addListener(new DeviceListener() { @Override public void onValueChanged(Device device, Object value, Object former) { if (value!=null){ @@ -97,7 +98,7 @@ public class Commands extends Panel { try { evalAsync(statement, background).handle((ret, ex) -> { if (ex != null){ - if (getContext().getGlobal("recovering") == null) { + if (Context.getGlobal("recovering") == null) { showException((Exception)ex); } } else if (showReturn){ @@ -133,9 +134,9 @@ public class Commands extends Panel { tabCommands = new javax.swing.JPanel(); pnDry = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); - spinnerDryTime = new ch.psi.utils.swing.HorizontalSpinner(); + spinnerDryTime = new ch.psi.pshell.swing.HorizontalSpinner(); buttonDry = new javax.swing.JButton(); - spinnerDrySpeed = new ch.psi.utils.swing.HorizontalSpinner(); + spinnerDrySpeed = new ch.psi.pshell.swing.HorizontalSpinner(); jLabel7 = new javax.swing.JLabel(); ckeckParkOnDry = new javax.swing.JCheckBox(); pnTransfer = new javax.swing.JPanel(); @@ -143,11 +144,11 @@ public class Commands extends Panel { jPanel5 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); checkForce = new javax.swing.JCheckBox(); - spinnerSample = new ch.psi.utils.swing.HorizontalSpinner(); - spinnerPuck = new ch.psi.utils.swing.HorizontalSpinner(); + spinnerSample = new ch.psi.pshell.swing.HorizontalSpinner(); + spinnerPuck = new ch.psi.pshell.swing.HorizontalSpinner(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); - spinnerSegment = new ch.psi.utils.swing.HorizontalSpinner(); + spinnerSegment = new ch.psi.pshell.swing.HorizontalSpinner(); jLabel3 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); checkDatamatrix = new javax.swing.JCheckBox(); diff --git a/plugins/Hexiposi.java b/plugins/Hexiposi.java index 2c55c2c..56d5847 100644 --- a/plugins/Hexiposi.java +++ b/plugins/Hexiposi.java @@ -2,11 +2,12 @@ * Copyright (c) 2014-2018 Paul Scherrer Institute. All rights reserved. */ -import ch.psi.pshell.core.Context; -import ch.psi.pshell.ui.StripChart; -import ch.psi.pshell.ui.App; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; +import ch.psi.pshell.framework.Context; +import ch.psi.pshell.stripchart.StripChart; +import ch.psi.pshell.stripchart.App; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.framework.Setup; +import ch.psi.pshell.utils.State; import java.io.File; import java.util.logging.Level; import java.util.logging.Logger; @@ -18,11 +19,11 @@ public class Hexiposi extends Panel { final StripChart stripChart; public Hexiposi() { initComponents(); - stripChart = new StripChart(this.getTopLevel(), false, App.getStripChartFolderArg()); + stripChart = new StripChart(this.getTopLevel(), false, null); panel.add(stripChart.getPlotPanel()); try { - stripChart.open(new File(Context.getInstance().getSetup().expandPath("{home}/stripchart/hexiposi_positon.scd"))); + stripChart.open(new File(Setup.expandPath("{home}/stripchart/hexiposi_positon.scd"))); stripChart.start(); } catch (Exception ex) { showException(ex); diff --git a/plugins/HexiposiPanel.java b/plugins/HexiposiPanel.java index b29a526..ac349ff 100644 --- a/plugins/HexiposiPanel.java +++ b/plugins/HexiposiPanel.java @@ -1,6 +1,6 @@ -import ch.psi.pshell.core.Context; +import ch.psi.pshell.framework.Context; import ch.psi.pshell.device.Device; import ch.psi.pshell.swing.DevicePanel; @@ -88,7 +88,7 @@ public class HexiposiPanel extends DevicePanel { private void buttonHomingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonHomingActionPerformed try { //Context.getInstance().evalLineAsync("hexiposi.move_home()").handle((ret, ex) -> { - Context.getInstance().evalLineAsync("homing_hexiposi()").handle((ret, ex) -> { + Context.getInterpreter().evalLineAsync("homing_hexiposi()").handle((ret, ex) -> { if (ex != null){ showException((Exception)ex); } diff --git a/plugins/Image_Correlator.java b/plugins/Image_Correlator.java index 27f26c6..6375cb1 100644 --- a/plugins/Image_Correlator.java +++ b/plugins/Image_Correlator.java @@ -71,8 +71,8 @@ public class Image_Correlator implements PlugIn { int width = im1.getWidth(); int height = im1.getHeight(); float[] v1, v2; - ip1 = im1.getProcessor(); - ip2 = im2.getProcessor(); + ImageProcessor ip1 = im1.getProcessor(); + ImageProcessor ip2 = im2.getProcessor(); v1 = new float[width*height]; v2 = new float[width*height]; ImageProcessor plot= new FloatProcessor(256, 256); @@ -92,7 +92,7 @@ public class Image_Correlator implements PlugIn { } plot.invertLut(); plot.resetMinAndMax(); - pcc = calculateCorrelation(v1, v2); + double pcc = calculateCorrelation(v1, v2); ImagePlus ret = new ImagePlus("Correlation Plot", plot); return new Object[]{pcc,ret}; diff --git a/plugins/LN2.java b/plugins/LN2.java index 0aefc2f..dba878a 100644 --- a/plugins/LN2.java +++ b/plugins/LN2.java @@ -2,13 +2,14 @@ * Copyright (c) 2014-2018 Paul Scherrer Institute. All rights reserved. */ -import ch.psi.pshell.core.Context; +import ch.psi.pshell.framework.Context; import ch.psi.pshell.plot.TimePlotBase; -import ch.psi.pshell.ui.StripChart; -import ch.psi.pshell.ui.App; -import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; -import ch.psi.utils.swing.SwingUtils; +import ch.psi.pshell.stripchart.StripChart; +import ch.psi.pshell.stripchart.App; +import ch.psi.pshell.framework.Panel; +import ch.psi.pshell.framework.Setup; +import ch.psi.pshell.utils.State; +import ch.psi.pshell.swing.SwingUtils; import java.awt.Dimension; import java.io.File; import java.io.IOException; @@ -23,11 +24,11 @@ public class LN2 extends Panel { TimePlotBase plot; public LN2() { initComponents(); - stripChart = new StripChart(this.getTopLevel(), false, App.getStripChartFolderArg()); + stripChart = new StripChart(this.getTopLevel(), false, null); panel.add(stripChart.getPlotPanel()); try { - stripChart.open(new File(Context.getInstance().getSetup().expandPath("{home}/stripchart/LN2_Monitoring.scd"))); + stripChart.open(new File(Setup.expandPath("{home}/stripchart/LN2_Monitoring.scd"))); stripChart.start(); } catch (Exception ex) { showException(ex); @@ -66,7 +67,7 @@ public class LN2 extends Panel { public void saveImage(){ getLogger().severe("Saving image"); try { - String fileName = new File(getContext().getSetup().expandPath("{images}/ln2/{date}_{time}.png")).getCanonicalPath(); + String fileName = new File(Setup.expandPath("{images}/ln2/{date}_{time}.png")).getCanonicalPath(); getLogger().severe("File: " + fileName); plot.saveSnapshot(fileName, "png", new Dimension(1200,800)); } catch (Exception ex) { diff --git a/plugins/LaserUE.java b/plugins/LaserUE.java index 579d317..5fc2ef1 100644 --- a/plugins/LaserUE.java +++ b/plugins/LaserUE.java @@ -1,9 +1,9 @@ import ch.psi.pshell.device.Readable; import ch.psi.pshell.serial.SerialPortDevice; import ch.psi.pshell.serial.SerialPortDeviceConfig; -import static ch.psi.utils.BitMask.*; -import ch.psi.utils.Convert; -import ch.psi.utils.State; +import static ch.psi.pshell.utils.BitMask.*; +import ch.psi.pshell.utils.Convert; +import ch.psi.pshell.utils.State; import java.io.IOException; /* diff --git a/plugins/LaserUEPanel.java b/plugins/LaserUEPanel.java index 017fb77..33bd325 100644 --- a/plugins/LaserUEPanel.java +++ b/plugins/LaserUEPanel.java @@ -1,7 +1,7 @@ -import ch.psi.pshell.core.Context; +import ch.psi.pshell.framework.Context; import ch.psi.pshell.device.Device; import ch.psi.pshell.swing.DevicePanel; -import ch.psi.utils.swing.SwingUtils; +import ch.psi.pshell.swing.SwingUtils; /** * @@ -27,7 +27,7 @@ public class LaserUEPanel extends DevicePanel { void execute(String statement, boolean showReturn){ try { - Context.getInstance().evalLineBackgroundAsync(statement).handle((ret, ex) -> { + Context.getInterpreter().evalLineBackgroundAsync(statement).handle((ret, ex) -> { if (LaserUEPanel.this.isShowing()){ if (ex != null){ showException((Exception)ex); diff --git a/plugins/MXSC-2.0.0.jar b/plugins/MXSC-2.0.0.jar new file mode 100644 index 0000000..25c92df Binary files /dev/null and b/plugins/MXSC-2.0.0.jar differ diff --git a/plugins/PuckDetectionPanel.java b/plugins/PuckDetectionPanel.java index e07dde6..e095a34 100644 --- a/plugins/PuckDetectionPanel.java +++ b/plugins/PuckDetectionPanel.java @@ -2,9 +2,9 @@ import ch.psi.mxsc.Puck; import ch.psi.mxsc.PuckDetection; import ch.psi.mxsc.PuckState; import ch.psi.mxsc.PuckState.SwitchState; -import ch.psi.pshell.core.Context; +import ch.psi.pshell.framework.Context; import ch.psi.pshell.swing.DevicePanel; -import ch.psi.utils.swing.SwingUtils; +import ch.psi.pshell.swing.SwingUtils; /** * @@ -54,7 +54,7 @@ public class PuckDetectionPanel extends DevicePanel { void execute(String statement, boolean showReturn){ try { - Context.getInstance().evalLineBackgroundAsync(statement).handle((ret, ex) -> { + Context.getInterpreter().evalLineBackgroundAsync(statement).handle((ret, ex) -> { if (ex != null){ showException((Exception)ex); } else if (showReturn){ diff --git a/plugins/Recovery.java b/plugins/Recovery.java index ee1e216..96c00aa 100644 --- a/plugins/Recovery.java +++ b/plugins/Recovery.java @@ -3,9 +3,10 @@ */ import ch.psi.pshell.device.Device; -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.utils.State; +import ch.psi.pshell.swing.SwingUtils; import java.awt.Color; import java.io.IOException; import java.util.List; @@ -26,7 +27,7 @@ public class Recovery extends Panel { //Overridable callbacks @Override public void onInitialize(int runCount) { - getContext().setGlobal("recovering", null); + Context.setGlobal("recovering", null); } @Override @@ -41,7 +42,7 @@ public class Recovery extends Panel { } void updateButton(){ - buttonRecover.setEnabled((getContext().getState().isNormal()) && + buttonRecover.setEnabled((Context.getState().isNormal()) && (textPosition.getText().trim().isEmpty()) && (!textSegment.getText().trim().isEmpty()) && !isRecovering() @@ -50,7 +51,7 @@ public class Recovery extends Panel { } boolean isRecovering(){ - return "true".equals(getContext().getGlobal("recovering")); + return "true".equals(Context.getGlobal("recovering")); } @Override @@ -62,7 +63,7 @@ public class Recovery extends Panel { @Override protected void onTimer() { System.out.println("."); - Device robot = getContext().getDevicePool().getByName("robot", Device.class); + Device robot = Context.getDevicePool().getByName("robot", Device.class); if ((robot==null) || (!robot.getState().isNormal())){ System.out.println("*"); ledValidSegment.setColor(Color.BLACK); @@ -225,27 +226,27 @@ public class Recovery extends Panel { return; } buttonAbort.setEnabled(true); - getContext().setGlobal("recovering", "true"); - Device robot = getContext().getDevicePool().getByName("robot", Device.class); + Context.setGlobal("recovering", "true"); + Device robot = Context.getDevicePool().getByName("robot", Device.class); abort(); - getContext().waitState(State.Ready, 5000); + Context.waitState(State.Ready, 5000); eval("robot.stop_task()", false); robot.waitReady(5000); evalAsync("recover()", false).handle((ret, ex) -> { if (ex != null){ - if (!getContext().isAborted()){ + if (!Context.isAborted()){ showException((Exception)ex); } } else { SwingUtils.showMessage(getTopLevel(), "Return", String.valueOf(ret)); } - getContext().setGlobal("recovering", null); + Context.setGlobal("recovering", null); buttonAbort.setEnabled(false); return ret; }); } catch (Exception ex) { showException(ex); - getContext().setGlobal("recovering", null); + Context.setGlobal("recovering", null); buttonAbort.setEnabled(false); } }//GEN-LAST:event_buttonRecoverActionPerformed diff --git a/plugins/RobotPanel.java b/plugins/RobotPanel.java index e841f57..5c54254 100644 --- a/plugins/RobotPanel.java +++ b/plugins/RobotPanel.java @@ -1,9 +1,9 @@ import ch.psi.pshell.device.Device; -import ch.psi.pshell.ui.App; +import ch.psi.pshell.app.App; import ch.psi.pshell.swing.DevicePanel; -import ch.psi.pshell.core.Context; -import ch.psi.utils.State; +import ch.psi.pshell.framework.Context; +import ch.psi.pshell.utils.State; import java.awt.Color; import java.util.Map; import javax.swing.JSpinner; @@ -162,7 +162,7 @@ public class RobotPanel extends DevicePanel { buttonEnable = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); - spinnerSpeed = new ch.psi.utils.swing.HorizontalSpinner(); + spinnerSpeed = new ch.psi.pshell.swing.HorizontalSpinner(); jLabel7 = new javax.swing.JLabel(); ledMoving = new ch.psi.pshell.swing.Led(); panelMotionCtr = new javax.swing.JPanel(); @@ -569,7 +569,7 @@ public class RobotPanel extends DevicePanel { private void buttonEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEnableActionPerformed try{ - Context.getInstance().evalLineBackground(getDevice().getName() + ".enable()"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".enable()"); } catch (Exception ex){ this.showException(ex); } @@ -577,7 +577,7 @@ public class RobotPanel extends DevicePanel { private void buttonDisableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDisableActionPerformed try{ - Context.getInstance().evalLineBackground(getDevice().getName() + ".disable()"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".disable()"); } catch (Exception ex){ this.showException(ex); } @@ -586,7 +586,7 @@ public class RobotPanel extends DevicePanel { private void spinnerSpeedStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerSpeedStateChanged try{ if (!updating){ - Context.getInstance().evalLineBackground(getDevice().getName() + ".set_monitor_speed(" + spinnerSpeed.getValue() + ")"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".set_monitor_speed(" + spinnerSpeed.getValue() + ")"); } } catch (Exception ex){ this.showException(ex); @@ -595,7 +595,7 @@ public class RobotPanel extends DevicePanel { private void butonStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonStopActionPerformed try{ - Context.getInstance().evalLineBackground(getDevice().getName() + ".reset_motion()"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".reset_motion()"); } catch (Exception ex){ this.showException(ex); } @@ -603,7 +603,7 @@ public class RobotPanel extends DevicePanel { private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed try{ - Context.getInstance().evalLineBackground(getDevice().getName() + ".stop()"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".stop()"); } catch (Exception ex){ this.showException(ex); } @@ -611,7 +611,7 @@ public class RobotPanel extends DevicePanel { private void buttonResumeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonResumeActionPerformed try{ - Context.getInstance().evalLineBackground(getDevice().getName() + ".resume()"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".resume()"); } catch (Exception ex){ this.showException(ex); } @@ -619,7 +619,7 @@ public class RobotPanel extends DevicePanel { private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed try{ - Context.getInstance().evalLineBackground(getDevice().getName() + ".stop_task()"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".stop_task()"); //Context.getInstance().evalLineBackground(getDevice().getName() + ".task_kill('" + textTask.getText() + "')"); } catch (Exception ex){ this.showException(ex); @@ -628,7 +628,7 @@ public class RobotPanel extends DevicePanel { private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseActionPerformed try{ - Context.getInstance().evalLineBackground(getDevice().getName() + ".close_tool()"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".close_tool()"); } catch (Exception ex){ this.showException(ex); } @@ -636,7 +636,7 @@ public class RobotPanel extends DevicePanel { private void buttonOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOpenActionPerformed try{ - Context.getInstance().evalLineBackground(getDevice().getName() + ".open_tool()"); + Context.getInterpreter().evalLineBackground(getDevice().getName() + ".open_tool()"); } catch (Exception ex){ this.showException(ex); } diff --git a/plugins/SmartMagnetPanel.java b/plugins/SmartMagnetPanel.java index 589fb82..9364632 100644 --- a/plugins/SmartMagnetPanel.java +++ b/plugins/SmartMagnetPanel.java @@ -1,9 +1,9 @@ import ch.psi.pshell.device.Device; -import ch.psi.pshell.ui.App; +import ch.psi.pshell.app.App; import ch.psi.pshell.swing.DevicePanel; -import ch.psi.pshell.core.Context; -import ch.psi.utils.State; +import ch.psi.pshell.framework.Context; +import ch.psi.pshell.utils.State; import java.awt.Color; import java.io.IOException; import java.lang.reflect.Method; @@ -275,7 +275,7 @@ public class SmartMagnetPanel extends DevicePanel { private void buttonSupressOnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSupressOnActionPerformed try { - Context.getInstance().evalLineBackground("smart_magnet.set_supress(True)"); + Context.getInterpreter().evalLineBackground("smart_magnet.set_supress(True)"); } catch (Exception ex) { Logger.getLogger(SmartMagnetPanel.class.getName()).log(Level.SEVERE, null, ex); } @@ -283,7 +283,7 @@ public class SmartMagnetPanel extends DevicePanel { private void buttonSupressOffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSupressOffActionPerformed try { - Context.getInstance().evalLineBackground("smart_magnet.set_supress(False)"); + Context.getInterpreter().evalLineBackground("smart_magnet.set_supress(False)"); } catch (Exception ex) { Logger.getLogger(SmartMagnetPanel.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/plugins/WagoPanel.java b/plugins/WagoPanel.java index cacadcd..9fd0843 100644 --- a/plugins/WagoPanel.java +++ b/plugins/WagoPanel.java @@ -1,5 +1,5 @@ import ch.psi.mxsc.Controller; -import ch.psi.pshell.core.Context; +import ch.psi.pshell.framework.Context; import ch.psi.pshell.swing.DevicePanel; import java.util.concurrent.CompletableFuture; import javax.swing.border.TitledBorder; @@ -38,7 +38,7 @@ public class WagoPanel extends DevicePanel { void execute(String statement){ try { - Context.getInstance().evalLineBackgroundAsync(statement).handle((ret, ex) -> { + Context.getInterpreter().evalLineBackgroundAsync(statement).handle((ret, ex) -> { if (WagoPanel.this.isShowing()){ if (ex != null){ showException((Exception)ex); diff --git a/plugins/gui.java b/plugins/gui.java index fe17ab2..d067796 100644 --- a/plugins/gui.java +++ b/plugins/gui.java @@ -2,8 +2,8 @@ * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. */ -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.util.logging.Level; import java.util.logging.Logger; diff --git a/script/data/pucks.py b/script/data/pucks.py index 61e8014..22dbeea 100644 --- a/script/data/pucks.py +++ b/script/data/pucks.py @@ -38,13 +38,13 @@ def clear_puck_info(): def save_puck_info(): data = get_puck_info() - output_file = open( get_context().setup.expandPath("{context}/pucks_info.json") , "w") + output_file = open( Setup.expandPath("{context}/pucks_info.json") , "w") output_file.write(json.dumps(data)) output_file.close() def restore_puck_info(): try: - inputfile = open(get_context().setup.expandPath("{context}/pucks_info.json"), "r") + inputfile = open(Setup.expandPath("{context}/pucks_info.json"), "r") info = json.loads(inputfile.read()) except: print >> sys.stderr, "Error reading pucks info file: " + str(sys.exc_info()[1]) diff --git a/script/data/samples.py b/script/data/samples.py index c290d14..eafa34c 100644 --- a/script/data/samples.py +++ b/script/data/samples.py @@ -38,16 +38,16 @@ def clear_samples_info(): def save_samples_info(): data = get_samples_info(True) - output_file = open( get_context().setup.expandPath("{context}/samples_info.json") , "w") + output_file = open( Setup.expandPath("{context}/samples_info.json") , "w") output_file.write(data) output_file.close() - get_context().sendEvent("samples_updated", True) + get_interpreter().sendEvent("samples_updated", True) save_puck_info() def restore_samples_info(): restore_puck_info() try: - inputfile = open(get_context().setup.expandPath("{context}/samples_info.json"), "r") + inputfile = open(Setup.expandPath("{context}/samples_info.json"), "r") info = inputfile.read() except: print >> sys.stderr, "Error reading sample info file: " + str(sys.exc_info()[1]) diff --git a/script/devices/Camera.py b/script/devices/Camera.py index eff3676..2829a72 100644 --- a/script/devices/Camera.py +++ b/script/devices/Camera.py @@ -15,7 +15,7 @@ img_stream.start() #show_panel(img_stream) def add_img(img_stream): img_stream.waitCacheChange(0) - if (img_stream.state == State.Busy) and (get_context().state.isActive()): + if (img_stream.state == State.Busy) and (Context.getState().isActive()): add_device(img_stream.getChild("image"), True) img = RegisterMatrixSource("img", image) #img = RegisterArraySource("img", image) diff --git a/script/devices/SmartMagnet.py b/script/devices/SmartMagnet.py index 75a4176..95dc700 100644 --- a/script/devices/SmartMagnet.py +++ b/script/devices/SmartMagnet.py @@ -1,6 +1,6 @@ class SmartMagnet(DeviceBase): def __init__(self, name): - #DeviceBase.__init__(self, name, get_context().pluginManager.getDynamicClass("SmartMagnetConfig")()) + #DeviceBase.__init__(self, name, get_plugin_manager().getDynamicClass("SmartMagnetConfig")()) DeviceBase.__init__(self, name, DeviceConfig({ "holdingCurrent":0.0, "restingCurrent":0.0, diff --git a/script/devices/VmbCamera.py b/script/devices/VmbCamera.py index 2dae6d6..bd146dc 100644 --- a/script/devices/VmbCamera.py +++ b/script/devices/VmbCamera.py @@ -42,7 +42,7 @@ class VmbCamera (CameraBase): def init_img(): try: self.stream.waitCacheChange(0) - if (self.stream.state == State.Busy) and (get_context().state.isActive()): + if (self.stream.state == State.Busy) and (Context.getState().isActive()): self.register = self.stream.getChild("image") self.image = RegisterMatrixSource(self.image_name , self.register) #self.image = RegisterArraySource(name, ) @@ -67,7 +67,7 @@ class VmbCamera (CameraBase): def wait_init(): try: self.waitStateNot(State.Disabled, -1) - if (self.stream.state == State.Busy) and (get_context().state.isActive()): + if (self.stream.state == State.Busy) and (Context.getState().isActive()): callback() except Exception as e: log(str(e)) diff --git a/script/imgproc/CoverCorrelation.py b/script/imgproc/CoverCorrelation.py index 9792c01..2f4b73e 100644 --- a/script/imgproc/CoverCorrelation.py +++ b/script/imgproc/CoverCorrelation.py @@ -5,8 +5,7 @@ add_mark = False #offset = 50 #add_mark = True - -Image_Correlator = get_context().getClassByName("Image_Correlator") +Image_Correlator = Context.getClassByName("Image_Correlator") correlator = Image_Correlator() def get_min(ip1): diff --git a/script/local.py b/script/local.py index 9bc74a9..e18a95d 100644 --- a/script/local.py +++ b/script/local.py @@ -1,73 +1,73 @@ -################################################################################################### -# Deployment specific global definitions - executed after startup.py -################################################################################################### -import traceback +################################################################################################### +# Deployment specific global definitions - executed after startup.py +################################################################################################### +import traceback import requests -from ch.psi.pshell.serial import TcpDevice -from ch.psi.pshell.modbus import ModbusTCP -import ch.psi.mxsc.Controller as Controller -import ch.psi.pshell.core.Nameable as Nameable -import ch.psi.utils.Chrono as Chrono -import ch.psi.mxsc.Controller as Controller - - - -run("setup/Layout") +from ch.psi.pshell.serial import TcpDevice +from ch.psi.pshell.modbus import ModbusTCP +import ch.psi.mxsc.Controller as Controller +import ch.psi.pshell.utils.Nameable as Nameable +import ch.psi.pshell.utils.Chrono as Chrono +import ch.psi.mxsc.Controller as Controller + + + +run("setup/Layout") run("data/reports") - - -################################################################################################### -# Configuration -################################################################################################### - -IMAGING_ENABLED_PREFERENCE = "imaging_enabled" -PUCK_TYPES_PREFERENCE = "puck_types" -BARCODE_READER_SCAN_PUCKS = "barcode_reader_scan_pucks" -ROOM_TEMPERATURE_ENABLED_PREFERENCE = "room_temperature_enabled" -BEAMLINE_STATUS_ENABLED_PREFERENCE = "beamline_status_enabled" -VALVE_CONTROL_ENABLED_PREFERENCE = "valve_control" + + +################################################################################################### +# Configuration +################################################################################################### + +IMAGING_ENABLED_PREFERENCE = "imaging_enabled" +PUCK_TYPES_PREFERENCE = "puck_types" +BARCODE_READER_SCAN_PUCKS = "barcode_reader_scan_pucks" +ROOM_TEMPERATURE_ENABLED_PREFERENCE = "room_temperature_enabled" +BEAMLINE_STATUS_ENABLED_PREFERENCE = "beamline_status_enabled" +VALVE_CONTROL_ENABLED_PREFERENCE = "valve_control" SERVICE_MODE_PREFERENCE = "service_mode" - -def is_imaging_enabled(): - setting = get_setting(IMAGING_ENABLED_PREFERENCE) - return not (str(setting).lower() == 'false') - -def set_imaging_enabled(value): - set_setting(IMAGING_ENABLED_PREFERENCE, (True if value else False) ) - -def assert_imaging_enabled(): - if is_imaging_enabled() == False: - raise Exception ("Imaging is disabled") - -#"unipuck", "minispine" or "mixed" -def set_puck_types(value): - set_setting(PUCK_TYPES_PREFERENCE, True if value else False ) - -def get_puck_types(): - setting = get_setting(PUCK_TYPES_PREFERENCE) - if setting == "unipuck" or setting == "minispine": - return setting - return "mixed" - - -def is_barcode_reader_scan_pucks(): - setting = get_setting(BARCODE_READER_SCAN_PUCKS) - return False if setting is None else setting.lower() == "true" - -def set_barcode_reader_scan_pucks(value): - set_setting(BARCODE_READER_SCAN_PUCKS, True if value else False ) - -def is_valve_controlled(): - setting = get_setting(VALVE_CONTROL_ENABLED_PREFERENCE) - return False if setting is None else setting.lower() == "true" - -def set_valve_controlled(value): - set_setting(VALVE_CONTROL_ENABLED_PREFERENCE, True if value else False ) - -def reset_mounted_sample_position(): - set_setting("mounted_sample_position", None) + +def is_imaging_enabled(): + setting = get_setting(IMAGING_ENABLED_PREFERENCE) + return not (str(setting).lower() == 'false') + +def set_imaging_enabled(value): + set_setting(IMAGING_ENABLED_PREFERENCE, (True if value else False) ) + +def assert_imaging_enabled(): + if is_imaging_enabled() == False: + raise Exception ("Imaging is disabled") + +#"unipuck", "minispine" or "mixed" +def set_puck_types(value): + set_setting(PUCK_TYPES_PREFERENCE, True if value else False ) + +def get_puck_types(): + setting = get_setting(PUCK_TYPES_PREFERENCE) + if setting == "unipuck" or setting == "minispine": + return setting + return "mixed" + + +def is_barcode_reader_scan_pucks(): + setting = get_setting(BARCODE_READER_SCAN_PUCKS) + return False if setting is None else setting.lower() == "true" + +def set_barcode_reader_scan_pucks(value): + set_setting(BARCODE_READER_SCAN_PUCKS, True if value else False ) + +def is_valve_controlled(): + setting = get_setting(VALVE_CONTROL_ENABLED_PREFERENCE) + return False if setting is None else setting.lower() == "true" + +def set_valve_controlled(value): + set_setting(VALVE_CONTROL_ENABLED_PREFERENCE, True if value else False ) + +def reset_mounted_sample_position(): + set_setting("mounted_sample_position", None) def is_service_mode(): setting = get_setting(SERVICE_MODE_PREFERENCE) @@ -79,55 +79,55 @@ def set_service_mode(value): - -def get_puck_barcode_reader(): - if is_barcode_reader_scan_pucks(): - return barcode_reader - else: - return barcode_reader_puck - -#In order to apply current config -set_imaging_enabled(is_imaging_enabled()) -set_puck_types(get_puck_types()) -set_barcode_reader_scan_pucks(is_barcode_reader_scan_pucks()) -set_valve_controlled(is_valve_controlled()) -if get_context().getRunCount() == 0: +def get_puck_barcode_reader(): + if is_barcode_reader_scan_pucks(): + return barcode_reader + else: + return barcode_reader_puck + +#In order to apply current config +set_imaging_enabled(is_imaging_enabled()) +set_puck_types(get_puck_types()) +set_barcode_reader_scan_pucks(is_barcode_reader_scan_pucks()) +set_valve_controlled(is_valve_controlled()) + +if Context.getRunCount() == 0: set_service_mode(False) #Always start in normal mode else: set_service_mode(is_service_mode()) - - -force_dry_mount_count = get_setting("force_dry_mount_count") -if force_dry_mount_count is None: - set_setting("force_dry_mount_count", 0) - -force_dry_timeout = get_setting("force_dry_timeout") -if force_dry_timeout is None: - set_setting("force_dry_timeout", 0) - + + +force_dry_mount_count = get_setting("force_dry_mount_count") +if force_dry_mount_count is None: + set_setting("force_dry_mount_count", 0) + +force_dry_timeout = get_setting("force_dry_timeout") +if force_dry_timeout is None: + set_setting("force_dry_timeout", 0) + cold_position_timeout = get_setting("cold_position_timeout") if cold_position_timeout is None: set_setting("cold_position_timeout", 0) - - -def is_room_temperature_enabled(): - setting = get_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE) - return str(setting).lower() == 'true' - -set_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE, is_room_temperature_enabled()) - - -def is_beamline_status_enabled(): - setting = get_setting(BEAMLINE_STATUS_ENABLED_PREFERENCE) - return str(setting).lower() == 'true' - -set_setting(BEAMLINE_STATUS_ENABLED_PREFERENCE, is_beamline_status_enabled()) - -################################################################################################### -# Scripted devices and pseudo-devices -################################################################################################### + + +def is_room_temperature_enabled(): + setting = get_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE) + return str(setting).lower() == 'true' + +set_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE, is_room_temperature_enabled()) + + +def is_beamline_status_enabled(): + setting = get_setting(BEAMLINE_STATUS_ENABLED_PREFERENCE) + return str(setting).lower() == 'true' + +set_setting(BEAMLINE_STATUS_ENABLED_PREFERENCE, is_beamline_status_enabled()) + +################################################################################################### +# Scripted devices and pseudo-devices +################################################################################################### @@ -136,12 +136,13 @@ scripted_devices = ["devices/RobotSC", "devices/Wago", "devices/BarcodeReader", "devices/VmbCamera", ] -for script in scripted_devices: - try: +for script in scripted_devices: + + try: print "Running: ", script - run(script) - except: - print >> sys.stderr, traceback.format_exc() + run(script) + except: + print >> sys.stderr, traceback.format_exc() @@ -154,184 +155,186 @@ def set_laser_pos(pos=None): def is_door_closed(): return feedback_psys_safety.take() - -################################################################################################### -# Utility modules -################################################################################################### - -run("data/samples") -run("data/pucks") -run("motion/tools") -run("motion/mount") -run("motion/unmount") -run("motion/get_dewar") -run("motion/put_dewar") -run("motion/get_gonio") -run("motion/put_gonio") -run("motion/move_dewar") -run("motion/move_gonio") -run("motion/move_heater") -run("motion/move_home") -run("motion/move_park") -run("motion/move_cold") -run("motion/move_scanner") -run("motion/move_aux") -run("motion/get_aux") -run("motion/put_aux") -run("motion/dry") -run("motion/trash") -run("motion/calibrate_tool") -run("motion/scan_pin") -run("motion/robot_recover") -run("motion/recover") -run("tools/Math") -if is_imaging_enabled(): - run("imgproc/Utils") - -def system_check(robot_move=True): - if not air_pressure_ok.read(): - raise Exception("Air pressure is not ok") - if not n2_pressure_ok.read(): - raise Exception("N2 pressure is not ok") - if robot_move: - if not feedback_local_safety.read(): - raise Exception("Local safety not released") - auto = not is_manual_mode() - if auto: - if not feedback_psys_safety.read(): - raise Exception("Psys safety not released") - #if not guiding_tool_park.read(): - # raise Exception("Guiding tool 1 not parked") + +################################################################################################### +# Utility modules +################################################################################################### + +run("data/samples") +run("data/pucks") +run("motion/tools") +run("motion/mount") +run("motion/unmount") +run("motion/get_dewar") +run("motion/put_dewar") +run("motion/get_gonio") +run("motion/put_gonio") +run("motion/move_dewar") +run("motion/move_gonio") +run("motion/move_heater") +run("motion/move_home") +run("motion/move_park") +run("motion/move_cold") +run("motion/move_scanner") +run("motion/move_aux") +run("motion/get_aux") +run("motion/put_aux") +run("motion/dry") +run("motion/trash") +run("motion/calibrate_tool") +run("motion/scan_pin") +run("motion/robot_recover") +run("motion/recover") +run("tools/Math") +if is_imaging_enabled(): + run("imgproc/Utils") + +def system_check(robot_move=True): + if not air_pressure_ok.read(): + raise Exception("Air pressure is not ok") + if not n2_pressure_ok.read(): + raise Exception("N2 pressure is not ok") + if robot_move: + if not feedback_local_safety.read(): + raise Exception("Local safety not released") + auto = not is_manual_mode() + if auto: + if not feedback_psys_safety.read(): + raise Exception("Psys safety not released") + #if not guiding_tool_park.read(): + # raise Exception("Guiding tool 1 not parked") #if not guiding_tool_park_2.read(): # raise Exception("Guiding tool 2 not parked") - -def system_check_msg(): - try: - system_check(True) - return "Ok" - except: - return sys.exc_info()[1] - -def get_puck_dev(segment, puck): - if type(segment) is int: - segment = chr( ord('A') + (segment-1)) - - return Controller.getInstance().getPuck(str(segment).upper() + str(puck)) - -def get_puck_elect_detection(segment, puck): - return str(get_puck_dev(segment, puck).detection) - -def get_puck_img_detection(segment, puck): - return str(Controller.getInstance().getPuck(str(segment).upper() + str(puck)).imageDetection) - -def assert_puck_detected(segment, puck): - if (segment == AUX_SEGMENT) and (puck == 1): - return - if get_puck_elect_detection(segment, puck) != "Present": - raise Exception ("Puck " + str(segment).upper() + str(puck) + " not present") - - -def start_puck_detection(): - run("tools/RestartPuckDetection") - -def check_puck_detection(): - return run("tools/CheckPuckDetection") - -def stop_puck_detection(): - run("tools/StopPuckDetection") - - - -def get_detected_pucks(): - ret = [] - for i in range(30): - p = BasePlate.getPucks()[i] - if (str(p.getDetection()) == "Present"): - ret.append(str(p.getName())) - return ret - -def get_pucks_info(): - ret = [] - for i in range(30): - p = BasePlate.getPucks()[i] - name = p.getName() - det = str(p.getDetection()) - barcode = "" if p.getId() is None else p.getId() - - ret.append({"puckAddress": name, "puckState": det, "puckBarcode":barcode}) - return json.dumps(ret) - - -################################################################################################### -# Device initialization -################################################################################################### - -try: - set_heater(False) - set_air_stream(False) - set_pin_cleaner(True) -except: - print >> sys.stderr, traceback.format_exc() - - -try: - release_local_safety.write(False) - release_psys_safety.write(False) -except: - print >> sys.stderr, traceback.format_exc() - -try: - robot.setPolling(DEFAULT_ROBOT_POLLING) - robot.set_tool(TOOL_DEFAULT) - robot.set_frame(FRAME_DEFAULT) - robot.set_motors_enabled(True) - robot.set_joint_motors_enabled(True) -except: - print >> sys.stderr, traceback.format_exc() -if is_imaging_enabled(): - try: +def system_check_msg(): + try: + system_check(True) + return "Ok" + except: + return sys.exc_info()[1] + +def get_puck_dev(segment, puck): + if type(segment) is int: + segment = chr( ord('A') + (segment-1)) + + return Controller.getInstance().getPuck(str(segment).upper() + str(puck)) + +def get_puck_elect_detection(segment, puck): + return str(get_puck_dev(segment, puck).detection) + +def get_puck_img_detection(segment, puck): + return str(Controller.getInstance().getPuck(str(segment).upper() + str(puck)).imageDetection) + +def assert_puck_detected(segment, puck): + if (segment == AUX_SEGMENT) and (puck == 1): + return + if get_puck_elect_detection(segment, puck) != "Present": + raise Exception ("Puck " + str(segment).upper() + str(puck) + " not present") + + +def start_puck_detection(): + run("tools/RestartPuckDetection") + +def check_puck_detection(): + return run("tools/CheckPuckDetection") + +def stop_puck_detection(): + run("tools/StopPuckDetection") + + + +def get_detected_pucks(): + ret = [] + for i in range(30): + p = BasePlate.getPucks()[i] + if (str(p.getDetection()) == "Present"): + ret.append(str(p.getName())) + return ret + +def get_pucks_info(): + ret = [] + for i in range(30): + p = BasePlate.getPucks()[i] + name = p.getName() + det = str(p.getDetection()) + barcode = "" if p.getId() is None else p.getId() + + ret.append({"puckAddress": name, "puckState": det, "puckBarcode":barcode}) + return json.dumps(ret) + + +################################################################################################### +# Device initialization +################################################################################################### + +try: + set_heater(False) + set_air_stream(False) + set_pin_cleaner(True) +except: + print >> sys.stderr, traceback.format_exc() + + +try: + release_local_safety.write(False) + release_psys_safety.write(False) +except: + print >> sys.stderr, traceback.format_exc() + + +try: + robot.setPolling(DEFAULT_ROBOT_POLLING) + robot.set_tool(TOOL_DEFAULT) + robot.set_frame(FRAME_DEFAULT) + robot.set_motors_enabled(True) + robot.set_joint_motors_enabled(True) +except: + print >> sys.stderr, traceback.format_exc() + +if is_imaging_enabled(): + try: cam.setGrabMode(Camera.GrabMode.Continuous) cam.setTriggerMode(Camera.TriggerMode.Fixed_Rate) cam.setAcquirePeriod(330.00) cam.setGain(0.0) - #cam.setROI(int(get_setting("roi_x")), int(get_setting("roi_y")), int(get_setting("roi_w")), int(get_setting("roi_h"))) - except: - print >> sys.stderr, traceback.format_exc() - -#TODO: The Smart Magnet keeps moving sample if detecting is enabled -# Detection keeps disabled unless during moount/unmount -try: - smart_magnet.set_supress(True) -except: - print >> sys.stderr, traceback.format_exc() - -#gripper_cam.paused = True -################################################################################################### -# Device monitoring -################################################################################################### - -DEWAR_LEVEL_RT = 5.0 -is_room_temperature = False - -def is_room_temp(): - return is_room_temperature - - -class DewarLevelListener (DeviceListener): - def onValueChanged(self, device, value, former): - global is_room_temperature - if value is not None: - is_room_temperature = value <= DEWAR_LEVEL_RT -dewar_level_listener = DewarLevelListener() - -for l in dewar_level.listeners: - #if isinstance(l, DewarLevelListener): #Class changes... - if Nameable.getShortClassName(l.getClass()) == "DewarLevelListener": - dewar_level.removeListener(l) - -dewar_level.addListener(dewar_level_listener) -dewar_level_listener.onValueChanged(dewar_level, dewar_level.take(), None) + #cam.setROI(int(get_setting("roi_x")), int(get_setting("roi_y")), int(get_setting("roi_w")), int(get_setting("roi_h"))) + + except: + print >> sys.stderr, traceback.format_exc() + +#TODO: The Smart Magnet keeps moving sample if detecting is enabled +# Detection keeps disabled unless during moount/unmount +try: + smart_magnet.set_supress(True) +except: + print >> sys.stderr, traceback.format_exc() + +#gripper_cam.paused = True +################################################################################################### +# Device monitoring +################################################################################################### + +DEWAR_LEVEL_RT = 5.0 +is_room_temperature = False + +def is_room_temp(): + return is_room_temperature + + +class DewarLevelListener (DeviceListener): + def onValueChanged(self, device, value, former): + global is_room_temperature + if value is not None: + is_room_temperature = value <= DEWAR_LEVEL_RT +dewar_level_listener = DewarLevelListener() + +for l in dewar_level.listeners: + #if isinstance(l, DewarLevelListener): #Class changes... + if Nameable.getShortClassName(l.getClass()) == "DewarLevelListener": + dewar_level.removeListener(l) + +dewar_level.addListener(dewar_level_listener) +dewar_level_listener.onValueChanged(dewar_level, dewar_level.take(), None) @@ -426,107 +429,106 @@ def invalidate_cover_info(cover_info): log("Invalidate cover location - Robot cleared in task continuation") cover_info[3]=CLEAR_STATUS_IN_TASK -################################################################################################### -# Global variables & application state -################################################################################################### - - -context = get_context() - -cover_detection_debug = False - -in_mount_position = False - - -def assert_mount_position(): - print "Source: ", get_exec_pars().source - if not in_mount_position and get_exec_pars().source == CommandSource.server : - raise Exception("Not in mount position") - +################################################################################################### +# Global variables & application state +################################################################################################### + + +cover_detection_debug = False + +in_mount_position = False + + +def assert_mount_position(): + print "Source: ", get_exec_pars().source + if not in_mount_position and get_exec_pars().source == CommandSource.server : + raise Exception("Not in mount position") + + """ -def is_puck_loading(): +def is_puck_loading(): guiding_tools_parked = guiding_tool_park.read() and guiding_tool_park_2.read() - return robot.state == State.Ready and robot.take()["pos"] == 'pPark' and \ - feedback_psys_safety.take() == False and \ + return robot.state == State.Ready and robot.take()["pos"] == 'pPark' and \ + feedback_psys_safety.take() == False and \ not guiding_tools_parked """ - -def set_pin_offset(val): - if abs(val) >5: - raise Exception("Invalid pin offset: " + str(val)) - try: - set_setting("pin_offset",float(val)) - except: - log("Error setting pin offset: " + str(sys.exc_info()[1]), False) - -def get_pin_offset(): - try: - ret = float(get_setting("pin_offset")) - if abs(ret) >5: - raise Exception("Invalid configured pin offset: " + str(ret)) - return ret - except: - log("Error getting pin offset: " + str(sys.exc_info()[1]), False) - return 0.0 - - -def set_pin_angle_offset(val): - if (abs(val) > 180.0) or (abs(val) < -180.0): - raise Exception("Invalid pin angle offset: " + str(val)) - try: - set_setting("pin_angle_offset",float(val)) - except: - log("Error setting pin angle offset: " + str(sys.exc_info()[1]), False) - -def get_pin_angle_offset(): - try: - ret = float(get_setting("pin_angle_offset")) - if (abs(ret) > 180.0) or (abs(ret) < -180.0): - raise Exception("Invalid configured pin angle offset: " + str(ret)) - return ret - except: - log("Error getting pin angle offset: " + str(sys.exc_info()[1]), False) - return 0.0 - -def is_force_dry(): - try: - dry_mount_counter = int(get_setting("dry_mount_counter")) - except: - dry_mount_counter = 0 - - try: - dry_timespan = time.time() - float( get_setting("dry_timestamp")) - except: - dry_timespan = 3600 - - try: - force_dry_mount_count = int(get_setting("force_dry_mount_count")) - if force_dry_mount_count>0 and dry_mount_counter>=force_dry_mount_count: - return True - except: - pass - - try: - force_dry_timeout = float(get_setting("force_dry_timeout")) - if force_dry_timeout>0 and dry_timespan>=force_dry_timeout: - return True - except: - pass + +def set_pin_offset(val): + if abs(val) >5: + raise Exception("Invalid pin offset: " + str(val)) + try: + set_setting("pin_offset",float(val)) + except: + log("Error setting pin offset: " + str(sys.exc_info()[1]), False) + +def get_pin_offset(): + try: + ret = float(get_setting("pin_offset")) + if abs(ret) >5: + raise Exception("Invalid configured pin offset: " + str(ret)) + return ret + except: + log("Error getting pin offset: " + str(sys.exc_info()[1]), False) + return 0.0 + + +def set_pin_angle_offset(val): + if (abs(val) > 180.0) or (abs(val) < -180.0): + raise Exception("Invalid pin angle offset: " + str(val)) + try: + set_setting("pin_angle_offset",float(val)) + except: + log("Error setting pin angle offset: " + str(sys.exc_info()[1]), False) + +def get_pin_angle_offset(): + try: + ret = float(get_setting("pin_angle_offset")) + if (abs(ret) > 180.0) or (abs(ret) < -180.0): + raise Exception("Invalid configured pin angle offset: " + str(ret)) + return ret + except: + log("Error getting pin angle offset: " + str(sys.exc_info()[1]), False) + return 0.0 + +def is_force_dry(): + try: + dry_mount_counter = int(get_setting("dry_mount_counter")) + except: + dry_mount_counter = 0 + + try: + dry_timespan = time.time() - float( get_setting("dry_timestamp")) + except: + dry_timespan = 3600 + + try: + force_dry_mount_count = int(get_setting("force_dry_mount_count")) + if force_dry_mount_count>0 and dry_mount_counter>=force_dry_mount_count: + return True + except: + pass + + try: + force_dry_timeout = float(get_setting("force_dry_timeout")) + if force_dry_timeout>0 and dry_timespan>=force_dry_timeout: + return True + except: + pass return False def assert_detector_safe(): pass - + def onPuckLoadingChange(puck_loading): set_led_state(puck_loading) - #pass + #pass - -update() -add_device(Controller.getInstance().basePlate, True) -restore_samples_info() - -print "Initialization complete" +update() +add_device(Controller.getInstance().basePlate, True) +restore_samples_info() + + +print "Initialization complete" \ No newline at end of file diff --git a/script/tasks/ColdPositionTimeout.py b/script/tasks/ColdPositionTimeout.py index 197e829..171a017 100644 --- a/script/tasks/ColdPositionTimeout.py +++ b/script/tasks/ColdPositionTimeout.py @@ -4,17 +4,17 @@ if cold_position_timeout > 0: if (time.time() - robot.last_command_timestamp) > cold_position_timeout: if robot.is_cold(): log("Detected cold position timeout", False) - if get_context().state == State.Ready: + if get_interpreter().state == State.Ready: if robot.state == State.Ready: if feedback_psys_safety.take() == True: #TODO: Chan - get_context().evalLine("dry(wait_cold = -1)") #Dry and park : use get_context().evalLine to change application state + get_interpreter().evalLine("dry(wait_cold = -1)") #Dry and park : use get_interpreter().evalLine to change application state else: raise Exception("Cannot clear cold position: feedback_psys_safety = False ") else: raise Exception("Cannot clear cold position: robot state: " + str(robot.state)) else: - raise Exception("Cannot clear cold position: system state: " + str(get_context().state)) + raise Exception("Cannot clear cold position: system state: " + str(get_interpreter().state)) diff --git a/script/test/TestBugPcAPI2.py b/script/test/TestBugPcAPI2.py index 5e92b37..b0cf7d6 100644 --- a/script/test/TestBugPcAPI2.py +++ b/script/test/TestBugPcAPI2.py @@ -1,5 +1,5 @@ import ch.psi.pshell.imaging.MjpegSource as MjpegSource -MjpegSource2 = get_context().pluginManager.getDynamicClass("MjpegSource2") +MjpegSource2 = get_plugin_manager().getDynamicClass("MjpegSource2") add_device(MjpegSource("gripper_cam", "http://axis-accc8e9cc87b.psi.ch/axis-cgi/mjpg/video.cgi"), True) #gripper_cam.polling=1000 gripper_cam.monitored = True diff --git a/script/test/TestCmdSynchronization.py b/script/test/TestCmdSynchronization.py index 098998d..ccc0ea7 100644 --- a/script/test/TestCmdSynchronization.py +++ b/script/test/TestCmdSynchronization.py @@ -5,7 +5,7 @@ def get_pos_str(): enable_motion() -get_context().setLogLevel(java.util.logging.Level.FINER) +Context.setLogLevel(java.util.logging.Level.FINER) try: while True: #robot.move_dewar() @@ -29,4 +29,4 @@ try: robot.assert_park() finally: - get_context().setLogLevel(java.util.logging.Level.INFO) \ No newline at end of file + Context.setLogLevel(java.util.logging.Level.INFO) \ No newline at end of file diff --git a/script/test/TestCorrelation.py b/script/test/TestCorrelation.py index b447276..59c9c5c 100644 --- a/script/test/TestCorrelation.py +++ b/script/test/TestCorrelation.py @@ -8,7 +8,7 @@ add_mark = False #add_mark = True -Image_Correlator = get_context().getClassByName("Image_Correlator") +Image_Correlator = Context.getClassByName("Image_Correlator") correlator = Image_Correlator() diff --git a/script/test/test_swingutils.py b/script/test/test_swingutils.py index 65b354b..e1cc9c1 100644 --- a/script/test/test_swingutils.py +++ b/script/test/test_swingutils.py @@ -1,7 +1,7 @@ import ch.psi.pshell.imaging.RendererMode as RendererMode import ch.psi.pshell.imaging.Calibration as Calibration from ch.psi.pshell.imaging.Overlays import * -import ch.psi.utils.swing.SwingUtils as SwingUtils +import ch.psi.pshell.swing.SwingUtils as SwingUtils import javax.swing.SwingUtilities as SwingUtilities from swingutils.threads.swing import callSwing