forked from M-Labs/artiq
draft load/save configuration
parent
8b105c064a
commit
2e48426bf7
|
@ -1,14 +1,17 @@
|
|||
import asyncio
|
||||
import logging
|
||||
import textwrap
|
||||
import os
|
||||
from collections import namedtuple
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
import pyqtgraph as pg
|
||||
|
||||
from sipyco import pyon
|
||||
|
||||
from artiq.coredevice.comm_moninj import CommMonInj, TTLOverride, TTLProbe
|
||||
from artiq.coredevice.ad9912_reg import AD9912_SER_CONF
|
||||
from artiq.gui.tools import LayoutWidget
|
||||
from artiq.gui.tools import LayoutWidget, get_open_file_name, get_save_file_name
|
||||
from artiq.gui.models import DictSyncTreeSepModel
|
||||
|
||||
|
||||
|
@ -902,6 +905,15 @@ class MoninjTreeWidget(pg.TreeWidget):
|
|||
for child in child_items:
|
||||
self.remove_widget(child)
|
||||
|
||||
def extend(self, d):
|
||||
pass
|
||||
|
||||
def clear(self):
|
||||
pass
|
||||
|
||||
def export_list(self):
|
||||
pass
|
||||
|
||||
|
||||
class MonInjDock(QtWidgets.QDockWidget):
|
||||
def __init__(self, schedule_ctl):
|
||||
|
@ -939,6 +951,44 @@ class MonInjDock(QtWidgets.QDockWidget):
|
|||
def set_channels(self, handlers):
|
||||
self._channel_model.update(handlers)
|
||||
|
||||
def _connect_config(self, config):
|
||||
pass
|
||||
|
||||
async def load_configuration(self):
|
||||
try:
|
||||
filename = await get_open_file_name(
|
||||
self,
|
||||
"Load configuration",
|
||||
self._current_dir,
|
||||
"PYON files (*.pyon);;All files (*.*)")
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
self._current_dir = os.path.dirname(filename)
|
||||
try:
|
||||
configuration = pyon.load_file(filename)
|
||||
connected_config = self._connect_config(configuration)
|
||||
connected_config = self.dm.connect_config(configuration)
|
||||
self.tree.clear()
|
||||
self.tree.extend(connected_config)
|
||||
except Exception:
|
||||
logger.error("Failed to load moninj configuration", exc_info=True)
|
||||
|
||||
async def save_configuration(self):
|
||||
try:
|
||||
filename = await get_save_file_name(
|
||||
self,
|
||||
"Save configuration",
|
||||
self._current_dir,
|
||||
"PYON files (*.pyon);;All files (*.*)")
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
self._current_dir = os.path.dirname(filename)
|
||||
try:
|
||||
configuration = self.tree.export_list()
|
||||
pyon.store_file(filename, configuration)
|
||||
except Exception:
|
||||
logger.error("Failed to save moninj configuration", exc_info=True)
|
||||
|
||||
async def stop(self):
|
||||
if self.dm is not None:
|
||||
await self.dm.close()
|
||||
|
|
Loading…
Reference in New Issue