Class SysMLADirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.Director
-
- ptolemy.actor.process.ProcessDirector
-
- ptolemy.domains.sysml.kernel.SysMLADirector
-
- All Implemented Interfaces:
java.lang.Cloneable
,Executable
,Initializable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
@Deprecated public class SysMLADirector extends ProcessDirector
Deprecated.Use SysmlConcurrentDirector or SysMLSequentialDirectorVersion A of a SysML director. This version is inspired by a subset of the semantics of IBM Rational's Rhapsody SysML tool. In this MoC, each actor executes in its own thread (corresponding to an "active object" in SysML). Inputs provided to an input port (by the thread of another actor) are put into a single queue belonging to the destination actor. The thread for the destination actor retrieves the first input in the queue and uses it to set the value of exactly one input port. All other input ports are marked absent. The actor then fires, possibly producing one or more outputs which are directed to their destination actors.
When multiple actors send tokens to an actor, whether to the same port or to distinct ports, this MoC is nondeterministic. The order in which the tokens are processed will depend on the happenstances of scheduling, since the tokens are put into a single queue in the order in which they arrive.
In this MoC, we assume that an actor iterates within its thread only if either it has called fireAt() to request a future firing (or a re-firing at the current time), or it has at least one event in its input queue. Thus, the actor's thread will block until one of those conditions is satisfied.
When all threads are blocked, then if at least one has called fireAt() to request a future firing, then this director will advance model time to the smallest time of such a request, and then again begin executing actors until they all block.
When all actors are blocked, and none has called fireAt(), the model terminates.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Red (eal)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SysMLADirector.SysMLAReceiver
Deprecated.Variant of a Mailbox that overrides the put() method to divert the input to the queue associated with the actor and then provides a method to really put a token into a receiver.-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
activeObjects
Deprecated.If true, then every actor executes in its own thread.-
Fields inherited from class ptolemy.actor.process.ProcessDirector
_newActorThreadList, _notDone
-
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description SysMLADirector(CompositeEntity container, java.lang.String name)
Deprecated.Construct a director in the given container with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected boolean
_areThreadsDeadlocked()
Deprecated.Override the base class to return true if all active threads are blocked.protected void
_clearReceivers(Actor actor)
Deprecated.Clear all the input receivers for the specified actor.protected Time
_earliestNextFiringTime()
Deprecated.Return the earliest time that any actor has requested a refiring.protected boolean
_isFlowPort(IOPort port)
Deprecated.Return true if the specified port is a flow port.protected boolean
_iterateActorOnce(Actor actor)
Deprecated.Iterate the specified actor once.protected ProcessThread
_newProcessThread(Actor actor, ProcessDirector director)
Deprecated.Create a new ProcessThread for controlling the actor that is passed as a parameter of this method.protected boolean
_resolveDeadlock()
Deprecated.Return true indicating that deadlock has been resolved and that execution should continue.protected Time
_runToCompletion(Actor actor)
Deprecated.Iterate the specified actor until its input queue is empty and any pending fireAt() time requests are in the future.java.lang.Object
clone(Workspace workspace)
Deprecated.Clone the director into the specified workspace.void
fire()
Deprecated.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)
Deprecated.Override the base class to make a local record of the requested firing.void
initialize()
Deprecated.Invoke the initialize() method of ProcessDirector.void
initialize(Actor actor)
Deprecated.Initialize the given actor.Receiver
newReceiver()
Deprecated.Return a new receiver SysMLAReceiver.boolean
postfire()
Deprecated.Return false if a stop has been requested or if the model has reached deadlock.boolean
prefire()
Deprecated.Override the base class to set time to match environment time if this director is embedded.void
stop()
Deprecated.Request that the director cease execution altogether.boolean
transferInputs(IOPort port)
Deprecated.Transfer at most one token from an input port of the container to the ports it is connected to on the inside.void
transferOutputs()
Deprecated.For all inputs in the input queue of the container of this actor, put the input token into the inside of the corresponding output port and then transfer outputs from that port.void
wrapup()
Deprecated.If activeObjects is true, then delegate to the superclass; otherwise, invoke the wrapup() method of all the actors contained in the director's container.-
Methods inherited from class ptolemy.actor.process.ProcessDirector
_areAllThreadsStopped, _getActiveThreadsCount, _getBlockedThreadsCount, _getStoppedThreadsCount, _requestFinishOnReceivers, addThread, finish, isStopFireRequested, isThreadActive, preinitialize, removeThread, stopFire, terminate, threadBlocked, threadHasPaused, threadHasResumed, threadUnblocked, transferOutputs
-
Methods inherited from class ptolemy.actor.Director
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, suggestedModalModelDirectors, supportMultirateFiring, suspend
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_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
-
-
-
-
Field Detail
-
activeObjects
public Parameter activeObjects
Deprecated.If true, then every actor executes in its own thread. This is a boolean that defaults to false.
-
-
Constructor Detail
-
SysMLADirector
public SysMLADirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Deprecated.Construct a director in the given container with the given name.- Parameters:
container
- Container of the director.name
- Name of this director.- Throws:
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.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Deprecated.Clone the director into the specified workspace.- Overrides:
clone
in classProcessDirector
- Parameters:
workspace
- The workspace for the cloned object.- Returns:
- The new PNDirector.
- Throws:
java.lang.CloneNotSupportedException
- If one of the attributes cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Deprecated.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. Then deal with the deadlock by calling the protected method _resolveDeadlock() and return. This method is synchronized on the director.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classProcessDirector
- Throws:
IllegalActionException
- If a derived class throws it.
-
fireAt
public Time fireAt(Actor actor, Time time, int microstep) throws IllegalActionException
Deprecated.Override the base class to make a local record of the requested firing.- Overrides:
fireAt
in classDirector
- Parameters:
actor
- The actor scheduled to be fired.time
- The requested time.microstep
- The requested microstep.- Returns:
- An instance of Time with the current time value, or if there is an executive director, the time at which the container of this director will next be fired in response to this request.
- Throws:
IllegalActionException
- If there is an executive director and it throws it. Derived classes may choose to throw this exception for other reasons.- See Also:
Director.fireAtCurrentTime(Actor)
,Director.fireContainerAt(Time)
-
initialize
public void initialize() throws IllegalActionException
Deprecated.Invoke the initialize() method of ProcessDirector. Also set all the state variables to the their initial values. The list of process listeners is not reset as the developer might want to reuse the list of listeners.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classDirector
- Throws:
IllegalActionException
- If the initialize() method of one of the deeply contained actors throws it.
-
initialize
public void initialize(Actor actor) throws IllegalActionException
Deprecated.Initialize the given actor. This method is generally called by the initialize() method of the director, and by the manager whenever an actor is added to an executing model as a mutation. This method will generally perform domain-specific initialization on the specified actor and call its initialize() method. In this base class, only the actor's initialize() method of the actor is called and no domain-specific initialization is performed. Typical actions a director might perform include starting threads to execute the actor or checking to see whether the actor can be managed by this director. For example, a time-based domain (such as CT) might reject sequence based actors.- Overrides:
initialize
in classProcessDirector
- Parameters:
actor
- The actor that is to be initialized.- Throws:
IllegalActionException
- If the actor is not acceptable to the domain. Not thrown in this base class.
-
newReceiver
public Receiver newReceiver()
Deprecated.Return a new receiver SysMLAReceiver.- Overrides:
newReceiver
in classDirector
- Returns:
- A new SysMLAReceiver.
-
postfire
public boolean postfire() throws IllegalActionException
Deprecated.Return false if a stop has been requested or if the model has reached deadlock. Otherwise, if there is a pending fireAt request, either advance time to that requested time (if at the top level) or request a firing at that time. If there is no pending fireAt request, then return false. Otherwise, return true.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classProcessDirector
- Returns:
- False if the director has detected a deadlock or a stop has been requested.
- Throws:
IllegalActionException
- If a derived class throws it.
-
prefire
public boolean prefire() throws IllegalActionException
Deprecated.Override the base class to set time to match environment time if this director is embedded.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classProcessDirector
- Returns:
- Whatever the superclass returns.
- Throws:
IllegalActionException
- Not thrown in this base class.
-
stop
public void stop()
Deprecated.Request that the director cease execution altogether. This causes a call to stop() on all actors contained by the container of this director (if activeObject is false) or on all actors with active threads (if activeObject is true), and sets a flag so that the next call to postfire() returns false.- Specified by:
stop
in interfaceExecutable
- Overrides:
stop
in classProcessDirector
-
transferInputs
public boolean transferInputs(IOPort port) throws IllegalActionException
Deprecated.Transfer at most one token from an input port of the container to the ports it is connected to on the inside.- Overrides:
transferInputs
in classProcessDirector
- Parameters:
port
- The port.- Returns:
- True if tokens were transferred.
- Throws:
IllegalActionException
- If transfer fails.
-
transferOutputs
public void transferOutputs() throws IllegalActionException
Deprecated.For all inputs in the input queue of the container of this actor, put the input token into the inside of the corresponding output port and then transfer outputs from that port.- Overrides:
transferOutputs
in classDirector
- Throws:
IllegalActionException
- If the transfer fails.
-
wrapup
public void wrapup() throws IllegalActionException
Deprecated.If activeObjects is true, then delegate to the superclass; otherwise, invoke the wrapup() method of all the actors contained in the director's container.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classProcessDirector
- Throws:
IllegalActionException
- If the wrapup() method of one of the associated actors throws it.
-
_areThreadsDeadlocked
protected boolean _areThreadsDeadlocked()
Deprecated.Override the base class to return true if all active threads are blocked.- Overrides:
_areThreadsDeadlocked
in classProcessDirector
- Returns:
- True if all active threads are blocked.
-
_clearReceivers
protected void _clearReceivers(Actor actor) throws IllegalActionException
Deprecated.Clear all the input receivers for the specified actor.- Parameters:
actor
- The actor.- Throws:
IllegalActionException
- If the receivers can't be cleared.
-
_earliestNextFiringTime
protected Time _earliestNextFiringTime()
Deprecated.Return the earliest time that any actor has requested a refiring. As a side effect, update the _winningThreads set to identify the threads that will be unblocked when time is advanced.- Returns:
- The next requested firing time.
-
_iterateActorOnce
protected boolean _iterateActorOnce(Actor actor) throws IllegalActionException
Deprecated.Iterate the specified actor once.- Parameters:
actor
- The actor to iterate.- Returns:
- True if either prefire() returns false or postfire() returns true.
- Throws:
IllegalActionException
- If the actor throws it.
-
_runToCompletion
protected Time _runToCompletion(Actor actor) throws IllegalActionException
Deprecated.Iterate the specified actor until its input queue is empty and any pending fireAt() time requests are in the future. NOTE: This method is used only if activeObjects = false.- Parameters:
actor
- The actor to run.- Returns:
- The earliest pending fireAt time in the future, or TIME.POSITIVE_INFINITY if there is none.
- Throws:
IllegalActionException
- If the actor throws it.
-
_isFlowPort
protected boolean _isFlowPort(IOPort port)
Deprecated.Return true if the specified port is a flow port.- Parameters:
port
- The port.- Returns:
- True if the port contains a boolean-valued parameter named "flow" with value true.
-
_newProcessThread
protected ProcessThread _newProcessThread(Actor actor, ProcessDirector director) throws IllegalActionException
Deprecated.Create a new ProcessThread for controlling the actor that is passed as a parameter of this method.- Overrides:
_newProcessThread
in classProcessDirector
- Parameters:
actor
- The actor that the created ProcessThread will control.director
- The director that manages the model that the created thread is associated with.- Returns:
- Return a new ProcessThread that will control the actor passed as a parameter for this method.
- Throws:
IllegalActionException
- If creating a new ProcessThread throws it.
-
_resolveDeadlock
protected boolean _resolveDeadlock() throws IllegalActionException
Deprecated.Return true indicating that deadlock has been resolved and that execution should continue. The postfire() method will deal with determining whether execution really should continue.- Overrides:
_resolveDeadlock
in classProcessDirector
- Returns:
- True.
- Throws:
IllegalActionException
- Not thrown in this class.
-
-