MainPanel prototype

This commit is contained in:
gac-S_Changer
2018-04-10 09:50:23 +02:00
parent fd15d2cf48
commit 1e2fee44d0
7 changed files with 75 additions and 37 deletions

View File

@@ -17,12 +17,21 @@ import java.util.logging.Level;
public class PuckDetection extends DeviceBase{
final String server;
public volatile Chrono chrono;
boolean debug;
public PuckDetection(String name, String server){
super(name);
this.server = server.startsWith("tcp://") ? server : "tcp://" + server;
}
public boolean isDebug(){
return debug;
}
public void setDebug(boolean value){
debug = value;
}
Thread thread;
Thread watchDog;
@@ -72,11 +81,16 @@ public class PuckDetection extends DeviceBase{
//subscriber.subscribe("Status".getBytes());
subscriber.subscribe("".getBytes());
try{
if (debug){
System.out.println("Start listening");
}
while (!Thread.currentThread().isInterrupted()) {
//String type = subscriber.recvStr();
//System.out.println(type);
String contents = subscriber.recvStr();
//System.out.println(contents);
if (debug){
System.out.println(contents);
}
processMessage(contents);
if (Controller.getInstance()!=null){
@@ -86,6 +100,10 @@ public class PuckDetection extends DeviceBase{
chrono = new Chrono();
}
} finally{
if (debug){
System.out.println("Stop listening");
}
if (Controller.getInstance()!=null){
Controller.getInstance().clearPuckStates();
}
@@ -107,7 +125,7 @@ public class PuckDetection extends DeviceBase{
for (List<List> bus : detection){
for (List<Integer> sensor : bus){
Integer indDetector = sensor.get(0);
Integer mecDetector = sensor.get(0);
Integer mecDetector = sensor.get(1);
PuckState puck = Controller.getInstance().getPuckState(id);
puck.set(mecDetector, indDetector);
@@ -132,9 +150,10 @@ public class PuckDetection extends DeviceBase{
}
public static void main(String[] args) throws IOException, InterruptedException {
PuckDetection pd = new PuckDetection("PD","129.129.110.83:5556");
pd.initialize();
PuckDetection pd = new PuckDetection("PD","129.129.110.99:5556");
//PuckDetection pd = new PuckDetection("PD","raspberrypi:5556");
pd.setDebug(true);
pd.initialize();
Thread.sleep(100000);
}
}