|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.actor.Director
ptolemy.domains.modal.kernel.FSMDirector
ptolemy.domains.modal.kernel.MultirateFSMDirector
public class MultirateFSMDirector
This director extends FSMDirector by supporting production and consumption of multiple tokens on a port in a firing. This director assumes that every state has exactly one refinement, with one exception. A state may have no refinement if upon being entered, it has an outgoing transition with a guard that is true. This will be treated as a "transient state." Transient states can have preemptive and non-preemptive transitions, while non-transient states are assumed to have only non-preemptive transitions. When a modal model reaches a transient state, it will progress through that state to the next state until it encounters a state with a refinement. This procedure is done in the preinitialize() method and the postfire() method. Hence each time when a modal model is fired, the current state always has a state refinement.
The number of tokens to be transferred from an input port of the modal model is at most the token consumption rate inferred by the inside port of the current state refinement. The number of tokens to be transferred from an output port of the state refinement is exactly the token production rate inferred by the state refinement. If there are not enough tokens available from the refinement, an exception is thrown. The default token consumption and production rate of a port is 1.
When a state transition occurs, this director compares the port rates of the destination state refinement with that of the current state refinement. If the rates are different, then invalidate the schedule of the executive director of the modal model. Update the port rates of the modal model to be the port rates of the destination state refinement.
This director does not support transition refinements.
FSMDirector
,
Serialized Form
Red (hyzheng) |
Red (hyzheng) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
protected boolean |
_refinementPostfire
The returned value of the postfire() method of the currentRefinement. |
protected boolean |
_reinitialize
A flag indicating whether the initialize method is called due to reinitialization. |
Fields inherited from class ptolemy.domains.modal.kernel.FSMDirector |
---|
_currentLocalReceiverMap, _disabledActors, _enabledRefinements, _indexOffset, _localReceiverMaps, _stateRefinementsToPostfire, _transitionRefinementsToPostfire, controllerName |
Fields inherited from class ptolemy.actor.Director |
---|
_actorsFinishedExecution, _currentTime, _finishRequested, _initializables, _stopRequested, timeResolution |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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 | |
---|---|
MultirateFSMDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name. |
Method Summary | |
---|---|
protected void |
_declareDependency(ConstVariableModelAnalysis analysis,
IOPort port,
java.lang.String name,
java.util.List dependents)
Add a DependencyDeclaration (with the name "_MultirateFSMRateDependencyDeclaration") to the variable with the given name in the given port that declares the variable is dependent on the given list of variables. |
protected void |
_declareReconfigurationDependencyForRefinementRateVariables(ConstVariableModelAnalysis analysis,
IOPort port,
java.lang.String parameterName)
Declare the reconfiguration dependency in the given analysis associated with the parameter name of the given port. |
protected CompositeActor |
_getEnclosingDomainActor()
If the container of this director does not have an MultirateFSMDirector as its executive director, then return the container. |
private State |
_getNonTransientState()
Return the current state if it has a refinement. |
protected java.util.List |
_getRefinementRateVariables(IOPort port,
java.lang.String parameterName)
Return the set of variables with the given parameter name that are contained by ports connected to the given port on the inside. |
protected boolean |
_updateInputTokenConsumptionRates(TypedCompositeActor actor)
Extract the token consumption rates from the input ports of the current refinement and update the rates of the input ports of the modal model containing the refinement. |
protected boolean |
_updateOutputTokenProductionRates(TypedCompositeActor actor)
Extract the token production rates from the output ports of the current refinement and update the production and initial production rates of the output ports of the modal model containing the refinement. |
void |
chooseNextNonTransientState(State currentState)
Choose the next non-transient state given the current state. |
State |
chooseTransition(State state)
Choose an enabled transition leaving the given state. |
void |
fire()
Fire the modal model. |
Time |
fireAtCurrentTime(Actor actor)
Override the base class to ignore the fireAt() call if the specified actor is the controller. |
void |
initialize()
Initialize the modal model. |
boolean |
makeStateTransition()
Commit transition and set up new state and connection map if exactly one transition is enabled. |
Receiver |
newReceiver()
Return a new receiver of a type compatible with this director. |
boolean |
postfire()
Postfire the modal model and commit the transition. |
void |
preinitialize()
Preinitialize all actors deeply contained by the container of this director. |
boolean |
supportMultirateFiring()
Return a boolean to indicate whether a ModalModel under control of this director supports multirate firing. |
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. |
boolean |
transferOutputs(IOPort port)
Transfer data from an output port of the current refinement actor to the ports it is connected to on the outside. |
Methods inherited from class ptolemy.kernel.util.Attribute |
---|
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent |
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, getDisplayName, getFullName, getName, getName, setName |
Field Detail |
---|
protected boolean _reinitialize
protected boolean _refinementPostfire
Constructor Detail |
---|
public MultirateFSMDirector(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 is not a
CompositeActor and the name collides with an entity in the container.Method Detail |
---|
public void chooseNextNonTransientState(State currentState) throws IllegalActionException
currentState
- The current state.
IllegalActionException
- If a transient state is reached
but no further transition is enabled.public State chooseTransition(State state) throws IllegalActionException
state
- The given state.
IllegalActionException
- If a non-transient state has
preemptive transitions, or if a transition has refinement.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class FSMDirector
IllegalActionException
- If there is no controller or
the current state has no or more than one refinement.public Time fireAtCurrentTime(Actor actor) throws IllegalActionException
fireAtCurrentTime
in class Director
actor
- The actor scheduled to be fired.
IllegalActionException
- If thrown by the executive director.Director.fireAt(Actor, Time)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class FSMDirector
IllegalActionException
- If the refinement has no or more
than one refinement, or the initialize() method of one of the
associated actors throws it.public boolean makeStateTransition() throws IllegalActionException
IllegalActionException
- If there is no controller, or if the
destination state has no or more than one refinement, or if the state
refinement throws it.public Receiver newReceiver()
newReceiver
in class FSMDirector
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class FSMDirector
IllegalActionException
- If a refinement throws it, or
if there is no controller.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class Director
IllegalActionException
- If there is no controller, or if the
non-transient initial state has no or more than one refinement, or if
the preinitialize() method of one of the associated actors throws it.public boolean supportMultirateFiring()
supportMultirateFiring
in class Director
public boolean transferInputs(IOPort port) throws IllegalActionException
transferInputs
in class FSMDirector
port
- The input port to transfer tokens from.
IllegalActionException
- If the port is not an opaque
input port.public boolean transferOutputs(IOPort port) throws IllegalActionException
transferOutputs
in class Director
port
- The port to transfer tokens from.
IllegalActionException
- If the port is not an opaque
output port.protected void _declareDependency(ConstVariableModelAnalysis analysis, IOPort port, java.lang.String name, java.util.List dependents) throws IllegalActionException
analysis
- The object that contains the dependency declarations.port
- The IOPort to get rate variables from.name
- The name of the IOPort.dependents
- The dependents that the dependency declaration of the
given IO port depends on.
IllegalActionException
- If a valid rate variable from the
given port can not be found, or the variable does not contain a
DependencyDeclaration attribute, or a new DependencyDeclaration object
can not be created, or can not associated with the analysis object the
newly created DependencyDeclaration object.protected void _declareReconfigurationDependencyForRefinementRateVariables(ConstVariableModelAnalysis analysis, IOPort port, java.lang.String parameterName) throws IllegalActionException
analysis
- The object that contains the dependency declarations.port
- The IOPort to get refinement rate variables from.parameterName
- The name of the rate variables.
IllegalActionException
- If can not get the refinement rate
variables from the given port, or can not add the dependency declaration
of the given port to the analysis object, or a declared constant rate
variable does not contain a constant value.protected CompositeActor _getEnclosingDomainActor() throws IllegalActionException
IllegalActionException
- If the top-level director is an
MultirateFSMDirector. This director is intended for use only inside
some other domain.protected java.util.List _getRefinementRateVariables(IOPort port, java.lang.String parameterName) throws IllegalActionException
port
- The given port.parameterName
- The given parameter name.
IllegalActionException
- If can not get a rate variable
from the port that is connected to the given port from inside.protected boolean _updateInputTokenConsumptionRates(TypedCompositeActor actor) throws IllegalActionException
actor
- The current refinement.
IllegalActionException
- If can not find the controller, or
the port connections between controller and refinements are not
correct, or can not get valid token consumption rates for input ports.protected boolean _updateOutputTokenProductionRates(TypedCompositeActor actor) throws IllegalActionException
actor
- The current refinement.
IllegalActionException
- If we cannot get valid token
consumption rates for input ports.private State _getNonTransientState() throws IllegalActionException
IllegalActionException
- If a transient state is reached
while no further transition is enabled.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |