Package ptolemy.actor

Examples of ptolemy.actor.CompositeActor


    /** Return a list of all the output ports contained by the
     *  deeply contained entities of the container of this director.
     *  @return The list of output ports.
     */
    private List _getOutputPortList() {
        CompositeActor container = (CompositeActor) getContainer()
                .getContainer();
        List actors = container.deepEntityList();
        Iterator actorIterator2 = actors.iterator();
        List outputPortList = new LinkedList();

        while (actorIterator2.hasNext()) {
            Actor containedActor = (Actor) actorIterator2.next();
View Full Code Here


     */
    public void declareRateDependency() throws IllegalActionException {
        ConstVariableModelAnalysis analysis = ConstVariableModelAnalysis
                .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",
View Full Code Here

     *  external ports are not correct.
     */
    protected Schedule _getSchedule() throws NotSchedulableException,
            IllegalActionException {
        SDFDirector director = (SDFDirector) getContainer();
        CompositeActor model = (CompositeActor) director.getContainer();

        _checkDynamicRateVariables(model, _rateVariables);

        int vectorizationFactor = 1;

        Token token = director.vectorizationFactor.getToken();
        vectorizationFactor = ((IntToken) token).intValue();

        if (vectorizationFactor < 1) {
            throw new NotSchedulableException(this,
                    "The supplied vectorizationFactor must be "
                            + "a positive integer. The given value was: "
                            + vectorizationFactor);
        }

        CompositeActor container = (CompositeActor) director.getContainer();

        // A linked list containing all the actors.
        List allActorList = container.deepEntityList();

        // externalRates maps from external
        // ports to the number of tokens that that port
        // will produce or consume in each firing.
        // It gets populated with the fractional production ratios
        // and is used in the end to set final rates on external ports.
        // This map is initialized to zero.
        // NOTE: This used to be a TreeMap using DFUtilities.NamedObjComparator().
        // However, that comparator is very slow.
        // FIXME: Why not get this via the container of the receivers?
        // 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
View Full Code Here

                }
            }
        }

        Director director = (Director) getContainer();
        CompositeActor model = (CompositeActor) director.getContainer();

        // Get the rate of this port.
        int currentRate;

        if (currentActor == model) {
View Full Code Here

            if (!(container instanceof CompositeActor)) {
                throw new IllegalActionException(this, "No controller found.");
            }

            CompositeActor cont = (CompositeActor) container;
            Entity entity = cont.getEntity(name);

            if (entity == null) {
                throw new IllegalActionException(this, "No controller found "
                        + "with name " + name);
            }
View Full Code Here

        */

        // If a transition was taken, then request a refiring at the current time
        // in case the destination state is a transient state.
        if (_enabledTransition != null) {
            CompositeActor container = (CompositeActor) getContainer();
            Director executiveDirector = container.getExecutiveDirector();
            if (executiveDirector != null) {
                if (_debugging) {
                    _debug("Request refiring by "
                            + executiveDirector.getFullName() + " at "
                            + getModelTime());
View Full Code Here

            while (states.hasNext()) {
                state = (State) states.next();
                _localReceiverMaps.put(state, new HashMap());
            }

            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();
View Full Code Here

        // Get the range.
        ArrayToken rangeValue = (ArrayToken) range.getToken();
        int dimensions = rangeValue.length();
        double[] randomLocation = new double[dimensions];

        CompositeActor container = (CompositeActor) getContainer();
        StringBuffer changeMoML = new StringBuffer("<group>\n");
        Iterator actors = container.deepEntityList().iterator();

        while (actors.hasNext()) {
            Entity node = (Entity) actors.next();

            // Skip actors that are not properly marked.
            Attribute mark = node.getAttribute("randomize");

            if (!(mark instanceof Variable)) {
                continue;
            }

            Token markValue = ((Variable) mark).getToken();

            if (!(markValue instanceof BooleanToken)) {
                continue;
            }

            if (!((BooleanToken) markValue).booleanValue()) {
                continue;
            }

            for (int i = 0; i < dimensions; i++) {
                ArrayToken lowHigh = (ArrayToken) rangeValue.getElement(i);

                if (lowHigh.length() < 2) {
                    throw new IllegalActionException(this, "Invalid range: "
                            + range.getExpression());
                }

                double low = ((DoubleToken) lowHigh.getElement(0))
                        .doubleValue();
                double high = ((DoubleToken) lowHigh.getElement(1))
                        .doubleValue();

                if (high < low) {
                    throw new IllegalActionException(this, "Invalid range: "
                            + range.getExpression());
                }

                // If the precision is 0, then use the maximum precision allowed by double.
                // Otherwise, round according to the maxPrecision parameter.
                if (_mathContext == null) {
                    randomLocation[i] = low
                            + ((_random.nextDouble()) * (high - low));
                } else {
                    double candidateRandomLocation = low
                            + ((_random.nextDouble()) * (high - low));
                    // Create a BigDecimal with the specified precision.
                    BigDecimal decimal = new BigDecimal(
                            candidateRandomLocation, _mathContext);
                    // Obtain the rounded double value.
                    randomLocation[i] = decimal.doubleValue();
                }
            }

            changeMoML.append(_getLocationSetMoML(container, node,
                    randomLocation));
        }

        changeMoML.append("</group>");

        MoMLChangeRequest request = new MoMLChangeRequest(this, container,
                changeMoML.toString());
        container.requestChange(request);

        // Increment the workspace version number, since the wireless
        // graph connectivity probably changed as a result of the node
        // location randomization.  This is used in conjunction with
        // LimitedRangeChannel.valueChanged(), which invalidates the
View Full Code Here

     */
    private void _cloneRecursionActor() throws IllegalActionException,
            CloneNotSupportedException {
        try {
            // Clone the composite actor.
            CompositeActor clone = (CompositeActor) _recursionActor
                    .clone(workspace());

            // Place the clone inside this actor.
            clone.setContainer(this);

            // i is used to generate different names for new relations.
            int i = 0;
            Iterator ports = portList().iterator();

            _inputTokensHolder.clear();

            while (ports.hasNext()) {
                IOPort port = (IOPort) ports.next();

                // Store all tokens contained by input ports of this actor
                // because connecting ports will result in creating receivers
                // again and all tokens in the original receivers will be lost.
                if (port.isInput()) {
                    int width = port.getWidth();
                    Receiver[][] receivers = port.getReceivers();
                    Token[][] tokens = new Token[width][0];

                    for (int channel = 0; channel < width; channel++) {
                        int size = ((QueueReceiver) receivers[channel][0])
                                .size();
                        tokens[channel] = new Token[size];

                        for (int count = 0; count < size; count++) {
                            tokens[channel][count] = port.get(channel);
                        }
                    }

                    _inputTokensHolder.put(port, tokens);
                }

                // Connect the corresponding ports of both actors.
                IOPort matchingPort = (IOPort) clone.getPort(port.getName());
                IORelation relation = (IORelation) newRelation("r_" + i++);
                port.link(relation);
                matchingPort.link(relation);

                if (port.isMultiport()) {
View Full Code Here

     @exception IllegalActionException If no actor is found with
     *   the given name.
     */
    private void _searchRecursionActor() throws IllegalActionException {
        String recursionActorValue = recursionActor.stringValue();
        CompositeActor container = (CompositeActor) getContainer();

        while (container != null) {
            if (recursionActorValue.equals(container.getName())) {
                _recursionActor = container;
                return;
            } else {
                container = (CompositeActor) container.getContainer();
            }
        }

        throw new IllegalActionException(this,
                "Can not find a container with name " + recursionActorValue);
View Full Code Here

TOP

Related Classes of ptolemy.actor.CompositeActor

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.