WIP adding searching capabilities in python files. was done : search_in_CTN
authorEdouard Tisserant
Thu, 21 Mar 2019 14:00:26 +0100
branchsearch_in_CTN
changeset 2527 f47e397e9b61
parent 2526 450c6239ee75
child 2528 6bfc8a9bf0e7
WIP adding searching capabilities in python files. was done :
- added search in global variables used by Code File Tree Nodes
CodeFileTreeNode.py
--- a/CodeFileTreeNode.py	Thu Mar 21 13:10:49 2019 +0100
+++ b/CodeFileTreeNode.py	Thu Mar 21 14:00:26 2019 +0100
@@ -36,6 +36,8 @@
 from PLCControler import UndoBuffer
 from ConfigTreeNode import XSDSchemaErrorMessage
 
+from plcopen.plcopen import TestTextElement
+
 CODEFILE_XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:xhtml="http://www.w3.org/1999/xhtml">
@@ -212,7 +214,15 @@
 
     def CTNSearch(self, criteria):
         # TODO really search
-        return [((self.CTNFullName(),"var_inout",1,"name"), (0,2),(0,4),"a_cow"),
+        variables = self.GetVariables()
+        results = []
+        tagname = self.CTNFullName()
+        for index, var in enumerate(variables):
+            varname = var["Name"]
+            results.extend([((tagname, "var_inout", index, "name"),) + result
+                            for result in TestTextElement(varname, criteria)])
+        print("FFFFFFFFFF", results)
+        return results + [((self.CTNFullName(),"var_inout",1,"name"), (0,2),(0,4),"a_cow"),
                 ((self.CTNFullName(),"body"), (1,12),(1,15),"Bitch I'm a cow !")]
 
 # -------------------------------------------------------------------------------