This commit is contained in:
@@ -89,7 +89,15 @@ public class BasePlate extends DeviceBase {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Puck.Detection[] getDetection(){
|
||||
Puck.Detection[] ret = new Puck.Detection[Controller.NUMBER_OF_PUCKS];
|
||||
for (int i=0; i<ret.length;i++){
|
||||
ret[i] = getPucks()[i].detection;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Sample getSelectedSample(){
|
||||
Puck puck = getSelectedPuck();
|
||||
if (puck != null){
|
||||
|
||||
@@ -271,6 +271,15 @@ public class Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Boolean isBarcodeReaderScanPucks() {
|
||||
try {
|
||||
return getMainFrame().eval("is_barcode_reader_scan_pucks()", true).equals(true);
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isPuckLoading() {
|
||||
try {
|
||||
return getMainFrame().eval("is_puck_loading()", true).equals(true);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package ch.psi.mxsc;
|
||||
|
||||
import ch.psi.mxsc.BasePlatePanel.SelectionMode;
|
||||
import ch.psi.mxsc.Puck.Detection;
|
||||
import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.core.JsonSerializer;
|
||||
import ch.psi.pshell.core.Plugin;
|
||||
@@ -12,7 +13,6 @@ import ch.psi.pshell.device.DeviceAdapter;
|
||||
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.utils.State;
|
||||
@@ -26,13 +26,11 @@ import java.awt.GridBagLayout;
|
||||
import java.awt.Image;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
@@ -162,12 +160,27 @@ public class MainPanel extends Panel {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
if (value!=null){ //Keep last value
|
||||
textSampleDatamatrix.setText((value==null) ? "" : value.toString());
|
||||
String valStr = value.toString().trim();
|
||||
if (puckLoading && Controller.getInstance().isBarcodeReaderScanPucks()){
|
||||
onPuckBarcode(valStr);
|
||||
} else {
|
||||
textSampleDatamatrix.setText(valStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
textPuckDatamatrix.setText("");
|
||||
textSampleDatamatrix.setText("");
|
||||
|
||||
|
||||
((Device) getDevice("puck_detection")).addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
if (value!=null){ //Keep last value
|
||||
onPuckDetectionChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
this.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -203,9 +216,9 @@ public class MainPanel extends Panel {
|
||||
}
|
||||
|
||||
try {
|
||||
puckLoading = Controller.getInstance().isPuckLoading();
|
||||
setPuckLoading(Controller.getInstance().isPuckLoading());
|
||||
} catch (Exception ex) {
|
||||
puckLoading = null;
|
||||
setPuckLoading(false);
|
||||
}
|
||||
if (getState()==State.Ready){
|
||||
if (Boolean.TRUE.equals(puckLoading)){
|
||||
@@ -496,6 +509,53 @@ public class MainPanel extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////// Puck Loading /////////////////////////////////
|
||||
|
||||
Detection[] currentDetection;
|
||||
void setPuckLoading(Boolean value){
|
||||
if (value==null){
|
||||
value = false;
|
||||
}
|
||||
if (value != puckLoading){
|
||||
puckLoading = value;
|
||||
textPuckDatamatrix.setText("");
|
||||
if (Controller.getInstance().isBarcodeReaderScanPucks()){
|
||||
if (puckLoading){
|
||||
execute("barcode_reader.enable()", true);
|
||||
execute("barcode_reader.polling = 100", true);
|
||||
currentDetection = Controller.getInstance().basePlate.getDetection();
|
||||
} else if (getState().isInitialized()){
|
||||
execute("barcode_reader.polling = 0", true);
|
||||
execute("barcode_reader.disable()", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onPuckBarcode(String datamatrix){
|
||||
if (puckLoading){
|
||||
textPuckDatamatrix.setText(datamatrix);
|
||||
System.out.println(datamatrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onPuckDetectionChanged(){
|
||||
if (puckLoading){
|
||||
String datamatrix = textPuckDatamatrix.getText().trim();
|
||||
Detection[] detection = Controller.getInstance().basePlate.getDetection();
|
||||
if (!datamatrix.isEmpty()){
|
||||
for (int i=0; i< Controller.NUMBER_OF_PUCKS; i++){
|
||||
if ((currentDetection[i] != Detection.Present) && (detection[i] == Detection.Present)){
|
||||
System.out.println("Detected puck " + datamatrix + " at position " + Controller.getInstance().basePlate.getPucks()[i].getName());
|
||||
textPuckDatamatrix.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
currentDetection = detection;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ch.psi.mxsc;
|
||||
|
||||
import static ch.psi.mxsc.Controller.NUMBER_OF_PUCKS;
|
||||
import ch.psi.pshell.core.JsonSerializer;
|
||||
import ch.psi.pshell.device.DeviceBase;
|
||||
import ch.psi.utils.Chrono;
|
||||
@@ -8,6 +9,7 @@ import ch.psi.utils.Threading;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PuckDetection extends DeviceBase {
|
||||
|
||||
@@ -163,7 +165,7 @@ public class PuckDetection extends DeviceBase {
|
||||
return Controller.getInstance().getPuck(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void doClose() {
|
||||
if (watchDog != null) {
|
||||
|
||||
Reference in New Issue
Block a user