Package ptolemy.actor

Examples of ptolemy.actor.IOPort


        if (refinements != null) {
            for (int i = 0; i < refinements.length; i++) {
                Iterator inputPorts = refinements[i].inputPortList().iterator();

                while (inputPorts.hasNext()) {
                    IOPort inputPort = (IOPort) inputPorts.next();

                    if ((inputPort.getWidth() != 0)
                            && (DFUtilities.getRate(inputPort) > 0)) {
                        Iterator inputPortsOutside = inputPort
                                .deepConnectedInPortList().iterator();

                        while (inputPortsOutside.hasNext()) {
                            IOPort inputPortOutside = (IOPort) inputPortsOutside
                                    .next();

                            if ((inputPortOutside.getContainer() == container)
                                    && !_refinementReferredInputPorts
                                            .contains(inputPortOutside)) {
                                _refinementReferredInputPorts
                                        .add(inputPortOutside);
                            }
View Full Code Here


        // GRDirector, so producing those outputs in postfire()
        // is OK.
        Iterator outports = ((Actor)getContainer())
                .outputPortList().iterator();
        while (outports.hasNext() && !_stopRequested) {
            IOPort p = (IOPort) outports.next();
            transferOutputs(p);
        }

        // Note: actors return false on postfire(), if they wish never
        // to be fired again during the execution. This can be
View Full Code Here

                // Check all the input ports of the actor to see whether there
                // are more input tokens to be processed.
                Iterator inputPorts = actorToFire.inputPortList().iterator();

                while (inputPorts.hasNext() && !refire) {
                    IOPort port = (IOPort) inputPorts.next();

                    // iterate all the channels of the current input port.
                    for (int i = 0; i < port.getWidth(); i++) {
                        if (port.hasToken(i)) {
                            refire = true;

                            // Found a channel that has input data,
                            // jump out of the for loop.
                            break;
View Full Code Here

            CompositeActor container = (CompositeActor) getContainer();
            Iterator inputPorts = container.inputPortList().iterator();
            boolean hasInput = false;

            while (inputPorts.hasNext() && !hasInput) {
                IOPort port = (IOPort) inputPorts.next();

                for (int i = 0; i < port.getWidth(); i++) {
                    if (port.hasToken(i)) {
                        hasInput = true;
                        break;
                    }
                }
            }
View Full Code Here

            int depth = -1;
            Iterator inputs = actor.inputPortList().iterator();

            while (inputs.hasNext()) {
                IOPort inputPort = (IOPort) inputs.next();
                int inputDepth = _getDepthOfIOPort(inputPort);

                if ((inputDepth < depth) || (depth == -1)) {
                    depth = inputDepth;
                }
            }

            Iterator outputs = actor.outputPortList().iterator();

            while (outputs.hasNext()) {
                IOPort outputPort = (IOPort) outputs.next();
                int outputDepth = _getDepthOfIOPort(outputPort);

                if ((outputDepth < depth) || (depth == -1)) {
                    depth = outputDepth;
                }
            }

            // Note that if an actor has no ports, the defaultActorDepth,
            // which is a negative number, will be used such that each
            // actor has a unique depth.
            if (depth == -1) {
                depth = defaultActorDepth;
            }
            _actorToDepth.put(actor, Integer.valueOf(depth));
            // Increment the default depth value for the next actor.
            defaultActorDepth++;
        }

        // If the event queue is not empty, we should update the depths of
        // the existing events with new depths.
        // NOTE: After update, we must use the same _eventQueue to keep the
        // existing references to it. For example, the debug listeners.
        if (!_eventQueue.isEmpty()) {
            // Setup a temporary repository for the existing events
            // in the queue.
            LinkedList updatedEventList = new LinkedList();

            while (!_eventQueue.isEmpty()) {
                DEEvent event = _eventQueue.take();
                IOPort ioPort = event.ioPort();
                Actor actor = event.actor();

                // Treat pure events and trigger events differently.
                // Must check ioPort first and then actor, because
                // if ioPort is not null, its actor can not be null.
View Full Code Here

        LinkedList ports = new LinkedList();

        // Assign depths to ports based on the topological sorting result.
        for (int i = 0; i <= (numberOfPorts - 1); i++) {
            IOPort ioPort = (IOPort) sort[i];
            ports.add(ioPort);
            int depth = i;
            Actor portContainer = (Actor) ioPort.getContainer();
            // The ports of the composite actor that contains
            // this director are set to the highest depth
            // (the lowest priority).
            if (ioPort.isOutput() && portContainer.equals(getContainer())) {
                depth += numberOfPorts;
            }

            // Insert the hashtable entry.
            _portToDepth.put(ioPort, Integer.valueOf(depth));
            if (_debugging && _verbose) {
                _debug(((Nameable) ioPort).getFullName(), "depth: " + depth);
            }
        }

        if (_debugging && _verbose) {
            _debug("## adjusting port depths to "
                    + "make opaque composite actors and "
                    + "actors with no output ports strict.");
        }

        HashSet actorsWithPortDepthsAdjusted = new HashSet();

        // Adjusts the depths according to:
        // - If an output depends on several inputs directly,
        //   all inputs must have the same depth, the biggest one.
        for (int i = sort.length - 1; i >= 0; i--) {
            IOPort ioPort = (IOPort) sort[i];

            // Get the container actor of the current output port.
            Actor portContainer = (Actor) ioPort.getContainer();

            // Skip the ports of the container. Their depths are handled
            // by the upper level executive director of this container.
            if (portContainer.equals(getContainer())) {
                continue;
            }

            // For opaque composite actors and for actors with
            // no output ports, adjust the depths of all input ports
            // to match the maximum depth of the input ports.
            // If an actor has no output ports, then the default
            // dependencies of all input ports to all output ports
            // will not have been created. Hence, there is no mechanism
            // provided by this default to elevate the depth of all
            // the input ports to the maximum of those depths.
            // Thus, we conservatively assume that any actor with
            // no output ports should be treated as if it had one
            // output port (say, representing its state), and that
            // all input ports depend on that output port.
            // This will not be necessary in a version of DE
            // that implements a strict fixed-point semantics.
            if (ioPort.isInput()) {
                if (portContainer.outputPortList().size() == 0
                        || (portContainer instanceof CompositeActor && ((CompositeActor) portContainer)
                                .isOpaque())) {
                    List inputPorts = portContainer.inputPortList();

                    if (inputPorts.size() <= 1) {
                        // If the sink actor has only one input port, there is
                        // no need to adjust its depth.
                        continue;
                    }

                    if (actorsWithPortDepthsAdjusted.contains(portContainer)) {
                        // The depths of the input ports of this acotr
                        // have been adjusted.
                        continue;
                    } else {
                        actorsWithPortDepthsAdjusted.add(portContainer);
                    }

                    Iterator inputsIterator = inputPorts.iterator();

                    // Iterate all input ports of the sink or composite actor
                    // to find the largest depth.
                    int maximumPortDepth = -1;
                    while (inputsIterator.hasNext()) {
                        IOPort input = (IOPort) inputsIterator.next();
                        int inputPortDepth = ports.indexOf(input);
                        if (maximumPortDepth < inputPortDepth) {
                            maximumPortDepth = inputPortDepth;
                        }
                    }

                    // Set the depths of the input ports to the maximum one.
                    inputsIterator = inputPorts.iterator();
                    while (inputsIterator.hasNext()) {
                        IOPort input = (IOPort) inputsIterator.next();

                        if (_debugging && _verbose) {
                            _debug(((Nameable) input).getFullName(),
                                    "depth is adjusted to: " + maximumPortDepth);
                        }

                        // Insert the hashtable entry.
                        _portToDepth.put(input, Integer
                                .valueOf(maximumPortDepth));
                    }
                }
            }
            // For an output port, adjust the depths of all the
            // input ports on which it depends to match the largest
            // depth of those input ports.
            // FIXME: The following is really problematic. Check the
            // DESchedulingTest3.xml as example (NOTE: I can't
            // find this example. EAL).
            if (ioPort.isOutput()) {
                // Get the function dependency of the container actor
                FunctionDependency functionDependency = portContainer
                        .getFunctionDependency();

                List inputPorts = functionDependency
                        .getInputPortsDependentOn(ioPort);
                Iterator inputsIterator = inputPorts.iterator();

                // Iterate all input ports the current output depends on to
                // find their maximum depth.
                int maximumPortDepth = -1;
                while (inputsIterator.hasNext()) {
                    IOPort input = (IOPort) inputsIterator.next();
                    int inputPortDepth = ports.indexOf(input);
                    if (maximumPortDepth < inputPortDepth) {
                        maximumPortDepth = inputPortDepth;
                    }
                }

                // Set the depths of the input ports to the maximum one.
                inputsIterator = inputPorts.iterator();
                while (inputsIterator.hasNext()) {
                    IOPort input = (IOPort) inputsIterator.next();
                    if (_debugging && _verbose) {
                        _debug(((Nameable) input).getFullName(),
                                "depth is adjusted to: " + maximumPortDepth);
                    }
                    // Insert the hashtable entry.
View Full Code Here

     */
    protected synchronized void _transferInputs() throws IllegalActionException {
        Iterator inputPorts = inputPortList().iterator();

        while (inputPorts.hasNext()) {
            IOPort port = (IOPort) inputPorts.next();
            getDirector().transferInputs(port);
        }
    }
View Full Code Here

        if (executiveDirector != null) {
            Iterator outports = outputPortList().iterator();

            while (outports.hasNext()) {
                IOPort p = (IOPort) outports.next();
                executiveDirector.transferOutputs(p);
            }
        }
    }
View Full Code Here

    private void _transferInputsToInside() throws IllegalActionException {
        // If there are no input ports, this method does nothing.
        CompositeActor container = (CompositeActor) getContainer();
        Iterator inports = container.inputPortList().iterator();
        while (inports.hasNext() && !_stopRequested) {
            IOPort p = (IOPort) inports.next();
            super.transferInputs(p);
        }
    }
View Full Code Here

        super._constructDetailedDependencyGraph();
        // Note: cannot call getDetailedDependencyGraph()! because the
        // _version is not updated yet and it will result in an infinite loop.
        CompositeActor actor = (CompositeActor) getContainer();
        if (actor instanceof EnabledComposite) {
            IOPort enable = ((EnabledComposite) actor).enable;
            Iterator outputs = ((Actor) getContainer()).outputPortList()
                    .listIterator();
            while (outputs.hasNext()) {
                IOPort output = (IOPort) outputs.next();
                _detailedDependencyGraph.addEdge(enable, output);
            }
        } else {
            // If the container is not an EnabledComposite, do nothing. Or,
            // an exception can be thrown here.
View Full Code Here

TOP

Related Classes of ptolemy.actor.IOPort

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.