コード例 #1
0
    def __init__(self, server_options=dict(), parent=None):
        super(LocalMRCConnection, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)
        self.server = server_process.pool.create_process(server_options)

        self.connection = MRCConnection(self.server.listen_address,
                                        self.server.listen_port)
        self.connection.connected.connect(self.connected)
        self.connection.disconnected.connect(self.disconnected)
        self.connection.connection_error.connect(self.connection_error)
        self.connection.request_queued.connect(self.request_queued)
        self.connection.request_sent.connect(self.request_sent)
        self.connection.message_received.connect(self.message_received)
        self.connection.notification_received.connect(
            self.notification_received)
        self.connection.notification_received.connect(
            self._on_connection_notification_received)
        self.connection.error_message_received.connect(
            self.error_message_received)
        self.connection.queue_empty.connect(self.queue_empty)
        self.connection.queue_size_changed.connect(self.queue_size_changed)

        self._connecting_future = None
        self._is_connecting = False
        self._is_connected = False
コード例 #2
0
ファイル: app_model.py プロジェクト: flueke/mesycontrol
 def __init__(self, url, mrc_registry=None, hw_mrc=None, cfg_mrc=None, parent=None):
     super(AppMrc, self).__init__(hardware=hw_mrc, config=cfg_mrc, parent=parent)
     self.log  = util.make_logging_source_adapter(__name__, self)
     self._url = str(url)
     self._devices = list()
     self._mrc_registry = None
     self.mrc_registry = mrc_registry
コード例 #3
0
    def __init__(self,
                 specialized_device,
                 display_mode,
                 write_mode,
                 parent=None):
        """Construct a device specific widget.
        * specialized_device should be a DeviceBase subclass tailored to the specific device.
        * display_mode and write_mode are the display and write modes to use with the device.
        """
        super(DeviceWidgetBase, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)
        self.device = specialized_device
        self._display_mode = display_mode
        self._write_mode = write_mode
        self.make_settings = None

        self.device.hardware_set.connect(self._on_device_hardware_set)
        self._on_device_hardware_set(self.device, None, self.device.hw)

        self.notes_widget = gui_util.DeviceNotesWidget(specialized_device)

        self.hide_notes_button = QtWidgets.QPushButton(
            clicked=self._toggle_hide_notes)
        self.set_notes_visible(False)

        self.tab_widget = QtWidgets.QTabWidget()
        self.tab_widget.setCornerWidget(self.hide_notes_button,
                                        Qt.TopRightCorner)

        layout = QtWidgets.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.notes_widget)
        layout.addWidget(self.tab_widget)
        layout.setStretch(1, 1)
コード例 #4
0
ファイル: server_process.py プロジェクト: flueke/mesycontrol
    def __init__(self,
                 binary='mesycontrol_server',
                 listen_address='127.0.0.1',
                 listen_port=BASE_PORT,
                 serial_port=None,
                 baud_rate=0,
                 tcp_host=None,
                 tcp_port=4001,
                 verbosity=0,
                 output_buffer_maxlen=10000,
                 parent=None):

        super(ServerProcess, self).__init__(parent)

        self.log = util.make_logging_source_adapter(__name__, self)
        self.binary = binary
        self.listen_address = listen_address
        self.listen_port = listen_port
        self.serial_port = serial_port
        self.baud_rate = baud_rate
        self.tcp_host = tcp_host
        self.tcp_port = tcp_port
        self.verbosity = verbosity

        self.process = None
        self.lastExitCode = None

        self._startup_delay_timer = QtCore.QTimer()
        self._startup_delay_timer.setSingleShot(True)
        self._startup_delay_timer.setInterval(ServerProcess.startup_delay_ms)

        self.output_buffer = collections.deque(maxlen=output_buffer_maxlen)
コード例 #5
0
ファイル: test_util.py プロジェクト: flueke/mesycontrol
def test_make_logging_source_adapter():
    class TestClass():
        pass

    test_instance = TestClass()

    log = util.make_logging_source_adapter(__name__, test_instance)
    assert log.logger.name.endswith(test_instance.__class__.__name__)
