Package ptolemy.actor

Examples of ptolemy.actor.IOPort


            Actor containedActor = (Actor) actorIterator.next();
            List temporaryInputPortList = containedActor.inputPortList();
            Iterator inputPortIterator = temporaryInputPortList.iterator();

            while (inputPortIterator.hasNext()) {
                IOPort inputPort = (IOPort) inputPortIterator.next();
                inputPortList.add(inputPort);
            }
        }

        return inputPortList;
View Full Code Here


            Actor containedActor = (Actor) actorIterator2.next();
            List temporaryOutputPortList = containedActor.outputPortList();
            Iterator outputPortIterator = temporaryOutputPortList.iterator();

            while (outputPortIterator.hasNext()) {
                IOPort outputPort = (IOPort) outputPortIterator.next();
                outputPortList.add(outputPort);
            }
        }

        return outputPortList;
View Full Code Here

                .getAnalysis(this);
        SDFDirector director = (SDFDirector) getContainer();
        CompositeActor model = (CompositeActor) director.getContainer();

        for (Iterator ports = model.portList().iterator(); ports.hasNext();) {
            IOPort port = (IOPort) ports.next();

            if (!(port instanceof ParameterPort)) {
                if (port.isInput()) {
                    _declareDependency(analysis, port, "tokenConsumptionRate",
                            _rateVariables);
                }

                if (port.isOutput()) {
                    _declareDependency(analysis, port, "tokenProductionRate",
                            _rateVariables);
                    _declareDependency(analysis, port, "tokenInitProduction",
                            _rateVariables);
                }
View Full Code Here

        // Update the number of tokens waiting on the actor's input ports.
        Iterator inputPorts = currentActor.inputPortList().iterator();

        while (inputPorts.hasNext()) {
            IOPort inputPort = (IOPort) inputPorts.next();
            int tokenRate = DFUtilities.getTokenConsumptionRate(inputPort);

            // Ignore zero rate ports.. they don't limit the number of times
            // we can fire their actors.
            if (tokenRate == 0) {
                continue;
            }

            Receiver[][] receivers = inputPort.getReceivers();

            for (int channel = 0; channel < receivers.length; channel++) {
                if (receivers[channel] == null) {
                    continue;
                }
View Full Code Here

        int count = 0;

        Iterator inputPorts = actor.inputPortList().iterator();

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

            if (_debugging && VERBOSE) {
                _debug("Checking input " + inputPort.getFullName());
            }

            int threshold = DFUtilities.getTokenConsumptionRate(inputPort);

            if (_debugging && VERBOSE) {
                _debug("Threshold = " + threshold);
            }

            Receiver[][] receivers = inputPort.getReceivers();
            boolean isFulfilled = true;

            for (int channel = 0; channel < receivers.length; channel++) {
                if (receivers[channel] == null) {
                    continue;
View Full Code Here

        // or better yet, cache it in the receivers?
        Map externalRates = new HashMap();

        // Initialize externalRates to zero.
        for (Iterator ports = container.portList().iterator(); ports.hasNext();) {
            IOPort port = (IOPort) ports.next();
            externalRates.put(port, Fraction.ZERO);
        }

        // First solve the balance equations
        Map entityToFiringsPerIteration = _solveBalanceEquations(container,
View Full Code Here

            CompositeActor comp = (CompositeActor) getContainer();
            Iterator inPorts = comp.inputPortList().iterator();
            List resultsList = new LinkedList();

            while (inPorts.hasNext()) {
                IOPort port = (IOPort) inPorts.next();
                Receiver[][] allReceivers = port.deepGetReceivers();
                states = controller.entityList().iterator();

                while (states.hasNext()) {
                    state = (State) states.next();
View Full Code Here

                Actor currentActor = (Actor) pendingActors.removeFirst();
                Iterator actorPorts = ((ComponentEntity) currentActor)
                        .portList().iterator();

                while (actorPorts.hasNext()) {
                    IOPort currentPort = (IOPort) actorPorts.next();
                    _propagatePort(container, currentPort,
                            entityToFiringsPerIteration, externalRates,
                            remainingActors, pendingActors, clusteredActors,
                            clusteredExternalPorts);
                }
            }

            // Now we have _clusteredActors, which contains actors in
            // one cluster (they are connected). Find the LCM of their
            // denominator and normalize their firings. This means firings
            // of actors are only normalized within their cluster.
            int lcm = 1;

            for (Iterator actors = clusteredActors.iterator(); actors.hasNext();) {
                Actor currentActor = (Actor) actors.next();
                Fraction fraction = (Fraction) entityToFiringsPerIteration
                        .get(currentActor);
                int denominator = fraction.getDenominator();
                lcm = Fraction.lcm(lcm, denominator);
            }

            // Got the normalizing factor.
            Fraction lcmFraction = new Fraction(lcm);

            for (Iterator actors = clusteredActors.iterator(); actors.hasNext();) {
                Actor currentActor = (Actor) actors.next();
                Fraction repetitions = ((Fraction) entityToFiringsPerIteration
                        .get(currentActor)).multiply(lcmFraction);

                if (repetitions.getDenominator() != 1) {
                    throw new InternalErrorException(
                            "Failed to properly perform"
                                    + " fraction normalization.");
                }

                entityToFiringsPerIteration.put(currentActor, repetitions);
            }

            for (Iterator externalPorts = clusteredExternalPorts.iterator(); externalPorts
                    .hasNext();) {
                IOPort port = (IOPort) externalPorts.next();
                Fraction rate = ((Fraction) externalRates.get(port))
                        .multiply(lcmFraction);

                if (rate.getDenominator() != 1) {
                    throw new InternalErrorException(
View Full Code Here

    private void _checkDirectInputOutputConnection(CompositeActor container,
            Map externalRates) {

        Iterator inputPorts = container.inputPortList().iterator();
        while (inputPorts.hasNext()) {
            IOPort inputPort = (IOPort) inputPorts.next();
            Fraction rate = (Fraction) externalRates.get(inputPort);
            if (rate.equals(Fraction.ZERO)) {

                // Check to make sure that if this port is an external
                // input port, then it does not drive the same relation as some
                // other output port or some other external input port.
                // This results in a non-deterministic merge and is illegal.

                Iterator connectedPorts = inputPort.deepInsidePortList()
                        .iterator();

                // Make sure any connected output ports are connected on
                // the inside.
                while (connectedPorts.hasNext()) {
                    IOPort connectedPort = (IOPort) connectedPorts.next();

                    // connectPort might be connected on the inside to the
                    // currentPort, which is legal.  The container argument
                    // is always the container of the director, so any port
                    // that has that container must be connected on the inside.
                    if (connectedPort.isOutput()
                            && (connectedPort.getContainer() != container)) {
                        throw new NotSchedulableException(inputPort,
                                connectedPort,
                                "External input port drive the same relation "
                                        + "as an output port. "
                                        + "This is not legal in SDF.");
                    } else if (connectedPort.isInput()
                            && (connectedPort.getContainer() == container)) {
                        throw new NotSchedulableException(inputPort,
                                connectedPort,
                                "External input port drives the same relation "
                                        + "as another external input port. "
                                        + "This is not legal in SDF.");
                    }
                }

                boolean isDirectionConnection = true;
                List insideSinkPorts = inputPort.insideSinkPortList();

                // A dangling port has zero rate.
                if (insideSinkPorts.isEmpty()) {
                    isDirectionConnection = false;
                } else {
                    // If the zero external port rate is due to the rate
                    // propagation from a contained actor (i.e., connected to the
                    // zero rate port of the actor), then the zero external rate
                    // must be preserved.
                    Iterator sinkPorts = insideSinkPorts.iterator();
                    while (sinkPorts.hasNext()) {
                        IOPort sinkPort = (IOPort) sinkPorts.next();
                        if (sinkPort.getContainer() != container) {
                            isDirectionConnection = false;
                            break;
                        }
                    }
                }

                if (isDirectionConnection) {
                    externalRates.put(inputPort, new Fraction(1));
                    Iterator sinkPorts = insideSinkPorts.iterator();
                    while (sinkPorts.hasNext()) {
                        IOPort sinkPort = (IOPort) sinkPorts.next();
                        externalRates.put(sinkPort, new Fraction(1));
                    }
                }
            }
        }
View Full Code Here

        for (Iterator actors = actorList.iterator(); actors.hasNext();) {
            ComponentEntity actor = (ComponentEntity) actors.next();

            // Check if this actor has any ports with rate of zero.
            for (Iterator ports = actor.portList().iterator(); ports.hasNext();) {
                IOPort port = (IOPort) ports.next();

                if (DFUtilities.getRate(port) == 0) {
                    return actor;
                }
            }
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.