Migrate to PShell 2.0
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
package ch.psi.mxsc;
|
||||
|
||||
import ch.psi.mxsc.BasePlatePanel.SelectionMode;
|
||||
import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.core.Plugin;
|
||||
import ch.psi.pshell.framework.Context;
|
||||
import ch.psi.pshell.plugin.Plugin;
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.device.DeviceAdapter;
|
||||
import ch.psi.pshell.device.DeviceListener;
|
||||
import ch.psi.pshell.device.DeviceBase;
|
||||
import ch.psi.pshell.device.DeviceListener;
|
||||
import ch.psi.pshell.device.GenericDevice;
|
||||
@@ -16,16 +16,17 @@ import ch.psi.pshell.imaging.Renderer;
|
||||
import ch.psi.pshell.imaging.RendererMode;
|
||||
import ch.psi.pshell.imaging.Source;
|
||||
import ch.psi.pshell.scripting.ViewPreference;
|
||||
import ch.psi.pshell.ui.App;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.StatusBar;
|
||||
import ch.psi.utils.Chrono;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.Document;
|
||||
import ch.psi.utils.swing.DocumentListener;
|
||||
import ch.psi.utils.swing.Editor;
|
||||
import ch.psi.utils.swing.JsonTableEditor;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.pshell.framework.App;
|
||||
import ch.psi.pshell.framework.Panel;
|
||||
import ch.psi.pshell.framework.Setup;
|
||||
import ch.psi.pshell.framework.StatusBar;
|
||||
import ch.psi.pshell.utils.Chrono;
|
||||
import ch.psi.pshell.utils.State;
|
||||
import ch.psi.pshell.swing.Document;
|
||||
import ch.psi.pshell.swing.DocumentListener;
|
||||
import ch.psi.pshell.swing.Editor;
|
||||
import ch.psi.pshell.swing.JsonTableEditor;
|
||||
import ch.psi.pshell.swing.SwingUtils;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@@ -89,18 +90,18 @@ public class MainPanel extends Panel {
|
||||
rt
|
||||
}
|
||||
public static final BasePlateLayout BASE_PLATE_LAYOUT =
|
||||
App.hasArgument("sf") ? BasePlateLayout.sf :
|
||||
( App.hasArgument("6d") ? BasePlateLayout.x06da :
|
||||
( App.hasArgument("rt") ? BasePlateLayout.rt : BasePlateLayout.normal)
|
||||
App.hasAdditionalArgument("sf") ? BasePlateLayout.sf :
|
||||
( App.hasAdditionalArgument("6d") ? BasePlateLayout.x06da :
|
||||
( App.hasAdditionalArgument("rt") ? BasePlateLayout.rt : BasePlateLayout.normal)
|
||||
);
|
||||
|
||||
public static boolean isRt(){
|
||||
return App.hasArgument("rt");
|
||||
return App.hasAdditionalArgument("rt");
|
||||
}
|
||||
|
||||
public MainPanel() {
|
||||
initComponents();
|
||||
getContext().getPluginManager().addDynamicClass(PuckDetection.class);
|
||||
Context.getPluginManager().addDynamicClass(PuckDetection.class);
|
||||
Controller.createInstance(this);
|
||||
basePlatePanel.setMode(BasePlatePanel.Mode.single);
|
||||
setExpertMode(false);
|
||||
@@ -285,7 +286,7 @@ public class MainPanel extends Panel {
|
||||
|
||||
@Override
|
||||
protected void onLoaded() {
|
||||
if (App.isDetached()) {
|
||||
if (Setup.isDetached()) {
|
||||
Image img = new ImageIcon(this.getClass().getResource("/apple_transparent_white_100x50.png")).getImage();
|
||||
SwingUtils.getWindow(this).setIconImage(img);
|
||||
}
|
||||
@@ -365,7 +366,7 @@ public class MainPanel extends Panel {
|
||||
}
|
||||
try {
|
||||
devicesPanel.initialize();
|
||||
((Device) getDevice("dewar_level")).addListener(new DeviceAdapter() {
|
||||
((Device) getDevice("dewar_level")).addListener(new DeviceListener() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateLevel(value);
|
||||
@@ -373,7 +374,7 @@ public class MainPanel extends Panel {
|
||||
});
|
||||
updateLevel(((Device) getDevice("dewar_level")).take());
|
||||
|
||||
((Device) getDevice("air_pressure_ok")).addListener(new DeviceAdapter() {
|
||||
((Device) getDevice("air_pressure_ok")).addListener(new DeviceListener() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateAirPressure(value);
|
||||
@@ -381,7 +382,7 @@ public class MainPanel extends Panel {
|
||||
});
|
||||
updateAirPressure(((Device) getDevice("air_pressure_ok")).take());
|
||||
|
||||
((Device) getDevice("n2_pressure_ok")).addListener(new DeviceAdapter() {
|
||||
((Device) getDevice("n2_pressure_ok")).addListener(new DeviceListener() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateN2Pressure(value);
|
||||
@@ -389,7 +390,7 @@ public class MainPanel extends Panel {
|
||||
});
|
||||
updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take());
|
||||
|
||||
((Device) getDevice("feedback_local_safety")).addListener(new DeviceAdapter() {
|
||||
((Device) getDevice("feedback_local_safety")).addListener(new DeviceListener() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateLocalSafety(value);
|
||||
@@ -399,7 +400,7 @@ public class MainPanel extends Panel {
|
||||
|
||||
updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take());
|
||||
|
||||
((Device) getDevice("gripper_dryer")).addListener(new DeviceAdapter() {
|
||||
((Device) getDevice("gripper_dryer")).addListener(new DeviceListener() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateDryer(value);
|
||||
@@ -408,7 +409,7 @@ public class MainPanel extends Panel {
|
||||
updateDryer(((Device) getDevice("gripper_dryer")).take());
|
||||
|
||||
Device feedback_psys_safety = ((Device) getDevice("feedback_psys_safety"));
|
||||
feedback_psys_safety.addListener(new DeviceAdapter() {
|
||||
feedback_psys_safety.addListener(new DeviceListener() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
doorsHaveOpened = Boolean.FALSE.equals(value);
|
||||
@@ -417,7 +418,7 @@ public class MainPanel extends Panel {
|
||||
});
|
||||
feedback_psys_safety.request();
|
||||
updatePsysSafety(((Device) getDevice("feedback_psys_safety")).take());
|
||||
((Device) getDevice("robot")).addListener(new DeviceAdapter() {
|
||||
((Device) getDevice("robot")).addListener(new DeviceListener() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateMode(value);
|
||||
@@ -522,7 +523,7 @@ public class MainPanel extends Panel {
|
||||
void setStatus(String status) {
|
||||
String current = current = (statusBar==null) ? this.status : statusBar.getStatusLabel().getText();
|
||||
if (!status.equals(current)) {
|
||||
getContext().setPreference(ViewPreference.STATUS, status);
|
||||
Context.getInterpreter().setPreference(ViewPreference.STATUS, status);
|
||||
}
|
||||
this.status = status;
|
||||
}
|
||||
@@ -856,7 +857,7 @@ public class MainPanel extends Panel {
|
||||
// buttonDrawing.setSelected(false);
|
||||
// updateViewType();
|
||||
} else {
|
||||
checkService.setSelected( Controller.getInstance().isServiceMode());
|
||||
checkService.setSelected( Boolean.TRUE.equals(Controller.getInstance().isServiceMode()));
|
||||
}
|
||||
if (current != expert) {
|
||||
onModeChange(expert);
|
||||
@@ -870,11 +871,11 @@ public class MainPanel extends Panel {
|
||||
|
||||
Panel showCommandsPanel() {
|
||||
if (commandsPlugin != null) {
|
||||
getContext().getPluginManager().unloadPlugin(commandsPlugin);
|
||||
Context.getPluginManager().unloadPlugin(commandsPlugin);
|
||||
}
|
||||
commandsPlugin = getContext().getPluginManager().loadPlugin(getContext().getSetup().expandPath("{plugins}/Commands.java"));
|
||||
commandsPlugin = Context.getPluginManager().loadPlugin(Setup.expandPath("{plugins}/Commands.java"));
|
||||
((Panel) commandsPlugin).setDetached(true, getTopLevel());
|
||||
getContext().getPluginManager().initializePlugin(commandsPlugin);
|
||||
Context.getPluginManager().initializePlugin(commandsPlugin);
|
||||
return ((Panel) commandsPlugin);
|
||||
}
|
||||
|
||||
@@ -882,11 +883,11 @@ public class MainPanel extends Panel {
|
||||
|
||||
Panel showRecoveryPanel() {
|
||||
if (recoveryPlugin != null) {
|
||||
getContext().getPluginManager().unloadPlugin(recoveryPlugin);
|
||||
Context.getPluginManager().unloadPlugin(recoveryPlugin);
|
||||
}
|
||||
recoveryPlugin = getContext().getPluginManager().loadPlugin(getContext().getSetup().expandPath("{plugins}/Recovery.java"));
|
||||
recoveryPlugin = Context.getPluginManager().loadPlugin(Setup.expandPath("{plugins}/Recovery.java"));
|
||||
((Panel) recoveryPlugin).setDetached(true, getTopLevel());
|
||||
getContext().getPluginManager().initializePlugin(recoveryPlugin);
|
||||
Context.getPluginManager().initializePlugin(recoveryPlugin);
|
||||
return ((Panel) recoveryPlugin);
|
||||
}
|
||||
|
||||
@@ -1036,7 +1037,7 @@ public class MainPanel extends Panel {
|
||||
|
||||
JsonTableEditor openSamplesInfo(){
|
||||
try{
|
||||
String file = getContext().getSetup().expandPath("{context}/samples_info.json");
|
||||
String file = Setup.expandPath("{context}/samples_info.json");
|
||||
if (getView()!=null){
|
||||
for (Editor ed : getView().getEditors()) {
|
||||
if (ed instanceof JsonTableEditor) {
|
||||
@@ -1117,7 +1118,7 @@ public class MainPanel extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
final DeviceListener cover_detection_listener = new DeviceAdapter() {
|
||||
final DeviceListener cover_detection_listener = new DeviceListener() {
|
||||
@Override
|
||||
public void onCacheChanged(Device device, Object value, Object former, long timestamp, boolean valueChange) {
|
||||
Point mm = null;
|
||||
|
||||
Reference in New Issue
Block a user