Commit 09728480 authored by Aliaksandr Halavatyi's avatar Aliaksandr Halavatyi
Browse files

work on the microscope commander

parent 1c0dccf4
......@@ -8,7 +8,7 @@
<version>5.0</version> <relativePath /> </parent> -->
<groupId>embl.almf</groupId>
<artifactId>AutoMicTools_</artifactId>
<version>1.1.21-SNAPSHOT</version>
<version>1.1.22-SNAPSHOT</version>
<name>plugins/AutoMicTools_.jar</name>
<description>Collection of tools for automated (feedback) microscopy data acquisition and analysis</description>
......
......@@ -15,6 +15,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
......@@ -40,6 +41,8 @@ import de.embl.cba.utils.ij.Close_all_forced;
public abstract class JobDistributor_Abstract extends RunJythonOnMonitoredFiles implements PlugIn {
private static final String PREFS_PREFIX="Automic.JobDistributor";
private static final String KEY_EXPERIMENT_PATH="Experiment folder";
......@@ -49,8 +52,12 @@ public abstract class JobDistributor_Abstract extends RunJythonOnMonitoredFiles
private static final String KEY_FILE_EXTENSION="Image File Extension";
private static final String KEY_FILL_JOB_PARAMETERS_FROM_FILE="Fill parameters from file";
private static final String KEY_INPUT_JOB_PARAMETERS="Input file with job parameters";
private static final String KEY_MICROSCOPE_COMMANDER="Microscope commander";
private Map<String,Class<? extends MicroscopeCommanderInterface>> microscopeCommanderMap;
protected ParameterCollection distributorParameters;
Node jobsNode;
......@@ -180,6 +187,12 @@ public abstract class JobDistributor_Abstract extends RunJythonOnMonitoredFiles
params.addParameter(KEY_FILL_JOB_PARAMETERS_FROM_FILE, false, null, ParameterType.BOOL_PARAMETER);
params.addParameter(KEY_INPUT_JOB_PARAMETERS, "", null, ParameterType.FILEPATH_PARAMETER);
Set<String> keySet=microscopeCommanderMap.keySet();
String[] commanderNames=keySet.toArray(new String[keySet.size()]);
params.addSelectionParameter(KEY_MICROSCOPE_COMMANDER, commanderNames[0], commanderNames[0], ParameterType.STRING_PARAMETER, commanderNames);
return params;
}
......@@ -187,7 +200,14 @@ public abstract class JobDistributor_Abstract extends RunJythonOnMonitoredFiles
public JobDistributor_Abstract(){
super();
microscopeCommanderMap=MicroscopeCommanderFactory.identifyCommanders();
distributorParameters=createDistributorParameters();
microscopeCommander = MicroscopeCommanderFactory.createMicroscopeCommander(microscopeCommanderMap.get(distributorParameters.getParameterStringValue(KEY_MICROSCOPE_COMMANDER)),null);
try{
ParameterPrefsManager.setParametersFromFijiPrefs(distributorParameters, PREFS_PREFIX);
}catch (Exception _ex){
......@@ -237,7 +257,7 @@ public abstract class JobDistributor_Abstract extends RunJythonOnMonitoredFiles
}
//
job.initialise(_fileTag, _colTag, _visual);
job.initialise(_fileTag, _colTag, _visual, microscopeCommander);
JobList.add(job);
}catch (Exception ex){
Utils.generateErrorMessage("Can not initialise Job", "Can not initialise Job: "+_JobClass.getName());
......@@ -308,8 +328,11 @@ public abstract class JobDistributor_Abstract extends RunJythonOnMonitoredFiles
public void startFolderMonitoring() throws Exception {
microscopeCommander = MicroscopeCommanderFactory.createMicroscopeCommander(MicroscopeCommanderFactory.ZEISS_ZEN_BLACK,null);
//microscopeCommander = MicroscopeCommanderFactory.createMicroscopeCommander(MicroscopeCommanderFactory.ZEISS_ZEN_BLACK,null);
IJ.log("Created microscope commander: "+ microscopeCommander);
super.startMonitoring();
ewr=new ExceptionWriter(getWatchpath());
}
......
......@@ -3,6 +3,7 @@ import java.io.File;
import java.util.Date;
import java.util.Map;
import automic.online.microscope.MicroscopeCommanderInterface;
import automic.online.microscope.ZeissKeys;
import automic.parameters.ParameterCollection;
import automic.table.TableModel;
......@@ -51,6 +52,8 @@ public class Job_Default {
protected String imgColumnNm; //tag of the file columns in the output table where triggering image is stored
protected String fileTag; //unique name of the triggering tag
protected boolean visOnline; //flag telling whether visualisation should run online
protected MicroscopeCommanderInterface microscopeCommander;
private Map<String,Object> sharData;
......@@ -62,11 +65,17 @@ public class Job_Default {
* @param _visOnline whether visualisation procedure to be called online
*/
public void initialise(String _fTag,String _colNm, boolean _visOnline){
this.initialise(_fTag, _colNm, _visOnline, null);
}
public void initialise(String _fTag,String _colNm, boolean _visOnline, MicroscopeCommanderInterface _microscopeCommander){
this.fileTag=_fTag;
this.imgColumnNm=_colNm;
this.visOnline=_visOnline;
this.microscopeCommander=_microscopeCommander;
}
public String getFileTag(){
return fileTag;
}
......
package automic.online.microscope;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.reflections.Reflections;
import automic.parameters.ParameterCollection;
import automic.utils.Utils;
......@@ -10,6 +16,25 @@ public abstract class MicroscopeCommanderFactory {
//public static final String OLYMPUS_FV3000="Olympus_FV3000";
public static Map<String,Class<? extends MicroscopeCommanderInterface>> identifyCommanders(){
Map<String,Class<? extends MicroscopeCommanderInterface>> microscopeCommanderMap=new HashMap<>();
Reflections reflections = new Reflections("automic.online.microscope");
Set<Class<? extends MicroscopeCommanderInterface>> microscopeCommanderClasses = reflections.getSubTypesOf(MicroscopeCommanderInterface.class);
for (Class<? extends MicroscopeCommanderInterface> type : microscopeCommanderClasses) {
microscopeCommanderMap.put(type.getSimpleName(), type);
}
return microscopeCommanderMap;
}
public static MicroscopeCommanderInterface createMicroscopeCommander(String _microscopeTypeTag, ParameterCollection _commanderParameters){
switch (_microscopeTypeTag) {
case ZEISS_ZEN_BLACK: return new ZenBlackCommander();
......
package automic.online.microscope;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.io.File;
import com.eclipsesource.json.JsonObject;
import automic.geom.Point3D;
import automic.parameters.ParameterCollection;
import ij.gui.Roi;
public interface MicroscopeCommanderInterface {
public void parseSettings(ParameterCollection _microscopeSettings);
......@@ -11,4 +19,11 @@ public interface MicroscopeCommanderInterface {
public void skipJobsInCurrentPosition();
public void stopCommander();
public void submitJobPixels(File _sourceImageFile, String _jobNameToPerform, Point3D[] _positions,Roi[] _bleachRois)throws Exception;
public void submitJobPixels(File _sourceImageFile, String _jobNameToPerform, Point3D _position) throws Exception;
public void submitJobPixels(File _sourceImageFile, String _jobNameToPerform, Point3D[] _positions) throws Exception;
}
package automic.online.microscope;
import java.io.File;
import automic.geom.Point3D;
import automic.parameters.ParameterCollection;
import ij.gui.Roi;
public class ZenBlackCommander implements MicroscopeCommanderInterface {
@Override
......@@ -20,4 +24,22 @@ public class ZenBlackCommander implements MicroscopeCommanderInterface {
@Override
public void stopCommander() {}
@Override
public void submitJobPixels(File _sourceImageFile, String _jobNameToPerform, Point3D[] _positions,Roi[] _bleachRois)throws Exception{
throw new Exception("ZenBlackCommander.submitJobPixels().Method has not been implemented");
}
@Override
public void submitJobPixels(File _sourceImageFile, String _jobNameToPerform, Point3D _position)
throws Exception{
submitJobPixels(_sourceImageFile, _jobNameToPerform, new Point3D[] {_position},null);
}
@Override
public void submitJobPixels(File _sourceImageFile, String _jobNameToPerform, Point3D[] _positions)
throws Exception{
submitJobPixels(_sourceImageFile, _jobNameToPerform, _positions, null);
}
}
......@@ -20,4 +20,13 @@ public class SelectionParameter extends Parameter{
if (options.indexOf(_value)<0)
throw new IllegalArgumentException("Specified value is not in the permitted list");
}
public String[] getOptionsAsStringArray() {
String[] optionsArray=new String[options.size()];
for (int i=0;i<options.size();i++) {
optionsArray[i]=options.get(i).toString();
}
return optionsArray;
}
}
......@@ -6,6 +6,7 @@ import automic.parameters.ArrayParameter;
import automic.parameters.Parameter;
import automic.parameters.ParameterCollection;
import automic.parameters.ParameterType;
import automic.parameters.SelectionParameter;
import fiji.util.gui.GenericDialogPlus;
import ij.gui.GenericDialog;
......@@ -34,6 +35,15 @@ public class ParameterGuiManager{
continue;
}
if (currentParameter instanceof SelectionParameter) {
String[] options=((SelectionParameter)currentParameter).getOptionsAsStringArray();
gd.addChoice(key, options, options[0]);
continue;
}
switch (currentParameter.getType()) {
case ParameterType.STRING_PARAMETER:
gd.addStringField(key, (String)currentParameter.getValue());
......@@ -82,6 +92,12 @@ public class ParameterGuiManager{
continue;
}
if (currentParameter instanceof SelectionParameter) {
currentParameter.setValueFromString(_dialog.getNextChoice());
continue;
}
switch (currentParameter.getType()) {
case ParameterType.STRING_PARAMETER:
currentParameter.setValue(_dialog.getNextString());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment