-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ResamplerFix
- Loading branch information
Showing
12 changed files
with
409 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
java/src/main/java/org/micromanager/remote/RemoteNotificationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.micromanager.remote; | ||
|
||
import mmcorej.org.json.JSONException; | ||
import org.micromanager.acqj.api.AcqNotificationListener; | ||
import org.micromanager.acqj.api.AcquisitionAPI; | ||
import org.micromanager.acqj.main.AcqNotification; | ||
import org.micromanager.acqj.main.Acquisition; | ||
import org.micromanager.internal.zmq.ZMQPushSocket; | ||
import org.micromanager.ndtiffstorage.IndexEntryData; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.LinkedBlockingDeque; | ||
|
||
/** | ||
* A class that broadcasts information about images that have finsihed saving to disk | ||
* @author henrypinkard | ||
*/ | ||
public class RemoteNotificationHandler implements AcqNotificationListener { | ||
|
||
private ZMQPushSocket<AcqNotification> pushSocket_; | ||
private ExecutorService executor_ = Executors.newSingleThreadExecutor((Runnable r) -> { | ||
return new Thread(r, "Remote notification thread"); | ||
}); | ||
private LinkedBlockingDeque<AcqNotification> notifications_ = new LinkedBlockingDeque<AcqNotification>(); | ||
|
||
/** | ||
* Called by python side | ||
*/ | ||
public RemoteNotificationHandler(AcquisitionAPI acq) { | ||
acq.addAcqNotificationListener(this); | ||
executor_.submit(new Runnable() { | ||
@Override | ||
public void run() { | ||
pushSocket_ = new ZMQPushSocket<AcqNotification>( | ||
t -> { | ||
try { | ||
return t.toJSON(); | ||
} catch (JSONException e) { | ||
throw new RuntimeException("Problem with notification socket"); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Start pushing out the indices to the other side | ||
*/ | ||
public void start() { | ||
//constantly poll the socket for more event sequences to submit | ||
executor_.submit(() -> { | ||
while (true) { | ||
AcqNotification e = null; | ||
try { | ||
e = notifications_.takeFirst(); | ||
} catch (InterruptedException ex) { | ||
// this should never happen | ||
ex.printStackTrace(); | ||
throw new RuntimeException(ex); | ||
} | ||
|
||
pushSocket_.push(e); | ||
if (e.isAcquisitionFinishedNotification()) { | ||
return; | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void postNotification(AcqNotification n) { | ||
notifications_.add(n); | ||
} | ||
|
||
/** | ||
* Called by the python side to signal that the final shutdown signal has been received | ||
* and that the push socket can be closed | ||
*/ | ||
public void notificationHandlingComplete() { | ||
executor_.submit(() -> { | ||
pushSocket_.close(); | ||
executor_.shutdown(); | ||
}); | ||
} | ||
|
||
public int getPort() { | ||
while (pushSocket_ == null) { | ||
try { | ||
Thread.sleep(1); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
return pushSocket_.getPort(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
version_info = (0, 28, 1) | ||
version_info = (0, 28, 2) | ||
__version__ = ".".join(map(str, version_info)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.