PTOLEMY II - CiteSeerX
PTOLEMY II - CiteSeerX
PTOLEMY II - CiteSeerX
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Designing Actors<br />
/** Javadoc comment for the actor class. */<br />
public class ActorClassName extends BaseClass implements MarkerInterface {<br />
}<br />
/** Javadoc comment for constructor. */<br />
public ActorClassName(CompositeEntity container, String name)<br />
throws NameDuplicationException, IllegalActionException {<br />
super(container, name);<br />
// Create and configure ports, e.g. ...<br />
portName = new TypedIOPort(this, "portName", true, false);<br />
// Create and configure parameters, e.g. ...<br />
parameterName = new Parameter(this, "parameterName");<br />
parameterName.setExpression("0.0");<br />
parameterName.setTypeEquals(BaseType.DOUBLE);<br />
}<br />
///////////////////////////////////////////////////////////////////<br />
//// ports and parameters ////<br />
/** Javadoc comment for port. */<br />
public TypedIOPort portName;<br />
/** Javadoc comment for parameter. */<br />
public Parameter parameterName;<br />
///////////////////////////////////////////////////////////////////<br />
//// public methods ////<br />
/** Javadoc comment for fire method. */<br />
public void fire() {<br />
super.fire();<br />
... read inputs and produce outputs ...<br />
}<br />
/** Javadoc comment for initialize method. */<br />
public void initialize() {<br />
super.initialize();<br />
... initialize local variables ...<br />
}<br />
/** Javadoc comment for prefire method. */<br />
public boolean prefire() {<br />
... determine whether firing should proceed and return false if not ...<br />
return super.prefire();<br />
}<br />
/** Javadoc comment for preinitialize method. */<br />
public void preinitialize() {<br />
super.preinitialize();<br />
... set port types and/or scheduling information ...<br />
}<br />
/** Javadoc comment for postfire method. */<br />
public boolean postfire() {<br />
... update persistent state ...<br />
... determine whether firing should continue to next iteration and return false if not ...<br />
return super.postfire();<br />
}<br />
/** Javadoc comment for wrapup method. */<br />
public void wrapup() {<br />
super.wrapup();<br />
... display final results ...<br />
}<br />
FIGURE 5.1. Anatomy of an actor.<br />
Heterogeneous Concurrent Modeling and Design 153