ptolemy.domains.ct.kernel
Class CTEmbeddedDirector

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.Director
              extended by ptolemy.actor.sched.StaticSchedulingDirector
                  extended by ptolemy.domains.ct.kernel.CTDirector
                      extended by ptolemy.domains.ct.kernel.CTMultiSolverDirector
                          extended by ptolemy.domains.ct.kernel.CTEmbeddedDirector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Executable, Initializable, TimedDirector, CTGeneralDirector, CTTransparentDirector, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class CTEmbeddedDirector
extends CTMultiSolverDirector
implements CTTransparentDirector

An embedded director for CT inside CT or FSM. Conceptually, this director interacts with a continuous outside domain. As a consequence, this director exposes its step size control information to the outer domain through its container, which must be a CTCompositeActor.

Unlike the CTMixedSignalDirector, this director does not run ahead of the global time and rollback, simply because the step size control information is accessible from outer domain which has a continuous time and understands the meaning of step size.

Since:
Ptolemy II 0.2
Version:
$Id: CTEmbeddedDirector.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Jie Liu, Haiyang Zheng
See Also:
CTMultiSolverDirector, CTTransparentDirector, Serialized Form
Accepted Rating:
Red (hyzheng)
Proposed Rating:
Yellow (hyzheng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private  boolean _outputAcceptable
           
private  boolean _stateAcceptable
           
 
Fields inherited from class ptolemy.domains.ct.kernel.CTMultiSolverDirector
_initialStatesNotReady, breakpointODESolver, ODESolver
 
Fields inherited from class ptolemy.domains.ct.kernel.CTDirector
_timeBase, errorTolerance, initStepSize, maxIterations, maxStepSize, minStepSize, startTime, stopTime, synchronizeToRealTime, valueResolution
 
Fields inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_postfireReturns
 
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
CTEmbeddedDirector()
          Construct a director in the default workspace with an empty string as its name.
CTEmbeddedDirector(CompositeEntity container, java.lang.String name)
          Construct a director in the given container with the given name.
CTEmbeddedDirector(Workspace workspace)
          Construct a director in the workspace with an empty name.
 
Method Summary
 boolean canBeInsideDirector()
          Always return true indicating that this director can be an inside director.
 boolean canBeTopLevelDirector()
          Always return false indicating that this director cannot be a top-level director.
 void emitCurrentStates()
          Emit the current states of the dynamic actors executed by this director.
 void fire()
          Execute the subsystem for one iteration.
 double getCurrentStepSize()
          Return the current integration step size, which is inherited from the executive CT director.
 CTExecutionPhase getExecutionPhase()
          Get the current execution phase, which is inherited from the executive CT director.
 CTGeneralDirector getExecutiveCTGeneralDirector()
          Return the executive CT general director of this director.
 Time getIterationBeginTime()
          Return the begin time of the current iteration.
 void goToMarkedState()
          Restore the saved states, which include the states of stateful actors.
 void initialize()
          Call the initialize() method of the super class.
 boolean isDiscretePhase()
          Return true if this is the discrete phase execution.
 boolean isOutputAccurate()
          Return true if all output step size control actors are satisfied with the current step size.
 boolean isStateAccurate()
          Return true if all state step size control actors are satisfied with the current step size.
 void markState()
          Mark the known good states, including the states of the stateful actors.
 boolean postfire()
          Return false if some actor returns false from its postfire method or a stop is requested.
 double predictedStepSize()
          Return the predicted next step size, which is the minimum of the prediction from all step size control actors.
 boolean prefire()
          Call the prefire of the super class.
 void preinitialize()
          Check whether the container implements the CTStepSizeControlActor interface.
 double refinedStepSize()
          Return the refined step size if the current fire is not accurate.
 
Methods inherited from class ptolemy.domains.ct.kernel.CTMultiSolverDirector
_continuousPhaseExecution, _discretePhaseExecution, _initParameters, _isOutputAccurate, _isStateAccurate, _iterateEventGenerators, _iteratePurelyDiscreteActors, _iterateWaveformGenerators, _predictNextStepSize, _propagateResolvedStates, _refinedStepWRTOutput, _refinedStepWRTState, _removeCurrentTimeFromBreakpointTable, _resolveInitialStates, attributeChanged, establishInitialStates, fireEventGenerators, getBreakpointSolver, getNormalODESolver, getODESolverClassName, hasCurrentEvent, postfireEventGenerators, produceOutput, setInitialStatesNotReady, setModelTime, updateContinuousStates
 
Methods inherited from class ptolemy.domains.ct.kernel.CTDirector
_instantiateODESolver, _setCurrentODESolver, _setDiscretePhase, _setExecutionPhase, _setIterationBeginTime, clone, delayDependency, fireAt, getBreakPoints, getCurrentODESolver, getErrorTolerance, getInitialStepSize, getMaxIterations, getMaxStepSize, getMinStepSize, getModelNextIterationTime, getModelStartTime, getModelStopTime, getSuggestedNextStepSize, getValueResolution, newReceiver, prefireClear, prefireDynamicActors, setCurrentStepSize, setSuggestedNextStepSize, suggestedModalModelDirectors
 
Methods inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_setScheduler, addDebugListener, getScheduler, invalidateSchedule, isScheduleValid, removeDebugListener, setScheduler
 
Methods inherited from class ptolemy.actor.Director
_description, _fireContainerAt, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, addInitializable, createSchedule, defaultDependency, finish, fireAt, fireAtCurrentTime, getCausalityInterface, getCurrentTime, getGlobalTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, isFireFunctional, isStopRequested, isStrict, iterate, preinitialize, removeInitializable, requestInitialization, setContainer, setCurrentTime, stop, stopFire, supportMultirateFiring, terminate, transferInputs, transferOutputs, wrapup
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, 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, 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, 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
 
Methods inherited from interface ptolemy.domains.ct.kernel.CTTransparentDirector
hasCurrentEvent, prefireDynamicActors
 
Methods inherited from interface ptolemy.domains.ct.kernel.CTGeneralDirector
getErrorTolerance, getODESolverClassName
 
Methods inherited from interface ptolemy.actor.TimedDirector
getModelTime, getTimeResolution
 

Field Detail

_outputAcceptable

private boolean _outputAcceptable

_stateAcceptable

private boolean _stateAcceptable
Constructor Detail

CTEmbeddedDirector

public CTEmbeddedDirector()
Construct a director in the default workspace with an empty string as its name. The director is added to the list of objects in the workspace. Increment the version number of the workspace. All the parameters take their default values.


CTEmbeddedDirector

public CTEmbeddedDirector(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. All the parameters take their default values.

Parameters:
container - The container.
name - Name of this director.
Throws:
IllegalActionException - If the director is not compatible with the specified container. May be thrown in a derived class.
NameDuplicationException - If the container is not a CompositeActor and the name collides with an entity in the container.

CTEmbeddedDirector

public CTEmbeddedDirector(Workspace workspace)
Construct a director in the workspace with an empty name. The director is added to the list of objects in the workspace. Increment the version number of the workspace. All the parameters take their default values.

Parameters:
workspace - The workspace of this object.
Method Detail

canBeInsideDirector

public boolean canBeInsideDirector()
Always return true indicating that this director can be an inside director.

Overrides:
canBeInsideDirector in class CTMultiSolverDirector
Returns:
True always.

canBeTopLevelDirector

public boolean canBeTopLevelDirector()
Always return false indicating that this director cannot be a top-level director.

Overrides:
canBeTopLevelDirector in class CTMultiSolverDirector
Returns:
False always.

emitCurrentStates

public void emitCurrentStates()
Emit the current states of the dynamic actors executed by this director.

Specified by:
emitCurrentStates in interface CTTransparentDirector

fire

public void fire()
          throws IllegalActionException
Execute the subsystem for one iteration. An iteration includes a discrete phase of execution and a continuous one. If states cannot be resolved accurately, then this subsystem may produce a meaningless output. It is the outside system's responsibility to check whether this subsystem is accurate in this iteration, by calling the isOutputAccurate() and isStateAccurate() methods of the CTCompositeActor that contains this director.

Specified by:
fire in interface Executable
Overrides:
fire in class CTMultiSolverDirector
Throws:
IllegalActionException - If there does not exits a schedule, or ODE solver cannot be set, or any actor throws it during this iteration.

getCurrentStepSize

public double getCurrentStepSize()
Return the current integration step size, which is inherited from the executive CT director.

Specified by:
getCurrentStepSize in interface CTGeneralDirector
Overrides:
getCurrentStepSize in class CTDirector
Returns:
The current step size.
See Also:
CTDirector.setCurrentStepSize(double)

getExecutiveCTGeneralDirector

public CTGeneralDirector getExecutiveCTGeneralDirector()
Return the executive CT general director of this director.

Specified by:
getExecutiveCTGeneralDirector in interface CTGeneralDirector
Overrides:
getExecutiveCTGeneralDirector in class CTMultiSolverDirector
Returns:
The executive CT general director of this director.

getExecutionPhase

public CTExecutionPhase getExecutionPhase()
Get the current execution phase, which is inherited from the executive CT director.

Specified by:
getExecutionPhase in interface CTGeneralDirector
Overrides:
getExecutionPhase in class CTDirector
Returns:
The current execution phase.

getIterationBeginTime

public Time getIterationBeginTime()
Return the begin time of the current iteration.

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

goToMarkedState

public void goToMarkedState()
Restore the saved states, which include the states of stateful actors.

Specified by:
goToMarkedState in interface CTTransparentDirector

initialize

public void initialize()
                throws IllegalActionException
Call the initialize() method of the super class. Set the _initialStatesNotReady variable to false indicating no special process to construct initial states is needed.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class CTMultiSolverDirector
Throws:
IllegalActionException - If the initialize() method of the super class throws it, or the stop time can not be registered as a breakpoint.

isDiscretePhase

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

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

isOutputAccurate

public boolean isOutputAccurate()
Return true if all output step size control actors are satisfied with the current step size.

Specified by:
isOutputAccurate in interface CTTransparentDirector
Returns:
True if the current step size is accurate with respect to output step size control actors.

isStateAccurate

public boolean isStateAccurate()
Return true if all state step size control actors are satisfied with the current step size.

Specified by:
isStateAccurate in interface CTTransparentDirector
Returns:
True if the current step size is accurate with respect to state step size control actors.

markState

public void markState()
Mark the known good states, including the states of the stateful actors.

Specified by:
markState in interface CTTransparentDirector

postfire

public boolean postfire()
                 throws IllegalActionException
Return false if some actor returns false from its postfire method or a stop is requested.

Specified by:
postfire in interface Executable
Overrides:
postfire in class CTMultiSolverDirector
Returns:
false if some actor returns false from its postfire method or a stop is requested.
Throws:
IllegalActionException - If thrown by any actor during its postfire method.

predictedStepSize

public double predictedStepSize()
Return the predicted next step size, which is the minimum of the prediction from all step size control actors.

Specified by:
predictedStepSize in interface CTTransparentDirector
Returns:
The predicted step size from this subsystem.

prefire

public boolean prefire()
                throws IllegalActionException
Call the prefire of the super class. Change the ODE solver based on the phase of execution.

Specified by:
prefire in interface Executable
Overrides:
prefire in class CTMultiSolverDirector
Returns:
True if the prefire() method of super class returns true.
Throws:
IllegalActionException - If super class throws it or the ODE solver can not be set.

preinitialize

public void preinitialize()
                   throws IllegalActionException
Check whether the container implements the CTStepSizeControlActor interface. If not, then throw an exception. Call the preinitialize method of the super class.

Specified by:
preinitialize in interface Initializable
Overrides:
preinitialize in class CTMultiSolverDirector
Throws:
IllegalActionException - If the container of this director does not implement CTStepSizeControlActor, or the preinitialize method throws it.

refinedStepSize

public double refinedStepSize()
Return the refined step size if the current fire is not accurate.

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