Package ptolemy.data

Examples of ptolemy.data.ArrayToken


        public void createEditor(NamedObj object, Frame parent) {
            // Perform the highlighting.
            try {
                NamedObj container = HighlightEntities.this.getContainer();
                if (container instanceof CompositeEntity) {
                    ArrayToken names = (ArrayToken) entityNames.getToken();
                    if (names != null && names.length() > 0) {
                        StringBuffer moml = new StringBuffer("<group>");
                        for (int i = 0; i < names.length(); i++) {
                            String name = ((StringToken) names.getElement(i))
                                    .stringValue();
                            ComponentEntity entity = ((CompositeEntity) container)
                                    .getEntity(name);
                            if (entity != null) {
                                moml.append("<entity name=\"");
View Full Code Here


                    locationArray[i] = new DoubleToken(location[i]);
                }

                double timeValue = getDirector().getModelTime()
                        .getDoubleValue();
                Token[] values = { new ArrayToken(locationArray),
                        new DoubleToken(timeValue), new IntToken(0) };
                Token result = new RecordToken(labels, values);

                output.send(0, result);
            } else {
                // It is the pursuer. Send its parent info to the pursuer.
                if (_timeValue > 0.0) {
                    String[] labels = { "location", "time", "depth" };

                    Token[] values = { new ArrayToken(_parentLocation),
                            new DoubleToken(_timeValue),
                            new IntToken(_parentDepth) };
                    Token result = new RecordToken(labels, values);

                    output.send(0, result);
View Full Code Here

                                + ". Must be nonnegative.");
            }

            _reinitializeNeeded = true;
        } else if (attribute == taps) {
            ArrayToken tapsToken = (ArrayToken) (taps.getToken());
            _taps = tapsToken.arrayValue();

            // Get a token representing zero in the appropriate type.
            _zero = _taps[0].zero();

            _reinitializeNeeded = true;
View Full Code Here

     @exception IllegalActionException If a runtime type conflict occurs.
     */
    public void fire() throws IllegalActionException {
        super.fire();

        ArrayToken token = (ArrayToken) input.get(0);
        int rate = ((IntToken) arrayLength.getToken()).intValue();
        boolean enforce = ((BooleanToken) enforceArrayLength.getToken())
                .booleanValue();

        if (enforce && (token.length() != rate)) {
            throw new IllegalActionException(this, "The "
                    + "number of elements in the input ArrayToken ("
                    + token.length() + ") is not the same as the arrayLength "
                    + "parameter (" + rate + ").");
        }

        Token[] elements = token.arrayValue();
        output.send(0, elements, elements.length);
    }
View Full Code Here

            } else {
                _outputs[i] = _outputs[(2 * (_numberOfLags - notSymmetric)) - i];
            }
        }

        output.broadcast(new ArrayToken(_outputs));
    }
View Full Code Here

     *   nondecreasing and nonnegative, or it is not a row vector.
     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == offsets) {
            ArrayToken offsetsValue = (ArrayToken) offsets.getToken();
            _offsets = new double[offsetsValue.length()];

            double previous = 0.0;

            for (int i = 0; i < offsetsValue.length(); i++) {
                _offsets[i] = ((DoubleToken) offsetsValue.getElement(i))
                        .doubleValue();

                // Check nondecreasing property.
                if (_offsets[i] < previous) {
                    throw new IllegalActionException(this,
View Full Code Here

        super(container, name);

        StringToken[] empty = new StringToken[1];
        stateVariableNames = new Parameter(this, "stateVariableNames");
        empty[0] = new StringToken("");
        stateVariableNames.setToken(new ArrayToken(BaseType.STRING, empty));
        initialStates = new Parameter(this, "initialStates");
        initialStates.setTypeEquals(BaseType.DOUBLE_MATRIX);

        setClassName("ptolemy.domains.ct.lib.DifferentialSystem");
View Full Code Here

     */
    public void preinitialize() throws IllegalActionException {
        // Check parameters.
        _checkParameters();

        ArrayToken stateNames = (ArrayToken) stateVariableNames.getToken();
        int n = stateNames.length();
        int m = inputPortList().size();
        int r = outputPortList().size();

        // FIXME: Why does this get the token and then do nothing with the value?
        //DoubleMatrixToken initial = (DoubleMatrixToken) initialStates
        //        .getToken();

        try {
            _workspace.getWriteAccess();
            removeAllEntities();
            removeAllRelations();

            // Create the model
            Integrator[] integrators = new Integrator[n];
            String[] states = new String[n];
            IORelation[] stateRelations = new IORelation[n];
            Expression[] equations = new Expression[n];

            // Integrators and feedback expressions
            for (int i = 0; i < n; i++) {
                states[i] = ((StringToken) stateNames.getElement(i))
                        .stringValue().trim();
                integrators[i] = new Integrator(this, states[i]);
                integrators[i].initialState.setExpression("initialStates(0,"
                        + i + ")");
                stateRelations[i] = new TypedIORelation(this, "relation_"
View Full Code Here

    /** Check the dimensions of all parameters and ports.
     *  @exception IllegalActionException If the dimensions are illegal.
     */
    private void _checkParameters() throws IllegalActionException {
        // Check state variable names.
        ArrayToken stateNames = (ArrayToken) stateVariableNames.getToken();
        int n = stateNames.length();

        if (n < 1) {
            throw new IllegalActionException(this, "There must be at "
                    + "least one state variable for a differential system.");
        }

        // Check if any of the state variable names is an empty string.
        for (int i = 0; i < n; i++) {
            String name = (((StringToken) stateNames.getElement(i))
                    .stringValue()).trim();

            if (name.equals("")) {
                throw new IllegalActionException(this, "A state variable "
                        + "name should not be an empty string.");
View Full Code Here

     *   to this container (not thrown in this base class).
     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == initialPool) {
            ArrayToken pool = (ArrayToken) initialPool.getToken();
            // Reset the pool.
            _pool.clear();
            // Copy the tokens into the pool.
            for (int i = 0; i < pool.length(); i++) {
                _pool.add(pool.getElement(i));
            }
        } else {
            super.attributeChanged(attribute);
        }
    }
View Full Code Here

TOP

Related Classes of ptolemy.data.ArrayToken

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.