Package ptolemy.actor

Examples of ptolemy.actor.Actor


     *  This will roll back any actors that were fired in the current iteration.
     */
    public void rollBackToCommittedState() {
        Iterator actors = _actorsFired.iterator();
        while (actors.hasNext()) {
            Actor actor = (Actor) actors.next();
            if (actor instanceof ContinuousStatefulComponent) {
                ((ContinuousStatefulComponent) actor)
                        .rollBackToCommittedState();
            } else if (actor instanceof CompositeActor) {
                // Delegate to the director.
                Director director = actor.getDirector();
                if (director instanceof ContinuousDirector) {
                    ((ContinuousDirector) director).rollBackToCommittedState();
                }
            }
        }
View Full Code Here


     */
    public double suggestedStepSize() throws IllegalActionException {
        double result = Double.POSITIVE_INFINITY;
        Iterator actors = _actorsFired.iterator();
        while (actors.hasNext()) {
            Actor actor = (Actor) actors.next();
            if (actor instanceof ContinuousStepSizeController) {
                double candidate = ((ContinuousStepSizeController) actor)
                        .suggestedStepSize();
                if (candidate < result) {
                    result = candidate;
                }
            } else if (actor instanceof CompositeActor) {
                // Delegate to the director.
                Director director = actor.getDirector();
                if (director instanceof ContinuousStepSizeController) {
                    double candidate = ((ContinuousStepSizeController) director)
                            .suggestedStepSize();
                    if (candidate < result) {
                        result = candidate;
View Full Code Here

                                + timeStamp + "current time in TM is "
                                + getModelTime());
            } else if (timeStamp == getModelTime()) {
                _interruptQueue.take();

                Actor actor = interruptEvent.actor();

                if (actor != null) {
                    if (actor.prefire()) {
                        actor.fire();

                        if (!actor.postfire()) {
                            _disableActor(actor);
                        }
                    }
                }
            } else {
                // All interrupts are in the future.
                // Get the time for the next interrupt.
                // It will be used for finding the next iteration time.
                _nextIterationTime = timeStamp;
                break;
            }
        }

        // Then we process TM events.
        TMEvent event = null;

        while (!_eventQueue.isEmpty()) {
            event = (TMEvent) _eventQueue.get();

            if (_debugging) {
                _debug("The first event in the queue is ", event.toString());
            }

            // Notice that the first event in the queue
            // either has processing time > 0 or hasn't been started.
            if (!event.hasStarted()) {
                if (_debugging) {
                    _debug(getName(), "put trigger event ", event.toString(),
                            " into " + ((NamedObj) event.actor()).getName()
                                    + " and processing");
                }

                event.receiver()._triggerEvent(event.token());

                // FIXME: What shall we do if there are events to
                // the same actor with the same priority.
                // Check if there are any events with equal priority
                // for this actor. If so, make them available to the
                // actor at the same time.
                Actor actor = event.actor();

                if ((actor == getContainer()) || !actor.prefire()) {
                    // If the actor is the container of this director,
                    // then the event is at the output boundary.
                    // Remove the event and look at the next event.
                    _eventQueue.take();
                    event = null;

                    // Return to the while loop.
                } else {
                    // Determine the processing time.
                    double processingTime = ((DoubleToken) defaultTaskExecutionTime
                            .getToken()).doubleValue();

                    if (actor instanceof TMActor) {
                        processingTime = ((TMActor) actor).getExecutionTime();
                    } else {
                        // Use the executionTime parameter from the port
                        // or the actor.
                        Parameter executionTime = (Parameter) event.receiver()
                                .getContainer().getAttribute("executionTime");

                        // Actor starts to execute
                        if (executionTime == null) {
                            executionTime = (Parameter) ((NamedObj) actor)
                                    .getAttribute("executionTime");
                        }

                        if (executionTime != null) {
                            processingTime = ((DoubleToken) executionTime
                                    .getToken()).doubleValue();
                        }
                    }

                    if (processingTime == 0.0) {
                        if (_debugging) {
                            _debug(getName(), event.toString(),
                                    " has processing time 0, so processed.");
                        }

                        // This event  can be processed immediately.
                        _eventQueue.take();

                        actor.fire();

                        // Actor stops executing, i.e. finishing
                        _displaySchedule(((Nameable) actor).getName(),
                                getModelTime().getDoubleValue(),
                                ScheduleListener.TASK_SLEEPING);
                        _displaySchedule();

                        if (!actor.postfire()) {
                            _disableActor(actor);
                        }
                    } else {
                        // Really start a task with non-zero processing
                        // time.
View Full Code Here

                                .toString());
                    }

                    _eventQueue.take();

                    Actor actor = event.actor();
                    actor.fire();

                    // Actor stops executing, i.e. finishing
                    _displaySchedule(((Nameable) actor).getName(),
                            getModelTime().getDoubleValue(),
                            ScheduleListener.TASK_SLEEPING);
                    _displaySchedule();

                    // Should handle dead actors.
                    if (!actor.postfire()) {
                        _disableActor(actor);
                    }
                } else {
                    if (_debugging) {
                        _debug(getName(), "still needs processing time as "
                                + event.processingTime());
                    }
                }
            }
        }

        // check the interupt queue:
        while (!_interruptQueue.isEmpty()) {
            DEEvent interruptEvent = _interruptQueue.get();
            Time timeStamp = interruptEvent.timeStamp();

            if (timeStamp.compareTo(_outsideTime) < 0) {
                // This should never happen.
                throw new IllegalActionException(this,
                        "external input in the past: " + "input time stamp is "
                                + timeStamp + "current time in TM is "
                                + getModelTime());
            } else if (timeStamp.compareTo(_outsideTime) == 0) {
                _interruptQueue.take();

                Actor actor = interruptEvent.actor();

                if (actor != null) {
                    if (actor.prefire()) {
                        actor.fire();

                        if (!actor.postfire()) {
                            _disableActor(actor);
                        }
                    }
                }
            } else {
View Full Code Here

        // opaque.
        // super.preinitialize();

        // preinitialize all contained actors.
        for (Iterator i = deepEntityList().iterator(); i.hasNext();) {
            Actor actor = (Actor) i.next();
            actor.preinitialize();
        }
    }
View Full Code Here

            _workspace.doneWriting();
        }

        // preinitialize all contained actors.
        for (Iterator i = deepEntityList().iterator(); i.hasNext();) {
            Actor actor = (Actor) i.next();
            actor.preinitialize();
        }
    }
View Full Code Here

     @param time The scheduled time.
     *  @exception IllegalActionException If the operation is not
     *    permissible (e.g. the given time is in the past).
     */
    public void fireAt(Actor actor, Time time) throws IllegalActionException {
        Actor container = (Actor) getContainer();
        if (container != null) {
            Director executiveDirector = container.getExecutiveDirector();
            if (executiveDirector != null) {
                executiveDirector.fireAt(container, time);
            }
        }
    }
View Full Code Here

     @param actor The actor scheduled to be fired.
     *  @exception IllegalActionException If the enclosing director
     *   throws it.
     */
    public void fireAtCurrentTime(Actor actor) throws IllegalActionException {
        Actor container = (Actor) getContainer();
        if (container != null) {
            Director executiveDirector = container.getExecutiveDirector();
            if (executiveDirector != null) {
                executiveDirector.fireAtCurrentTime(container);
            }
        }
    }
View Full Code Here

        Schedule schedule = new Schedule();
        Iterator actorIterator = actorList.iterator();

        while (actorIterator.hasNext()) {
            Actor actor = (Actor) actorIterator.next();
            Firing firing = new Firing();
            firing.setActor(actor);
            schedule.add(firing);
        }
View Full Code Here

        if (_debugging) {
            _debug("## Result of topological sort (highest depth to lowest):");
        }

        Schedule schedule = new Schedule();
        Actor lastActor = null;
        Actor actor = null;

        for (int i = 0; i < sort.length; i++) {
            IOPort ioPort = (IOPort) sort[i];

            // If this ioPort is input but has no connections,
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.