ptolemy.caltrop.ddi
Class AbstractDDI

java.lang.Object
  extended byptolemy.caltrop.ddi.AbstractDDI
All Implemented Interfaces:
DDI, Executable
Direct Known Subclasses:
CSP, Dataflow, SDF

public abstract class AbstractDDI
extends java.lang.Object
implements DDI

Since:
Ptolemy II 4.0
Version:
$Id: AbstractDDI.java,v 1.12 2004/04/13 18:37:31 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
AbstractDDI()
           
 
Method Summary
 int iterate(int i)
          Invoke a specified number of iterations of the actor.
 void stop()
          Request that execution of this Executable stop as soon as possible.
 void stopFire()
          Request that execution of the current iteration complete.
 void terminate()
          Terminate any currently executing model with extreme prejudice.
 void wrapup()
          This method is invoked exactly once per execution of an application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ptolemy.caltrop.ddi.DDI
getName, isLegalActor, setupActor
 
Methods inherited from interface ptolemy.actor.Executable
fire, initialize, postfire, prefire, preinitialize
 

Constructor Detail

AbstractDDI

public AbstractDDI()
Method Detail

iterate

public int iterate(int i)
            throws IllegalActionException
Description copied from interface: Executable
Invoke a specified number of iterations of the actor. An iteration is equivalent to invoking prefire(), fire(), and postfire(), in that order. In an iteration, if prefire() returns true, then fire() will be called once, followed by postfire(). Otherwise, if prefire() returns false, fire() and postfire() are not invoked, and this method returns NOT_READY. If postfire() returns false, then no more iterations are invoked, and this method returns STOP_ITERATING. Otherwise, it returns COMPLETED.

An implementation of this method is not required to actually invoke prefire(), fire(), and postfire(). An implementation of this method must, however, perform the equivalent operations.

Specified by:
iterate in interface Executable
Parameters:
i - The number of iterations to perform.
Returns:
NOT_READY, STOP_ITERATING, or COMPLETED.
Throws:
IllegalActionException - If iterating is not permitted, or if prefire(), fire(), or postfire() throw it.

stop

public void stop()
Description copied from interface: Executable
Request that execution of this Executable stop as soon as possible. An implementation of this method should pass on the request to any contained executable objects. An implementation should also return false from postfire() to indicate to the caller that no further execution of this Executable is appropriate. After this method is called, the executable object should not be fired again. The stopFire() method, by contrast, requests that the current iteration be completed, but not that the entire execution be stopped. I.e., the Executable may be fired again after stopFire() is called.

Specified by:
stop in interface Executable

stopFire

public void stopFire()
Description copied from interface: Executable
Request that execution of the current iteration complete. If an iteration is always a finite computation (the usual case), i.e. the fire() method always returns in finite time, then nothing needs to be done in this method, except possibly to pass on the request to any contained executable objects. This method is used to request that an unbounded computation suspend, returning control to the caller. Thus, if the fire() method does not normally return in finite time, then this method is used to request that it return. It should suspend execution in such a way that if the fire() method is called again, execution will resume at the point where it was suspended. However, it should not assume the fire() method will be called again. It is possible that the wrapup() method will be called next.

Specified by:
stopFire in interface Executable

terminate

public void terminate()
Description copied from interface: Executable
Terminate any currently executing model with extreme prejudice. This method is not intended to be used as a normal route of stopping execution. To normally stop execution, call the finish() method instead. This method should be called only when execution fails to terminate by normal means due to certain kinds of programming errors (infinite loops, threading errors, etc.).

After this method completes, all resources in use should be released and any sub-threads should be killed. However, a consistent state is not guaranteed. The topology should probably be recreated before attempting any further operations. This method should not be synchronized because it must happen as soon as possible, no matter what.

Specified by:
terminate in interface Executable

wrapup

public void wrapup()
            throws IllegalActionException
Description copied from interface: Executable
This method is invoked exactly once per execution of an application. None of the other action methods should be be invoked after it. It finalizes an execution, typically closing files, displaying final results, etc. When this method is called, no further execution should occur.

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