ptolemy.domains.fsm.kernel
Class HSDirector

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.util.Attribute
          extended byptolemy.actor.Director
              extended byptolemy.domains.fsm.kernel.FSMDirector
                  extended byptolemy.domains.fsm.kernel.HSDirector
All Implemented Interfaces:
ptolemy.kernel.util.Changeable, java.lang.Cloneable, CTTransparentDirector, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.actor.Executable, ptolemy.actor.util.ExplicitChangeContext, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, java.io.Serializable

public class HSDirector
extends FSMDirector
implements CTTransparentDirector

An HSDirector governs the execution of the discrete dynamics of a hybrid system model.

Hierarchical Hybrid System Simulation describes how hybrid system models are built and simulated in Ptolemy II.

Note: this class is still under development.

Since:
Ptolemy II 1.0
Version:
$Id: HSDirector.java,v 1.60 2004/04/13 05:12:55 cxh Exp $
Author:
Xiaojun Liu
See Also:
Serialized Form
Accepted Rating:
Red (liuxj)
Proposed Rating:
Red (liuxj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.domains.fsm.kernel.FSMDirector
_currentLocalReceiverMap, _enabledRefinements, _fireRefinement, _firstFire, _localReceiverMaps, controllerName
 
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
HSDirector()
          Construct a director in the default workspace with an empty string as its name.
HSDirector(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct a director in the given container with the given name.
HSDirector(ptolemy.kernel.util.Workspace workspace)
          Construct a director in the workspace with an empty name.
 
Method Summary
 void fire()
          Set the values of input variables in the mode controller.
 double getCurrentTime()
          Return the current time obtained from the executive director, if there is one, and otherwise return the local view of current time.
 double getNextIterationTime()
          Return the next iteration time obtained from the executive director.
 boolean hasCurrentEvent()
          Return true if the current refinement produces events.
 boolean isThisStepAccurate()
          Return true if there are no refinements, or if the current integration step is accurate with the respect of all the enabled refinements, which are refinements that returned true in their prefire() methods in this iteration, or if a refinement is not a CTStepSizeControlActor; and if the current time is exactly the same time the transition is enabled.
 ptolemy.actor.Receiver newReceiver()
          Return a CTReceiver.
 boolean postfire()
          Return true if the mode controller wishes to be scheduled for another iteration.
 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 prefire()
          Set the controller.
 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.domains.fsm.kernel.FSMDirector
_buildLocalReceiverMaps, _chooseTransition, _currentLocalReceivers, _getLastChosenTransition, _readInputs, _readOutputsFromRefinement, _setCurrentConnectionMap, _setCurrentState, attributeChanged, clone, fireAt, getContext, getController, getModifiedVariables, handleModelError, initialize, setContainer, setCurrentTime, transferInputs
 
Methods inherited from class ptolemy.actor.Director
_description, _isEmbedded, _isTopLevel, _writeAccessRequired, domainPolymorphicTransferInputs, domainPolymorphicTransferOutputs, fireAtCurrentTime, 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 ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, 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, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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.kernel.util.Nameable
description, getContainer, getFullName, getName, getName, setName
 

Constructor Detail

HSDirector

public HSDirector()
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.


HSDirector

public HSDirector(ptolemy.kernel.util.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.

Parameters:
workspace - The workspace of this director.

HSDirector

public HSDirector(ptolemy.kernel.CompositeEntity container,
                  java.lang.String name)
           throws ptolemy.kernel.util.IllegalActionException,
                  ptolemy.kernel.util.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:
ptolemy.kernel.util.IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container.
ptolemy.kernel.util.NameDuplicationException - If the container is not a CompositeActor and the name collides with an entity in the container.
Method Detail

fire

public void fire()
          throws ptolemy.kernel.util.IllegalActionException
Set the values of input variables in the mode controller. Examine the preemptive outgoing transitions of its current state. Throw an exception if there is more than one transition enabled. 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 of the mode controller is not fired. If no preemptive transition is enabled and the refinement is ready to fire in the current iteration, fire the refinement. 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.

Specified by:
fire in interface ptolemy.actor.Executable
Overrides:
fire in class FSMDirector
Throws:
ptolemy.kernel.util.IllegalActionException - If there is more than one transition enabled, or there is no controller, or thrown by any choice action.

getCurrentTime

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

Returns:
The current time.

getNextIterationTime

public double getNextIterationTime()
Return the next iteration time obtained from the executive director.

Overrides:
getNextIterationTime in class FSMDirector
Returns:
The next iteration time.

hasCurrentEvent

public boolean hasCurrentEvent()
Return true if the current refinement produces events.

Specified by:
hasCurrentEvent in interface CTTransparentDirector
Returns:
True if the current refinement produces events.

isThisStepAccurate

public boolean isThisStepAccurate()
Return true if there are no refinements, or if the current integration step is accurate with the respect of all the enabled refinements, which are refinements that returned true in their prefire() methods in this iteration, or if a refinement is not a CTStepSizeControlActor; and if the current time is exactly the same time the transition is enabled.

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

newReceiver

public ptolemy.actor.Receiver newReceiver()
Return a CTReceiver.

Overrides:
newReceiver in class FSMDirector
Returns:
a new CTReceiver.

postfire

public boolean postfire()
                 throws ptolemy.kernel.util.IllegalActionException
Return true if the mode controller wishes to be scheduled for another iteration. Postfire the enabled refinements of the current state of the mode controller and take out event outputs that the refinements generate. Execute the commit actions contained by the last chosen transition of the mode controller and set its current state to the destination state of the transition. Clear the relation list associated with the enabled transition and request to be fired again at the current time.

Specified by:
postfire in interface ptolemy.actor.Executable
Overrides:
postfire in class FSMDirector
Returns:
True if the mode controller wishes to be scheduled for another iteration.
Throws:
ptolemy.kernel.util.IllegalActionException - If thrown by any action, or there is no controller.

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.

prefire

public boolean prefire()
                throws ptolemy.kernel.util.IllegalActionException
Set the controller. Call super.prefire().

Specified by:
prefire in interface ptolemy.actor.Executable
Overrides:
prefire in class FSMDirector
Throws:
ptolemy.kernel.util.IllegalActionException - If there is no controller. FIXME: Changed by liuj, not yet reviewed.

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.