public class SequenceScheduler extends Scheduler
A SequenceScheduler is contained by a SequencedModelDirector, and provides the schedule for it. The director will use this schedule to govern the execution of a CompositeActor.
A schedule is represented by the Schedule class, and determines the order of the firing of the actors in a particular composite actor. In this base class, the default schedule fires the deeply contained actors in the order of their construction. A domain specific scheduler will override this to provide a different order.
The schedule, once constructed, is cached and reused as long as the schedule is still valid. The validity of the schedule is set by the setValid() method. If the current schedule is not valid, then the schedule will be recomputed the next time the getSchedule() method is called. However, derived classes will usually override only the protected _getSchedule() method.
The scheduler does not perform any mutations, and it does not listen for changes in the model. Directors that use this scheduler should normally invalidate the schedule when mutations occur.
Schedule
Red (beth) |
Red (beth) |
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
DirectedGraph |
_actorGraph
The DirectedGraph for the model.
|
(package private) java.util.Hashtable<Actor,java.util.List<Node>> |
_actorGraphNodeList
Hashtable of actors to graph nodes
FIXME: Is there a better way to do this?
|
(package private) boolean |
_allowDisconnectedGraphs
Cache of the value of allowDisconnectedGraphs.
|
protected static java.lang.String |
_DEFAULT_SCHEDULER_NAME
The default name.
|
protected boolean |
_scheduleUnexecutedActors
Flag for appending all the unexecuted actors that are not sequenced at the end of the schedule.
|
(package private) java.util.Hashtable<Node,java.lang.Boolean> |
_visitedNodes
Hashtable of graph nodes to a boolean value
Keeps track of which nodes in the graph have been visited
(in other words, can be scheduled somewhere)
Anything that has not been visited is unreachable.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
SequenceScheduler()
Construct a scheduler with no container(director)
in the default workspace, the name of the scheduler is
"Scheduler".
|
SequenceScheduler(Director container,
java.lang.String name)
Construct a scheduler in the given container with the given name.
|
SequenceScheduler(Workspace workspace)
Construct a scheduler in the given workspace with the name
"Scheduler".
|
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
_getInitialValueParameterName(TypedIOPort port,
int channel)
Return the initialValueParameter name for each of the port .
|
protected SequenceSchedule |
_getSchedule(boolean validSequence)
Beth - The SequenceScheduler assembles the structures that the
SequenceSchedule will need to determine the next actor to fire.
|
java.lang.Object |
clone(Workspace workspace)
Clone the scheduler into the specified workspace.
|
SequenceSchedule |
getSchedule(java.util.List<SequenceAttribute> independentList)
Return the schedule assuming that list of sequence numbers is for a valid
schedule and not for a list of unexecuted actors after a valid schedule
has been executed.
|
SequenceSchedule |
getSchedule(java.util.List<SequenceAttribute> independentList,
boolean validSequence)
Have to override this function in order to return a SequenceSchedule
All additional code copied from Scheduler.java
Have to also introduce own local variable, _cachedGetSchedule,
to be of type SequenceSchedule
The Sequence Scheduler takes one list as input
- A list of independent sequenced actor attributes
The sequence scheduler determines an additional list:
- A list of sequenced actors that are dependent on control actors,
or other actors
It is possible to get the actor name from a sequence attribute by
calling attributename.getContainer()
Return the scheduling sequence as an instance of the Schedule class.
|
void |
printSubGraph(DirectedAcyclicGraph subGraph)
Print the subGraph edges and nodes.
|
void |
setContainer(NamedObj container)
FIXME: Keep this or change?
|
boolean |
unreachableActorExists()
Prints a list of unreachable actors, that are unreachable due to a lack of
connected actors.
|
java.util.List<Actor> |
unreachableActorList()
Returns a list of unreachable actors found in the most recent call to
Scheduler.getSchedule() . |
_getSchedule, getSchedule, isValid, setValid
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, 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 static final java.lang.String _DEFAULT_SCHEDULER_NAME
protected boolean _scheduleUnexecutedActors
boolean _allowDisconnectedGraphs
public DirectedGraph _actorGraph
java.util.Hashtable<Actor,java.util.List<Node>> _actorGraphNodeList
java.util.Hashtable<Node,java.lang.Boolean> _visitedNodes
public SequenceScheduler()
public SequenceScheduler(Workspace workspace)
workspace
- Object for synchronization and version tracking.public SequenceScheduler(Director container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this attribute.IllegalActionException
- If the attribute is not of an
acceptable class for the container, or if the name contains a period.NameDuplicationException
- If the name coincides with
an attribute already in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Scheduler
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 SequenceSchedule getSchedule(java.util.List<SequenceAttribute> independentList, boolean validSequence) throws IllegalActionException, NotSchedulableException
independentList
- List of independent and dependent
sequence attributes (and, associated actors, found by calling
getContainer() on a SequenceAttribute) There must be at least
one sequence attribute in the _independentList.validSequence
- true if the schedule being returned is
for a valid sequence schedule and not for a list of unexecuted actors,
false otherwise.IllegalActionException
- If the scheduler has no container
(a director), or the director has no container (a CompositeActor),
or the scheduling algorithm throws it.NotSchedulableException
- If the _getSchedule() method
throws it. Not thrown in this base class, but may be needed
by the derived schedulers.public SequenceSchedule getSchedule(java.util.List<SequenceAttribute> independentList) throws IllegalActionException, NotSchedulableException
independentList
- List of independent and dependent
sequence attributes (and, associated actors, found by calling
getContainer() on a SequenceAttribute) There must be at least
one sequence attribute in the _independentList.IllegalActionException
- If the scheduler has no container
(a director), or the director has no container (a CompositeActor),
or the scheduling algorithm throws it.NotSchedulableException
- If the _getSchedule() method
throws it.public java.util.List<Actor> unreachableActorList()
Scheduler.getSchedule()
. Actors are unreachable if they
are not connected FIXME and have no sequence number?.
, that are unreachable due to a lack of
connected actors. These will be 'upstream' actors that are not upstream
of any sequenced actor.
This is done by returning a list of all actors with a 'false' entry
in the hashtable _visitedNodes.
This method is meant to be called after processGraph() has been called for
all schedules. However, the SequenceScheduler itself does not know if there
are any more schedules remaining. So, the director can call this function,
once all schedules have been handled.public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException
If this method results in removing this director from a container that is a Director, then this scheduler ceases to be the active scheduler for that CompositeActor. Moreover, if the director contains any other schedulers, then the most recently added of those schedulers becomes the active scheduler.
This method is write-synchronized to the workspace and increments its version number.
setContainer
in class Scheduler
container
- The proposed container.IllegalActionException
- If the action would result in a
recursive containment structure, or if
this scheduler and container are not in the same workspace, or
if the protected method _checkContainer() throws it.NameDuplicationException
- If the name of this scheduler
collides with a name already in the container. This will not
be thrown if the container argument is an instance of
CompositeActor.Attribute.getContainer()
protected SequenceSchedule _getSchedule(boolean validSequence) throws IllegalActionException, NotSchedulableException
validSequence
- true if the schedule being returned is
for a valid sequence schedule and not for a list of unexecuted actors,
false otherwise.IllegalActionException
- If the scheduling algorithm
throws it. Not thrown in this base class, but may be thrown
by derived classes.NotSchedulableException
- If the CompositeActor is not
schedulable. Not thrown in this base class, but may be thrown
by derived classes.CompositeEntity.deepEntityList()
public boolean unreachableActorExists()
public void printSubGraph(DirectedAcyclicGraph subGraph)
subGraph
- The directed acyclic graph to print.protected static java.lang.String _getInitialValueParameterName(TypedIOPort port, int channel)
port
- The port.channel
- The channel of the port.