Skip to content

Commit

Permalink
Merge pull request micro-manager#1955 from nicost/acqEngJRunnables
Browse files Browse the repository at this point in the history
Make runnables work in the new Acquisition Engine.
  • Loading branch information
nicost authored May 23, 2024
2 parents c949e68 + 0cf440e commit b67fec6
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,30 @@ private void loadRunnables(SequenceSettings acquisitionSettings) {
currentAcquisition_.addHook(new AcquisitionHook() {
@Override
public AcquisitionEvent run(AcquisitionEvent event) {
boolean zMatch = event.getZIndex() == null || event.getZIndex() == r.slice_;
boolean tMatch = event.getTIndex() == null || event.getTIndex() == r.frame_;
boolean cMatch = event.getConfigPreset() == null
|| acquisitionSettings.channels().get(r.channel_).config()
.equals(event.getConfigPreset());
boolean pMatch = event.getAxisPosition(MDAAcqEventModules.POSITION_AXIS) == null
|| ((Integer) event.getAxisPosition(MDAAcqEventModules.POSITION_AXIS))
== r.position_;
if (event.isAcquisitionFinishedEvent()) {
return event;
}
int t = event.getTIndex() == null ? 0 : event.getTIndex();
boolean tMatch = r.frame_ < 0 || r.frame_ == t;
int p = event.getAxisPosition(MDAAcqEventModules.POSITION_AXIS) == null ? 0 :
(Integer) event.getAxisPosition(MDAAcqEventModules.POSITION_AXIS);
boolean pMatch = r.position_ < 0 || r.position_ == p;
boolean cMatch = r.channel_ < 0;
if (r.channel_ >= 0) {
String channelPreset = acquisitionSettings.channels().get(r.channel_).config();
if (channelPreset != null) {
cMatch = channelPreset.equals(event.getConfigPreset());
}
}
int z = event.getZIndex() == null ? 0 : event.getZIndex();
boolean zMatch = r.slice_ < 0 || r.slice_ == z;
if (pMatch && zMatch && tMatch && cMatch) {
// useful for logging, keep it
// studio_.scripter().message("Running runnable for "
// + r.frame_ + " (" + t + ") "
// + r.position_ + "( " + p + ") "
// + r.channel_ + "( " + event.getConfigPreset() + ") "
// + r.slice_ + "( " + z + ")");
r.runnable_.run();
}
return event;
Expand Down

0 comments on commit b67fec6

Please sign in to comment.