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

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