Package ptolemy.data

Examples of ptolemy.data.IntToken


        offsets = new Parameter(this, "offsets");
        offsets.setExpression("{0.0, 1.0}");
        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


                $ASSIGN$SPECIAL$_latestCount(12, _latestCount);
                $ASSIGN$_consumed(true);
            }
        }
        if (_consumed) {
            Token out = new IntToken(_latestCount);
            output.send(0, out);
        }
    }
View Full Code Here

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

            if (_latestSum == null) {
                $ASSIGN$_latestSum(in);
            } else {
                $ASSIGN$_latestSum(_latestSum.add(in));
            }
            Token out = _latestSum.divide(new IntToken(_latestCount));
            output.broadcast(out);
        }
    }
View Full Code Here

     * @exception NameDuplicationException If the container already has an
     * actor with this name.
     */
    public Recorder(CompositeEntity container, String name) throws NameDuplicationException, IllegalActionException  {
        super(container, name);
        capacity = new Parameter(this, "capacity", new IntToken(-1));
        capacity.setTypeEquals(BaseType.INT);
    }
View Full Code Here

    public Distributor(CompositeEntity container, String name) throws NameDuplicationException, IllegalActionException  {
        super(container, name);
        blockSize = new Parameter(this, "blockSize");
        blockSize.setTypeEquals(BaseType.INT);
        blockSize.setExpression("1");
        input_tokenConsumptionRate = new Parameter(input, "tokenConsumptionRate", new IntToken(0));
        input_tokenConsumptionRate.setVisibility(Settable.NOT_EDITABLE);
        input_tokenConsumptionRate.setTypeEquals(BaseType.INT);
        input_tokenConsumptionRate.setPersistent(false);
        output_tokenProductionRate = new Parameter(output, "tokenProductionRate");
        output_tokenProductionRate.setVisibility(Settable.NOT_EDITABLE);
View Full Code Here

                _addPoint(curValue);
            }
        }
        Token[] values = new Token[_bins.length];
        for (int i = 0; i < _bins.length; i++) {
            values[i] = new IntToken(_bins[i]);
        }
        output.send(0, new ArrayToken(BaseType.INT, values));
    }
View Full Code Here

                    }
                    if ((indata < dipThreshold) && (localMax > squelchValue)) {
                        if (_debugging) {
                            _debug("** Found a peak with value " + localMax+" at index "+localMaxIndex);
                        }
                        resultIndices.add(new IntToken(localMaxIndex));
                        resultPeaks.add(new DoubleToken(localMax));
                        if (resultPeaks.size() > maxPeaks) {
                            break;
                        }
                        localMin = indata;
View Full Code Here

        attributeChanged(indexes);
        values = new Parameter(this, "values");
        values.setExpression("{1.0, 0.0}");
        values.setTypeEquals(new ArrayType(BaseType.DOUBLE));
        int defOrder = _interpolation.getOrder();
        IntToken defOrderToken = new IntToken(defOrder);
        order = new Parameter(this, "order", defOrderToken);
        order.setTypeEquals(BaseType.INT);
        int defPeriod = _interpolation.getPeriod();
        IntToken defPeriodToken = new IntToken(defPeriod);
        period = new Parameter(this, "period", defPeriodToken);
        period.setTypeEquals(BaseType.INT);
        output.setTypeEquals(BaseType.DOUBLE);
    }
View Full Code Here

                _model = null;
                _manager = null;
                _throwable = null;
            }
        } else if (attribute == maxOutputLength) {
            IntToken length = (IntToken) maxOutputLength.getToken();

            if (length.intValue() > 0) {
                _outputLength = length.intValue();
            } else {
                throw new IllegalActionException(this,
                        "output array length is less than or equal 0?!");
            }
        } else {
View Full Code Here

TOP

Related Classes of ptolemy.data.IntToken

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.