From 8ee72f125148b56b5636d3312b0a1041501be9ff Mon Sep 17 00:00:00 2001 From: yannachen Date: Tue, 2 Jul 2024 15:20:03 -0500 Subject: [PATCH] Fixed a bug that didn't disable snake axes checkbox during __init__ in grid scan window. --- src/firefly/controller.py | 3 +++ src/firefly/plans/grid_scan.py | 14 ++++++++++++-- src/firefly/queue_client.py | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/firefly/controller.py b/src/firefly/controller.py index 57da133c..70bc5033 100644 --- a/src/firefly/controller.py +++ b/src/firefly/controller.py @@ -247,6 +247,9 @@ def setup_window_actions(self): WindowClass=PlanMainWindow, ), } + # Disabled the grid scan window until this issue is fixed + # https://github.com/spc-group/haven/issues/231 + self.actions.plans['grid_scan'].setEnabled(False) # Action for showing the run browser window self.actions.run_browser = WindowAction( name="show_run_browser_action", diff --git a/src/firefly/plans/grid_scan.py b/src/firefly/plans/grid_scan.py index 611104a0..87e970d0 100644 --- a/src/firefly/plans/grid_scan.py +++ b/src/firefly/plans/grid_scan.py @@ -88,6 +88,7 @@ def __init__(self, parent=None, args=None, macros=None, ui_filename=None, **kwar def customize_ui(self): super().customize_ui() + self.update_snakes() # add title layout self.title_region = TitleRegion() self.ui.title_layout.addLayout(self.title_region.layout) @@ -112,7 +113,15 @@ async def update_devices_slot(self, registry): @asyncSlot(int) async def update_regions_slot(self, new_region_num: int): await super().update_regions(new_region_num) - # disable snake for the last region and enable the previous regions + self.update_snakes() + + def update_snakes(self): + """Update the snake checkboxes. + + The last region is not snakable, so that checkbox gets + disabled. The rest get enabled. + + """ if len(self.regions) > 0: self.regions[-1].snake_checkbox.setEnabled(False) for region_i in self.regions[:-1]: @@ -150,9 +159,10 @@ def queue_plan(self, *args, **kwargs): ) # Submit the item to the queueserver - log.info("Added line scan() plan to queue.") + log.info(f"Added grid_scan() plan to queue ({repeat_scan_num} scans).") # repeat scans for i in range(repeat_scan_num): + print("EMITTING") self.queue_item_submitted.emit(item) def ui_filename(self): diff --git a/src/firefly/queue_client.py b/src/firefly/queue_client.py index 12aa6bfd..041a0fb9 100644 --- a/src/firefly/queue_client.py +++ b/src/firefly/queue_client.py @@ -110,9 +110,10 @@ async def add_queue_item(self, item): try: result = await self.api.item_add(item=item) self.check_result(result) - except (RuntimeError, comm_base.RequestFailedError): + except (RuntimeError, comm_base.RequestFailedError) as ex: # Request failed, so force a UI update await self.check_queue_status(force=True) + raise else: await self.check_queue_status(force=False)