This commit is contained in:
@@ -14,17 +14,17 @@ import ch.psi.pshell.device.DeviceListener;
|
||||
import ch.psi.pshell.device.GenericDevice;
|
||||
import ch.psi.pshell.device.ReadbackDevice;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.Audio;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Window;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -245,7 +245,7 @@ public class Controller {
|
||||
refreshSamplesTable();
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final DeviceListener hexiposiListener = new DeviceAdapter() {
|
||||
@@ -689,8 +689,16 @@ public class Controller {
|
||||
return puckLoading;
|
||||
}
|
||||
|
||||
void playSound(String name){
|
||||
try{
|
||||
Audio.playFile(new File(Context.getInstance().getSetup().expandPath("{home}/sounds/" + name + ".wav")));
|
||||
} catch (Exception ex){
|
||||
Logger.getLogger(Controller.class.getName()).log(Level.FINE, null, ex);
|
||||
}
|
||||
}
|
||||
void onPuckBarcode(String datamatrix) {
|
||||
if (isPuckLoading()) {
|
||||
playSound("mounted");
|
||||
getMainFrame().setPuckDatamatrix(datamatrix);
|
||||
System.out.println("Detected Puck: " + datamatrix);
|
||||
}
|
||||
@@ -712,6 +720,7 @@ 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) {
|
||||
playSound("mounted");
|
||||
if (!datamatrix.isEmpty()) {
|
||||
getMainFrame().setPuckDatamatrix(null);
|
||||
linkPuckDatamatrix(puck, datamatrix);
|
||||
@@ -719,6 +728,7 @@ public class Controller {
|
||||
askPuckDatamatrix(puck);
|
||||
}
|
||||
} else if (detectedPuckRemoved) {
|
||||
playSound("unmounted");
|
||||
linkPuckDatamatrix(puck, null);
|
||||
}
|
||||
}
|
||||
@@ -832,5 +842,5 @@ public class Controller {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -133,8 +133,10 @@ public class DevicesPanel extends javax.swing.JPanel {
|
||||
|
||||
DevicePanel showDevicePanel(String device){
|
||||
if (isActive()){
|
||||
try{
|
||||
return Controller.getInstance().getMainFrame().showDevicePanel(device);
|
||||
try{
|
||||
DevicePanel ret = Controller.getInstance().getMainFrame().showDevicePanel(device);
|
||||
Controller.getInstance().getMainFrame().onExpertCommand(SwingUtils.getWindow(ret));
|
||||
return ret;
|
||||
} catch (Exception ex) {
|
||||
SwingUtils.showException(this, ex);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ 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.Chrono;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.BorderLayout;
|
||||
@@ -22,6 +23,9 @@ import java.awt.Dialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Image;
|
||||
import java.awt.Window;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.GroupLayout;
|
||||
@@ -241,6 +245,14 @@ public class MainPanel extends Panel {
|
||||
ledRoomTemperature.setColor(Color.BLACK);
|
||||
labelRoomTemperature.setText("Room Temperature");
|
||||
}
|
||||
try {
|
||||
if ((expertChrono!=null) && (expertChrono.isTimeout(10 * 60000))){ //After 10min
|
||||
setExpertMode(false);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
|
||||
Controller.getInstance().onTimer();
|
||||
if (getState() == State.Ready) {
|
||||
if (Boolean.TRUE.equals(Controller.getInstance().isPuckLoading())) {
|
||||
@@ -439,6 +451,7 @@ public class MainPanel extends Panel {
|
||||
}
|
||||
|
||||
void setExpertMode(boolean expert) {
|
||||
boolean current = buttonExpertCommands.isVisible();
|
||||
buttonExpertCommands.setVisible(expert);
|
||||
buttonRecovery.setVisible(expert);
|
||||
buttonCalibrateImage.setVisible(expert);
|
||||
@@ -458,29 +471,33 @@ public class MainPanel extends Panel {
|
||||
buttonDrawing.setSelected(true);
|
||||
updateViewType();
|
||||
}
|
||||
if (current!=expert){
|
||||
onModeChange(expert);
|
||||
}
|
||||
}
|
||||
|
||||
Plugin commandsPlugin;
|
||||
|
||||
void showCommandsPanel() {
|
||||
Panel showCommandsPanel() {
|
||||
if (commandsPlugin != null) {
|
||||
getContext().getPluginManager().unloadPlugin(commandsPlugin);
|
||||
}
|
||||
commandsPlugin = getContext().getPluginManager().loadPlugin(getContext().getSetup().expandPath("{plugins}/Commands.java"));
|
||||
((Panel) commandsPlugin).setDetached(true, getTopLevel());
|
||||
getContext().getPluginManager().initializePlugin(commandsPlugin);
|
||||
return ((Panel) commandsPlugin);
|
||||
}
|
||||
|
||||
Plugin recoveryPlugin;
|
||||
|
||||
void showRecoveryPanel() {
|
||||
Panel showRecoveryPanel() {
|
||||
if (recoveryPlugin != null) {
|
||||
getContext().getPluginManager().unloadPlugin(recoveryPlugin);
|
||||
}
|
||||
recoveryPlugin = getContext().getPluginManager().loadPlugin(getContext().getSetup().expandPath("{plugins}/Recovery.java"));
|
||||
((Panel) recoveryPlugin).setDetached(true, getTopLevel());
|
||||
getContext().getPluginManager().initializePlugin(recoveryPlugin);
|
||||
|
||||
return ((Panel) recoveryPlugin);
|
||||
}
|
||||
|
||||
void setDefaultDetail() {
|
||||
@@ -575,6 +592,32 @@ public class MainPanel extends Panel {
|
||||
String ret = textSampleDatamatrix.getText();
|
||||
return (ret != null) ? ret.trim() : "";
|
||||
}
|
||||
|
||||
|
||||
Chrono expertChrono;
|
||||
final List<Window> expertWindows = new ArrayList<>();
|
||||
void onExpertCommand(Window window){
|
||||
expertChrono = new Chrono();
|
||||
if ((window!=null) && (!expertWindows.contains(window))){
|
||||
expertWindows.add(window);
|
||||
}
|
||||
}
|
||||
|
||||
void onModeChange(boolean expert){
|
||||
if (expert){
|
||||
expertChrono = new Chrono();
|
||||
} else {
|
||||
expertChrono = null;
|
||||
for (Window w : expertWindows){
|
||||
if ((w!=null) && (w.isShowing())){
|
||||
w.setVisible(false);
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
expertWindows.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
@@ -1512,8 +1555,9 @@ public class MainPanel extends Panel {
|
||||
}//GEN-LAST:event_buttonCameraActionPerformed
|
||||
|
||||
private void buttonExpertCommandsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExpertCommandsActionPerformed
|
||||
try {
|
||||
showCommandsPanel();
|
||||
try {
|
||||
Panel panel = showCommandsPanel();
|
||||
onExpertCommand(SwingUtils.getWindow(panel));
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
@@ -1572,8 +1616,8 @@ public class MainPanel extends Panel {
|
||||
if (dlg.getResult() == false) {
|
||||
checkExpert.setSelected(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setExpertMode(checkExpert.isSelected());
|
||||
}//GEN-LAST:event_checkExpertActionPerformed
|
||||
|
||||
@@ -1599,14 +1643,16 @@ public class MainPanel extends Panel {
|
||||
}//GEN-LAST:event_btViewRTActionPerformed
|
||||
|
||||
private void buttonRecoveryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRecoveryActionPerformed
|
||||
try {
|
||||
showRecoveryPanel();
|
||||
try {
|
||||
Panel panel = showRecoveryPanel();
|
||||
onExpertCommand(SwingUtils.getWindow(panel));
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonRecoveryActionPerformed
|
||||
|
||||
private void buttonCalibrateImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCalibrateImageActionPerformed
|
||||
onExpertCommand(null);
|
||||
execute("imgproc/CameraCalibration", null, false, true);
|
||||
}//GEN-LAST:event_buttonCalibrateImageActionPerformed
|
||||
|
||||
@@ -1628,11 +1674,13 @@ public class MainPanel extends Panel {
|
||||
}//GEN-LAST:event_buttonDetectCoverActionPerformed
|
||||
|
||||
private void buttonCalibrateCoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCalibrateCoverActionPerformed
|
||||
onExpertCommand(null);
|
||||
execute("imgproc/CoverDetectionCalibration", null, false, true);
|
||||
}//GEN-LAST:event_buttonCalibrateCoverActionPerformed
|
||||
|
||||
private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed
|
||||
this.showSettingsEditor(false);
|
||||
onExpertCommand(null);
|
||||
this.showSettingsEditor(true);
|
||||
}//GEN-LAST:event_buttonConfigActionPerformed
|
||||
|
||||
private void buttonReleaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleaseActionPerformed
|
||||
|
||||
Reference in New Issue
Block a user