Skip to content

Commit

Permalink
Merge pull request #279 from bls337/main
Browse files Browse the repository at this point in the history
add checks before starting an acq; add checks on plugin startup
  • Loading branch information
bls337 authored May 2, 2024
2 parents 20a6bc1 + b7d1fcb commit d5cd336
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public LightSheetManagerFrame(final LightSheetManagerModel model, final boolean

// create the user interface
if (isLoaded) {
initDialogs();
GeometryType geometryType = model_.devices()
.getDeviceAdapter().getMicroscopeGeometry();
switch (geometryType) {
Expand Down Expand Up @@ -139,7 +140,7 @@ private void createUserInterface() {
WindowUtils.registerWindowClosingEvent(this, event -> {
tabPanel_.getNavigationTab().getNavigationPanel().stopPolling();
model_.getUserSettings().save();
System.out.println("main window closed!");
studio_.logs().logMessage("user settings saved");
});

}
Expand All @@ -153,6 +154,14 @@ public Studio getStudio_() {
return studio_;
}

/**
* Detect settings after the model is loaded,
* ask to change settings with dialogs.
*/
private void initDialogs() {
model_.devices().checkDevices(this);
}

public void toggleLiveMode() {
if (studio_.live().isLiveModeOn()) {
studio_.live().setLiveModeOn(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public static String showTextEntryDialog(final JFrame frame, final String title,
JOptionPane.PLAIN_MESSAGE, null, null, "");
}

public static int showYesNoDialog(final JFrame frame, final String title, final String message) {
return JOptionPane.showConfirmDialog(frame, message, title, JOptionPane.YES_NO_OPTION);
}

/**
* Shows a customized message dialog box, this method does not log the error.<P>
* This is used for reporting errors in the AcquisitionTable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import mmcorej.CMMCore;
import mmcorej.DeviceType;
import org.micromanager.Studio;
import org.micromanager.lightsheetmanager.gui.utils.DialogUtils;
import org.micromanager.lightsheetmanager.model.devices.DeviceBase;
import org.micromanager.lightsheetmanager.model.devices.Galvo;
import org.micromanager.lightsheetmanager.model.devices.LightSheetDeviceManager;
Expand All @@ -24,6 +25,7 @@
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIXYStage;
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIZStage;

import javax.swing.JFrame;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -419,4 +421,37 @@ private ArrayList<String> updateConfig(final String groupName, final String conf
return newProperties;
}

// TODO: adapt for diSPIM and multiple cameras
/**
* Check user settings and ask to change settings with dialogs.
*/
public void checkDevices(final JFrame frame) {

final String cameraKey = "ImagingCamera";
CameraBase cameraDevice = getDevice(cameraKey);
CameraLibrary cameraLib = CameraLibrary.UNKNOWN;
if (cameraDevice != null) {
cameraLib = CameraLibrary.fromString(cameraDevice.getDeviceLibrary());
}

switch (cameraLib) {
case HAMAMATSU:
// Flash4, Fusion, etc
HamamatsuCamera camera = getDevice(cameraKey);
if (camera.getTriggerPolarity().equals(HamamatsuCamera.Values.NEGATIVE)) {
final int result = DialogUtils.showYesNoDialog(frame, "Hamamatsu Camera",
"The trigger polarity should be set to POSITIVE. Set it now?");
if (result == 0) {
camera.setTriggerPolarity(HamamatsuCamera.Values.POSITIVE);
}
}
break;
case PVCAM:
// Kinetix, etc
break;
default:
break;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public AcquisitionEngineSCAPE(final LightSheetManagerModel model) {
@Override
boolean setup() {

// this is needed for LSMAcquisitionEvents to work with multiple positions
if (core_.getFocusDevice().isEmpty()
&& acqSettings_.isUsingMultiplePositions()) {
studio_.logs().showError("The default focus device \"Core-Focus\" needs to be set to use multiple positions.");
}

// make sure that there are positions in the PositionList
if (acqSettings_.isUsingMultiplePositions()) {
final int numPositions = studio_.positions().getPositionList().getNumberOfPositions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static class Properties {
public static final String CAMERA_BUS = "Camera Bus";
public static final String TRIGGER_SOURCE = "TRIGGER SOURCE";
public static final String TRIGGER_ACTIVE = "TRIGGER ACTIVE";
public static final String TRIGGER_POLARITY = "TriggerPolarity";
public static final String SENSOR_MODE = "SENSOR MODE";
public static final String INTERNAL_LINE_INTERVAL = "INTERNAL LINE INTERVAL";
public static final String SCAN_MODE = "ScanMode";
Expand All @@ -39,6 +40,8 @@ public static class Values {
public static final String PROGRESSIVE = "PROGRESSIVE";
public static final String AREA = "AREA";
public static final String USB3 = "USB3";
public static final String POSITIVE = "POSITIVE";
public static final String NEGATIVE = "NEGATIVE";
public static final String SCAN_MODE_1 = "1";
public static final String SCAN_MODE_2 = "2";
public static final String SCAN_MODE_3 = "3";
Expand Down Expand Up @@ -238,4 +241,13 @@ public boolean isFusion() {
public boolean isFlash4() {
return getProperty(Properties.CAMERA_NAME).startsWith(Models.FLASH4);
}

public String getTriggerPolarity() {
return getProperty(Properties.TRIGGER_POLARITY);
}

public void setTriggerPolarity(final String polarity) {
setProperty(Properties.TRIGGER_POLARITY, polarity);
}

}

0 comments on commit d5cd336

Please sign in to comment.