Package ptolemy.actor.util

Examples of ptolemy.actor.util.Time


     @exception TerminateProcessException If activity is scheduled
     *   to cease.
     */
    public void put(Token token) {
        Thread thread = Thread.currentThread();
        Time time = _lastTime;

        if (thread instanceof DDEThread) {
            TimeKeeper timeKeeper = ((DDEThread) thread).getTimeKeeper();
            time = timeKeeper.getOutputTime();
        }
View Full Code Here


        synchronized (_director) {
            if ((time.compareTo(_getCompletionTime()) > 0)
                    && (_getCompletionTime().getDoubleValue() != ETERNITY)
                    && !_terminate) {
                try {
                    time = new Time(_director, INACTIVE);
                } catch (IllegalActionException e) {
                    // If the time resolution of the director is invalid,
                    // it should have been caught before this.
                    throw new InternalErrorException(e);
                }
View Full Code Here

     *  at <i>waiter</i>, and produce no output.
     *  @exception IllegalActionException If get() or send() throws it.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        Time currentTime = ((DEDirector) getDirector()).getModelTime();

        while (waiter.hasToken(0)) {
            waiter.get(0);
            _waiting.addElement(currentTime);
        }

        boolean godot = false;

        while (waitee.hasToken(0)) {
            waitee.get(0);
            godot = true;
        }

        if (godot) {
            for (int i = 0; i < _waiting.size(); i++) {
                Time previousTime = (Time) _waiting.elementAt(i);
                DoubleToken outToken = new DoubleToken(currentTime.subtract(
                        previousTime).getDoubleValue());
                output.send(0, outToken);
            }

View Full Code Here

            }
        } else {
            _currentInput = null;
        }

        Time currentTime = getDirector().getModelTime();
        _currentOutput = null;

        if (_delayedOutputTokens.size() > 0) {
            if (currentTime.compareTo(_nextTimeFree) == 0) {
                TimedEvent earliestEvent = (TimedEvent) _delayedOutputTokens
                        .get();
                Time eventTime = earliestEvent.timeStamp;

                if (!eventTime.equals(currentTime)) {
                    throw new InternalErrorException("Timer time is "
                            + "reached, but output is not available.");
                }

                _currentOutput = (Token) earliestEvent.contents;
View Full Code Here

     *  a future firing to produce it.
     *  @exception IllegalActionException If there is no director or can not
     *  schedule future firings to handle delayed input events.
     */
    public boolean postfire() throws IllegalActionException {
        Time currentTime = getDirector().getModelTime();

        // Remove the current output token from _delayedTokens.
        if (_currentOutput != null) {
            _delayedOutputTokens.take();
        }

        // If the delayedInputTokensList is not empty and the
        // delayedOutputTokens is empty (meaning the timer is ready to process
        // a new input), get the first input in the delayedInputTokensList,
        // put it into the delayedOutputTokens, and begin processing it.
        // Schedule a refiring to produce the corresponding
        // output at the time: current time + delay specified by the input
        // being processed.
        if ((_delayedInputTokensList.size() != 0)
                && _delayedOutputTokens.isEmpty()) {
            // NOTE: the input has a fixed data type as double.
            DoubleToken delayToken = (DoubleToken) _delayedInputTokensList
                    .removeFirst();
            double delay = delayToken.doubleValue();
            _nextTimeFree = currentTime.add(delay);
            _delayedOutputTokens.put(new TimedEvent(_nextTimeFree, value
                    .getToken()));
            getDirector().fireAt(this, _nextTimeFree);
        }

View Full Code Here

        // NOTE: The amount of delay may be zero.
        // In this case, if there is already some token scheduled to
        // be produced at the current time before the current input
        // arrives, that token is produced. While the current input
        // is delayed to the next available firing at the current time.
        Time currentTime = getDirector().getModelTime();
        _currentOutput = null;

        if (_delayedOutputTokens.size() > 0) {
            TimedEvent earliestEvent = (TimedEvent) _delayedOutputTokens.get();
            Time eventTime = earliestEvent.timeStamp;

            if (eventTime.equals(currentTime)) {
                _currentOutput = (Token) earliestEvent.contents;
                output.send(0, _currentOutput);
            }
        }
    }
View Full Code Here

     *  a firing to produce the earliest output token.
     *  @exception IllegalActionException If scheduling to refire cannot
     *  be performed or the superclass throws it.
     */
    public boolean postfire() throws IllegalActionException {
        Time currentTime = getDirector().getModelTime();
        Time delayToTime = currentTime.add(_delay);

        // Remove the token that is sent at the current time.
        if (_delayedOutputTokens.size() > 0) {
            if (_currentOutput != null) {
                _delayedOutputTokens.take();
            }
        }

        // Handle the refiring of the multiple tokens
        // that are scheduled to be produced at the same time.
        if (_delayedOutputTokens.size() > 0) {
            TimedEvent earliestEvent = (TimedEvent) _delayedOutputTokens.get();
            Time eventTime = earliestEvent.timeStamp;

            if (eventTime.equals(currentTime)) {
                getDirector().fireAt(this, currentTime);
            }
        }

        // Process the current input.
View Full Code Here

        // Consume an input.
        if (input.hasToken(0)) {
            input.get(0);
        }

        Time currentTime = getDirector().getModelTime();

        if (_previousTime.compareTo(Time.NEGATIVE_INFINITY) != 0) {
            DoubleToken outToken = new DoubleToken(currentTime.subtract(
                    _previousTime).getDoubleValue());
            output.send(0, outToken);
        }
    }
View Full Code Here

            throws IllegalActionException {
        // NOTE: We only remove elements from breakpoint table in this method
        // and the postfire() method of the CT director.
        boolean currentTimeIsABreakpoint = false;
        TotallyOrderedSet breakPoints = getBreakPoints();
        Time now = getModelTime();

        // If the current time is a breakpoint, remove it from table.
        if ((breakPoints != null) && !breakPoints.isEmpty()) {
            if (breakPoints.contains(now)) {
                // The current time is a break point.
                currentTimeIsABreakpoint = true;

                Time time = (Time) breakPoints.removeFirst();

                if (time.compareTo(now) < 0) {
                    // This should not happen for CTMultisolverDirector,
                    // but it is possible for CTEmbeddedDirector.
                    // When a CT refinement is made inactive for a long time
                    // and reentered, the previously stored breakpoints may
                    // be in the past... The same thing happens in the
View Full Code Here

                _debug("The first breakpoint in the breakpoint list is at "
                        + breakpoints.first());
            }

            // NOTE: the breakpoint table is not changed.
            Time nextBreakpoint = ((Time) breakpoints.first());
            double maximAllowedStepSize = nextBreakpoint.subtract(
                    getModelTime()).getDoubleValue();

            if (maximAllowedStepSize < refinedStepSize) {
                refinedStepSize = maximAllowedStepSize;
                if (_debugging) {
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.