コード例 #6
0
ファイル: app_model.py プロジェクト: flueke/mesycontrol
    def __init__(self, app_registry, device_registry):
        self.log                = util.make_logging_source_adapter(__name__, self)
        self.registry           = app_registry
        self.device_registry    = device_registry

        self._hw_registry_set(app_registry, None, app_registry.hw)
        self._cfg_registry_set(app_registry, None, app_registry.cfg)

        app_registry.hardware_set.connect(self._hw_registry_set)
        app_registry.config_set.connect(self._cfg_registry_set)
コード例 #7
0
 def __init__(self, bus=None, address=None, idc=None, parent=None):
     super(Device, self).__init__(parent)
     self.log = util.make_logging_source_adapter(__name__, self)
     self._bus = int(bus) if bus is not None else None
     self._address = int(address) if address is not None else None
     self._idc = int(idc) if idc is not None else None
     self._mrc = None
     self._memory = dict()  # address -> value
     self._read_futures = dict()  # address -> future
     self._extensions = dict()  # name -> value
コード例 #8
0
ファイル: tcp_client.py プロジェクト: flueke/mesycontrol
 def __init__(self, parent=None):
     super(MCTCPClient, self).__init__(parent)
     self.log    = util.make_logging_source_adapter(__name__, self)
     self._queue = util.OrderedSet()
     self._socket = QtNetwork.QTcpSocket()
     self._socket.connected.connect(self.connected)
     self._socket.disconnected.connect(self._socket_disconnected)
     self._socket.error.connect(self._socket_error)
     self._socket.readyRead.connect(self._socket_readyRead)
     self._current_request = None
     self._reset_state()
コード例 #9
0
    def __init__(self, device, display_mode, write_mode, parent=None):
        super(DeviceTableModel, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)

        self._display_mode = display_mode
        self._write_mode = write_mode

        self._device = None
        self.device = device
        self._editing_ignore_paramter_ranges = False
        self._display_hex_values = False
コード例 #10
0
ファイル: config_gui.py プロジェクト: flueke/mesycontrol
    def __init__(self,
                 app_registry,
                 device_registry,
                 parent_widget,
                 parent=None):
        super(ApplySetupRunner, self).__init__(parent=parent)

        self.log = util.make_logging_source_adapter(__name__, self)
        self.app_registry = app_registry
        self.device_registry = device_registry
        self.parent_widget = parent_widget
コード例 #11
0
ファイル: gui_mainwindow.py プロジェクト: flueke/mesycontrol
    def __init__(self, context, parent=None):
        super(MainWindow, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)
        self.context = context
        self.mdiArea = MCMdiArea()
        self.toolbar = self.addToolBar("toolbar")
        self.toolbar.setObjectName("toolbar")
        self.setWindowTitle("mesycontrol")
        self.setWindowIcon(make_icon(":/window-icon.png"))

        self.mdiArea.setLayout(QtWidgets.QGridLayout())
        self.setCentralWidget(self.mdiArea)

        self.status_bar = QtWidgets.QStatusBar()
        self.setStatusBar(self.status_bar)

        self.actionQuickstart = QtWidgets.QAction("Quickstart")
        self.actionQuickstart.setShortcut("F1")

        self.menu_file = QtWidgets.QMenu("&File")
        self.menu_window = QtWidgets.QMenu("&Window")
        self.menu_help = QtWidgets.QMenu("&Help")

        self.menu_help.addAction(self.actionQuickstart)
        self.menu_help.addSeparator()
        self.menu_help.addAction("&About", self.on_actionAbout_triggered)
        self.menu_help.addAction("About &Qt", self.on_actionAbout_Qt_triggered)

        self.menu_bar = self.menuBar()
        self.menu_bar.addMenu(self.menu_file)
        self.menu_bar.addMenu(self.menu_help)

        # Treeview
        self.treeview = MCTreeView(app_registry=context.app_registry,
                                   device_registry=context.device_registry)

        dw_tree = QtWidgets.QDockWidget("Device tree", self)
        dw_tree.setObjectName("dw_treeview")
        dw_tree.setWidget(self.treeview)
        dw_tree.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable
                            | QtWidgets.QDockWidget.DockWidgetFloatable)
        self.addDockWidget(Qt.BottomDockWidgetArea, dw_tree)

        # Log view
        self.logview = log_view.LogView(parent=self)
        dw_logview = QtWidgets.QDockWidget("Application Log", self)
        dw_logview.setObjectName("dw_logview")
        dw_logview.setWidget(self.logview)
        dw_logview.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable
                               | QtWidgets.QDockWidget.DockWidgetFloatable)
        self.addDockWidget(Qt.BottomDockWidgetArea, dw_logview)
