diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/gui_tools.py b/csaxs_bec/bec_ipython_client/plugins/omny/gui_tools.py index 2b3ea89..6d749f8 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/gui_tools.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/gui_tools.py @@ -35,6 +35,7 @@ class OMNYGuiTools: self.fig203 = None self.progressbar = None self.text_box = None + self.idle_text_box = None def omnygui_start_gui(self): if self.gui is None or self.gui.gui_is_alive() is False: @@ -45,6 +46,7 @@ class OMNYGuiTools: self.fig202 = None self.fig203 = None self.text_box = None + self.idle_text_box = None def omnygui_stop_gui(self): self.gui.close() @@ -77,13 +79,38 @@ class OMNYGuiTools: def omnygui_remove_all_docks(self): self.gui.clear_all() - self.fig200 = None self.fig201 = None self.fig202 = None self.fig203 = None self.progressbar = None self.text_box = None + self.idle_text_box = None + + def omnygui_idle(self): + self.omnygui_start_gui() + if self.idle_text_box is None: + self.omnygui_remove_all_docks() + self.idle_text_box = self.gui.add_dock(name="idle_text").add_widget("TextBox") + try: + self.gui.remove_dock(name="default_figure") + except: + pass + text = ( + "
" + + " ,o888888o. ,8. ,8. b. 8 `8.`8888. ,8' \n" + + " . 8888 `88. ,888. ,888. 888o. 8 `8.`8888. ,8' \n" + + ",8 8888 `8b .`8888. .`8888. Y88888o. 8 `8.`8888. ,8' \n" + + "88 8888 `8b ,8.`8888. ,8.`8888. .`Y888888o. 8 `8.`8888.,8' \n" + + "88 8888 88 ,8'8.`8888,8^8.`8888. 8o. `Y888888o. 8 `8.`88888' \n" + + "88 8888 88 ,8' `8.`8888' `8.`8888. 8`Y8o. `Y88888o8 `8. 8888 \n" + + "88 8888 ,8P ,8' `8.`88' `8.`8888. 8 `Y8o. `Y8888 `8 8888 \n" + + "`8 8888 ,8P ,8' `8.`' `8.`8888. 8 `Y8o. `Y8 8 8888 \n" + + " ` 8888 ,88' ,8' `8 `8.`8888. 8 `Y8o.` 8 8888 \n" + + " `8888888P' ,8' ` `8.`8888. 8 `Yo 8 8888 \n" + + "" + ) + self.idle_text_box.set_html_text(text) def _omnycam_clear(self): self.omnygui_remove_all_docks() @@ -102,7 +129,7 @@ class OMNYGuiTools: def omnygui_show_omnycam_samplestage(self): self.omnygui_start_gui() if self.fig201 is None: - self._omnycam_clear() + self.omnygui_remove_all_docks() self.fig201 = self.gui.add_dock(name="omnycam201").add_widget("BECImageWidget") if self._omnycam_check_device_exists(dev.cam201): fig = self.fig201.image("cam201") @@ -125,7 +152,7 @@ class OMNYGuiTools: def omnygui_show_progress(self): self.omnygui_start_gui() if self.progressbar is None: - self._omnycam_clear() + self.omnygui_remove_all_docks() # Add a new dock with a RingProgressBar widget self.progressbar = self.gui.add_dock(name="progress").add_widget("RingProgressBar") # Customize the size of the progress ring @@ -135,22 +162,25 @@ class OMNYGuiTools: # Set precision for the self.progressbar display self.progressbar.set_precision(1) # Display self.progressbar with one decimal places # Setting multiple rigns with different values - self.progressbar.set_number_of_bars(2) + self.progressbar.set_number_of_bars(3) + self.progressbar.rings[2].set_update("scan") # Set the values of the rings to 50, 75, and 25 from outer to inner ring - self.progressbar.set_value([50, 75]) + # self.progressbar.set_value([50, 75]) # Add a new dock with a TextBox widget self.text_box = self.gui.add_dock(name="progress_text").add_widget("TextBox") try: self.gui.remove_dock(name="default_figure") except: pass - self._omnygui_update_progress() + self._omnygui_update_progress() def _omnygui_update_progress(self): if self.progressbar is not None: - progress = self.progress["projection"] / self.progress["total_projections"] + progress = self.progress["projection"] / self.progress["total_projections"] * 100 subotmo_progress = ( - self.progress["subtomo_projection"] / self.progress["subtomo_total_projections"] + self.progress["subtomo_projection"] + / self.progress["subtomo_total_projections"] + * 100 ) self.progressbar.set_value([progress, subotmo_progress]) diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py index d86d9bb..4b348c1 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py @@ -982,6 +982,7 @@ class OMNY( if 0 <= angle < 180.05: print(f"Starting OMNY scan for angle {angle} in subtomo {subtomo_number}") self._print_progress() + self.omnygui_show_progress() while not successful: self._start_beam_check() if not self.special_angles: @@ -1143,7 +1144,7 @@ class OMNY( ) break else: - raise FlomniError("undefined tomo type") + raise OMNYError("undefined tomo type") def _print_progress(self): print("\x1b[95mProgress report:") diff --git a/csaxs_bec/devices/ids_cameras/ids_camera.py b/csaxs_bec/devices/ids_cameras/ids_camera.py index 59d7c7d..c095ee8 100644 --- a/csaxs_bec/devices/ids_cameras/ids_camera.py +++ b/csaxs_bec/devices/ids_cameras/ids_camera.py @@ -245,6 +245,8 @@ class IDSCamera(PSIDetectorBase): self.bits_per_pixel = bits_per_pixel self.channels = channels self.m_n_colormode = m_n_colormode + #TODO fix connected and wait_for_connection + self.custom_prepare.on_connection_established() def wait_for_connection(self, all_signals=False, timeout=10): if ueye is None: @@ -252,7 +254,7 @@ class IDSCamera(PSIDetectorBase): "The pyueye library is not installed or doesn't provide the necessary c libs" ) super().wait_for_connection(all_signals, timeout) - self.custom_prepare.on_connection_established() + #self.custom_prepare.on_connection_established() def destroy(self): """Extend Ophyds destroy function to kill the data thread"""