Package ptolemy.data

Examples of ptolemy.data.ArrayToken


     * @param attribute The attribute that changed.
     * @exception IllegalActionException If the base class throws it.
     */
    public void attributeChanged(Attribute attribute) throws IllegalActionException  {
        if (attribute == reflectionCoefficients) {
            ArrayToken value = (ArrayToken)reflectionCoefficients.getToken();
            int valueLength = value.length();
            if ((_backward == null) || (valueLength != (_backward.length - 1))) {
                $ASSIGN$_backward(new double[valueLength + 1]);
                $ASSIGN$_backwardCache(new double[valueLength + 1]);
                $ASSIGN$_forward(new double[valueLength + 1]);
                $ASSIGN$_forwardCache(new double[valueLength + 1]);
                $ASSIGN$_reflectionCoefs(new double[valueLength]);
            }
            for (int i = 0; i < valueLength; i++) {
                $ASSIGN$_reflectionCoefs(i, ((DoubleToken)value.getElement(i)).doubleValue());
            }
        } else {
            super.attributeChanged(attribute);
        }
    }
View Full Code Here


        offsets.setTypeEquals(new ArrayType(BaseType.DOUBLE));
        attributeChanged(offsets);
        IntToken[] defaultValues = new IntToken[2];
        defaultValues[0] = new IntToken(1);
        defaultValues[1] = new IntToken(0);
        ArrayToken defaultValueToken = new ArrayToken(BaseType.INT, defaultValues);
        values = new Parameter(this, "values", defaultValueToken);
        output.setTypeAtLeast(ArrayType.elementType(values));
        attributeChanged(values);
    }
View Full Code Here

     * @exception IllegalActionException If the offsets array is not
     * 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();
            $ASSIGN$_offsets(new double[offsetsValue.length()]);
            double previous = 0.0;
            for (int i = 0; i < offsetsValue.length(); i++) {
                $ASSIGN$_offsets(i, ((DoubleToken)offsetsValue.getElement(i)).doubleValue());
                if (_offsets[i] < previous) {
                    throw new IllegalActionException(this, "Value of offsets is not nondecreasing " + "and nonnegative.");
                }
                previous = _offsets[i];
            }
View Full Code Here

     * Set the current value.
     * @return True.
     * @exception IllegalActionException If there is no director.
     */
    public boolean prefire() throws IllegalActionException  {
        ArrayToken val = (ArrayToken)(values.getToken());
        if ((val == null) || (val.length() <= _phase)) {
            throw new IllegalActionException(this, "Offsets and values parameters lengths do not match.");
        }
        $ASSIGN$_currentValue(val.getElement(_phase));
        return true;
    }
