moninj: merge docks

This commit is contained in:
Simon Renblad 2024-04-24 10:51:54 +08:00
parent 648d7a3d87
commit 687c12033e
2 changed files with 9 additions and 19 deletions

View File

@ -487,12 +487,10 @@ class _DeviceManager:
self.handlers_by_uid = dict() self.handlers_by_uid = dict()
self.dds_sysclk = 0 self.dds_sysclk = 0
self.ttl_cb = lambda: None
self.ttl_handlers = dict() self.ttl_handlers = dict()
self.dds_cb = lambda: None
self.dds_handlers = dict() self.dds_handlers = dict()
self.dac_cb = lambda: None
self.dac_handlers = dict() self.dac_handlers = dict()
self.channels_cb = lambda: None
def init_ddb(self, ddb): def init_ddb(self, ddb):
self.ddb = ddb self.ddb = ddb
@ -513,17 +511,14 @@ class _DeviceManager:
self.setup_ttl_monitoring(False, handler.channel) self.setup_ttl_monitoring(False, handler.channel)
handler.delete_widget() handler.delete_widget()
del self.ttl_handlers[handler.channel] del self.ttl_handlers[handler.channel]
self.ttl_cb()
elif isinstance(handler, _DDSHandler): elif isinstance(handler, _DDSHandler):
self.setup_dds_monitoring(False, handler.bus_channel, handler.channel) self.setup_dds_monitoring(False, handler.bus_channel, handler.channel)
handler.delete_widget() handler.delete_widget()
del self.dds_handlers[(handler.bus_channel, handler.channel)] del self.dds_handlers[(handler.bus_channel, handler.channel)]
self.dds_cb()
elif isinstance(handler, _DACHandler): elif isinstance(handler, _DACHandler):
self.setup_dac_monitoring(False, handler.spi_channel, handler.channel) self.setup_dac_monitoring(False, handler.spi_channel, handler.channel)
handler.delete_widget() handler.delete_widget()
del self.dac_handlers[(handler.spi_channel, handler.channel)] del self.dac_handlers[(handler.spi_channel, handler.channel)]
self.dac_cb()
else: else:
raise ValueError raise ValueError
@ -536,19 +531,19 @@ class _DeviceManager:
if isinstance(handler, _TTLHandler): if isinstance(handler, _TTLHandler):
self.ttl_handlers[handler.channel] = handler self.ttl_handlers[handler.channel] = handler
self.ttl_cb()
self.setup_ttl_monitoring(True, handler.channel) self.setup_ttl_monitoring(True, handler.channel)
elif isinstance(handler, _DDSHandler): elif isinstance(handler, _DDSHandler):
self.dds_handlers[(handler.bus_channel, handler.channel)] = handler self.dds_handlers[(handler.bus_channel, handler.channel)] = handler
self.dds_cb()
self.setup_dds_monitoring(True, handler.bus_channel, handler.channel) self.setup_dds_monitoring(True, handler.bus_channel, handler.channel)
elif isinstance(handler, _DACHandler): elif isinstance(handler, _DACHandler):
self.dac_handlers[(handler.spi_channel, handler.channel)] = handler self.dac_handlers[(handler.spi_channel, handler.channel)] = handler
self.dac_cb()
self.setup_dac_monitoring(True, handler.spi_channel, handler.channel) self.setup_dac_monitoring(True, handler.spi_channel, handler.channel)
else: else:
raise ValueError raise ValueError
if self.description != description:
self.channels_cb()
self.description = description self.description = description
def ttl_set_mode(self, channel, mode): def ttl_set_mode(self, channel, mode):
@ -811,14 +806,10 @@ class _MonInjDock(QtWidgets.QDockWidget):
class MonInj: class MonInj:
def __init__(self, schedule_ctl): def __init__(self, schedule_ctl):
self.ttl_dock = _MonInjDock("TTL") self.dock = _MonInjDock("MonInj")
self.dds_dock = _MonInjDock("DDS")
self.dac_dock = _MonInjDock("DAC")
self.dm = _DeviceManager(schedule_ctl) self.dm = _DeviceManager(schedule_ctl)
self.dm.ttl_cb = lambda: self.ttl_dock.layout_widgets(self.dm.ttl_handlers.values()) self.dm.channels_cb = lambda: self.dock.layout_widgets(self.dm.handlers_by_uid.values())
self.dm.dds_cb = lambda: self.dds_dock.layout_widgets(self.dm.dds_handlers.values())
self.dm.dac_cb = lambda: self.dac_dock.layout_widgets(self.dm.dac_handlers.values())
async def stop(self): async def stop(self):
if self.dm is not None: if self.dm is not None:

View File

@ -261,8 +261,8 @@ def main():
# lay out docks # lay out docks
right_docks = [ right_docks = [
d_explorer, d_shortcuts, d_explorer, d_shortcuts,
d_ttl_dds.ttl_dock, d_ttl_dds.dds_dock, d_ttl_dds.dac_dock, d_ttl_dds.dock, d_datasets, d_applets,
d_datasets, d_applets, d_waveform, d_interactive_args d_waveform, d_interactive_args
] ]
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, right_docks[0]) main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, right_docks[0])
for d1, d2 in zip(right_docks, right_docks[1:]): for d1, d2 in zip(right_docks, right_docks[1:]):
@ -280,8 +280,7 @@ def main():
atexit_register_coroutine(smgr.stop, loop=loop) atexit_register_coroutine(smgr.stop, loop=loop)
# work around for https://github.com/m-labs/artiq/issues/1307 # work around for https://github.com/m-labs/artiq/issues/1307
d_ttl_dds.ttl_dock.show() d_ttl_dds.dock.show()
d_ttl_dds.dds_dock.show()
# create first log dock if not already in state # create first log dock if not already in state
d_log0 = logmgr.first_log_dock() d_log0 = logmgr.first_log_dock()