mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 15:13:52 +01:00
feat: New XML-RPC function 'set_plcprogram'
With the new XML-RPC function, a new PLC program can be passed, which is loaded directly and saved in the configuration file. Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
@@ -477,6 +477,8 @@ class RevPiPyLoad:
|
|||||||
# XML Modus 4 Einstellungen ändern
|
# XML Modus 4 Einstellungen ändern
|
||||||
self.xsrv.register_function(
|
self.xsrv.register_function(
|
||||||
4, self.xml_setconfig, "set_config")
|
4, self.xml_setconfig, "set_config")
|
||||||
|
self.xsrv.register_function(
|
||||||
|
4, self.xml_setplcprogram, "set_plcprogram")
|
||||||
self.xsrv.register_function(
|
self.xsrv.register_function(
|
||||||
4, self.xml_setpictoryrsc, "set_pictoryrsc")
|
4, self.xml_setpictoryrsc, "set_pictoryrsc")
|
||||||
|
|
||||||
@@ -1365,6 +1367,33 @@ class RevPiPyLoad:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def xml_setplcprogram(self, plcprogram: str) -> int:
|
||||||
|
"""
|
||||||
|
Set new plc program, without restart services.
|
||||||
|
|
||||||
|
:returns: 0 Erfolgreich
|
||||||
|
-1 Programm lauft noch
|
||||||
|
-2 Datei nicht gefunden
|
||||||
|
"""
|
||||||
|
if type(plcprogram) is not str:
|
||||||
|
raise TypeError("The given plc program must be <class 'str'>")
|
||||||
|
if not plcprogram:
|
||||||
|
raise ValueError("Empty string not allowed for plc program")
|
||||||
|
|
||||||
|
stop_code = self.xml_plcstop()
|
||||||
|
|
||||||
|
# Set the new plc program setting to activ configuration
|
||||||
|
self.plcprogram = plcprogram
|
||||||
|
|
||||||
|
# Save the new value to config file without reload
|
||||||
|
self.xml_setconfig({"plcprogram": plcprogram}, False)
|
||||||
|
|
||||||
|
# Start the program, if it was running before change
|
||||||
|
if stop_code > -1:
|
||||||
|
return self.xml_plcstart()
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
def xml_setpictoryrsc(self, filebytes, reset=False):
|
def xml_setpictoryrsc(self, filebytes, reset=False):
|
||||||
"""Schreibt die config.rsc Datei von piCotry.
|
"""Schreibt die config.rsc Datei von piCotry.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user