|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.codegen.kernel.CodeGeneratorHelper
ptolemy.codegen.actor.Director
public class Director
Code generator helper associated with the ptolemy.actor.Director class. This class is also associated with a code generator. FIXME: need documentation on how subclasses should extend this class.
CodeGenerator
,
Serialized Form
Yellow (zhouye) |
Yellow (zhouye) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper |
---|
CodeGeneratorHelper.Channel, CodeGeneratorHelper.VariableScope |
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
protected Director |
_director
The associated director. |
protected static java.lang.String |
_eol
End of line character. |
protected static java.lang.String |
_INDENT1
Indent string for indent level 1. |
protected static java.lang.String |
_INDENT2
Indent string for indent level 2. |
protected static java.lang.String |
_INDENT3
Indent string for indent level 3. |
protected static java.lang.String |
_INDENT4
Indent string for indent level 4. |
Fields inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper |
---|
_codeGenerator, _codeStream, _parseTreeCodeGenerator, _portConversions, _referencedParameters |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary | |
---|---|
Director(Director director)
Construct the code generator helper associated with the given director. |
Method Summary | |
---|---|
protected int |
_ceilToPowerOfTwo(int value)
Return the minimum number of power of two that is greater than or equal to the given integer. |
protected static java.lang.String |
_getIndentPrefix(int level)
Return a number of spaces that is proportional to the argument. |
protected void |
_updateConnectedPortsOffset(IOPort port,
java.lang.StringBuffer code,
int rate)
Update the offsets of the buffers associated with the ports connected with the given port in its downstream. |
protected void |
_updatePortOffset(IOPort port,
java.lang.StringBuffer code,
int rate)
Update the read offsets of the buffer associated with the given port. |
java.lang.String |
createOffsetVariablesIfNeeded()
Generate code for declaring read and write offset variables if needed. |
java.lang.String |
generateCodeForGet(IOPort port,
int channel)
Generate the code for getting data from the specified port channel. |
java.lang.String |
generateCodeForSend(IOPort port,
int channel,
java.lang.String dataToken)
Generate the code for sending data to the specified port channel. |
java.lang.String |
generateFireCode()
Generate the code for the firing of actors. |
java.lang.String |
generateFireFunctionCode()
Generate The fire function code. |
java.lang.String |
generateInitializeCode()
Generate the initialize code for this director. |
java.lang.String |
generateMainLoop()
Generate a main loop for an execution under the control of this director. |
void |
generateModeTransitionCode(java.lang.StringBuffer code)
Generate mode transition code. |
java.lang.String |
generateOffset(java.lang.String offsetString,
IOPort port,
int channel,
boolean isWrite,
CodeGeneratorHelper helper)
Generate the expression that represents the offset in the generated code. |
java.lang.String |
generatePostfireCode()
Generate the postfire code of the associated composite actor. |
java.lang.String |
generatePreinitializeCode()
Generate the preinitialize code for this director. |
void |
generateTransferInputsCode(IOPort inputPort,
java.lang.StringBuffer code)
Generate code for transferring enough tokens to complete an internal iteration. |
void |
generateTransferOutputsCode(IOPort outputPort,
java.lang.StringBuffer code)
Generate code for transferring enough tokens to fulfill the output production rate. |
java.lang.String |
generateVariableDeclaration()
Generate variable declarations for inputs and outputs and parameters. |
java.lang.String |
generateVariableInitialization()
Generate variable initialization for the referenced parameters. |
java.lang.String |
generateWrapupCode()
Generate the wrapup code of the director associated with this helper class. |
int |
getBufferSize(IOPort port,
int channelNumber)
Return the buffer size of a given channel (i.e, a given port and a given channel number). |
NamedObj |
getComponent()
Return the director associated with this class. |
java.util.Set |
getHeaderFiles()
Get the files needed by the code generated from this helper class. |
java.util.Set |
getIncludeDirectories()
Return an empty HashSet. |
java.util.Set |
getLibraries()
Return an empty HashSet. |
java.util.Set |
getLibraryDirectories()
Return an empty HashSet. |
java.util.Set |
getModifiedVariables()
Return a set of parameters that will be modified during the execution of the model. |
java.lang.String |
getReference(Attribute attribute,
java.lang.String[] channelAndOffset,
CodeGeneratorHelper helper)
Return an unique label for the given attribute referenced by the given helper. |
java.lang.String |
getReference(TypedIOPort port,
java.lang.String[] channelAndOffset,
boolean forComposite,
boolean isWrite,
CodeGeneratorHelper helper)
Return an unique label for the given port channel referenced by the given helper. |
static java.util.List<CodeGeneratorHelper.Channel> |
getReferenceChannels(IOPort port,
int channelNumber)
Return the reference channels for the specified port channel. |
double |
getWCET()
Return the worst case execution time (WCET) seen by this director. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String _eol
protected Director _director
protected static final java.lang.String _INDENT1
_getIndentPrefix(int)
protected static final java.lang.String _INDENT2
_getIndentPrefix(int)
protected static final java.lang.String _INDENT3
_getIndentPrefix(int)
protected static final java.lang.String _INDENT4
_getIndentPrefix(int)
Constructor Detail |
---|
public Director(Director director)
director
- The associated director.Method Detail |
---|
public java.lang.String createOffsetVariablesIfNeeded() throws IllegalActionException
createOffsetVariablesIfNeeded
in interface ActorCodeGenerator
createOffsetVariablesIfNeeded
in class CodeGeneratorHelper
IllegalActionException
- If thrown while creating
offset variables.public java.lang.String generateCodeForSend(IOPort port, int channel, java.lang.String dataToken) throws IllegalActionException
port
- The specified port.channel
- The specified channel.dataToken
- The data to send.
IllegalActionException
- Not thrown in this base class.public java.lang.String generateCodeForGet(IOPort port, int channel) throws IllegalActionException
port
- The specified port.channel
- The specified channel.
IllegalActionException
- Not thrown in this base class.public java.lang.String generateFireCode() throws IllegalActionException
generateFireCode
in interface ActorCodeGenerator
generateFireCode
in class CodeGeneratorHelper
IllegalActionException
- If the helper associated with
an actor throws it while generating fire code for the actor.public java.lang.String generateFireFunctionCode() throws IllegalActionException
generateFireFunctionCode
in interface ActorCodeGenerator
generateFireFunctionCode
in class CodeGeneratorHelper
IllegalActionException
- If thrown while generating fire code.public java.util.Set getHeaderFiles() throws IllegalActionException
getHeaderFiles
in interface ActorCodeGenerator
getHeaderFiles
in class CodeGeneratorHelper
IllegalActionException
- If something goes wrong.public java.lang.String generateMainLoop() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateInitializeCode() throws IllegalActionException
generateInitializeCode
in interface ComponentCodeGenerator
generateInitializeCode
in class CodeGeneratorHelper
IllegalActionException
- If the helper associated with
an actor throws it while generating initialize code for the actor.public java.lang.String generateOffset(java.lang.String offsetString, IOPort port, int channel, boolean isWrite, CodeGeneratorHelper helper) throws IllegalActionException
offsetString
- The specified offset from the user.port
- The referenced port.channel
- The referenced port channel.isWrite
- Whether to generate the write or read offset.helper
- The specified helper.
IllegalActionException
- If there is problems getting
the port buffer size or the offset in the channel and offset map.public java.lang.String generatePostfireCode() throws IllegalActionException
generatePostfireCode
in interface ActorCodeGenerator
generatePostfireCode
in class CodeGeneratorHelper
IllegalActionException
- If the helper associated with
an actor throws it while generating postfire code for the actor
or while creating buffer size and offset map.public java.lang.String generatePreinitializeCode() throws IllegalActionException
generatePreinitializeCode
in interface ActorCodeGenerator
generatePreinitializeCode
in class CodeGeneratorHelper
IllegalActionException
- If getting the helper fails,
or if generating the preinitialize code for a helper fails,
or if there is a problem getting the buffer size of a port.public void generateModeTransitionCode(java.lang.StringBuffer code) throws IllegalActionException
generateModeTransitionCode
in interface ActorCodeGenerator
generateModeTransitionCode
in class CodeGeneratorHelper
code
- The string buffer that the generated code is appended to.
IllegalActionException
- If an actor helper throws it
while generating mode transition code.public void generateTransferInputsCode(IOPort inputPort, java.lang.StringBuffer code) throws IllegalActionException
inputPort
- The port to transfer tokens.code
- The string buffer that the generated code is appended to.
IllegalActionException
- If thrown while transferring tokens.public void generateTransferOutputsCode(IOPort outputPort, java.lang.StringBuffer code) throws IllegalActionException
outputPort
- The port to transfer tokens.code
- The string buffer that the generated code is appended to.
IllegalActionException
- If thrown while transferring tokens.public java.lang.String generateVariableDeclaration() throws IllegalActionException
generateVariableDeclaration
in interface ActorCodeGenerator
generateVariableDeclaration
in class CodeGeneratorHelper
IllegalActionException
- If the helper class for the model
director cannot be found.public java.lang.String generateVariableInitialization() throws IllegalActionException
generateVariableInitialization
in interface ActorCodeGenerator
generateVariableInitialization
in class CodeGeneratorHelper
IllegalActionException
- If the helper class for the model
director cannot be found.public java.lang.String generateWrapupCode() throws IllegalActionException
generateWrapupCode
in interface ComponentCodeGenerator
generateWrapupCode
in class CodeGeneratorHelper
IllegalActionException
- If the helper class for each actor
cannot be found, or if an error occurs while the helper generate the
wrapup code.public java.lang.String getReference(TypedIOPort port, java.lang.String[] channelAndOffset, boolean forComposite, boolean isWrite, CodeGeneratorHelper helper) throws IllegalActionException
port
- The given port.channelAndOffset
- The given channel and offset.forComposite
- Whether the given helper is associated with
a CompositeActorisWrite
- The type of the reference. True if this is
a write reference; otherwise, this is a read reference.helper
- The specified helper.
IllegalActionException
- If the helper throws it while
generating the label.public java.lang.String getReference(Attribute attribute, java.lang.String[] channelAndOffset, CodeGeneratorHelper helper) throws IllegalActionException
attribute
- The given attribute.channelAndOffset
- The given channel and offset.helper
- The specified helper.
IllegalActionException
- If the helper throws it while
generating the label.public static java.util.List<CodeGeneratorHelper.Channel> getReferenceChannels(IOPort port, int channelNumber) throws IllegalActionException
port
- The given port.channelNumber
- The given channel.
IllegalActionException
- If CodeGeneratorHelper.getSinkChannels(IOPort, int)
throws it.public int getBufferSize(IOPort port, int channelNumber) throws IllegalActionException
getBufferSize
in class CodeGeneratorHelper
port
- The given port.channelNumber
- The given channel number.
IllegalActionException
- Not thrown in this base class.CodeGeneratorHelper.setBufferSize(IOPort, int, int)
public NamedObj getComponent()
getComponent
in interface ComponentCodeGenerator
getComponent
in class CodeGeneratorHelper
public java.util.Set getIncludeDirectories() throws IllegalActionException
getIncludeDirectories
in interface ActorCodeGenerator
getIncludeDirectories
in class CodeGeneratorHelper
IllegalActionException
- Not thrown in this method.public java.util.Set getLibraries() throws IllegalActionException
getLibraries
in interface ActorCodeGenerator
getLibraries
in class CodeGeneratorHelper
IllegalActionException
- Not thrown in this method.public java.util.Set getLibraryDirectories() throws IllegalActionException
getLibraryDirectories
in interface ActorCodeGenerator
getLibraryDirectories
in class CodeGeneratorHelper
IllegalActionException
- Not thrown in this method.public java.util.Set getModifiedVariables() throws IllegalActionException
getModifiedVariables
in interface ActorCodeGenerator
getModifiedVariables
in class CodeGeneratorHelper
IllegalActionException
- If the helper associated with an actor
or director throws it while getting modified variables.public double getWCET() throws IllegalActionException
getWCET
in class CodeGeneratorHelper
IllegalActionException
- If there is a problem determining
the WCET or a problem accessing the model.protected int _ceilToPowerOfTwo(int value) throws IllegalActionException
value
- The given integer.
IllegalActionException
- If the given integer is not positive.protected static java.lang.String _getIndentPrefix(int level)
level
- The level of indenting represented by the spaces.
_INDENT1
protected void _updatePortOffset(IOPort port, java.lang.StringBuffer code, int rate) throws IllegalActionException
port
- The port whose read offset is to be updated.code
- The string buffer that the generated code is appended to.rate
- The rate, which must be greater than or equal to 0.
IllegalActionException
- If thrown while reading or writing
offsets, or getting the buffer size, or if the rate is less than 0.protected void _updateConnectedPortsOffset(IOPort port, java.lang.StringBuffer code, int rate) throws IllegalActionException
port
- The port whose directly connected downstream actors update
their write offsets.code
- The string buffer that the generated code is appended to.rate
- The rate, which must be greater than or equal to 0.
IllegalActionException
- If thrown while reading or writing
offsets, or getting the buffer size, or if the rate is less than 0.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |