migrated secop_psi drivers to new syntax
- includes all changes up to 'fix inheritance order' from git_mlz
6a32ecf342
Change-Id: Ie3ceee3dbd0a9284b47b1d5b5dbe262eebe8f283
This commit is contained in:
@@ -21,13 +21,13 @@
|
||||
# *****************************************************************************
|
||||
|
||||
import configparser
|
||||
from configparser import NoOptionError
|
||||
from collections import OrderedDict
|
||||
from secop.gui.cfg_editor.tree_widget_item import TreeWidgetItem
|
||||
from secop.gui.cfg_editor.utils import get_all_items, get_params, get_props,\
|
||||
get_all_children_with_names, get_module_class_from_name, \
|
||||
get_interface_class_from_name
|
||||
from configparser import NoOptionError
|
||||
|
||||
from secop.gui.cfg_editor.tree_widget_item import TreeWidgetItem
|
||||
from secop.gui.cfg_editor.utils import get_all_children_with_names, \
|
||||
get_all_items, get_interface_class_from_name, \
|
||||
get_module_class_from_name, get_params, get_props
|
||||
|
||||
NODE = 'node'
|
||||
INTERFACE = 'interface'
|
||||
@@ -58,7 +58,7 @@ def write_config(file_name, tree_widget):
|
||||
value = value.replace('\n\n', '\n.\n')
|
||||
value = value.replace('\n', '\n ')
|
||||
itm_lines[id(itm)] = '[%s %s]\n' % (itm.kind, itm.name) +\
|
||||
value_str % (SECTIONS[itm.kind], value)
|
||||
value_str % (SECTIONS[itm.kind], value)
|
||||
# TODO params and props
|
||||
elif itm.kind == PARAMETER and value:
|
||||
itm_lines[id(itm)] = value_str % (itm.name, value)
|
||||
@@ -142,7 +142,7 @@ def read_config(file_path):
|
||||
else:
|
||||
param.addChild(TreeWidgetItem(PROPERTY,
|
||||
separated[1], get_value(config, section,
|
||||
option)))
|
||||
option)))
|
||||
node = get_comments(node, ifs, mods, file_path)
|
||||
return node, ifs, mods
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
# *****************************************************************************
|
||||
|
||||
import os
|
||||
from secop.gui.qt import QMainWindow, QMessageBox
|
||||
from secop.gui.cfg_editor.node_display import NodeDisplay
|
||||
from secop.gui.cfg_editor.utils import loadUi, get_file_paths
|
||||
from secop.gui.cfg_editor.widgets import TabBar
|
||||
|
||||
from secop.gui.cfg_editor.node_display import NodeDisplay
|
||||
from secop.gui.cfg_editor.utils import get_file_paths, loadUi
|
||||
from secop.gui.cfg_editor.widgets import TabBar
|
||||
from secop.gui.qt import QMainWindow, QMessageBox
|
||||
|
||||
# TODO move secop mainwinodw to gui/client and all specific stuff
|
||||
NODE = 'node'
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#
|
||||
# *****************************************************************************
|
||||
|
||||
from secop.gui.qt import QWidget, Qt, QHBoxLayout, QSpacerItem, QSizePolicy
|
||||
from secop.gui.cfg_editor.utils import loadUi
|
||||
from secop.gui.qt import QHBoxLayout, QSizePolicy, QSpacerItem, Qt, QWidget
|
||||
|
||||
|
||||
class NodeDisplay(QWidget):
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
#
|
||||
# *****************************************************************************
|
||||
|
||||
from secop.gui.qt import QTreeWidgetItem, QFont, QWidget, QVBoxLayout, QLabel, \
|
||||
QHBoxLayout, QPushButton, QSize, QSizePolicy, QDialog, QTextEdit, pyqtSignal
|
||||
from secop.gui.cfg_editor.utils import setTreeIcon, setIcon, loadUi, \
|
||||
set_name_edit_style
|
||||
from secop.gui.cfg_editor.utils import loadUi, \
|
||||
set_name_edit_style, setIcon, setTreeIcon
|
||||
from secop.gui.qt import QDialog, QFont, QHBoxLayout, \
|
||||
QLabel, QPushButton, QSize, QSizePolicy, QTextEdit, \
|
||||
QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal
|
||||
from secop.gui.valuewidgets import get_widget
|
||||
from secop.properties import Property
|
||||
|
||||
|
||||
@@ -20,15 +20,16 @@
|
||||
#
|
||||
# *****************************************************************************
|
||||
|
||||
from os import path, listdir
|
||||
import sys
|
||||
import inspect
|
||||
from secop.gui.qt import uic, QIcon, QSize, QFileDialog, QDialogButtonBox
|
||||
from secop.server import getGeneralConfig
|
||||
import sys
|
||||
from os import listdir, path
|
||||
|
||||
from secop.gui.qt import QDialogButtonBox, QFileDialog, QIcon, QSize, uic
|
||||
from secop.modules import Module
|
||||
from secop.params import Parameter
|
||||
from secop.properties import Property
|
||||
from secop.protocol.interface.tcp import TCPServer
|
||||
from secop.server import getGeneralConfig
|
||||
|
||||
uipath = path.dirname(__file__)
|
||||
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
|
||||
import os
|
||||
|
||||
from secop.gui.cfg_editor.config_file import write_config, read_config
|
||||
from secop.gui.cfg_editor.config_file import read_config, write_config
|
||||
from secop.gui.cfg_editor.tree_widget_item import TreeWidgetItem
|
||||
from secop.gui.cfg_editor.utils import get_file_paths, get_modules, \
|
||||
get_interfaces, loadUi, set_name_edit_style, get_module_class_from_name, \
|
||||
get_all_items, get_interface_class_from_name, get_params, get_props, \
|
||||
setActionIcon
|
||||
from secop.gui.qt import QWidget, QDialog, QLabel, QTabBar, Qt, QPoint, QMenu, \
|
||||
QTreeWidget, QSize, pyqtSignal, QLineEdit, QComboBox, QDialogButtonBox, \
|
||||
QTextEdit, QTreeView, QStandardItemModel, QStandardItem
|
||||
from secop.gui.cfg_editor.utils import get_all_items, \
|
||||
get_file_paths, get_interface_class_from_name, get_interfaces, \
|
||||
get_module_class_from_name, get_modules, get_params, \
|
||||
get_props, loadUi, set_name_edit_style, setActionIcon
|
||||
from secop.gui.qt import QComboBox, QDialog, QDialogButtonBox, QLabel, \
|
||||
QLineEdit, QMenu, QPoint, QSize, QStandardItem, QStandardItemModel, \
|
||||
Qt, QTabBar, QTextEdit, QTreeView, QTreeWidget, QWidget, pyqtSignal
|
||||
|
||||
NODE = 'node'
|
||||
MODULE = 'module'
|
||||
|
||||
@@ -26,9 +26,9 @@ import secop.client
|
||||
from secop.gui.modulectrl import ModuleCtrl
|
||||
from secop.gui.nodectrl import NodeCtrl
|
||||
from secop.gui.paramview import ParameterView
|
||||
from secop.gui.qt import QInputDialog, QMainWindow, QMessageBox, \
|
||||
QObject, QTreeWidgetItem, pyqtSignal, pyqtSlot, QBrush, QColor
|
||||
from secop.gui.util import loadUi, Value
|
||||
from secop.gui.qt import QBrush, QColor, QInputDialog, QMainWindow, \
|
||||
QMessageBox, QObject, QTreeWidgetItem, pyqtSignal, pyqtSlot
|
||||
from secop.gui.util import Value, loadUi
|
||||
from secop.lib import formatExtendedTraceback
|
||||
|
||||
ITEM_TYPE_NODE = QTreeWidgetItem.UserType + 1
|
||||
@@ -90,7 +90,7 @@ class QSECNode(QObject):
|
||||
|
||||
def queryCache(self, module):
|
||||
return {k: Value(*self.conn.cache[(module, k)])
|
||||
for k in self.modules[module]['parameters']}
|
||||
for k in self.modules[module]['parameters']}
|
||||
|
||||
def syncCommunicate(self, action, ident='', data=None):
|
||||
reply = self.conn.request(action, ident, data)
|
||||
|
||||
@@ -36,19 +36,19 @@ class CommandDialog(QDialog):
|
||||
loadUi(self, 'cmddialog.ui')
|
||||
|
||||
self.setWindowTitle('Arguments for %s' % cmdname)
|
||||
#row = 0
|
||||
# row = 0
|
||||
|
||||
self._labels = []
|
||||
self.widgets = []
|
||||
# improve! recursive?
|
||||
dtype = argument
|
||||
l = QLabel(repr(dtype))
|
||||
l.setWordWrap(True)
|
||||
w = get_widget(dtype, readonly=False)
|
||||
self.gridLayout.addWidget(l, 0, 0)
|
||||
self.gridLayout.addWidget(w, 0, 1)
|
||||
self._labels.append(l)
|
||||
self.widgets.append(w)
|
||||
label = QLabel(repr(dtype))
|
||||
label.setWordWrap(True)
|
||||
widget = get_widget(dtype, readonly=False)
|
||||
self.gridLayout.addWidget(label, 0, 0)
|
||||
self.gridLayout.addWidget(widget, 0, 1)
|
||||
self._labels.append(label)
|
||||
self.widgets.append(widget)
|
||||
|
||||
self.gridLayout.setRowStretch(1, 1)
|
||||
self.setModal(True)
|
||||
|
||||
@@ -25,14 +25,15 @@
|
||||
import json
|
||||
import pprint
|
||||
from time import sleep
|
||||
|
||||
import mlzlog
|
||||
|
||||
import secop.lib
|
||||
from secop.datatypes import EnumType, StringType
|
||||
from secop.errors import SECoPError
|
||||
from secop.gui.qt import QFont, QFontMetrics, QLabel, \
|
||||
QMessageBox, QTextCursor, QWidget, pyqtSlot, toHtmlEscaped
|
||||
from secop.gui.util import loadUi, Value
|
||||
import secop.lib
|
||||
from secop.gui.util import Value, loadUi
|
||||
|
||||
|
||||
class NodeCtrl(QWidget):
|
||||
@@ -167,7 +168,6 @@ class NodeCtrl(QWidget):
|
||||
print(secop.lib.formatExtendedTraceback())
|
||||
widget = QLabel('Bad configured Module %s! (%s)' % (modname, e))
|
||||
|
||||
|
||||
if unit:
|
||||
labelstr = '%s (%s):' % (modname, unit)
|
||||
else:
|
||||
@@ -289,7 +289,7 @@ class DrivableWidget(ReadableWidget):
|
||||
|
||||
def update_current(self, value):
|
||||
self.currentLineEdit.setText(str(value))
|
||||
#elif self._is_enum:
|
||||
# elif self._is_enum:
|
||||
# member = self._map[self._revmap[value.value]]
|
||||
# self.currentLineEdit.setText('%s.%s (%d)' % (member.enum.name, member.name, member.value))
|
||||
|
||||
|
||||
@@ -22,12 +22,9 @@
|
||||
# *****************************************************************************
|
||||
|
||||
|
||||
from secop.datatypes import EnumType, FloatRange, IntRange
|
||||
from secop.gui.qt import QPushButton as QButton
|
||||
from secop.gui.qt import QCheckBox, QLabel, QLineEdit, \
|
||||
QMessageBox, QSizePolicy, Qt, QWidget, pyqtSignal, pyqtSlot
|
||||
from secop.datatypes import EnumType
|
||||
from secop.gui.qt import QWidget, pyqtSignal, pyqtSlot
|
||||
from secop.gui.util import loadUi
|
||||
from secop.lib import formatExtendedStack
|
||||
|
||||
|
||||
class ParameterWidget(QWidget):
|
||||
|
||||
@@ -32,6 +32,7 @@ uipath = path.dirname(__file__)
|
||||
def loadUi(widget, uiname, subdir='ui'):
|
||||
uic.loadUi(path.join(uipath, subdir, uiname), widget)
|
||||
|
||||
|
||||
class Value:
|
||||
def __init__(self, value, timestamp=None, readerror=None):
|
||||
self.value = value
|
||||
|
||||
@@ -23,12 +23,13 @@
|
||||
|
||||
|
||||
from secop.datatypes import ArrayOf, BLOBType, BoolType, EnumType, \
|
||||
FloatRange, IntRange, StringType, StructOf, TupleOf, TextType
|
||||
from secop.gui.qt import QCheckBox, QComboBox, QDialog, QDoubleSpinBox, \
|
||||
QFrame, QGridLayout, QGroupBox, QLabel, QLineEdit, QSpinBox, QVBoxLayout, \
|
||||
QTextEdit
|
||||
FloatRange, IntRange, StringType, StructOf, TextType, TupleOf
|
||||
from secop.gui.qt import QCheckBox, QComboBox, QDialog, \
|
||||
QDoubleSpinBox, QFrame, QGridLayout, QGroupBox, \
|
||||
QLabel, QLineEdit, QSpinBox, QTextEdit, QVBoxLayout
|
||||
from secop.gui.util import loadUi
|
||||
|
||||
|
||||
# XXX: implement live validators !!!!
|
||||
# XXX: signals upon change of value
|
||||
# XXX: honor readonly in all cases!
|
||||
@@ -171,12 +172,12 @@ class StructWidget(QGroupBox):
|
||||
self._labels = []
|
||||
for idx, name in enumerate(sorted(datatype.members)):
|
||||
dt = datatype.members[name]
|
||||
w = get_widget(dt, readonly=readonly, parent=self)
|
||||
l = QLabel(name)
|
||||
self.layout.addWidget(l, idx, 0)
|
||||
self.layout.addWidget(w, idx, 1)
|
||||
self._labels.append(l)
|
||||
self.subwidgets[name] = (w, dt)
|
||||
widget = get_widget(dt, readonly=readonly, parent=self)
|
||||
label = QLabel(name)
|
||||
self.layout.addWidget(label, idx, 0)
|
||||
self.layout.addWidget(widget, idx, 1)
|
||||
self._labels.append(label)
|
||||
self.subwidgets[name] = (widget, dt)
|
||||
self.datatypes.append(dt)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
@@ -215,21 +216,22 @@ class ArrayWidget(QGroupBox):
|
||||
w.set_value(v)
|
||||
|
||||
|
||||
|
||||
def get_widget(datatype, readonly=False, parent=None):
|
||||
return {FloatRange: FloatWidget,
|
||||
IntRange: IntWidget,
|
||||
StringType: StringWidget,
|
||||
TextType: TextWidget,
|
||||
BLOBType: BlobWidget,
|
||||
EnumType: EnumWidget,
|
||||
BoolType: BoolWidget,
|
||||
TupleOf: TupleWidget,
|
||||
StructOf: StructWidget,
|
||||
ArrayOf: ArrayWidget,
|
||||
return {
|
||||
FloatRange: FloatWidget,
|
||||
IntRange: IntWidget,
|
||||
StringType: StringWidget,
|
||||
TextType: TextWidget,
|
||||
BLOBType: BlobWidget,
|
||||
EnumType: EnumWidget,
|
||||
BoolType: BoolWidget,
|
||||
TupleOf: TupleWidget,
|
||||
StructOf: StructWidget,
|
||||
ArrayOf: ArrayWidget,
|
||||
}.get(datatype.__class__)(datatype, readonly, parent)
|
||||
# TODO: handle NoneOr
|
||||
|
||||
|
||||
class msg(QDialog):
|
||||
def __init__(self, stuff, parent=None):
|
||||
super(msg, self).__init__(parent)
|
||||
@@ -242,7 +244,7 @@ class msg(QDialog):
|
||||
dt = StructOf(i=IntRange(0, 10), f=FloatRange(), b=BoolType())
|
||||
w = StructWidget(dt)
|
||||
self.gridLayout.addWidget(w, row, 1)
|
||||
row+=1
|
||||
row += 1
|
||||
|
||||
self.gridLayout.addWidget(QLabel('stuff'), row, 0, 1, 0)
|
||||
row += 1 # at pos (0,0) span 2 cols, 1 row
|
||||
|
||||
Reference in New Issue
Block a user