Examples of CTDirector


Examples of ptolemy.domains.ct.kernel.CTDirector

    /** Return true if this actor is scheduled to fire at the current time.
     *  @return True if this actor is scheduled to fire at the current time.
     *  @exception IllegalActionException If thrown by the super class.
     */
    public boolean prefire() throws IllegalActionException {
        CTDirector director = (CTDirector) getDirector();
        boolean result = (director.getModelTime().compareTo(_nextOutputTime) == 0);
        return result && super.prefire();
    }
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     @exception IllegalActionException If the director throws it when
     *   scheduling the next firing, or if the length of the values and
     *   offsets parameters don't match.
     */
    public boolean postfire() throws IllegalActionException {
        CTDirector director = (CTDirector) getDirector();
        double periodValue = ((DoubleToken) period.getToken()).doubleValue();

        // Increment to the next phase.
        _phase++;

        if (_phase >= _offsets.length) {
            _phase = 0;
            _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);
        }

        _nextOutputTime = _cycleStartTime.add(_offsets[_phase]);
        director.fireAt(this, _nextOutputTime);
        return true;
    }
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     *  derivative.
     *  @exception IllegalActionException If the token cannot be sent.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        CTDirector director = (CTDirector) getDirector();

        if (director.isDiscretePhase()) {
            if ((input.hasToken(0) && (!derivative.hasToken(0)))
                    || (!input.hasToken(0) && derivative.hasToken(0))) {
                throw new IllegalActionException(this,
                        " No synchronized inputs.");
            }

            if (input.hasToken(0) && derivative.hasToken(0)) {
                _value = ((DoubleToken) input.get(0)).doubleValue();
                _derivative = ((DoubleToken) derivative.get(0)).doubleValue();
                _time = director.getModelTime();

                if (_debugging) {
                    _debug(getFullName(), " get inputs: (" + _value, ", "
                            + _derivative + ").");
                }
            }
        }

        double timeInterval = director.getModelTime().subtract(_time)
                .getDoubleValue();
        output.send(0, new DoubleToken(_value + (timeInterval * _derivative)));
    }
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

        // override how this is done.
        _updateTentativeValues();

        // In initialize() method, we already ensured that the director is
        // 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.
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     @exception IllegalActionException If the hasToken() query failed
     *  or tokens cannot be sent from the output.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        CTDirector director = (CTDirector) getDirector();

        // FIXME: do we need to constraint that the current execution phase is
        // CTExecutionPhase.GENERATING_EVENTS_PHASE?
        if (director.isDiscretePhase() && hasCurrentEvent()) {
            trigger.get(0);

            for (int i = 0; i < Math.min(input.getWidth(), output.getWidth()); i++) {
                if (input.hasToken(i)) {
                    output.send(i, input.get(i));
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     *  call.
     *  @exception IllegalActionException If the token cannot be sent.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        CTDirector director = (CTDirector) getDirector();

        if (director.isDiscretePhase()) {
            if (input.hasToken(0)) {
                _lastToken = input.get(0);

                CTDirector dir = (CTDirector) getDirector();
                _debug(getFullName() + " receives an event at: "
                        + dir.getModelTime() + " with token "
                        + _lastToken.toString());
            }
        }

        output.send(0, _lastToken);
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

        if (_debugging) {
            _debug("Consuming a trigger token: " + _thisTrigger);
        }

        CTDirector director = (CTDirector) getDirector();

        if (director.getExecutionPhase() == CTExecutionPhase.GENERATING_EVENTS_PHASE) {
            if (_debugging && _verbose) {
                _debug("This is a discrete phase execution.");
            }

            // There are two conditions when an event is generated.
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

    /** Return the refined step size if there is a missed event,
     *  otherwise return the current step size.
     *  @return The refined step size.
     */
    public double refinedStepSize() {
        CTDirector dir = (CTDirector) getDirector();
        double refinedStep = dir.getCurrentStepSize();

        if (_eventMissed) {
            // The refined step size is a linear interpolation.
            // NOTE: we always to get a little overshoot to make sure the
            // level crossing happens. The little overshoot chosen here
            // is half of the error toelrance.
            refinedStep = ((Math.abs(_lastTrigger - _level) + (_errorTolerance / 2)) * dir
                    .getCurrentStepSize())
                    / Math.abs(_thisTrigger - _lastTrigger);

            if (_debugging) {
                _debug(getFullName() + " Event Missed: refined step to "
                        + refinedStep + " at " + dir.getModelTime());
            }
        }

        return refinedStep;
    }
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     *  current time.
     *  @exception IllegalActionException If the transfer of tokens failed.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        CTDirector director = (CTDirector) getDirector();

        if ((director.getExecutionPhase() == CTExecutionPhase.GENERATING_EVENTS_PHASE)
                && hasCurrentEvent()) {
            for (int i = 0; i < Math.min(input.getWidth(), output.getWidth()); i++) {
                if (input.hasToken(i)) {
                    Token token = input.get(i);
                    output.send(i, token);
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

    /** Return true if there is a current event. In other words, the current
     *  time is one of the sampling times.
     *  @return If there is a discrete event to emit.
     */
    public boolean hasCurrentEvent() {
        CTDirector director = (CTDirector) getDirector();

        if (director.getModelTime().compareTo(_nextSamplingTime) == 0) {
            _hasCurrentEvent = true;

            if (_debugging && _verbose) {
                _debug(getFullName(), " has an event at: "
                        + director.getModelTime() + ".");
            }
        } else {
            _hasCurrentEvent = false;
        }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.