コード例 #12
0
    def __init__(self, url, parent=None):
        super(HardwareMrc, self).__init__(url, parent)
        self.log   = util.make_logging_source_adapter(__name__, self)
        self._controller = None

        self._connected  = False
        self._connecting = False
        self._disconnected = True
        self.last_connection_error = None
        self._status = None
        self._has_write_access = False
        self._can_acquire_write_access = False
        self._silenced = False
        self._connect_future = None
コード例 #13
0
    def __init__(self, app_registry, device_registry, linked_mode_on=False):
        self.log = util.make_logging_source_adapter(__name__, self)

        self.app_registry = app_registry
        self.app_registry.mrc_added.connect(self._mrc_added)
        self.app_registry.mrc_about_to_be_removed.connect(
            self._mrc_about_to_be_removed)

        self.cfg_model = ctm.ConfigTreeModel(device_registry=device_registry)

        self.hw_model = htm.HardwareTreeModel(device_registry=device_registry)

        self._linked_mode = linked_mode_on
        self._populate_models()
コード例 #14
0
ファイル: app_context.py プロジェクト: flueke/mesycontrol
    def __init__(self, main_file, auto_load_device_modules=True, parent=None):
        super(Context, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)
        self.main_file = main_file
        self.device_registry = device_registry.DeviceRegistry(
            auto_load_device_modules)

        hw_registry = bm.MRCRegistry()  # Root of the hardware model tree
        setup = cm.Setup()  # Root of the config model tree
        self.app_registry = am.MRCRegistry(hw_registry,
                                           setup)  # Root of the app model tree
        self.director = am.Director(self.app_registry, self.device_registry)

        self._shutdown_callbacks = list()
コード例 #15
0
    def __init__(self, app_device, read_mode, write_mode, parent=None):
        """
        app_device: app_model.Device
        read_mode:  util.HARDWARE | util.CONFIG
        write_mode: util.HARDWARE | util.CONFIG | util.COMBINED
        """

        super(DeviceBase, self).__init__(parent)

        self.log = util.make_logging_source_adapter(__name__, self)

        self.log.debug("DeviceBase(d=%s, r_mode=%s, w_mode=%s)", app_device,
                       util.RW_MODE_NAMES[read_mode],
                       util.RW_MODE_NAMES[write_mode])

        self.app_device = app_device
        self.app_device.mrc_changed.connect(self.mrc_changed)

        self.app_device.hardware_set.connect(self._on_hardware_set)
        self.app_device.config_set.connect(self._on_config_set)

        self.app_device.idc_conflict_changed.connect(self.idc_conflict_changed)
        self.app_device.idc_changed.connect(self.idc_changed)
        self.app_device.hw_idc_changed.connect(self.hw_idc_changed)
        self.app_device.cfg_idc_changed.connect(self.cfg_idc_changed)

        self.app_device.module_changed.connect(self.module_changed)
        self.app_device.hw_module_changed.connect(self.hw_module_changed)
        self.app_device.cfg_module_changed.connect(self.cfg_module_changed)

        self.app_device.profile_changed.connect(self.profile_changed)
        self.app_device.hw_profile_changed.connect(self.hw_profile_changed)
        self.app_device.cfg_profile_changed.connect(self.cfg_profile_changed)

        self.app_device.config_applied_changed.connect(
            self.config_applied_changed)

        self.app_device.hw_parameter_changed.connect(
            self._on_hw_parameter_changed)
        self.app_device.cfg_parameter_changed.connect(
            self._on_cfg_parameter_changed)

        self.app_device.hw_extension_changed.connect(
            self._on_hw_extension_changed)
        self.app_device.cfg_extension_changed.connect(
            self._on_cfg_extension_changed)

        self._read_mode = read_mode
        self._write_mode = write_mode
