Package ptolemy.actor.util

Examples of ptolemy.actor.util.Time


            _firstFire = false;
            return;
        }

        DEDirector dir = (DEDirector) getDirector();
        Time now = dir.getModelTime();
        double maxDelayValue = ((DoubleToken) maxDelay.getToken())
                .doubleValue();

        if (next.hasToken(0)) {
            next.get(0);

            if (now.compareTo(_nextMsgTime) < 0) {
                // ignore this
            } else {
                // compute a random delay between zero and MaxDelay.
                double delay = maxDelayValue * Math.random();
                _nextMsgTime = now.add(delay);
                dir.fireAt(this, _nextMsgTime);
            }

            //System.out.println("DEMessageSource " + this.getFullName() +
            //        " next message " + "scheduled at " + _nextMsgTime);
        }

        if (now.compareTo(_nextMsgTime) == 0) {
            ++_msgNum;
            output.broadcast(new IntToken(_msgNum));
        } else {
            // this refire should be discarded
            return;
View Full Code Here


     @return True if the current time matches the _nextOutputTime.
     */
    protected boolean _isTimeForOutput() {
        FixedPointDirector director = (FixedPointDirector) getDirector();
        boolean rightIndex = _nextOutputIndex == director.getIndex();
        Time currentTime = director.getModelTime();
        return rightIndex && _tentativeNextOutputTime.equals(currentTime);
    }
View Full Code Here

    public void fireAt(Actor actor, Time time) throws IllegalActionException {
        if (_debugging) {
            _debug(actor.getName() + " requests refiring at " + time);
        }
        // Check if the request time is earlier than the current time.
        Time currentTime = getModelTime();
        // Breakpoints always have an index larger than 1 except the
        // stop time breakpoint.
        int index = 1;

        int comparisonResult = time.compareTo(currentTime);
View Full Code Here

        }

        if (!_breakpoints.isEmpty()) {
            SuperdenseTime nextBreakpoint = (SuperdenseTime) _breakpoints
                    .first();
            Time breakpointTime = nextBreakpoint.timestamp();
            int comparison = breakpointTime.compareTo(_currentTime);
            if (comparison < 0) {
                accurate = false;
            }
        }
View Full Code Here

        }

        if (!_breakpoints.isEmpty()) {
            SuperdenseTime nextBreakpoint = (SuperdenseTime) _breakpoints
                    .first();
            Time nextBreakpointTime = nextBreakpoint.timestamp();
            int comparison = nextBreakpointTime.compareTo(_iterationBeginTime
                    .add(refinedStep));
            if (comparison < 0) {
                refinedStep = nextBreakpointTime.subtract(_iterationBeginTime)
                        .getDoubleValue();
                if (refinedStep < 0.0) {
                    throw new IllegalActionException(this,
                            "Cannot set a step size to respect the breakpoint at "
                                    + nextBreakpoint);
View Full Code Here

            SuperdenseTime nextBreakpoint = (SuperdenseTime) _breakpoints
                    .first();
            if (_debugging) {
                _debug("The first breakpoint is at " + nextBreakpoint);
            }
            Time breakpointTime = nextBreakpoint.timestamp();
            double result = breakpointTime.subtract(getModelTime())
                    .getDoubleValue();
            if (result < suggestedStep) {
                if (result < 0.0) {
                    throw new InternalErrorException(
                            "Missed a breakpoint at time " + breakpointTime
                                    + ". Current time is " + getModelTime());
                }
                suggestedStep = result;
                if (_debugging) {
                    _debug("----- Revising step size due to breakpoint to "
                            + suggestedStep);
                }
            }
        }
        // Next ensure the selected step size does not take us
        // past the stop time.
        // NOTE: This test could possibly be eliminated by
        // putting the stop time on the breakpoint table. Be sure,
        // however, that this results in the right number of
        // events generated at the stop time. This is very tricky,
        // and probably not worth the effort.
        Time targetTime = getModelTime().add(suggestedStep);
        if (targetTime.compareTo(_stopTime) > 0) {
            suggestedStep = _stopTime.subtract(getModelTime()).getDoubleValue();
            if (_debugging) {
                _debug("----- Revising step size due to stop time to "
                        + suggestedStep);
            }
View Full Code Here

        // with the current index, then remove that breakpoint because we have
        // just completed execution of that iteration.
        if (!_breakpoints.isEmpty()) {
            SuperdenseTime nextBreakpoint = (SuperdenseTime) _breakpoints
                    .first();
            Time breakpointTime = nextBreakpoint.timestamp();
            int comparison = breakpointTime.compareTo(_currentTime);
            if (comparison == 0 && nextBreakpoint.index() == _index) {
                if (_debugging) {
                    _debug("Removing breakpoint at " + nextBreakpoint);
                }
                _breakpoints.removeFirst();
View Full Code Here

     */
    private void _discardBreakpointsBefore(Time time) {
        while (!_breakpoints.isEmpty()) {
            SuperdenseTime nextBreakpoint = (SuperdenseTime) _breakpoints
                    .first();
            Time breakpointTime = nextBreakpoint.timestamp();
            int comparison = breakpointTime.compareTo(time);
            if (comparison > 0
                    || (comparison == 0 && nextBreakpoint.index() > _index)) {
                // Next breakpoint is in the future.
                break;
            } else {
View Full Code Here

        if (_isEmbedded()) {
            _startTime = ((Actor) getContainer()).getExecutiveDirector()
                    .getModelStartTime();
        } else {
            _startTime = new Time(this, ((DoubleToken) startTime.getToken())
                    .doubleValue());
        }
        _stopTime = new Time(this, ((DoubleToken) stopTime.getToken())
                .doubleValue());
        _iterationBeginTime = _startTime;

        // clear the existing breakpoint table or
        // create a breakpoint table if necessary
View Full Code Here

        // with the current index, then remove that breakpoint because we have
        // just completed execution of that iteration.
        if (!_breakpoints.isEmpty()) {
            SuperdenseTime nextBreakpoint = (SuperdenseTime) _breakpoints
                    .first();
            Time breakpointTime = nextBreakpoint.timestamp();
            int comparison = breakpointTime.compareTo(_currentTime);
            if (comparison == 0 && nextBreakpoint.index() == _index) {
                if (_debugging) {
                    _debug("Removing breakpoint at " + nextBreakpoint);
                }
                _breakpoints.removeFirst();
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.