Class AtomicExecutionAspect

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, ActorExecutionAspect, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Decorator, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
    Direct Known Subclasses:
    DynamicCoreAssignmentScheduler, FCFSScheduler, FixedPriorityScheduler

    public class AtomicExecutionAspect
    extends TypedAtomicActor
    implements ActorExecutionAspect
    This is a base class for resource schedulers. This is a Decorator that will decorate any instance of Actor that is deeply contained by its container, including within opaque composites. This base class provides one decorator attributes. When you create an instance of this class in a composite actor, every Actor within that composite actor is decorated with these this parameter:
    • enable: If true, then the decorated actor will use this resource. This is a boolean that defaults to false.
    This base class is not used but to use derived classes, drag them into a model and enable the actors that will use the resource. Currently, the following Directors honor ExecutionAspect settings:
    • PtidesDirector. A ExecutionAspect on a PtidesPlatform will cause the platform time at which actors produce their outputs to be delayed by the specified execution time beyond the platform time at which the resource becomes available to execute the actor.
    • DEDirector. Note that using a ExecutionAspect in a DE model will change the MoC and nondeterminism is introduced with ExecutionAspects.
    • SDF Director, if contained hierarchically directly or via multiple hierarchy layers by a PtidesDirector.
    • SysMLSequentialDirector, if contained hierarchically directly or via multiple hierarchy layers by a PtidesDirector.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Patricia Derler, Edward A. Lee
    Pt.AcceptedRating:
    Red (derler)
    Pt.ProposedRating:
    Red (derler)
    • Field Detail

      • _actors

        protected java.util.List<NamedObj> _actors
        Actors decorated by this aspect.
      • _lastActorFinished

        protected boolean _lastActorFinished
        True if in the last request to schedule an actor, this actor finished execution.
      • _lastActorThatFinished

        protected NamedObj _lastActorThatFinished
        Last actor that finished execution.
      • _lastTimeScheduled

        protected java.util.HashMap<NamedObj,​Time> _lastTimeScheduled
        The last time an actor's remaining time was updated due to a scheduling request.
      • _remainingTimes

        protected java.util.HashMap<NamedObj,​Time> _remainingTimes
        The remaining execution time for every actor that has been scheduled or null if the actor execution finished.
      • _executionAspectListeners

        protected java.util.List<ExecutionAspectListener> _executionAspectListeners
        Listeners that want to be informed about rescheduling events.
    • Constructor Detail

      • AtomicExecutionAspect

        public AtomicExecutionAspect​(CompositeEntity container,
                                     java.lang.String name)
                              throws IllegalActionException,
                                     NameDuplicationException
        Create a new resource schedule in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.
        Parameters:
        container - The container.
        name - The name of this actor within the container.
        Throws:
        IllegalActionException - If this actor cannot be contained by the proposed container (see the setContainer() method).
        NameDuplicationException - If the name coincides with an entity already in the container.
    • Method Detail

      • createDecoratorAttributes

        public DecoratorAttributes createDecoratorAttributes​(NamedObj target)
        Return the decorated attributes for the target NamedObj. If the specified target is not an Actor, return null.
        Specified by:
        createDecoratorAttributes in interface Decorator
        Parameters:
        target - The NamedObj that will be decorated.
        Returns:
        The decorated attributes for the target NamedObj, or null if the specified target is not an Actor.
      • decoratedObjects

        public java.util.List<NamedObj> decoratedObjects()
        Return a list of the entities deeply contained by the container of this resource scheduler.
        Specified by:
        decoratedObjects in interface Decorator
        Returns:
        A list of the objects decorated by this decorator.
      • getExecutionTime

        public double getExecutionTime​(NamedObj actor)
                                throws IllegalActionException
        Get the execution time of an actor. If the actor does not have an attribute specifying the execution time, return the minimum execution time.
        Specified by:
        getExecutionTime in interface ActorExecutionAspect
        Parameters:
        actor - The actor.
        Returns:
        The execution time.
        Throws:
        IllegalActionException - Thrown in attribute or token cannot be read.
      • getRemainingTime

        public Time getRemainingTime​(NamedObj actor)
        Return remaining time actor needs to finish.
        Parameters:
        actor - The actor.
        Returns:
        The time the actor still needs.
      • getTime

        public Time getTime​(double time)
                     throws IllegalActionException
        Return a new time object using the enclosing director.
        Parameters:
        time - Double value of the new time object.
        Returns:
        The new time object.
        Throws:
        IllegalActionException - If the time object cannot be created.
      • isGlobalDecorator

        public boolean isGlobalDecorator()
        Return true to indicate that this decorator should decorate objects across opaque hierarchy boundaries.
        Specified by:
        isGlobalDecorator in interface Decorator
        Returns:
        True if decorator is global.
      • isWaitingForResource

        public boolean isWaitingForResource​(Actor actor)
        Check whether the execution of an actor is handled by this aspect actor.
        Specified by:
        isWaitingForResource in interface ActorExecutionAspect
        Parameters:
        actor - The actor.
        Returns:
        True, if the actor execution is handled by this aspect actor.
      • lastScheduledActorFinished

        public boolean lastScheduledActorFinished()
        If the last actor that was scheduled finished execution then this method returns true.
        Specified by:
        lastScheduledActorFinished in interface ActorExecutionAspect
        Returns:
        True if last actor that was scheduled finished execution.
      • schedule

        public Time schedule​(Time environmentTime)
                      throws IllegalActionException
        Perform rescheduling actions when no new actor requests to be scheduled.
        Specified by:
        schedule in interface ActorExecutionAspect
        Parameters:
        environmentTime - The outside time.
        Returns:
        Relative time when this Scheduler has to be executed again to perform rescheduling actions.
        Throws:
        IllegalActionException - Thrown in subclasses.
      • schedule

        public Time schedule​(NamedObj actor,
                             Time environmentTime,
                             Time deadline,
                             Time executionTime)
                      throws IllegalActionException
        Schedule the actor. In this base class, do nothing. Derived classes should schedule the actor.
        Specified by:
        schedule in interface ActorExecutionAspect
        Parameters:
        actor - The actor to be scheduled.
        environmentTime - The current platform time.
        deadline - The deadline timestamp of the event to be scheduled. This can be the same as the environmentTime.
        executionTime - The execution time of the actor.
        Returns:
        Relative time when this Scheduler has to be executed again to perform rescheduling actions. In this base class, null is returned.
        Throws:
        IllegalActionException - Thrown if actor parameters such as execution time or priority cannot be read.
      • _getDeadline

        protected Time _getDeadline​(Actor actor,
                                    Time timestamp)
                             throws IllegalActionException
        Get the deadline for an actor that requests a firing at time timestamp. This base class just returns the maximum value.
        Parameters:
        actor - The actor that requests firing.
        timestamp - The time when the actor wants to be fired.
        Returns:
        The deadline for the actor.
        Throws:
        IllegalActionException - If time objects cannot be created.
      • lastActorFinished

        protected boolean lastActorFinished()
        Return whether last actor that was scheduled finished execution.
        Returns:
        True if last actor finished execution.