@@ -672,12 +672,26 @@ def execute(self, command, *args):
672
672
dict = {'x': value, 'y': value, 'z': value, 'theta': value, 'f': value}
673
673
"""
674
674
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 ]},)
676
678
)
677
679
678
680
elif command == "stop_stage" :
679
681
"""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 )
681
695
682
696
elif command == "move_stage_and_update_info" :
683
697
"""update stage view to show the position
@@ -704,7 +718,10 @@ def execute(self, command, *args):
704
718
self .execute ("acquire" )
705
719
706
720
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.
708
725
709
726
Returns
710
727
-------
@@ -754,8 +771,8 @@ def execute(self, command, *args):
754
771
return
755
772
self .change_microscope (temp [0 ], temp [1 ])
756
773
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" ) )
759
776
work_thread .join ()
760
777
761
778
elif command == "set_save" :
@@ -785,26 +802,29 @@ def execute(self, command, *args):
785
802
}
786
803
"""
787
804
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 )
789
807
)
790
808
791
809
elif command == "stage_limits" :
792
810
self .stage_controller .stage_limits = args [0 ]
793
811
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 )
795
814
)
796
815
797
816
elif command == "autofocus" :
798
817
"""Execute autofocus routine."""
799
818
if not self .acquire_bar_controller .is_acquiring :
800
819
self .threads_pool .createThread (
801
- "camera" ,
802
- self .capture_image ,
820
+ resourceName = "camera" ,
821
+ target = self .capture_image ,
803
822
args = ("autofocus" , "live" , * args ),
804
823
)
805
824
elif self .acquire_bar_controller .mode == "live" :
806
825
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 )
808
828
)
809
829
810
830
elif command == "eliminate_tiles" :
@@ -829,7 +849,8 @@ def execute(self, command, *args):
829
849
"""Tell model to load/unload features."""
830
850
831
851
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 )
833
854
)
834
855
work_thread .join ()
835
856
0 commit comments