public class PteraDirector extends Director implements ValueListener
PteraController
) in Ptera modal
models (instances of PteraModalModel
). This director has an event queue
where events can be scheduled and are ordered by their time stamps. Events are
processed according to their time-stamp order. Actions of the events are
executed when the events are processed.
Between events there may be scheduling relations. If an event schedules another to occur after a certain amount of model time, then the other event is placed in the event queue when the first event is processed. Scheduling relations may be guarded by boolean expressions.
Each Ptera controller transparently creates a Ptera director inside. For a Ptera controller that serves as refinement of an event in another Ptera controller, the Ptera director in it invokes the fireAt() method of the Ptera director in the containing Ptera controller. When multiple events are scheduled in one firing of the inner Ptera director, only one invocation of fireAt() is made in postfire() with the most imminent event as the parameter.
This director can be used in DE as a contained model of computation. It can also be used to control timed or untimed models of computation, such as DE, dataflow, and FSM.
DEDirector
Red (tfeng) |
Yellow (tfeng) |
Modifier and Type | Class and Description |
---|---|
static class |
PteraDirector.TimedEvent
The class to encapsulate information to be stored in an entry in the event
queue.
|
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
StringAttribute |
controllerName
Attribute specifying the name of the Ptera controller in the
container of this director.
|
Parameter |
LIFO
A Boolean parameter that decides whether simultaneous events should be
placed in the event queue in the last-in-first-out (LIFO) fashion or
not.
|
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
_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 |
---|
PteraDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_insertInitialEvents()
Insert initial events into the event queue, and request firing from the
director at the higher level, if any.
|
protected boolean |
_isTopLevel()
Return whether this director is top-level.
|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute.
|
PteraDirector.TimedEvent |
cancel(Event event)
Cancel an event that was previously scheduled in the event queue.
|
java.lang.Object |
clone(Workspace workspace)
Clone the director into the specified workspace.
|
PteraDirector.TimedEvent |
findFirst(Event event,
boolean findRefinements)
Find the first occurrence of the given event in the event queue.
|
void |
fire()
Fire the director and process the imminent events or the events that
react to inputs if inputs are available.
|
Time |
fireAt(Actor actor,
Time time,
int microstep)
Request a firing of the given actor at the given model
time.
|
void |
fireAt(Event event,
Time time,
Token arguments,
java.util.List<NamedObj> triggers,
boolean reset)
Request to process an event at the given model time.
|
void |
fireAt(PteraDirector.TimedEvent timedEvent,
java.util.List<NamedObj> triggers)
Request to process an event at the given model time.
|
PteraController |
getController()
Return the Ptera controller has the same container as this director.
|
IllegalActionException |
getModelException()
Return the exception (if any) that occurred when the refinement was fired.
|
Time |
getModelTime()
Return the current time object of the model being executed by this
director.
|
void |
initialize()
Initialize the model controlled by this director.
|
void |
initialize(Actor actor)
Initialize the given actor, unless it is a RefinementActor (which will
be initialized when the event that it refines is fired).
|
boolean |
postfire()
Return true if the director wishes to be scheduled for another
iteration.
|
boolean |
prefire()
Return true if the director is ready to fire.
|
void |
preinitialize()
Invoke the preinitialize() method of the superclass.
|
void |
stop()
Request that the director cease execution altogether.
|
void |
stopFire()
Request the execution of the current iteration to complete.
|
void |
valueChanged(Settable settable)
Monitor the change of a variable specified by the
settable
argument if the execution has started, and invokes fireAt() to request
to fire all the events that are listening to that variable at the
current model time. |
void |
wrapup()
Invoke the wrapup() method of the superclass, and clear the event queue.
|
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _schedule, _transferInputs, _transferOutputs, addInitializable, createSchedule, defaultDependency, delayDependency, finish, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getErrorTolerance, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, newReceiver, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferInputs, transferOutputs, transferOutputs
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public Parameter LIFO
public StringAttribute controllerName
public PteraDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this director.IllegalActionException
- If the name has a period in it, or
the director is not compatible with the specified container, or if
the time resolution parameter is malformed.NameDuplicationException
- If the container already contains
an entity with the specified name.public void attributeChanged(Attribute attribute) throws IllegalActionException
controllerName
attribute, then make note that this
has changed.attributeChanged
in class Director
attribute
- The attribute that changed.IllegalActionException
- If thrown by the superclass
attributeChanged() method.public PteraDirector.TimedEvent cancel(Event event) throws IllegalActionException
SchedulingRelation
object with the canceling attribute set to
true.event
- The event to be cancelled.IllegalActionException
- If the refinement of the given event
(if any) cannot be obtained.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Director
workspace
- The workspace for the new director.java.lang.CloneNotSupportedException
- If a derived class contains
an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public PteraDirector.TimedEvent findFirst(Event event, boolean findRefinements) throws IllegalActionException
findRefinements
is true, then the refinements of the given
event are also searched for.event
- The event.findRefinements
- Whether refinements of the given event should be
searched for.IllegalActionException
- If the refinements of the given event
cannot be retrieved.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class Director
IllegalActionException
- If inputs cannot be read at the input
ports, the controller that contains this director cannot be found, or
this exception is raised when firing a refinement or processing an
event.public Time fireAt(Actor actor, Time time, int microstep) throws IllegalActionException
fireAt
in class Director
actor
- The actor scheduled to be fired.time
- The scheduled time.microstep
- The microstep (ignored by this director).IllegalActionException
- If the operation is not
permissible (e.g. the given time is in the past), or if the executive director
does not support fireAt() precisely (it does not agree to refire
this Ptera model at the requested time).Director.fireAtCurrentTime(Actor)
,
Director.fireContainerAt(Time)
public void fireAt(Event event, Time time, Token arguments, java.util.List<NamedObj> triggers, boolean reset) throws IllegalActionException
event
- The event scheduled to be processed.time
- The scheduled time.arguments
- The arguments to the event, which must be either an
ArrayToken or a RecordToken.triggers
- A list of ports and variables that triggers the event
before its scheduled time is reached.reset
- Whether the refinement of the scheduled event should be
reinitialized when the event is processed.IllegalActionException
- If the operation is not
permissible (e.g. the given time is in the past), or if the executive
director does not support fireAt() precisely (it does not agree to
refire this Ptera model at the requested time)public void fireAt(PteraDirector.TimedEvent timedEvent, java.util.List<NamedObj> triggers) throws IllegalActionException
timedEvent
- The TimedEvent object to be scheduled.triggers
- A list of ports and variables that triggers the event
before its scheduled time is reached.IllegalActionException
- If the operation is not
permissible (e.g. the given time is in the past), or if the executive
director does not support fireAt() precisely (it does not agree to
refire this Ptera model at the requested time)public PteraController getController() throws IllegalActionException
FSMDirector.getController()
. However, due to
the class hierarchy, there is no easy way to reuse the code.IllegalActionException
- If no controller is found.public Time getModelTime()
getModelTime
in class Director
Director.setModelTime(Time)
public IllegalActionException getModelException()
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class Director
IllegalActionException
- If the initialize() method of
the superclass throws it.public void initialize(Actor actor) throws IllegalActionException
initialize
in class Director
actor
- The actor that is to be initialized.IllegalActionException
- If the actor is not
acceptable to the domain. Not thrown in this base class.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class Director
IllegalActionException
- If the executive director does
not support fireAt() precisely (that is, it does not agree to
refire this Ptera model at the requested time).public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class Director
IllegalActionException
- If the superclass throws it, or if the
tokens at the input ports cannot be checked.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class Director
IllegalActionException
- If the preinitialize() method of
one of the associated actors throws it.public void stop()
stop
in interface Executable
stop
in class Director
public void stopFire()
stopFire
in interface Executable
stopFire
in class Director
public void valueChanged(Settable settable)
settable
argument if the execution has started, and invokes fireAt() to request
to fire all the events that are listening to that variable at the
current model time.valueChanged
in interface ValueListener
settable
- The variable that has been changed.public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
wrapup
in class Director
IllegalActionException
- If the wrapup() method of
the superclass throws it.protected void _insertInitialEvents() throws IllegalActionException
IllegalActionException
- If whether an event is initial event
cannot be checked, or if the executive director does not support
fireAt() precisely (it does not agree to refire this Ptera at the
requested time).protected boolean _isTopLevel()
_isTopLevel
in class Director