diff --git a/src/aare/daq/server.py b/src/aare/daq/server.py index 0e4e1c6f..e7d32c3d 100644 --- a/src/aare/daq/server.py +++ b/src/aare/daq/server.py @@ -1200,6 +1200,25 @@ async def unmount(token: str = Depends(oauth2_scheme)): return "OK" +@app.post("/sample/unmount_then_park_and_dry") +@needs_hw_lock +async def unmount_then_park_and_dry(token: str = Depends(oauth2_scheme)): + """ + Unmount the current sample from the goniometer, then tell the robot to park and dry + + Args: + token: OAuth2 access token. + + Returns: + "OK" on success. + """ + logger.debug("Unmount, then park and dry") + auth.check_jwt_rw(cfg, auth.parse_token(token)) + daq.sample = None + daq.park_and_dry(park=True) + return "OK" + + @app.post("/sample/manual") @needs_hw_lock async def manual(s: SampleShortInfo, token: str = Depends(oauth2_scheme)): diff --git a/src/aare/gui/main_window.py b/src/aare/gui/main_window.py index 40b98ec4..f600eae8 100644 --- a/src/aare/gui/main_window.py +++ b/src/aare/gui/main_window.py @@ -1113,7 +1113,7 @@ class MainWindow(QMainWindow): self.job_list_panel.auto_scan.connect(self.daq.automated_scan) self.job_list_panel.unmount.connect(self.daq.unmount) - self.job_list_panel.park_and_dry.connect(self.daq.park_and_dry) + self.job_list_panel.unmount_then_park_and_dry.connect(self.daq.unmount_then_park_and_dry) # Gate manual mounts/unmounts on the hutch PSS state so the user gets an # immediate pop-up instead of the robot failing to move server-side. diff --git a/src/aare/gui/panels/sample_queue_panel.py b/src/aare/gui/panels/sample_queue_panel.py index da7ef53d..c8a0f4e4 100644 --- a/src/aare/gui/panels/sample_queue_panel.py +++ b/src/aare/gui/panels/sample_queue_panel.py @@ -31,7 +31,7 @@ logger = setup_logger(LOGGER_NAME) class SampleQueuePanel(QFrame): auto_scan = Signal(SampleShortInfo) unmount = Signal() - park_and_dry = Signal() + unmount_then_park_and_dry = Signal() viewer_track_online = Signal() samples_in_queue_changed = Signal(int) automation_running_changed = Signal(bool) @@ -284,11 +284,12 @@ class SampleQueuePanel(QFrame): self.pause_automation() logger.info("Automation queue empty; unmounting current sample.") - self.unmount.emit() if self.park_and_dry_when_cleared.isChecked(): logger.info("Automation queue empty; parking and drying TELL.") - self.park_and_dry.emit() + self.unmount_then_park_and_dry.emit() + else: + self.unmount.emit() def run(self): self._recovery_timer.stop() diff --git a/src/aare/gui/threads/daq_worker.py b/src/aare/gui/threads/daq_worker.py index ed27a993..07a2c1d7 100644 --- a/src/aare/gui/threads/daq_worker.py +++ b/src/aare/gui/threads/daq_worker.py @@ -1499,7 +1499,10 @@ class DAQWorker(QObject): def anneal(self, time_s: float): self.generic_post(f"beamline/anneal?time_s={time_s:.1f}") - # TODO combine dry and park and dry + @Slot() + def unmount_then_park_and_dry(self): + self.generic_post("sample/unmount_then_park_and_dry") + @Slot() def park_and_dry(self): self.generic_post("tell/park_and_dry")