CLI: simpler status polling, fixing pyro5 thread
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 22 May 2023 14:37:15 +0200
changeset 3812 92e528718733
parent 3811 fcd2826f5c9e
child 3813 6f3e20690172
CLI: simpler status polling, fixing pyro5 thread
Beremiz_cli.py
CLIController.py
--- a/Beremiz_cli.py	Sat May 20 00:37:31 2023 +0200
+++ b/Beremiz_cli.py	Mon May 22 14:37:15 2023 +0200
@@ -117,7 +117,8 @@
         click.echo("Press Ctrl+C to quit")
         try:
             while True:
-                time.sleep(1)
+                session.controller.UpdateMethodsFromPLCStatus()
+                time.sleep(0.5)
         except KeyboardInterrupt:
             pass
 
--- a/CLIController.py	Sat May 20 00:37:31 2023 +0200
+++ b/CLIController.py	Mon May 22 14:37:15 2023 +0200
@@ -78,38 +78,11 @@
         log = Log()
         LocalRuntimeMixin.__init__(self, log, use_gui=False)
         ProjectController.__init__(self, None, log)
-        self.CLIStatusTimer = None
-        self.KillCLIStatusTimer = False
-
-
-    def StartCLIStatusTimer(self):
-        if self.CLIStatusTimer is not None:
-            return
-        self.CLIStatusTimer = Timer(0.5, self.CLIStatusTimerProc)
-        self.KillCLIStatusTimer = False
-        self.CLIStatusTimer.start()
-
-    def StopCLIStatusTimer(self):
-        if self.CLIStatusTimer is None:
-            return
-        self.KillCLIStatusTimer = True
-        self.CLIStatusTimer.cancel()
-        self.CLIStatusTimer = None
-
-    def CLIStatusTimerProc(self):
-        self.CLIStatusTimer = None
-        if not self.KillCLIStatusTimer:
-            self.PullPLCStatusProc(None)
-            self.StartCLIStatusTimer()
 
     def _SetConnector(self, connector, update_status=True):
         self._connector = connector
         self.previous_log_count = [None]*LogLevelsCount
-        if connector is not None:
-            self.StartCLIStatusTimer()
-        else:
-            self.StopCLIStatusTimer()
-            if update_status:
+        if connector is None and update_status:
                 self.UpdateMethodsFromPLCStatus()
 
     def UpdatePLCLog(self, log_count):