ptolemy.actor.kiel
Class SyncChartDirector

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.actor.sched.FixedPointDirector
                      extended by ptolemy.actor.kiel.SyncChartDirector
All Implemented Interfaces:
Serializable, Cloneable, ptolemy.actor.Executable, ptolemy.actor.Initializable, ptolemy.actor.SuperdenseTimeDirector, ptolemy.kernel.util.Changeable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Moveable, ptolemy.kernel.util.Nameable

public class SyncChartDirector
extends ptolemy.actor.sched.FixedPointDirector

This director implements a fixed point iteration for finding synchronous signal assignments of SyncCharts. This director is based on the FixedPointDirector that was written for Ptolemy II by Haiyang Zheng and Edward A. Lee.

See Also:
Serialized Form
Pt.ProposedRating:
Red (cmot)
Rating red

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.NamedObj.ContainedObjectsIterator
 
Field Summary
protected  int _index
          The current index of the model.
protected  List _receivers
          List of all receivers this director has created.
 ptolemy.kernel.util.Attribute statesignals
           
 
Fields inherited from class ptolemy.actor.sched.FixedPointDirector
iterations, synchronizeToRealTime
 
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
SyncChartDirector()
          Construct a director in the default workspace with an empty string as its name.
SyncChartDirector(ptolemy.kernel.CompositeEntity container, String name)
          Construct a director in the given container with the given name.
SyncChartDirector(ptolemy.kernel.util.Workspace workspace)
          Construct a director in the given workspace with an empty name.
 
Method Summary
protected  void _receiverChanged()
          React to the change in receiver status by incrementing the count of known receivers.
protected  void _resetAllReceivers()
          Reset all receivers to unknown status and clear out variables used to track which actors fired in the last iteration.
protected  void _synchronizeToRealTime()
          Synchronize to real time, if appropriate.
 void fire()
          Prefire and fire actors in the order given by the scheduler until the iteration converges.
 int getIndex()
          Return the current index of the director.
 String[] getMustCannotSignals()
          Specify whether the execution should synchronize to the real time.
 boolean implementsStrictActorSemantics()
          Return true, indicating that this director assumes and exports the strict actor semantics, as described in this paper:
 void initialize()
          Initialize the director and all deeply contained actors by calling the super.initialize() method.
 boolean isFireFunctional()
          Return true if all the controlled actors' isFireFunctional() methods return true.
 boolean isPossiblyEnabled(ptolemy.domains.modal.kernel.Transition transition)
          Checks whether a transition can possibly be taken.
 boolean isStrict()
          Return false.
 ptolemy.actor.Receiver newReceiver()
          Return a new FixedPointReceiver.
 boolean postfire()
          Call postfire() on all contained actors that were fired in the current iteration.
 boolean prefire()
          Return true if the director is ready to fire.
 void setIndex(int index)
          Set the superdense time index.
 String[] suggestedModalModelDirectors()
          Return an array of suggested directors to be used with ModalModel.
 boolean transferInputs(ptolemy.actor.IOPort port)
          Transfer data from the specified input port of the container to the ports it is connected to on the inside.
 boolean transferOutputs(ptolemy.actor.IOPort port)
          Transfer data from the specified output port of the container to the ports it is connected to on the outside.
 
Methods inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_setScheduler, addDebugListener, clone, getScheduler, invalidateSchedule, isScheduleValid, removeDebugListener, setScheduler
 
Methods inherited from class ptolemy.actor.Director
_description, _fireContainerAt, _getWCET, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, finish, fireAt, fireAt, fireAtCurrentTime, getCausalityInterface, getCurrentTime, getErrorTolerance, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, initialize, invalidateResolvedTypes, isStopRequested, iterate, preinitialize, removeInitializable, requestInitialization, setContainer, setCurrentTime, setModelTime, stop, stopFire, supportMultirateFiring, terminate, 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
 

Field Detail

statesignals

public ptolemy.kernel.util.Attribute statesignals

_index

protected int _index
The current index of the model.


_receivers

protected List _receivers
List of all receivers this director has created.

Constructor Detail

SyncChartDirector

public SyncChartDirector()
                  throws ptolemy.kernel.util.IllegalActionException,
                         ptolemy.kernel.util.NameDuplicationException
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.

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 already contains an entity with the specified name.

SyncChartDirector

public SyncChartDirector(ptolemy.kernel.util.Workspace workspace)
                  throws ptolemy.kernel.util.IllegalActionException,
                         ptolemy.kernel.util.NameDuplicationException
Construct a director in the given 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 for this object.
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 already contains an entity with the specified name.

