Package ptolemy.actor.util

Examples of ptolemy.actor.util.Time


     */
    public synchronized void initialize() throws IllegalActionException  {
        super.initialize();
        $ASSIGN$_firstFiring(true);
        $ASSIGN$_phase(0);
        Time currentTime = getDirector().getModelTime();
        Time nextFiringTime = currentTime.add(_offsets[0]);
        getDirector().fireAt(this, nextFiringTime);
    }
View Full Code Here


            $ASSIGN$_cycleStartTime(_cycleStartTime.add(periodValue));
        }
        if (_offsets[_phase] >= periodValue) {
            throw new IllegalActionException(this, "Offset number " + _phase+" with value "+_offsets[_phase]+" must be less than the "+"period, which is "+periodValue);
        }
        Time nextIterationTime = _cycleStartTime.add(_offsets[_phase]);
        getDirector().fireAt(this, nextIterationTime);
        return true;
    }
View Full Code Here

     * Output the current value.
     * @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException  {
        super.fire();
        Time currentTime = getDirector().getModelTime();
        $ASSIGN$_boundaryCrossed(false);
        $ASSIGN$_tentativeCurrentOutputIndex(_currentOutputIndex);
        output.send(0, _getValue(_tentativeCurrentOutputIndex));
        if (currentTime.compareTo(_nextFiringTime) == 0) {
            $ASSIGN$SPECIAL$_tentativeCurrentOutputIndex(11, _tentativeCurrentOutputIndex);
            if (_tentativeCurrentOutputIndex >= _length) {
                $ASSIGN$_tentativeCurrentOutputIndex(0);
            }
            $ASSIGN$_boundaryCrossed(true);
View Full Code Here

     */
    public void initialize() throws IllegalActionException  {
        super.initialize();
        $ASSIGN$_tentativeCurrentOutputIndex(0);
        $ASSIGN$_currentOutputIndex(0);
        Time currentTime = getDirector().getModelTime();
        $ASSIGN$_nextFiringTime(currentTime);
        if (((BooleanToken)fireAtStart.getToken()).booleanValue()) {
            getDirector().fireAt(this, currentTime);
        } else {
            double meanTimeValue = ((DoubleToken)meanTime.getToken()).doubleValue();
View Full Code Here

        if (attribute == stopTime) {
            double newStopTimeValue = ((DoubleToken) stopTime.getToken())
                    .doubleValue();

            if (_executing) {
                Time newStopTime = new Time(getDirector(), newStopTimeValue);
                Director director = getDirector();

                if (director != null) {
                    Time currentTime = director.getModelTime();

                    if (newStopTime.compareTo(currentTime) > 0) {
                        director.fireAt(this, newStopTime);
                    } else {
                        throw new IllegalActionException(this, "The stop time "
View Full Code Here

            throw new IllegalActionException(this, "No director!");
        }

        double stopTimeValue = ((DoubleToken) stopTime.getToken())
                .doubleValue();
        _stopTime = new Time(getDirector(), stopTimeValue);

        Time currentTime = director.getModelTime();

        if (!_stopTime.isInfinite() && (_stopTime.compareTo(currentTime) > 0)) {
            director.fireAt(this, _stopTime);
            _executing = true;
        }
View Full Code Here

     *  at the end of their postfire() method and return its returned
     *  value.
     *  @exception IllegalActionException Not thrown in this base class.
     */
    public boolean postfire() throws IllegalActionException {
        Time currentTime = getDirector().getModelTime();

        if (currentTime.compareTo(_stopTime) >= 0) {
            return false;
        }

        return true;
    }
View Full Code Here

    public void fire() throws IllegalActionException {
        super.fire();
        if (input.hasToken(0)) {
            _newToken = input.get(0);

            Time currentTime = getDirector().getModelTime();

            if (currentTime.compareTo(_lastTime) == 0) {
                // If the current time is the same as the last time,
                // output the last token, because any change of the
                // output from the last time indicates an infinite
                // rate change.
                // The only exception is that in the first firing,
                // where the last token is null, the new token is always
                // accepted.
                if (_lastToken != null) {
                    _newToken = _lastToken;
                }

                output.send(0, _newToken);
            } else {
                double valueDifference = ((DoubleToken) _newToken
                        .subtract(_lastToken)).doubleValue();
                double timeDifference = currentTime.subtract(_lastTime)
                        .getDoubleValue();
                double rate = valueDifference / timeDifference;
                double risingRate = ((DoubleToken) risingSlewRate.getToken())
                        .doubleValue();
                double fallingRate = ((DoubleToken) fallingSlewRate.getToken())
View Full Code Here

    /** Initialize the local time variables and the cache of last token.
     *  @exception IllegalActionException If the super cclass throws it.
     */
    public void initialize() throws IllegalActionException {
        super.initialize();
        _lastTime = new Time(getDirector());
        _lastToken = null;
    }
View Full Code Here

        // a CTDirector.
        CTDirector director = (CTDirector) getDirector();

        if (director.isDiscretePhase()) {
            // Get the current time and period.
            Time currentTime = director.getModelTime();
            double periodValue = ((DoubleToken) period.getToken())
                    .doubleValue();

            // Use Time.NEGATIVE_INFINITY to indicate that no refire
            // event should be scheduled because we aren't at a phase boundary.
            _tentativeNextFiringTime = Time.NEGATIVE_INFINITY;

            // By default, the cycle count will not be incremented.
            _tentativeCycleCountIncrement = 0;

            // In case current time has reached or crossed a boundary between
            // periods, update it.  Note that normally the time will not
            // advance more than one period
            // (unless, perhaps, the entire domain has been dormant
            // for some time, as might happen for example in a hybrid system).
            // But do not do this if we are before the first iteration.
            // FIXME: why?
            if (_tentativeCycleCount > 0) {
                while (_tentativeCycleStartTime.add(periodValue).compareTo(
                        currentTime) <= 0) {
                    _tentativeCycleStartTime = _tentativeCycleStartTime
                            .add(periodValue);
                }
            }

            // Adjust the phase if the current time has moved beyond
            // the current phase time.
            Time currentPhaseTime = _tentativeCycleStartTime
                    .add(_offsets[_tentativePhase]);

            if (currentTime.compareTo(currentPhaseTime) == 0) {
                // Phase boundary.  Change the current value.
                _tentativeCurrentValue = _getValue(_tentativePhase);

                // If we are beyond the number of cycles requested, then
                // change the output value to zero.
                int cycleLimit = ((IntToken) numberOfCycles.getToken())
                        .intValue();

                // FIXME: performance suffers from this. cache the stop time.
                // NOTE: there are two stop time. One is based on the cycles
                // and period, and the other one is based on the stopTime
                // parameter.
                Time stopTime = _tentativeStartTime.add(cycleLimit
                        * periodValue);

                if (((cycleLimit > 0) && (currentTime.compareTo(stopTime) >= 0))
                        || _tentativeDone) {
                    _tentativeCurrentValue = defaultValue.getToken();
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.