WIP adding searching capabilities in python files: search_in_CTN
authorEdouard Tisserant
Fri, 15 Mar 2019 14:11:49 +0100
branchsearch_in_CTN
changeset 2523 aa7f138648f3
parent 2521 48ebcbe7f19b
child 2524 c80b0d864475
WIP adding searching capabilities in python files:
- Added recursive Search capability to config tree nodes
- Added stub search to code editors, for test
CodeFileTreeNode.py
ConfigTreeNode.py
PLCControler.py
--- a/CodeFileTreeNode.py	Mon Mar 11 13:51:07 2019 +0100
+++ b/CodeFileTreeNode.py	Fri Mar 15 14:11:49 2019 +0100
@@ -209,6 +209,11 @@
                     if variable.getonchange()])
         return ret
 
+
+    def CTNSearch(self, criteria):
+        # TODO really search
+        return [((self.CTNFullName()), (0,0),(0,3),"cow")]
+
 # -------------------------------------------------------------------------------
 #                      Current Buffering Management Functions
 # -------------------------------------------------------------------------------
--- a/ConfigTreeNode.py	Mon Mar 11 13:51:07 2019 +0100
+++ b/ConfigTreeNode.py	Fri Mar 15 14:11:49 2019 +0100
@@ -36,6 +36,7 @@
 import traceback
 import types
 import shutil
+from operator import add
 from builtins import str as text
 from past.builtins import execfile
 
@@ -121,6 +122,12 @@
             return parent + "." + self.CTNName()
         return self.BaseParams.getName()
 
+    def CTNSearch(self, criteria):
+        # TODO match config's fields name and fields contents
+        return reduce(add, [
+            CTNChild.CTNSearch(criteria)
+            for CTNChild in self.IterChildren()])
+
     def GetIconName(self):
         return None
 
--- a/PLCControler.py	Mon Mar 11 13:51:07 2019 +0100
+++ b/PLCControler.py	Fri Mar 15 14:11:49 2019 +0100
@@ -2749,7 +2749,10 @@
     # -------------------------------------------------------------------------------
 
     def SearchInProject(self, criteria):
-        return self.Project.Search(criteria)
+        project_matches =  self.Project.Search(criteria)
+        print(project_matches)
+        ctn_matches =  self.CTNSearch(criteria)
+        return project_matches + ctn_matches
 
     def SearchInPou(self, tagname, criteria, debug=False):
         pou = self.GetEditedElement(tagname, debug)