Skip to content

Commit

Permalink
Merge pull request #88 from nicost/nullEvents
Browse files Browse the repository at this point in the history
Adds a way to end an  event "branch" using null as a signal
  • Loading branch information
nicost authored May 26, 2023
2 parents 3798f07 + 9851932 commit ba5c336
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.micro-manager.acqengj</groupId>
<artifactId>AcqEngJ</artifactId>
<version>0.26.5</version>
<version>0.26.6</version>
<packaging>jar</packaging>
<name>AcqEngJ</name>
<description>Java-based Acquisition engine for Micro-Manager</description>
Expand All @@ -24,7 +24,7 @@
<developer>
<id>nicost</id>
<name>Nico Stuurman</name>
<organization>UCSF/HHMI</organization>
<organization>Altos Labs</organization>
</developer>
</developers>

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/micromanager/acqj/internal/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public Future submitEventIterator(Iterator<AcquisitionEvent> 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() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -59,7 +63,7 @@ public AcquisitionEvent next() {
}
descendNewBranch();
}
// System.out.println(next);

if (eventMonitorFunction_ == null) {
return next;
}
Expand Down

0 comments on commit ba5c336

Please sign in to comment.