ptolemy.caltrop.ddi
Class SDF

java.lang.Object
  extended byptolemy.caltrop.ddi.AbstractDDI
      extended byptolemy.caltrop.ddi.SDF
All Implemented Interfaces:
DDI, Executable

public class SDF
extends AbstractDDI
implements DDI

A plugin for the SDF domain. In SDF, a CAL actor is valid if:

  1. The rates of each action are statically computable, and these rates are the same for each action.
  2. There is at least one unguarded action.
This plugin also adds attributes containing rate information to the ports of the actor.

Since:
Ptolemy II 4.0
Version:
$Id: SDF.java,v 1.19 2004/04/13 18:37:40 cxh Exp $
Author:
Christopher Chang
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Field Summary
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
SDF(CalInterpreter ptActor, caltrop.interpreter.ast.Actor actor, caltrop.interpreter.Context context, caltrop.interpreter.environment.Environment env)
          Create an SDF
 
Method Summary
 void fire()
          Executes the selected action on the first fire() call.
 java.lang.String getName()
          Get the name of this SDF.
 void initialize()
          In SDF, selecting which initializer to fire is already done in preinitialize().
 boolean isLegalActor()
          In SDF, an actor is legal if: The rates of each action are statically computable, and these rates are the same for each action.
 boolean postfire()
          This method should be invoked once per iteration, after the last invocation of fire() in that iteration.
 boolean prefire()
          Select a firable action among the actions of the actor, if possible.
 void preinitialize()
          This method should be invoked exactly once per execution of a model, before any of these other methods are invoked.
 void setupActor()
          Setup the actor associated with this DDI.
 
Methods inherited from class ptolemy.caltrop.ddi.AbstractDDI
iterate, stop, stopFire, terminate, wrapup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Executable
iterate, stop, stopFire, terminate, wrapup
 

Constructor Detail

SDF

public SDF(CalInterpreter ptActor,
           caltrop.interpreter.ast.Actor actor,
           caltrop.interpreter.Context context,
           caltrop.interpreter.environment.Environment env)
Create an SDF

Parameters:
ptActor - The instance of ptolemy.actor.Actor that the plugin will be associated with.
actor - The abstract syntax tree of the CAL source.
context - The context that the plugin will use.
env - The environment that the plugin will use.
Method Detail

isLegalActor

public boolean isLegalActor()
In SDF, an actor is legal if:
  1. The rates of each action are statically computable, and these rates are the same for each action.
  2. There is at least one unguarded action.
  3. The rates and guards of the initializers are statically computable.

Specified by:
isLegalActor in interface DDI
Returns:
True if the actor associated with this DDI is a legal SDF actor.

setupActor

public void setupActor()
Setup the actor associated with this DDI. Assumes that isLegalActor() is called first.

Setup involves attaching attributes with token consumption/production rates to the input and output ports of the actor associated with this DDI.

Specified by:
setupActor in interface DDI

getName

public java.lang.String getName()
Get the name of this SDF.

Specified by:
getName in interface DDI
Returns:
The name of this SDF.

fire

public void fire()
          throws IllegalActionException
Executes the selected action on the first fire() call. On successive calls, it rolls back previous state changes, selects a new action and executes it.

Note: Is this correct behavior? What is the contract between the result of prefire() and successive calls to fire()?

Specified by:
fire in interface Executable
Throws:
IllegalActionException - If an error occurs during the interpretation of the action.

initialize

public void initialize()
                throws IllegalActionException
In SDF, selecting which initializer to fire is already done in preinitialize().

Specified by:
initialize in interface Executable
Throws:
IllegalActionException

postfire

public boolean postfire()
                 throws IllegalActionException
Description copied from interface: Executable
This method should be invoked once per iteration, after the last invocation of fire() in that iteration. It may produce output data. It returns true if the execution can proceed into the next iteration, false if the actor does not wish to be fired again. This method typically wraps up an iteration, which may involve updating local state. In an opaque, non-atomic entity, it may also transfer output data. The execution of this method is bounded.

Specified by:
postfire in interface Executable
Returns:
True if the execution can continue.
Throws:
IllegalActionException - If postfiring is not permitted.

prefire

public boolean prefire()
                throws IllegalActionException
Select a firable action among the actions of the actor, if possible.

Specified by:
prefire in interface Executable
Returns:
True, if an action could be selected.
Throws:
IllegalActionException - If an error occurred during the action selection.

preinitialize

public void preinitialize()
                   throws IllegalActionException
Description copied from interface: Executable
This method should be invoked exactly once per execution of a model, before any of these other methods are invoked. For actors, this is invoked prior to type resolution and may trigger changes in the topology, changes in the type constraints.

Specified by:
preinitialize in interface Executable
Throws:
IllegalActionException - If initializing is not permitted.