Puck detetion mode - during loading only

This commit is contained in:
gac-S_Changer
2025-08-21 11:27:10 +02:00
parent 45cb47eb71
commit 114c800ac2
9 changed files with 159 additions and 178 deletions

View File

@@ -333,8 +333,10 @@ public class Controller {
final DeviceListener puckDetectionListener = new DeviceListener() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
if (value != null) { //Keep last value
onPuckDetectionChanged();
if (puck_detection.isEnabled()){
if (value != null) { //Keep last value
onPuckDetectionChanged();
}
}
}
};
@@ -358,7 +360,7 @@ public class Controller {
} else {
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, "No puck_detection detected.");
}
checkPuckLoading();
checkPuckDetectionEnabling();
}
PuckState[] puckState;
@@ -692,16 +694,18 @@ public class Controller {
}
////////////////////// Puck Loading /////////////////////////////////
Boolean puckLoading;
boolean puckLoading;
Puck.Detection[] currentDetection;
boolean puckReaderOk = true;
String insertedPuckDatamatrix;
Puck removedPuck;
//true->load
//false->unload
//null->finish transfer mode
void setPuckLoading(Boolean load) {
void setPuckLoading(boolean load) {
if (load != puckLoading) {
if (load!=null){
if (load){
if (isDoorClosed()){
return;
}
@@ -709,7 +713,7 @@ public class Controller {
removedPuck = null;
} else {
Controller.getInstance().setLaserPos((Puck)null);
setLaserPos((Puck)null);
}
if ((dialogAskPuckDatamatrix != null) && (dialogAskPuckDatamatrix.isShowing())) {
dialogAskPuckDatamatrix.setVisible(false);
@@ -725,7 +729,7 @@ public class Controller {
if (puckReaderOk) {
Logger.getLogger(Controller.class.getName()).warning("Communication failure: " + name);
}
puckLoading = null;
puckLoading = false;
puckReaderOk = false;
} else {
if (!puckReaderOk) {
@@ -736,14 +740,14 @@ public class Controller {
return ret;
};
try {
if (puckLoading!=null) {
if (puckLoading) {
getMainFrame().evalAsync(name + ".enable(); " + name + ".polling = 100", true).handle(errorHandler);
currentDetection = basePlate.getDetection();
} else if (getState().isInitialized()) {
getMainFrame().evalAsync(name + ".polling = 0; " + name + ".disable()", true).handle(errorHandler);
onPuckScanned(null);
}
getMainFrame().evalAsync("onPuckLoadingChange(" + ((puckLoading!=null) ? "True" : "False") + ")");
getMainFrame().evalAsync("onPuckLoadingChange(" + (puckLoading ? "True" : "False") + ")");
} catch (Exception ex) {
errorHandler.apply(null, ex);
}
@@ -752,7 +756,18 @@ public class Controller {
}
}
public Boolean isPuckLoading() {
public boolean isPuckLoading() {
try {
if (isPuckDetectionLoading()){
if (!puck_detection.isEnabled()){
//Does not process load events if checking missing pucks before re-enabling detection
return false;
}
}
} catch (IOException ex) {
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
}
return puckLoading;
}
@@ -784,7 +799,7 @@ public class Controller {
}
public void onPuckBarcode(String datamatrix) {
if (isPuckLoading()!=null) {
if (isPuckLoading()) {
playSound("scanned");
System.out.println("Detected Puck: " + datamatrix);
onPuckScanned(datamatrix);
@@ -796,9 +811,9 @@ public class Controller {
getMainFrame().setSampleDatamatrix(datamatrix);
System.out.println("Detected Sample: " + datamatrix);
}
void onPuckDetectionChanged() {
if (isPuckLoading()!=null) {
if (isPuckLoading()) {
Puck.Detection[] detection = basePlate.getDetection();
for (int i = 0; i < Controller.NUMBER_OF_PUCKS; i++) {
Puck puck = basePlate.getPucks()[i];
@@ -806,10 +821,8 @@ public class Controller {
boolean detectedPuckInserted = (currentDetection[i] != Puck.Detection.Present) && (detection[i] == Puck.Detection.Present);
boolean detectedPuckRemoved = (currentDetection[i] != Puck.Detection.Empty) && (detection[i] == Puck.Detection.Empty);
if (detectedPuckInserted) {
onPuckInserted(puck);
} else if (detectedPuckRemoved) {
playSound("unmounted");
onPuckMounted(puck);
} else if (detectedPuckRemoved) {
onPuckUnmounted(puck);
}
}
@@ -817,31 +830,9 @@ public class Controller {
currentDetection = detection;
}
}
String insertedPuckDatamatrix;
Puck removedPuck;
public void onPuckInserted(Puck puck) {
playSound("mounted");
String datamatrix = getMainFrame().getPuckDatamatrix();
logPuckDetectionChange(puck, true);
onPuckScanned(null);
if ((datamatrix==null) || (datamatrix.isBlank())){
if (puck == removedPuck){
datamatrix = insertedPuckDatamatrix;
}
}
onPuckMounted(puck, datamatrix);
insertedPuckDatamatrix = datamatrix;
removedPuck = null;
}
public void onPuckRemoved(Puck puck) {
playSound("unmounted");
logPuckDetectionChange(puck, false);
onPuckUnmounted(puck);
}
void linkPuckDatamatrix(Puck puck, String datamatrix, boolean showMessage) {
public void linkPuckDatamatrix(Puck puck, String datamatrix, boolean showMessage) {
// if ( ((puck.getId()==null) && (datamatrix!=null)) ||
// (puck.getId()!=null) && (!puck.getId().equals(datamatrix))){
String puckName = (puck == null) ? "" : puck.getName();
@@ -959,14 +950,22 @@ public class Controller {
}
}
Boolean puckDetectionLoading;
public boolean isPuckDetectionLoading() throws IOException{
if (puckDetectionLoading==null){
puckDetectionLoading = "loading".equals(Context.getSetting("puck_detection"));
}
return puckDetectionLoading;
}
boolean showingPuckLoadingDialog;
public void checkPuckLoading(){
boolean showingPuckLoadingDialog;
public void checkPuckDetectionEnabling(){
try{
showingPuckLoadingDialog = (dialogPuckLoading != null) && (dialogPuckLoading.isShowing());
if ("loading".equals(Context.getSetting("puck_detection"))){
if ( isPuckDetectionLoading()){
if (showingPuckLoadingDialog){
var werePresent = new ArrayList<String>();
Puck[] pucks = basePlate.getPucks();
@@ -988,10 +987,16 @@ public class Controller {
removed.removeAll(present);
if (removed.size()>0){
PuckDetectionErrorDialog dlg = new PuckDetectionErrorDialog(mainFrame.getTopLevel());
PuckDetectionErrorDialog dlg = new PuckDetectionErrorDialog(dialogPuckLoading, false);
dlg.initialize(removed);
dlg.setVisible(true);
}
dlg.setLocationRelativeTo(dialogPuckLoading);
dlg.setVisible(true);
for (String address: removed){
Puck puck = basePlate.getPuckByName(address);
clearPuckMountedSample(puck);
Controller.getInstance().linkPuckDatamatrix(puck, null, false);
}
}
}
puck_detection.setEnabled(showingPuckLoadingDialog);
}
@@ -1008,20 +1013,20 @@ public class Controller {
dialogPuckLoading = new PuckLoadingDialog(mainFrame.getTopLevel(), load, false);
dialogPuckLoading.setLocationRelativeTo(mainFrame);
dialogPuckLoading.setVisible(true);
checkPuckLoading();
checkPuckDetectionEnabling();
dialogPuckLoading.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
try{
setPuckLoading(null);
setPuckLoading(false);
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
}
}
@Override
public void windowClosed(WindowEvent e) {
checkPuckLoading();
checkPuckDetectionEnabling();
}
});
@@ -1042,9 +1047,9 @@ public class Controller {
}
}
void onPuckLoadingModeChange(Boolean puckLoadMode) {
if (puckMountMode == PuckMountMode.Dialog) {
if (puckLoadMode!=null) {
public void onPuckLoadingModeChange(boolean puckLoadMode) {
if ( hasLoadDialog()) {
if (puckLoadMode) {
showDialogPuckLoading(puckLoadMode);
mainFrame.setViewDesign();
} else {
@@ -1054,10 +1059,10 @@ public class Controller {
}
}
void onPuckScanned(String datamatrix) {
if (isPuckLoading()!=null) {
public void onPuckScanned(String datamatrix) {
if (isPuckLoading()) {
getMainFrame().setPuckDatamatrix(datamatrix);
if (puckMountMode == PuckMountMode.Dialog) {
if ( hasLoadDialog()) {
showDialogPuckLoading(puckLoading);
dialogPuckLoading.onPuckScanned(datamatrix);
}
@@ -1065,46 +1070,66 @@ public class Controller {
getMainFrame().setPuckDatamatrix(null);
}
}
void onPuckMounted(Puck puck, String datamatrix) {
if (isPuckLoading()!=null) {
if (puckMountMode == PuckMountMode.Dialog) {
showDialogPuckLoading(puckLoading);
dialogPuckLoading.onPuckMounted(puck, datamatrix);
} else {
if (!datamatrix.isEmpty()) {
linkPuckDatamatrix(puck, datamatrix, true);
} else {
askPuckDatamatrix(puck);
}
}
}
public boolean hasLoadDialog(){
return(puckMountMode == PuckMountMode.Dialog);
}
void onPuckUnmounted(Puck puck) {
if (isPuckLoading()!=null) {
try{
Sample sample = getMountedSample();
if ((sample!=null) && (sample.getPuck() == puck)){
resetMountedSample();
sample.setLoaded(false);
SwingUtilities.invokeLater(()->{;
getMainFrame().refresh();
});
}
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
public void onPuckMounted(Puck puck) {
String datamatrix = getMainFrame().getPuckDatamatrix();
Logger.getLogger(Controller.class.getName()).info("Mounted puck: " + puck.getName() + " - datamatrix:" + datamatrix);
playSound("mounted");
logPuckDetectionChange(puck, true);
onPuckScanned(null);
if ((datamatrix==null) || (datamatrix.isBlank())){
if (puck == removedPuck){
datamatrix = insertedPuckDatamatrix;
}
if (puckMountMode == PuckMountMode.Dialog) {
showDialogPuckLoading(puckLoading);
dialogPuckLoading.onPuckUnmounted(puck);
} else {
linkPuckDatamatrix(puck, null, true);
}
removedPuck = puck;
}
if ((datamatrix != null) && (!datamatrix.isEmpty())) {
Controller.getInstance().linkPuckDatamatrix(puck, datamatrix, !hasLoadDialog());
}
if (hasLoadDialog()) {
showDialogPuckLoading(puckLoading);
dialogPuckLoading.onPuckMounted(puck, datamatrix);
} else {
if ((datamatrix == null) || (datamatrix.isEmpty())){
askPuckDatamatrix(puck);
}
}
insertedPuckDatamatrix = datamatrix;
removedPuck = null;
}
public void onPuckUnmounted(Puck puck) {
Logger.getLogger(Controller.class.getName()).info("Unmounted puck: " + puck.getName());
playSound("unmounted");
clearPuckMountedSample(puck);
Controller.getInstance().linkPuckDatamatrix(puck, null, !hasLoadDialog());
if ( hasLoadDialog()) {
showDialogPuckLoading(puckLoading);
dialogPuckLoading.onPuckUnmounted(puck);
}
removedPuck = puck;
}
void clearPuckMountedSample(Puck puck){
try{
Sample sample = getMountedSample();
if ((sample!=null) && (sample.getPuck() == puck)){
resetMountedSample();
sample.setLoaded(false);
SwingUtilities.invokeLater(()->{;
getMainFrame().refresh();
});
}
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
}
}
void logSampleMounted(String former, String current){
logEvent((current!=null) ? "Sample Mounted" : "Sample Unmounted", former, current);
}

View File

@@ -20,7 +20,7 @@ public class ControllerRT extends Controller{
ControllerRT(Panel mainFrame) {
//basePlate = new BasePlate();
basePlate.addListener(basePlateListener);
setPuckLoading(null);
setPuckLoading(false);
for (PuckState ps : getPuckStates()){
ps.set(1, 0);
}

View File

@@ -504,12 +504,8 @@ public class MainPanel extends Panel {
Controller.getInstance().onTimer();
if (getState() == State.Ready) {
Boolean puckLoading = Controller.getInstance().isPuckLoading();
if (puckLoading==null){
setStatus("Ready");
} else {
setStatus(puckLoading ? PUCK_LOADING_STATUS : PUCK_UNLOADING_STATUS);
}
boolean puckLoading = Controller.getInstance().isPuckLoading();
setStatus((puckLoading==false) ? "Ready" : PUCK_LOADING_STATUS);
} else {
status = null;
}
@@ -672,7 +668,7 @@ public class MainPanel extends Panel {
}
if (!Boolean.TRUE.equals(value)){
try {
Controller.getInstance().setPuckLoading(null);
Controller.getInstance().setPuckLoading(false);
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
}
@@ -1141,7 +1137,7 @@ public class MainPanel extends Panel {
Boolean.FALSE.equals(Controller.getInstance().isDoorClosed())){
try{
if ((fmm!=null)){
Controller.getInstance().setPuckLoading(null);
Controller.getInstance().setPuckLoading(false);
} else {
if (doorsHaveOpened){
doorsHaveOpened=false;

View File

@@ -71,9 +71,10 @@ public class PuckDetection extends DeviceBase {
if (chrono.isTimeout(TIMEOUT)) {
if (!isSimulated()) {
setState(State.Offline);
if (Controller.getInstance() != null) {
Controller.getInstance().clearPuckStates();
}
getLogger().severe("Puck Detection Timeout");
//if (Controller.getInstance() != null) {
// Controller.getInstance().clearPuckStates();
//}
}
}
Thread.sleep(1000);
@@ -129,13 +130,12 @@ public class PuckDetection extends DeviceBase {
if (debug) {
System.out.println(contents);
}
setCache(contents);
if (isEnabled() || (take() == null)){
processMessage(contents);
}
setState(State.Ready);
setCache(contents);
if (chrono != null){
updateTime.update(chrono.getEllapsed());
}
@@ -192,7 +192,7 @@ public class PuckDetection extends DeviceBase {
if (Controller.getInstance() != null) {
Controller.getInstance().updateView();
}
}
}
public PuckState getPuckState(int id) throws Exception {
if (Controller.getInstance() == null) {

View File

@@ -27,13 +27,13 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="labelSuggestion" pref="470" max="32767" attributes="0"/>
<Component id="labelSuggestion" pref="802" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="buttonOk" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="labelSuggestion1" pref="470" max="32767" attributes="0"/>
<Component id="labelSuggestion1" pref="802" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -43,13 +43,13 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="labelSuggestion" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="labelSuggestion1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="panelTable" min="-2" pref="172" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Component id="panelTable" pref="172" max="32767" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Component id="buttonOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View File

@@ -2,17 +2,21 @@
package ch.psi.mxsc;
import ch.psi.pshell.swing.StandardDialog;
import ch.psi.pshell.swing.SwingUtils;
import ch.psi.pshell.utils.Str;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Window;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JDialog;
import javax.swing.table.DefaultTableModel;
/**
*
*/
public class PuckDetectionErrorDialog extends StandardDialog {
public class PuckDetectionErrorDialog extends JDialog {
final DefaultTableModel model;
final int INDEX_USER = 0;
@@ -20,13 +24,13 @@ public class PuckDetectionErrorDialog extends StandardDialog {
final int INDEX_DATAMATRIX = 2;
final int INDEX_POSITION = 3;
public PuckDetectionErrorDialog(java.awt.Frame parent) {
super(parent, true);
public PuckDetectionErrorDialog(JDialog parent, boolean modal) {
super(parent, "Puck Detection Error", modal);
initComponents();
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
model = (DefaultTableModel) table.getModel();
table.getTableHeader().setFont(table.getTableHeader().getFont().deriveFont(16.0f));
panelTable.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0));
initComponents();
panelTable.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0));
}
public void initializePucks(List<Puck> failing) {
@@ -44,7 +48,7 @@ public class PuckDetectionErrorDialog extends StandardDialog {
model.setRowCount(failing.size());
for (int i=0; i< failing.size(); i++) {
String pos = failing.get(i);
model.setValueAt(failing, i, INDEX_POSITION);
model.setValueAt(failing.get(i), i, INDEX_POSITION);
for (int j=0; j< keys.length; j++) {
Map info = (Map) dms.get(keys[j]);
String address = Str.toString(info.getOrDefault("address", ""));
@@ -71,7 +75,7 @@ public class PuckDetectionErrorDialog extends StandardDialog {
}
Controller.getInstance().setLaserPos((Puck)null);
} catch (Exception ex){
showException(ex);
SwingUtils.showException(this,ex);
}
}
@@ -156,12 +160,12 @@ public class PuckDetectionErrorDialog extends StandardDialog {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(labelSuggestion, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)
.addComponent(labelSuggestion, javax.swing.GroupLayout.DEFAULT_SIZE, 802, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(buttonOk)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(labelSuggestion1, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE))
.addComponent(labelSuggestion1, javax.swing.GroupLayout.DEFAULT_SIZE, 802, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
@@ -171,17 +175,17 @@ public class PuckDetectionErrorDialog extends StandardDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(labelSuggestion1)
.addGap(18, 18, 18)
.addComponent(panelTable, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(panelTable, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(buttonOk)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOkActionPerformed
cancel();
setVisible(false);
}//GEN-LAST:event_buttonOkActionPerformed
private void tableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableKeyReleased
@@ -192,47 +196,6 @@ public class PuckDetectionErrorDialog extends StandardDialog {
updateLaser();
}//GEN-LAST:event_tableMouseReleased
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(PuckDetectionErrorDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(PuckDetectionErrorDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(PuckDetectionErrorDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(PuckDetectionErrorDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
PuckDetectionErrorDialog dialog = new PuckDetectionErrorDialog(new javax.swing.JFrame());
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonOk;

View File

@@ -318,9 +318,10 @@ public class PuckGraphics {
//Draw pointed
if (puck.isPointed()){
Point pos = getDrawPosition();
int pointerSize = 8;
g.setColor(Color.red);
g.drawOval(position.x - pointerSize / 2, position.y - pointerSize / 2, pointerSize, pointerSize);
g.fillOval(pos.x - pointerSize / 2, pos.y - pointerSize / 2, pointerSize, pointerSize);
}
//Draw text

View File

@@ -118,7 +118,6 @@ public class PuckLoadingDialog extends JDialog {
void onPuckMounted(Puck puck, String datamatrix){
Controller.getInstance().setLaserPos((Puck)null);
if ((datamatrix != null) && (!datamatrix.isEmpty())) {
Controller.getInstance().linkPuckDatamatrix(puck, datamatrix, false);
setStatusLabel("Mounted puck " + datamatrix + " at " + puck.getName(), 5000);
setSugestionLabel(null, -1);
buttonSet.setEnabled(false);
@@ -139,8 +138,7 @@ public class PuckLoadingDialog extends JDialog {
void onPuckUnmounted(Puck puck){
if (puck == detectedPuck){
}
Controller.getInstance().linkPuckDatamatrix(puck, null, false);
}
setStatusLabel("Unmounted puck from "+ puck.getName(), 5000);
if (puck == detectedPuck){
buttonSet.setEnabled(false);

View File

@@ -52,14 +52,14 @@ public class PuckState {
//TODO: Handle -1 value: error
SwitchState mec = SwitchState.fromInt(mecSwitch);
SwitchState ind = SwitchState.fromInt(indSwitch);
boolean changed = (mec != this.mecSwitch) || (mec != this.mecSwitch);
boolean changed = (mec != this.mecSwitch) || (ind != this.indSwitch);
this.mecSwitch = mec;
this.indSwitch = ind;
BasePlate basePlate = getBasePlate();
if (basePlate != null) {
Puck puck = basePlate.getPucks()[id - 1];
Puck.Detection detection = null;
Puck.Detection detection = Puck.Detection.Offline;
switch(puck.getDetectionMode()){
case Mechanical:
if (this.mecSwitch ==SwitchState.On ) {
@@ -91,9 +91,7 @@ public class PuckState {
}
break;
}
if (detection!=null){
puck.detection = detection;
}
puck.detection = detection;
}
return changed;
}