Skip to content

Commit

Permalink
Fix: Disable device controls on device open before running other list…
Browse files Browse the repository at this point in the history
…eners
  • Loading branch information
alexdewar committed Oct 26, 2023
1 parent 1f54903 commit f7dd7a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion finesse/gui/device_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(
layout.addWidget(self._open_close_btn)

# pubsub subscriptions
pub.subscribe(self._on_device_opened, f"device.opened.{topic}")
pub.subscribe(self._on_device_opened, f"device.opening.{topic}")

Check warning on line 139 in finesse/gui/device_view.py

View check run for this annotation

Codecov / codecov/patch

finesse/gui/device_view.py#L139

Added line #L139 was not covered by tests
pub.subscribe(self._on_device_closed, f"device.closed.{topic}")
pub.subscribe(self._show_error_message, f"device.error.{topic}")

Expand Down
5 changes: 4 additions & 1 deletion finesse/hardware/manage_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def _open_device(
else:
logging.info("Opened device")

# Signal that device is now open
# Signal that device is now open. The reason for the two different topics is
# because we want to ensure that some listeners always run before others, in
# case an error occurs and we have to undo the work.
pub.sendMessage(f"device.opening.{instance.topic}")
pub.sendMessage(f"device.opened.{instance.topic}")


Expand Down
10 changes: 9 additions & 1 deletion tests/hardware/test_manage_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ def test_open_device(

if not raise_error:
assert devices_dict == {instance: device_mock}
sendmsg_mock.assert_called_once_with(f"device.opened.{instance.topic}")

# Two separate messages are sent on device open
sendmsg_mock.assert_has_calls(
[
call(f"device.{name}.{instance.topic}")
for name in ("opening", "opened")
]
)

logging_mock.error.assert_not_called()
logging_mock.warn.assert_not_called()
else:
Expand Down

0 comments on commit f7dd7a8

Please sign in to comment.