Package ptolemy.actor

Examples of ptolemy.actor.Director


     *    permissible (e.g. the given time is in the past).
     */
    public void fireAt(Actor actor, Time time) throws IllegalActionException {
        Actor container = (Actor) getContainer();
        if (container != null) {
            Director executiveDirector = container.getExecutiveDirector();
            if (executiveDirector != null) {
                executiveDirector.fireAt(container, time);
            }
        }
    }
View Full Code Here


     *   throws it.
     */
    public void fireAtCurrentTime(Actor actor) throws IllegalActionException {
        Actor container = (Actor) getContainer();
        if (container != null) {
            Director executiveDirector = container.getExecutiveDirector();
            if (executiveDirector != null) {
                executiveDirector.fireAtCurrentTime(container);
            }
        }
    }
View Full Code Here

    class ButtonListener implements ActionListener {
        public void actionPerformed(ActionEvent event) {
            try {
                _buttonPressed = true;

                Director director = getDirector();

                // JDK1.2 bug: WallClockTime._getCurrentTime() is
                // protected, but not accessible here.
                // Note, WallClockTime._getCurrentTime() returns a double,
                // which we are going to compare against model time,
                // so we create a Time object that accounts for the
                // precision of the director.
                Time firingTime = new Time(director, _getCurrentTime());

                Time currentTime = director.getModelTime();

                if (firingTime.compareTo(currentTime) < 0) {
                    // This shouldn't happen, but it will prevent us
                    // from enqueuing events in the past
                    firingTime = currentTime;
                }

                director.fireAt(_self, firingTime);
            } catch (IllegalActionException ex) {
                // Should never happen
                throw new InternalErrorException(ex.getMessage());
            }
        }
View Full Code Here

                .doubleValue();

        if (speed == Double.POSITIVE_INFINITY) {
            super._transmitTo(token, sender, receiver, properties);
        } else {
            Director director = getDirector();

            // FIXME: This isn't right because the receiver
            // may have moved during propagation.  Maybe
            // register a ValueListener to the _location attributes
            // of the receiver actors, and continually recalculate
            // the correct arrival time for the message each time the
            // receiver location changes.  Even so, this will be
            // an approximation, and needs to be fully characterized.
            // Also, the receiver needs to be in range at the
            // conclusion of the propagation, whereas this method is
            // called only if the receiver is in range at the
            // initiation of the transmission.
            WirelessIOPort destination = (WirelessIOPort) receiver
                    .getContainer();
            double distance = _distanceBetween(sender, destination);
            Time time = director.getModelTime().add(distance / speed);

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

            Double timeDouble = Double.valueOf(time.getDoubleValue());
            Reception reception = new Reception();
            reception.token = token;
            reception.sender = sender;
            reception.receiver = receiver;
            reception.properties = properties;
            _receptions.put(timeDouble, reception);

            director.fireAt(this, time);
        }
    }
View Full Code Here

    public boolean postfire() throws IllegalActionException {
        _debug(getName() + " postfire.");
        _lastToken = input.get(0);

        if (((BooleanToken) print.getToken()).booleanValue()) {
            Director dir = getDirector();

            if (dir != null) {
                System.out.println(dir.getModelTime() + " "
                        + ((DoubleToken) _lastToken).doubleValue());
            }
        }

        return true;
View Full Code Here

    public void initialize(CompositeActor toplevel)
            throws IllegalActionException, NameDuplicationException {
        _toplevel = toplevel;

        // Applet codegen works with all directors, not just SDF.
        Director topLevelDirector = toplevel.getDirector();

        // FIXME: nearly duplicate code in java/TestApplication.java
        if ((topLevelDirector != null)
                && topLevelDirector instanceof SDFDirector) {
            SDFDirector director = (SDFDirector) topLevelDirector;
View Full Code Here

                                + " Found multiple refinements in: "
                                + currentState.getName());
            }

            TypedCompositeActor currentRefinement = (TypedCompositeActor) (currentRefinements[0]);
            Director refinementDir = currentRefinement.getDirector();

            if (refinementDir instanceof MultirateFSMDirector) {
                refinementDir.initialize();
            }

            /*boolean inputRateChanged = */
            _updateInputTokenConsumptionRates(currentRefinement);

View Full Code Here

                //_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();
                    }

                    RecordToken result2 = new RecordToken(labels, values2);
                    _receptions.put(timeDouble, result2);

                    director.fireAt(this, time.add(delayTime));
                }

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

        int inputRows = matrix.getRowCount();
        int inputColumns = matrix.getColumnCount();

        // If the director is an SDFDirector, check the dimensions
        // of the matrix.
        Director director = getDirector();

        if (director instanceof SDFDirector) {
            if ((inputRows * inputColumns) != (_rows * _columns)) {
                throw new IllegalActionException(this,
                        "Received a matrix whose dimension does not "
View Full Code Here

        // FIXME: This seems wrong.
        if (container instanceof CompositeActor) {
            // We need to check if the container is a CompositeActor
            // because the reference to SchedulePlotter in tmentities.xml
            // is not a CompositeActor
            Director director = ((CompositeActor) container).getDirector();

            if (!(director instanceof TMDirector)) {
                throw new IllegalActionException("Director '" + director
                        + "' is not a TMDirector, so adding a SchedulePlotter "
                        + "makes no sense");
View Full Code Here

TOP

Related Classes of ptolemy.actor.Director

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.