svghmi/svghmi.py
branchsvghmi
changeset 3287 70a76083c59c
parent 3286 5a135e635bfa
child 3289 3c893aed9198
equal deleted inserted replaced
3286:5a135e635bfa 3287:70a76083c59c
    53     def GetLibraryPath(self):
    53     def GetLibraryPath(self):
    54          return paths.AbsNeighbourFile(__file__, "pous.xml")
    54          return paths.AbsNeighbourFile(__file__, "pous.xml")
    55 
    55 
    56     def Generate_C(self, buildpath, varlist, IECCFLAGS):
    56     def Generate_C(self, buildpath, varlist, IECCFLAGS):
    57         global hmi_tree_root, on_hmitree_update, maxConnectionsTotal
    57         global hmi_tree_root, on_hmitree_update, maxConnectionsTotal
       
    58 
       
    59         already_found_watchdog = False
       
    60         for CTNChild in self.GetCTR().IterChildren():
       
    61             if isinstance(CTNChild, SVGHMI):
       
    62                 # collect maximum connection total for all svghmi nodes
       
    63                 maxConnectionsTotal += CTNChild.GetParamsAttributes("SVGHMI.MaxConnections")["value"]
       
    64 
       
    65                 # spot watchdog abuse
       
    66                 if CTNChild.GetParamsAttributes("SVGHMI.EnableWatchdog")["value"]:
       
    67                     if already_found_watchdog:
       
    68                         self.FatalError("SVGHMI: Only one watchdog enabled HMI allowed")
       
    69                     already_found_watchdog = True
       
    70 
    58 
    71 
    59         """
    72         """
    60         PLC Instance Tree:
    73         PLC Instance Tree:
    61           prog0
    74           prog0
    62            +->v1 HMI_INT
    75            +->v1 HMI_INT
   195                     "extern %(type)s %(C_path)s;" % v]
   208                     "extern %(type)s %(C_path)s;" % v]
   196 
   209 
   197         # TODO check if programs need to be declared separately
   210         # TODO check if programs need to be declared separately
   198         # "programs_declarations": "\n".join(["extern %(type)s %(C_path)s;" %
   211         # "programs_declarations": "\n".join(["extern %(type)s %(C_path)s;" %
   199         #                                     p for p in self._ProgramList]),
   212         #                                     p for p in self._ProgramList]),
   200 
       
   201         for CTNChild in self.GetCTR().IterChildren():
       
   202             if isinstance(CTNChild, SVGHMI):
       
   203                 maxConnectionsTotal += CTNChild.GetParamsAttributes("SVGHMI.MaxConnections")["value"]
       
   204 
       
   205 
   213 
   206         # C code to observe/access HMI tree variables
   214         # C code to observe/access HMI tree variables
   207         svghmi_c_filepath = paths.AbsNeighbourFile(__file__, "svghmi.c")
   215         svghmi_c_filepath = paths.AbsNeighbourFile(__file__, "svghmi.c")
   208         svghmi_c_file = open(svghmi_c_filepath, 'r')
   216         svghmi_c_file = open(svghmi_c_filepath, 'r')
   209         svghmi_c_code = svghmi_c_file.read()
   217         svghmi_c_code = svghmi_c_file.read()