Puck detetion mode - during loading only

This commit is contained in:
gac-S_Changer
2025-08-08 13:17:25 +02:00
parent 249e9e3855
commit 9b4179478b
2 changed files with 44 additions and 15 deletions

View File

@@ -62,7 +62,7 @@ public class Controller {
static /*Panel*/ MainPanel mainFrame;
Device barcode_reader;
Device barcode_reader_puck;
Device puck_detection;
PuckDetection puck_detection;
JDialog dialogAskPuckDatamatrix;
String currentMountedSample;
PuckLoadingDialog dialogPuckLoading;
@@ -140,7 +140,7 @@ public class Controller {
puckState = new PuckState[NUMBER_OF_PUCKS];
for (int i = 0; i < NUMBER_OF_PUCKS; i++) {
puckState[i] = new PuckState(i + 1);
}
}
}
private Controller(Panel mainFrame) {
@@ -149,8 +149,7 @@ public class Controller {
clearPuckStates();
basePlate.addListener(basePlateListener);
roomTemperatureBasePlate = new RoomTemperatureBasePlate();
roomTemperatureBasePlate = new RoomTemperatureBasePlate();
}
final DeviceListener basePlateListener = new DeviceListener() {
@@ -242,12 +241,11 @@ public class Controller {
@Override
public void onDeviceRemoved(GenericDevice dev) {
}
});
});
updateDevices();
updatePuckTypes();
clearSamplesTable();
refreshSamplesTable();
refreshSamplesTable();
}
public Sample getMountedSample() throws Exception{
@@ -354,12 +352,13 @@ public class Controller {
} else {
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, "No barcode_reader_puck detected.");
}
puck_detection = (Device) getDevice("puck_detection");
puck_detection = (PuckDetection) getDevice("puck_detection");
if (puck_detection != null) {
puck_detection.addListener(puckDetectionListener);
} else {
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, "No puck_detection detected.");
}
checkEnablePuckDetection();
}
PuckState[] puckState;
@@ -960,6 +959,18 @@ public class Controller {
}
}
public void checkEnablePuckDetection(){
try{
if ("loading".equals(Context.getSetting("puck_detection"))){
boolean loading = (dialogPuckLoading != null) && (dialogPuckLoading.isShowing());
puck_detection.setEnabled(loading);
}
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
}
}
void showDialogPuckLoading(boolean load) {
if ((dialogPuckLoading != null) && (dialogPuckLoading.isVisible())) {
@@ -968,6 +979,7 @@ public class Controller {
dialogPuckLoading = new PuckLoadingDialog(mainFrame.getTopLevel(), load, false);
dialogPuckLoading.setLocationRelativeTo(mainFrame);
dialogPuckLoading.setVisible(true);
checkEnablePuckDetection();
dialogPuckLoading.addWindowListener(new WindowAdapter() {
@Override
@@ -976,8 +988,13 @@ public class Controller {
setPuckLoading(null);
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
}
}
}
@Override
public void windowClosed(WindowEvent e) {
checkEnablePuckDetection();
}
});
}

View File

@@ -17,6 +17,7 @@ public class PuckDetection extends DeviceBase {
public volatile Chrono chrono;
boolean debug;
public static final int TIMEOUT = 10000;
boolean enabled = true;
public PuckDetection(String name, String server) {
super(name);
@@ -128,11 +129,15 @@ public class PuckDetection extends DeviceBase {
if (debug) {
System.out.println(contents);
}
processMessage(contents);
if (Controller.getInstance() != null) {
Controller.getInstance().updateView();
setCache(contents);
if (isEnabled() || (take() == null)){
processMessage(contents);
if (Controller.getInstance() != null) {
Controller.getInstance().updateView();
}
}
setState(State.Ready);
if (chrono != null){
updateTime.update(chrono.getEllapsed());
@@ -176,8 +181,7 @@ public class PuckDetection extends DeviceBase {
}
address++;
}
}
setCache(str);
}
} catch (Exception ex) {
getLogger().log(Level.INFO, null, ex);
}
@@ -215,6 +219,14 @@ public class PuckDetection extends DeviceBase {
thread = null;
}
}
public void setEnabled(boolean value){
enabled = value;
}
public boolean isEnabled(){
return enabled;
}
public static void main(String[] args) throws IOException, InterruptedException {
//PuckDetection pd = new PuckDetection("PD", "129.129.110.99:5556");