SyncChartDirector

public SyncChartDirector(ptolemy.kernel.CompositeEntity container,
                         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 the director.
name - Name of this director.
Throws:
ptolemy.kernel.util.IllegalActionException - If the director is not compatible with the specified container.
ptolemy.kernel.util.NameDuplicationException - If the name collides with an attribute in the container.
Method Detail

isPossiblyEnabled

public boolean isPossiblyEnabled(ptolemy.domains.modal.kernel.Transition transition)
                          throws ptolemy.kernel.util.IllegalActionException
Checks whether a transition can possibly be taken. That is the case if this transition is already enabled. It is also the case if it cannot be evaluated because an important signal-status is missing (unknown). In this case an UndefinedConstantOrIdentifierException is raised by Ptolemy and this is also interpreted as a possibly enabled transition because the trigger could not be evaluated to false unambiguously with this signal being still unknown.

Parameters:
transition - the transition
Returns:
true, if is possibly enabled
Throws:
ptolemy.kernel.util.IllegalActionException - the illegal action exception

getMustCannotSignals

public String[] getMustCannotSignals()
Specify whether the execution should synchronize to the real time. This parameter has type boolean and defaults to false. If set to true, then this director stalls in the prefire() method until the elapsed real real time matches the current time. If the period parameter has value 0.0 (the default), then changing this parameter to true has no effect. Note that in this base class, there is no period parameter and time is never advanced, so this will have no effect. It has effect in derived classes.


fire

public void fire()
          throws ptolemy.kernel.util.IllegalActionException
Prefire and fire actors in the order given by the scheduler until the iteration converges. An iteration converges when a pass through the schedule does not change the status of any receiver.

Specified by:
fire in interface ptolemy.actor.Executable
Overrides:
fire in class ptolemy.actor.sched.FixedPointDirector
Throws:
ptolemy.kernel.util.IllegalActionException - If an actor violates the monotonicity constraints, or the prefire() or fire() method of the actor throws it.

getIndex

public int getIndex()
Return the current index of the director. The current index is a portion of the superdense time. Superdense time means that time is a real value and an index, allowing multiple sequential steps to occur at a fixed (real) time.

Specified by:
getIndex in interface ptolemy.actor.SuperdenseTimeDirector
Overrides:
getIndex in class ptolemy.actor.sched.FixedPointDirector
Returns:
the superdense time index
See Also:
setIndex(int), SuperdenseTimeDirector

implementsStrictActorSemantics

public boolean implementsStrictActorSemantics()
Return true, indicating that this director assumes and exports the strict actor semantics, as described in this paper:

A. Goderis, C. Brooks, I. Altintas, E. A. Lee, and C. Goble, "Heterogeneous Composition of Models of Computation," EECS Department, University of California, Berkeley, Tech. Rep. UCB/EECS-2007-139, Nov. 2007. http://www.eecs.berkeley.edu/Pubs/TechRpts/2007/EECS-2007-139.html

In particular, a director that implements this interface guarantees that it will not invoke the postfire() method of an actor until all its inputs are known at the current tag. Moreover, it it will only do so in its own postfire() method, and in its prefire() and fire() methods, it does not change its own state. Thus, such a director can be used within a model of computation that has a fixed-point semantics, such as SRDirector and ContinuousDirector.

Overrides:
implementsStrictActorSemantics in class ptolemy.actor.sched.FixedPointDirector
Returns:
True.

initialize

public void initialize()
                throws ptolemy.kernel.util.IllegalActionException
Initialize the director and all deeply contained actors by calling the super.initialize() method. Reset all private variables.

Specified by:
initialize in interface ptolemy.actor.Initializable
Overrides:
initialize in class ptolemy.actor.sched.FixedPointDirector
Throws:
ptolemy.kernel.util.IllegalActionException - If the superclass throws it.

isFireFunctional

public boolean isFireFunctional()
Return true if all the controlled actors' isFireFunctional() methods return true. Otherwise, return false.

Specified by:
isFireFunctional in interface ptolemy.actor.Executable
Overrides:
isFireFunctional in class ptolemy.actor.sched.FixedPointDirector
Returns:
True if all controlled actors are functional. Return false if there is no container or no actors in the container.

isStrict

public boolean isStrict()
Return false. The transferInputs() method checks whether the inputs are known before calling hasToken(). Thus this director tolerates unknown inputs.

Specified by:
isStrict in interface ptolemy.actor.Executable
Overrides:
isStrict in class ptolemy.actor.sched.FixedPointDirector
Returns:
False.

newReceiver

public ptolemy.actor.Receiver newReceiver()
Return a new FixedPointReceiver. If a subclass overrides this method, the receiver it creates must be a subclass of FixedPointReceiver, and it must add the receiver to the _receivers list (a protected member of this class).

Overrides:
newReceiver in class ptolemy.actor.sched.FixedPointDirector
Returns:
A new FixedPointReceiver.

postfire

public boolean postfire()
                 throws ptolemy.kernel.util.IllegalActionException
Call postfire() on all contained actors that were fired in the current iteration. Return false if the model has finished executing, either by reaching the iteration limit, or if no actors in the model return true in postfire(), or if stop has been requested, or if no actors fired at all in the last iteration. This method is called only once for each iteration. Note that actors are postfired in arbitrary order.

Specified by:
postfire in interface ptolemy.actor.Executable
Overrides:
postfire in class ptolemy.actor.sched.FixedPointDirector
Returns:
True if the execution is not finished.
Throws:
ptolemy.kernel.util.IllegalActionException - If the iterations parameter does not have a valid token, or if there still some unknown inputs (which indicates a causality loop).

prefire

public boolean prefire()
                throws ptolemy.kernel.util.IllegalActionException
Return true if the director is ready to fire. If synchronizeToRealTime is true, then wait for real time elapse to match or exceed model time. The return whatever the base class returns.

Specified by:
prefire in interface ptolemy.actor.Executable
Overrides:
prefire in class ptolemy.actor.sched.FixedPointDirector
Returns:
True.
Throws:
ptolemy.kernel.util.IllegalActionException - Not thrown in this base class.

setIndex

public void setIndex(int index)
              throws ptolemy.kernel.util.IllegalActionException
Set the superdense time index. This should only be called by an enclosing director.

Specified by:
setIndex in interface ptolemy.actor.SuperdenseTimeDirector
Overrides:
setIndex in class ptolemy.actor.sched.FixedPointDirector
Throws:
ptolemy.kernel.util.IllegalActionException - Not thrown in this base class.
See Also:
getIndex(), SuperdenseTimeDirector

suggestedModalModelDirectors

public String[] suggestedModalModelDirectors()
Return an array of suggested directors to be used with ModalModel. Each director is specified by its full class name. The first director in the array will be the default director used by a modal model.

Overrides:
suggestedModalModelDirectors in class ptolemy.actor.sched.FixedPointDirector
Returns:
An array of suggested directors to be used with ModalModel.
See Also:
Director.suggestedModalModelDirectors()

transferInputs

public boolean transferInputs(ptolemy.actor.IOPort port)
                       throws ptolemy.kernel.util.IllegalActionException
Transfer data from the specified input port of the container to the ports it is connected to on the inside. If there is no data on the specified input port, then set the ports on the inside to absent by calling sendClearInside(). This method delegates the data transfer operation to the transferInputs method of the super class.

Overrides:
transferInputs in class ptolemy.actor.sched.FixedPointDirector
Parameters:
port - The port to transfer tokens from.
Returns:
True if at least one token is transferred.
Throws:
ptolemy.kernel.util.IllegalActionException - If the port is not an opaque input port.

transferOutputs

public boolean transferOutputs(ptolemy.actor.IOPort port)
                        throws ptolemy.kernel.util.IllegalActionException
Transfer data from the specified output port of the container to the ports it is connected to on the outside. If there is no data on the specified output port, then set the ports on the outside to absent by calling sendClear(). This method delegates the data transfer operation to the transferOutputs method of the super class.

Overrides:
transferOutputs in class ptolemy.actor.sched.FixedPointDirector
Parameters:
port - The port to transfer tokens from.
Returns:
True if at least one token is transferred.
Throws:
ptolemy.kernel.util.IllegalActionException - If the port is not an opaque output port.

_receiverChanged

protected void _receiverChanged()
React to the change in receiver status by incrementing the count of known receivers.

Overrides:
_receiverChanged in class ptolemy.actor.sched.FixedPointDirector

_resetAllReceivers

protected void _resetAllReceivers()
Reset all receivers to unknown status and clear out variables used to track which actors fired in the last iteration.

Overrides:
_resetAllReceivers in class ptolemy.actor.sched.FixedPointDirector

_synchronizeToRealTime

protected void _synchronizeToRealTime()
                               throws ptolemy.kernel.util.IllegalActionException
Synchronize to real time, if appropriate.

Overrides:
_synchronizeToRealTime in class ptolemy.actor.sched.FixedPointDirector
Throws:
ptolemy.kernel.util.IllegalActionException - If the synchronizeToRealTime parameter is ill formed.