Package ptolemy.data

Examples of ptolemy.data.DoubleToken


     * @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException  {
        super.fire();
        if (input.hasToken(0)) {
            DoubleToken inputValue = (DoubleToken)input.get(0);
            double k;
            int M = _backward.length - 1;
            $ASSIGN$_forwardCache(0, inputValue.doubleValue());
            for (int i = 1; i <= M; i++) {
                k = _reflectionCoefs[M - i];
                $ASSIGN$_forwardCache(i, (k * _backwardCache[i]) + _forwardCache[i - 1]);
            }
            output.broadcast(new DoubleToken(_forwardCache[M]));
            for (int i = 1; i < M; i++) {
                k = -_reflectionCoefs[M - 1-i];
                $ASSIGN$_backwardCache(i, _backwardCache[i + 1] + (k * _forwardCache[i + 1]));
            }
            $ASSIGN$_backwardCache(M, _forwardCache[M]);
View Full Code Here


     * actor with this name.
     */
    public SequentialClock(CompositeEntity container, String name) throws NameDuplicationException, IllegalActionException  {
        super(container, name);
        output = new TypedIOPort(this, "output", false, true);
        period = new Parameter(this, "period", new DoubleToken(2.0));
        period.setTypeEquals(BaseType.DOUBLE);
        offsets = new Parameter(this, "offsets");
        offsets.setExpression("{0.0, 1.0}");
        offsets.setTypeEquals(new ArrayType(BaseType.DOUBLE));
        attributeChanged(offsets);
View Full Code Here

     * @exception IllegalActionException If there's no director.
     */
    public void fire() throws IllegalActionException  {
        super.fire();
        for (int i = 0; i < _dataSize; i++) {
            output.send(i, new DoubleToken(_data[i]));
        }
    }
View Full Code Here

                if (typ.equals("boolean")) {
                    port.send(0, new BooleanToken(((Boolean) ret)
                            .booleanValue()));
                } else if (typ.equals("double")) {
                    port.send(0, new DoubleToken(((Double) ret).doubleValue()));
                } else if (typ.equals("int")) {
                    port.send(0, new IntToken(((Integer) ret).intValue()));
                } else if (typ.equals("char")) {
                    port.send(0,
                            new UnsignedByteToken(((Byte) ret).byteValue()));
                } else {
                    System.out.println("The return type is not convertible "
                            + "with Ptolemy II types.");
                }
            }
            //if the argument is output
            else if ((port != null)
                    && port.isOutput()
                    && (port.getName() != null)
                    && (getArgumentReturn() != null)
                    && !(port.getName().equals(this.getArgumentReturn()
                            .getName()))) {
                String typ = "";
                Field field = null;

                try {
                    field = _class.getDeclaredField("_" + port.getName());
                    typ = field.getType().toString();
                } catch (NoSuchFieldException ex) {
                    try {
                        field = _class.getDeclaredField("_"
                                + port.getName().substring(0,
                                        port.getName().length() - 3));
                        typ = field.getType().toString();
                    } catch (Throwable throwable) {
                        try {
                            throw new IllegalActionException(this, throwable,
                                    "No '+" + port.getName() + "' field !");
                        } catch (Throwable throwable2) {
                            getDirector().stop();
                        }
                    }
                }

                if (field == null) {
                    throw new InternalErrorException("Field '" + port.getName()
                            + "' in '" + _class + "' is null?");
                } else {
                    if (typ.equals("boolean")) {
                        try {
                            port.send(0,
                                    new BooleanToken(field.getBoolean(obj)));
                        } catch (IllegalAccessException ex) {
                            throw new IllegalActionException(this, ex, "Type '"
                                    + typ + "' is not castable");
                        }
                    } else if (typ.equals("double")) {
                        try {
                            port.send(0, new DoubleToken(field.getDouble(obj)));
                        } catch (IllegalAccessException ex) {
                            throw new IllegalActionException(this, ex, "Type '"
                                    + typ + "' is not castable");
                        }
                    } else if (typ.equals("int")) {
                        try {
                            port.send(0, new IntToken(field.getInt(obj)));
                        } catch (IllegalAccessException ex) {
                            throw new IllegalActionException(this, ex, "Type '"
                                    + typ + "' is not castable");
                        }
                    } else if (typ.equals("char")) {
                        try {
                            port.send(0, new UnsignedByteToken(field
                                    .getChar(obj)));
                        } catch (IllegalAccessException ex) {
                            throw new IllegalActionException(this, ex, "Type '"
                                    + typ + "' is not castable");
                        }
                    } else if (typ.equals("class [I")) {
                        try {
                            if (field == null) {
                                throw new InternalErrorException(
                                        "field == null?");
                            }
                            if (obj == null) {
                                throw new InternalErrorException("obj == null?");
                            }
                            if (field.get(obj) == null) {
                                throw new InternalErrorException(
                                        "field.get(obj)  == null? (field = "
                                                + field + " obj = " + obj);
                            }
                            Token[] toks = new Token[((int[]) field.get(obj)).length];

                            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) {
View Full Code Here

            if (phaseChange > Math.PI) {
                phaseChange -= (2 * Math.PI);
            }
            $ASSIGN$_tempPreviousPhaseOutput(_previousPhaseOutput + phaseChange);
            $ASSIGN$_tempPreviousPhaseInput(newPhase);
            output.send(0, new DoubleToken(_tempPreviousPhaseOutput));
        }
    }
View Full Code Here

                    newCoefficient = 1.0;
                } else if (newCoefficient < -1.0) {
                    newCoefficient = -1.0;
                }
            }
            outputArray[i - 1] = new DoubleToken(newCoefficient);
            $ASSIGN$_reflectionCoefficientsCache(i - 1, newCoefficient);
            $ASSIGN$_estimatedErrorPowerCache(i, newError);
        }
        adaptedReflectionCoefficients.send(0, new ArrayToken(BaseType.DOUBLE, outputArray));
    }
