Package ptolemy.data.expr

Examples of ptolemy.data.expr.Variable$TypeTerm


        Iterator insidePorts = port.deepInsidePortList().iterator();

        while (insidePorts.hasNext()) {
            IOPort insidePort = (IOPort) insidePorts.next();
            Variable variable = DFUtilities.getRateVariable(insidePort,
                    parameterName);

            if (variable != null) {
                list.add(variable);
            }
View Full Code Here


    private int _getTokenConsumptionRate(Receiver receiver)
            throws IllegalActionException {
        int tokenConsumptionRate;

        IOPort port = receiver.getContainer();
        Variable rateVariable = null;
        Token token = null;
        Receiver[][] portReceivers = null;

        // If DDF domain is inside another domain and the
        // receiver is contained by an opaque output port...
        // The default production rate is -1 which means all
        // tokens in the receiver are transferred to the outside.
        if (port.isOutput()) {
            rateVariable = DFUtilities.getRateVariable(port,
                    "tokenProductionRate");
            portReceivers = port.getInsideReceivers();

            if (rateVariable == null) {
                return -1;
            } else {
                token = rateVariable.getToken();

                if (token == null) {
                    return -1;
                }
            }
        }

        if (port.isInput()) {
            rateVariable = DFUtilities.getRateVariable(port,
                    "tokenConsumptionRate");
            portReceivers = port.getReceivers();

            if (rateVariable == null) {
                return 1;
            } else {
                token = rateVariable.getToken();

                if (token == null) {
                    return 1;
                }
            }
View Full Code Here

                productionRateToken[i] = new IntToken(productionRate[i]);
            }

            // Since this is output port, we look for token production rate
            // instead of token consumption rate.
            Variable rateVariable = DFUtilities.getRateVariable(outputPort,
                    "tokenProductionRate");

            if (rateVariable == null) {
                try {
                    rateVariable = new Parameter(outputPort,
                            "tokenProductionRate");
                } catch (NameDuplicationException ex) {
                    //should not happen.
                    throw new InternalErrorException(this, ex, null);
                }
            }

            rateVariable.setToken(new ArrayToken(BaseType.INT,
                    productionRateToken));
        }
    }
