Package ptolemy.actor

Examples of ptolemy.actor.Director


     @return True if it is OK to fire.
     */
    private boolean _prefireWithEnclosingNonContinuousDirector()
            throws IllegalActionException {
        CompositeActor container = (CompositeActor) getContainer();
        Director executiveDirector = ((Actor) container).getExecutiveDirector();

        // Check the enclosing model time against the local model time.
        Time outTime = executiveDirector.getModelTime();
        int comparison = _currentTime.compareTo(outTime);
        if (comparison > 0) {
            // Local current time exceeds that of the environment.
            // We need to roll back. Make sure this is allowable.
            if (!_commitIsPending) {
                throw new IllegalActionException(this, "The model time of "
                        + container.getFullName()
                        + " is greater than the environment time. "
                        + "Environment: " + outTime
                        + ", the model time (iteration begin time): "
                        + _currentTime);
            }
            // If we get here, local time exceeds the environment time
            // and we have speculatively executed up to that local time.
            // But now, we cannot commit that execution because an unexpected
            // event has occurred.  Instead, we have to re-do the integration
            // with a smaller step size that brings us up to the current
            // environment time.
            // NOTE: This depends on the property that if an integration
            // step with a larger step size was successful and produced
            // no events, then an integration step with this now smaller
            // step size will also be successful and produce no events.
            _currentStepSize = outTime.subtract(_iterationBeginTime)
                    .getDoubleValue();
            // If the step size is now negative, then we are trying
            // to roll back too far.
            if (_currentStepSize < 0.0) {
                throw new IllegalActionException(this,
                        "Attempting to roll back time from "
                                + _iterationBeginTime + " to " + outTime
                                + ", but state has been committed.");
            }
            rollBackToCommittedState();
            fire();
            // It is safe to commit if we assume that the environment
            // will not roll back time, and that it is not iterating to
            // a fixed point. FIXME: Is this assumption right?
            // If the enclosing director is a FixedPointDirector,
            // there may inputs that are unknown! Perhaps the composite
            // actor prefire() returns false if there unknown inputs?
            _commit();
            _commitIsPending = false;
        } else if (comparison == 0 && _commitIsPending) {
            // If we have a pending commit and current time matches the environment
            // time, then perform the commit now.
            _commitIsPending = false;
            boolean result = _commit();
            if (result == false) {
                // The commit returned false, which means that either all
                // actors return false in postfire or if we have reached the
                // stop time. In this case, we should not execute further,
                // so prefire() should return false.
                // FIXME: Actually, postfire() should return false.
                // Also, why do the other branches of the if ignore
                // the return value of _commit()?
                return false;
            }
        } else if (comparison < 0
                && executiveDirector != _enclosingContinuousDirector()) {
            // Local current time is behind environment time, so
            // We must be inside a modal model and have been
            // disabled at the time that the commit
            // would be effective. Cancel any pending commit.
            if (_commitIsPending) {
                _commitIsPending = false;
                rollBackToCommittedState();
            }
            // Force current time to match the environment time, and treat
            // this as if were were starting again in initialize().
            // This ensures that actors like plotters will be postfired at
            // the current time.
            // FIXME: How do we know that that time matches the
            // time at which the commit occurred?
            // Shouldn't this be checked?
            _currentTime = outTime;
            if (_debugging) {
                _debug("----- Setting current time to match enclosing non-ContinuousDirector: "
                        + _currentTime);
            }
            _currentStepSize = 0.0;
        }

        // Adjust the step size to
        // make sure the time does not exceed the next iteration
        // time of the environment during this next integration step.
        Time environmentNextIterationTime = executiveDirector
                .getModelNextIterationTime();
        Time localTargetTime = _iterationBeginTime.add(_currentStepSize);
        if (environmentNextIterationTime.compareTo(localTargetTime) < 0) {
            _currentStepSize = environmentNextIterationTime.subtract(
                    _currentTime).getDoubleValue();
View Full Code Here


                if (actor instanceof ContinuousStatefulComponent) {
                    _statefulComponents.add(actor);
                } else if ((actor instanceof CompositeActor)
                        && ((CompositeEntity) actor).isOpaque()
                        && !((CompositeEntity) actor).isAtomic()) {
                    Director director = ((Actor) actor).getDirector();
                    if (director instanceof ContinuousStatefulComponent) {
                        _statefulComponents.add(director);
                    }
                }
            }
View Full Code Here

                if (actor instanceof ContinuousStepSizeController) {
                    _stepSizeControllers.add(actor);
                } else if ((actor instanceof CompositeActor)
                        && ((CompositeEntity) actor).isOpaque()
                        && !((CompositeEntity) actor).isAtomic()) {
                    Director director = ((Actor) actor).getDirector();
                    if (director instanceof ContinuousStepSizeController) {
                        _stepSizeControllers.add(director);
                    }
                }
            }
