This commit is contained in:
gac-S_Changer
2018-12-14 15:25:26 +01:00
parent 8e0046d976
commit cffd5e7619
6 changed files with 218 additions and 74 deletions

46
nbactions.xml Normal file
View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath ch.psi.pshell.ui.App -p=ch.psi.mxsc.MainPanel -home=C:\dev\pshell\home -r</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-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</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath ch.psi.pshell.ui.App -p=ch.psi.mxsc.MainPanel -home=C:\dev\pshell\home -r</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
</actions>

51
pom.xml
View File

@@ -10,25 +10,12 @@
<groupId>${project.groupId}</groupId>
<artifactId>pshell</artifactId>
<version>${project.version}</version>
</dependency>
<!-- TODO:
Remove these dependecies when jhdf5 & jcae are in centralized repo.
-->
</dependency>
<dependency>
<groupId>ch.sis</groupId>
<artifactId>ch.sis.jhdf5</artifactId>
<version>14.12.6</version>
</dependency>
<dependency>
<groupId>ch.psi</groupId>
<artifactId>jcae</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>ch.psi</groupId>
<artifactId>bsread</artifactId>
<version>3.4.4</version>
</dependency>
<groupId>org.zeromq</groupId>
<artifactId>jeromq</artifactId>
<version>0.4.0-PSI</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -36,22 +23,22 @@
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>releases</id>
<name>releases</name>
<url>https://artifacts.psi.ch/artifactory/releases</url>
</repository>
<id>jcenter</id>
<name>jcenter</name>
<url>https://jcenter.bintray.com/</url>
</repository>
<repository>
<id>libs-releases</id>
<name>libs-releases</name>
<url>https://artifacts.psi.ch/artifactory/libs-releases-local</url>
</repository>
<id>bintray-hltools</id>
<name>bintray</name>
<url>https://dl.bintray.com/paulscherrerinstitute/hltools</url>
</repository>
<repository>
<id>libs-snapshots</id>
<name>libs-snapshots</name>
<url>http://artifacts.psi.ch/artifactory/libs-snapshots-local</url>
</repository>
<id>imagej</id>
<name>imagej</name>
<url>http://maven.imagej.net/content/repositories/public</url>
</repository>
</repositories>
<name>MXSC</name>
@@ -65,7 +52,7 @@
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>C:\Users\gac-S_Changer\Dev\PShell\home\plugins</outputDirectory>
<outputDirectory>C:\dev\pshell\home\plugins</outputDirectory>
</configuration>
</plugin>
</plugins>

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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;