equal
deleted
inserted
replaced
540 """ |
540 """ |
541 Create the confnodes that may be added as child to this node self |
541 Create the confnodes that may be added as child to this node self |
542 @param CTNType: string desining the confnode class name (get name from CTNChildrenTypes) |
542 @param CTNType: string desining the confnode class name (get name from CTNChildrenTypes) |
543 @param CTNName: string for the name of the confnode instance |
543 @param CTNName: string for the name of the confnode instance |
544 """ |
544 """ |
545 # reorgabize self.CTNChildrenTypes tuples from (name, CTNClass, Help) |
545 # reorganize self.CTNChildrenTypes tuples from (name, CTNClass, Help) |
546 # to ( name, (CTNClass, Help)), an make a dict |
546 # to ( name, (CTNClass, Help)), an make a dict |
547 transpose = zip(*self.CTNChildrenTypes) |
547 transpose = zip(*self.CTNChildrenTypes) |
548 CTNChildrenTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2]))) |
548 CTNChildrenTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2]))) |
549 # Check that adding this confnode is allowed |
549 # Check that adding this confnode is allowed |
550 try: |
550 try: |
691 def CallMethod(self, method): |
691 def CallMethod(self, method): |
692 for d in self.ConfNodeMethods: |
692 for d in self.ConfNodeMethods: |
693 if d["method"]==method and d.get("enabled", True) and d.get("shown", True): |
693 if d["method"]==method and d.get("enabled", True) and d.get("shown", True): |
694 getattr(self, method)() |
694 getattr(self, method)() |
695 |
695 |
696 def _GetClassFunction(name): |
|
697 def GetRootClass(): |
|
698 return getattr(__import__("confnodes." + name), name).RootClass |
|
699 return GetRootClass |
|
700 |
|
701 |
696 |
702 #################################################################################### |
697 #################################################################################### |
703 #################################################################################### |
698 #################################################################################### |
704 #################################################################################### |
699 #################################################################################### |
705 ################################### ROOT ###################################### |
700 ################################### ROOT ###################################### |
732 |
727 |
733 MATIEC_ERROR_MODEL = re.compile(".*\.st:(\d+)-(\d+)\.\.(\d+)-(\d+): error : (.*)$") |
728 MATIEC_ERROR_MODEL = re.compile(".*\.st:(\d+)-(\d+)\.\.(\d+)-(\d+): error : (.*)$") |
734 |
729 |
735 DEBUG_RETRIES_WARN = 3 |
730 DEBUG_RETRIES_WARN = 3 |
736 DEBUG_RETRIES_REREGISTER = 4 |
731 DEBUG_RETRIES_REREGISTER = 4 |
|
732 |
|
733 def CTNClassFactory(classpath): |
|
734 if type(classpath)==str: |
|
735 def fac(): |
|
736 mod=__import__(classpath.rsplit('.',1)[0]) |
|
737 return reduce(getattr, classpath.split('.')[1:], mod) |
|
738 return fac |
|
739 else: |
|
740 return lambda:classpath |
737 |
741 |
738 class ConfigTreeRoot(ConfigTreeNode, PLCControler): |
742 class ConfigTreeRoot(ConfigTreeNode, PLCControler): |
739 """ |
743 """ |
740 This class define Root object of the confnode tree. |
744 This class define Root object of the confnode tree. |
741 It is responsible of : |
745 It is responsible of : |
746 - ... |
750 - ... |
747 |
751 |
748 """ |
752 """ |
749 |
753 |
750 # For root object, available Children Types are modules of the confnode packages. |
754 # For root object, available Children Types are modules of the confnode packages. |
751 CTNChildrenTypes = [(name, _GetClassFunction(name), help) for name, help in zip(confnodes.__all__,confnodes.helps)] |
755 CTNChildrenTypes = [(n, CTNClassFactory(c), d) for n,d,h,c in confnodes.catalog] |
752 |
756 |
753 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
757 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
754 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
758 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
755 <xsd:element name="BeremizRoot"> |
759 <xsd:element name="BeremizRoot"> |
756 <xsd:complexType> |
760 <xsd:complexType> |