From a7dd7577df9dfcb5e2e40387008067a76db56074 Mon Sep 17 00:00:00 2001 From: Nico Stuurman Date: Thu, 21 Dec 2023 15:05:53 -0800 Subject: [PATCH 1/2] Engine: avoid hardware errors while running sequences. I encountered two problems: the NIDAQ board did not like to load a sequence while a sequence was still running. Stopping the sequence before loading it fixed that one. I believe that it should be posisble to avoid re-loading the exact same sequence all together. We could remember the previosu sequence and if this one is identical, skip loading. The other problem was that the prepareSequenceAcquistion call throws erros if the camera acquisition is still running. I am a bit surprised that code elsewhere is not checking for this. The way my PR is now waiting for the sequence to end is ugly, but I do not know of a better way. The upshot of all of this, is that this engine now has much less dead time between acquiring two volumes than the Clojure engine, which is very cool and useful. --- .../org/micromanager/acqj/internal/Engine.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/micromanager/acqj/internal/Engine.java b/src/main/java/org/micromanager/acqj/internal/Engine.java index d041023..aa13a50 100644 --- a/src/main/java/org/micromanager/acqj/internal/Engine.java +++ b/src/main/java/org/micromanager/acqj/internal/Engine.java @@ -194,9 +194,9 @@ public void checkForDefaultDevices(AcquisitionEvent event) { if (event.getZPosition() != null && (zStage == null || zStage.equals(""))) { throw new RuntimeException("Event requires a z position, but no Core-Focus device is set"); } - if (event.getXPosition() != null && (xyStage == null || xyStage.equals(""))) { - throw new RuntimeException("Event requires an x position, but no Core-XYStage device is set"); - } + if (event.getXPosition() != null && (xyStage == null || xyStage.equals(""))) { + throw new RuntimeException("Event requires an x position, but no Core-XYStage device is set"); + } } /** @@ -713,6 +713,11 @@ private void prepareHardware(final AcquisitionEvent event, hardwareSequencesInProgress.deviceNames.add(xyStage); } if (event.isZSequenced()) { + // at least some zStages freak out (in this case, NIDAQ board) when you + // try to load a sequence while the sequence is still running. Nothing in + // the engine stops a stage sequence if all goes well. + // Stopping a sequence if it is not running hopefully will not harm anyone. + core_.stopStageSequence(zStage); core_.loadStageSequence(zStage, zSequence); hardwareSequencesInProgress.deviceNames.add(zStage); } @@ -728,6 +733,11 @@ private void prepareHardware(final AcquisitionEvent event, } } } + // preparing a sequence while one is running is deadly. There must be a + // better way than this... + while (core_.isSequenceRunning()) { + Thread.sleep(1); + } core_.prepareSequenceAcquisition(core_.getCameraDevice()); From 7ecb96f0427d298bfc3ad361fae457160cef0cc7 Mon Sep 17 00:00:00 2001 From: Nico Stuurman Date: Sat, 23 Dec 2023 16:38:27 -0800 Subject: [PATCH 2/2] Bumped version to 0.34.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ff7574..b53ea46 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.micro-manager.acqengj AcqEngJ - 0.34.0 + 0.34.1 jar AcqEngJ Java-based Acquisition engine for Micro-Manager