Package ptolemy.data.expr

Examples of ptolemy.data.expr.Variable


                        // then read and write positions in the buffer
                        // must return to the previous values after one
                        // iteration of the container actor in order to
                        // avoid using read and write offset variables.
                        if (inline) {
                            Variable firings = (Variable) ((NamedObj) actor)
                                    .getAttribute("firingsPerIteration");
                            int firingsPerIteration = ((IntToken) firings
                                    .getToken()).intValue();
                            readTokens = DFUtilities.getRate(inputPort)
                                    * firingsPerIteration;
                            writeTokens = readTokens;

View Full Code Here


     @exception IllegalActionException If the variable exists and
     *  its value cannot be set.
     */
    public static void setOrCreate(NamedObj container, String name, int value)
            throws IllegalActionException {
        Variable variable = _getOrCreate(container, name);
        variable.setToken(new IntToken(value));
    }
View Full Code Here

     @exception IllegalActionException If the variable exists and
     *  its value cannot be set.
     */
    public static void setOrCreate(NamedObj container, String name,
            String expression) throws IllegalActionException {
        Variable variable = _getOrCreate(container, name);
        variable.setExpression(expression);
    }
View Full Code Here

        if (rate < 0) {
            throw new IllegalActionException("Negative rate is not allowed: "
                    + rate);
        }

        Variable parameter = (Variable) port.getAttribute(name);

        if (parameter != null) {
            parameter.setToken(new IntToken(rate));
        } else {
            try {
                // Use Variable rather than Parameter so the
                // value is transient.
                parameter = new Variable(port, name, new IntToken(rate));
                parameter.setVisibility(Settable.NOT_EDITABLE);
                parameter.setPersistent(false);
            } catch (KernelException ex) {
                throw new InternalErrorException(port, ex, "Should not occur");
            }
        }
    }
View Full Code Here

     *  created for the given port, or the given value is not an acceptable.
     *  @see #getRateVariable(Port, String)
     */
    public static void setRateVariable(Port port, String name, int value)
            throws IllegalActionException {
        Variable rateParameter = (Variable) port.getAttribute(name);

        if (rateParameter == null) {
            try {
                String altName = "_" + name;
                rateParameter = (Variable) port.getAttribute(altName);

                if (rateParameter == null) {
                    rateParameter = new Parameter(port, altName);
                    rateParameter.setVisibility(Settable.NOT_EDITABLE);
                    rateParameter.setPersistent(false);
                }
            } catch (KernelException ex) {
                throw new InternalErrorException(port, ex, "Should not occur");
            }
        }
        rateParameter.setToken(new IntToken(value));
    }
View Full Code Here

    public static void showRate(Port port, boolean flag)
            throws IllegalActionException {
        String name = "_showRate";

        // Look for an existing parameter.
        Variable variable = (Variable) port.getAttribute(name);

        if (variable == null) {
            try {
                variable = new Parameter(port, name);
                variable.setVisibility(Settable.EXPERT);
                variable.setPersistent(false);
            } catch (KernelException ex) {
                throw new InternalErrorException(port, ex, "Should not occur");
            }
        }

        variable.setToken(BooleanToken.getInstance(flag));
    }
View Full Code Here

    ////                         private methods                   ////
    // If a variable exists with the given container and given name,
    // then return it. Otherwise, create the variable and return it.
    private static Variable _getOrCreate(NamedObj container, String name)
            throws IllegalActionException {
        Variable variable = (Variable) container.getAttribute(name);

        if (variable == null) {
            try {
                variable = new TemporaryVariable(container, name);
                variable.setVisibility(Settable.NOT_EDITABLE);
                variable.setPersistent(false);
            } catch (KernelException ex) {
                throw new InternalErrorException(container, ex,
                        "Should not occur");
            }
        }
View Full Code Here

        while (attributes.hasNext()) {
            Attribute attribute = (Attribute) attributes.next();

            if (attribute instanceof Variable) {
                Variable variable = (Variable) attribute;

                // If getToken() fails, make sure that you are calling
                // setExpression with a string that has double quotes.
                String value = variable.getToken().toString();

                // Strip out any leading and trailing double quotes
                if (value.startsWith("\"") && (value.length() > 2)) {
                    value = value.substring(1, value.length() - 1);
                }

                substituteMap.put("@" + variable.getName() + "@", value);
            }
        }

        return substituteMap;
    }
View Full Code Here

        // Determine requiredFiringsPerIteration for this actor.
        // The default value 0 means no requirement on this actor.
        ActorInfo actorInfo = (ActorInfo) _actorsInfo.get(actor);
        actorInfo.requiredFiringsPerIteration = 0;

        Variable requiredFiringsPerIteration = (Variable) ((Entity) actor)
                .getAttribute("requiredFiringsPerIteration");

        if (requiredFiringsPerIteration != null) {
            Token token = requiredFiringsPerIteration.getToken();

            if (token instanceof IntToken) {
                int value = ((IntToken) token).intValue();

                if (value > 0) {
View Full Code Here

            Arrays.fill(rate, 1);
        } else {
            Arrays.fill(rate, -1);
        }

        Variable rateVariable = DFUtilities.getRateVariable(port,
                "tokenConsumptionRate");

        if (rateVariable != null) {
            Token token = rateVariable.getToken();

            if (token != null) {
                // If token is ArrayToken, then each channel has a
                // corresponding input rate in the array.
                if (token instanceof ArrayToken) {
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.