View Full Code Here

    private void _init() throws IllegalActionException,
            NameDuplicationException {
        annotation = new StringParameter(this, "annotation");
        annotation.setExpression("");
        // Add a hint to indicate to the PtolemyQuery class to open with a text style.
        Variable variable = new Variable(annotation, "_textHeightHint");
        variable.setExpression("5");
        variable.setPersistent(false);

        guardExpression = new StringAttribute(this, "guardExpression");
        // Add a hint to indicate to the PtolemyQuery class to open with a text style.
        variable = new Variable(guardExpression, "_textHeightHint");
        variable.setExpression("5");
        variable.setPersistent(false);

        outputActions = new OutputActionsAttribute(this, "outputActions");
        // Add a hint to indicate to the PtolemyQuery class to open with a text style.
        variable = new Variable(outputActions, "_textHeightHint");
        variable.setExpression("5");
        variable.setPersistent(false);

        setActions = new CommitActionsAttribute(this, "setActions");
        // Add a hint to indicate to the PtolemyQuery class to open with a text style.
        variable = new Variable(setActions, "_textHeightHint");
        variable.setExpression("5");
        variable.setPersistent(false);

        exitAngle = new Parameter(this, "exitAngle");
        exitAngle.setVisibility(Settable.NONE);
        exitAngle.setExpression("PI/5.0");
        exitAngle.setTypeEquals(BaseType.DOUBLE);
View Full Code Here

                        .getName(context));
                SootField field;

                // Create a field to contain the value of the attribute.
                if (settable instanceof Variable) {
                    Variable variable = (Variable) settable;
                    ptolemy.data.type.Type type = variable.getType();
                    Type tokenType = PtolemyUtilities
                            .getSootTypeForTokenType(type);

                    boolean isConstant = constantAnalysis.getConstVariables(
                            context).contains(attribute);

                    int modifier;

                    if (isConstant) {
                        modifier = Modifier.PUBLIC | Modifier.FINAL;
                    } else {
                        modifier = Modifier.PUBLIC;
                    }

                    field = new SootField(fieldName + "_CGToken", tokenType,
                            modifier);
                    theClass.addField(field);

                    if (isConstant) {
                        try {
                            field.addTag(new ValueTag(variable.getToken()));
                        } catch (Exception ex) {
                        }

                        field.addTag(new TypeTag(type));
                    }
View Full Code Here

        final NamedObj model = ((ExpressionShellEffigy) getContainer())
                .getModel();
        ParserScope scope = new ModelScope() {
            public ptolemy.data.Token get(String name)
                    throws IllegalActionException {
                Variable result = getScopedVariable(null, model, name);

                if (result != null) {
                    return result.getToken();
                } else {
                    return null;
                }
            }

            public ptolemy.data.type.Type getType(String name)
                    throws IllegalActionException {
                Variable result = getScopedVariable(null, model, name);

                if (result != null) {
                    return result.getType();
                } else {
                    return null;
                }
            }

            public InequalityTerm getTypeTerm(String name)
                    throws IllegalActionException {
                Variable result = getScopedVariable(null, model, name);

                if (result != null) {
                    return result.getTypeTerm();
                } else {
                    return null;
                }
            }

            public Set identifierSet() {
                return getAllScopedVariableNames(null, model);
            }
        };

        Token result = _evaluator.evaluateParseTree(node, scope);

        // If a target was specified, instantiate a new token.
        if (targetName != null) {
            Attribute attribute = model.getAttribute(targetName);

            if ((attribute != null) && !(attribute instanceof Parameter)) {
                attribute.setContainer(null);
                attribute = null;
            }

            if (attribute == null) {
                attribute = new Parameter(model, targetName);
            }

            ((Parameter) attribute).setToken(result);
        }

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

        Iterator attributeMapEntries = properties.entrySet().iterator();
        while (attributeMapEntries.hasNext()) {
            Map.Entry attributeNames = (Map.Entry) attributeMapEntries.next();
            String attributeName = (String) attributeNames.getKey();
            String attributeValue = (String) attributeNames.getValue();
            Variable variable = (Variable) getAttribute(attributeName);
            if (variable == null) {
                variable = new Variable(this, attributeName);
            }
            variable.setExpression(attributeValue);
        }
        // Validate only after setting all expressions, in case
        // there are cross dependencies.
        validateSettables();
    }
View Full Code Here

                Entity entity = (Entity) entities.next();
                Iterator attributes = entity.attributeList().iterator();
                while (attributes.hasNext()) {
                    Attribute attribute = (Attribute) attributes.next();
                    if (attribute instanceof Variable) {
                        Variable variable = (Variable) attribute;

                        boolean doGetToken = true;
                        while (doGetToken) {
                            doGetToken = false;
                            try {
                                variable.getToken();
                            } catch (IllegalActionException ex) {
                                doGetToken = _findUndefinedConstantsOrIdentifiers(
                                        ex, container, parsedContainer);
                            }
                        }
View Full Code Here

                        .length() + 2);

        Attribute masterAttribute = container.getAttribute(variableName);

        if (masterAttribute instanceof Variable) {
            Variable masterVariable = (Variable) masterAttribute;
            ParserScope parserScope = masterVariable.getParserScope();
            if (parserScope instanceof ModelScope) {
                if (masterVariable != null) {
                    Variable node = masterVariable.getVariable(idException
                            .nodeName());

                    if (node == _previousNode) {
                        // We've already seen this node, so stop
                        // looping through the getToken() loop.
                        return false;
                    }
                    _previousNode = node;

                    try {

                        String moml = node.exportMoML().replaceFirst(
                                "<property",
                                "<property createIfNecessary=\"true\"");

                        // Insert the new variable so that other
                        // variables may use it.
View Full Code Here

        getIntegerMatrices = new Parameter(this, "getIntegerMatrices",
                new BooleanToken(_dataParameters.getIntMatrices));
        new CheckBoxStyle(getIntegerMatrices, "style");

        // _time is not needed, fire() sets a matlab variable directly
        _iteration = new Variable(this, "iteration", new IntToken(1));
    }
View Full Code Here

TOP

Related Classes of ptolemy.data.expr.Variable$TypeTerm

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.