plcopen/plcopen.py
changeset 94 e7f5a251f251
parent 89 a6ff2b3fcc25
child 108 9aa1fdfb7cb2
equal deleted inserted replaced
93:c3c24b979a4d 94:e7f5a251f251
   419         derived_type.setName(type)
   419         derived_type.setName(type)
   420         var_type.setValue(derived_type)
   420         var_type.setValue(derived_type)
   421         var.setType(var_type)
   421         var.setType(var_type)
   422         content[-1]["value"].appendVariable(var)
   422         content[-1]["value"].appendVariable(var)
   423     setattr(cls, "addPouVar", addPouVar)
   423     setattr(cls, "addPouVar", addPouVar)
       
   424     
       
   425     def changePouVar(self, old_type, old_name, new_type, new_name):
       
   426         content = self.interface.getContent()
       
   427         for varlist in content:
       
   428             variables = varlist["value"].getVariable()
       
   429             for var in variables:
       
   430                 if var.getName() == old_name:
       
   431                     var_type = var.getType().getValue()
       
   432                     if isinstance(var_type, PLCOpenClasses["derived"]) and var_type.getName() == old_type:
       
   433                         var.setName(new_name)
       
   434                         var.getType().getValue().setName(new_type)
       
   435                         return
       
   436     setattr(cls, "changePouVar", changePouVar)
   424     
   437     
   425     def removePouVar(self, type, name):
   438     def removePouVar(self, type, name):
   426         content = self.interface.getContent()
   439         content = self.interface.getContent()
   427         for varlist in content:
   440         for varlist in content:
   428             variables = varlist["value"].getVariable()
   441             variables = varlist["value"].getVariable()