Replaces Master-Slave with Client-Server

Expunging all occurrences of inappropriate language of the query and
response paradigm of PLC communications. We are familiar with the Modbus
terminology and support this change.
https://www.modbus.org/docs/Client-ServerPR-07-2020-final.docx.pdf

An adapted version already exists for the server side. Since the server
side cannot be updated immediately, there is still a translation
function in this project to maintain compatibility.
This commit is contained in:
2023-02-07 13:10:36 +01:00
parent 43d4a97edd
commit a96d7d4269
6 changed files with 3105 additions and 3063 deletions

View File

@@ -798,12 +798,12 @@ Wählen Sie 'Ja' zum Überschreiben, 'Nein' um nur fehlende
<context>
<name>RevPiOption</name>
<message>
<location filename="../revpioption.py" line="300"/>
<location filename="../revpioption.py" line="342"/>
<source>Question</source>
<translation>Frage</translation>
</message>
<message>
<location filename="../revpioption.py" line="149"/>
<location filename="../revpioption.py" line="185"/>
<source>The settings will be set on the Revolution Pi now.
ACL changes and service settings are applied immediately.</source>
@@ -812,76 +812,76 @@ ACL changes and service settings are applied immediately.</source>
Berechtigungseinstellungen werden sofort gesetzt.</translation>
</message>
<message>
<location filename="../revpioption.py" line="196"/>
<location filename="../revpioption.py" line="232"/>
<source>Error</source>
<translation>Fehler</translation>
</message>
<message>
<location filename="../revpioption.py" line="196"/>
<location filename="../revpioption.py" line="232"/>
<source>The settings could not be saved on the Revolution Pi!
Try to save the values one mor time and check the log files of RevPiPyLoad if the error rises again.</source>
<translation>Die Einstellungen konnten nicht auf dem Revolution Pi gespeichert werden!
Versuche es erneut und prüfe die Logdateien von RevPiPyLoad, wenn der Fehler erneut auftritt.</translation>
</message>
<message>
<location filename="../revpioption.py" line="206"/>
<location filename="../revpioption.py" line="242"/>
<source>Do you really want to quit?
Unsaved changes will be lost.</source>
<translation>Soll das Fenster wirklich geschlossen werden?
Ungesicherte Änderungen gehen verloren.</translation>
</message>
<message>
<location filename="../revpioption.py" line="249"/>
<location filename="../revpioption.py" line="291"/>
<source>running</source>
<translation>läuft</translation>
</message>
<message>
<location filename="../revpioption.py" line="249"/>
<location filename="../revpioption.py" line="291"/>
<source>stopped</source>
<translation>angehalten</translation>
</message>
<message>
<location filename="../revpioption.py" line="240"/>
<location filename="../revpioption.py" line="282"/>
<source>The MQTT service is not available on your RevPiPyLoad version.</source>
<translation>MQTT ist in der RevPiPyLoad Version nicht verfügbar.</translation>
</message>
<message>
<location filename="../revpioption.py" line="280"/>
<location filename="../revpioption.py" line="322"/>
<source>read only</source>
<translation>Nur lesen</translation>
</message>
<message>
<location filename="../revpioption.py" line="280"/>
<location filename="../revpioption.py" line="322"/>
<source>read and write</source>
<translation>lesen und schreiben</translation>
</message>
<message>
<location filename="../revpioption.py" line="300"/>
<location filename="../revpioption.py" line="342"/>
<source>Are you sure you want to deactivate the XML-RPC server? You will NOT be able to access the Revolution Pi with this program after saving the options!</source>
<translation>Willst du den XML-RPC Server wirklich deaktivieren? Du wirst dich NICHT mehr mit diesem Programm zum Revolution Pi verbinden können!</translation>
</message>
<message>
<location filename="../revpioption.py" line="312"/>
<location filename="../revpioption.py" line="354"/>
<source>Start/Stop PLC program and read logs</source>
<translation>SPS Programm starten/stoppen und Logs lesen</translation>
</message>
<message>
<location filename="../revpioption.py" line="312"/>
<location filename="../revpioption.py" line="354"/>
<source>+ read IOs in watch mode</source>
<translation>+ EAs in SPS Betrachter lesen</translation>
</message>
<message>
<location filename="../revpioption.py" line="312"/>
<location filename="../revpioption.py" line="354"/>
<source>+ read properties and download PLC program</source>
<translation>+ Einstellungen lesen und SPS Programm herunterladen</translation>
</message>
<message>
<location filename="../revpioption.py" line="312"/>
<location filename="../revpioption.py" line="354"/>
<source>+ upload PLC program</source>
<translation>+ SPS Programm hochladen</translation>
</message>
<message>
<location filename="../revpioption.py" line="312"/>
<location filename="../revpioption.py" line="354"/>
<source>+ set properties</source>
<translation>+ Einstellungen ändern</translation>
</message>

