Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

far from perfect... #1

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#auto update and compilation files ignored
bin/
update/
workspace/

#IntelliJ project files
.idea/
Icy-MicroManager.iml
setting.xml
..gitignore.swp
CHANGELOG.txt
COPYING.txt
CoreLogs/
README.txt
colormap/
hs_err_pid17643.log
icy.app/
icy.exe
icy.jar
icy.sh
ij/
lib/
out/
resources.jar
updater.jar
version.xml

1 change: 0 additions & 1 deletion bin/.gitignore

This file was deleted.

176 changes: 93 additions & 83 deletions src/plugins/tprovoost/Microscopy/MicroManager/MicroManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@
import javax.swing.WindowConstants;

import org.json.JSONObject;
import org.micromanager.MMStudio;
import org.micromanager.MMVersion;
import org.micromanager.acquisition.AcquisitionEngine;
import org.micromanager.acquisition.AcquisitionWrapperEngine;
import org.micromanager.acquisition.TaggedImageQueue;
import org.micromanager.api.IAcquisitionEngine2010;
import org.micromanager.api.SequenceSettings;
import org.micromanager.api.TaggedImageAnalyzer;
import org.micromanager.utils.MDUtils;
import org.micromanager.utils.ReportingUtils;
import org.micromanager.internal.MMStudio;
import org.micromanager.internal.MMVersion;
import org.micromanager.acquisition.internal.AcquisitionEngine;
import org.micromanager.acquisition.internal.AcquisitionWrapperEngine;
import org.micromanager.acquisition.internal.TaggedImageQueue;
import org.micromanager.data.Coords;
import org.micromanager.data.Image;
import org.micromanager.data.Metadata;
import org.micromanager.data.Processor;
import org.micromanager.data.ProcessorContext;
import org.micromanager.acquisition.internal.IAcquisitionEngine2010;
import org.micromanager.acquisition.SequenceSettings;
import org.micromanager.internal.utils.ImageUtils;
//TODO
//import org.micromanager.api.TaggedImageAnalyzer;
import org.micromanager.internal.utils.MDUtils;
import org.micromanager.internal.utils.ReportingUtils;

import icy.common.Version;
import icy.file.FileUtil;
Expand All @@ -32,6 +39,7 @@
import icy.system.thread.ThreadUtil;
import icy.util.ClassUtil;
import icy.util.StringUtil;
import ij.process.FloatProcessor;
import mmcorej.CMMCore;
import mmcorej.MMCoreJ;
import mmcorej.StrVector;
Expand Down Expand Up @@ -1317,8 +1325,9 @@ public static synchronized void init()
@Override
public void run()
{
//TODO refer to todo below
// In AWT Thread because it creates a JComponent
getAcquisitionEngine().addImageProcessor(new ImageAnalyser());
// getAcquisitionEngine().addImageProcessor(new ImageAnalyser());
}
});

Expand Down Expand Up @@ -1483,79 +1492,80 @@ public static void shutdown()
acquisitionManager = null;
}

// TODO this tagged image analyszer is no more existing in mm2; You should write a frame processor for this
// custom TaggedImageAnalyzer so we have events for new image
private static class ImageAnalyser extends TaggedImageAnalyzer
{
ImageAnalyser()
{
super();
}

@Override
protected void analyze(TaggedImage image)
{
final List<AcquisitionListener> listeners = getAcquisitionListeners();

try
{
// no more image or last one ?
if ((image == null) || TaggedImageQueue.isPoison(image))
{
if (acquisitionManager != null)
acquisitionManager.done();

// send acquisition ended event
for (AcquisitionListener l : listeners)
l.acquisitionFinished(getAcquisitionResult());

// done
return;
}

final JSONObject tags = image.tags;

boolean firstImage = (MDUtils.getPositionIndex(tags) == 0) && (MDUtils.getFrameIndex(tags) == 0)
&& (MDUtils.getChannelIndex(tags) == 0) && (MDUtils.getSliceIndex(tags) == 0);
boolean newAcquisition = (acquisitionManager == null) || acquisitionManager.isDone();

// first acquisition image or new acquisition --> create the new acquisition
if (firstImage || newAcquisition)
{
// end previous acquisition
if (!newAcquisition)
{
acquisitionManager.done();

// send acquisition ended event
for (AcquisitionListener l : listeners)
l.acquisitionFinished(getAcquisitionResult());
}

final SequenceSettings settings = getAcquisitionSettings();
final JSONObject metadata = getAcquisitionMetaData();

// create the acquisition manager
acquisitionManager = new AcquisitionResult(settings, metadata);

// send acquisition started event
for (AcquisitionListener l : listeners)
l.acquisitionStarted(settings, metadata);
}

// store image in acquisition manager only if storage is enabled
if (getStoreLastAcquisition())
acquisitionManager.imageReceived(image);

// send image received event
for (AcquisitionListener l : listeners)
l.acqImgReveived(image);
}
catch (Exception e)
{
IcyExceptionHandler.showErrorMessage(e, true);
}
}
}
// private static class ImageAnalyser extends TaggedImageAnalyzer
// {
// ImageAnalyser()
// {
// super();
// }
//
// @Override
// protected void analyze(TaggedImage image)
// {
// final List<AcquisitionListener> listeners = getAcquisitionListeners();
//
// try
// {
// // no more image or last one ?
// if ((image == null) || TaggedImageQueue.isPoison(image))
// {
// if (acquisitionManager != null)
// acquisitionManager.done();
//
// // send acquisition ended event
// for (AcquisitionListener l : listeners)
// l.acquisitionFinished(getAcquisitionResult());
//
// // done
// return;
// }
//
// final JSONObject tags = image.tags;
//
// boolean firstImage = (MDUtils.getPositionIndex(tags) == 0) && (MDUtils.getFrameIndex(tags) == 0)
// && (MDUtils.getChannelIndex(tags) == 0) && (MDUtils.getSliceIndex(tags) == 0);
// boolean newAcquisition = (acquisitionManager == null) || acquisitionManager.isDone();
//
// // first acquisition image or new acquisition --> create the new acquisition
// if (firstImage || newAcquisition)
// {
// // end previous acquisition
// if (!newAcquisition)
// {
// acquisitionManager.done();
//
// // send acquisition ended event
// for (AcquisitionListener l : listeners)
// l.acquisitionFinished(getAcquisitionResult());
// }
//
// final SequenceSettings settings = getAcquisitionSettings();
// final JSONObject metadata = getAcquisitionMetaData();
//
// // create the acquisition manager
// acquisitionManager = new AcquisitionResult(settings, metadata);
//
// // send acquisition started event
// for (AcquisitionListener l : listeners)
// l.acquisitionStarted(settings, metadata);
// }
//
// // store image in acquisition manager only if storage is enabled
// if (getStoreLastAcquisition())
// acquisitionManager.imageReceived(image);
//
// // send image received event
// for (AcquisitionListener l : listeners)
// l.acqImgReveived(image);
// }
// catch (Exception e)
// {
// IcyExceptionHandler.showErrorMessage(e, true);
// }
// }
// }

