PLCControler.py
changeset 71 0578bc212c20
parent 70 0e48629c1e6d
child 80 c798a68c5560
equal deleted inserted replaced
70:0e48629c1e6d 71:0578bc212c20
   309             for name in pounames:
   309             for name in pounames:
   310                 self.PouUsingTree[name] = []
   310                 self.PouUsingTree[name] = []
   311             # Analyze each pou 
   311             # Analyze each pou 
   312             for pou in pous:
   312             for pou in pous:
   313                 name = pou.getName()
   313                 name = pou.getName()
       
   314                 if pou.interface:
       
   315                     # Extract variables from every varLists
       
   316                     for type, varlist in pou.getVars():
       
   317                         for var in varlist.getVariable():
       
   318                             var_type = var.getType().getValue()
       
   319                             if not isinstance(var_type, (StringType, UnicodeType)):
       
   320                                 typename = var_type.getName()
       
   321                                 if typename in pounames and name not in self.PouUsingTree[typename]:
       
   322                                     self.PouUsingTree[typename].append(name)
   314                 bodytype = pou.getBodyType()
   323                 bodytype = pou.getBodyType()
   315                 # If pou is written in a graphical language
   324                 # If pou is written in a graphical language
   316                 if bodytype in ["FBD","LD","SFC"]:
   325                 if bodytype in ["FBD","LD","SFC"]:
   317                     # Analyze each instance of the pou
   326                     # Analyze each instance of the pou
   318                     for instance in pou.getInstances():
   327                     for instance in pou.getInstances():
   762         pou = self.Project.getPou(name)
   771         pou = self.Project.getPou(name)
   763         if not pou.interface:
   772         if not pou.interface:
   764             pou.interface = plcopen.pou_interface()
   773             pou.interface = plcopen.pou_interface()
   765         # Set Pou interface
   774         # Set Pou interface
   766         pou.setVars(self.ExtractVarLists(vars))
   775         pou.setVars(self.ExtractVarLists(vars))
       
   776         self.RefreshPouUsingTree()
   767         self.RefreshBlockTypes()
   777         self.RefreshBlockTypes()
   768     
   778     
   769     # Replace the return type of the pou given by its name (only for functions)
   779     # Replace the return type of the pou given by its name (only for functions)
   770     def SetPouInterfaceReturnType(self, name, type):
   780     def SetPouInterfaceReturnType(self, name, type):
   771         pou = self.Project.getPou(name)
   781         pou = self.Project.getPou(name)