Adding support for syntax highlighting for EN and ENO parameters in formal function and function blocs in textual editor
authorlaurent
Mon, 04 Jul 2011 15:24:44 +0200
changeset 549 b0d6819119c3
parent 548 0b6ab74f4b89
child 550 cfa295862d55
Adding support for syntax highlighting for EN and ENO parameters in formal function and function blocs in textual editor
PLCControler.py
TextViewer.py
--- a/PLCControler.py	Wed Jun 29 12:29:14 2011 +0200
+++ b/PLCControler.py	Mon Jul 04 15:24:44 2011 +0200
@@ -1073,8 +1073,16 @@
             blocktype = self.GetBlockType(typename, debug = debug)
             if blocktype is not None:
                 tree = []
+                en = False
+                eno = False
                 for var_name, var_type, var_modifier in blocktype["inputs"] + blocktype["outputs"]:
+                    en |= var_name.upper() == "EN"
+                    eno |= var_name.upper() == "ENO"    
                     tree.append((var_name, var_type, self.GenerateVarTree(var_type, debug)))
+                if not eno:
+                    tree.insert(0, ("ENO", "BOOL", ([], [])))
+                if not en:
+                    tree.insert(0, ("EN", "BOOL", ([], [])))
                 return tree, []
             datatype = project.getdataType(typename)
             if datatype is not None:
--- a/TextViewer.py	Wed Jun 29 12:29:14 2011 +0200
+++ b/TextViewer.py	Mon Jul 04 15:24:44 2011 +0200
@@ -344,6 +344,9 @@
                 blockname = blocktype["name"].upper()
                 if blocktype["type"] == "function" and blockname not in self.Keywords and blockname not in self.Variables.keys():
                     interface = dict([(name, {}) for name, type, modifier in blocktype["inputs"] + blocktype["outputs"] if name != ''])
+                    for param in ["EN", "ENO"]:
+                        if not interface.has_key(param):
+                            interface[param] = {}
                     if self.Functions.has_key(blockname):
                         self.Functions[blockname]["interface"].update(interface)
                         self.Functions[blockname]["extensible"] |= blocktype["extensible"]