svghmi/svghmi.py
branchsvghmi
changeset 2890 ae8063127e95
parent 2866 59a855c17aa6
child 2945 69f395c01c09
equal deleted inserted replaced
2889:4eeed820fd3a 2890:ae8063127e95
    53         if iectype is not None:
    53         if iectype is not None:
    54             self.iectype = iectype
    54             self.iectype = iectype
    55             self.vartype = vartype
    55             self.vartype = vartype
    56             self.cpath = cpath
    56             self.cpath = cpath
    57 
    57 
    58         if nodetype in ["HMI_NODE", "HMI_ROOT"]:
    58         if nodetype in ["HMI_NODE"]:
    59             self.children = []
    59             self.children = []
    60 
    60 
    61     def pprint(self, indent = 0):
    61     def pprint(self, indent = 0):
    62         res = ">"*indent + pformat(self.__dict__, indent = indent, depth = 1) + "\n"
    62         res = ">"*indent + pformat(self.__dict__, indent = indent, depth = 1) + "\n"
    63         if hasattr(self, "children"):
    63         if hasattr(self, "children"):
   134 
   134 
   135 hmi_tree_root = None
   135 hmi_tree_root = None
   136 
   136 
   137 on_hmitree_update = None
   137 on_hmitree_update = None
   138 
   138 
   139 SPECIAL_NODES = [("heartbeat", "HMI_INT")]
   139 SPECIAL_NODES = [("HMI_ROOT", "HMI_NODE"),
       
   140                  ("heartbeat", "HMI_INT")]
   140                  # ("current_page", "HMI_STRING")])
   141                  # ("current_page", "HMI_STRING")])
   141 
   142 
   142 class SVGHMILibrary(POULibrary):
   143 class SVGHMILibrary(POULibrary):
   143     def GetLibraryPath(self):
   144     def GetLibraryPath(self):
   144          return paths.AbsNeighbourFile(__file__, "pous.xml")
   145          return paths.AbsNeighbourFile(__file__, "pous.xml")
   181         """
   182         """
   182 
   183 
   183         # Filter known HMI types
   184         # Filter known HMI types
   184         hmi_types_instances = [v for v in varlist if v["derived"] in HMI_TYPES]
   185         hmi_types_instances = [v for v in varlist if v["derived"] in HMI_TYPES]
   185 
   186 
   186         hmi_tree_root = HMITreeNode(None, "/", "HMI_ROOT")
   187         hmi_tree_root = None
       
   188 
       
   189         # take first HMI_NODE (placed as special node), make it root
       
   190         for i,v in enumerate(hmi_types_instances):
       
   191             path = v["IEC_path"].split(".")
       
   192             derived = v["derived"]
       
   193             if derived == "HMI_NODE" and ['CONFIG', 'HEARTBEAT'] :
       
   194                 hmi_tree_root = HMITreeNode(path, "", derived, v["type"], v["vartype"], v["C_path"])
       
   195                 hmi_types_instances.pop(i)
       
   196                 break
       
   197 
       
   198         assert(hmi_tree_root is not None)
   187 
   199 
   188         # deduce HMI tree from PLC HMI_* instances
   200         # deduce HMI tree from PLC HMI_* instances
   189         for v in hmi_types_instances:
   201         for v in hmi_types_instances:
   190             path = v["IEC_path"].split(".")
   202             path = v["IEC_path"].split(".")
   191             # ignores variables starting with _TMP_
   203             # ignores variables starting with _TMP_
   442         global hmi_tree_root
   454         global hmi_tree_root
   443         res = [hmi_tree_root.etree(add_hash=True)]
   455         res = [hmi_tree_root.etree(add_hash=True)]
   444         return res
   456         return res
   445 
   457 
   446     def CTNGenerate_C(self, buildpath, locations):
   458     def CTNGenerate_C(self, buildpath, locations):
   447         """
       
   448         Return C code generated by iec2c compiler
       
   449         when _generate_softPLC have been called
       
   450         @param locations: ignored
       
   451         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
       
   452         """
       
   453 
   459 
   454         location_str = "_".join(map(str, self.GetCurrentLocation()))
   460         location_str = "_".join(map(str, self.GetCurrentLocation()))
   455         view_name = self.BaseParams.getName()
   461         view_name = self.BaseParams.getName()
   456 
   462 
   457         svgfile = self._getSVGpath()
   463         svgfile = self._getSVGpath()