MainPanel prototype
This commit is contained in:
@@ -13,9 +13,11 @@ import ch.psi.pshell.device.ProcessVariableBase;
|
||||
import ch.psi.pshell.device.ReadbackDevice;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.State;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.script.ScriptException;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
@@ -25,7 +27,7 @@ public class Controller {
|
||||
|
||||
static Controller instance;
|
||||
final BasePlate basePlate;
|
||||
final Panel mainFrame;
|
||||
final /*Panel*/ MainPanel mainFrame;
|
||||
Device hexaposi;
|
||||
|
||||
public static Controller getInstance() {
|
||||
@@ -53,11 +55,12 @@ public class Controller {
|
||||
for (int i = 0; i < NUMBER_OF_PUCKS; i++) {
|
||||
puckState[i] = new PuckState(i + 1);
|
||||
}
|
||||
this.mainFrame = mainFrame;
|
||||
this.mainFrame = (MainPanel)mainFrame;
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public Panel getMainFrame() {
|
||||
//public Panel getMainFrame() {
|
||||
public MainPanel getMainFrame() {
|
||||
return mainFrame;
|
||||
}
|
||||
|
||||
@@ -165,14 +168,7 @@ public class Controller {
|
||||
getMainFrame().runAsync("imgproc/LedDetectionProc", args).handle((ret, ex) -> {
|
||||
if (ex == null) {
|
||||
Map<String, List<String>> map = (Map<String, List<String>>) ret;
|
||||
for (Puck.ImageDetection id : Puck.ImageDetection.values()) {
|
||||
for (String name : map.get(id.toString())) {
|
||||
Puck p = basePlate.getPuckByName(name);
|
||||
if (p != null) {
|
||||
p.setImageDetection(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
setImageDetection(map);
|
||||
} else {
|
||||
getMainFrame().showException((Exception)ex);
|
||||
}
|
||||
@@ -181,9 +177,31 @@ public class Controller {
|
||||
updateView();
|
||||
}
|
||||
|
||||
public void clearImageDetection() throws Context.ContextStateException {
|
||||
getMainFrame().evalAsync("clear_detection(None)");
|
||||
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){
|
||||
for (Puck.ImageDetection id : Puck.ImageDetection.values()) {
|
||||
for (String name : map.get(id.toString())) {
|
||||
Puck p = basePlate.getPuckByName(name);
|
||||
if (p != null) {
|
||||
p.setImageDetection(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onPuckPressed(Puck puck){
|
||||
getMainFrame().textDetSensors.setText(String.valueOf(puck.getDetection()));
|
||||
getMainFrame().textDetImage.setText(String.valueOf(puck.getImageDetection()));
|
||||
}
|
||||
|
||||
void onSamplePressed(Sample sample){
|
||||
onPuckPressed(sample.getPuck());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user