Package ptolemy.data.expr

Examples of ptolemy.data.expr.Variable


            // Ensure that the production rate is one.
            // FIXME: This may not be right if there is no
            // actual source of data for this port (e.g. no
            // SetVariable actor).
            Variable rate = (Variable) port.getAttribute("tokenProductionRate");

            if (rate == null) {
                try {
                    rate = new Variable(port, "tokenProductionRate");
                } catch (NameDuplicationException e) {
                    throw new InternalErrorException(e);
                }
            }

            rate.setToken(new IntToken(1));

            String portName = port.getName();
            Attribute attribute = getAttribute(portName);

            if (attribute == null) {
                try {
                    workspace().getWriteAccess();
                    attribute = new Variable(this, portName);
                } catch (NameDuplicationException ex) {
                    throw new InternalErrorException(ex);
                } finally {
                    workspace().doneWriting();
                }
View Full Code Here


            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        setClassName("ptolemy.actor.lib.hoc.IterateOverArray");
        new IterateDirector(this, uniqueName("IterateDirector"));

        _iterationCount = new Variable(this, "iterationCount", new IntToken(0));
        _iterationCount.setTypeEquals(BaseType.INT);
    }
View Full Code Here

        if (container != null) {
            for (Iterator entities = container.deepEntityList().iterator(); entities
                    .hasNext();) {
                Entity actor = (Entity) entities.next();
                Variable parameter = (Variable) actor
                        .getAttribute("firingCount");

                if (parameter != null) {
                    parameter.setExpression("0");
                }
            }
        }
    }
View Full Code Here

        CompositeActor model = (CompositeActor) director.getContainer();
        Iterator relations = model.relationList().iterator();

        while (relations.hasNext()) {
            Relation relation = (Relation) relations.next();
            Variable variable = (Variable) relation.getAttribute("bufferSize");
            result.append(relation.getName() + ": ");

            if (variable == null) {
                result.append("null");
            } else {
                result.append(variable.getExpression());
            }

            result.append("\n");
        }
View Full Code Here

                    Entity entity = (Entity) connectedPort.getContainer();
                    String name = connectedPort.getName(model);
                    String identifier = name.replaceAll("\\.", "::");

                    String sinkExpression;
                    Variable sinkRateVariable = DFUtilities.getRateVariable(
                            connectedPort, "tokenConsumptionRate");

                    if (sinkRateVariable == null) {
                        sinkExpression = "1";
                    } else {
                        sinkExpression = identifier + "::"
                                + sinkRateVariable.getName();
                    }

                    String expression = sinkExpression + " * "
                            + entity.getName() + "::firingsPerIteration";

                    DFUtilities.setExpressionIfNotDefined(port,
                            "tokenConsumptionRate", expression);

                    if (_debugging && VERBOSE) {
                        _debug("Setting tokenConsumptionRate to " + expression);
                    }
                }
            } else if (port.isOutput()) {
                List sources = port.insideSourcePortList();

                if (sources.size() > 0) {
                    IOPort connectedPort = (IOPort) sources.get(0);
                    Entity entity = (Entity) connectedPort.getContainer();
                    String name = connectedPort.getName(model);
                    String identifier = name.replaceAll("\\.", "::");
                    Variable sourceRateVariable = DFUtilities.getRateVariable(
                            connectedPort, "tokenProductionRate");
                    String sourceExpression;

                    if (sourceRateVariable == null) {
                        sourceExpression = "1";
                    } else {
                        sourceExpression = identifier + "::"
                                + sourceRateVariable.getName();
                    }

                    String expression = sourceExpression + " * "
                            + entity.getName() + "::firingsPerIteration";

View Full Code Here

        }

        if (element instanceof SymbolicFiring) {
            SymbolicFiring firing = (SymbolicFiring) element;
            Entity actor = (Entity) firing.getActor();
            Variable parameter = (Variable) actor
                    .getAttribute("firingsPerIteration");

            if (parameter == null) {
                parameter = new Parameter(actor, "firingsPerIteration");
                parameter.setVisibility(Settable.NOT_EDITABLE);
                parameter.setPersistent(false);
            }

            parameter.setExpression(recursiveExpression);
        } else if (element instanceof SymbolicSchedule) {
            SymbolicSchedule schedule = (SymbolicSchedule) element;

            for (Iterator i = schedule.iterator(); i.hasNext();) {
                _inferFiringCounts((SymbolicScheduleElement) i.next(),
View Full Code Here

                                "Cannot complete action: " + ex.getMessage());
                    } catch (UnknownResultException ex) {
                        // Produce no output.
                    }
                } else if (nextDestination instanceof Variable) {
                    Variable destination = (Variable) nextDestination;

                    try {
                        //Token token = variable.getToken();
                        destination.setToken(token);

                        // Force all dependents to re-evaluate.
                        // This makes the parameters in the actors of
                        // the refinement take on new values immediately
                        // after the action is committed.
                        destination.validate();

                        if (_debugging) {
                            _debug(getFullName() + " variable: "
                                    + destination.getName() + ", value: "
                                    + token);
                        }
                    } catch (UnknownResultException ex) {
                        destination.setUnknown(true);
                    }
                } else {
                    throw new IllegalActionException(this,
                            "Destination is neither an IOPort nor a Variable: "
                                    + nextDestination.getFullName());
View Full Code Here

        Attribute temporaryAttribute = weights.getAttribute("Weight");

        if (temporaryAttribute == null) {
            return 1;
        } else if (temporaryAttribute instanceof Variable) {
            Variable weightAttribute = (Variable) temporaryAttribute;
            Token weightToken = weightAttribute.getToken();

            if (weightToken instanceof ScalarToken) {
                ScalarToken weightScalarToken = (ScalarToken) weightToken;
                return weightScalarToken.intValue();
            }
View Full Code Here

        doublePath = new Parameter(this, "doublePath", new LongToken(0));
        doublePath.setToken("false");
        doublePath.setTypeEquals(BaseType.BOOLEAN);

        _distance = new Variable(this, "distance");
        _distance.setExpression("Infinity");

        // Hide the ports in Vergil.
        SingletonParameter hide = new SingletonParameter(output, "_hide");
        hide.setToken(BooleanToken.TRUE);
View Full Code Here

         */
        public ptolemy.data.Token get(String name)
                throws IllegalActionException {
            PSDFDirector director = (PSDFDirector) getContainer();
            CompositeActor reference = (CompositeActor) director.getContainer();
            Variable result = getScopedVariable(null, reference, name);

            if (result != null) {
                return result.getToken();
            } else {
                return null;
            }
        }
View Full Code Here

TOP

Related Classes of ptolemy.data.expr.Variable

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.