|
|
@@ -963,7 +963,6 @@ def directConnectPort(outport, listeners):
|
|
|
|
|
|
# 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()
|
|
|
@@ -971,11 +970,8 @@ def directConnectPort(outport, listeners):
|
|
|
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.host_DEVS = ExternalWrapper(listeners[outline])
|
|
|
@@ -998,3 +994,48 @@ def directConnectPort(outport, listeners):
|
|
|
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))
|