From 5fd42dc0e2a9a9849a9f4545e9470a20d3290d14 Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Fri, 26 Apr 2024 14:49:52 +0800 Subject: [PATCH] moninj: separate DDS further --- artiq/dashboard/moninj.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/artiq/dashboard/moninj.py b/artiq/dashboard/moninj.py index a2d5ead8d..9d518d2e6 100644 --- a/artiq/dashboard/moninj.py +++ b/artiq/dashboard/moninj.py @@ -155,11 +155,12 @@ class _TTLHandler: class _DDSWidget(QtWidgets.QFrame): apply_changes = QtCore.pyqtSignal() off_clicked = QtCore.pyqtSignal() - set_clicked = QtCore.pyqtSignal() def __init__(self, title, is_urukul): QtWidgets.QFrame.__init__(self) + self._value = 0 + self.setFrameShape(QtWidgets.QFrame.Box) self.setFrameShadow(QtWidgets.QFrame.Raised) @@ -245,20 +246,29 @@ class _DDSWidget(QtWidgets.QFrame): grid.setRowStretch(3, 1) set_btn.clicked.connect(self.set_clicked) - apply.clicked.connect(self.apply_changes) + apply.clicked.connect(self._apply_changes) if is_urukul: off_btn.clicked.connect(self.off_clicked) off_btn.setToolTip(textwrap.dedent( """Note: If TTL RTIO sw for the channel is switched high, this button will not disable the channel. Use the TTL override instead.""")) - self.value_edit.returnPressed.connect(self.apply_changes) + self.value_edit.returnPressed.connect(self._apply_changes) def cancel_changes(cancel): self.set_page(0) self.value_edit.escapePressedConnect(cancel_changes) cancel.clicked.connect(cancel_changes) + def _apply_changes(self): + self.widget.set_page(0) + self.apply_changes.emit() + + def set_clicked(self): + self.set_page(1) + self.set_edit_value(self._value) + self.start_edit() + def set_page(self, page): self.data_stack.setCurrentIndex(page) self.button_stack.setCurrentIndex(page) @@ -271,6 +281,7 @@ class _DDSWidget(QtWidgets.QFrame): def set_value(self, value): self.value_label.setText("{:.7f}".format(value)) + self._value = value self.set_edit_value(value) def start_edit(self): @@ -308,7 +319,6 @@ class _DDSHandler: self.widget = _DDSWidget(title, self.is_urukul) self.widget.apply_changes.connect(self.apply_changes) self.widget.off_clicked.connect(self.off_clicked) - self.widget.set_clicked.connect(self.set_clicked) self.refresh_display() def monitor_update(self, probe, value): @@ -323,14 +333,9 @@ class _DDSHandler: self.widget.set_value(self.cur_frequency / 1e6) def apply_changes(self): - self.widget.set_page(0) frequency = self.widget.get_value() * 1e6 self.dm.dds_set_frequency(self.dds_name, frequency) - def set_clicked(self): - self.widget.set_page(1) - self.widget.set_edit_value(self.cur_frequency / 1e6) - self.widget.start_edit() def off_clicked(self): self.dm.dds_channel_toggle(self.dds_name, sw=False)