PLCControler.py
changeset 229 a5087e346baa
parent 226 6a2f7ddd2e50
child 233 de7ddb376150
equal deleted inserted replaced
228:da7ddaf27cca 229:a5087e346baa
   437             if len(lines) > 1:
   437             if len(lines) > 1:
   438                 next_row = row + len(lines) - 1
   438                 next_row = row + len(lines) - 1
   439                 next_col = len(lines[-1]) + 1
   439                 next_col = len(lines[-1]) + 1
   440             else:
   440             else:
   441                 next_col = col + len(chunk)
   441                 next_col = col + len(chunk)
   442             if next_row >= from_location[0] and next_col >= from_location[1] and len(chunk_infos) > 0:
   442             if (next_row > from_location[0] or next_row == from_location[0] and next_col >= from_location[1]) and len(chunk_infos) > 0:
   443                 infos.append((chunk_infos, (row, col)))
   443                 infos.append((chunk_infos, (row, col)))
   444             if next_row == to_location[0] and next_col > to_location[1] or next_row > to_location[0]:
   444             if next_row == to_location[0] and next_col > to_location[1] or next_row > to_location[0]:
   445                 return infos
   445                 return infos
   446             row, col = next_row, next_col
   446             row, col = next_row, next_col
   447         return infos
   447         return infos
  1263     # Change the edited element text
  1263     # Change the edited element text
  1264     def SetEditedElementText(self, tagname, text):
  1264     def SetEditedElementText(self, tagname, text):
  1265         element = self.GetEditedElement(tagname)
  1265         element = self.GetEditedElement(tagname)
  1266         if element != None:
  1266         if element != None:
  1267             element.settext(text)
  1267             element.settext(text)
  1268             self.RefreshPouUsingTree()
  1268             self.Project.RefreshElementUsingTree()
  1269     
  1269     
  1270     # Return the edited element text
  1270     # Return the edited element text
  1271     def GetEditedElementText(self, tagname):
  1271     def GetEditedElementText(self, tagname):
  1272         element = self.GetEditedElement(tagname)
  1272         element = self.GetEditedElement(tagname)
  1273         if element != None:
  1273         if element != None:
  1669             blocktype_infos = self.GetBlockType(blocktype)
  1669             blocktype_infos = self.GetBlockType(blocktype)
  1670             if blocktype_infos["type"] != "function" and blockname is not None:
  1670             if blocktype_infos["type"] != "function" and blockname is not None:
  1671                 block.setinstanceName(blockname)
  1671                 block.setinstanceName(blockname)
  1672                 self.AddEditedElementPouVar(tagname, blocktype, blockname)
  1672                 self.AddEditedElementPouVar(tagname, blocktype, blockname)
  1673             element.addinstance("block", block)
  1673             element.addinstance("block", block)
  1674             self.RefreshPouUsingTree()
  1674             self.Project.RefreshElementUsingTree()
  1675     
  1675     
  1676     def SetEditedElementBlockInfos(self, tagname, id, infos):
  1676     def SetEditedElementBlockInfos(self, tagname, id, infos):
  1677         element = self.GetEditedElement(tagname)
  1677         element = self.GetEditedElement(tagname)
  1678         if element is not None:
  1678         if element is not None:
  1679             block = element.getinstance(id)
  1679             block = element.getinstance(id)
  1730                             variable.setedge(connector.GetEdge())
  1730                             variable.setedge(connector.GetEdge())
  1731                         position = connector.GetRelPosition()
  1731                         position = connector.GetRelPosition()
  1732                         variable.addconnectionPointOut()
  1732                         variable.addconnectionPointOut()
  1733                         variable.connectionPointOut.setrelPositionXY(position.x, position.y)
  1733                         variable.connectionPointOut.setrelPositionXY(position.x, position.y)
  1734                         block.outputVariables.appendvariable(variable)
  1734                         block.outputVariables.appendvariable(variable)
  1735             self.RefreshPouUsingTree()
  1735             self.Project.RefreshElementUsingTree()
  1736         
  1736         
  1737     def AddEditedElementVariable(self, tagname, id, type):
  1737     def AddEditedElementVariable(self, tagname, id, type):
  1738         element = self.GetEditedElement(tagname)
  1738         element = self.GetEditedElement(tagname)
  1739         if element is not None:            
  1739         if element is not None:            
  1740             if type == INPUT:
  1740             if type == INPUT:
  2231         if element is not None:
  2231         if element is not None:
  2232             instance = element.getinstance(id)
  2232             instance = element.getinstance(id)
  2233             if isinstance(instance, plcopen.fbdObjects_block):
  2233             if isinstance(instance, plcopen.fbdObjects_block):
  2234                 self.RemoveEditedElementPouVar(tagname, instance.gettypeName(), instance.getinstanceName())
  2234                 self.RemoveEditedElementPouVar(tagname, instance.gettypeName(), instance.getinstanceName())
  2235             element.removeinstance(id)
  2235             element.removeinstance(id)
  2236             self.RefreshPouUsingTree()
  2236             self.Project.RefreshElementUsingTree()
  2237 
  2237 
  2238     def GetEditedResourceVariables(self, tagname):
  2238     def GetEditedResourceVariables(self, tagname):
  2239         varlist = []
  2239         varlist = []
  2240         words = tagname.split("::")
  2240         words = tagname.split("::")
  2241         for var in self.GetConfigurationGlobalVars(words[1]):
  2241         for var in self.GetConfigurationGlobalVars(words[1]):