View Full Code Here

                // always contains a MicaCompositeActor
                ComponentEntity micaCompositeActor = ((CompositeEntity) wirelessNode)
                        .getEntity("MicaCompositeActor");
                if (micaCompositeActor instanceof MicaCompositeActor) {
                    // Get the director of the MicaCompositeActor.
                    Director director = ((MicaCompositeActor) micaCompositeActor)
                            .getDirector();
                    if (director instanceof PtinyOSDirector) {
                        Attribute nodeID = director.getAttribute("nodeID");
                        if (nodeID instanceof PtinyOSNodeParameter) {
                            // Get the token that stores the node ID.
                            try {
                                Token nodeIDToken = ((PtinyOSNodeParameter) nodeID)
                                        .getToken();
View Full Code Here

    private void _requestInitialization() {
        // Set this composite to opaque.
        _opaque = true;

        // Request for initialization.
        Director dir = getDirector();

        if (dir != null) {
            dir.requestInitialization(this);
        }
    }
View Full Code Here

     @exception TerminateProcessException If the process termination
     *   is requested by the director.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        Director director = getDirector();
        if (!(director instanceof RendezvousDirector)) {
            throw new IllegalActionException(this,
                    "Barrier can only be used with RendezvousDirector.");
        }
        if (_debugging) {
View Full Code Here

            // Assumes that we already checked in preinitialize() that the
            // container is a CompositeActor.
            CompositeActor container = (CompositeActor) getContainer();

            // Get the executive director.  If there is none, use this instead.
            Director director = container.getExecutiveDirector();

            if (director == null) {
                director = this;
            }

            Time t = new Time(director, Long.parseLong(newTime));
            director.fireAt(container, t);
        } catch (Exception ex) {
            // We use MessageHandler instead of throwing an exception
            // because this method is called from C.
            // MessageHandler.error() will pop up a window with the
            // exception description and stack trace, and after the
View Full Code Here

     */
    private long _getModelTimeAsLongValue() {
        CompositeActor container = (CompositeActor) getContainer();

        // Get the executive director.  If there is none, use this instead.
        Director director = container.getExecutiveDirector();
        if (director == null) {
            director = this;
        }

        // Get the current model time.
        long currentTimeValue = 0;
        Time currentTime = director.getModelTime();
        if (currentTime != null) {
            // NOTE: this could overflow.
            currentTimeValue = currentTime.getLongValue();
        }
        return currentTimeValue;
View Full Code Here

    // FIXME rename?
    private boolean _isTopLevelNC() {
        NamedObj container = getContainer();

        if (container instanceof CompositeActor) {
            Director director = ((CompositeActor) container)
                    .getExecutiveDirector();

            if (director instanceof PtinyOSDirector) {
                return false;
            } else {
View Full Code Here

    private NamedObj _toplevelNC() {
        if (!_isTopLevelNC()) {
            NamedObj container = getContainer();

            if (container instanceof CompositeActor) {
                Director director = ((CompositeActor) container)
                        .getExecutiveDirector();

                if (director instanceof PtinyOSDirector) {
                    return ((PtinyOSDirector) director)._toplevelNC();
                }
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.