Skip to content

Commit

Permalink
Added the status mappings as an argument to the queue_status() genera…
Browse files Browse the repository at this point in the history
…tor.
  • Loading branch information
yannachen committed Dec 14, 2024
1 parent 44eabb2 commit 1671dec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/firefly/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ophydregistry import Registry
from qasync import asyncSlot
from qtpy import QtCore, QtWidgets
from qtpy.QtCore import Signal
from qtpy.QtCore import Signal, Slot
from qtpy.QtGui import QIcon, QKeySequence
from qtpy.QtWidgets import QAction, QErrorMessage

Expand Down Expand Up @@ -318,9 +318,6 @@ def setup_window_actions(self):
icon=qta.icon("mdi.sine-wave"),
)

def update_queue_controls(self, status):
print(status)

@asyncSlot(QAction)
async def finalize_new_window(self, action):
"""Slot for providing new windows for after a new window is created."""
Expand Down Expand Up @@ -609,6 +606,7 @@ def start(self):
def update_devices_allowed(self, devices):
pass

@Slot(str)
def enable_queue_controls(self, re_state):
"""Enable/disable the navbar buttons that control the queue.
Expand All @@ -617,7 +615,6 @@ 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
5 changes: 4 additions & 1 deletion src/firefly/queue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def queue_status(status_mapping: Mapping[str, str] = {}):
for key, val in status.items()
if key not in last_status or val != last_status[key]
}
log.debug(f"Received updated queue status: {status_diff}")
updated_params = {
status_mapping[key]: (val,)
for key, val in status_diff.items()
Expand Down Expand Up @@ -122,7 +123,7 @@ def __init__(self, *args, api, **kwargs):
self.timer = QTimer()
self.timer.timeout.connect(self.update)
# Create the generator to keep track of the queue states
self.status = queue_status()
self.status = queue_status(status_mapping=self.parameter_mapping)
next(self.status) # Prime the generator

def start(self):
Expand Down Expand Up @@ -242,6 +243,8 @@ 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
if signals_changed != {}:
log.debug(f"Emitting changed signals: {signals_changed}")
for signal_name, args in signals_changed.items():
if hasattr(self, signal_name):
signal = getattr(self, signal_name)
Expand Down

0 comments on commit 1671dec

Please sign in to comment.