This commit is contained in:
gac-S_Changer
2018-08-14 14:09:01 +02:00
parent 3d571e8a4e
commit 047fad02d8
4 changed files with 415 additions and 230 deletions

View File

@@ -3,6 +3,7 @@
*/
package ch.psi.mxsc;
import ch.psi.mxsc.Puck.PuckType;
import ch.psi.pshell.core.Context;
import ch.psi.pshell.core.DevicePool;
import ch.psi.pshell.core.DevicePoolListener;
@@ -43,6 +44,37 @@ public class Controller {
Esera;
}
public enum PuckTypes {
unipuck,
minispine,
mixed
}
PuckTypes puckTypes = PuckTypes.mixed;
public PuckTypes getPuckTypes() {
return puckTypes;
}
void updatePuckTypes(){
try{
puckTypes = PuckTypes.valueOf(getMainFrame().eval("get_puck_types()", true).toString());
} catch( Exception ex){
puckTypes = PuckTypes.mixed;
}
switch(puckTypes){
case unipuck:
setSinglePuckType(PuckType.Unipuck);
break;
case minispine:
setSinglePuckType(PuckType.Minispine);
break;
case mixed:
//setSinglePuckType(PuckType.Unknown);
break;
}
}
final PuckSensorAccess puckSensorAccess = PuckSensorAccess.RaspberryPi;
static String PUCK_ESERA_DEVICE = "onewire";
@@ -55,7 +87,7 @@ public class Controller {
for (int i = 0; i < NUMBER_OF_PUCKS; i++) {
puckState[i] = new PuckState(i + 1);
}
this.mainFrame = (MainPanel)mainFrame;
this.mainFrame = (MainPanel) mainFrame;
instance = this;
}
@@ -102,7 +134,7 @@ public class Controller {
}
}
hexiposi = (Device) getMainFrame().getDevice("hexiposi");
if (hexiposi!=null){
if (hexiposi != null) {
hexiposi.addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
@@ -119,11 +151,11 @@ public class Controller {
public PuckState[] getPuckStates() {
return puckState;
}
public Puck getPuck(String name){
public Puck getPuck(String name) {
return basePlate.getPuckByName(name);
}
EseraDetection detection;
//From 1 to PUCKS_NUMBER
@@ -161,7 +193,7 @@ public class Controller {
try {
return getMainFrame().eval("is_led_room_temp()", true).equals(true);
} catch (Exception ex) {
return null;
return null;
}
}
@@ -169,26 +201,26 @@ public class Controller {
try {
return getMainFrame().eval("is_room_temp()", true).equals(true);
} catch (Exception ex) {
return null;
return null;
}
}
public String getWorkingMode(){
public String getWorkingMode() {
try {
return String.valueOf(getMainFrame().eval("robot.working_mode", true));
} catch (Exception ex) {
return "Unknown";
}
return "Unknown";
}
}
public boolean isManualMode(){
public boolean isManualMode() {
try {
return getMainFrame().eval("is_manual_mode()", true).equals(true);
} catch (Exception ex) {
return false;
return false;
}
}
public void imageDetectPucks() throws Context.ContextStateException {
imageDetectPucks(null, null, null);
}
@@ -203,7 +235,7 @@ public class Controller {
Map<String, List<String>> map = (Map<String, List<String>>) ret;
setImageDetection(map);
} else {
getMainFrame().showException((Exception)ex);
getMainFrame().showException((Exception) ex);
}
return ret;
});
@@ -213,21 +245,32 @@ 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();
updateView();
}
void setImageDetection(Map<String, List<String>> map){
for (Puck.ImageDetection id : Puck.ImageDetection.values()) {
for (String name : map.get(id.toString())) {
void setImageDetection(Map<String, List<String>> map) {
for (Puck.PuckType puckType : Puck.PuckType.values()) {
for (String name : map.get(puckType.toString())) {
Puck p = basePlate.getPuckByName(name);
if (p != null) {
p.setImageDetection(id);
p.setPuckType(puckType);
}
}
}
}
}
void setSinglePuckType(Puck.PuckType puckType) {
for (Puck p : basePlate.getPucks()) {
p.setPuckType(puckType);
}
}
void resetPuckTypes() {
for (Puck p : basePlate.getPucks()) {
p.setPuckType(Puck.PuckType.Unknown);
}
}
BasePlatePanel puckPanel;
void onPuckPressed(Puck puck){
//JPanel panel = new SinglePuckPanel(puck);