This commit is contained in:
gac-S_Changer
2019-02-28 16:38:41 +01:00
parent eaec82dd86
commit e2ce88fefb
2 changed files with 91 additions and 64 deletions

View File

@@ -31,7 +31,7 @@
<Group type="102" alignment="1" attributes="0">
<Component id="panelTop" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="panelBottom" pref="76" max="32767" attributes="0"/>
<Component id="panelBottom" pref="75" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
</Group>
</Group>
@@ -334,21 +334,21 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="9" max="32767" attributes="0"/>
<EmptySpace pref="13" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonDetectCover" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="hexiposiPanel" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="9" max="32767" attributes="0"/>
<EmptySpace pref="14" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace pref="14" max="32767" attributes="0"/>
<EmptySpace pref="15" max="32767" attributes="0"/>
<Component id="hexiposiPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="9" max="32767" attributes="0"/>
<EmptySpace pref="10" max="32767" attributes="0"/>
<Component id="buttonDetectCover" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -384,12 +384,12 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="8" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonDrawing" linkSize="25" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonCamera" linkSize="25" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="8" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -896,7 +896,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="panelDetail" pref="108" max="32767" attributes="0"/>
<Component id="panelDetail" pref="106" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="panelDevices" min="-2" pref="280" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
@@ -1004,9 +1004,9 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="devicesPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="28" max="32767" attributes="0"/>
<Component id="panelExpert" min="-2" pref="93" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="31" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -1018,7 +1018,7 @@
<Component id="panelExpert" max="32767" attributes="0"/>
<Component id="devicesPanel" pref="235" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="8" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View File

