public class AtomicExecutionAspect extends TypedAtomicActor implements ActorExecutionAspect
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:
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected java.util.List<NamedObj> |
_actors
Actors decorated by this aspect.
|
protected java.util.List<ExecutionAspectListener> |
_executionAspectListeners
Listeners that want to be informed about rescheduling events.
|
protected boolean |
_lastActorFinished
True if in the last request to schedule an actor, this actor
finished execution.
|
protected NamedObj |
_lastActorThatFinished
Last actor that finished execution.
|
protected java.util.HashMap<NamedObj,Time> |
_lastTimeScheduled
The last time an actor's remaining time was updated due to a scheduling
request.
|
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.
|
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
AtomicExecutionAspect(CompositeEntity container,
java.lang.String name)
Create a new resource schedule in the specified container with the specified
name.
|
Modifier and Type | Method and Description |
---|---|
protected Time |
_getDeadline(Actor actor,
Time timestamp)
Get the deadline for an actor that requests a firing at time
timestamp.
|
void |
addExecutingListener(ExecutionAspectListener listener)
Add schedule listener.
|
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace.
|
DecoratorAttributes |
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.
|
java.util.List<NamedObj> |
decoratedObjects()
Return a list of the entities deeply contained by the container
of this resource scheduler.
|
void |
fire()
Perform rescheduling if necessary.
|
double |
getExecutionTime(NamedObj actor)
Get the execution time of an actor.
|
Time |
getRemainingTime(NamedObj actor)
Return remaining time actor needs to finish.
|
Time |
getTime(double time)
Return a new time object using the enclosing director.
|
void |
initialize()
Initialize local variables.
|
void |
initializeDecoratedActors()
Iterate through all entities deeply contained by the container,
record for each that it is not executing.
|
boolean |
isGlobalDecorator()
Return true to indicate that this decorator should
decorate objects across opaque hierarchy boundaries.
|
boolean |
isWaitingForResource(Actor actor)
Check whether the execution of an actor is handled by
this aspect actor.
|
protected boolean |
lastActorFinished()
Return whether last actor that was scheduled finished execution.
|
boolean |
lastScheduledActorFinished()
If the last actor that was scheduled finished execution
then this method returns true.
|
void |
notifyExecutionListeners(NamedObj entity,
java.lang.Double time,
ExecutionAspectListener.ExecutionEventType eventType)
Notify schedule listeners about rescheduling events.
|
void |
removeExecutionListener(ExecutionAspectListener listener)
Remove schedule listener.
|
Time |
schedule(NamedObj actor,
Time environmentTime,
Time deadline,
Time executionTime)
Schedule the actor.
|
Time |
schedule(Time environmentTime)
Perform rescheduling actions when no new actor requests to be
scheduled.
|
void |
setContainer(CompositeEntity container)
Override the base class to first set the container, then establish
a connection with any decorated objects it finds in scope in the new
container.
|
void |
wrapup()
Create end events for the plotter.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stop, stopFire, terminate
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
description, getContainer, getDisplayName, getFullName, getName, getName, setName
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable
getDerivedLevel, getDerivedList, propagateValue
protected java.util.List<NamedObj> _actors
protected boolean _lastActorFinished
protected NamedObj _lastActorThatFinished
protected java.util.HashMap<NamedObj,Time> _lastTimeScheduled
protected java.util.HashMap<NamedObj,Time> _remainingTimes
protected java.util.List<ExecutionAspectListener> _executionAspectListeners
public AtomicExecutionAspect(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor within the container.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.public void addExecutingListener(ExecutionAspectListener listener) throws IllegalActionException
addExecutingListener
in interface ActorExecutionAspect
listener
- The listener to be added.IllegalActionException
- If an error occurs in the initialization
of actors scheduled by this resource scheduler.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class TypedAtomicActor
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If a derived class contains
an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public DecoratorAttributes createDecoratorAttributes(NamedObj target)
createDecoratorAttributes
in interface Decorator
target
- The NamedObj that will be decorated.public java.util.List<NamedObj> decoratedObjects()
decoratedObjects
in interface Decorator
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- Not thrown here.public double getExecutionTime(NamedObj actor) throws IllegalActionException
getExecutionTime
in interface ActorExecutionAspect
actor
- The actor.IllegalActionException
- Thrown in attribute or token cannot be read.public Time getRemainingTime(NamedObj actor)
actor
- The actor.public Time getTime(double time) throws IllegalActionException
time
- Double value of the new time object.IllegalActionException
- If the time object cannot be created.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- Thrown if list of actors
scheduled by this scheduler cannot be retrieved.public void initializeDecoratedActors() throws IllegalActionException
initializeDecoratedActors
in interface ActorExecutionAspect
IllegalActionException
- If the decorator parameters cannot be read.public boolean isGlobalDecorator()
isGlobalDecorator
in interface Decorator
public boolean isWaitingForResource(Actor actor)
isWaitingForResource
in interface ActorExecutionAspect
actor
- The actor.public boolean lastScheduledActorFinished()
lastScheduledActorFinished
in interface ActorExecutionAspect
public void notifyExecutionListeners(NamedObj entity, java.lang.Double time, ExecutionAspectListener.ExecutionEventType eventType)
notifyExecutionListeners
in interface ActorExecutionAspect
entity
- Entity that is being scheduled.time
- Time when entity is being scheduled.eventType
- Type of event.public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class AtomicActor<TypedIOPort>
container
- The container to attach this attribute to..IllegalActionException
- If this attribute is not of the
expected class for the container, or it has no name,
or the attribute and container are not in the same workspace, or
the proposed container would result in recursive containment.NameDuplicationException
- If the container already has
an attribute with the name of this attribute.ComponentEntity.getContainer()
public Time schedule(Time environmentTime) throws IllegalActionException
schedule
in interface ActorExecutionAspect
environmentTime
- The outside time.IllegalActionException
- Thrown in subclasses.public Time schedule(NamedObj actor, Time environmentTime, Time deadline, Time executionTime) throws IllegalActionException
schedule
in interface ActorExecutionAspect
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.IllegalActionException
- Thrown if actor parameters such
as execution time or priority cannot be read.public void removeExecutionListener(ExecutionAspectListener listener)
removeExecutionListener
in interface ActorExecutionAspect
listener
- The listener to be removed.public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
wrapup
in class AtomicActor<TypedIOPort>
IllegalActionException
- Thrown by super class.protected Time _getDeadline(Actor actor, Time timestamp) throws IllegalActionException
actor
- The actor that requests firing.timestamp
- The time when the actor wants to be fired.IllegalActionException
- If time objects cannot be created.protected boolean lastActorFinished()