Completed
Push — master ( af7566...2b0b83 )
by Olivier
30s
created

CallMethodDialog._add_input()   A

Complexity

Conditions 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 1
1
from PyQt5.QtCore import QSettings, Qt
2
from PyQt5.QtWidgets import QPushButton, QComboBox, QLabel, QLineEdit, QHBoxLayout, QDialog, QDialogButtonBox, QVBoxLayout, QCheckBox, QFrame
3
4
from opcua import ua, Node
5
from opcua.common.ua_utils import string_to_variant
6
from opcua.common.ua_utils import data_type_to_variant_type
7
8
from uawidgets.get_node_dialog import GetNodeButton
9
10
11
class CallMethodDialog(QDialog):
12
    def __init__(self, parent, server, node):
13
        QDialog.__init__(self, parent)
14
        self.setWindowTitle("UA Method Call")
15
        self.settings = QSettings()
16
        self.server = server
17
        self.node = node
18
19
        self.vlayout = QVBoxLayout(self)
20
        self.layout = QHBoxLayout()
21
        self.vlayout.addLayout(self.layout)
22
        self.inputs = []
23
        self.outputs = []
24
25
        self.vlayout.addWidget(QLabel("Input Arguments:", self))
26
        try:
27
            inputs = node.get_child("0:InputArguments")
28
            args = inputs.get_value()
29
            for arg in args:
30
                self._add_input(arg)
31
        except ua.UaError as ex:
32
            print(ex)
33
        self.vlayout.addWidget(QLabel("Output", self))
34
        try:
35
            outputs = node.get_child("0:OutputArguments")
36
            args = outputs.get_value()
37
            for arg in args:
38
                self._add_output(arg)
39
        except ua.UaError as ex:
40
            print(ex)
41
42
        layout = QHBoxLayout()
43
        self.vlayout.addLayout(layout)
44
45
        cancel_button = QPushButton("Cancel")
46
        cancel_button.clicked.connect(self.close)
47
        layout.addWidget(cancel_button)
48
        call_button = QPushButton("Call Method")
49
        call_button.clicked.connect(self._call)
50
        layout.addWidget(call_button)
51
52
    def _call(self):
53
        parent = node.get_parent()
54
        args = []
55
        for inp in self.inputs:
56
            pass
57
58
59
60
61
    def _add_input(self, arg):
62
        layout = QHBoxLayout()
63
        self.vlayout.addLayout(layout)
64
        layout.addWidget(QLabel("Argument:", self))
65
        layout.addWidget(QLabel("Name:{}".format(arg.Name), self))
66
        layout.addWidget(QLabel("Data type:{}".format(arg.DataType), self))
67
        layout.addWidget(QLabel("Description:{}".format(arg.Description), self))
68
        lineedit = QLineEdit(self)
69
        self.inputs.append(lineedit)
70
        layout.addWidget(lineedit)
71
72
    def _add_output(self, arg):
73
        layout = QHBoxLayout()
74
        self.vlayout.addLayout(layout)
75
        layout.addWidget(QLabel("Output:", self))
76
        label = QLabel("", self)
77
        self.outputs.append(label)
78
        layout.addWidget(label)
79