public class SysMLSequentialDirector extends Director implements SuperdenseTimeDirector
Sequential version of a SysML director. This version is inspired by a subset of the semantics of IBM Rational's Rhapsody SysML tool. In this MoC, all actors execute in the same thread. Inputs provided to an input port (by another actor) are put into a single queue managed by this director. This director executes by first initializing all actors (which may cause them to place events on the queue and/or to request firings at future times, "timeouts"). Then, in each iteration, this director retrieves one event from the queue, offers it to the destination actor as an input, and fires that destination actor. That actor may put events on the event queue and/or request firings at future times. The director continues doing this until there are no more events to be processed at the current time. At that point, it allows time to advance, and first all actors that whose timeouts match the time advance, in the same order in which they asserted those timeouts (in previous firings). Those firings may again place events in the event queue, so this director will again fire actors until the event queue is empty.
Ports that are marked as flow ports (which contain an attribute named "flow" with value "true") are treated specially. First, the value on such ports is persistent. It does not disappear after being read, unlike the events that arrive on standard ports. Second, when a new value is sent to a flow port, the new value is made immediately available to the destination actor, and a "change event" is placed on the event queue. The change event ensures that the actor is notified of the changed value, but the actor may actually notice the change value before it processes the change event, if there are already other events in the queue destined for that actor.
This director is related to the DE director, with some key differences. First, it handles only one event from the event queue at a time. Second, the dependencies between actors are ignored. Third, it supports "flow ports," which have persistent value, and "change events," which indicate to an actor that the value on a flow port has changed.
Unlike the DE director, the order in which actors are initialized affects the execution because it affects the initial order in which events are placed on the event queue. After that, if the actors are deterministic, then the execution is deterministic.
Red (eal) |
Red (eal) |
Modifier and Type | Class and Description |
---|---|
static class |
SysMLSequentialDirector.SuperdenseTime
Data structure for storing a superdense time.
|
class |
SysMLSequentialDirector.SysMLSequentialReceiver
Variant of a Mailbox that overrides the put() method to
divert the input to the director's queue
and then provides a method to really put a token into
a receiver.
|
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected boolean |
_isInitializing
A local boolean variable indicating whether this director is in
initialization phase execution.
|
protected int |
_microstep
The current microstep.
|
_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 |
---|
SysMLSequentialDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected SysMLSequentialDirector.SuperdenseTime |
_advanceAdvanceables(Time time,
int microstep)
Advance time of all actors that implement Advanceable to the
specified time and microstep.
|
protected void |
_clearReceivers(Actor actor)
Clear all the input receivers for the specified actor.
|
protected ptolemy.domains.sysml.kernel.SysMLSequentialDirector.RefireRequest |
_earliestNextFiringRequest()
Return the earliest pending fire request.
|
protected java.util.List<Advanceable> |
_getAdvanceables()
Return a list of actors under the control of this director that implement
the
Advanceable interface. |
protected boolean |
_isFlowPort(IOPort port)
Return true if the specified port is a flow port.
|
protected boolean |
_iterateActorOnce(Actor actor)
Iterate the specified actor once.
|
java.lang.Object |
clone(Workspace workspace)
Clone the director into the specified workspace.
|
void |
fire()
Start a new iteration (at a new time, presumably) and either
run the actors to completion in order of creation or
wait until a deadlock is detected, depending on activeObjects.
|
Time |
fireAt(Actor actor,
Time time,
int microstep)
Override the base class to make a local record of the requested
firing.
|
int |
getIndex()
Return a superdense time index for the current time,
where the index is equal to the microstep.
|
void |
initialize()
Invoke the initialize() method of ProcessDirector.
|
void |
initialize(Actor actor)
Initialize the given actor.
|
Receiver |
newReceiver()
Return a new receiver SysMLAReceiver.
|
boolean |
postfire()
Return false if a stop has been requested or if
the model has reached deadlock.
|
boolean |
prefire()
Override the base class to set time to match environment
time if this director is embedded.
|
boolean |
scheduleContainedActors()
Return true if next actor in list of fire requests was scheduled
and can execute.
|
void |
setIndex(int index)
Set the superdense time index.
|
void |
setModelTime(Time newTime)
Set a new value to the current time of the model.
|
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, delayDependency, finish, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getErrorTolerance, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, setContainer, setCurrentTime, setEmbedded, setTimeResolution, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferInputs, transferOutputs, transferOutputs, wrapup
_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
protected boolean _isInitializing
protected int _microstep
public SysMLSequentialDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- Container of the director.name
- Name of this director.IllegalActionException
- If the director is not compatible
with the specified container. Thrown in derived classes.NameDuplicationException
- If the container not a
CompositeActor and the name collides with an entity in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Director
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If one of the attributes
cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class Director
IllegalActionException
- If a derived class throws it.public Time fireAt(Actor actor, Time time, int microstep) throws IllegalActionException
fireAt
in class Director
actor
- The actor scheduled to be fired.time
- The requested time.microstep
- The requested microstep.IllegalActionException
- If there is an executive director
and it throws it. Derived classes may choose to throw this
exception for other reasons.Director.fireAtCurrentTime(Actor)
,
Director.fireContainerAt(Time)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class Director
IllegalActionException
- If the initialize() method of one
of the deeply contained actors 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 int getIndex()
getIndex
in interface SuperdenseTimeDirector
setIndex(int)
,
SuperdenseTimeDirector
public Receiver newReceiver()
newReceiver
in class Director
public boolean scheduleContainedActors() throws IllegalActionException
scheduleContainedActors
in class Director
IllegalActionException
- If request to resource scheduler fails.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class Director
IllegalActionException
- If a derived class throws it.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class Director
IllegalActionException
- Not thrown in this base class.public void setIndex(int index) throws IllegalActionException
setIndex
in interface SuperdenseTimeDirector
index
- The index of the superdense time object.
Events that occur at the same time have different indicies.IllegalActionException
- Not thrown in this base class.getIndex()
,
SuperdenseTimeDirector
public void setModelTime(Time newTime) throws IllegalActionException
setModelTime
in class Director
newTime
- The new current simulation time.IllegalActionException
- If the new time is less than
the current time returned by getCurrentTime().Director.getModelTime()
protected SysMLSequentialDirector.SuperdenseTime _advanceAdvanceables(Time time, int microstep) throws IllegalActionException
time
- The time to advance to.microstep
- The microstep to advance to.IllegalActionException
- If an actor refuses to advance time,
or if the proposed time is in the past.protected void _clearReceivers(Actor actor) throws IllegalActionException
actor
- The actor.IllegalActionException
- If the receivers can't be cleared.protected ptolemy.domains.sysml.kernel.SysMLSequentialDirector.RefireRequest _earliestNextFiringRequest()
protected java.util.List<Advanceable> _getAdvanceables()
Advanceable
interface.protected boolean _isFlowPort(IOPort port)
port
- The port.protected boolean _iterateActorOnce(Actor actor) throws IllegalActionException
actor
- The actor to be iterated.IllegalActionException
- If the actor throws it.