From 5ff547dfff57de7aa7793cc8820a0c6454694319 Mon Sep 17 00:00:00 2001 From: Klaus Landsdorf Date: Sat, 26 Feb 2022 22:45:54 +0100 Subject: [PATCH 1/3] feat: Subscription shows Identifier and not Display-Name --- uaclient/mainwindow.py | 20 +++++++++++++++----- uaclient/mainwindow_ui.py | 6 ++++++ uaclient/mainwindow_ui.ui | 12 ++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/uaclient/mainwindow.py b/uaclient/mainwindow.py index 36b1824..f55eaf6 100644 --- a/uaclient/mainwindow.py +++ b/uaclient/mainwindow.py @@ -169,10 +169,16 @@ def _subscribe(self, node=None): if node is None: return if node in self._subscribed_nodes: - logger.warning("allready subscribed to node: %s ", node) + logger.warning("already subscribed to node: %s ", node) return - self.model.setHorizontalHeaderLabels(["DisplayName", "Value", "Timestamp"]) - text = str(node.read_display_name().Text) + + if QSettings().value("sub_identifier_mode", False, bool): + self.model.setHorizontalHeaderLabels(["Identifier", "Value", "Timestamp"]) + text = str(node.nodeid.Identifier) + else: + self.model.setHorizontalHeaderLabels(["DisplayName", "Value", "Timestamp"]) + text = str(node.read_display_name().Text) + row = [QStandardItem(text), QStandardItem("No Data yet"), QStandardItem("")] row[0].setData(node) self.model.appendRow(row) @@ -285,6 +291,7 @@ def __init__(self): self.ui.connectOptionButton.clicked.connect(self.show_connection_dialog) self.ui.actionClient_Application_Certificate.triggered.connect(self.show_application_certificate_dialog) + self.ui.actionSubIdentifier_Mode.triggered.connect(self.sub_identifier_mode) self.ui.actionDark_Mode.triggered.connect(self.dark_mode) def _uri_changed(self, uri): @@ -447,6 +454,9 @@ def call_method(self): dia = CallMethodDialog(self, self.uaclient.client, node) dia.show() + def sub_identifier_mode(self): + self.settings.setValue("sub_identifier_mode", self.ui.actionSubIdentifier_Mode.isChecked()) + def dark_mode(self): self.settings.setValue("dark_mode", self.ui.actionDark_Mode.isChecked()) @@ -463,10 +473,10 @@ def main(): logging.getLogger().addHandler(handler) logging.getLogger("uaclient").setLevel(logging.INFO) logging.getLogger("uawidgets").setLevel(logging.INFO) - #logging.getLogger("opcua").setLevel(logging.INFO) # to enable logging of ua client library + # logging.getLogger("opcua").setLevel(logging.INFO) # to enable logging of ua client library # set stylesheet - if (QSettings().value("dark_mode", "false") == "true"): + if QSettings().value("dark_mode", False, bool): file = QFile(":/dark.qss") file.open(QFile.ReadOnly | QFile.Text) stream = QTextStream(file) diff --git a/uaclient/mainwindow_ui.py b/uaclient/mainwindow_ui.py index 4359aa3..9208075 100644 --- a/uaclient/mainwindow_ui.py +++ b/uaclient/mainwindow_ui.py @@ -298,6 +298,9 @@ def setupUi(self, MainWindow): self.actionDark_Mode = QtWidgets.QAction(MainWindow) self.actionDark_Mode.setCheckable(True) self.actionDark_Mode.setObjectName("actionDark_Mode") + self.actionSubIdentifier_Mode = QtWidgets.QAction(MainWindow) + self.actionSubIdentifier_Mode.setCheckable(True) + self.actionSubIdentifier_Mode.setObjectName("actionSubIdentifier_Mode") self.actionClient_Application_Certificate = QtWidgets.QAction(MainWindow) self.actionClient_Application_Certificate.setObjectName("actionClient_Application_Certificate") self.actionFocusTree = QtWidgets.QAction(MainWindow) @@ -313,6 +316,7 @@ def setupUi(self, MainWindow): self.menuOPC_UA_Client.addAction(self.actionFocusTree) self.menuSettings.addAction(self.actionDark_Mode) self.menuSettings.addAction(self.actionClient_Application_Certificate) + self.menuSettings.addAction(self.actionSubIdentifier_Mode) self.menuBar.addAction(self.menuOPC_UA_Client.menuAction()) self.menuBar.addAction(self.menuSettings.menuAction()) @@ -374,6 +378,8 @@ def retranslateUi(self, MainWindow): self.actionCall.setToolTip(_translate("MainWindow", "Call Ua Method")) self.actionDark_Mode.setText(_translate("MainWindow", "Dark Mode")) self.actionDark_Mode.setStatusTip(_translate("MainWindow", "Enables Dark Mode Theme")) + self.actionSubIdentifier_Mode.setText(_translate("MainWindow", "Name Subscription with Identifier")) + self.actionSubIdentifier_Mode.setStatusTip(_translate("MainWindow", "Enables naming Subscription with Identifier")) self.actionClient_Application_Certificate.setText(_translate("MainWindow", "Client Application Certificate")) self.actionFocusTree.setText(_translate("MainWindow", "FocusTree")) self.actionFocusTree.setShortcut(_translate("MainWindow", "Alt+T")) diff --git a/uaclient/mainwindow_ui.ui b/uaclient/mainwindow_ui.ui index 564518f..9a4c715 100644 --- a/uaclient/mainwindow_ui.ui +++ b/uaclient/mainwindow_ui.ui @@ -85,6 +85,7 @@ + @@ -566,6 +567,17 @@ Client Application Certificate + + + true + + + Name Subscription with Identifier + + + Enables naming Subscription with Identifier + + From 969526d55ccdf701f3a9807baa342afefea9e01b Mon Sep 17 00:00:00 2001 From: Klaus Landsdorf Date: Sat, 26 Feb 2022 23:35:59 +0100 Subject: [PATCH 2/3] chore: window titles --- uaclient/mainwindow_ui.py | 2 ++ uaclient/mainwindow_ui.ui | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/uaclient/mainwindow_ui.py b/uaclient/mainwindow_ui.py index 9208075..27d4709 100644 --- a/uaclient/mainwindow_ui.py +++ b/uaclient/mainwindow_ui.py @@ -383,3 +383,5 @@ def retranslateUi(self, MainWindow): self.actionClient_Application_Certificate.setText(_translate("MainWindow", "Client Application Certificate")) self.actionFocusTree.setText(_translate("MainWindow", "FocusTree")) self.actionFocusTree.setShortcut(_translate("MainWindow", "Alt+T")) + self.addrDockWidget.setWindowTitle(_translate("MainWindow", "Connection Options")) + self.logDockWidget_2.setWindowTitle(_translate("MainWindow", "Logs")) diff --git a/uaclient/mainwindow_ui.ui b/uaclient/mainwindow_ui.ui index 9a4c715..d536f14 100644 --- a/uaclient/mainwindow_ui.ui +++ b/uaclient/mainwindow_ui.ui @@ -191,6 +191,9 @@ Qt::TopDockWidgetArea + + Connection + 4 @@ -372,6 +375,9 @@ + + &Logs + 8 From 55aa84c73c13ae16529366d3ea21b94575654396 Mon Sep 17 00:00:00 2001 From: Klaus Landsdorf Date: Sat, 26 Feb 2022 23:36:15 +0100 Subject: [PATCH 3/3] feat: resize subscription list --- uaclient/mainwindow.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/uaclient/mainwindow.py b/uaclient/mainwindow.py index f55eaf6..6985ce6 100644 --- a/uaclient/mainwindow.py +++ b/uaclient/mainwindow.py @@ -8,7 +8,7 @@ from PyQt5.QtCore import pyqtSignal, QFile, QTimer, Qt, QObject, QSettings, QTextStream, QItemSelection, \ QCoreApplication from PyQt5.QtGui import QStandardItemModel, QStandardItem, QIcon -from PyQt5.QtWidgets import QMainWindow, QMessageBox, QWidget, QApplication, QMenu +from PyQt5.QtWidgets import QMainWindow, QMessageBox, QWidget, QApplication, QMenu, QHeaderView from uaclient.theme import breeze_resources @@ -131,7 +131,9 @@ def __init__(self, window, uaclient): self._subscribed_nodes = [] self.model = QStandardItemModel() self.window.ui.subView.setModel(self.model) - self.window.ui.subView.horizontalHeader().setSectionResizeMode(1) + + for i in range(self.window.ui.subView.horizontalHeader().count()): + self.window.ui.subView.horizontalHeader().setSectionResizeMode(i, QHeaderView.Stretch) self.window.ui.actionSubscribeDataChange.triggered.connect(self._subscribe) self.window.ui.actionUnsubscribeDataChange.triggered.connect(self._unsubscribe)