forked from M-Labs/artiq
moninj: merge moninj docks
This commit is contained in:
parent
5fb7fbc8ec
commit
8bde26956a
@ -158,9 +158,6 @@ class _TTLHandler:
|
|||||||
self.widget.level_toggled.connect(self.level_toggled)
|
self.widget.level_toggled.connect(self.level_toggled)
|
||||||
self.refresh_display()
|
self.refresh_display()
|
||||||
|
|
||||||
def sort_key(self):
|
|
||||||
return self.channel
|
|
||||||
|
|
||||||
|
|
||||||
class _DDSWidget(QtWidgets.QFrame):
|
class _DDSWidget(QtWidgets.QFrame):
|
||||||
apply_changes = QtCore.pyqtSignal()
|
apply_changes = QtCore.pyqtSignal()
|
||||||
@ -354,9 +351,6 @@ class _DDSHandler:
|
|||||||
def off_clicked(self):
|
def off_clicked(self):
|
||||||
self.dm.dds_channel_toggle(self.dds_name, sw=False)
|
self.dm.dds_channel_toggle(self.dds_name, sw=False)
|
||||||
|
|
||||||
def sort_key(self):
|
|
||||||
return (self.bus_channel, self.channel)
|
|
||||||
|
|
||||||
|
|
||||||
class _DACWidget(QtWidgets.QFrame):
|
class _DACWidget(QtWidgets.QFrame):
|
||||||
def __init__(self, channel, title):
|
def __init__(self, channel, title):
|
||||||
@ -407,9 +401,6 @@ class _DACHandler:
|
|||||||
if self.widget is not None:
|
if self.widget is not None:
|
||||||
self.widget.set_value(self.cur_value * 100 / 2**16)
|
self.widget.set_value(self.cur_value * 100 / 2**16)
|
||||||
|
|
||||||
def sort_key(self):
|
|
||||||
return (self.spi_channel, self.channel)
|
|
||||||
|
|
||||||
|
|
||||||
class Model(DictSyncTreeSepModel):
|
class Model(DictSyncTreeSepModel):
|
||||||
def __init__(self, init):
|
def __init__(self, init):
|
||||||
@ -540,11 +531,8 @@ 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
|
self.channels_cb = lambda: None
|
||||||
|
|
||||||
@ -598,9 +586,6 @@ class _DeviceManager:
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
if description != self.description:
|
if description != self.description:
|
||||||
self.ttl_cb()
|
|
||||||
self.dds_cb()
|
|
||||||
self.dac_cb()
|
|
||||||
self.channels_cb()
|
self.channels_cb()
|
||||||
|
|
||||||
self.description = description
|
self.description = description
|
||||||
@ -841,16 +826,22 @@ class _DeviceManager:
|
|||||||
await self.mi_connection.close()
|
await self.mi_connection.close()
|
||||||
|
|
||||||
|
|
||||||
class _MonInjDock(QtWidgets.QDockWidget):
|
class MonInjDock(QtWidgets.QDockWidget):
|
||||||
def __init__(self, name):
|
def __init__(self, schedule_ctl):
|
||||||
QtWidgets.QDockWidget.__init__(self, name)
|
QtWidgets.QDockWidget.__init__(self, "MonInj")
|
||||||
self.setObjectName(name)
|
self.setObjectName("MonInj")
|
||||||
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
|
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
|
||||||
QtWidgets.QDockWidget.DockWidgetFloatable)
|
QtWidgets.QDockWidget.DockWidgetFloatable)
|
||||||
|
|
||||||
|
self.dm = _DeviceManager(schedule_ctl)
|
||||||
|
self.dm.channels_cb = lambda: self.set_channels(self.dm.handlers_by_uid)
|
||||||
|
|
||||||
layout = LayoutWidget()
|
layout = LayoutWidget()
|
||||||
self.setWidget(layout)
|
self.setWidget(layout)
|
||||||
self._channel_model = Model({})
|
self._channel_model = Model({})
|
||||||
self.add_channel_dialog = _AddChannelDialog(self, self._channel_model)
|
self.add_channel_dialog = _AddChannelDialog(self, self._channel_model)
|
||||||
|
self.add_channel_dialog.accepted.connect(
|
||||||
|
lambda: self.layout_widgets(self.add_channel_dialog.channels))
|
||||||
add_channel_btn = QtWidgets.QToolButton()
|
add_channel_btn = QtWidgets.QToolButton()
|
||||||
add_channel_btn.setToolTip("Add channels...")
|
add_channel_btn.setToolTip("Add channels...")
|
||||||
add_channel_btn.setIcon(
|
add_channel_btn.setIcon(
|
||||||
@ -867,26 +858,13 @@ class _MonInjDock(QtWidgets.QDockWidget):
|
|||||||
scroll_area.setWidget(grid_widget)
|
scroll_area.setWidget(grid_widget)
|
||||||
|
|
||||||
def layout_widgets(self, handlers):
|
def layout_widgets(self, handlers):
|
||||||
for handler in sorted(handlers, key=lambda h: h.sort_key()):
|
for handler in handlers:
|
||||||
self.grid.addWidget(handler.widget)
|
self.grid.addWidget(handler.widget)
|
||||||
|
|
||||||
def set_channels(self, handlers):
|
def set_channels(self, handlers):
|
||||||
self._channel_model.clear()
|
self._channel_model.clear()
|
||||||
self._channel_model.update(handlers)
|
self._channel_model.update(handlers)
|
||||||
|
|
||||||
|
|
||||||
class MonInj:
|
|
||||||
def __init__(self, schedule_ctl):
|
|
||||||
self.ttl_dock = _MonInjDock("TTL")
|
|
||||||
self.dds_dock = _MonInjDock("DDS")
|
|
||||||
self.dac_dock = _MonInjDock("DAC")
|
|
||||||
|
|
||||||
self.dm = _DeviceManager(schedule_ctl)
|
|
||||||
self.dm.ttl_cb = lambda: self.ttl_dock.layout_widgets(self.dm.ttl_handlers.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())
|
|
||||||
self.dm.channels_cb = lambda: self.ttl_dock.set_channels(self.dm.handlers_by_uid)
|
|
||||||
|
|
||||||
async def stop(self):
|
async def stop(self):
|
||||||
if self.dm is not None:
|
if self.dm is not None:
|
||||||
await self.dm.close()
|
await self.dm.close()
|
||||||
|
@ -226,7 +226,7 @@ def main():
|
|||||||
smgr.register(d_applets)
|
smgr.register(d_applets)
|
||||||
broadcast_clients["ccb"].notify_cbs.append(d_applets.ccb_notify)
|
broadcast_clients["ccb"].notify_cbs.append(d_applets.ccb_notify)
|
||||||
|
|
||||||
d_ttl_dds = moninj.MonInj(rpc_clients["schedule"])
|
d_ttl_dds = moninj.MonInjDock(rpc_clients["schedule"])
|
||||||
atexit_register_coroutine(d_ttl_dds.stop, loop=loop)
|
atexit_register_coroutine(d_ttl_dds.stop, loop=loop)
|
||||||
|
|
||||||
d_waveform = waveform.WaveformDock(
|
d_waveform = waveform.WaveformDock(
|
||||||
@ -260,8 +260,7 @@ def main():
|
|||||||
|
|
||||||
# lay out docks
|
# lay out docks
|
||||||
right_docks = [
|
right_docks = [
|
||||||
d_explorer, d_shortcuts,
|
d_explorer, d_shortcuts, d_ttl_dds,
|
||||||
d_ttl_dds.ttl_dock, d_ttl_dds.dds_dock, d_ttl_dds.dac_dock,
|
|
||||||
d_datasets, d_applets, d_waveform, d_interactive_args
|
d_datasets, d_applets, d_waveform, d_interactive_args
|
||||||
]
|
]
|
||||||
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, right_docks[0])
|
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, right_docks[0])
|
||||||
@ -279,10 +278,6 @@ def main():
|
|||||||
smgr.start(loop=loop)
|
smgr.start(loop=loop)
|
||||||
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
|
|
||||||
d_ttl_dds.ttl_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()
|
||||||
if d_log0 is not None:
|
if d_log0 is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user