From 5f19b8ac42aa295abb27b15c477a8b972b8617b1 Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Tue, 15 Jul 2025 14:17:24 +0200 Subject: [PATCH] Null ID for absent pucks --- src/main/java/ch/psi/mxsc/MainPanel.java | 92 +++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/psi/mxsc/MainPanel.java b/src/main/java/ch/psi/mxsc/MainPanel.java index 84ee34b..6e4752a 100644 --- a/src/main/java/ch/psi/mxsc/MainPanel.java +++ b/src/main/java/ch/psi/mxsc/MainPanel.java @@ -548,6 +548,13 @@ public class MainPanel extends Panel { } void updateLevel(Object value) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateLevel(value); + }); + return; + } + if ((value == null) || !(value instanceof Number)) { progressLN2.setIndeterminate(true); } else { @@ -558,6 +565,13 @@ public class MainPanel extends Panel { } void updateAirPressure(Object value) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateAirPressure(value); + }); + return; + } + if ((value == null) || !(value instanceof Boolean)) { ledAirPressure.setColor(Color.BLACK); } else if ((Boolean) value) { @@ -568,6 +582,12 @@ public class MainPanel extends Panel { } void updateN2Pressure(Object value) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateN2Pressure(value); + }); + return; + } if ((value == null) || !(value instanceof Boolean)) { ledN2Pressure.setColor(Color.BLACK); } else if ((Boolean) value) { @@ -578,6 +598,12 @@ public class MainPanel extends Panel { } void updateLocalSafety(Object value) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateLocalSafety(value); + }); + return; + } if ((value == null) || !(value instanceof Boolean)) { ledLocalSafety.setColor(Color.BLACK); } else if ((Boolean) value) { @@ -588,6 +614,12 @@ public class MainPanel extends Panel { } void updateDryer(Object value) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateDryer(value); + }); + return; + } if ((value == null) || !(value instanceof Boolean)) { ledDryer.setColor(Color.BLACK); } else if ((Boolean) value) { @@ -606,6 +638,13 @@ public class MainPanel extends Panel { } void updateButtonState(){ + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateButtonState(); + }); + return; + } + boolean doors_open = !Boolean.TRUE.equals(Controller.getInstance().isDoorClosed()); boolean cover_pos_detected = isCoverPosDetected(); buttonSampleLoad.setEnabled(doors_open && !cover_pos_detected && getState().isInitialized()); @@ -613,6 +652,14 @@ public class MainPanel extends Panel { buttonDrawing.setEnabled(getState().isInitialized()); } void updatePsysSafety(Object value) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updatePsysSafety(value); + }); + return; + } + + if ((value == null) || !(value instanceof Boolean)) { ledPsysSafety.setColor(Color.BLACK); } else if (Boolean.TRUE.equals(manualMode)) { @@ -633,6 +680,13 @@ public class MainPanel extends Panel { } void updateMode(Object value) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateMode(value); + }); + return; + } + if ((value != null) && (value instanceof Map)) { manualMode = "manual".equals(String.valueOf(((Map) value).get("mode"))); ledManualMode.setColor(manualMode ? Color.YELLOW : Color.GREEN); @@ -645,6 +699,12 @@ public class MainPanel extends Panel { } void updateCameraView() { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateCameraView(); + }); + return; + } try{ //if (buttonCamera.isSelected()){ int center_x = ((Number)this.eval("cover_detection.config.center_x", true)).intValue(); @@ -731,6 +791,12 @@ public class MainPanel extends Panel { WaterLevelPanel waterLevelPanel; void updateViewMode() { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + updateViewMode(); + }); + return; + } try { if (btViewDewar.isSelected() != viewDewar) { viewDewar = btViewDewar.isSelected(); @@ -758,7 +824,13 @@ public class MainPanel extends Panel { } volatile boolean updating; - void setExpertMode(boolean expert) { + void setExpertMode(boolean expert) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + setExpertMode(expert); + }); + return; + } try{ updating = true; boolean current = buttonExpertCommands.isVisible(); @@ -848,6 +920,12 @@ public class MainPanel extends Panel { final int COLUMN_SAMPLE_POSITION = 5; void setSamplesTable(Object[][] sampleData) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + setSamplesTable(sampleData); + }); + return; + } tableSamples.setModel(new DefaultTableModel( sampleData, new String[]{ @@ -901,10 +979,22 @@ public class MainPanel extends Panel { } public void setPuckDatamatrix(String datamatrix) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + setPuckDatamatrix(datamatrix); + }); + return; + } textPuckDatamatrix.setText((datamatrix == null) ? "" : String.valueOf(datamatrix)); } public void setSampleDatamatrix(String datamatrix) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()->{ + setSampleDatamatrix(datamatrix); + }); + return; + } textSampleDatamatrix.setText((datamatrix == null) ? "" : String.valueOf(datamatrix)); }