ptolemy.domains.ct.kernel
Class CTEmbeddedDirector

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

public class CTEmbeddedDirector
extends CTMultiSolverDirector
implements CTTransparentDirector

An embedded director for CT inside CT/FSM. Conceptually, this director interacts with a continuous outer domain. As a consequence, this director exposes its step size control information. If the container of this director is a CTCompositeActor, then this information is further exposed to the outer domain.

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,v 1.61 2004/04/13 05:12:47 cxh Exp $
Author:
Jie Liu
See Also:
CTMultiSolverDirector, CTTransparentDirector, Serialized Form
Accepted Rating:
Yellow (chf)
Proposed Rating:
Yellow (liuj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.domains.ct.kernel.CTMultiSolverDirector
breakpointODESolver, ODESolver
 
Fields inherited from class ptolemy.domains.ct.kernel.CTDirector
_postfireReturns, _refireActors, errorTolerance, initStepSize, maxIterations, maxStepSize, minStepSize, startTime, stopTime, synchronizeToRealTime, timeResolution, valueResolution
 
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
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 fire()
          Execute the subsystem for one iteration.
 void fireAt(Actor actor, double time)
          Register the break point to this director and to the executive director.
 void initialize()
          Set the current time to be the current time of the outside model.
 boolean isThisStepAccurate()
          Return true if the current integration step is accurate.
 boolean postfire()
          Update the states of actors directed by this director.
 double predictedStepSize()
          Return the predicted next step size, which is the minimum of the prediction from step size control actors.
 boolean prefire()
          Return true always.
 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, _fireOneIteration, _initParameters, _isOutputAccurate, _isStateAccurate, _predictNextStepSize, _prefireDynamicActors, _processBreakpoints, _refinedStepWRTOutput, _refinedStepWRTState, attributeChanged, getBreakpointSolver, getODESolver, hasCurrentEvent
 
Methods inherited from class ptolemy.domains.ct.kernel.CTDirector
_areTimesCloseEnough, _instantiateODESolver, _setBreakpointIteration, _setCurrentODESolver, _setDiscretePhase, _setIterationBeginTime, _writeAccessRequired, getBreakPoints, getCurrentODESolver, getCurrentStepSize, getErrorTolerance, getInitialStepSize, getIterationBeginTime, getMaxIterations, getMaxStepSize, getMinStepSize, getNextIterationTime, getStartTime, getStopTime, getSuggestedNextStepSize, getValueResolution, isBreakpointIteration, isDiscretePhase, isPrefireComplete, newReceiver, prefireClear, produceOutput, setCurrentStepSize, setCurrentTime, setPrefireComplete, setSuggestedNextStepSize, updateContinuousStates
 
Methods inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_setScheduler, addDebugListener, getScheduler, invalidateSchedule, isScheduleValid, removeDebugListener, setScheduler, setScheduleValid
 
Methods inherited from class ptolemy.actor.Director
_description, _isEmbedded, _isTopLevel, domainPolymorphicTransferInputs, domainPolymorphicTransferOutputs, fireAtCurrentTime, getCurrentTime, getTimeResolution, initialize, invalidateResolvedTypes, iterate, needWriteAccess, requestInitialization, setContainer, setTimeResolution, stop, stopFire, terminate, transferInputs, transferOutputs, wrapup
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, clone, 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, 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, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, 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.domains.ct.kernel.CTTransparentDirector
hasCurrentEvent
 

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(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.

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.
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.

fire

public void fire()
          throws IllegalActionException
Execute the subsystem for one iteration. An iteration includes an event phase, a state resolving phase, and a output phase. If the state cannot be accurately resolved, then subsystem may produce a meaningless output. It is the outer domain's responsibility to check if this subsystem is accurate in this iteration, by calling the isThisStepAccurate() method of the CTCompositeActor that contains this director.

Specified by:
fire in interface Executable
Overrides:
fire in class CTMultiSolverDirector
Throws:
IllegalActionException - If one of the actors throw it during one iteration.

fireAt

public void fireAt(Actor actor,
                   double time)
            throws IllegalActionException
Register the break point to this director and to the executive director.

Overrides:
fireAt in class CTDirector
Parameters:
actor - The actor that requested the fire
time - The fire time
Throws:
IllegalActionException - If the time is before the current time, or there is no executive director.

initialize

public void initialize()
                throws IllegalActionException
Set the current time to be the current time of the outside model. Both the current time and the stop time are registered as a breakpoint. It invokes the initialize() method for all the Actors in the container.

Specified by:
initialize in interface Executable
Overrides:
initialize in class CTMultiSolverDirector
Throws:
IllegalActionException - If the instantiation of the solvers does not succeed or one of the directed actors throws it.

isThisStepAccurate

public boolean isThisStepAccurate()
Return true if the current integration step is accurate. This is determined by asking all the step size control actors in the state transition schedule and output schedule.

Specified by:
isThisStepAccurate in interface CTTransparentDirector
Returns:
True if the current step is accurate.

postfire

public boolean postfire()
                 throws IllegalActionException
Update the states of actors directed by this director. Discrete events at current time will be consumed and produced.

Specified by:
postfire in interface Executable
Overrides:
postfire in class CTMultiSolverDirector
Returns:
True if this is not a top-level director, or the simulation is not finished and stop() has not been called.
Throws:
IllegalActionException - Not thrown in this base class.

predictedStepSize

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

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

prefire

public boolean prefire()
                throws IllegalActionException
Return true always. Recompute the schedules if there was a mutation. Synchronize time with the outer domain, and adjust the contents of the breakpoint table with respect to the current time.

Specified by:
prefire in interface Executable
Overrides:
prefire in class CTMultiSolverDirector
Returns:
True always.
Throws:
IllegalActionException - Not thrown in this base class.

preinitialize

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

Specified by:
preinitialize in interface Executable
Overrides:
preinitialize in class CTMultiSolverDirector
Throws:
IllegalActionException - If the container of this director does not implement CTStepSizeControlActor, or one of the actors 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.