Package ptolemy.actor.util

Examples of ptolemy.actor.util.Time


     @deprecated As of Ptolemy 4.1, replaced by
     *  {@link #setModelTime}
     @see #getCurrentTime()
     */
    public void setCurrentTime(double newTime) throws IllegalActionException {
        setModelTime(new Time(this, newTime));
    }
View Full Code Here


            // Since by default directors have no time, this is
            // invisible.
            timeResolution.setVisibility(Settable.NONE);

            // Make sure getCurrentTime() never returns null.
            _currentTime = new Time(this, Double.NEGATIVE_INFINITY);
        } catch (Throwable throwable) {
            // This is the only place to create
            // the timeResolution parameter, no exception should ever
            // be thrown.
View Full Code Here

     */
    protected synchronized boolean _resolveInternalDeadlock()
            throws IllegalActionException {
        if (_actorsDelayed > 0) {
            // Time deadlock.
            Time nextTime = _getNextTime();
            setModelTime(nextTime);

            // Now go through list of delayed actors
            // and wake up those at this time
            boolean done = false;
View Full Code Here

            // synchronize the local time with the outside time.
            CompositeActor container = (CompositeActor) getContainer();
            Director executiveDirector = container.getExecutiveDirector();
            _outsideTime = executiveDirector.getModelTime();

            Time localTime = getModelTime();
            // As an optimization, we try to keep the step size
            // bounded by the time to the next event in the
            // enclosing model.
            Time outsideNextIterationTime = executiveDirector
                    .getModelNextIterationTime();

            if (_debugging) {
                _debug("The current time of outside model is " + _outsideTime,
                        " and its next iteration time is "
                                + outsideNextIterationTime,
                        "\nThe current time of this director is " + localTime);
            }

            // Now, check the next iteration time.
            if (outsideNextIterationTime.compareTo(_outsideTime) < 0) {
                // NOTE: This check is redundant. The outside director should
                // guarantee that this never happen.
                throw new IllegalActionException(this, "Outside domain"
                        + " time is going backward."
                        + " Current outside time = " + _outsideTime
                        + ", but the next iteration time = "
                        + outsideNextIterationTime);
            }

            double aheadLength = _runAheadLength;

            // Ideally, the outside time should equal the local time.
            // If the outside time is less than the local time, then rollback
            // is needed. If the outside time is greater than the local time,
            // an exception will be thrown.
            if (_outsideTime.compareTo(localTime) > 0) {
                throw new IllegalActionException(this, executiveDirector,
                        "Outside time is later than the local time. "
                                + "This should never happen.");
            } else if (_outsideTime.compareTo(localTime) < 0) {
                // Outside time less than the local time. Rollback!
                // NOTE: This can happen, for example, if the CT model is
                // inside a DE model, and it has advanced its time too
                // far into the future. For example, if it was previously
                // fired at time 0.0 and it advanced its local time
                // to 0.1, but later it gets fired again at time 0.05.
                // In that case, it has to restart the integration
                // from time 0.0 and ensure that it doesn't progress
                // its local time past 0.05.
                // An example is to have two interacting CT subsystems
                // embedded inside a DE model, where one system (called A)
                // produces an event at time 0.1 and the other one (called B)
                // produces an event at time 0.05. A may integrate with a step
                // size of 0.1 but it has to roll back and use a step size 0.05
                // such that the event produced by B can be handled.
                if (_debugging) {
                    _debug(getName() + " rollback from: " + localTime + " to: "
                            + _knownGoodTime + "due to outside time "
                            + _outsideTime);
                }

                // The local time is set backwards to a known good time.
                _rollback();

                aheadLength = _outsideTime.subtract(getModelTime())
                        .getDoubleValue();

            } else {
                aheadLength = outsideNextIterationTime.subtract(_outsideTime)
                        .getDoubleValue();
            }

            if (_debugging) {
                _debug(getName(), " local time = " + localTime,
View Full Code Here

                    DDEReceiver rcvr = (DDEReceiver) rcvrs[i][j];

                    if (_oneArg) {
                        rcvr.put(_tokens[cnt]);
                    } else {
                        rcvr.put(_tokens[cnt], new Time(getDirector(),
                                _times[cnt]));
                    }
                }
            }
View Full Code Here

    protected void _advanceModelTime() throws IllegalActionException {
        CTDirector director = (CTDirector) getContainer();
        // NOTE: why is the current model time changed here?
        // Some state transition actors may be some functions
        // defined on the current time, such as the CurrentTime actor.
        Time iterationBeginTime = director.getIterationBeginTime();
        double currentStepSize = director.getCurrentStepSize();
        director.setModelTime(iterationBeginTime.add(currentStepSize
                * _timeInc[_getRoundCount()]));
    }
View Full Code Here

    protected void _advanceModelTime() throws IllegalActionException {
        CTDirector director = (CTDirector) getContainer();
        // NOTE: why is the current model time changed here?
        // Some state transition actors may be some functions
        // defined on the current time, such as the CurrentTime actor.
        Time iterationBeginTime = director.getIterationBeginTime();
        double currentStepSize = director.getCurrentStepSize();
        director.setModelTime(iterationBeginTime.add(currentStepSize
                * _timeInc[_getRoundCount()]));
    }
View Full Code Here

                    // right value. Only if the _phase is zero is this an
                    // issue, since in that case, the cycleStartTime has
                    // been updated to the start of the new cycle, which
                    // is too far in the future.
                    if (_phase == 0 && _firstOutputProduced) {
                        Time potentialNextOutputTime = _tentativeCycleStartTime
                                .subtract(_previousPeriod).add(periodValue);
                        if (potentialNextOutputTime.compareTo(getDirector()
                                .getModelTime()) >= 0) {
                            _tentativeNextOutputTime = potentialNextOutputTime;
                            _tentativeCycleStartTime = potentialNextOutputTime;
                            // If this occurs outside fire(), e.g. in a modal
                            // model state transition, we also need to set the _cycleStartTime
View Full Code Here

     *   than the period, or if there is no director.
     */
    public void fire() throws IllegalActionException {
        // Cannot call super.fire() because it consumes
        // trigger inputs.
        Time currentTime = getDirector().getModelTime();
        if (_debugging) {
            _debug("Called fire() at time " + currentTime);
        }

        // Use the strategy pattern here so that derived classes can
View Full Code Here

     *  with this _tentativeNextOutputTime. If _tentativeNextOutputTime
     *  is already equal to or greater than current time, then do nothing.
     *  @exception IllegalActionException If the period is invalid.
     */
    protected void _catchUp() throws IllegalActionException {
        Time currentTime = getDirector().getModelTime();
        if (_tentativeNextOutputTime.compareTo(currentTime) >= 0) {
            return;
        }
        // Find the first cycle time and phase greater than the
        // current one that equals or exceeds current time.
        // It might not be the very next phase because we could
        // have been disabled in a modal model, or we could have
        // skipped cycles due to not being triggered.
        double periodValue = ((DoubleToken) period.getToken()).doubleValue();
        Time phaseStartTime = _tentativeCycleStartTime
                .add(_offsets[_tentativePhase]);
        while (phaseStartTime.compareTo(currentTime) < 0) {
            _tentativePhase++;
            if (_tentativePhase >= _offsets.length) {
                _tentativePhase = 0;
                _tentativeCycleStartTime = _tentativeCycleStartTime
                        .add(periodValue);
View Full Code Here

TOP

Related Classes of ptolemy.actor.util.Time

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.