plcopen/plcopen.py
changeset 891 39f355a535d8
parent 854 c10f2092c43a
child 966 dc1318160073
equal deleted inserted replaced
890:b3cafb73c5e9 891:39f355a535d8
  2328             node.childNodes.append(relPosition)
  2328             node.childNodes.append(relPosition)
  2329             node.childNodes.extend(connections)
  2329             node.childNodes.extend(connections)
  2330             tree.childNodes = [node]
  2330             tree.childNodes = [node]
  2331     setattr(cls, "compatibility", compatibility)
  2331     setattr(cls, "compatibility", compatibility)
  2332 
  2332 
  2333 cls = _initElementClass("transition", "sfcObjects_transition", "single")
  2333 cls = _initElementClass("transition", "sfcObjects_transition")
  2334 if cls:
  2334 if cls:
  2335     def getinfos(self):
  2335     def getinfos(self):
  2336         infos = _getelementinfos(self)
  2336         infos = _getelementinfos(self)
  2337         infos["type"] = "transition"
  2337         infos["type"] = "transition"
  2338         specific_values = infos["specific_values"]
  2338         specific_values = infos["specific_values"]
  2380                 values["value"] = content["value"]
  2380                 values["value"] = content["value"]
  2381             return values
  2381             return values
  2382         return ""
  2382         return ""
  2383     setattr(cls, "getconditionContent", getconditionContent)
  2383     setattr(cls, "getconditionContent", getconditionContent)
  2384 
  2384 
       
  2385     def getconditionConnection(self):
       
  2386         if self.condition:
       
  2387             content = self.condition.getcontent()
       
  2388             if content["name"] == "connectionPointIn":
       
  2389                 return content["value"]
       
  2390         return None
       
  2391     setattr(cls, "getconditionConnection", getconditionConnection)
       
  2392 
       
  2393     def getBoundingBox(self):
       
  2394         bbox = _getBoundingBoxSingle(self)
       
  2395         condition_connection = self.getconditionConnection()
       
  2396         if condition_connection:
       
  2397             bbox.union(_getConnectionsBoundingBox(condition_connection))
       
  2398         return bbox
       
  2399     setattr(cls, "getBoundingBox", getBoundingBox)
       
  2400     
       
  2401     def translate(self, dx, dy):
       
  2402         _translateSingle(self, dx, dy)
       
  2403         condition_connection = self.getconditionConnection()
       
  2404         if condition_connection:
       
  2405             _translateConnections(condition_connection, dx, dy)
       
  2406     setattr(cls, "translate", translate)
       
  2407     
       
  2408     def filterConnections(self, connections):
       
  2409         _filterConnectionsSingle(self, connections)
       
  2410         condition_connection = self.getconditionConnection()
       
  2411         if condition_connection:
       
  2412             _filterConnections(condition_connection, self.localId, connections)
       
  2413     setattr(cls, "filterConnections", filterConnections)
       
  2414     
       
  2415     def updateConnectionsId(self, translation):
       
  2416         connections_end = []
       
  2417         if self.connectionPointIn is not None:
       
  2418             connections_end = _updateConnectionsId(self.connectionPointIn, translation)
       
  2419         condition_connection = self.getconditionConnection()
       
  2420         if condition_connection:
       
  2421             connections_end.extend(_updateConnectionsId(condition_connection, translation))
       
  2422         return _getconnectionsdefinition(self, connections_end)
       
  2423     setattr(cls, "updateConnectionsId", updateConnectionsId)
       
  2424 
  2385     def updateElementName(self, old_name, new_name):
  2425     def updateElementName(self, old_name, new_name):
  2386         if self.condition:
  2426         if self.condition:
  2387             content = self.condition.getcontent()
  2427             content = self.condition.getcontent()
  2388             if content["name"] == "reference":
  2428             if content["name"] == "reference":
  2389                 if content["value"].getname() == old_name:
  2429                 if content["value"].getname() == old_name:
  2400             elif content["name"] == "inline":
  2440             elif content["name"] == "inline":
  2401                 content["value"].updateElementAddress(address_model, new_leading)
  2441                 content["value"].updateElementAddress(address_model, new_leading)
  2402     setattr(cls, "updateElementAddress", updateElementAddress)
  2442     setattr(cls, "updateElementAddress", updateElementAddress)
  2403 
  2443 
  2404     def getconnections(self):
  2444     def getconnections(self):
  2405         if self.condition:
  2445         condition_connection = self.getconditionConnection()
  2406             content = self.condition.getcontent()
  2446         if condition_connection:
  2407             if content["name"] == "connectionPointIn":
  2447             return condition_connection.getconnections()
  2408                 return content["value"].getconnections()
  2448         return None
  2409     setattr(cls, "getconnections", getconnections)
  2449     setattr(cls, "getconnections", getconnections)
  2410     
  2450     
  2411     def Search(self, criteria, parent_infos=[]):
  2451     def Search(self, criteria, parent_infos=[]):
  2412         parent_infos = parent_infos + ["transition", self.getlocalId()]
  2452         parent_infos = parent_infos + ["transition", self.getlocalId()]
  2413         search_result = []
  2453         search_result = []