Package ptolemy.actor

Examples of ptolemy.actor.Actor


     *
     * @return The RendezvousDirector controlling this model.
     */
    protected RendezvousDirector _getDirector() {
        try {
            Actor container = (Actor) getContainer().getContainer();

            if (isInsideBoundary()) {
                return (RendezvousDirector) container.getDirector();
            } else {
                return (RendezvousDirector) container.getExecutiveDirector();
            }
        } catch (NullPointerException ex) {
            // If a thread has a reference to a receiver with no director it
            // is an error so terminate the process.
            throw new TerminateProcessException(
View Full Code Here


     *  actor. Send events with time stamps of
     *  PrioritizedTimedQueue.INACTIVE to these "downstream" actors.
     * @see ptolemy.domains.dde.kernel.PrioritizedTimedQueue
     */
    public synchronized void noticeOfTermination() {
        Actor actor = getActor();
        Iterator outputPorts = actor.outputPortList().iterator();
        double endTime = PrioritizedTimedQueue.INACTIVE;

        if (outputPorts != null) {
            while (outputPorts.hasNext()) {
                IOPort port = (IOPort) outputPorts.next();
View Full Code Here

     *  <P>
     *  NOTE: This method assumes an implementation of fireAt() that
     *  would be more appropriately named <I>continueAt()</I>.
     */
    public void start() {
        Actor actor = getActor();
        DDEDirector director = (DDEDirector) actor.getDirector();
        Hashtable table = director._getInitialTimeTable();

        if (table != null) {
            Double dTime = (Double) table.get(actor);

View Full Code Here

        _iteration = 0;

        // Get the ViewScreen.
        ViewScreenInterface viewScreen = _getViewScreen();

        Actor container = (Actor) getContainer();
        while (viewScreen == null) {
            // Tolerate GR nested within GR, in which case
            // the view screen should be that of the enclosing composite.
            // There could be an intervening FSMDirector, etc.
            Director executiveDirector = container.getExecutiveDirector();
            if (executiveDirector instanceof GRDirector) {
                viewScreen = ((GRDirector)executiveDirector)._getViewScreen();
            } else {
                if (executiveDirector == null) {
                    throw new IllegalActionException(this,
                            "GR model does not contain a view screen.");
                }
                container = (Actor) container.getContainer();
            }
        }

        // Set the view screen for all the actors.
        Iterator actors = ((TypedCompositeActor)container)
View Full Code Here

        Schedule schedule = scheduler.getSchedule();

        Iterator actors = schedule.actorIterator();

        while (actors.hasNext()) {
            Actor actor = (Actor) actors.next();

            if (_disabledActors.contains(actor)) {
                continue;
            }

            // If an actor returns true to prefire(), fire() and postfire()
            // will be called.
            if (_debugging) {
                _debug(new FiringEvent(this, actor, FiringEvent.BEFORE_PREFIRE,
                        1));
            }

            if (actor instanceof CompositeActor) {
                CompositeActor compositeActor = (CompositeActor) actor;
                Director insideDirector = compositeActor.getDirector();
                // FIXME: This is bogus.  This is assuming there is no
                // more than one inside director, and is delegating the
                // incrementing of time to that inside director.
                _insideDirector = insideDirector;
                _pseudoTimeEnabled = true;
            }

            boolean flag = actor.prefire();

            if (_debugging) {
                _debug(new FiringEvent(this, actor, FiringEvent.AFTER_PREFIRE,
                        1));
            }

            if (flag) {
                if (_debugging) {
                    _debug(new FiringEvent(this, actor,
                            FiringEvent.BEFORE_FIRE, 1));
                }

                actor.fire();

                if (_debugging) {
                    _debug(new FiringEvent(this, actor, FiringEvent.AFTER_FIRE,
                            1));
                    _debug(new FiringEvent(this, actor,
                            FiringEvent.BEFORE_POSTFIRE, 1));
                }

                if (!actor.postfire()) {
                    _disabledActors.add(actor);
                }

                if (_debugging) {
                    _debug(new FiringEvent(this, actor,
View Full Code Here

        // NOTE: This fire method does not call super.fire()
        // because this method is very different from that of the super class.
        // A BIG while loop that handles all events with the same tag.
        while (true) {
            // Find the next actor to be fired.
            Actor actorToFire = _getNextActorToFire();

            // Check whether the actor to be fired is null.
            // -- If the actor to be fired is null,
            // There are two conditions that the actor to be fired
            // can be null.
            if (actorToFire == null) {
                if (_isTopLevel()) {
                    // Case 1:
                    // If this director is an executive director at
                    // the top level, a null actor means that there are
                    // no events in the event queue.
                    if (_debugging) {
                        _debug("No more events in the event queue.");
                    }

                    // Setting the follow variable to true makes the
                    // postfire method return false.
                    // Do not do this if _stopFireRequested is true,
                    // since there may in fact be actors to fire, but
                    // their firing has been deferred.
                    if (!_stopFireRequested) {
                        _noMoreActorsToFire = true;
                    }
                } else {
                    // Case 2:
                    // If this director belongs to an opaque composite model,
                    // which is not at the top level, the director may be
                    // invoked by an update of an external parameter port.
                    // Therefore, no actors contained by the composite model
                    // need to be fired.
                    // NOTE: There may still be events in the event queue
                    // of this director that are scheduled for future firings.
                    if (_debugging) {
                        _debug("No actor requests to be fired "
                                + "at the current tag.");
                    }
                }

                // Nothing more needs to be done in the current iteration.
                // Simply return.
                // Since we are now actually stopping the firing, we can set this false.
                _stopFireRequested = false;
                return;
            }

            // -- If the actor to be fired is not null.
            // If the actor to be fired is the container of this director,
            // the next event to be processed is in an inside receiver of
            // an output port of the container. In this case, this method
            // simply returns, and gives the outside domain a chance to react
            // to that event.
            // NOTE: Topological sort always assigns the composite actor the
            // lowest priority. This guarantees that all the inside actors
            // have fired (reacted to their triggers) before the composite
            // actor fires.
            // TESTIT.
            // FIXME: However, there may be more than one output port,
            // should all the events be removed from the event queue?
            if (actorToFire == getContainer()) {
                // Since we are now actually stopping the firing, we can set this false.
                _stopFireRequested = false;
                return;
            }

            if (_debugging) {
                _debug("DE director fires at " + getModelTime()
                        + "  with microstep as " + _microstep);
            }

            // Keep firing the actor to be fired until there are no more input
            // tokens available in any of its input ports, or its prefire()
            // method returns false.
            boolean refire;

            do {
                refire = false;

                // NOTE: There are enough tests here against the
                // _debugging variable that it makes sense to split
                // into two duplicate versions.
                if (_debugging) {
                    // Debugging. Report everything.
                    if (((Nameable) actorToFire).getContainer() == null) {
                        // If the actor to be fired does not have a container,
                        // it may just be deleted. Put this actor to the
                        // list of disabled actors.
                        _debug("Actor has no container. Disabling actor.");
                        _disableActor(actorToFire);
                        break;
                    }

                    _debug(new FiringEvent(this, actorToFire,
                            FiringEvent.BEFORE_PREFIRE));

                    if (!actorToFire.prefire()) {
                        _debug("*** Prefire returned false.");
                        break;
                    }

                    _debug(new FiringEvent(this, actorToFire,
                            FiringEvent.AFTER_PREFIRE));

                    _debug(new FiringEvent(this, actorToFire,
                            FiringEvent.BEFORE_FIRE));
                    actorToFire.fire();
                    _debug(new FiringEvent(this, actorToFire,
                            FiringEvent.AFTER_FIRE));

                    _debug(new FiringEvent(this, actorToFire,
                            FiringEvent.BEFORE_POSTFIRE));

                    if (!actorToFire.postfire()) {
                        _debug("*** Postfire returned false:",
                                ((Nameable) actorToFire).getName());

                        // This actor requests not to be fired again.
                        _disableActor(actorToFire);
                        break;
                    }

                    _debug(new FiringEvent(this, actorToFire,
                            FiringEvent.AFTER_POSTFIRE));
                } else {
                    // No debugging.
                    if (((Nameable) actorToFire).getContainer() == null) {
                        // If the actor to be fired does not have a container,
                        // it may just be deleted. Put this actor to the
                        // list of disabled actors.
                        _disableActor(actorToFire);
                        break;
                    }

                    if (!actorToFire.prefire()) {
                        break;
                    }

                    actorToFire.fire();

                    if (!actorToFire.postfire()) {
                        // This actor requests not to be fired again.
                        _disableActor(actorToFire);
                        break;
                    }
                }

                // Check all the input ports of the actor to see whether there
                // are more input tokens to be processed.
                Iterator inputPorts = actorToFire.inputPortList().iterator();

                while (inputPorts.hasNext() && !refire) {
                    IOPort port = (IOPort) inputPorts.next();

                    // iterate all the channels of the current input port.
View Full Code Here

     *  current time, or the depth of the given IO port has not be calculated,
     *  or the new event can not be enqueued.
     */
    protected void _enqueueTriggerEvent(IOPort ioPort)
            throws IllegalActionException {
        Actor actor = (Actor) ioPort.getContainer();

        if ((_eventQueue == null)
                || ((_disabledActors != null) && _disabledActors
                        .contains(actor))) {
            return;
View Full Code Here

        // The depth of an actor starts with a negative number.
        int defaultActorDepth = -numberOfActors;

        while (actorsIterator.hasNext()) {
            Actor actor = (Actor) actorsIterator.next();

            // Calculate the depth of the given actor, which is the
            // smallest depth of all the input and output ports.
            // Why?
            // Here is the example: A model with a feedback loop, which
            // contains a non-zero TimedDelay actor. When the TimedDelay actor
            // requests a refiring, the depth of the event should have the
            // depth of its output.
            // The reason to include the depths of input ports for calculation
            // is to reduce unnecessary number of firings. In particular,
            // if an actor receives a trigger event that has the same tag as
            // one of its pure events, one firing is sufficient.

            int depth = -1;
            Iterator inputs = actor.inputPortList().iterator();

            while (inputs.hasNext()) {
                IOPort inputPort = (IOPort) inputs.next();
                int inputDepth = _getDepthOfIOPort(inputPort);

                if ((inputDepth < depth) || (depth == -1)) {
                    depth = inputDepth;
                }
            }

            Iterator outputs = actor.outputPortList().iterator();

            while (outputs.hasNext()) {
                IOPort outputPort = (IOPort) outputs.next();
                int outputDepth = _getDepthOfIOPort(outputPort);

                if ((outputDepth < depth) || (depth == -1)) {
                    depth = outputDepth;
                }
            }

            // Note that if an actor has no ports, the defaultActorDepth,
            // which is a negative number, will be used such that each
            // actor has a unique depth.
            if (depth == -1) {
                depth = defaultActorDepth;
            }
            _actorToDepth.put(actor, Integer.valueOf(depth));
            // Increment the default depth value for the next actor.
            defaultActorDepth++;
        }

        // If the event queue is not empty, we should update the depths of
        // the existing events with new depths.
        // NOTE: After update, we must use the same _eventQueue to keep the
        // existing references to it. For example, the debug listeners.
        if (!_eventQueue.isEmpty()) {
            // Setup a temporary repository for the existing events
            // in the queue.
            LinkedList updatedEventList = new LinkedList();

            while (!_eventQueue.isEmpty()) {
                DEEvent event = _eventQueue.take();
                IOPort ioPort = event.ioPort();
                Actor actor = event.actor();

                // Treat pure events and trigger events differently.
                // Must check ioPort first and then actor, because
                // if ioPort is not null, its actor can not be null.
                if (ioPort != null) {
View Full Code Here

        // Assign depths to ports based on the topological sorting result.
        for (int i = 0; i <= (numberOfPorts - 1); i++) {
            IOPort ioPort = (IOPort) sort[i];
            ports.add(ioPort);
            int depth = i;
            Actor portContainer = (Actor) ioPort.getContainer();
            // The ports of the composite actor that contains
            // this director are set to the highest depth
            // (the lowest priority).
            if (ioPort.isOutput() && portContainer.equals(getContainer())) {
                depth += numberOfPorts;
            }

            // Insert the hashtable entry.
            _portToDepth.put(ioPort, Integer.valueOf(depth));
            if (_debugging && _verbose) {
                _debug(((Nameable) ioPort).getFullName(), "depth: " + depth);
            }
        }

        if (_debugging && _verbose) {
            _debug("## adjusting port depths to "
                    + "make opaque composite actors and "
                    + "actors with no output ports strict.");
        }

        HashSet actorsWithPortDepthsAdjusted = new HashSet();

        // Adjusts the depths according to:
        // - If an output depends on several inputs directly,
        //   all inputs must have the same depth, the biggest one.
        for (int i = sort.length - 1; i >= 0; i--) {
            IOPort ioPort = (IOPort) sort[i];

            // Get the container actor of the current output port.
            Actor portContainer = (Actor) ioPort.getContainer();

            // Skip the ports of the container. Their depths are handled
            // by the upper level executive director of this container.
            if (portContainer.equals(getContainer())) {
                continue;
            }

            // For opaque composite actors and for actors with
            // no output ports, adjust the depths of all input ports
            // to match the maximum depth of the input ports.
            // If an actor has no output ports, then the default
            // dependencies of all input ports to all output ports
            // will not have been created. Hence, there is no mechanism
            // provided by this default to elevate the depth of all
            // the input ports to the maximum of those depths.
            // Thus, we conservatively assume that any actor with
            // no output ports should be treated as if it had one
            // output port (say, representing its state), and that
            // all input ports depend on that output port.
            // This will not be necessary in a version of DE
            // that implements a strict fixed-point semantics.
            if (ioPort.isInput()) {
                if (portContainer.outputPortList().size() == 0
                        || (portContainer instanceof CompositeActor && ((CompositeActor) portContainer)
                                .isOpaque())) {
                    List inputPorts = portContainer.inputPortList();

                    if (inputPorts.size() <= 1) {
                        // If the sink actor has only one input port, there is
                        // no need to adjust its depth.
                        continue;
                    }

                    if (actorsWithPortDepthsAdjusted.contains(portContainer)) {
                        // The depths of the input ports of this acotr
                        // have been adjusted.
                        continue;
                    } else {
                        actorsWithPortDepthsAdjusted.add(portContainer);
                    }

                    Iterator inputsIterator = inputPorts.iterator();

                    // Iterate all input ports of the sink or composite actor
                    // to find the largest depth.
                    int maximumPortDepth = -1;
                    while (inputsIterator.hasNext()) {
                        IOPort input = (IOPort) inputsIterator.next();
                        int inputPortDepth = ports.indexOf(input);
                        if (maximumPortDepth < inputPortDepth) {
                            maximumPortDepth = inputPortDepth;
                        }
                    }

                    // Set the depths of the input ports to the maximum one.
                    inputsIterator = inputPorts.iterator();
                    while (inputsIterator.hasNext()) {
                        IOPort input = (IOPort) inputsIterator.next();

                        if (_debugging && _verbose) {
                            _debug(((Nameable) input).getFullName(),
                                    "depth is adjusted to: " + maximumPortDepth);
                        }

                        // Insert the hashtable entry.
                        _portToDepth.put(input, Integer
                                .valueOf(maximumPortDepth));
                    }
                }
            }
            // For an output port, adjust the depths of all the
            // input ports on which it depends to match the largest
            // depth of those input ports.
            // FIXME: The following is really problematic. Check the
            // DESchedulingTest3.xml as example (NOTE: I can't
            // find this example. EAL).
            if (ioPort.isOutput()) {
                // Get the function dependency of the container actor
                FunctionDependency functionDependency = portContainer
                        .getFunctionDependency();

                List inputPorts = functionDependency
                        .getInputPortsDependentOn(ioPort);
                Iterator inputsIterator = inputPorts.iterator();
View Full Code Here

        if (_eventQueue == null) {
            throw new IllegalActionException(
                    "Fire method called before the preinitialize method.");
        }

        Actor actorToFire = null;
        DEEvent lastFoundEvent = null;
        DEEvent nextEvent = null;

        // Keep taking events out until there are no more events that have the
        // same tag and go to the same destination actor, or until the queue is
        // empty, or until a stop is requested.
        // LOOPLABEL::GetNextEvent
        while (!_stopRequested) {
            // Get the next event from the event queue.
            if (_stopWhenQueueIsEmpty) {
                if (_eventQueue.isEmpty()) {
                    // If the event queue is empty,
                    // jump out of the loop: LOOPLABEL::GetNextEvent
                    break;
                }
            }

            if (!_isTopLevel()) {
                // If the director is not at the top level.
                if (_eventQueue.isEmpty()) {
                    // This could happen if the container simply fires
                    // this composite at times it chooses. Most directors
                    // do this (SDF, SR, Continuous, etc.). It can also
                    // happen if an input is provided to a parameter port
                    // and the container is DE.
                    // In all these cases, no actors inside need to be
                    // fired.
                    break;
                } else {
                    // For an embedded DE director, the following code prevents
                    // the director from reacting to future events with bigger
                    // time values in their tags.
                    // For a top-level DE director, there is no such constraint
                    // because the top-level director is responsible to advance
                    // simulation by increasing the model tag.
                    nextEvent = _eventQueue.get();

                    // An embedded director should process events
                    // that only happen at the current tag.
                    // If the event is in the past, that is an error,
                    // because the event should have been consumed in prefire().
                    if ((nextEvent.timeStamp().compareTo(getModelTime()) < 0)) {
                        // missed an event
                        throw new IllegalActionException(
                                "Fire: Missed an event: the next event tag "
                                        + nextEvent.timeStamp()
                                        + " :: "
                                        + nextEvent.microstep()
                                        + " is earlier than the current model tag "
                                        + getModelTime() + " :: " + _microstep
                                        + " !");
                    }

                    // If the event is in the future time, it is ignored
                    // and will be processed later.
                    // Note that it is fine for the new event to have a bigger
                    // microstep. This indicates that the embedded director is
                    // going to advance microstep.
                    // Note that conceptually, the outside and inside DE models
                    // share the same microstep and the current design and
                    // implementation assures that. However, the embedded DE
                    // director does ask for the microstep of the upper level
                    // DE director. They keep their own count of their
                    // microsteps. The reason for this is to avoid the
                    // difficulties caused by passing information across modal
                    // model layers.
                    if ((nextEvent.timeStamp().compareTo(getModelTime()) > 0)) {
                        // reset the next event
                        nextEvent = null;

                        // jump out of the loop: LOOPLABEL::GetNextEvent
                        break;
                    }
                }
            } else { // if (!topLevel)
                // If the director is at the top level
                // If the event queue is empty, normally
                // a blocking read is performed on the queue.
                // However, there are two conditions that the blocking
                // read is not performed, which are checked below.
                if (_eventQueue.isEmpty()) {
                    // The two conditions are:
                    // 1. An actor to be fired has been found; or
                    // 2. There are no more events in the event queue,
                    // and the current time is equal to the stop time.
                    if ((actorToFire != null)
                            || (getModelTime().equals(getModelStopTime()))) {
                        // jump out of the loop: LOOPLABEL::GetNextEvent
                        break;
                    }
                }

                // Otherwise, if the event queue is empty,
                // a blocking read is performed on the queue.
                // stopFire() needs to also cause this to fall out!
                while (_eventQueue.isEmpty() && !_stopRequested
                        && !_stopFireRequested) {
                    if (_debugging) {
                        _debug("Queue is empty. Waiting for input events.");
                    }

                    Thread.yield();

                    synchronized (_eventQueue) {
                        // Need to check _stopFireRequested again inside
                        // the synchronized block, because it may have changed.
                        if (_eventQueue.isEmpty() && !_stopFireRequested) {
                            try {
                                // NOTE: Release the read access held
                                // by this thread to prevent deadlocks.
                                workspace().wait(_eventQueue);
                            } catch (InterruptedException e) {
                                // If the wait is interrupted,
                                // then stop waiting.
                                break;
                            }
                        }
                    } // Close synchronized block
                } // Close the blocking read while loop

                // To reach this point, either the event queue is not empty,
                // or _stopRequested or _stopFireRequested is true, or an interrupted exception
                // happened.
                if (_eventQueue.isEmpty()) {
                    // Stop is requested or this method is interrupted.
                    // jump out of the loop: LOOPLABEL::GetNextEvent
                    break;
                } else {
                    // At least one event is found in the event queue.
                    nextEvent = _eventQueue.get();
                }
            }

            // This is the end of the different behaviors of embedded and
            // top-level directors on getting the next event.
            // When this point is reached, the nextEvent can not be null.
            // In the rest of this method, this is not checked any more.
            if (nextEvent == null) {
                throw new IllegalActionException("The event to be handled"
                        + " can not be null!");
            }

            // If the actorToFire is null, find the destination actor associated
            // with the event just found. Store this event as lastFoundEvent and
            // go back to continue the GetNextEvent loop.
            // Otherwise, check whether the event just found goes to the
            // same actor to be fired. If so, dequeue that event and continue
            // the GetNextEvent loop. Otherwise, jump out of the GetNextEvent
            // loop.
            // TESTIT
            if (actorToFire == null) {
                // If the actorToFire is not set yet,
                // find the actor associated with the event just found,
                // and update the current tag with the event tag.
                Time currentTime;

                if (_synchronizeToRealTime) {
                    // If synchronized to the real time.
                    synchronized (_eventQueue) {
                        while (!_stopRequested && !_stopFireRequested) {
                            lastFoundEvent = _eventQueue.get();
                            currentTime = lastFoundEvent.timeStamp();

                            long elapsedTime = System.currentTimeMillis()
                                    - _realStartTime;

                            // NOTE: We assume that the elapsed time can be
                            // safely cast to a double.  This means that
                            // the DE domain has an upper limit on running
                            // time of Double.MAX_VALUE milliseconds.
                            double elapsedTimeInSeconds = elapsedTime / 1000.0;
                            ptolemy.actor.util.Time elapsed
                                    = new ptolemy.actor.util.Time(this, elapsedTimeInSeconds);
                            if (currentTime.compareTo(elapsed) <= 0) {
                                break;
                            }

                            // NOTE: We used to do the following, but it had a limitation.
                            // In particular, if any user code also calculated the elapsed
                            // time and then constructed a Time object to post an event
                            // on the event queue, there was no assurance that the quantization
                            // would be the same, and hence it was possible for that event
                            // to be in the past when posted, even if done in the same thread.
                            // To ensure that the comparison of current time against model time
                            // always yields the same result, we have to do the comparison using
                            // the Time class, which is what the event queue does.
                            /*
                            if (currentTime.getDoubleValue() <= elapsedTimeInSeconds) {
                                break;
                            }*/

                            long timeToWait = (long) (currentTime.subtract(
                                    elapsed).getDoubleValue() * 1000.0);

                            if (timeToWait > 0) {
                                if (_debugging) {
                                    _debug("Waiting for real time to pass: "
                                            + timeToWait);
                                }

                                try {
                                    // NOTE: The built-in Java wait() method
                                    // does not release the
                                    // locks on the workspace, which would block
                                    // UI interactions and may cause deadlocks.
                                    // SOLUTION: workspace.wait(object, long).
                                    _workspace.wait(_eventQueue, timeToWait);
                                    // If we get here and either stop() or stopFire()
                                    // was called, then it is not time to process any event,
                                    // so we should leave it in the event queue.
                                    if (_stopRequested || _stopFireRequested) {
                                        return null;
                                    }
                                } catch (InterruptedException ex) {
                                    // Continue executing.
                                }
                            }
                        } // while
                    } // sync
                } // if (_synchronizeToRealTime)

                // Consume the earliest event from the queue. The event must be
                // obtained here, since a new event could have been enqueued
                // into the queue while the queue was waiting. For example,
                // an IO interrupt event.
                // FIXME: The above statement is misleading. How could the
                // newly inserted event happen earlier than the previously
                // first event in the queue? It may be possible in the
                // distributed DE models, but should not happen in DE models.
                // Will this cause problems, such as setting time backwards?
                // TESTIT How to??
                synchronized (_eventQueue) {
                    lastFoundEvent = _eventQueue.take();
                    currentTime = lastFoundEvent.timeStamp();
                    actorToFire = lastFoundEvent.actor();

                    // NOTE: The _enqueueEvent method discards the events
                    // for disabled actors.
                    if ((_disabledActors != null)
                            && _disabledActors.contains(actorToFire)) {
                        // This actor has requested not to be fired again.
                        if (_debugging) {
                            _debug("Skipping disabled actor: ",
                                    ((Nameable) actorToFire).getFullName());
                        }

                        actorToFire = null;

                        // start a new iteration of the loop:
                        // LOOPLABEL::GetNextEvent
                        continue;
                    }

                    // Advance the current time to the event time.
                    // NOTE: This is the only place that the model time changes.
                    setModelTime(currentTime);

                    // Advance the current microstep to the event microstep.
                    _microstep = lastFoundEvent.microstep();
                }

                // Exceeding stop time means the current time is strictly
                // bigger than the model stop time.
                if (currentTime.compareTo(getModelStopTime()) > 0) {
                    if (_debugging) {
                        _debug("Current time has passed the stop time.");
                    }

                    _exceedStopTime = true;
                    return null;
                }
            } else { // if (actorToFire == null)
                // We have already found an event and the actor to react to it.
                // Check whether the newly found event has the same tag
                // and depth. If so, the destination actor should be the same,
                // and they are handled at the same time. For example, a pure
                // event and a trigger event that go to the same actor.
                if (nextEvent.hasTheSameTagAndDepthAs(lastFoundEvent)) {
                    // Consume the event from the queue and discard it.
                    // FIXME: This isn't right!  The microstep is only incremented
                    // by fireAt() calls. The Repeat actor, for one, produces a sequence
                    // of outputs, each of which will have the same microstep.
                    _eventQueue.take();
                } else if (nextEvent.hasTheSameTagAs(lastFoundEvent)) {
                    // The actor to be fired is the container, we remove all
                    // the trigger events with the same tag from the event
                    // queue such that the executive director of this DE model
                    // can react to these events.
                    Actor actor = nextEvent.actor();
                    if (actor == actorToFire) {
                        _eventQueue.take();
                    } else {
                        // Next event has a future tag or a different destination.
                        break;
View Full Code Here

TOP

Related Classes of ptolemy.actor.Actor

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.