Skip to content

Commit 71a10fa

Browse files
authoredFeb 19, 2025
Merge pull request #1062 from TheDeanLab/right-click-stage-update
2 parents 87feb55 + 51e47d1 commit 71a10fa

File tree

6 files changed

+156
-112
lines changed

6 files changed

+156
-112
lines changed
 

‎pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dev = [
5252
"pytest-xvfb",
5353
"pytest-cov",
5454
"pre-commit",
55+
"pytest-rerunfailures",
5556
"ipykernel",
5657
"jupyterlab",
5758
"pydantic-ome-ngff==0.5.3"

‎src/navigate/controller/controller.py

+32-11
Original file line numberDiff line numberDiff line change
@@ -672,12 +672,26 @@ def execute(self, command, *args):
672672
dict = {'x': value, 'y': value, 'z': value, 'theta': value, 'f': value}
673673
"""
674674
self.threads_pool.createThread(
675-
"model", self.move_stage, args=({args[1] + "_abs": args[0]},)
675+
resourceName="model",
676+
target=self.move_stage,
677+
args=({args[1] + "_abs": args[0]},)
676678
)
677679

678680
elif command == "stop_stage":
679681
"""Creates a thread and uses it to call the model to stop stage"""
680-
self.threads_pool.createThread("stop_stage", self.stop_stage)
682+
self.threads_pool.createThread(
683+
resourceName="stop_stage",
684+
target=self.stop_stage)
685+
686+
elif command == "query_stages":
687+
"""Query the stages for their current position in a thread-blocking format.
688+
"""
689+
query_thread = self.threads_pool.createThread(
690+
resourceName="model",
691+
target=self.stop_stage)
692+
693+
while query_thread.is_alive():
694+
time.sleep(0.01)
681695

682696
elif command == "move_stage_and_update_info":
683697
"""update stage view to show the position
@@ -704,7 +718,10 @@ def execute(self, command, *args):
704718
self.execute("acquire")
705719

706720
elif command == "get_stage_position":
707-
"""Returns the current stage position
721+
"""Returns the current stage position from the widgets.
722+
723+
Does not communicate with the stages, but rather takes the last known
724+
position.
708725
709726
Returns
710727
-------
@@ -754,8 +771,8 @@ def execute(self, command, *args):
754771
return
755772
self.change_microscope(temp[0], temp[1])
756773
work_thread = self.threads_pool.createThread(
757-
"model", lambda: self.model.run_command("update_setting", "resolution")
758-
)
774+
resourceName="model",
775+
target=lambda: self.model.run_command("update_setting", "resolution"))
759776
work_thread.join()
760777

761778
elif command == "set_save":
@@ -785,26 +802,29 @@ def execute(self, command, *args):
785802
}
786803
"""
787804
self.threads_pool.createThread(
788-
"model", lambda: self.model.run_command("update_setting", *args)
805+
resourceName="model",
806+
target=lambda: self.model.run_command("update_setting", *args)
789807
)
790808

791809
elif command == "stage_limits":
792810
self.stage_controller.stage_limits = args[0]
793811
self.threads_pool.createThread(
794-
"model", lambda: self.model.run_command("stage_limits", *args)
812+
resourceName="model",
813+
target=lambda: self.model.run_command("stage_limits", *args)
795814
)
796815

797816
elif command == "autofocus":
798817
"""Execute autofocus routine."""
799818
if not self.acquire_bar_controller.is_acquiring:
800819
self.threads_pool.createThread(
801-
"camera",
802-
self.capture_image,
820+
resourceName="camera",
821+
target=self.capture_image,
803822
args=("autofocus", "live", *args),
804823
)
805824
elif self.acquire_bar_controller.mode == "live":
806825
self.threads_pool.createThread(
807-
"model", lambda: self.model.run_command("autofocus", *args)
826+
resourceName="model",
827+
target=lambda: self.model.run_command("autofocus", *args)
808828
)
809829

810830
elif command == "eliminate_tiles":
@@ -829,7 +849,8 @@ def execute(self, command, *args):
829849
"""Tell model to load/unload features."""
830850

831851
work_thread = self.threads_pool.createThread(
832-
"model", lambda: self.model.run_command("load_feature", *args)
852+
resourceName="model",
853+
target=lambda: self.model.run_command("load_feature", *args)
833854
)
834855
work_thread.join()
835856

0 commit comments

Comments
 (0)