Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Subscription shows Identifier and not Display-Name #78

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions uaclient/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, QDialog
from PyQt5.QtWidgets import QMainWindow, QMessageBox, QWidget, QApplication, QMenu, QDialog, QHeaderView

from uaclient.theme import breeze_resources

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -169,10 +171,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)
Expand Down Expand Up @@ -285,6 +293,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):
Expand Down Expand Up @@ -447,6 +456,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())

Expand All @@ -463,10 +475,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)
Expand Down
8 changes: 8 additions & 0 deletions uaclient/mainwindow_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())

Expand Down Expand Up @@ -374,6 +378,10 @@ 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"))
self.addrDockWidget.setWindowTitle(_translate("MainWindow", "Connection Options"))
self.logDockWidget_2.setWindowTitle(_translate("MainWindow", "Logs"))
18 changes: 18 additions & 0 deletions uaclient/mainwindow_ui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
</property>
<addaction name="actionDark_Mode"/>
<addaction name="actionClient_Application_Certificate"/>
<addaction name="actionSubIdentifier_Mode"/>
</widget>
<addaction name="menuOPC_UA_Client"/>
<addaction name="menuSettings"/>
Expand Down Expand Up @@ -190,6 +191,9 @@
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Connection</string>
</property>
<attribute name="dockWidgetArea">
<number>4</number>
</attribute>
Expand Down Expand Up @@ -371,6 +375,9 @@
</widget>
</widget>
<widget class="QDockWidget" name="logDockWidget_2">
<property name="windowTitle">
<string>&amp;Logs</string>
</property>
<attribute name="dockWidgetArea">
<number>8</number>
</attribute>
Expand Down Expand Up @@ -566,6 +573,17 @@
<string>Client Application Certificate</string>
</property>
</action>
<action name="actionSubIdentifier_Mode">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Name Subscription with Identifier</string>
</property>
<property name="statusTip">
<string>Enables naming Subscription with Identifier</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
Expand Down