Add PLC stop command python3
authorGP Orcullo <kinsamanka@gmail.com>
Thu, 20 Oct 2022 19:30:23 +0800
branchpython3
changeset 3775 5780e7c13fd8
parent 3774 5a3c5dc888cc
child 3776 1fbc900ca1ce
Add PLC stop command
Beremiz_cli.py
CLIController.py
--- a/Beremiz_cli.py	Mon Nov 07 17:32:56 2022 +0800
+++ b/Beremiz_cli.py	Thu Oct 20 19:30:23 2022 +0800
@@ -92,6 +92,15 @@
         return session.controller.run_project()
     return processor
 
+@cli.command()
+@pass_session
+@ensure_controller
+def stop(session):
+    """Stop program running in PLC. """
+    def processor():
+        return session.controller.stop_project()
+    return processor
+
 
 @cli.result_callback()
 @pass_session
--- a/CLIController.py	Mon Nov 07 17:32:56 2022 +0800
+++ b/CLIController.py	Thu Oct 20 19:30:23 2022 +0800
@@ -172,6 +172,12 @@
 
         return 0 if self._Run() else 1
         
+    @with_project_loaded
+    @connected
+    def stop_project(self):
+
+        return 0 if self._Stop() else 1
+        
 
     def finish(self):