View File

@@ -61,7 +61,7 @@ class MqttManager(QtWidgets.QDialog, Ui_diag_mqtt):
return True
def accept(self) -> None:
"""Save values to master dict."""
"""Save values to value dict."""
self.dc["mqttbasetopic"] = self.txt_basetopic.text()
self.dc["mqttsendinterval"] = self.sbx_sendinterval.value()
self.dc["mqttsend_on_event"] = int(self.cbx_send_on_event.isChecked())

View File

@@ -22,9 +22,10 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
self.setFixedSize(self.size())
self.dc = {}
self.acl_plcslave = ""
self.acl_plcserver = ""
self.acl_xmlrpc = ""
self.mrk_xml_ask = True
self.wrong_names = False
self._dict_mqttsettings = {
"mqttbasetopic": "revpi01",
@@ -56,7 +57,7 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
self.cbx_zeroonerror.setEnabled(allow)
self.cbb_replace_io.setEnabled(allow)
self.txt_replace_io.setEnabled(allow and self.cbb_replace_io.currentIndex() == 3)
self.cbx_plcslave.setEnabled(allow)
self.cbx_plcserver.setEnabled(allow)
self.cbx_mqtt.setEnabled(allow)
self.cbx_xmlrpc.setEnabled(allow)
@@ -85,8 +86,8 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
self.cbb_reset_driver_action.currentIndex() != self.dc.get("reset_driver_action", 2) or
# todo: self.dc.get("rtlevel", 2)
int(self.cbx_plcslave.isChecked()) != self.dc.get("plcslave", 0) or
self.acl_plcslave != self.dc.get("plcslaveacl", "") or
int(self.cbx_plcserver.isChecked()) != self.dc.get("plcserver", 0) or
self.acl_plcserver != self.dc.get("plcserveracl", "") or
int(self.cbx_mqtt.isChecked()) != self.dc.get("mqtt", 0) or
self._changesdone_mqtt() or
@@ -120,8 +121,8 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
self.cbx_zeroonerror.setChecked(bool(self.dc.get("zeroonerror", 0)))
self.txt_replace_io.setText(self.dc.get("replace_ios", ""))
self.cbb_reset_driver_action.setCurrentIndex(self.dc.get("reset_driver_action", 2))
self.cbx_plcslave.setChecked(bool(self.dc.get("plcslave", 0)))
self.acl_plcslave = self.dc.get("plcslaveacl", "")
self.cbx_plcserver.setChecked(bool(self.dc.get("plcserver", 0)))
self.acl_plcserver = self.dc.get("plcserveracl", "")
self.cbx_mqtt.setChecked(bool(self.dc.get("mqtt", 0)))
self.cbx_xmlrpc.setChecked(bool(self.dc.get("xmlrpc", 0)))
self.acl_xmlrpc = self.dc.get("xmlrpcacl", "")
@@ -141,6 +142,41 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
if key in self.dc:
self._dict_mqttsettings[key] = self.dc[key]
def _translate_wrong_names(self) -> dict:
"""
Translate settings values of revpipyload < 0.10.0.
With RevPiPyLoad 0.10.0 we replaced the words master-slave with
client-server. Unfortunately we cannot expect that everyone will be
able to switch to the new version of RevPiPyLoad immediately.
Therefore, for a few versions of this software, we need to do a
translation of the values.
This function will translate the self.dc always to the new values and
return a copy of it with new or old values, depending on previous
detections.
:return: Settings with wrong values, if detected in previous calls
"""
name_mappings = (
("plcslave", "plcserver"),
("plcslaveacl", "plcserveracl"),
)
for wrong, right in name_mappings:
if wrong in self.dc:
self.wrong_names = True
self.dc[right] = self.dc[wrong]
del self.dc[wrong]
translated_settings = self.dc.copy()
if self.wrong_names:
for wrong, right in name_mappings:
if right in translated_settings:
translated_settings[wrong] = self.dc[right]
del translated_settings[right]
return translated_settings
def accept(self) -> None:
if not self._changesdone():
super(RevPiOption, self).accept()
@@ -164,9 +200,9 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
self.dc["zeroonerror"] = int(self.cbx_zeroonerror.isChecked())
self.dc["replace_ios"] = self.txt_replace_io.text()
# PLCSlave Settings
self.dc["plcslave"] = int(self.cbx_plcslave.isChecked())
self.dc["plcslaveacl"] = self.acl_plcslave
# PLCServer Settings
self.dc["plcserver"] = int(self.cbx_plcserver.isChecked())
self.dc["plcserveracl"] = self.acl_plcserver
# MQTT Settings
self.dc["mqtt"] = int(self.cbx_mqtt.isChecked())
@@ -186,7 +222,7 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
self.dc["xmlrpcacl"] = self.acl_xmlrpc
saved = helper.cm.call_remote_function(
"set_config", self.dc, ask,
"set_config", self._translate_wrong_names(), ask,
default_value=False
)
@@ -223,14 +259,20 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
if len(self.dc) == 0:
return QtWidgets.QDialog.Rejected
self.wrong_names = False
self._translate_wrong_names()
self._load_settings()
self._apply_acl()
running = helper.cm.call_remote_function("plcslaverunning", default_value=False)
self.lbl_slave_status.setText(
running = helper.cm.call_remote_function(
"plcslaverunning" if self.wrong_names else "plcserverrunning",
default_value=False
)
self.lbl_server_status.setText(
self.tr("running") if running else self.tr("stopped")
)
self.lbl_slave_status.setStyleSheet(
self.lbl_server_status.setStyleSheet(
"color: green" if running else "color: red"
)
@@ -275,15 +317,15 @@ class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
self.txt_replace_io.setEnabled(index == 3)
@QtCore.pyqtSlot()
def on_btn_aclplcslave_clicked(self):
def on_btn_aclplcserver_clicked(self):
"""Start ACL manager to edit ACL entries."""
self.diag_aclmanager.setup_acl_manager(self.acl_plcslave, {
self.diag_aclmanager.setup_acl_manager(self.acl_plcserver, {
0: self.tr("read only"),
1: self.tr("read and write"),
})
self.diag_aclmanager.read_only = helper.cm.xml_mode < 4
if self.diag_aclmanager.exec() == QtWidgets.QDialog.Accepted:
self.acl_plcslave = self.diag_aclmanager.get_acl()
self.acl_plcserver = self.diag_aclmanager.get_acl()
@QtCore.pyqtSlot()
def on_btn_mqtt_clicked(self):

File diff suppressed because it is too large Load Diff

View File

@@ -74,23 +74,23 @@ class Ui_diag_options(object):
self.gb_server.setObjectName("gb_server")
self.gridLayout_2 = QtWidgets.QGridLayout(self.gb_server)
self.gridLayout_2.setObjectName("gridLayout_2")
self.btn_aclplcslave = QtWidgets.QPushButton(self.gb_server)
self.btn_aclplcslave.setObjectName("btn_aclplcslave")
self.gridLayout_2.addWidget(self.btn_aclplcslave, 0, 1, 1, 1)
self.btn_aclplcserver = QtWidgets.QPushButton(self.gb_server)
self.btn_aclplcserver.setObjectName("btn_aclplcserver")
self.gridLayout_2.addWidget(self.btn_aclplcserver, 0, 1, 1, 1)
self.cbx_mqtt = QtWidgets.QCheckBox(self.gb_server)
self.cbx_mqtt.setObjectName("cbx_mqtt")
self.gridLayout_2.addWidget(self.cbx_mqtt, 2, 0, 1, 1)
self.cbx_plcslave = QtWidgets.QCheckBox(self.gb_server)
self.cbx_plcslave.setObjectName("cbx_plcslave")
self.gridLayout_2.addWidget(self.cbx_plcslave, 0, 0, 1, 1)
self.lbl_slave_status = QtWidgets.QLabel(self.gb_server)
self.lbl_slave_status.setAlignment(QtCore.Qt.AlignCenter)
self.lbl_slave_status.setObjectName("lbl_slave_status")
self.gridLayout_2.addWidget(self.lbl_slave_status, 1, 1, 1, 1)
self.lbl_lbl_slave_status = QtWidgets.QLabel(self.gb_server)
self.lbl_lbl_slave_status.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.lbl_lbl_slave_status.setObjectName("lbl_lbl_slave_status")
self.gridLayout_2.addWidget(self.lbl_lbl_slave_status, 1, 0, 1, 1)
self.cbx_plcserver = QtWidgets.QCheckBox(self.gb_server)
self.cbx_plcserver.setObjectName("cbx_plcserver")
self.gridLayout_2.addWidget(self.cbx_plcserver, 0, 0, 1, 1)
self.lbl_server_status = QtWidgets.QLabel(self.gb_server)
self.lbl_server_status.setAlignment(QtCore.Qt.AlignCenter)
self.lbl_server_status.setObjectName("lbl_server_status")
self.gridLayout_2.addWidget(self.lbl_server_status, 1, 1, 1, 1)
self.lbl_lbl_server_status = QtWidgets.QLabel(self.gb_server)
self.lbl_lbl_server_status.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.lbl_lbl_server_status.setObjectName("lbl_lbl_server_status")
self.gridLayout_2.addWidget(self.lbl_lbl_server_status, 1, 0, 1, 1)
self.lbl_mqtt_status = QtWidgets.QLabel(self.gb_server)
self.lbl_mqtt_status.setAlignment(QtCore.Qt.AlignCenter)
self.lbl_mqtt_status.setObjectName("lbl_mqtt_status")
@@ -141,11 +141,11 @@ class Ui_diag_options(object):
self.cbx_autoreload.setText(_translate("diag_options", "Restart PLC program after exit or crash"))
self.lbl_lbl_reset_driver_action.setText(_translate("diag_options", "PLC program behavior after piCtory driver reset clicked"))
self.gb_server.setTitle(_translate("diag_options", "RevPiPyLoad server services"))
self.btn_aclplcslave.setText(_translate("diag_options", "Edit ACL"))
self.btn_aclplcserver.setText(_translate("diag_options", "Edit ACL"))
self.cbx_mqtt.setText(_translate("diag_options", "MQTT process image publisher"))
self.cbx_plcslave.setText(_translate("diag_options", "Start RevPi piControl server"))
self.lbl_slave_status.setText(_translate("diag_options", "status"))
self.lbl_lbl_slave_status.setText(_translate("diag_options", "piControl server is:"))
self.cbx_plcserver.setText(_translate("diag_options", "Start RevPi piControl server"))
self.lbl_server_status.setText(_translate("diag_options", "status"))
self.lbl_lbl_server_status.setText(_translate("diag_options", "piControl server is:"))
self.lbl_mqtt_status.setText(_translate("diag_options", "status"))
self.lbl_lbl_mqtt_status.setText(_translate("diag_options", "MQTT publish service is:"))
self.btn_mqtt.setText(_translate("diag_options", "Settings"))

View File

@@ -149,7 +149,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QPushButton" name="btn_aclplcslave">
<widget class="QPushButton" name="btn_aclplcserver">
<property name="text">
<string>Edit ACL</string>
</property>
@@ -163,14 +163,14 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cbx_plcslave">
<widget class="QCheckBox" name="cbx_plcserver">
<property name="text">
<string>Start RevPi piControl server</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lbl_slave_status">
<widget class="QLabel" name="lbl_server_status">
<property name="text">
<string>status</string>
</property>
@@ -180,7 +180,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_lbl_slave_status">
<widget class="QLabel" name="lbl_lbl_server_status">
<property name="text">
<string>piControl server is:</string>
</property>