diff --git a/src/revpipyload/revpipyload.py b/src/revpipyload/revpipyload.py index cfe77d1..87aac87 100644 --- a/src/revpipyload/revpipyload.py +++ b/src/revpipyload/revpipyload.py @@ -477,6 +477,8 @@ class RevPiPyLoad: # XML Modus 4 Einstellungen ändern self.xsrv.register_function( 4, self.xml_setconfig, "set_config") + self.xsrv.register_function( + 4, self.xml_setplcprogram, "set_plcprogram") self.xsrv.register_function( 4, self.xml_setpictoryrsc, "set_pictoryrsc") @@ -1365,6 +1367,33 @@ class RevPiPyLoad: 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 ") + 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): """Schreibt die config.rsc Datei von piCotry.