コード例 #16
0
ファイル: config_gui.py プロジェクト: flueke/mesycontrol
    def __init__(self, title=str(), parent=None):
        super(SubProgressDialog, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)
        self.ui = util.loadUi(":/ui/subprogress_widget.ui")
        self.setWindowTitle(title)
        self.setWindowIcon(util.make_icon(":/window-icon.png"))

        l = QtWidgets.QHBoxLayout(self)
        l.setContentsMargins(0, 0, 0, 0)
        l.setSpacing(0)
        l.addWidget(self.ui)
        self.resize(300, 100)

        self.ui.cancel_button.clicked.connect(self.cancel)
        self._reset()
コード例 #17
0
ファイル: future.py プロジェクト: flueke/mesycontrol
    def __init__(self):
        self._done = False
        self._result = None
        self._exception = None
        self._exception_observed = False
        self._running = False
        self._cancelled = False
        self._callbacks = list()
        self._progress_callbacks = list()
        self._progress_min = 0
        self._progress_max = 100
        self._progress = 0
        self._progress_text = str()

        self.log = util.make_logging_source_adapter(__name__, self)
コード例 #18
0
ファイル: gui_util.py プロジェクト: flueke/mesycontrol
    def __init__(self, widget, window_name_prefix, parent=None, **kwargs):
        super(DeviceSubWindow, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)
        self.setWidget(widget)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.window_name_prefix = window_name_prefix
        self._linked_mode = False
        self.update_title_and_name()
        self.setWindowIcon(util.make_icon(":/window-icon.png"))

        widget.display_mode_changed.connect(self.update_title_and_name)
        widget.write_mode_changed.connect(self.update_title_and_name)

        self.device.config_set.connect(self._on_device_config_set)
        self.device.hardware_set.connect(self._on_device_hardware_set)
        self._on_device_config_set(self.device, None, self.device.cfg)
        self._on_device_hardware_set(self.device, None, self.device.hw)
コード例 #19
0
    def __init__(self, connection):

        self.log = util.make_logging_source_adapter(__name__, self)

        self.connection = connection
        self._mrc = None

        # Maps subscribers to a set of poll items
        self._poll_subscriptions = dict()

        self._connect_timer = QtCore.QTimer()
        self._connect_timer.setSingleShot(True)
        self._connect_timer.timeout.connect(self._on_connect_timer_timeout)
        self._connect_future = None

        def on_connected():
            for i in bm.BUS_RANGE:
                self.scanbus(i)

        self.connection.connected.connect(on_connected)
        self.connection.notification_received.connect(
            self._on_notification_received)
コード例 #20
0
ファイル: app_model.py プロジェクト: flueke/mesycontrol
    def __init__(self, bus, address, mrc=None, hw_device=None, cfg_device=None,
            hw_module=None, cfg_module=None, parent=None):
        self.bus        = int(bus)
        self.address    = int(address)

        if self.bus not in bm.BUS_RANGE:
            raise ValueError("Bus out of range")

        if self.address not in bm.DEV_RANGE:
            raise ValueError("Device address out of range")

        super(Device, self).__init__(hardware=hw_device, config=cfg_device, parent=parent)

        self.log  = util.make_logging_source_adapter(__name__, self)

        self.log.debug("am.Device(b=%d, a=%d, hw_device=%s, cfg_device=%s, hw_mod=%s, cfg_mod=%s",
                bus, address, hw_device, cfg_device, hw_module, cfg_module)

        self._mrc               = None
        self._hw_module         = hw_module
        self._cfg_module        = cfg_module
        self._idc_conflict      = False # Set by _update_idc_conflict()
        # _config_applied can take three values: True, False or None with the
        # latter representing the unknown state.
        self._config_applied    = None  # Set by update_config_applied()
        self._config_addresses  = set() # Filled by set_module()

        self.mrc        = mrc
        self._update_config_addresses()

        self.hardware_set.connect(self._on_hardware_set)
        self.config_set.connect(self._on_config_set)
        self.idc_conflict_changed.connect(self.update_config_applied)

        self._update_idc_conflict()
        self._on_hardware_set(self, None, hw_device)
        self._on_config_set(self, None, cfg_device)
