SVGHMI: detect watchdog abuse (more than one HMI instance with watchdog) at build time svghmi
authorEdouard Tisserant
Thu, 22 Jul 2021 12:03:34 +0200
branchsvghmi
changeset 3287 70a76083c59c
parent 3286 5a135e635bfa
child 3288 8f3cb4b47cbb
SVGHMI: detect watchdog abuse (more than one HMI instance with watchdog) at build time
svghmi/svghmi.py
--- a/svghmi/svghmi.py	Thu Jul 22 12:02:50 2021 +0200
+++ b/svghmi/svghmi.py	Thu Jul 22 12:03:34 2021 +0200
@@ -56,6 +56,19 @@
     def Generate_C(self, buildpath, varlist, IECCFLAGS):
         global hmi_tree_root, on_hmitree_update, maxConnectionsTotal
 
+        already_found_watchdog = False
+        for CTNChild in self.GetCTR().IterChildren():
+            if isinstance(CTNChild, SVGHMI):
+                # collect maximum connection total for all svghmi nodes
+                maxConnectionsTotal += CTNChild.GetParamsAttributes("SVGHMI.MaxConnections")["value"]
+
+                # spot watchdog abuse
+                if CTNChild.GetParamsAttributes("SVGHMI.EnableWatchdog")["value"]:
+                    if already_found_watchdog:
+                        self.FatalError("SVGHMI: Only one watchdog enabled HMI allowed")
+                    already_found_watchdog = True
+
+
         """
         PLC Instance Tree:
           prog0
@@ -198,11 +211,6 @@
         # "programs_declarations": "\n".join(["extern %(type)s %(C_path)s;" %
         #                                     p for p in self._ProgramList]),
 
-        for CTNChild in self.GetCTR().IterChildren():
-            if isinstance(CTNChild, SVGHMI):
-                maxConnectionsTotal += CTNChild.GetParamsAttributes("SVGHMI.MaxConnections")["value"]
-
-
         # C code to observe/access HMI tree variables
         svghmi_c_filepath = paths.AbsNeighbourFile(__file__, "svghmi.c")
         svghmi_c_file = open(svghmi_c_filepath, 'r')