View Full Code Here

     * @exception IllegalActionException If this method is invoked
     * with an unrecognized parameter.
     */
    public void attributeChanged(Attribute attribute) throws IllegalActionException  {
        if (attribute == numerator) {
            ArrayToken numeratorValue = (ArrayToken)numerator.getToken();
            $ASSIGN$_numerator(numeratorValue.arrayValue());
        } else if (attribute == denominator) {
            ArrayToken denominatorValue = (ArrayToken)denominator.getToken();
            $ASSIGN$_denominator(denominatorValue.arrayValue());
            if (!_denominator[0].isEqualTo(_denominator[0].one()).booleanValue()) {
                try {
                    MessageHandler.warning("First denominator value is required to be 1. " + "Using 1.");
                } catch (CancelException ex) {
                    throw new IllegalActionException(this, "Canceled parameter change.");
View Full Code Here

                            for (int j = 0; j < ((int[]) field.get(obj)).length; j++) {
                                toks[j] = new IntToken(
                                        ((int[]) field.get(obj))[j]);
                            }

                            port.send(0, new ArrayToken(BaseType.INT, toks));
                        } catch (IllegalAccessException ex) {
                            throw new IllegalActionException(this, ex, "Type '"
                                    + typ + "' is not castable");
                        }
                    } else if (typ.equals("class [D")) {
                        try {
                            Token[] toks = new Token[((double[]) field.get(obj)).length];

                            for (int j = 0; j < ((double[]) field.get(obj)).length; j++) {
                                toks[j] = new DoubleToken(((double[]) field
                                        .get(obj))[j]);
                            }

                            port.send(0, new ArrayToken(toks));
                        } catch (IllegalAccessException ex) {
                            throw new IllegalActionException(this, ex, "Type '"
                                    + typ + "' is not castable");
                        }
                    } else {
View Full Code Here

     * @exception IllegalActionException If the indexes vector is not
     * increasing and nonnegative, or the indexes is not a row vector.
     */
    public void attributeChanged(Attribute attribute) throws IllegalActionException  {
        if (attribute == indexes) {
            ArrayToken indexesValue = (ArrayToken)indexes.getToken();
            $ASSIGN$_indexes(new int[indexesValue.length()]);
            int previous = 0;
            for (int i = 0; i < indexesValue.length(); i++) {
                $ASSIGN$_indexes(i, ((IntToken)indexesValue.getElement(i)).intValue());
                if (_indexes[i] < previous) {
                    throw new IllegalActionException(this, "Value of indexes is not nondecreasing " + "and nonnegative.");
                }
                previous = _indexes[i];
            }
        } else if (attribute == values) {
            try {
                ArrayToken valuesArray = (ArrayToken)values.getToken();
                Token prototype = valuesArray.getElement(0);
                $ASSIGN$_zero(prototype.zero());
            } catch (ArrayIndexOutOfBoundsException ex) {
                throw new IllegalActionException(this, "Cannot set values to an empty array.");
            } catch (ClassCastException ex) {
                throw new IllegalActionException(this, "Cannot set values to something that is not an array: " + values.getToken());
View Full Code Here

     * do not have the same length, or if there is no director.
     */
    public void fire() throws IllegalActionException  {
        super.fire();
        int currentIndex = 0;
        ArrayToken val = (ArrayToken)values.getToken();
        if (_indexColCount < _indexes.length) {
            if (val.length() != _indexes.length) {
                throw new IllegalActionException(this, "Parameters values and indexes have " + "different lengths.  Length of values = " + val.length()+". Length of indexes = "+_indexes.length+".");
            }
            currentIndex = _indexes[_indexColCount];
            if (_iterationCount == currentIndex) {
                output.send(0, val.getElement(_indexColCount));
                $ASSIGN$_match(true);
                return;
            }
        } else {
            if (_repeatFlag) {
                $ASSIGN$_iterationCount(0);
                $ASSIGN$_indexColCount(0);
                currentIndex = _indexes[_indexColCount];
                if (_iterationCount == currentIndex) {
                    output.send(0, val.getElement(_indexColCount));
                    $ASSIGN$_match(true);
                }
                return;
            }
        }
View Full Code Here

     * @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException  {
        super.fire();
        if ((enable.getWidth() == 0) || (enable.hasToken(0) && ((BooleanToken)enable.get(0)).booleanValue())) {
            ArrayToken valuesArray = (ArrayToken)values.getToken();
            if (_currentIndex < valuesArray.length()) {
                output.send(0, valuesArray.getElement(_currentIndex));
                $ASSIGN$_outputProduced(true);
            }
        }
    }
View Full Code Here

     */
    public boolean postfire() throws IllegalActionException  {
        if (_outputProduced) {
            $ASSIGN$_outputProduced(false);
            $ASSIGN$SPECIAL$_currentIndex(0, 1);
            ArrayToken valuesArray = (ArrayToken)values.getToken();
            if (_currentIndex >= valuesArray.length()) {
                boolean repeatValue = ((BooleanToken)repeat.getToken()).booleanValue();
                if (repeatValue) {
                    $ASSIGN$_currentIndex(0);
                } else {
                    boolean holdLastOutputValue = ((BooleanToken)holdLastOutput.getToken()).booleanValue();
                    if (holdLastOutputValue) {
                        $ASSIGN$_currentIndex(valuesArray.length() - 1);
                    } else {
                        $ASSIGN$_currentIndex(valuesArray.length());
                    }
                }
            }
        }
        return super.postfire();
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.