public class Director extends NamedProgramCodeGeneratorAdapter
GenericCodeGenerator
Yellow (zhouye) |
Yellow (zhouye) |
NamedProgramCodeGeneratorAdapter.VariableScope
ProgramCodeGeneratorAdapter.Channel
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected Director |
_director
The associated director.
|
_component, _defaultBlocks, _eol, _templateParser
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
Director(Director director)
Construct the code generator adapter associated with the given director.
|
Modifier and Type | Method and Description |
---|---|
protected int |
_ceilToPowerOfTwo(int value)
Return the minimum number of power of two that is greater than or
equal to the given integer.
|
protected java.lang.String |
_generateVariableDeclaration(NamedProgramCodeGeneratorAdapter target)
Generate variable declarations for inputs and outputs and parameters.
|
protected java.lang.String |
_generateVariableInitialization(NamedProgramCodeGeneratorAdapter target)
Generate variable initialization for the referenced parameters.
|
protected java.lang.String |
_getParameter(NamedProgramCodeGeneratorAdapter target,
Attribute attribute,
java.lang.String[] channelAndOffset)
Return an unique label for the given attribute referenced
by the given adapter.
|
java.lang.String |
generateCodeForGet(IOPort port,
int channel)
Generate the get code for Port port.
|
java.lang.String |
generateCodeForSend(IOPort port,
int channel,
java.lang.String dataToken)
Generate the send code for Port port.
|
java.lang.String |
generateConstructorCode()
Generate the constructor code for the specified director.
|
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.
|
void |
generateModeTransitionCode(java.lang.StringBuffer code)
Generate mode transition 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.
|
java.lang.String |
generatePreinitializeMethodBodyCode()
Generate the preinitialization method body.
|
void |
generateTransferInputsCode(IOPort inputPort,
java.lang.StringBuffer code)
Generate code for transferring enough tokens to complete an internal
iteration.
|
void |
generateTransferInputsCode(IOPort inputPort,
java.lang.StringBuffer code,
boolean executive)
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.
|
void |
generateTransferOutputsCode(IOPort outputPort,
java.lang.StringBuffer code,
boolean executive)
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 |
generateVariableDeclaration(NamedProgramCodeGeneratorAdapter adapter)
Generate variable declarations for inputs and outputs and parameters.
|
java.lang.String |
generateVariableInitialization()
Generate variable initialization for the referenced parameters.
|
java.lang.String |
generateVariableInitialization(NamedProgramCodeGeneratorAdapter adapter)
Generate variable initialization for the referenced parameters.
|
java.lang.String |
generateWrapupCode()
Generate the wrapup code of the director associated with this adapter
class.
|
NamedObj |
getComponent()
Return the director associated with this class.
|
java.util.Set<java.lang.String> |
getIncludeDirectories()
Return an empty HashSet.
|
java.util.Set<java.lang.String> |
getLibraries()
Return an empty HashSet.
|
java.util.Set<java.lang.String> |
getLibraryDirectories()
Return an empty HashSet.
|
java.util.Set<Parameter> |
getModifiedVariables()
Return a set of parameters that will be modified during the execution
of the model.
|
java.lang.String |
getParameter(NamedProgramCodeGeneratorAdapter target,
Attribute attribute,
java.lang.String[] channelAndOffset)
Gets the parameter.
|
java.lang.String |
getReference(java.lang.String name,
boolean isWrite,
NamedProgramCodeGeneratorAdapter target)
Return the reference to the specified parameter or port of the
associated actor.
|
_generateFireCode, _generateTypeConvertStatement, analyzeTypeConvert, copyFilesToCodeDirectory, generateMainLoop, generatePrefireCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, getAddTimeString, getBufferSize, getBufferSize, getDeclareSharedCode, getDefaultBlocks, getFireFunctionParameters, getHeaderFiles, getName, getParameterValue, getReference, getReference, getSharedCode, getSinkChannels, getSourceTimeString, getTimeSourcePortName, getTypeConvertChannels, getTypeConvertReference, getTypeConvertSinkChannels, setupAdapter, targetType
_generateBlockByName, getAdapter, getCodeGenerator, getTemplateParser, processCode, setCodeGenerator, setTemplateParser, toString
createDecoratorAttributes, generateName
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateExistence, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getContainer, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
protected Director _director
public Director(Director director)
director
- The associated director.public java.lang.String generateCodeForSend(IOPort port, int channel, java.lang.String dataToken)
port
- The port for which to generate send code.channel
- The channel for which the send code is generated.dataToken
- The token to be sentpublic java.lang.String generateCodeForGet(IOPort port, int channel)
port
- The port for which to generate get code.channel
- The channel for which the get code is generated.public java.lang.String generateFireCode() throws IllegalActionException
generateFireCode
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If the adapter associated with
an actor throws it while generating fire code for the actor.public java.lang.String generateFireFunctionCode() throws IllegalActionException
generateFireFunctionCode
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If thrown while generating fire code.public java.lang.String generateConstructorCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateInitializeCode() throws IllegalActionException
generateInitializeCode
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If illegal macro names are found.public java.lang.String generatePostfireCode() throws IllegalActionException
generatePostfireCode
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If the adapter 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 class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If getting the adapter fails,
or if generating the preinitialize code for a adapter fails,
or if there is a problem getting the buffer size of a port.public java.lang.String generatePreinitializeMethodBodyCode() throws IllegalActionException
Typically, the preinitialize code consists of variable declarations. However, AutoAdapter generates method calls that instantiate wrapper TypedCompositeActors, so we need to invoke those method calls.
generatePreinitializeMethodBodyCode
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- Not thrown in this base class.public void generateModeTransitionCode(java.lang.StringBuffer code) throws IllegalActionException
generateModeTransitionCode
in class NamedProgramCodeGeneratorAdapter
code
- The string buffer that the generated code is appended to.IllegalActionException
- If an actor adapter 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 generateTransferInputsCode(IOPort inputPort, java.lang.StringBuffer code, boolean executive) throws IllegalActionException
inputPort
- The port to transfer tokens.code
- The string buffer that the generated code is appended to.executive
- If true, then look for the reference in the
executive director (the director of the container). The
CaseDirector calls this with executive == true, most (all?)
other Directors call this with executive == false.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 void generateTransferOutputsCode(IOPort outputPort, java.lang.StringBuffer code, boolean executive) throws IllegalActionException
outputPort
- The port to transfer tokens.code
- The string buffer that the generated code is appended to.executive
- If true, then look for the reference in the
executive director (the director of the container). The
CaseDirector calls this with executive == true, most (all?)
other Directors call this with executive == false.IllegalActionException
- If thrown while transferring tokens.public java.lang.String generateVariableDeclaration() throws IllegalActionException
generateVariableDeclaration
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If the adapter class for the model
director cannot be found.public java.lang.String generateVariableDeclaration(NamedProgramCodeGeneratorAdapter adapter) throws IllegalActionException
adapter
- The adapter for which to generate variable declarations.IllegalActionException
- If the adapter class for the model
director cannot be found.public java.lang.String generateVariableInitialization() throws IllegalActionException
generateVariableInitialization
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If the adapter class for the model
director cannot be found.public java.lang.String generateVariableInitialization(NamedProgramCodeGeneratorAdapter adapter) throws IllegalActionException
adapter
- The adapter for which to generate variable initialization.IllegalActionException
- If the adapter class for the model
director cannot be found.public java.lang.String generateWrapupCode() throws IllegalActionException
generateWrapupCode
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If the adapter class for each actor
cannot be found, or if an error occurs while the adapter generate the
wrapup code.public java.lang.String getReference(java.lang.String name, boolean isWrite, NamedProgramCodeGeneratorAdapter target) throws IllegalActionException
name
- The name of the parameter or portisWrite
- Whether to generate the write or read offset.target
- The ProgramCodeGeneratorAdapter for which code
needs to be generated.IllegalActionException
- If the parameter or port does not
exist or does not have a value.public NamedObj getComponent()
getComponent
in class NamedProgramCodeGeneratorAdapter
public java.util.Set<java.lang.String> getIncludeDirectories() throws IllegalActionException
getIncludeDirectories
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- Not thrown in this method.public java.util.Set<java.lang.String> getLibraries() throws IllegalActionException
getLibraries
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- Not thrown in this method.public java.util.Set<java.lang.String> getLibraryDirectories() throws IllegalActionException
getLibraryDirectories
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- Not thrown in this method.public java.util.Set<Parameter> getModifiedVariables() throws IllegalActionException
getModifiedVariables
in class NamedProgramCodeGeneratorAdapter
IllegalActionException
- If the adapter associated with an actor
or director throws it while getting modified variables.public java.lang.String getParameter(NamedProgramCodeGeneratorAdapter target, Attribute attribute, java.lang.String[] channelAndOffset) throws IllegalActionException
target
- An adapterattribute
- The attributechannelAndOffset
- The given channel and offset.IllegalActionException
- If the adapter throws it while
generating the label.protected int _ceilToPowerOfTwo(int value) throws IllegalActionException
value
- The given integer.IllegalActionException
- If the given integer is not positive.protected java.lang.String _generateVariableDeclaration(NamedProgramCodeGeneratorAdapter target) throws IllegalActionException
target
- The ProgramCodeGeneratorAdapter for which code
needs to be generated.IllegalActionException
- If the adapter class for the model
director cannot be found.protected java.lang.String _generateVariableInitialization(NamedProgramCodeGeneratorAdapter target) throws IllegalActionException
target
- The ProgramCodeGeneratorAdapter for which code
needs to be generated.IllegalActionException
- If the adapter class for the model
director cannot be found.protected java.lang.String _getParameter(NamedProgramCodeGeneratorAdapter target, Attribute attribute, java.lang.String[] channelAndOffset) throws IllegalActionException
target
- The ProgramCodeGeneratorAdapter for which code needs to be generated.attribute
- The given attribute.channelAndOffset
- The given channel and offset.IllegalActionException
- If the adapter throws it while
generating the label.