Class DEDirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.cg.kernel.generic.CodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
-
- ptolemy.cg.adapter.generic.adapters.ptolemy.actor.Director
-
- ptolemy.cg.adapter.generic.adapters.ptolemy.actor.PortDirector
-
- ptolemy.cg.adapter.generic.program.procedural.c.adapters.ptolemy.domains.de.kernel.DEDirector
-
- All Implemented Interfaces:
java.lang.Cloneable,Changeable,Debuggable,DebugListener,Derivable,ModelErrorHandler,MoMLExportable,Moveable,Nameable
- Direct Known Subclasses:
PtidesDirector
public class DEDirector extends PortDirector
Code generator adapter associated with the DEDirector class. This adapter is highly experimental since it changes a lot of behaviors of the code generation process. This class is also associated with a code generator.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- William Lucas based on SDFDirector.java by Ye Zhou, Gang Zhou
- Pt.AcceptedRating:
- red (wlc)
- Pt.ProposedRating:
- red (wlc)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
NamedProgramCodeGeneratorAdapter.VariableScope
-
Nested classes/interfaces inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
ProgramCodeGeneratorAdapter.Channel
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<NamedProgramCodeGeneratorAdapter,java.util.HashSet<Parameter>>_referencedParametersA hashmap that keeps track of parameters that are referenced for the associated actor.-
Fields inherited from class ptolemy.cg.adapter.generic.adapters.ptolemy.actor.PortDirector
_sanitizedDirectorName, ports
-
Fields inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
_component, _defaultBlocks, _eol, _templateParser
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Constructor Description DEDirector(DEDirector deDirector)Construct the code generator adapter associated with the given DEDirector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.BooleanallowDynamicMultiportReference()Return whether the channels in multiports can be dynamically referenced using the $ref macro.java.lang.StringgenerateConstructorCode()Generate the constructor code for the specified director.java.lang.StringgenerateFireAtFunctionCode()Generate The _fireAt function code.java.lang.StringgenerateFireFunctionCode()Generate The fire function code.java.lang.StringgenerateFirePrivateFunctionCode()Generate The _fire function code.java.lang.StringgenerateFunctionsDeclaration()Generate The functions' declaration code for this director.java.lang.StringgenerateInitializeFunctionCode()Generate the initialize code for the associated DE director.java.lang.StringgenerateMainLoop()Generate a main loop for an execution under the control of this DE director.java.lang.StringgenerateNextActorToFireFunctionCode()Generate The _NextActorToFire function code.java.lang.StringgeneratePortName(TypedIOPort port)Generate sanitized name for the given named object.java.lang.StringgeneratePostFireFunctionCode()Generate The postfire function code.java.lang.StringgeneratePreFireFunctionCode()Generate The prefire function code.java.lang.StringgeneratePreinitializeCode()Generate the preinitialize code for this director.java.lang.StringgeneratePreinitializeMethodBodyCode()Generate the preinitialize code for this director.java.lang.StringgenerateVariableDeclaration()Generate the variable declaration.java.lang.StringgenerateWrapupCode()Generate The wrapup function code.java.util.Set<java.lang.String>getHeaderFiles()Get the files needed by the code generated from this adapter class.java.lang.BooleanpadBuffers()Return whether we need to pad buffers or not.-
Methods inherited from class ptolemy.cg.adapter.generic.adapters.ptolemy.actor.PortDirector
_checkLocal, _checkRemote, _generateChannelOffset, _generatePortReference, _getCastType, _getChannelAndOffset, _getRefName, _getRefType, getReference, getReference, getSanitizedDirectorName
-
Methods inherited from class ptolemy.cg.adapter.generic.adapters.ptolemy.actor.Director
_ceilToPowerOfTwo, generateCodeForGet, generateCodeForSend, generateFireCode, generateInitializeCode, generateModeTransitionCode, generatePostfireCode, generateTransferInputsCode, generateTransferInputsCode, generateTransferOutputsCode, generateTransferOutputsCode, generateVariableDeclaration, generateVariableInitialization, generateVariableInitialization, getComponent, getIncludeDirectories, getLibraries, getLibraryDirectories, getModifiedVariables, getParameter
-
Methods inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
_generateFireCode, _generateTypeConvertStatement, analyzeTypeConvert, copyFilesToCodeDirectory, generatePrefireCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, getAddTimeString, getBufferSize, getBufferSize, getDeclareSharedCode, getDefaultBlocks, getFireFunctionParameters, getName, getParameterValue, getReference, getReference, getSharedCode, getSinkChannels, getSourceTimeString, getTimeSourcePortName, getTypeConvertChannels, getTypeConvertReference, getTypeConvertSinkChannels, setupAdapter, targetType
-
Methods inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
_generateBlockByName, getAdapter, getCodeGenerator, getTemplateParser, processCode, setCodeGenerator, setTemplateParser, toString
-
Methods inherited from class ptolemy.cg.kernel.generic.CodeGeneratorAdapter
createDecoratorAttributes, generateName
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_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
-
-
-
-
Field Detail
-
_referencedParameters
protected java.util.HashMap<NamedProgramCodeGeneratorAdapter,java.util.HashSet<Parameter>> _referencedParameters
A hashmap that keeps track of parameters that are referenced for the associated actor.
-
-
Constructor Detail
-
DEDirector
public DEDirector(DEDirector deDirector)
Construct the code generator adapter associated with the given DEDirector.- Parameters:
deDirector- The associated ptolemy.domains.de.kernel.DEDirector
-
-
Method Detail
-
allowDynamicMultiportReference
public final java.lang.Boolean allowDynamicMultiportReference() throws IllegalActionExceptionReturn whether the channels in multiports can be dynamically referenced using the $ref macro.- Specified by:
allowDynamicMultiportReferencein classPortDirector- Returns:
- True when the channels in multiports can be dynamically referenced using the $ref macro.
- Throws:
IllegalActionException- If the expression cannot be parsed or cannot be evaluated, or if the result of evaluation violates type constraints, or if the result of evaluation is null and there are variables that depend on this one.
-
generateConstructorCode
public java.lang.String generateConstructorCode() throws IllegalActionExceptionGenerate the constructor code for the specified director. In this class we initialize the director with its internal parameters and fields as well as with the depths of the actors.- Overrides:
generateConstructorCodein classDirector- Returns:
- The generated constructor code
- Throws:
IllegalActionException- Not thrown in this base class.
-
generateFunctionsDeclaration
public java.lang.String generateFunctionsDeclaration() throws IllegalActionExceptionGenerate The functions' declaration code for this director.- Returns:
- The functions' declaration function code.
- Throws:
IllegalActionException- If thrown while generating code.
-
generateFireAtFunctionCode
public java.lang.String generateFireAtFunctionCode() throws IllegalActionExceptionGenerate The _fireAt function code. This method is the direct transposition of the _fireAt function of the director in C.- Returns:
- The _fireAt function code.
- Throws:
IllegalActionException- If thrown while generating fire code.
-
generateFireFunctionCode
public java.lang.String generateFireFunctionCode() throws IllegalActionExceptionGenerate The fire function code. This method calls fire() for in a loop This method is the direct transposition of the Fire function of the director in C.- Overrides:
generateFireFunctionCodein classDirector- Returns:
- The fire function code.
- Throws:
IllegalActionException- If thrown while generating fire code.
-
generateFirePrivateFunctionCode
public java.lang.String generateFirePrivateFunctionCode() throws IllegalActionExceptionGenerate The _fire function code. This method is the direct transposition of the _fire function of the director in C.- Returns:
- The _fire function code.
- Throws:
IllegalActionException- If thrown while generating fire code.
-
generateInitializeFunctionCode
public java.lang.String generateInitializeFunctionCode() throws IllegalActionExceptionGenerate the initialize code for the associated DE director.- Returns:
- The generated initialize code.
- Throws:
IllegalActionException- If the adapter associated with an actor throws it while generating initialize code for the actor.
-
generateMainLoop
public java.lang.String generateMainLoop() throws IllegalActionExceptionGenerate a main loop for an execution under the control of this DE director.- Overrides:
generateMainLoopin classNamedProgramCodeGeneratorAdapter- Returns:
- Code for the main loop of an execution.
- Throws:
IllegalActionException- If something goes wrong.
-
generateNextActorToFireFunctionCode
public java.lang.String generateNextActorToFireFunctionCode() throws IllegalActionExceptionGenerate The _NextActorToFire function code. This method is the direct transposition of the _NextActorToFire function of the director in C.- Returns:
- The _fireAt function code.
- Throws:
IllegalActionException- If thrown while generating fire code.
-
generatePortName
public java.lang.String generatePortName(TypedIOPort port) throws IllegalActionException
Generate sanitized name for the given named object. Remove all underscores to avoid conflicts with systems functions.- Specified by:
generatePortNamein classPortDirector- Parameters:
port- The port for which the name is generated.- Returns:
- The sanitized name.
- Throws:
IllegalActionException- If the variablesAsArrays parameter cannot be read or if the buffer size of the port cannot be read.
-
generatePostFireFunctionCode
public java.lang.String generatePostFireFunctionCode() throws IllegalActionExceptionGenerate The postfire function code.- Returns:
- The postfire function code.
- Throws:
IllegalActionException- If thrown while generating fire code.
-
generatePreFireFunctionCode
public java.lang.String generatePreFireFunctionCode() throws IllegalActionExceptionGenerate The prefire function code.- Returns:
- The prefire function code.
- Throws:
IllegalActionException- If thrown while generating fire code.
-
generatePreinitializeCode
public java.lang.String generatePreinitializeCode() throws IllegalActionExceptionGenerate the preinitialize code for this director.- Overrides:
generatePreinitializeCodein classDirector- Returns:
- The generated preinitialize code.
- Throws:
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.
-
generatePreinitializeMethodBodyCode
public java.lang.String generatePreinitializeMethodBodyCode() throws IllegalActionExceptionGenerate the preinitialize code for this director. The preinitialize code for the director is generated by appending the preinitialize code for each actor.- Overrides:
generatePreinitializeMethodBodyCodein classDirector- Returns:
- The generated preinitialize code.
- Throws:
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.
-
generateVariableDeclaration
public java.lang.String generateVariableDeclaration() throws IllegalActionExceptionGenerate the variable declaration.We override the super method, because in DE the declaration of the variables are in the actor's files.
- Overrides:
generateVariableDeclarationin classDirector- Returns:
- code The generated code.
- Throws:
IllegalActionException- If the adapter class for the model director cannot be found.
-
generateWrapupCode
public java.lang.String generateWrapupCode() throws IllegalActionExceptionGenerate The wrapup function code.- Overrides:
generateWrapupCodein classDirector- Returns:
- The wrapup function code.
- Throws:
IllegalActionException- If thrown while generating fire code.
-
getHeaderFiles
public java.util.Set<java.lang.String> getHeaderFiles() throws IllegalActionExceptionGet the files needed by the code generated from this adapter class. Basically here, we include the "standard" C-written declaration of the DECQEventQueue- Overrides:
getHeaderFilesin classNamedProgramCodeGeneratorAdapter- Returns:
- A set of strings that are header files needed by the code generated from this adapter class.
- Throws:
IllegalActionException- If something goes wrong.
-
padBuffers
public final java.lang.Boolean padBuffers() throws IllegalActionExceptionReturn whether we need to pad buffers or not.- Specified by:
padBuffersin classPortDirector- Returns:
- True when we need to pad buffers.
- Throws:
IllegalActionException- If the expression cannot be parsed or cannot be evaluated, or if the result of evaluation violates type constraints, or if the result of evaluation is null and there are variables that depend on this one.
-
_generateVariableDeclaration
protected java.lang.String _generateVariableDeclaration(NamedProgramCodeGeneratorAdapter target) throws IllegalActionException
Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.- Overrides:
_generateVariableDeclarationin classDirector- Parameters:
target- The ProgramCodeGeneratorAdapter for which code needs to be generated.- Returns:
- code The generated code.
- Throws:
IllegalActionException- If the adapter class for the model director cannot be found.
-
_generateVariableInitialization
protected java.lang.String _generateVariableInitialization(NamedProgramCodeGeneratorAdapter target) throws IllegalActionException
Generate variable initialization for the referenced parameters.- Overrides:
_generateVariableInitializationin classDirector- Parameters:
target- The ProgramCodeGeneratorAdapter for which code needs to be generated.- Returns:
- code The generated code.
- Throws:
IllegalActionException- If the adapter class for the model director cannot be found.
-
_getParameter
protected java.lang.String _getParameter(NamedProgramCodeGeneratorAdapter target, Attribute attribute, java.lang.String[] channelAndOffset) throws IllegalActionException
Return an unique label for the given attribute referenced by the given adapter.- Overrides:
_getParameterin classDirector- Parameters:
target- The ProgramCodeGeneratorAdapter for which code needs to be generated.attribute- The given attribute.channelAndOffset- The given channel and offset.- Returns:
- an unique label for the given attribute.
- Throws:
IllegalActionException- If the adapter throws it while generating the label.
-
-