Skip to content

Commit

Permalink
Fixed queue status handlers at the beamline.
Browse files Browse the repository at this point in the history
  • Loading branch information
yannachen committed Dec 14, 2024
1 parent 2e312a1 commit 44eabb2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/firefly/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ async def finalize_new_window(self, action):
self.queue_status_changed.connect(action.window.update_queue_status)
self.queue_status_changed.connect(action.window.update_queue_controls)
if getattr(self, "_queue_client", None) is not None:
self._queue_client.check_queue_status(force=True)
status = await self._queue_client.queue_status()
action.window.update_queue_status(status)
action.window.update_queue_controls(status)
action.display.queue_item_submitted.connect(self.add_queue_item)
# Send the current devices to the window
await action.window.update_devices(self.registry)
Expand Down Expand Up @@ -615,6 +617,7 @@ def enable_queue_controls(self, re_state):
engine is already running.
"""
print(f"New re_state: {re_state}")
queue_actions = self.actions.queue_controls
# Decide which signals to enable
unknown_re_state = re_state is None or re_state.strip() == ""
Expand Down
7 changes: 4 additions & 3 deletions src/firefly/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ def update_queue_controls(self, new_status):

def update_queue_status(self, status):
"""Update the queue status labels."""
self.ui.environment_label.setText(status["worker_environment_state"])
new_length = status["items_in_queue"]
worker_state = status.get("worker_environment_state", "—")
self.ui.environment_label.setText(worker_state)
new_length = status.get("items_in_queue", "—")
self.ui.queue_length_label.setText(f"({new_length})")
self.ui.re_label.setText(status["re_state"])
self.ui.re_label.setText(status.get("re_state", "—"))
# Notify the display of the new status
display = self.display_widget()
display.update_queue_status(status)
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/queue_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, *args, **kwargs):
self.setDisabled(True)

def update_queue_style(self, status: dict):
if status["worker_environment_exists"]:
if status.get("worker_environment_exists", False):
self.setEnabled(True)
else:
# Should be disabled because the queue is closed
Expand Down
7 changes: 5 additions & 2 deletions src/firefly/queue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ async def update(self):
new_status = await self.queue_status()
signals_changed = self.status.send(new_status)
# Check individual components of the status if they've changed
print(signals_changed)
for signal_name, args in signals_changed.items():
if hasattr(self, signal_name):
signal = getattr(self, signal_name)
Expand All @@ -267,7 +266,11 @@ async def queue_status(self) -> dict:
status = await self.api.status()
except comm_base.RequestTimeoutError as e:
log.warning("Could not reach queueserver ZMQ.")
status = {"manager_state": "disconnected"}
status = {
"manager_state": "N.C.",
"worker_environment_state": "N.C.",
"re_state": "N.C.",
}
return status

async def update_devices(self):
Expand Down

0 comments on commit 44eabb2

Please sign in to comment.