nicost / micro-manager

Microscope control and image acquisition integrated with ImageJ.
http://www.micro-manager.org
16 stars 11 forks source link

attachRunnable in micromanager gamma - something changed? #68

Closed nicost closed 5 years ago

nicost commented 5 years ago

Reported by MonikaP:

I have a script that worked in micromanager beta. It contains the following lines:

mm.acquisitions().attachRunnable(0, 0, 0, 0, starting); // f, p, c, s mm.acquisitions().attachRunnable(0, -1, 0, 0, runnable); // f, p, c, s mm.acquisitions().runAcquisition();

In micromanager gamma, weirdness happends. If any one of the two runnables is commented out, the rest works. If both gets attached, the first runnable "starting" gets executed, the second "runnable" gets executed twice (when there are three positions on the list, so should execute 3 times), but no images are received, "Received 00 of 18 images" in Acquisition Progress. The runnables are only for opening external shutters and waiting between positions.

Any idea what can be going wrong? Or how I can rewrite my code?

Okay, I did some testing with a very simple runnable:

stupid1 = new Runnable() { public void run() { print("I'm stupid runnable 1"); } };

It is not possible to attach two runnables to the same plane. Combinations such as:

mm.acquisitions().attachRunnable(0, 0, 0, 0, stupid1); mm.acquisitions().attachRunnable(0, 0, 0, 0, stupid2); //two runnables to position 0

mm.acquisitions().attachRunnable(0, 0, 0, 0, stupid1); mm.acquisitions().attachRunnable(0, -1, 0, 0, stupid2); //one for position 0, one for all positions

Cause images to stop coming (but the runnables are still run, the messages get printed!).

Why is this so? How can I achieve what I need, run one piece of code at startup, and another one (ie waiting) for every position?

ctr26 commented 5 years ago

You could attach the new runnable inside the initialisation runnable? Will check at my workstation.

mm.acquisitions().clearRunnables();

public stupid2 = new Runnable() {
public void run() {
print("I'm stupid runnable 2");
}
};

stupid1 = new Runnable() {
public void run() {
print("I'm stupid runnable 1");
mm.acquisitions().attachRunnable(-1, -1, -1, -1, stupid2);
}
};

mm.acquisitions().attachRunnable(0, 0, 0, 0, stupid1);
nicost commented 5 years ago

Fixed in commits 60ec569ed6ba62f815c6d504b72de8b7f9617dfd and 7719f12888d0b7c6a90a83b241f164262495c7e3

pawlowska commented 5 years ago

@nicost yes, it works for me now, thanks!