|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.actor.Director
ptolemy.domains.fsm.kernel.FSMDirector
An FSMDirector governs the execution of a modal model. A modal model is a TypedCompositeActor with a FSMDirector as local director. The mode control logic is captured by a mode controller, an instance of FSMActor contained by the composite actor. Each state of the mode controller represents a mode of operation and can be refined by a TypedActor contained by the same composite actor.
When a modal model is fired, this director first transfers the input tokens from the outside domain to the mode controller and the refinement of its current state. The preemptive transitions from the current state of the mode controller are examined. If there is more than one transition enabled, an exception is thrown. If there is exactly one preemptive transition enabled then it is chosen and the choice actions contained by the transition are executed. The refinement of the current state is not fired. Any output token produced by the mode controller is transferred to the outside domain. If no preemptive transition is enabled, the refinement of the current state is fired. The non-preemptive transitions from the current state of the mode controller are examined. If there is more than one transition enabled, an exception is thrown. If there is exactly one non-preemptive transition enabled then it is chosen and the choice actions contained by the transition are executed. Any output token produced by the mode controller or the refinement is transferred to the outside domain.
The mode controller does not change state during successive firings in one iteration in order to support outside domains that iterate to a fixed point. When the modal model is postfired, the chosen transition of the latest firing is committed. The commit actions contained by the transition are executed and the current state of the mode controller is set to the destination state of the transition.
FSMActor,
Serialized Form
| Yellow (liuxj) |
| Yellow (liuxj) |
| Nested Class Summary |
| Nested classes inherited from class ptolemy.kernel.util.NamedObj |
ptolemy.kernel.util.NamedObj.ContainedObjectsIterator |
| Field Summary | |
protected java.util.Map |
_currentLocalReceiverMap
|
protected java.util.List |
_enabledRefinements
|
protected boolean |
_fireRefinement
|
protected boolean |
_firstFire
|
protected java.util.Map |
_localReceiverMaps
|
ptolemy.kernel.util.StringAttribute |
controllerName
Attribute specifying the name of the mode controller in the container of this director. |
| Fields inherited from class ptolemy.actor.Director |
_currentTime, _stopRequested |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
| Fields inherited from interface ptolemy.actor.Executable |
COMPLETED, NOT_READY, STOP_ITERATING |
| Constructor Summary | |
FSMDirector()
Construct a director in the default workspace with an empty string as its name. |
|
FSMDirector(ptolemy.kernel.CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name. |
|
FSMDirector(ptolemy.kernel.util.Workspace workspace)
Construct a director in the workspace with an empty name. |
|
| Method Summary | |
protected void |
_buildLocalReceiverMaps()
|
protected Transition |
_chooseTransition(java.util.List transitionList)
Return the enabled transition among the given list of transitions. |
protected ptolemy.actor.Receiver[][] |
_currentLocalReceivers(ptolemy.actor.IOPort port)
Return the receivers contained by ports connected to the inside of the given input port and on the mode controller or the refinement of its current state. |
protected Transition |
_getLastChosenTransition()
Return the last chosen transition. |
protected void |
_readInputs()
Set the value of the shadow variables for input ports of the controller actor. |
protected void |
_readOutputsFromRefinement()
Set the value of the shadow variables for input ports of the controller actor that are defined by output ports of the refinement. |
protected void |
_setCurrentConnectionMap()
Set the map from input ports to boolean flags indicating whether a channel is connected to an output port of the refinement of the current state. |
protected void |
_setCurrentState(State state)
Set the current state of this actor. |
void |
attributeChanged(ptolemy.kernel.util.Attribute attribute)
React to a change in an attribute. |
java.lang.Object |
clone(ptolemy.kernel.util.Workspace workspace)
Clone the director into the specified workspace. |
void |
fire()
Set the values of input variables in the mode controller. |
void |
fireAt(ptolemy.actor.Actor actor,
double time)
Schedule a firing of the given actor at the given time. |
ptolemy.kernel.Entity |
getContext()
Return the change context being made explicit. |
FSMActor |
getController()
Return the mode controller of this director. |
java.util.List |
getModifiedVariables()
Return a list of variables that are modified in a modal model. |
double |
getNextIterationTime()
Return the next iteration time provided by the refinement of the current state of the mode controller. |
boolean |
handleModelError(ptolemy.kernel.util.NamedObj context,
ptolemy.kernel.util.IllegalActionException exception)
Handle a model error by checking if there is any enabled non-preemptive transitions. |
void |
initialize()
Initialize the mode controller and all the refinements. |
ptolemy.actor.Receiver |
newReceiver()
Return a receiver that is a one-place buffer. |
boolean |
postfire()
Return true if the mode controller wishes to be scheduled for another iteration. |
boolean |
prefire()
Return true if the mode controller is ready to fire. |
void |
setContainer(ptolemy.kernel.util.NamedObj container)
If the container is not null, register this director as the model error handler. |
void |
setCurrentTime(double newTime)
Set the current time of the model under this director. |
boolean |
transferInputs(ptolemy.actor.IOPort port)
Transfer data from the input port of the container to the ports connected to the inside of the input port and on the mode controller or the refinement of its current state. |
| Methods inherited from class ptolemy.actor.Director |
_description, _isEmbedded, _isTopLevel, _writeAccessRequired, domainPolymorphicTransferInputs, domainPolymorphicTransferOutputs, fireAtCurrentTime, getCurrentTime, getTimeResolution, initialize, invalidateResolvedTypes, invalidateSchedule, iterate, needWriteAccess, preinitialize, requestInitialization, setTimeResolution, stop, stopFire, terminate, transferOutputs, wrapup |
| Methods inherited from class ptolemy.kernel.util.Attribute |
_getContainedObject, _propagateExistence, getContainer, setName |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, uniqueName, validateSettables, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ptolemy.kernel.util.Nameable |
description, getContainer, getFullName, getName, getName, setName |
| Field Detail |
public ptolemy.kernel.util.StringAttribute controllerName
protected java.util.Map _currentLocalReceiverMap
protected java.util.List _enabledRefinements
protected boolean _firstFire
protected boolean _fireRefinement
protected java.util.Map _localReceiverMaps
| Constructor Detail |
public FSMDirector()
public FSMDirector(ptolemy.kernel.util.Workspace workspace)
workspace - The workspace of this director.
public FSMDirector(ptolemy.kernel.CompositeEntity container,
java.lang.String name)
throws ptolemy.kernel.util.IllegalActionException,
ptolemy.kernel.util.NameDuplicationException
container - Container of this director.name - Name of this director.
ptolemy.kernel.util.IllegalActionException - If the name has a period in it, or
the director is not compatible with the specified container.
ptolemy.kernel.util.NameDuplicationException - If the container not a
CompositeActor and the name collides with an entity in the container.| Method Detail |
public void attributeChanged(ptolemy.kernel.util.Attribute attribute)
throws ptolemy.kernel.util.IllegalActionException
attribute - The attribute that changed.
ptolemy.kernel.util.IllegalActionException - If thrown by the superclass
attributeChanged() method.
public java.lang.Object clone(ptolemy.kernel.util.Workspace workspace)
throws java.lang.CloneNotSupportedException
workspace - The workspace for the new director.
java.lang.CloneNotSupportedException - If a derived class contains
an attribute that cannot be cloned.
public void fire()
throws ptolemy.kernel.util.IllegalActionException
fire in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - If there is more than one
transition enabled, or there is no controller, or thrown by any
choice action.
public void fireAt(ptolemy.actor.Actor actor,
double time)
throws ptolemy.kernel.util.IllegalActionException
actor - The actor scheduled to be fired.time - The scheduled time.
ptolemy.kernel.util.IllegalActionException - If thrown in scheduling
a firing of the container of this director at the given
time with the executive director.
public FSMActor getController()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If no controller is found.public ptolemy.kernel.Entity getContext()
getContext in interface ptolemy.actor.util.ExplicitChangeContext
public java.util.List getModifiedVariables()
throws ptolemy.kernel.util.IllegalActionException
getModifiedVariables in interface ptolemy.actor.util.ExplicitChangeContextptolemy.kernel.util.IllegalActionExceptionpublic double getNextIterationTime()
public boolean handleModelError(ptolemy.kernel.util.NamedObj context,
ptolemy.kernel.util.IllegalActionException exception)
throws ptolemy.kernel.util.IllegalActionException
handleModelError in interface ptolemy.kernel.util.ModelErrorHandlercontext - The context where the model error happens.exception - An exception that represents the model error.
ptolemy.kernel.util.IllegalActionException - The model error exception.
public void initialize()
throws ptolemy.kernel.util.IllegalActionException
initialize in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - If the initialize() method of
one of the associated actors throws it.public ptolemy.actor.Receiver newReceiver()
public boolean postfire()
throws ptolemy.kernel.util.IllegalActionException
postfire in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - If thrown by any commit action
or there is no controller.
public boolean prefire()
throws ptolemy.kernel.util.IllegalActionException
prefire in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - If there is no controller.
FIXME: Changed by liuj, not yet reviewed.
public void setContainer(ptolemy.kernel.util.NamedObj container)
throws ptolemy.kernel.util.IllegalActionException,
ptolemy.kernel.util.NameDuplicationException
container - The proposed container.
ptolemy.kernel.util.IllegalActionException - If the action would result in a
recursive containment structure, or if
this entity and container are not in the same workspace, or
if the protected method _checkContainer() throws it, or if
a contained Settable becomes invalid and the error handler
throws it.
ptolemy.kernel.util.NameDuplicationException - If the name of this entity
collides with a name already in the container.
public void setCurrentTime(double newTime)
throws ptolemy.kernel.util.IllegalActionException
newTime - The new current simulation time.
ptolemy.kernel.util.IllegalActionException - Not thrown in this base class.
FIXME: Changed by liuj, not yet reviewed.
public boolean transferInputs(ptolemy.actor.IOPort port)
throws ptolemy.kernel.util.IllegalActionException
port - The input port to transfer tokens from.
ptolemy.kernel.util.IllegalActionException - If the port is not an opaque
input port.
protected void _buildLocalReceiverMaps()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException
protected Transition _chooseTransition(java.util.List transitionList)
throws ptolemy.kernel.util.IllegalActionException
transitionList - A list of transitions.
ptolemy.kernel.util.IllegalActionException - If there is more than one
transition enabled, or if thrown by any choice action contained
by the enabled transition, or if there is no controller.
protected ptolemy.actor.Receiver[][] _currentLocalReceivers(ptolemy.actor.IOPort port)
throws ptolemy.kernel.util.IllegalActionException
port - An input port of the container of this director.
ptolemy.kernel.util.IllegalActionException - If there is no controller.protected Transition _getLastChosenTransition()
protected void _setCurrentState(State state)
throws ptolemy.kernel.util.IllegalActionException
state - The state to set.
ptolemy.kernel.util.IllegalActionException - If there is no controller.
protected void _setCurrentConnectionMap()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If the refinement specified
for one of the states is not valid, or if there is no controller.
protected void _readOutputsFromRefinement()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If a shadow variable cannot take
the token read from its corresponding channel (should not occur).
protected void _readInputs()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If a shadow variable cannot take
the token read from its corresponding channel (should not occur).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||