private static class LiveListenerThread extends Thread
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@

import org.json.JSONException;
import org.json.JSONObject;
import org.micromanager.MMStudio;
import org.micromanager.api.SequenceSettings;
import org.micromanager.dialogs.AcqControlDlg;
import org.micromanager.utils.MDUtils;
import org.micromanager.internal.MMStudio;
import org.micromanager.acquisition.SequenceSettings;
import org.micromanager.data.Image;
import org.micromanager.internal.dialogs.AcqControlDlg;
import org.micromanager.internal.utils.MDUtils;

import plugins.tprovoost.Microscopy.MicroManager.MicroManager;
import plugins.tprovoost.Microscopy.MicroManager.event.AcquisitionListener;
Expand Down Expand Up @@ -73,8 +74,7 @@ private void initDialog(MMMainFrame mainFrame)

// not existing yet ? --> create it now
if (advAcqDialog == null)
advAcqDialog = new AcqControlDlg(mmstudio.getAcquisitionEngine(), mainFrame.getMainPreferences(), mmstudio,
mainFrame.getOptions());
advAcqDialog = new AcqControlDlg(mmstudio.getAcquisitionEngine(),mmstudio);

// remove some of the default window listener
final WindowListener[] winListeners = advAcqDialog.getWindowListeners();
Expand Down Expand Up @@ -253,7 +253,7 @@ public void run()
}

@Override
public void acqImgReveived(TaggedImage newImg)
public void acqImgReveived(Image newImg)
{
ThreadUtil.invokeLater(new Runnable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

import org.json.JSONException;
import org.json.JSONObject;
import org.micromanager.api.SequenceSettings;
import org.micromanager.utils.MDUtils;
import org.micromanager.acquisition.SequenceSettings;
import org.micromanager.internal.utils.MDUtils;
import org.micromanager.data.Coords;
import org.micromanager.data.internal.DefaultImage;

import icy.main.Icy;
import icy.sequence.Sequence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import java.util.List;

import mmcorej.TaggedImage;

import org.json.JSONObject;
import org.micromanager.api.SequenceSettings;
import org.micromanager.acquisition.SequenceSettings;
import org.micromanager.data.Image;

import plugins.tprovoost.Microscopy.MicroManager.MicroManager;
import plugins.tprovoost.Microscopy.MicroManager.tools.MMUtils;
Expand All @@ -32,7 +31,7 @@ public interface AcquisitionListener
* @see MicroManager#getAcquisitionResult()
* @see MicroManager#setStoreLastAcquisition(boolean)
*/
public void acqImgReveived(TaggedImage image);
public void acqImgReveived(Image image);

/**
* Callback when {@link MicroManager#startAcquisition(int, double)} have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

import org.micromanager.MMVersion;
import org.micromanager.internal.MMVersion;

public class AboutPanel extends JPanel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import javax.swing.border.TitledBorder;

import org.json.JSONObject;
import org.micromanager.MMStudio;
import org.micromanager.internal.MMStudio;
import org.micromanager.internal.utils.ReportingUtils;

import icy.gui.component.button.IcyButton;
import icy.gui.component.button.IcyToggleButton;
Expand Down Expand Up @@ -214,12 +215,12 @@ public void unlock()

public void logError(Exception e)
{
getMMStudio().logError(e);
ReportingUtils.logError(e);
}

public void logError(Exception e, String msg)
{
getMMStudio().logError(e, msg);
ReportingUtils.logError(e, msg);
}

public void setLiveMode(boolean enable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import mmcorej.MMCoreJ;
import mmcorej.StrVector;

import org.micromanager.MMStudio;
import org.micromanager.internal.MMStudio;
import org.micromanager.internal.utils.ReportingUtils;

import plugins.tprovoost.Microscopy.MicroManager.MicroManager;

Expand Down Expand Up @@ -323,12 +324,12 @@ public void unlock()

public void logError(Exception e)
{
getMMStudio().logError(e);
ReportingUtils.logError(e);
}

public void logError(Exception e, String msg)
{
getMMStudio().logError(e, msg);
ReportingUtils.logError(e, msg);
}

public String getCameraName()
Expand Down Expand Up @@ -410,7 +411,7 @@ void setShutterCore(String value)
}
catch (Exception e)
{
getMMStudio().logError(e);
ReportingUtils.logError(e);
}
}

Expand Down
Loading