ptolemy.domains.ct.kernel
Class CTCaseDirector

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.Director
              extended by ptolemy.actor.lib.hoc.CaseDirector
                  extended by ptolemy.domains.ct.kernel.CTCaseDirector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Executable, Initializable, CTGeneralDirector, CTTransparentDirector, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class CTCaseDirector
extends CaseDirector
implements CTTransparentDirector

An CTCaseDirector governs the execution of the Case actor in CT.

Since:
Ptolemy II 5.2
Version:
$Id: CTCaseDirector.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (liuxj)
Proposed Rating:
Yellow (hyzheng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
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
CTCaseDirector(CompositeEntity container, java.lang.String name)
          Construct a director in the given container with the given name.
 
Method Summary
 void emitCurrentStates()
          Iterate the enbled refinements to emit the current states of their dynamic actors.
 double getCurrentStepSize()
          Ask for the current step size used by the solver from the executive CT director.
 double getErrorTolerance()
          Return error tolerance used for detecting enabled transitions.
 CTExecutionPhase getExecutionPhase()
          Get the current execution phase of this director.
 CTGeneralDirector getExecutiveCTGeneralDirector()
          Return the executive CT director of this director, or null if this director is at the top level or the executive director is not a CT general director.
 Time getIterationBeginTime()
          Return the begin time of the current iteration, this method only makes sense in continuous-time domain.
 Time getModelTime()
          Return the current time obtained from the executive director, if there is one, and otherwise return the local view of current time.
 java.lang.String getODESolverClassName()
          Get the ODE solver class name.
 void goToMarkedState()
          Restore the states of all the enabled refinements to the previously marked states.
 boolean hasCurrentEvent()
          Return true if the enabled refinements may produce events.
 boolean isDiscretePhase()
          Return true if this is the discrete phase execution.
 boolean isOutputAccurate()
          Retun true if all the current refinement has accurate output with the current step size.
 boolean isStateAccurate()
          Retun true if all the refinements can resolve their states with the current step size.
 void markState()
          Make the current states of all the enabled refinements.
 Receiver newReceiver()
          Return a CTReceiver.
 double predictedStepSize()
          Return the smallest next step size predicted by the all the enabled refinements, which are refinements that returned true in their prefire() methods in this iteration.
 boolean prefireDynamicActors()
          Return true if all the dynamic actors contained by the enabled refinements return true from their prefire() method.
 double refinedStepSize()
          Return the step size refined by all the enabled refinements, which are refinements that returned true in their prefire() methods in this iteration, or the enabled transition which requires the current time be the same with the time it is enabled.
 
Methods inherited from class ptolemy.actor.lib.hoc.CaseDirector
fire, fireAt, postfire, prefire
 
Methods inherited from class ptolemy.actor.Director
_description, _fireContainerAt, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, finish, fireAt, fireAtCurrentTime, getCausalityInterface, getCurrentTime, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, initialize, invalidateResolvedTypes, invalidateSchedule, isFireFunctional, isStopRequested, isStrict, iterate, preinitialize, preinitialize, removeInitializable, requestInitialization, setContainer, setCurrentTime, setModelTime, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, terminate, transferInputs, transferOutputs, wrapup
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CTCaseDirector

public CTCaseDirector(CompositeEntity container,
                      java.lang.String name)
               throws IllegalActionException,
                      NameDuplicationException
Construct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.

Parameters:
container - Container of this director.
name - Name of this director.
Throws:
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

emitCurrentStates

public void emitCurrentStates()
                       throws IllegalActionException
Iterate the enbled refinements to emit the current states of their dynamic actors.

Specified by:
emitCurrentStates in interface CTTransparentDirector
Throws:
IllegalActionException - If the current states can not be emitted.

getCurrentStepSize

public double getCurrentStepSize()
Ask for the current step size used by the solver from the executive CT director.

Specified by:
getCurrentStepSize in interface CTGeneralDirector
Returns:
The current step size.

getErrorTolerance

public final double getErrorTolerance()
Return error tolerance used for detecting enabled transitions.

Specified by:
getErrorTolerance in interface CTGeneralDirector
Overrides:
getErrorTolerance in class Director
Returns:
The error tolerance used for detecting enabled transitions.

getExecutiveCTGeneralDirector

public CTGeneralDirector getExecutiveCTGeneralDirector()
Return the executive CT director of this director, or null if this director is at the top level or the executive director is not a CT general director.

Specified by:
getExecutiveCTGeneralDirector in interface CTGeneralDirector
Returns:
The executive CT general director of this director, if there is any.

getExecutionPhase

public CTExecutionPhase getExecutionPhase()
Get the current execution phase of this director.

Specified by:
getExecutionPhase in interface CTGeneralDirector
Returns:
The current execution phase of this director.

getIterationBeginTime

public Time getIterationBeginTime()
Return the begin time of the current iteration, this method only makes sense in continuous-time domain.

Specified by:
getIterationBeginTime in interface CTGeneralDirector
Returns:
The begin time of the current iteration.

getModelTime

public Time getModelTime()
Return the current time obtained from the executive director, if there is one, and otherwise return the local view of current time.

Overrides:
getModelTime in class Director
Returns:
The current time.
See Also:
Director.setModelTime(Time)

getODESolverClassName

public java.lang.String getODESolverClassName()
Get the ODE solver class name.

Specified by:
getODESolverClassName in interface CTGeneralDirector
Returns:
the name of the ODE solver class.

goToMarkedState

public void goToMarkedState()
                     throws IllegalActionException
Restore the states of all the enabled refinements to the previously marked states.

Specified by:
goToMarkedState in interface CTTransparentDirector
Throws:
IllegalActionException - If there is no marked state.

hasCurrentEvent

public boolean hasCurrentEvent()
Return true if the enabled refinements may produce events.

Specified by:
hasCurrentEvent in interface CTTransparentDirector
Returns:
True if the enabled refinements may produce events.

isDiscretePhase

public boolean isDiscretePhase()
Return true if this is the discrete phase execution.

Specified by:
isDiscretePhase in interface CTGeneralDirector
Returns:
True if this is the discrete phase execution.

isOutputAccurate

public boolean isOutputAccurate()
Retun true if all the current refinement has accurate output with the current step size.

Specified by:
isOutputAccurate in interface CTTransparentDirector
Returns:
True if the current refinement has accurate output.

isStateAccurate

public boolean isStateAccurate()
Retun true if all the refinements can resolve their states with the current step size.

Specified by:
isStateAccurate in interface CTTransparentDirector
Returns:
True if all the refinements can resolve their states with the current step size.

markState

public void markState()
Make the current states of all the enabled refinements.

Specified by:
markState in interface CTTransparentDirector

newReceiver

public Receiver newReceiver()
Return a CTReceiver. By default, the signal type is continuous.

Overrides:
newReceiver in class CaseDirector
Returns:
a new CTReceiver with signal type as continuous.

predictedStepSize

public double predictedStepSize()
Return the smallest next step size predicted by the all the enabled refinements, which are refinements that returned true in their prefire() methods in this iteration. If there are no refinements, then return Double.MAX_VALUE. If a refinement is not a CTStepSizeControlActor, then its prediction is Double.MAX_VALUE.

Specified by:
predictedStepSize in interface CTTransparentDirector
Returns:
The predicted next step size.

prefireDynamicActors

public boolean prefireDynamicActors()
                             throws IllegalActionException
Return true if all the dynamic actors contained by the enabled refinements return true from their prefire() method.

Specified by:
prefireDynamicActors in interface CTTransparentDirector
Returns:
True if all dynamic actors of enabled refinements can be prefired.
Throws:
IllegalActionException - If the local directors of refinements throw it.

refinedStepSize

public double refinedStepSize()
Return the step size refined by all the enabled refinements, which are refinements that returned true in their prefire() methods in this iteration, or the enabled transition which requires the current time be the same with the time it is enabled. If there are no refinements, or no refinement is a CTStepSizeControlActor, then the refined step size is the smaller value between current step size of the executive director and refined step size from enabled transition.

Specified by:
refinedStepSize in interface CTTransparentDirector
Returns:
The refined step size.