/** * Return a list of source ports connected to this port on the same layer that can send data to * this port. This includes output ports that are connected on the outside to this port, and input * ports that are connected on the inside to this port. * * @param input TypedIOPort * @return A list of IOPort objects. */ private LinkedList _shallowSourcePortList(TypedIOPort input) { try { _workspace.getReadAccess(); Actor container = (Actor) input.getContainer(); Director excDirector = ((Actor) container).getExecutiveDirector(); int depthOfContainer = ((NamedObj) container).depthInHierarchy(); LinkedList result = new LinkedList(); Iterator ports = input.connectedPortList().iterator(); while (ports.hasNext()) { IOPort port = (IOPort) ports.next(); int depth = port.depthInHierarchy(); if (port.isInput() && (depth <= depthOfContainer)) { result.addLast(port); } else if (port.isOutput() && (depth == (depthOfContainer + 1))) { result.addLast(port); } } return result; } finally { _workspace.doneReading(); } }
/** * Return the list of sending (up-stream) ports that are connected to the specified port. This * treats every port as an opaque port. * * @param port The specified port. * @return The list of sending ports. */ protected static List<IOPort> _getSourcePortList(IOPort port) { List<IOPort> result = new ArrayList<IOPort>(); for (IOPort connectedPort : (List<IOPort>) port.connectedPortList()) { boolean isInput = connectedPort.isInput(); boolean isCompositeInput = connectedPort.getContainer() instanceof CompositeEntity && isInput && port.depthInHierarchy() > connectedPort.depthInHierarchy(); if (!isInput || isCompositeInput) { result.add(connectedPort); } } return result; }