コード例 #21
0
    def __init__(self, host, port, parent=None):
        super(MRCConnection, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)
        self.host = host
        self.port = port
        self.client = MCTCPClient()

        self.client.disconnected.connect(self.on_client_disconnected)
        self.client.socket_error.connect(self.on_client_socket_error)

        self.client.request_queued.connect(self.request_queued)
        self.client.request_sent.connect(self.request_sent)
        self.client.message_received.connect(self.message_received)
        self.client.response_received.connect(self.response_received)
        self.client.notification_received.connect(self.notification_received)
        self.client.notification_received.connect(
            self._on_client_notification_received)
        self.client.error_received.connect(self.error_message_received)

        self.client.queue_empty.connect(self.queue_empty)
        self.client.queue_size_changed.connect(self.queue_size_changed)

        self._is_connecting = False
        self._is_connected = False
コード例 #22
0
    def __init__(self, generator=None, parent=None):
        super(GeneratorRunner, self).__init__(parent)

        self.generator = generator
        self.log = util.make_logging_source_adapter(__name__, self)
コード例 #23
0
 def __init__(self, parent=None):
     super(BasicTreeModel, self).__init__(parent)
     self.log = util.make_logging_source_adapter(__name__, self)
     self.clear()
コード例 #24
0
ファイル: dialogs.py プロジェクト: flueke/mesycontrol
    def __init__(self,
                 bus=None,
                 available_addresses=bm.ALL_DEVICE_ADDRESSES,
                 known_idcs=list(),
                 allow_custom_idcs=True,
                 title="Add Device",
                 selected_bus=None,
                 selected_address=None,
                 selected_idc=None,
                 assigned_name=None,
                 parent=None):
        """
        Dialog constructor.

        If `bus' is given the dialog will use it as the selected bus and won't
        allow the user to change the bus.

        `available_addresses` should be a list of (bus, address) pairs. These
        address pairs will be available for the user to choose from.

        `known_idcs` should be a list of (idc, name) pairs.

        If `allow_custom_idcs` is True the user may enter a custom IDC,
        otherwise only IDCs from `known_idcs` are selectable.

        If `known_idcs' is empty and `allow_custom_idcs' is False this method
        will raise an exception.

        If `selected_bus` and `selected_address` is not None the corresponding
        item will be preselected in the GUI.

        If `selected_idc` is not None the device type will be set using the given IDC
        and will not be modifyable.
        """

        if len(known_idcs) == 0 and not allow_custom_idcs:
            raise RuntimeError("No devices to choose from")

        if len(available_addresses) == 0 or (
                bus is not None and util.ilen_destructive(
                    filter(lambda x: x[0] == bus, available_addresses)) == 0):
            raise RuntimeError("No addresses available")

        super(AddDeviceDialog, self).__init__(parent)

        self.log = util.make_logging_source_adapter(__name__, self)

        self.setWindowTitle(title)
        self._result = None
        self.allow_custom_idcs = allow_custom_idcs

        self.bus_combo = QtWidgets.QComboBox()
        self.bus_combo.addItems([str(i) for i in bm.BUS_RANGE])

        self.address_combos = [QtWidgets.QComboBox() for i in bm.BUS_RANGE]

        for b, a in sorted(available_addresses):
            self.address_combos[b].addItem("%X" % a, a)

        self.address_combo_stack = QtWidgets.QStackedWidget()

        for combo in self.address_combos:
            self.address_combo_stack.addWidget(combo)

        self.bus_combo.activated.connect(
            self.address_combo_stack.setCurrentIndex)

        self.idc_combo = EatReturnCombo()
        for idc, name in sorted(known_idcs, key=lambda x: x[1]):
            self.idc_combo.addItem("%s (%d)" % (name, idc), idc)

        if self.idc_combo.findData(idc) < 0:
            self.idc_combo.addItem(str(idc), idc)

        if selected_idc is not None:
            self.log.debug("selected_idc=%d, idx=%d", selected_idc,
                           self.idc_combo.findData(selected_idc))

            self.idc_combo.setCurrentIndex(
                self.idc_combo.findData(selected_idc))
            self.idc_combo.setEnabled(False)

        if bus is not None:
            self.bus_combo.setCurrentIndex(bus)
            self.address_combo_stack.setCurrentIndex(bus)

        self.name_input = QtWidgets.QLineEdit()

        if assigned_name is not None:
            self.name_input.setText(assigned_name)

        self.button_box = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)

        if allow_custom_idcs:
            self.idc_combo.setEditable(True)
            self.idc_combo.setValidator(QtGui.QIntValidator(1, 99))

            ok_button = self.button_box.button(QtWidgets.QDialogButtonBox.Ok)
            ok_button.setEnabled(len(known_idcs))

            def combo_index_changed():
                ok_button.setEnabled(True)

            def combo_le_text_edited():
                ok_button.setEnabled(
                    self.idc_combo.lineEdit().hasAcceptableInput())

            self.idc_combo.currentIndexChanged.connect(combo_index_changed)
            self.idc_combo.lineEdit().textEdited.connect(combo_le_text_edited)

        if selected_bus is not None:
            assert selected_bus in bm.BUS_RANGE
            self.bus_combo.setCurrentIndex(selected_bus)
            self.address_combo_stack.setCurrentIndex(selected_bus)

            if selected_address is not None:
                assert selected_address in bm.DEV_RANGE
                combo = self.address_combo_stack.currentWidget()
                combo.setCurrentIndex(combo.findText("%X" % selected_address))

        def accept():
            bus = self.bus_combo.currentIndex()
            address = int(self.address_combos[bus].itemData(
                self.address_combos[bus].currentIndex()))

            if self.allow_custom_idcs and self.idc_combo.lineEdit(
            ).hasAcceptableInput():
                idc = int(self.idc_combo.lineEdit().text())
            else:
                idx = self.idc_combo.currentIndex()
                idc = int(self.idc_combo.itemData(idx))

            name = self.name_input.text()

            self._result = AddDeviceDialog.Result(bus, address, idc, name)

            super(AddDeviceDialog, self).accept()

        self.button_box.accepted.connect(accept)
        self.button_box.rejected.connect(self.reject)

        layout = QtWidgets.QFormLayout(self)
        layout.addRow("Bus", self.bus_combo)
        layout.addRow("Address", self.address_combo_stack)
        layout.addRow("IDC", self.idc_combo)
        layout.addRow("Name", self.name_input)
        layout.addRow(self.button_box)
