Merge
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 04 Oct 2016 17:43:30 +0300
changeset 1535 b3c43aa29d94
parent 1533 aca8f43483e9 (current diff)
parent 1534 d2abe4109467 (diff)
child 1536 3518d10487db
Merge
--- a/plcopen/plcopen.py	Tue Sep 13 21:42:11 2016 +0300
+++ b/plcopen/plcopen.py	Tue Oct 04 17:43:30 2016 +0300
@@ -1559,7 +1559,7 @@
 cls = PLCOpenParser.GetElementClass("body")
 if cls:
     cls.currentExecutionOrderId = 0
-    
+    checkedBlocksDict = {}
     def resetcurrentExecutionOrderId(self):
         object.__setattr__(self, "currentExecutionOrderId", 0)
     setattr(cls, "resetcurrentExecutionOrderId", resetcurrentExecutionOrderId)
@@ -1576,6 +1576,7 @@
                                             PLCOpenParser.GetElementClass("connector", "commonObjects"), 
                                             PLCOpenParser.GetElementClass("continuation", "commonObjects"))):
                     element.setexecutionOrderId(0)
+            checkedBlocksDict.clear()
         else:
             raise TypeError, _("Can only generate execution order on FBD networks!")
     setattr(cls, "resetexecutionOrder", resetexecutionOrder)
@@ -1598,12 +1599,15 @@
         if self.content.getLocalTag() == "FBD":
             localid = link.getrefLocalId()
             instance = self.getcontentInstance(localid)
+            checkedBlocksDict[localid] = True
             if isinstance(instance, PLCOpenParser.GetElementClass("block", "fbdObjects")) and instance.getexecutionOrderId() == 0:
                 for variable in instance.inputVariables.getvariable():
                     connections = variable.connectionPointIn.getconnections()
                     if connections and len(connections) == 1:
-                        self.compileelementExecutionOrder(connections[0])
-                instance.setexecutionOrderId(self.getnewExecutionOrderId())
+                        if (checkedBlocksDict.has_key(connections[0].getrefLocalId()) == False):
+                            self.compileelementExecutionOrder(connections[0])
+                if instance.getexecutionOrderId() == 0:
+                    instance.setexecutionOrderId(self.getnewExecutionOrderId())
             elif isinstance(instance, PLCOpenParser.GetElementClass("continuation", "commonObjects")) and instance.getexecutionOrderId() == 0:
                 name = instance.getname()
                 for tmp_instance in self.getcontentInstances():