diff --git a/src/main/java/ch/psi/mxsc/PuckDetection.java b/src/main/java/ch/psi/mxsc/PuckDetection.java index 44f1dc0..36c2358 100644 --- a/src/main/java/ch/psi/mxsc/PuckDetection.java +++ b/src/main/java/ch/psi/mxsc/PuckDetection.java @@ -164,9 +164,11 @@ public class PuckDetection extends DeviceBase { for (List sensor : bus) { Integer indDetector = sensor.get(0); Integer mecDetector = sensor.get(1); - int index = Controller.getInstance().getPuckIndex(address); - PuckState puck = Controller.getInstance().getPuckState(index); - puck.set(mecDetector, indDetector); + if (Controller.getInstance()!=null){ + int index = Controller.getInstance().getPuckIndex(address); + PuckState puck = Controller.getInstance().getPuckState(index); + puck.set(mecDetector, indDetector); + } address++; } } @@ -177,10 +179,16 @@ public class PuckDetection extends DeviceBase { } public PuckState getPuckState(int id) throws Exception { + if (Controller.getInstance() == null) { + return null; + } return Controller.getInstance().getPuckState(id); } - public Puck getPuck(String name) throws Exception { + public Puck getPuck(String name) throws Exception { + if (Controller.getInstance() == null) { + return null; + } return Controller.getInstance().getPuck(name); } @@ -204,8 +212,9 @@ public class PuckDetection extends DeviceBase { } public static void main(String[] args) throws IOException, InterruptedException { - PuckDetection pd = new PuckDetection("PD", "129.129.110.99:5556"); + //PuckDetection pd = new PuckDetection("PD", "129.129.110.99:5556"); //PuckDetection pd = new PuckDetection("PD","raspberrypi:5556"); + PuckDetection pd = new PuckDetection("PD", "tell10s-raspberrypi:5556"); pd.setDebug(true); pd.initialize(); Thread.sleep(100000);