diff --git a/pom.xml b/pom.xml index 2bfe47b..7b4faaa 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.micro-manager.acqengj AcqEngJ - 0.26.5 + 0.26.6 jar AcqEngJ Java-based Acquisition engine for Micro-Manager @@ -24,7 +24,7 @@ nicost Nico Stuurman - UCSF/HHMI + Altos Labs diff --git a/src/main/java/org/micromanager/acqj/internal/Engine.java b/src/main/java/org/micromanager/acqj/internal/Engine.java index f9d4762..7f9fd4f 100644 --- a/src/main/java/org/micromanager/acqj/internal/Engine.java +++ b/src/main/java/org/micromanager/acqj/internal/Engine.java @@ -122,6 +122,11 @@ public Future submitEventIterator(Iterator eventIterator) { AcquisitionAPI acq = null; while (eventIterator.hasNext()) { AcquisitionEvent event = eventIterator.next(); + // Some iterators can return null, they still may have more events, but want to + // skip this one. + if (event == null) { + continue; + } acq = event.acquisition_; if (acq.isDebugMode()) { core_.logMessage("got event: " + event.toString() ); diff --git a/src/main/java/org/micromanager/acqj/util/AcquisitionEventIterator.java b/src/main/java/org/micromanager/acqj/util/AcquisitionEventIterator.java index 8b48367..0eeddf2 100644 --- a/src/main/java/org/micromanager/acqj/util/AcquisitionEventIterator.java +++ b/src/main/java/org/micromanager/acqj/util/AcquisitionEventIterator.java @@ -41,16 +41,20 @@ public boolean hasNext() { @Override public AcquisitionEvent next() { - AcquisitionEvent next = currentLeaf_.iterator.next(); - //Move to new branch or determine that all branches are exhausted - //May need to try ascent and descent multiple times in case a terminal iterator produces no events? + AcquisitionEvent next = null; + while (next == null && currentLeaf_.iterator.hasNext()) { + next = currentLeaf_.iterator.next(); + } + + // Move to new branch or determine that all branches are exhausted + // May need to try ascent and descent multiple times in case a terminal iterator + // produces no events? while (!currentLeaf_.iterator.hasNext()) { //ascend to node where next valid branch can be found while (!currentLeaf_.iterator.hasNext()) { currentLeaf_ = currentLeaf_.parent; if (currentLeaf_ == null) { eventsExhausted_ = true; -// System.out.println(next); if (eventMonitorFunction_ == null) { return next; } @@ -59,7 +63,7 @@ public AcquisitionEvent next() { } descendNewBranch(); } -// System.out.println(next); + if (eventMonitorFunction_ == null) { return next; }