@@ -24,10 +24,12 @@ import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Window;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
@@ -49,12 +51,12 @@ public class MainPanel extends Panel {
Boolean manualMode;
Boolean roomTemperature;
public final String PUCK_LOADING_STATUS = "Puck loading";
public enum BasePlateLayout{
public enum BasePlateLayout {
normal,
sf
}
public static final BasePlateLayout BASE_PLATE_LAYOUT = App.hasArgument("sf") ? BasePlateLayout.sf: BasePlateLayout.normal;
public static final BasePlateLayout BASE_PLATE_LAYOUT = App.hasArgument("sf") ? BasePlateLayout.sf : BasePlateLayout.normal;
public MainPanel() {
initComponents();
@@ -97,36 +99,36 @@ public class MainPanel extends Panel {
public void valueChanged(ListSelectionEvent e) {
try {
if (e.getValueIsAdjusting() == false) {
int selection = tableSamples.getSelectedRow();
if (selection>=0){
int selection = tableSamples.getSelectedRow();
if (selection >= 0) {
String add = String.valueOf(tableSamples.getModel().getValueAt(selection, COLUMN_PUCK_ADDRESS));
if (!add.trim().isEmpty()) {
int pos = -1;
try{
try {
pos = Integer.valueOf(String.valueOf(tableSamples.getModel().getValueAt(selection, COLUMN_SAMPLE_POSITION)));
} catch (Exception ex){
}
} catch (Exception ex) {
}
String curSelection = Controller.getInstance().getCurrentSelection();
String curPuck = (curSelection == null) ? null : curSelection.substring(0, 2);
if (!add.equals(curPuck)) {
Puck puck = Controller.getInstance().getPuck(add);
Controller.getInstance().selectPuck(puck);
}
if (pos>=0){
if (pos >= 0) {
add += pos;
if (!add.equals(curSelection)) {
Sample sample = Controller.getInstance().getSample(add);
Controller.getInstance().selectSample(sample);
}
}
}
}
}
}
}
} catch (Exception ex) {
showException(ex);
}
}
});
});
}
@Override
@@ -136,7 +138,7 @@ public class MainPanel extends Panel {
SwingUtils.getWindow(this).setIconImage(img);
}
basePlatePanel.setSelectionMode(SelectionMode.Pucks);
basePlatePanel.setDevice(Controller.getInstance().basePlate);
basePlatePanel.setDevice(Controller.getInstance().basePlate);
}
@Override
@@ -191,7 +193,7 @@ public class MainPanel extends Panel {
}
});
updateDryer(((Device) getDevice("gripper_dryer")).take());
((Device) getDevice("feedback_psys_safety")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
@@ -218,7 +220,7 @@ public class MainPanel extends Panel {
setPuckDatamatrix(null);
setSampleDatamatrix(null);
setBackgroundUpdate(true);
startTimer(3000, 1000);
startTimer(3000, 1000);
updateCameraView();
}
@@ -229,7 +231,7 @@ public class MainPanel extends Panel {
@Override
protected void onTimer() {
try{
try {
devicesPanel.update();
try {
roomTemperature = Controller.getInstance().isRoomTemp();
@@ -246,18 +248,18 @@ public class MainPanel extends Panel {
labelRoomTemperature.setText("Room Temperature");
}
try {
if ((expertChrono!=null) && (expertChrono.isTimeout(10 * 60000))){ //After 10min
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())) {
setStatus(PUCK_LOADING_STATUS);
} else {
setStatus(PUCK_LOADING_STATUS);
} else {
setStatus("Ready");
}
} else {
@@ -265,20 +267,23 @@ public class MainPanel extends Panel {
}
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
}
}
}
String status;
void setStatus (String status){
if (!status.equals(this.status)){
void setStatus(String status) {
if (!status.equals(this.status)) {
getContext().setPreference(ViewPreference.STATUS, status);
this.status = status;
}
}
void refresh() {
if (!SwingUtilities.isEventDispatchThread()){
SwingUtilities.invokeLater(()->{refresh();});
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> {
refresh();
});
return;
}
repaint();
@@ -328,7 +333,7 @@ public class MainPanel extends Panel {
ledLocalSafety.setColor(Color.RED);
}
}
void updateDryer(Object value) {
if ((value == null) || !(value instanceof Boolean)) {
ledDryer.setColor(Color.BLACK);
@@ -375,7 +380,7 @@ public class MainPanel extends Panel {
void execute(String statement, boolean background) {
execute(statement, background, false);
}
void execute(String statement, boolean background, boolean showReturn) {
execute(statement, background, showReturn, true);
}
@@ -385,7 +390,7 @@ public class MainPanel extends Panel {
getLogger().log(Level.INFO, "Execute: " + statement + (background ? "&" : ""));
evalAsync(statement, background).handle((ret, ex) -> {
if (ex != null) {
if (showException){
if (showException) {
showException((Exception) ex);
}
} else if (showReturn) {
@@ -394,7 +399,7 @@ public class MainPanel extends Panel {
return ret;
});
} catch (Exception ex) {
if (showException){
if (showException) {
showException(ex);
}
}
@@ -403,6 +408,7 @@ public class MainPanel extends Panel {
void execute(String script, Object args, boolean background, boolean showReturn) {
execute(script, args, background, showReturn, true);
}
void execute(String script, Object args, boolean background, boolean showReturn, boolean showException) {
try {
getLogger().log(Level.INFO, "Execute: " + script + (background ? "&" : ""));
@@ -415,8 +421,8 @@ public class MainPanel extends Panel {
return ret;
});
} catch (Exception ex) {
if (showException){
showException(ex);
if (showException) {
showException(ex);
}
}
}
@@ -482,7 +488,7 @@ public class MainPanel extends Panel {
buttonDrawing.setSelected(true);
updateViewType();
}
if (current!=expert){
if (current != expert) {
onModeChange(expert);
}
}
@@ -538,14 +544,14 @@ public class MainPanel extends Panel {
}
final int COLUMN_PUCK_ADDRESS = 3;
final int COLUMN_SAMPLE_POSITION = 5;
final int COLUMN_SAMPLE_POSITION = 5;
void setSamplesTable(Object[][] sampleData) {
tableSamples.setModel(new DefaultTableModel(
sampleData,
new String[]{
//"User Name", "Dewar Name",
"Puck Name", "Puck Type", "Puck Id", "Puck Address",
"Puck Name", "Puck Type", "Puck Id", "Puck Address",
"Sample Name", "Sample Position", "Sample Id", "Sample Status", "Mount Count"
}
) {
@@ -571,8 +577,8 @@ public class MainPanel extends Panel {
for (int i = 0; i < tableSamples.getModel().getRowCount(); i++) {
if (add.equals(tableSamples.getModel().getValueAt(i, COLUMN_PUCK_ADDRESS))) {
if (sample!=null){
if (!sample.equals(tableSamples.getModel().getValueAt(i, COLUMN_SAMPLE_POSITION))){
if (sample != null) {
if (!sample.equals(tableSamples.getModel().getValueAt(i, COLUMN_SAMPLE_POSITION))) {
continue;
}
}
@@ -603,24 +609,24 @@ 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){
void onExpertCommand(Window window) {
expertChrono = new Chrono();
if ((window!=null) && (!expertWindows.contains(window))){
if ((window != null) && (!expertWindows.contains(window))) {
expertWindows.add(window);
}
}
void onModeChange(boolean expert){
if (expert){
void onModeChange(boolean expert) {
if (expert) {
expertChrono = new Chrono();
} else {
expertChrono = null;
for (Window w : expertWindows){
if ((w!=null) && (w.isShowing())){
expertChrono = null;
for (Window w : expertWindows) {
if ((w != null) && (w.isShowing())) {
w.setVisible(false);
w.dispose();
}
@@ -628,7 +634,6 @@ public class MainPanel extends Panel {
expertWindows.clear();
}
}
/**
* This method is called from within the constructor to initialize the form.
@@ -1566,7 +1571,7 @@ public class MainPanel extends Panel {
}//GEN-LAST:event_buttonCameraActionPerformed
private void buttonExpertCommandsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExpertCommandsActionPerformed
try {
try {
Panel panel = showCommandsPanel();
onExpertCommand(SwingUtils.getWindow(panel));
} catch (Exception ex) {
@@ -1627,8 +1632,8 @@ public class MainPanel extends Panel {
if (dlg.getResult() == false) {
checkExpert.setSelected(false);
return;
}
}
}
}
setExpertMode(checkExpert.isSelected());
}//GEN-LAST:event_checkExpertActionPerformed
@@ -1654,7 +1659,7 @@ public class MainPanel extends Panel {
}//GEN-LAST:event_btViewRTActionPerformed
private void buttonRecoveryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRecoveryActionPerformed
try {
try {
Panel panel = showRecoveryPanel();
onExpertCommand(SwingUtils.getWindow(panel));
} catch (Exception ex) {
@@ -1691,7 +1696,29 @@ public class MainPanel extends Panel {
private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed
onExpertCommand(null);
this.showSettingsEditor(true);
boolean current = false;
try {
current = "true".equalsIgnoreCase(getSetting("valve_control"));
} catch (Exception ex) {
}
showSettingsEditor(true);
//Check if must open valve
if (current) {
SwingUtilities.invokeLater(() -> {
try {
boolean valveControl = "true".equalsIgnoreCase(getSetting("valve_control"));
if (!valveControl) {
execute("open_valve()", true);
}
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
}
});
}
}//GEN-LAST:event_buttonConfigActionPerformed
private void buttonReleaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleaseActionPerformed