Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class LightSheetManagerPlugin implements MenuPlugin, SciJavaPlugin {
public static final String copyright = "Applied Scientific Instrumentation (ASI), 2022-2026";
public static final String description = "A plugin to control various types of light sheet microscopes.";
public static final String menuName = "Light Sheet Manager";
public static final String version = "0.8.15";
public static final String version = "0.8.16";

private Studio studio_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public NavigationPanel getNavigationPanel() {

@Override
public void selected() {

// the beam may have been turned on or off on another tab or by an acquisition
navigationPanel_.updateBeamState();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public String toString() {
}
}

private static final String BEAM_ENABLED = "BeamEnabled";

private final CMMCore core_;

// data
Expand All @@ -60,6 +62,9 @@ public String toString() {
private Button btnMoveToZero_;
private Button btnSetZero_;

// true for a galvo whose device can blank the beam
private final boolean hasBeam_;

private final LightSheetManager model_;

public ControlPanel(final LightSheetManager model, final String propertyName, final String deviceName, final DeviceType deviceType, final Axis axis, final Units units) {
Expand All @@ -70,8 +75,10 @@ public ControlPanel(final LightSheetManager model, final String propertyName, fi
deviceType_ = Objects.requireNonNull(deviceType);
axis_ = axis;
units_ = units;
hasBeam_ = deviceType_ == DeviceType.GalvoDevice && hasBeamProperty();
createUserInterface();
createEventHandlers();
updateBeamState();
}

public String getPropertyName() {
Expand Down Expand Up @@ -464,4 +471,37 @@ public void update(String topic, Object value) {
lblPosition_.setText(String.format("%.3f %s", position, units_)));
}

/**
* Enables the move controls of a galvo only while its beam is on.
*/
public void updateBeamState() {
if (!hasBeam_) {
return;
}
final boolean isBeamOn = isBeamOn();
SwingUtilities.invokeLater(() -> {
txtAbsoluteMove_.setEnabled(isBeamOn);
btnRelMoveMinus_.setEnabled(isBeamOn);
btnRelMovePlus_.setEnabled(isBeamOn);
btnMoveToZero_.setEnabled(isBeamOn);
});
}

private boolean hasBeamProperty() {
try {
return core_.hasProperty(deviceName_, BEAM_ENABLED);
} catch (Exception e) {
return false;
}
}

// the device adapter answers from its own state, so this does not query the controller
private boolean isBeamOn() {
try {
return "Yes".equals(core_.getProperty(deviceName_, BEAM_ENABLED));
} catch (Exception e) {
return true; // a failed read should not lock the controls
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,12 @@ private boolean containsDigit(final String str) {
return containsDigit;
}

/**
* Updates the controls that depend on the beam, which can be turned on and off elsewhere.
*/
public void updateBeamState() {
for (ControlPanel controlPanel : controlPanels_) {
controlPanel.updateBeamState();
}
}
}
Loading