コード例 #25
0
ファイル: future.py プロジェクト: flueke/mesycontrol
 def __init__(self, the_future=None, parent=None):
     super(FutureObserver, self).__init__(parent)
     self.log = util.make_logging_source_adapter(__name__, self)
     self.future = the_future
     self.log.debug(f"FutureObserver created with future={self.future}")
コード例 #26
0
    def __init__(self,
                 device,
                 display_mode=util.COMBINED,
                 write_mode=util.COMBINED,
                 parent=None):

        super(DeviceTableWidget, self).__init__(parent)

        self.log = util.make_logging_source_adapter(__name__, self)
        settings = util.loadUi(":/ui/device_tableview_settings.ui")

        self.log.debug("display_mode=%d, write_mode=%d", display_mode,
                       write_mode)

        model = DeviceTableModel(device,
                                 display_mode=display_mode,
                                 write_mode=write_mode)
        self.view = DeviceTableView(model=model)
        sort_model = self.view.sort_model

        self.view.display_mode_changed.connect(self.display_mode_changed)
        self.view.write_mode_changed.connect(self.write_mode_changed)

        menu = QtWidgets.QMenu('Filter options', self)
        action = menu.addAction("Hide unknown")
        action.setCheckable(True)
        action.setChecked(sort_model.filter_unknown)
        action.triggered.connect(sort_model.set_filter_unknown)

        action = menu.addAction("Hide read-only")
        action.setCheckable(True)
        action.setChecked(sort_model.filter_readonly)
        action.triggered.connect(sort_model.set_filter_readonly)

        action = menu.addAction("Hide volatile")
        action.setCheckable(True)
        action.setChecked(sort_model.filter_volatile)
        action.triggered.connect(sort_model.set_filter_volatile)

        action = menu.addAction("Hide static")
        action.setCheckable(True)
        action.setChecked(sort_model.filter_static)
        action.triggered.connect(sort_model.set_filter_static)

        menu.addSeparator()

        action = menu.addAction("Ignore param ranges on edit")
        action.setCheckable(True)
        action.triggered.connect(model.set_editing_ignore_parameter_ranges)

        action = menu.addAction("Hexadecimal values")
        action.setCheckable(True)
        action.triggered.connect(model.set_display_hex_values)

        menu.addSeparator()

        action = menu.addAction("Resize table cells")
        action.triggered.connect(self.view.resizeColumnsToContents)
        action.triggered.connect(self.view.resizeRowsToContents)

        settings.pb_settings.setMenu(menu)

        settings.le_filter.textChanged.connect(sort_model.setFilterWildcard)

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(settings)
        layout.addWidget(self.view)
        self.setLayout(layout)
