Package ptolemy.data

Examples of ptolemy.data.RecordToken


        }

        // FIXME: Should use return value to determine what postfire() returns?
        _executeInsideModel();

        RecordToken result = (RecordToken) properties.getToken();

        if (_debugging) {
            _debug("---- the modified property value is. " + result.toString());
        }

        return result;
    }
View Full Code Here


     */
    public RecordToken transformProperties(RecordToken properties,
            WirelessIOPort sender, WirelessIOPort destination)
            throws IllegalActionException {

        RecordToken newProperties = properties;
        double[] p1 = _locationOf(sender);
        double[] p2 = _locationOf(destination);
        double depth = _polygonDepthBetweenPorts(p1, p2);

        if (depth > 0.0) {
            Token transmitPower = properties.get("power");
            double currentPower = ((DoubleToken) transmitPower).doubleValue();
            double multiplier = 0.0;
            // Avoid divide by zero, though in theory it's OK.
            if (_attenuation > 0.0) {
                multiplier = Math.exp((Math.log(0.5) / _attenuation) * depth);
            }

            // Create a record token with the receive power.
            String[] names = { "power" };
            Token[] values = { new DoubleToken(currentPower * multiplier) };
            RecordToken newPower = new RecordToken(names, values);

            // Merge the receive power into the merged token.
            newProperties = RecordToken.merge(newPower, properties);
        }
        return newProperties;
View Full Code Here

            }

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

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

            }
        }

        if (!rangeIsSet) {
            // Type constraints in the constructor make the casts safe.
            RecordToken defaultPropertiesValue = (RecordToken) defaultProperties
                    .getToken();

            // Type of the field must be convertible to double, but
            // need not actually be a double.
            ScalarToken field = (ScalarToken) defaultPropertiesValue
                    .get("range");
            range = field.doubleValue();
        }

        boolean result = (_distanceBetween(source, destination) <= range);
View Full Code Here

     */
    public void fire() throws IllegalActionException {
        super.fire();

        while (input.hasToken(0)) {
            RecordToken recordToken = (RecordToken) input.get(0);

            ArrayToken locationArray = (ArrayToken) recordToken.get("location");

            if (locationArray.length() < 2) {
                throw new IllegalActionException(this,
                        "Input is malformed: location field does not "
                                + "have two entries.");
            }

            double locationX = ((DoubleToken) locationArray.getElement(0))
                    .doubleValue();
            double locationY = ((DoubleToken) locationArray.getElement(1))
                    .doubleValue();

            double time = ((DoubleToken) recordToken.get("time")).doubleValue();

            // First check whether the location matches one already in the
            // buffer.  At the same time, identify the entry with the
            // oldest time and the newest time.
            boolean foundMatch = false;
View Full Code Here

    public void fire() throws IllegalActionException {
        super.fire();

        if (update.getWidth() > 0) {
            if (update.hasToken(0)) {
                RecordToken updateMsg = (RecordToken) update.get(0);
                _parkingManager.update(updateMsg);
                debug.send(0, updateMsg);

                if ((_parkingManager.getAvailable().size() == 0) && !_isFull) {
                    _isFull = true;
View Full Code Here

            ylocation.send(0, new DoubleToken(_myLocation[1] + _speed[1]));
        }

        if (input.hasToken(0)) {
            //receive message for updating the spanning tree.
            RecordToken inputToken = (RecordToken) input.get(0);

            if (_debugging) {
                _debug("message token received: ");
            }

            DoubleToken time = (DoubleToken) inputToken.get("time");
            IntToken d = (IntToken) inputToken.get("depth");

            if ((time.doubleValue() > _timeValue)
                    || ((time.doubleValue() == _timeValue) && (d.intValue() < _parentDepth))) {
                //the root node may have been changed
                //or there is a shorter path.
                ArrayToken locationArray = (ArrayToken) inputToken
                        .get("location");
                int length = locationArray.length();
                _parentLocation = new double[length];

                for (int i = 0; i < length; i++) {
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);
                }
            }
        }

        if (input.hasToken(0)) {
            //receive message for updating the spanning tree.
            RecordToken inputToken = (RecordToken) input.get(0);

            if (_debugging) {
                _debug("message token received: ");
            }

            DoubleToken time = (DoubleToken) inputToken.get("time");
            IntToken d = (IntToken) inputToken.get("depth");

            if ((time.doubleValue() > _timeValue)
                    || ((time.doubleValue() == _timeValue) && (d.intValue() < _parentDepth))) {
                //the root node may have been changed
                //or there is a shorter path.
                ArrayToken locationArray = (ArrayToken) inputToken
                        .get("location");
                int length = locationArray.length();
                _parentLocation = new DoubleToken[length];

                for (int i = 0; i < length; i++) {
                    _parentLocation[i] = (DoubleToken) locationArray
                            .getElement(i);
                }

                _timeValue = time.doubleValue();
                _parentDepth = d.intValue();

                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

                        }
                        _tableaus[i] = tableau;

                        JFrame frame = tableau.getFrame();
                        // Compute location of the new frame.
                        RecordToken location =
                            (RecordToken) screenLocation.getToken();
                        int x = ((IntToken) location.get("x")).intValue();
                        int y = ((IntToken) location.get("y")).intValue();
                        Point newLocation = frame.getLocation();
                        if (x >= 0) {
                            newLocation.x = x;
                        }
                        if (y >= 0) {
View Full Code Here

                                    + fieldNames[k] + "from matlab "
                                    + "struct " + nRows + "x" + nCols);
                        }
                    }

                    ta[m] = new RecordToken(fieldNames, fieldValues);
                }

                tr[n] = new ArrayToken(ta);
            }
View Full Code Here

TOP

Related Classes of ptolemy.data.RecordToken

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.