View Full Code Here

     * actor with this name.
     */
    public Gaussian(CompositeEntity container, String name) throws NameDuplicationException, IllegalActionException  {
        super(container, name);
        output.setTypeEquals(BaseType.DOUBLE);
        mean = new PortParameter(this, "mean", new DoubleToken(0.0));
        mean.setTypeEquals(BaseType.DOUBLE);
        standardDeviation = new PortParameter(this, "standardDeviation");
        standardDeviation.setExpression("1.0");
        standardDeviation.setTypeEquals(BaseType.DOUBLE);
    }
View Full Code Here

     */
    public void fire() throws IllegalActionException  {
        super.fire();
        mean.update();
        standardDeviation.update();
        output.send(0, new DoubleToken(_current));
    }
View Full Code Here

        $ASSIGN$_bins(new int[_numberOfBins]);
        inputCount.update();
        int count = ((IntToken)inputCount.getToken()).intValue();
        for (int i = 0; i < count; i++) {
            if (input.hasToken(0)) {
                DoubleToken curToken = (DoubleToken)input.get(0);
                double curValue = curToken.doubleValue();
                _addPoint(curValue);
            }
        }
        Token[] values = new Token[_bins.length];
        for (int i = 0; i < _bins.length; i++) {
View Full Code Here

        super(container, name);
        input.setTypeEquals(BaseType.DOUBLE);
        output.setTypeEquals(BaseType.DOUBLE);
        inputIsPower = new Parameter(this, "inputIsPower", new BooleanToken(false));
        inputIsPower.setTypeEquals(BaseType.BOOLEAN);
        min = new Parameter(this, "min", new DoubleToken(-100.0));
        min.setTypeEquals(BaseType.DOUBLE);
    }
View Full Code Here

TOP

Related Classes of ptolemy.data.DoubleToken

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.