コード例 #27
0
 def __init__(self):
     self.log = util.make_logging_source_adapter(__name__, self)
     self.predicate_binding_class_pairs = list()
     self.classinfo_bindings = list()
コード例 #28
0
ファイル: server_process.py プロジェクト: flueke/mesycontrol
 def __init__(self, parent=None):
     super(ServerProcessPool, self).__init__(parent)
     self.log = util.make_logging_source_adapter(__name__, self)
     self._procs_by_port = weakref.WeakValueDictionary()
     self._unavailable_ports = set()
コード例 #29
0
    def __init__(self,
                 app_registry,
                 device_registry,
                 linked_mode_on=False,
                 parent=None):
        super(MCTreeView, self).__init__(parent)
        self.log = util.make_logging_source_adapter(__name__, self)

        self._director = MCTreeDirector(app_registry=app_registry,
                                        device_registry=device_registry,
                                        linked_mode_on=linked_mode_on)

        self.cfg_model = self._director.cfg_model
        self.hw_model = self._director.hw_model

        self.cfg_view = ConfigTreeView()
        self.cfg_view.setObjectName('config_tree_view')
        self.cfg_view.setModel(self.cfg_model)
        self.cfg_model.rowsInserted.connect(self.cfg_view.expandAll)

        def on_cfg_rows_removed(parentIndex, start, end):
            self.log.debug(
                f"on_cfg_rows_removed parentIndex={parentIndex} start={start} end={end}"
            )
            self.cfg_view.rowsRemoved(parentIndex, start, end)
            self.cfg_view.resizeColumnToContents(0)

        self.cfg_model.rowsRemoved.connect(on_cfg_rows_removed)

        def resize_cfg_cols():
            self.cfg_view.resizeColumnToContents(0)

        self.cfg_model.rowsInserted.connect(resize_cfg_cols)

        self.cfg_view.customContextMenuRequested.connect(
            self._cfg_context_menu)
        self.cfg_view.expanded.connect(self._cfg_expanded)
        self.cfg_view.collapsed.connect(self._cfg_collapsed)
        self.cfg_view.setItemDelegate(MCTreeItemDelegate(self._director))

        self.cfg_view.selectionModel().selectionChanged.connect(
            self._cfg_selection_changed)
        self.cfg_view.doubleClicked.connect(self._cfg_view_double_clicked)
        self.cfg_view.clicked.connect(self._cfg_view_clicked)

        self.hw_view = HardwareTreeView()
        self.hw_view.setObjectName('hardware_tree_view')
        self.hw_view.setModel(self.hw_model)
        self.hw_model.rowsInserted.connect(self.hw_view.expandAll)

        def on_hw_rows_removed(parentIndex, start, end):
            self.log.debug(
                f"on_hw_rows_removed parentIndex={parentIndex} start={start} end={end}"
            )
            self.hw_view.rowsRemoved(parentIndex, start, end)
            self.hw_view.resizeColumnToContents(0)

        self.hw_model.rowsRemoved.connect(on_hw_rows_removed)

        def resize_hw_cols():
            self.hw_view.resizeColumnToContents(0)

        self.hw_model.rowsInserted.connect(resize_hw_cols)

        self.hw_view.customContextMenuRequested.connect(self._hw_context_menu)
        self.hw_view.expanded.connect(self._hw_expanded)
        self.hw_view.collapsed.connect(self._hw_collapsed)
        self.hw_view.setItemDelegate(MCTreeItemDelegate(self._director))
        self.hw_view.setFirstColumnSpanned(0, QtCore.QModelIndex(), True)

        self.hw_view.selectionModel().selectionChanged.connect(
            self._hw_selection_changed)
        self.hw_view.doubleClicked.connect(self._hw_view_double_clicked)
        self.hw_view.clicked.connect(self._hw_view_clicked)

        self.cfg_view.expandAll()
        self.hw_view.expandAll()

        self.splitter_toolbar = util.SimpleToolBar(Qt.Vertical)
        self.cfg_toolbar = util.SimpleToolBar(Qt.Horizontal)
        self.cfg_toolbar.layout().setContentsMargins(0, 0, 0, 0)
        self.hw_toolbar = util.SimpleToolBar(Qt.Horizontal)
        self.hw_toolbar.layout().setContentsMargins(0, 0, 0, 0)

        cfg_widget = QtWidgets.QGroupBox("Config")
        cfg_layout = QtWidgets.QVBoxLayout(cfg_widget)
        cfg_layout.setContentsMargins(2, 2, 2, 2)
        cfg_layout.addWidget(self.cfg_toolbar)
        cfg_layout.addWidget(self.cfg_view)
        cfg_layout.setStretch(1, 1)

        hw_widget = QtWidgets.QGroupBox("Hardware")
        hw_layout = QtWidgets.QVBoxLayout(hw_widget)
        hw_layout.setContentsMargins(2, 2, 2, 2)
        hw_layout.addWidget(self.hw_toolbar)
        hw_layout.addWidget(self.hw_view)
        hw_layout.setStretch(1, 1)

        center_widget = QtWidgets.QGroupBox("Actions")
        center_layout = QtWidgets.QVBoxLayout(center_widget)
        center_layout.setContentsMargins(2, 2, 2, 2)
        center_layout.addWidget(self.splitter_toolbar)
        self.center_widget = center_widget

        self.splitter = splitter = DoubleClickSplitter()
        splitter.setChildrenCollapsible(False)
        splitter.addWidget(hw_widget)
        splitter.addWidget(center_widget)
        splitter.addWidget(cfg_widget)

        def on_handle_double_clicked():
            # make hw and cfg views the same size which will result in the
            # splitter buttons being centered
            sizes = splitter.sizes()
            size = (sizes[0] + sizes[2]) / 2
            sizes[0], sizes[2] = size, size
            splitter.setSizes(sizes)

        splitter.handle(1).doubleClicked.connect(on_handle_double_clicked)
        splitter.handle(2).doubleClicked.connect(on_handle_double_clicked)

        layout = QtWidgets.QGridLayout(self)
        layout.addWidget(splitter, 0, 0)

        self._ignore_next_selection = False
コード例 #30
0
ファイル: device_registry.py プロジェクト: flueke/mesycontrol
    def __init__(self, auto_load_modules=False):
        self.log = util.make_logging_source_adapter(__name__, self)
        self.modules = dict()

        if auto_load_modules:
            self.load_system_modules()