Snej69420 9 месяцев назад
Родитель
Сommit
3df7874eb6
1 измененных файлов с 63 добавлено и 63 удалено
  1. 63 63
      pythonpdevs2.4.2/src/pypdevs/DEVS.py

+ 63 - 63
pythonpdevs2.4.2/src/pypdevs/DEVS.py

@@ -952,90 +952,90 @@ def directConnect(component_set, listeners):
                         outport.routing_outline.append((outline, z))
     return component_set
 
-def directConnectPort(outport, listeners):
-    """
-    Perform direct connection on a single port.
-
-    :param outport: the port to reconnect
-    :param listeners: the listeners that exist, potentially on this port
-    :returns: None
-    """
-
-    # The new contents of the line
-    outport.routing_outline = []
-    # Tracks ONLY the ports already added to routing_outline.
-    # This makes duplicate detection O(1) while maintaining identical behavior.
-    routing_outline = set()
-
-    worklist = [(p, outport.z_functions.get(p, None))
-                for p in outport.outline]
-
-    for outline, z in worklist:
-        if outline in listeners:
-            # This port is being listened on, so just add it as a fake model
-            fake_port = Port(is_input=False, name="Fake")
-            fake_port.host_DEVS = ExternalWrapper(listeners[outline])
-            outport.routing_outline.append((fake_port, z))
-
-        # Add it to the current iterating list, so we can just continue
-        if isinstance(outline.host_DEVS, CoupledDEVS):
-            for inline in outline.outline:
-                new_z = appendZ(z, outline.z_functions.get(inline, None))
-                worklist.append((inline, new_z))
-
-                # If it is a Coupled model, we should just continue
-                # expanding it and not add it to the finished line
-                if not isinstance(inline.host_DEVS, CoupledDEVS):
-                    if inline not in routing_outline:
-                        outport.routing_outline.append((inline, new_z))
-                        routing_outline.add(inline)
-        else:
-            # Atomic model reached, add if not already in routing_outline
-            if outline not in routing_outline:
-                outport.routing_outline.append((outline, z))
-                routing_outline.add(outline)
-
-# ORIGINAL
-
 # def directConnectPort(outport, listeners):
 #     """
 #     Perform direct connection on a single port.
 #
-#     :param outpurt: the port to reconnect
+#     :param outport: the port to reconnect
 #     :param listeners: the listeners that exist, potentially on this port
 #     :returns: None
 #     """
 #
 #     # The new contents of the line
 #     outport.routing_outline = []
+#     # Tracks ONLY the ports already added to routing_outline.
+#     # This makes duplicate detection O(1) while maintaining identical behavior.
+#     routing_outline = set()
+#
 #     worklist = [(p, outport.z_functions.get(p, None))
 #                 for p in outport.outline]
-#     listener_keys = set(listeners.keys())
+#
 #     for outline, z in worklist:
-#         if outline in listener_keys:
+#         if outline in listeners:
 #             # This port is being listened on, so just add it as a fake model
-#             fake_port = Port(is_input=False,name="Fake")
+#             fake_port = Port(is_input=False, name="Fake")
 #             fake_port.host_DEVS = ExternalWrapper(listeners[outline])
 #             outport.routing_outline.append((fake_port, z))
 #
-#         # If it is a coupled model, we must expand this model
+#         # Add it to the current iterating list, so we can just continue
 #         if isinstance(outline.host_DEVS, CoupledDEVS):
 #             for inline in outline.outline:
-#                 # Add it to the current iterating list, so we can just continue
-#                 entry = (inline, appendZ(z, outline.z_functions.get(inline, None)))
-#                 worklist.append(entry)
+#                 new_z = appendZ(z, outline.z_functions.get(inline, None))
+#                 worklist.append((inline, new_z))
+#
 #                 # If it is a Coupled model, we should just continue
 #                 # expanding it and not add it to the finished line
 #                 if not isinstance(inline.host_DEVS, CoupledDEVS):
-#                     entry = (inline, appendZ(z, outline.z_functions.get(inline, None)))
-#                     outport.routing_outline.append(entry)
+#                     if inline not in routing_outline:
+#                         outport.routing_outline.append((inline, new_z))
+#                         routing_outline.add(inline)
 #         else:
-#             for ol, z in outport.routing_outline:
-#                 if ol == outline:
-#                     break
-#             else:
-#                 # Add to the new line if it isn't already there
-#                 # Note that it isn't really mandatory to check for this,
-#                 # it is a lot cleaner to do so.
-#                 # This will greatly increase the complexity of the connector though
+#             # Atomic model reached, add if not already in routing_outline
+#             if outline not in routing_outline:
 #                 outport.routing_outline.append((outline, z))
+#                 routing_outline.add(outline)
+
+# ORIGINAL
+
+def directConnectPort(outport, listeners):
+    """
+    Perform direct connection on a single port.
+
+    :param outpurt: the port to reconnect
+    :param listeners: the listeners that exist, potentially on this port
+    :returns: None
+    """
+
+    # The new contents of the line
+    outport.routing_outline = []
+    worklist = [(p, outport.z_functions.get(p, None))
+                for p in outport.outline]
+    listener_keys = set(listeners.keys())
+    for outline, z in worklist:
+        if outline in listener_keys:
+            # This port is being listened on, so just add it as a fake model
+            fake_port = Port(is_input=False,name="Fake")
+            fake_port.host_DEVS = ExternalWrapper(listeners[outline])
+            outport.routing_outline.append((fake_port, z))
+
+        # If it is a coupled model, we must expand this model
+        if isinstance(outline.host_DEVS, CoupledDEVS):
+            for inline in outline.outline:
+                # Add it to the current iterating list, so we can just continue
+                entry = (inline, appendZ(z, outline.z_functions.get(inline, None)))
+                worklist.append(entry)
+                # If it is a Coupled model, we should just continue
+                # expanding it and not add it to the finished line
+                if not isinstance(inline.host_DEVS, CoupledDEVS):
+                    entry = (inline, appendZ(z, outline.z_functions.get(inline, None)))
+                    outport.routing_outline.append(entry)
+        else:
+            for ol, z in outport.routing_outline:
+                if ol == outline:
+                    break
+            else:
+                # Add to the new line if it isn't already there
+                # Note that it isn't really mandatory to check for this,
+                # it is a lot cleaner to do so.
+                # This will greatly increase the complexity of the connector though
+                outport.routing_outline.append((outline, z))