Skip to content

Commit e95cf2c

Browse files
Merge pull request #890 from annie-xd-wang/deal-with-removed/broken-plugins
Deal with removed/broken plugins
2 parents f1a9291 + 219ffb3 commit e95cf2c

File tree

5 files changed

+54
-14
lines changed

5 files changed

+54
-14
lines changed

docs/source/user_guide/hardware/configurations/configuration_ctaslmv2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ microscopes:
2121
serial_number: 302153
2222
flip_x: True
2323
flip_y: False
24-
defect_correct_mode: 1.0
24+
defect_correct_mode: 2.0
2525
delay: 20
2626
remote_focus_device:
2727
hardware:

docs/source/user_guide/hardware/configurations/configuration_mesospimbt.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ microscopes:
1919
hardware:
2020
type: HamamatsuOrca
2121
serial_number: 003209
22-
defect_correct_mode: 1.0 #2.0
22+
defect_correct_mode: 2.0 #2.0
2323
delay: 10 #ms
2424
settle_down: 0.0 #ms
2525
flip_x: True

docs/source/user_guide/hardware/remote_focus.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ The `BLINK <https://www.thorlabs.com/thorproduct.cfm?partnumber=BLINK>`_ and the
6565
`Optotune Focus Tunable Lens <https://www.optotune.com/tunable-lenses>`_ are
6666
controlled with an analog signal from the DAQ.
6767

68+
-----------------
69+
6870
Thorlabs BLINK
6971
~~~~~~~~~~~~~~
7072
The BLINK is a voice coil that is
@@ -89,6 +91,8 @@ voltage outside of its operating range.
8991
9092
|
9193
94+
-----------------
95+
9296
Optotune Focus Tunable Lens
9397
~~~~~~~~~~~~~~~~~~~~~~~~~~~
9498

docs/source/user_guide/hardware/stage.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ first establish communication with the device using `ASI provided software <http
9595
flip_z: False
9696
flip_f: False
9797
98+
-----------------
9899

99100
MFC2000
100101
~~~~~~~
@@ -146,6 +147,7 @@ MFC2000
146147
147148
|
148149
150+
-----------------
149151

150152
MS2000
151153
~~~~~~~
@@ -264,6 +266,8 @@ the software is restarted, it should work.
264266
265267
|
266268
269+
-----------------
270+
267271
Physik Instrumente
268272
------------------
269273

@@ -292,6 +296,8 @@ or on a label on the side of your stage.
292296
repeatability of 2 microns, and a minimum incremental motion of 100 nm.
293297
This is potentially too coarse.
294298

299+
-----------------
300+
295301
C-884
296302
~~~~~
297303

@@ -341,6 +347,8 @@ C-884
341347
342348
|
343349
350+
-----------------
351+
344352
E-709
345353
~~~~~
346354

@@ -449,6 +457,7 @@ positioning.
449457
450458
|
451459
460+
-----------------
452461

453462
KST101
454463
~~~~~~

src/navigate/controller/sub_controllers/plugins_controller.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import os
3636
import inspect
3737
import tkinter as tk
38+
from tkinter import messagebox
3839

3940
# Third-party imports
4041

@@ -135,16 +136,21 @@ def load_plugins(self):
135136
)
136137
if plugin_frame_module is None:
137138
print(
138-
"Make sure that the plug in frame name is correct! "
139-
f"Plug in {plugin_name} needs to be reinstalled!"
139+
f"Make sure that the plugin frame name {plugin_class_name} is correct! "
140+
f"Plugin {plugin_name} needs to be uninstalled from navigate or reinstalled!"
140141
)
141-
return
142+
continue
142143
plugin_frame = getattr(
143144
plugin_frame_module, f"{plugin_class_name}Frame"
144145
)
145146
plugin_controller_module = load_module_from_file(
146147
f"{plugin_class_name}Controller", controller_file
147148
)
149+
if plugin_controller_module is None:
150+
print(
151+
f"Make sure that the plugin controller {plugin_class_name} is correct! "
152+
f"Plugin {plugin_name} needs to be uninstalled from navigate or reinstalled!"
153+
)
148154
plugin_controller = getattr(
149155
plugin_controller_module, f"{plugin_class_name}Controller"
150156
)
@@ -208,13 +214,22 @@ def build_tab_window(self, plugin_name, frame, controller):
208214
controller: object
209215
navigate controller
210216
"""
211-
plugin_frame = frame(self.view.settings)
212-
self.view.settings.add(plugin_frame, text=plugin_name, sticky=tk.NSEW)
213-
plugin_controller = controller(plugin_frame, self.parent_controller)
214-
controller_name = (
215-
"__plugin" + "_".join(plugin_name.lower().split()) + "_controller"
216-
)
217-
self.plugins_dict[controller_name] = plugin_controller
217+
try:
218+
plugin_frame = frame(self.view.settings)
219+
self.view.settings.add(plugin_frame, text=plugin_name, sticky=tk.NSEW)
220+
plugin_controller = controller(plugin_frame, self.parent_controller)
221+
controller_name = (
222+
"__plugin" + "_".join(plugin_name.lower().split()) + "_controller"
223+
)
224+
self.plugins_dict[controller_name] = plugin_controller
225+
except:
226+
messagebox.showwarning(
227+
title="Warning",
228+
message=(
229+
f"Plugin {plugin_name} has something went wrong."
230+
f"Please make sure the plugin works correctly or uninstall it!"
231+
)
232+
)
218233

219234
def build_popup_window(self, plugin_name, frame, controller):
220235
"""Build popup window for a plugin
@@ -264,7 +279,19 @@ def func(*args, **kwargs):
264279
),
265280
)
266281

267-
return func
282+
def func_with_wrapper(*args, **kwargs):
283+
try:
284+
func(*args, **kwargs)
285+
except:
286+
messagebox.showwarning(
287+
title="Warning",
288+
message=(
289+
f"Plugin {plugin_name} has something went wrong."
290+
f"Please make sure the plugin works correctly or uninstall it from navigate!"
291+
)
292+
)
293+
294+
return func_with_wrapper
268295

269296

270297
class UninstallPluginController(GUIController):
@@ -342,7 +369,7 @@ def uninstall_plugins(self, *args):
342369
save_yaml_file(
343370
self.plugin_config_path, self.plugin_config, "plugins_config.yml"
344371
)
345-
tk.messagebox.showwarning(
372+
messagebox.showwarning(
346373
title="Navigate",
347374
message="Plugins are uninstalled! Please restart Navigate!",
348375
)

0 commit comments

Comments
 (0)