|
||||||||||
| 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 |
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
|
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(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name. |
|
FSMDirector(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 Receiver[][] |
_currentLocalReceivers(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(Attribute attribute)
React to a change in an attribute. |
java.lang.Object |
clone(Workspace workspace)
Clone the director into the specified workspace. |
void |
fire()
Set the values of input variables in the mode controller. |
void |
fireAt(Actor actor,
double time)
Schedule a firing of the given actor at the given time. |
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(NamedObj context,
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. |
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(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(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 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 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(Workspace workspace)
workspace - The workspace of this director.
public FSMDirector(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
container - Container of this director.name - Name of this director.
IllegalActionException - If the name has a period in it, or
the director is not compatible with the specified container.
NameDuplicationException - If the container not a
CompositeActor and the name collides with an entity in the container.| Method Detail |
public void attributeChanged(Attribute attribute)
throws IllegalActionException
attributeChanged in class NamedObjattribute - The attribute that changed.
IllegalActionException - If thrown by the superclass
attributeChanged() method.
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
clone in class Attributeworkspace - The workspace for the new director.
java.lang.CloneNotSupportedException - If a derived class contains
an attribute that cannot be cloned.
public void fire()
throws IllegalActionException
fire in interface Executablefire in class DirectorIllegalActionException - If there is more than one
transition enabled, or there is no controller, or thrown by any
choice action.
public void fireAt(Actor actor,
double time)
throws IllegalActionException
fireAt in class Directoractor - The actor scheduled to be fired.time - The scheduled time.
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 IllegalActionException
IllegalActionException - If no controller is found.public Entity getContext()
getContext in interface ExplicitChangeContext
public java.util.List getModifiedVariables()
throws IllegalActionException
getModifiedVariables in interface ExplicitChangeContextIllegalActionException - If the list of modified
variables cannot be returned.public double getNextIterationTime()
getNextIterationTime in class Director
public boolean handleModelError(NamedObj context,
IllegalActionException exception)
throws IllegalActionException
handleModelError in interface ModelErrorHandlerhandleModelError in class NamedObjcontext - The context where the model error happens.exception - An exception that represents the model error.
IllegalActionException - The model error exception.NamedObj.setModelErrorHandler(ModelErrorHandler handler)
public void initialize()
throws IllegalActionException
initialize in interface Executableinitialize in class DirectorIllegalActionException - If the initialize() method of
one of the associated actors throws it.public Receiver newReceiver()
newReceiver in class Director
public boolean postfire()
throws IllegalActionException
postfire in interface Executablepostfire in class DirectorIllegalActionException - If thrown by any commit action
or there is no controller.
public boolean prefire()
throws IllegalActionException
prefire in interface Executableprefire in class DirectorIllegalActionException - If there is no controller.
FIXME: Changed by liuj, not yet reviewed.
public void setContainer(NamedObj container)
throws IllegalActionException,
NameDuplicationException
setContainer in class Directorcontainer - The proposed container.
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.
NameDuplicationException - If the name of this entity
collides with a name already in the container.
public void setCurrentTime(double newTime)
throws IllegalActionException
setCurrentTime in class DirectornewTime - The new current simulation time.
IllegalActionException - Not thrown in this base class.
FIXME: Changed by liuj, not yet reviewed.
public boolean transferInputs(IOPort port)
throws IllegalActionException
transferInputs in class Directorport - The input port to transfer tokens from.
IllegalActionException - If the port is not an opaque
input port.IOPort.transferInputs()
protected void _buildLocalReceiverMaps()
throws IllegalActionException
IllegalActionException
protected Transition _chooseTransition(java.util.List transitionList)
throws IllegalActionException
transitionList - A list of transitions.
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 Receiver[][] _currentLocalReceivers(IOPort port)
throws IllegalActionException
port - An input port of the container of this director.
IllegalActionException - If there is no controller.protected Transition _getLastChosenTransition()
protected void _setCurrentState(State state)
throws IllegalActionException
state - The state to set.
IllegalActionException - If there is no controller.
protected void _setCurrentConnectionMap()
throws IllegalActionException
IllegalActionException - If the refinement specified
for one of the states is not valid, or if there is no controller.
protected void _readOutputsFromRefinement()
throws IllegalActionException
IllegalActionException - If a shadow variable cannot take
the token read from its corresponding channel (should not occur).
protected void _readInputs()
throws IllegalActionException
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 | |||||||||