diff --git a/nbactions.xml b/nbactions.xml new file mode 100644 index 0000000..827cc3d --- /dev/null +++ b/nbactions.xml @@ -0,0 +1,46 @@ + + + + run + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + -classpath %classpath ch.psi.pshell.ui.App -p=ch.psi.mxsc.MainPanel -home=C:\dev\pshell\home -r + java + + + + debug + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ch.psi.pshell.ui.App -p=ch.psi.mxsc.MainPanel -home=C:\dev\pshell\home -r + java + true + + + + profile + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + -classpath %classpath ch.psi.pshell.ui.App -p=ch.psi.mxsc.MainPanel -home=C:\dev\pshell\home -r + java + + + diff --git a/pom.xml b/pom.xml index 57e6f57..7bf54db 100644 --- a/pom.xml +++ b/pom.xml @@ -10,25 +10,12 @@ ${project.groupId} pshell ${project.version} - - + - ch.sis - ch.sis.jhdf5 - 14.12.6 - - - ch.psi - jcae - 2.9.5 - - - ch.psi - bsread - 3.4.4 - + org.zeromq + jeromq + 0.4.0-PSI + UTF-8 @@ -36,22 +23,22 @@ 1.8 + - releases - releases - https://artifacts.psi.ch/artifactory/releases - + jcenter + jcenter + https://jcenter.bintray.com/ + - libs-releases - libs-releases - https://artifacts.psi.ch/artifactory/libs-releases-local - + bintray-hltools + bintray + https://dl.bintray.com/paulscherrerinstitute/hltools + - libs-snapshots - libs-snapshots - http://artifacts.psi.ch/artifactory/libs-snapshots-local - - + imagej + imagej + http://maven.imagej.net/content/repositories/public + MXSC @@ -65,7 +52,7 @@ maven-jar-plugin 2.3.1 - C:\Users\gac-S_Changer\Dev\PShell\home\plugins + C:\dev\pshell\home\plugins diff --git a/src/main/java/ch/psi/mxsc/BasePlate.java b/src/main/java/ch/psi/mxsc/BasePlate.java index 63b8c0b..e7f9cb8 100644 --- a/src/main/java/ch/psi/mxsc/BasePlate.java +++ b/src/main/java/ch/psi/mxsc/BasePlate.java @@ -15,37 +15,75 @@ import java.util.ArrayList; */ public class BasePlate extends DeviceBase { + public enum WiringSetup{ + natural, + sf + } + final static PointDouble[] pucksPosition = new PointDouble[]{ + /* new PointDouble(0, 75), new PointDouble(0, 150), new PointDouble(64.95, 187.5), new PointDouble(129.9, 150), - new PointDouble(64.95, 112.5), + new PointDouble(64.95, 112.5), new PointDouble(64.95, 37.5), new PointDouble(129.9, 75), new PointDouble(194.85, 37.5), new PointDouble(194.85, -37.5), - new PointDouble(129.9, 0), + new PointDouble(129.9, 0), new PointDouble(64.95, -37.5), new PointDouble(129.9, -75), new PointDouble(129.9, -150), new PointDouble(64.95, -187.5), - new PointDouble(64.95, -112.5), + new PointDouble(64.95, -112.5), new PointDouble(0, -75), new PointDouble(0, -150), new PointDouble(-64.95, -187.5), new PointDouble(-129.9, -150), - new PointDouble(-64.95, -112.5), + new PointDouble(-64.95, -112.5), new PointDouble(-64.95, -37.5), new PointDouble(-129.9, -75), new PointDouble(-194.85, -37.5), new PointDouble(-194.85, 37.5), - new PointDouble(-129.9, 0), + new PointDouble(-129.9, 0), new PointDouble(-64.95, 37.5), new PointDouble(-129.9, 75), new PointDouble(-129.9, 150), new PointDouble(-64.95, 187.5), new PointDouble(-64.95, 112.5) + */ + new PointDouble(0, 75), + new PointDouble(0, 150), + new PointDouble(-64.95, 112.5), + new PointDouble(-64.95, 187.5), + new PointDouble(-129.9, 150), + new PointDouble(-64.95, 37.5), + new PointDouble(-129.9, 75), + new PointDouble(-129.9, 0), + new PointDouble(-194.85, 37.5), + new PointDouble(-194.85, -37.5), + new PointDouble(-64.95, -37.5), + new PointDouble(-129.9, -75), + new PointDouble(-64.95, -112.5), + new PointDouble(-129.9, -150), + new PointDouble(-64.95, -187.5), + new PointDouble(0, -75), + new PointDouble(0, -150), + new PointDouble(64.95, -112.5), + new PointDouble(64.95, -187.5), + new PointDouble(129.9, -150), + new PointDouble(64.95, -37.5), + new PointDouble(129.9, -75), + new PointDouble(129.9, 0), + new PointDouble(194.85, -37.5), + new PointDouble(194.85, 37.5), + new PointDouble(64.95, 37.5), + new PointDouble(129.9, 75), + new PointDouble(64.95, 112.5), + new PointDouble(129.9, 150), + new PointDouble(64.95, 187.5), + }; final static int numberOfPucks = pucksPosition.length; //final static DimensionDouble size = new DimensionDouble(580.0, 580.0); diff --git a/src/main/java/ch/psi/mxsc/Controller.java b/src/main/java/ch/psi/mxsc/Controller.java index 961a345..6e40071 100644 --- a/src/main/java/ch/psi/mxsc/Controller.java +++ b/src/main/java/ch/psi/mxsc/Controller.java @@ -47,6 +47,7 @@ public class Controller { final /*Panel*/ MainPanel mainFrame; Device hexiposi; Device barcode_reader; + Device barcode_reader_puck; Device puck_detection; JDialog dialogAskPuckDatamatrix; String currentMountedSample; @@ -235,6 +236,7 @@ public class Controller { setPuckLoading(isPuckLoading()); } catch (Exception ex) { setPuckLoading(false); + Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex); } refreshSamplesTable(); } @@ -259,6 +261,18 @@ public class Controller { } } }; + + final DeviceListener barcodeReaderPuckListener = new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + if (value != null) { //Keep last value + String valStr = value.toString().trim(); + if (puckLoading) { + onPuckBarcode(valStr); + } + } + } + }; final DeviceListener puckDetectionListener = new DeviceAdapter() { @Override @@ -292,6 +306,12 @@ public class Controller { } else { Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, "No barcode_reader detected."); } + barcode_reader_puck = (Device) getDevice("barcode_reader_puck"); + if (barcode_reader_puck != null) { + barcode_reader_puck.addListener(barcodeReaderPuckListener); + } else { + Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, "No barcode_reader_puck detected."); + } puck_detection = (Device) getDevice("puck_detection"); if (puck_detection != null) { puck_detection.addListener(puckDetectionListener); @@ -393,6 +413,14 @@ public class Controller { } } + public Device getPuckBarcodeReader() { + try { + return (Device) getMainFrame().eval("get_puck_barcode_reader()", true); + } catch (Exception ex) { + return null; + } + } + public Boolean isPuckLoading() { try { return getMainFrame().eval("is_puck_loading()", true).equals(true); @@ -544,18 +572,20 @@ public class Controller { //synchronized(samplesTableLock){ SwingUtilities.invokeLater(() -> { try { - String json = (String) Context.getInstance().evalLineBackground("get_samples_info()"); - if (!json.equals(samplesTableJson)) { - samplesTableJson = json; + if (Context.getInstance().getState().isInitialized()){ + String json = (String) Context.getInstance().evalLineBackground("get_samples_info()"); + if (!json.equals(samplesTableJson)) { + samplesTableJson = json; - //SamplesInfo sampleInfo = (SamplesInfo) JsonSerializer.decode(json, SampleInfo.class); - SampleInfo[] samples = (SampleInfo[]) JsonSerializer.decode(json, SampleInfo[].class); + //SamplesInfo sampleInfo = (SamplesInfo) JsonSerializer.decode(json, SampleInfo.class); + SampleInfo[] samples = (SampleInfo[]) JsonSerializer.decode(json, SampleInfo[].class); - Object[][] sampleData = new Object[samples.length][]; - for (int i = 0; i < samples.length; i++) { - sampleData[i] = samples[i].getData(); + Object[][] sampleData = new Object[samples.length][]; + for (int i = 0; i < samples.length; i++) { + sampleData[i] = samples[i].getData(); + } + getMainFrame().setSamplesTable(sampleData); } - getMainFrame().setSamplesTable(sampleData); } } catch (Exception ex) { clearSamplesTable(); @@ -584,14 +614,16 @@ public class Controller { } puckLoading = value; getMainFrame().setPuckDatamatrix(null); - if (isBarcodeReaderScanPucks()) { + Device reader = getPuckBarcodeReader(); + if (reader!=null) { + String name = reader.getName(); if (puckLoading) { - execute("barcode_reader.enable()", true); - execute("barcode_reader.polling = 100", true); + execute(name + ".enable()", true); + execute(name + ".polling = 100", true); currentDetection = basePlate.getDetection(); } else if (getState().isInitialized()) { - execute("barcode_reader.polling = 0", true); - execute("barcode_reader.disable()", true); + execute(name + ".polling = 0", true); + execute(name + ".disable()", true); getMainFrame().setPuckDatamatrix(null); } } diff --git a/src/main/java/ch/psi/mxsc/MainPanel.java b/src/main/java/ch/psi/mxsc/MainPanel.java index 806e551..709b10c 100644 --- a/src/main/java/ch/psi/mxsc/MainPanel.java +++ b/src/main/java/ch/psi/mxsc/MainPanel.java @@ -205,31 +205,35 @@ public class MainPanel extends Panel { @Override protected void onTimer() { - devicesPanel.update(); - try { - roomTemperature = Controller.getInstance().isRoomTemp(); - ledRoomTemperature.setColor(roomTemperature ? Color.YELLOW : Color.GREEN); - labelRoomTemperature.setText(roomTemperature ? "Room Temperature" : "Cryo Operation"); + try{ + devicesPanel.update(); try { - ledHeaterOk.setColor(roomTemperature ? Color.GREEN : (((Double) panelHeaterTemp.getDevice().take()) < 20.0 ? Color.RED : Color.GREEN)); + roomTemperature = Controller.getInstance().isRoomTemp(); + ledRoomTemperature.setColor(roomTemperature ? Color.YELLOW : Color.GREEN); + labelRoomTemperature.setText(roomTemperature ? "Room Temperature" : "Cryo Operation"); + try { + ledHeaterOk.setColor(roomTemperature ? Color.GREEN : (((Double) panelHeaterTemp.getDevice().take()) < 20.0 ? Color.RED : Color.GREEN)); + } catch (Exception ex) { + ledHeaterOk.setColor(Color.BLACK); + } } catch (Exception ex) { - ledHeaterOk.setColor(Color.BLACK); + roomTemperature = null; + ledRoomTemperature.setColor(Color.BLACK); + labelRoomTemperature.setText("Room Temperature"); } - } catch (Exception ex) { - roomTemperature = null; - ledRoomTemperature.setColor(Color.BLACK); - labelRoomTemperature.setText("Room Temperature"); - } - Controller.getInstance().onTimer(); - if (getState() == State.Ready) { - if (Boolean.TRUE.equals(Controller.getInstance().puckLoading)) { - getView().getStatusBar().setStatusMessage(PUCK_LOADING_STATUS); - } else { - if (PUCK_LOADING_STATUS.equals(getView().getStatusBar().getStatusLabel().getText())) { - getView().getStatusBar().setApplicationState(getState()); + Controller.getInstance().onTimer(); + if (getState() == State.Ready) { + if (Boolean.TRUE.equals(Controller.getInstance().puckLoading)) { + getView().getStatusBar().setStatusMessage(PUCK_LOADING_STATUS); + } else { + if (PUCK_LOADING_STATUS.equals(getView().getStatusBar().getStatusLabel().getText())) { + getView().getStatusBar().setApplicationState(getState()); + } } } - } + } catch (Exception ex) { + getLogger().log(Level.WARNING, null, ex); + } } void refresh() { @@ -324,6 +328,7 @@ public class MainPanel extends Panel { void execute(String statement, boolean background, boolean showReturn) { try { + getLogger().log(Level.INFO, "Execute: " + statement + (background ? "&" : "")); evalAsync(statement, background).handle((ret, ex) -> { if (ex != null) { showException((Exception) ex); @@ -339,6 +344,7 @@ public class MainPanel extends Panel { void execute(String script, Object args, boolean background, boolean showReturn) { try { + getLogger().log(Level.INFO, "Execute: " + script + (background ? "&" : "")); runAsync(script, args, background).handle((ret, ex) -> { if (ex != null) { showException((Exception) ex); diff --git a/src/main/java/ch/psi/mxsc/Puck.java b/src/main/java/ch/psi/mxsc/Puck.java index 629e580..dcacbee 100644 --- a/src/main/java/ch/psi/mxsc/Puck.java +++ b/src/main/java/ch/psi/mxsc/Puck.java @@ -34,6 +34,7 @@ public class Puck extends DeviceBase { new PointDouble(-28.39445573 * signalX, 44.18263554) }; + /* static final Character[] SEGMENTS = new Character[]{'A', 'A', 'F', 'F', 'F', 'F', 'F', 'E', 'E', 'E', 'E', 'E', @@ -47,7 +48,7 @@ public class Puck extends DeviceBase { 5, 4, 3, 1, 2, 5, 4, 3, 1, 2, 5, 4, 3, 1, 2, - 5, 4, 3}; + 5, 4, 3}; static final int[] ADDRESSES = new int[]{6, 7, 5, 4, 3, 1, 2, 20, 19, 18, 16, 17, @@ -55,14 +56,48 @@ public class Puck extends DeviceBase { 30, 29, 28, 26, 27, 25, 24, 23, 21, 22, 10, 9, 8}; - static final double[] ANGLES = new double[]{ 0.00, 0.00, 19.11, 40.89, 30.00, 60.00, 60.00, 79.11, 100.89, 90.00, 120.00, 120.00, 139.11, 160.89, 150.00, 180.00, 180.00, 199.11, 220.89, 210.00, 240.00, 240.00, 259.11, 280.89, 270.00, - 300.00, 300.00, 319.11, 340.89, 330.00}; + 300.00, 300.00, 319.11, 340.89, 330.00}; + */ + + static final Character[] SEGMENTS = new Character[]{ + 'A', 'A','A', 'A', 'A', + 'B', 'B', 'B', 'B', 'B', + 'C', 'C', 'C', 'C', 'C', + 'D', 'D', 'D', 'D', 'D', + 'E', 'E', 'E', 'E', 'E', + 'F', 'F', 'F', 'F', 'F', + }; + static final int[] NUMBERS = new int[]{ + 1, 2, 3, 4, 5, + 1, 2, 3, 4, 5, + 1, 2, 3, 4, 5, + 1, 2, 3, 4, 5, + 1, 2, 3, 4, 5, + 1, 2, 3, 4, 5, + }; + static final int[] ADDRESSES = new int[]{ + 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30 + }; + + static final double[] ANGLES = new double[]{ + 0.00, 0.00, 330.00, 340.89, 319.11, + 300.00, 300.00, 270.00, 280.89, 259.11, + 240.00, 240.00, 210.00, 220.89, 199.11, + 180.00, 180.00, 150.00, 160.89, 139.11, + 120.00, 120.00, 90.00, 100.89, 79.11, + 60.00, 60.00, 30.00, 40.89, 19.11 + }; final static PointDouble referencePosition = new PointDouble(0.0, -66.9 - 0.2); final static Double referenceSize = 6.2 + 0.2;