forked from M-Labs/artiq
moninj: handler create, delete widgets
This commit is contained in:
parent
3b8f6edd52
commit
aeaa337b1a
@ -115,14 +115,12 @@ class _TTLHandler:
|
||||
self.channel = channel
|
||||
self.force_out = force_out
|
||||
self.set_mode = dm.ttl_set_mode
|
||||
self.title = title
|
||||
self.cur_level = False
|
||||
self.cur_oe = False
|
||||
self.cur_override = False
|
||||
self.cur_override_level = False
|
||||
self.widget = _TTLWidget(title)
|
||||
self.widget.override_toggled.connect(self.override_toggled)
|
||||
self.widget.level_toggled.connect(self.level_toggled)
|
||||
self.refresh_display()
|
||||
self.widget = None
|
||||
|
||||
def override_toggled(self, override):
|
||||
if override:
|
||||
@ -141,6 +139,7 @@ class _TTLHandler:
|
||||
self.set_mode(self.channel, "0")
|
||||
|
||||
def refresh_display(self):
|
||||
if self.widget is not None:
|
||||
level = self.cur_override_level if self.cur_override else self.cur_level
|
||||
oe = self.cur_oe or self.force_out
|
||||
self.widget.setValueText(self.cur_override, level)
|
||||
@ -148,6 +147,16 @@ class _TTLHandler:
|
||||
with QtCore.QSignalBlocker(self.widget):
|
||||
self.widget.setButtonsState(self.cur_override, self.cur_level)
|
||||
|
||||
def delete_widget(self):
|
||||
self.widget.deleteLater()
|
||||
self.widget = None
|
||||
|
||||
def create_widget(self):
|
||||
self.widget = _TTLWidget(self.title)
|
||||
self.widget.override_toggled.connect(self.override_toggled)
|
||||
self.widget.level_toggled.connect(self.level_toggled)
|
||||
self.refresh_display()
|
||||
|
||||
def sort_key(self):
|
||||
return self.channel
|
||||
|
||||
@ -282,6 +291,7 @@ class _DDSHandler:
|
||||
def __init__(self, dm, title, bus_channel, channel, dds_type,
|
||||
ref_clk, cpld=None, pll=1, clk_div=0):
|
||||
self.dm = dm
|
||||
self.title = title
|
||||
self.bus_channel = bus_channel
|
||||
self.channel = channel
|
||||
self.cur_frequency = 0
|
||||
@ -305,7 +315,10 @@ class _DDSHandler:
|
||||
raise NotImplementedError
|
||||
sysclk = ref_clk / clk_mult[clk_div] * pll
|
||||
self.ftw_per_hz = 1 / sysclk * max_freq
|
||||
self.widget = _DDSWidget(title, self.is_urukul)
|
||||
self.widget = None
|
||||
|
||||
def create_widget(self):
|
||||
self.widget = _DDSWidget(self.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)
|
||||
@ -319,7 +332,12 @@ class _DDSHandler:
|
||||
def _ftw_to_freq(self, ftw):
|
||||
return ftw / self.ftw_per_hz
|
||||
|
||||
def delete_widget(self):
|
||||
self.widget.deleteLater()
|
||||
self.widget = None
|
||||
|
||||
def refresh_display(self):
|
||||
if self.widget is not None:
|
||||
self.widget.set_value(self.cur_frequency / 1e6)
|
||||
|
||||
def apply_changes(self):
|
||||
@ -370,13 +388,22 @@ class _DACWidget(QtWidgets.QFrame):
|
||||
|
||||
class _DACHandler:
|
||||
def __init__(self, dm, spi_channel, channel, title):
|
||||
self.widget = _DACWidget(channel, title)
|
||||
self.widget = None
|
||||
self.cur_value = 0
|
||||
self.spi_channel = spi_channel
|
||||
self.channel = channel
|
||||
self.title = title
|
||||
|
||||
def create_widget(self):
|
||||
self.widget = _DACWidget(self.channel, self.title)
|
||||
self.refresh_display()
|
||||
|
||||
def delete_widget(self):
|
||||
self.widget.deleteLater()
|
||||
self.widget = None
|
||||
|
||||
def refresh_display(self):
|
||||
if self.widget is not None:
|
||||
self.widget.set_value(self.cur_value * 100 / 2**16)
|
||||
|
||||
def sort_key(self):
|
||||
@ -484,17 +511,17 @@ class _DeviceManager:
|
||||
|
||||
if isinstance(handler, _TTLHandler):
|
||||
self.setup_ttl_monitoring(False, handler.channel)
|
||||
handler.widget.deleteLater()
|
||||
handler.delete_widget()
|
||||
del self.ttl_handlers[handler.channel]
|
||||
self.ttl_cb()
|
||||
elif isinstance(handler, _DDSHandler):
|
||||
self.setup_dds_monitoring(False, handler.bus_channel, handler.channel)
|
||||
handler.widget.deleteLater()
|
||||
handler.delete_widget()
|
||||
del self.dds_handlers[(handler.bus_channel, handler.channel)]
|
||||
self.dds_cb()
|
||||
elif isinstance(handler, _DACHandler):
|
||||
self.setup_dac_monitoring(False, handler.spi_channel, handler.channel)
|
||||
handler.widget.deleteLater()
|
||||
handler.delete_widget()
|
||||
del self.dac_handlers[(handler.spi_channel, handler.channel)]
|
||||
self.dac_cb()
|
||||
else:
|
||||
@ -502,6 +529,7 @@ class _DeviceManager:
|
||||
|
||||
for to_add in description - self.description:
|
||||
handler = to_add.cls(self, *to_add.arguments)
|
||||
handler.create_widget()
|
||||
if to_add.comment is not None:
|
||||
handler.widget.setToolTip(to_add.comment)
|
||||
self.handlers_by_uid[to_add.uid] = handler
|
||||
|
Loading…
Reference in New Issue
Block a user