This commit is contained in:
2018-08-16 10:56:50 +02:00
parent f5737189be
commit 525bb7ee38
9 changed files with 1949 additions and 1799 deletions

View File

@@ -9,6 +9,7 @@ import ch.psi.pshell.core.DevicePool;
import ch.psi.pshell.core.DevicePoolListener;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceAdapter;
import ch.psi.pshell.device.DeviceListener;
import ch.psi.pshell.device.GenericDevice;
import ch.psi.pshell.device.ReadbackDevice;
import ch.psi.pshell.ui.Panel;
@@ -89,6 +90,7 @@ public class Controller {
}
this.mainFrame = (MainPanel) mainFrame;
instance = this;
clearPuckStates();
}
//public Panel getMainFrame() {
@@ -97,7 +99,7 @@ public class Controller {
}
public void updateView() {
getMainFrame().repaint();
getMainFrame().refresh();
}
void onInitialize(int runCount) {
@@ -106,7 +108,7 @@ public class Controller {
getMainFrame().removeDevice(former);
}
getMainFrame().addDevice(basePlate);
clearPuckStates();
if (puckSensorAccess == PuckSensorAccess.Esera) {
getMainFrame().getContext().getDevicePool().addListener(new DevicePoolListener() {
@@ -133,17 +135,38 @@ public class Controller {
detection = new EseraDetection((Device) getMainFrame().getDevice(PUCK_ESERA_DEVICE));
}
}
Controller.getInstance().getDevicePool().addListener(new DevicePoolListener() {
@Override
public void onDeviceAdded(GenericDevice dev) {
updateDevices();
}
@Override
public void onDeviceRemoved(GenericDevice dev) {
}
});
updateDevices();
}
final DeviceListener hexiposiListener = new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateView();
}
};
void updateDevices(){
if (hexiposi!=null){
hexiposi.removeListener(hexiposiListener);
}
hexiposi = (Device) getMainFrame().getDevice("hexiposi");
if (hexiposi != null) {
hexiposi.addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateView();
}
});
hexiposi.addListener(hexiposiListener);
} else {
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, "No hexiposi detected.");
}
}
}
final PuckState[] puckState;
@@ -186,7 +209,11 @@ public class Controller {
}
public String getHexiposiPosition() {
return (String) ((ReadbackDevice) hexiposi).getReadback().take();
try {
return (String) ((ReadbackDevice) hexiposi).getReadback().take();
} catch (Exception ex) {
return null;
}
}
public Boolean isLedRoomTemp() {
@@ -245,7 +272,6 @@ public class Controller {
public void clearImageDetection() throws Context.ContextStateException, ScriptException, IOException, InterruptedException {
Map<String, List<String>> map = (Map<String, List<String>>) getMainFrame().eval("clear_detection(None)");
setImageDetection(map);
updateView();
}
void setImageDetection(Map<String, List<String>> map) {
@@ -257,6 +283,7 @@ public class Controller {
}
}
}
updateView();
}
void setSinglePuckType(Puck.PuckType puckType) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -97,7 +97,19 @@ public class Puck extends DeviceBase {
Minispine,
Unipuck,
Error,
Unknown,
Unknown;
public boolean isDefined(){
return (this==Minispine) || (this==Unipuck);
}
}
public String getStatus(){
if ((detection==Detection.Present) && puckType.isDefined()) {
return puckType.toString();
}
return detection.toString();
}
public double getAngle() {

View File

@@ -52,9 +52,11 @@ public class PuckDetection extends DeviceBase {
try {
while (!Thread.currentThread().isInterrupted()) {
if (chrono.isTimeout(3000)) {
setState(State.Offline);
if (Controller.getInstance() != null) {
Controller.getInstance().clearPuckStates();
if (!isSimulated()) {
setState(State.Offline);
if (Controller.getInstance() != null) {
Controller.getInstance().clearPuckStates();
}
}
}
Thread.sleep(1000);

View File

@@ -1,142 +0,0 @@
package ch.psi.mxsc;
import ch.psi.pshell.core.Context;
import ch.psi.pshell.core.JsonSerializer;
import ch.psi.utils.swing.StandardDialog;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
/**
*
*/
public class PuckLoadDialog extends StandardDialog {
String[] HEADER = new String[]{"Puck Address", "Mount Count", "User Name", "Puck Name", "Sample Status",
"Sample Name", "Sample Position", "Puck Barcode", "Dewar Name", "Puck Type"};
public PuckLoadDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
refresh();
}
void refresh() {
try {
String json = (String) Context.getInstance().evalLineBackground("get_samples_info()");
//SamplesInfo sampleInfo = (SamplesInfo) JsonSerializer.decode(json, SampleInfo.class);
SampleInfo[] samples = (SampleInfo[]) JsonSerializer.decode(json, SampleInfo[].class);
Object[][] sampleData = new Object[samples.length][];
for (int i=0; i< samples.length; i++) {
sampleData[i] = samples[i].getData();
}
table.setModel(new DefaultTableModel(
sampleData,
HEADER
));
} catch (Exception ex) {
clear();
Logger.getLogger(PuckLoadDialog.class.getName()).log(Level.SEVERE, null, ex);
}
}
void clear() {
table.setModel(new DefaultTableModel(
new Object[][]{},
HEADER
));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
table = new javax.swing.JTable();
setTitle("Puck Loading");
table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
}
));
jScrollPane1.setViewportView(table);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 79, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @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(PuckLoadDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(PuckLoadDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(PuckLoadDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(PuckLoadDialog.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() {
PuckLoadDialog dialog = new PuckLoadDialog(new javax.swing.JFrame(), true);
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.JScrollPane jScrollPane1;
private javax.swing.JTable table;
// End of variables declaration//GEN-END:variables
}

View File

@@ -30,7 +30,7 @@ public class PuckState {
indSwitch = false;
BasePlate basePlate = getBasePlate();
if (basePlate != null) {
basePlate.getPucks()[id - 1].detection = Puck.Detection.Offline;
basePlate.getPucks()[id - 1].detection = Puck.Detection.Empty;
}
}

View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="title" type="java.lang.String" value="Puck Loading"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Water Level"/>
</Border>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@@ -23,34 +23,29 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="395" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace pref="29" max="32767" attributes="0"/>
<Component id="progressWater" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace pref="29" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane1" min="-2" pref="277" max="-2" attributes="0"/>
<EmptySpace min="0" pref="79" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="progressWater" pref="670" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="table">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="0" rowCount="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JProgressBar" name="progressWater">
<Properties>
<Property name="maximum" type="int" value="1000"/>
<Property name="orientation" type="int" value="1"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,59 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ch.psi.mxsc;
/**
*
* @author gobbo_a
*/
public class WaterLevelPanel extends javax.swing.JPanel {
/**
* Creates new form WaterLevelPanel
*/
public WaterLevelPanel() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
progressWater = new javax.swing.JProgressBar();
setBorder(javax.swing.BorderFactory.createTitledBorder("Water Level"));
progressWater.setMaximum(1000);
progressWater.setOrientation(1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(29, Short.MAX_VALUE)
.addComponent(progressWater, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(29, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(progressWater, javax.swing.GroupLayout.DEFAULT_SIZE, 670, Short.MAX_VALUE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JProgressBar progressWater;
// End of variables declaration//GEN-END:variables
}