1560 setattr(cls, "Search", Search) |
1560 setattr(cls, "Search", Search) |
1561 |
1561 |
1562 cls = PLCOpenParser.GetElementClass("body") |
1562 cls = PLCOpenParser.GetElementClass("body") |
1563 if cls: |
1563 if cls: |
1564 cls.currentExecutionOrderId = 0 |
1564 cls.currentExecutionOrderId = 0 |
1565 checkedBlocksDict = {} |
1565 cls.checkedBlocksDict = {} |
1566 def resetcurrentExecutionOrderId(self): |
1566 def resetcurrentExecutionOrderId(self): |
1567 object.__setattr__(self, "currentExecutionOrderId", 0) |
1567 object.__setattr__(self, "currentExecutionOrderId", 0) |
1568 setattr(cls, "resetcurrentExecutionOrderId", resetcurrentExecutionOrderId) |
1568 setattr(cls, "resetcurrentExecutionOrderId", resetcurrentExecutionOrderId) |
1569 |
1569 |
1570 def getnewExecutionOrderId(self): |
1570 def getnewExecutionOrderId(self): |
1577 for element in self.content.getcontent(): |
1577 for element in self.content.getcontent(): |
1578 if not isinstance(element, (PLCOpenParser.GetElementClass("comment", "commonObjects"), |
1578 if not isinstance(element, (PLCOpenParser.GetElementClass("comment", "commonObjects"), |
1579 PLCOpenParser.GetElementClass("connector", "commonObjects"), |
1579 PLCOpenParser.GetElementClass("connector", "commonObjects"), |
1580 PLCOpenParser.GetElementClass("continuation", "commonObjects"))): |
1580 PLCOpenParser.GetElementClass("continuation", "commonObjects"))): |
1581 element.setexecutionOrderId(0) |
1581 element.setexecutionOrderId(0) |
1582 checkedBlocksDict.clear() |
1582 self.checkedBlocksDict.clear() |
1583 else: |
1583 else: |
1584 raise TypeError, _("Can only generate execution order on FBD networks!") |
1584 raise TypeError, _("Can only generate execution order on FBD networks!") |
1585 setattr(cls, "resetexecutionOrder", resetexecutionOrder) |
1585 setattr(cls, "resetexecutionOrder", resetexecutionOrder) |
1586 |
1586 |
1587 def compileexecutionOrder(self): |
1587 def compileexecutionOrder(self): |
1600 |
1600 |
1601 def compileelementExecutionOrder(self, link): |
1601 def compileelementExecutionOrder(self, link): |
1602 if self.content.getLocalTag() == "FBD": |
1602 if self.content.getLocalTag() == "FBD": |
1603 localid = link.getrefLocalId() |
1603 localid = link.getrefLocalId() |
1604 instance = self.getcontentInstance(localid) |
1604 instance = self.getcontentInstance(localid) |
1605 checkedBlocksDict[localid] = True |
1605 self.checkedBlocksDict[localid] = True |
1606 if isinstance(instance, PLCOpenParser.GetElementClass("block", "fbdObjects")) and instance.getexecutionOrderId() == 0: |
1606 if isinstance(instance, PLCOpenParser.GetElementClass("block", "fbdObjects")) and instance.getexecutionOrderId() == 0: |
1607 for variable in instance.inputVariables.getvariable(): |
1607 for variable in instance.inputVariables.getvariable(): |
1608 connections = variable.connectionPointIn.getconnections() |
1608 connections = variable.connectionPointIn.getconnections() |
1609 if connections and len(connections) == 1: |
1609 if connections and len(connections) == 1: |
1610 if (checkedBlocksDict.has_key(connections[0].getrefLocalId()) == False): |
1610 if (self.checkedBlocksDict.has_key(connections[0].getrefLocalId()) == False): |
1611 self.compileelementExecutionOrder(connections[0]) |
1611 self.compileelementExecutionOrder(connections[0]) |
1612 if instance.getexecutionOrderId() == 0: |
1612 if instance.getexecutionOrderId() == 0: |
1613 instance.setexecutionOrderId(self.getnewExecutionOrderId()) |
1613 instance.setexecutionOrderId(self.getnewExecutionOrderId()) |
1614 elif isinstance(instance, PLCOpenParser.GetElementClass("continuation", "commonObjects")) and instance.getexecutionOrderId() == 0: |
1614 elif isinstance(instance, PLCOpenParser.GetElementClass("continuation", "commonObjects")) and instance.getexecutionOrderId() == 0: |
1615 for tmp_instance in self.getcontentInstances(): |
1615 for tmp_instance in self.getcontentInstances(): |