Package ptolemy.data

Examples of ptolemy.data.IntToken


        super.fire();
        int j;
        _blocks = input.get(0, _blockCount);

        for (j = 0; j < _blockCount; j++) {
            _codewords[j] = new IntToken(_encode(IntegerMatrixMath
                    .fromMatrixToArray(((IntMatrixToken) _blocks[j])
                            .intMatrix()), _blockWidth * _blockHeight));
        }

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


                }

                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

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////
    private void _init() throws IllegalActionException,
            NameDuplicationException {
        initialQueueCapacity = new Parameter(this, "initialQueueCapacity",
                new IntToken(1));
        initialQueueCapacity.setTypeEquals(BaseType.INT);

        maximumQueueCapacity = new Parameter(this, "maximumQueueCapacity",
                new IntToken(65536));
        maximumQueueCapacity.setTypeEquals(BaseType.INT);
    }
View Full Code Here

    public Repeat(CompositeEntity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);

        // parameters
        numberOfTimes = new Parameter(this, "numberOfTimes", new IntToken(2));
        numberOfTimes.setTypeEquals(BaseType.INT);

        blockSize = new Parameter(this, "blockSize", new IntToken(1));
        blockSize.setTypeEquals(BaseType.INT);

        input_tokenConsumptionRate.setExpression("blockSize");
        output_tokenProductionRate.setExpression("numberOfTimes*blockSize");
    }
View Full Code Here

    public Torus3D(CompositeEntity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        angleSpan = new Parameter(this, "angleSpan", new DoubleToken(
                2 * Math.PI));
        slices = new Parameter(this, "slices", new IntToken(28));
        crossSectionRadius = new Parameter(this, "crossSectionRadius",
                new DoubleToken(0.15));
        hullRadius = new Parameter(this, "hullRadius", new DoubleToken(0.75));
    }
View Full Code Here

            if (getName().equals(destination)) {
                // Change the color of the icon to red.
                _circle2.fillColor.setToken("{1.0, 0.0, 0.1, 0.7}");

                //_isRed = true;
                test.send(0, new IntToken(hops + 1));

                //Call fireAt to set the color back to white after the delay time.
                Director director = getDirector();
                double delayTime = ((DoubleToken) delay.getToken())
                        .doubleValue();
                Time time = director.getModelTime().add(delayTime);
                director.fireAt(this, time);
            } else if (getName().equals(routeTo) || (hops == 0)) {
                // Change the color of the icon to green.
                _circle2.fillColor.setToken("{0.0, 1.0, 0.0, 1.0}");

                CompositeEntity container = (CompositeEntity) getContainer();
                Entity destNode = container.getEntity(destination);
                Locatable destLocation = (Locatable) destNode.getAttribute(
                        "_location", Locatable.class);
                Locatable myLocation = (Locatable) this.getAttribute(
                        "_location", Locatable.class);

                if ((destLocation == null) || (myLocation == null)) {
                    throw new IllegalActionException(
                            "Cannot determine location for node "
                                    + destNode.getName() + ".");
                }

                Iterator nodes = _connectedNodes.iterator();
                double minDistance = _distanceBetween(destLocation, myLocation);
                String to = " ";
                boolean multi = ((BooleanToken) doublePath.getToken())
                        .booleanValue();
                double nextMinDistance = _distanceBetween(destLocation,
                        myLocation);
                String to2 = " ";

                while (nodes.hasNext()) {
                    Entity node = (Entity) nodes.next();
                    Locatable location = (Locatable) node.getAttribute(
                            "_location", Locatable.class);

                    if (location == null) {
                        throw new IllegalActionException(
                                "Cannot determine location for node "
                                        + node.getName() + ".");
                    }

                    double d = _distanceBetween(destLocation, location);

                    if (multi) {
                        if (d < minDistance) {
                            nextMinDistance = minDistance;
                            to2 = to;
                            minDistance = d;
                            to = node.getName();
                        } else if (d < nextMinDistance) {
                            nextMinDistance = d;
                            to2 = node.getName();
                        }
                    } else {
                        if (d < minDistance) {
                            minDistance = d;
                            to = node.getName();
                        }
                    }
                }

                // Request refiring after a certain amount of time specified
                // by the <i>delay<i> parameter.
                Director director = getDirector();
                Token[] values = { new DoubleToken(data),
                        new StringToken(destination), new StringToken(to),
                        new IntToken(hops + 1) };
                double delayTime = ((DoubleToken) delay.getToken())
                        .doubleValue();
                Time time = director.getModelTime().add(delayTime);

                if (_receptions == null) {
                    _receptions = new HashMap();
                }

                Double timeDouble = Double.valueOf(time.getDoubleValue());
                String[] labels = { "data", "destination", "routeTo", "hops" };
                RecordToken result = new RecordToken(labels, values);
                _receptions.put(timeDouble, result);

                director.fireAt(this, time);

                if (multi) {
                    Token[] values2 = { new DoubleToken(data),
                            new StringToken(destination), new StringToken(to2),
                            new IntToken(hops + 1) };

                    if (_receptions == null) {
                        _receptions = new HashMap();
                    }
View Full Code Here

     *  an invalid value or if the super method throws it.
     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == interpolation) {
            IntToken token = (IntToken) (interpolation.getToken());
            _interpolationValue = token.intValue();

            if (_interpolationValue <= 0) {
                throw new IllegalActionException(this,
                        "Invalid interpolation: " + _interpolationValue
                                + ". Must be positive.");
            }

            _reinitializeNeeded = true;
        } else if (attribute == decimation) {
            IntToken token = (IntToken) (decimation.getToken());
            _decimationValue = token.intValue();

            if (_decimationValue <= 0) {
                throw new IllegalActionException(this, "Invalid decimation: "
                        + _decimationValue + ". Must be positive.");
            }

            _reinitializeNeeded = true;
        } else if (attribute == decimationPhase) {
            IntToken token = (IntToken) (decimationPhase.getToken());
            _decimationPhaseValue = token.intValue();

            if (_decimationPhaseValue < 0) {
                throw new IllegalActionException(this,
                        "Invalid decimationPhase: " + _decimationPhaseValue
                                + ". Must be nonnegative.");
View Full Code Here

            throw new InternalErrorException(this, ex,
                    "Could not create Default scheduler.");
        }

        try {
            iterations = new Parameter(this, "iterations", new IntToken(0));
            iterations.setTypeEquals(BaseType.INT);
            iterationTimeLowerBound = new Parameter(this,
                    "iterationTimeLowerBound", new IntToken(33));
            iterationTimeLowerBound.setTypeEquals(BaseType.INT);
        } catch (Throwable throwable) {
            throw new InternalErrorException(this, throwable,
                    "Cannot create default iterations parameter.");
        }
View Full Code Here

            //        " next message " + "scheduled at " + _nextMsgTime);
        }

        if (now.compareTo(_nextMsgTime) == 0) {
            ++_msgNum;
            output.broadcast(new IntToken(_msgNum));
        } else {
            // this refire should be discarded
            return;
        }
    }
View Full Code Here

        super(container, name);

        input_tokenConsumptionRate.setExpression("numberOfInputs");

        numberOfInputs = new Parameter(this, "numberOfInputs",
                new IntToken(256));
        numberOfInputs.setTypeEquals(BaseType.INT);

        numberOfLags = new Parameter(this, "numberOfLags", new IntToken(64));
        numberOfLags.setTypeEquals(BaseType.INT);

        biased = new Parameter(this, "biased", new BooleanToken(false));
        biased.setTypeEquals(BaseType.BOOLEAN);
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.