IDE: Allow POU Libraries to inject PLC Configurations globals during build.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Wed, 30 Jun 2021 15:44:32 +0200
changeset 2744 577118ebd179
parent 2743 748b96d71d62
child 3302 c89fc366bebd
IDE: Allow POU Libraries to inject PLC Configurations globals during build.
POULibrary.py
ProjectController.py
--- a/POULibrary.py	Wed Jun 30 16:46:14 2021 +0300
+++ b/POULibrary.py	Wed Jun 30 15:44:32 2021 +0200
@@ -63,6 +63,12 @@
         # Pure python or IEC libs doesn't produce C code
         return ((""), [], False), ""
 
+    def GlobalInstances(self):
+        """
+        @return: [(instance_name, instance_type),...]
+        """
+        return []
+
     def FatalError(self, message):
         """ Raise an exception that will trigger error message intended to 
             the user, but without backtrace since it is not a software error """
--- a/ProjectController.py	Wed Jun 30 16:46:14 2021 +0300
+++ b/ProjectController.py	Wed Jun 30 15:44:32 2021 +0200
@@ -745,7 +745,11 @@
         return locations
 
     def GetConfNodeGlobalInstances(self):
-        return self._GlobalInstances()
+        LibGlobals = []
+        for lib in self.Libraries:
+            LibGlobals += lib.GlobalInstances()
+        CTNGlobals = self._GlobalInstances()
+        return LibGlobals + CTNGlobals
 
     def _Generate_SoftPLC(self):
         if self._Generate_PLC_ST():