Class FMIMACodeGenerator
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.cg.kernel.generic.GenericCodeGenerator
-
- ptolemy.cg.kernel.generic.RunnableCodeGenerator
-
- ptolemy.cg.kernel.generic.program.ProgramCodeGenerator
-
- ptolemy.cg.kernel.generic.program.procedural.ProceduralCodeGenerator
-
- ptolemy.cg.kernel.generic.program.procedural.fmima.FMIMACodeGenerator
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Decorator
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
FMIMAHybridCodeGenerator
public class FMIMACodeGenerator extends ProceduralCodeGenerator
Generate a Functional Mockup Interface Master Algorithm (FMIMA) description of a model.To generate an FMIMA version of a model, use:
$PTII/bin/ptcg -generatorPackage ptolemy.cg.kernel.generic.program.procedural.fmima \ -generatorPackagelist generic.program.procedural.fmima \ $PTII/ptolemy/cg/kernel/generic/program/procedural/fmima/test/auto/FMUIncScale20RC1pt.xml
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Christopher Brooks
- Pt.AcceptedRating:
- red (cxh)
- Pt.ProposedRating:
- red (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_pathToSupportFiles
End of line character.-
Fields inherited from class ptolemy.cg.kernel.generic.program.procedural.ProceduralCodeGenerator
_compileCommandDefault, _includes, _libraries, compile, compileCommand, generateEmbeddedCode
-
Fields inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGenerator
_modifiedVariables, _newTypesUsed, _portTypeMap, _portTypeMap2, _portTypeMap3, _portTypeMaxIndex, _portTypeMaxIndex2, _portTypeMaxIndex3, _primitiveTypes, _runCommandDefault, _tokenFuncUsed, _typeFuncUsed, _variablesAsArrays, generateComment, inline, maximumLinesPerBlock, measureTime, sourceLineBinding, useMake, variablesAsArrays, verbosity
-
Fields inherited from class ptolemy.cg.kernel.generic.RunnableCodeGenerator
_substituteMap, run, runCommand
-
Fields inherited from class ptolemy.cg.kernel.generic.GenericCodeGenerator
_codeFileName, _eol, _executeCommands, _generateInSubdirectory, _model, _sanitizedModelName, codeDirectory, generateInSubdirectory, generatorPackage, generatorPackageList, INDENT1, INDENT2, INDENT3, overwriteFiles
-
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 FMIMACodeGenerator(NamedObj container, java.lang.String name)
Create a new instance of the FMIMACodeGenerator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
_generateCode(java.lang.StringBuffer code)
Generate FMIMA and append it to the given string buffer.protected java.lang.Class<?>
_getAdapterClassFilter()
Return the filter class to find adapters.protected void
_writeMakefile(CompositeEntity container, java.lang.String currentDirectory)
Read in a template makefile, substitute variables and write the resulting makefile.java.lang.String
comment(java.lang.String comment)
Return a formatted comment containing the specified string.java.lang.String
generateMainEntryCode()
Generate the main entry point.-
Methods inherited from class ptolemy.cg.kernel.generic.program.procedural.ProceduralCodeGenerator
_concatenateElements, _executeCommands, _reset, addInclude, addLibrary, addLibraryIfNecessary, clone, markFunctionCalled
-
Methods inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGenerator
_addActorIncludeDirectories, _addActorLibraries, _analyzeTypeConversions, _codeDirectoryAsFile, _finalPassOverCode, _formatComment, _generateBodyCode, _generateIncludeFiles, _generatePreinitializeCode, _generatePreinitializeMethodBodyCode, _generatePreinitializeMethodEntryCode, _generatePreinitializeMethodExitCode, _generatePreinitializeMethodProcedureName, _generateSharedCode, _getFireFunctionArguments, _instantiateAdapter, _printExecutionTime, _recordStartTime, _setupAdapter, _splitBody, _splitVariableDeclaration, _templateParserClass, _writeVariableDeclarations, addModifiedVariables, attributeChanged, codeGenType, comment, containsCode, generateClosingEntryCode, generateClosingExitCode, generateConstantDefinition, generateFireFunctionCode, generateFireFunctionCompositeEnd, generateFireFunctionCompositeStart, generateFireFunctionMethodInvocation, generateFireFunctionMethodName, generateFireFunctionVariableAndMethodName, generateFireFunctionVariableDeclaration, generateInitializeCode, generateInitializeEntryCode, generateInitializeExitCode, generateInitializeProcedureName, generateLineInfo, generateMainExitCode, generatePackageStatement, generatePortName, generatePostfireCode, generatePostfireEntryCode, generatePostfireExitCode, generatePostfireProcedureName, generatePtIOPortName, generatePtIOPortSize, generatePtTypedCompositeActorName, generatePtTypedCompositeActorSize, generateTypeConvertCode, generateVariableDeclaration, generateVariableInitialization, generateVariableName, generateWrapupCode, generateWrapupEntryCode, generateWrapupExitCode, generateWrapupProcedureName, getModifiedVariables, getTemplateExtension, invokeGenerateUpdatePortOffsets, isPrimitive, isPrimitive, ptolemyType, setModifiedVariables, splitLongBody, splitVariableDeclaration, targetType, updateCommandOptions
-
Methods inherited from class ptolemy.cg.kernel.generic.RunnableCodeGenerator
_runCommand, _setupCommands, _updateSubstituteMap
-
Methods inherited from class ptolemy.cg.kernel.generic.GenericCodeGenerator
_copyCFilesTosrc, _copyCFileTosrc, _getAdapter, _getAutoGeneratedAdapter, _getOutputFilename, _isTopLevel, _printTimeAndMemory, _resetAll, _writeCode, _writeCodeFileName, createDecoratorAttributes, decoratedObjects, generateCode, generateCode, generateCode, generateCopyright, getAdapter, getCodeFileName, getComponent, getExecuteCommands, getMethodExceptionString, getMethodVisibilityString, isGlobalDecorator, main, setCodeGenerator, setContainer, setExecuteCommands
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Constructor Detail
-
FMIMACodeGenerator
public FMIMACodeGenerator(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new instance of the FMIMACodeGenerator. The value of the generatorPackageList parameter of the base class is set togeneric.program.procedural.fmima
- Parameters:
container
- The container.name
- The name of the FMIMACodeGenerator.- Throws:
IllegalActionException
- If the super class throws the exception or error occurs when setting the file path.NameDuplicationException
- If the super class throws the exception or an error occurs when setting the file path.
-
-
Method Detail
-
comment
public java.lang.String comment(java.lang.String comment)
Return a formatted comment containing the specified string. In this base class, the comments is a C-style comment, which begins with "/ *" and ends with "* /" followed by the platform dependent end of line character(s): under Unix: backslash n, under Windows: backslash n backslash r. Subclasses may override this produce comments that match the code generation language.- Overrides:
comment
in classProgramCodeGenerator
- Parameters:
comment
- The string to put in the comment.- Returns:
- A formatted comment.
-
generateMainEntryCode
public java.lang.String generateMainEntryCode() throws IllegalActionException
Generate the main entry point.- Overrides:
generateMainEntryCode
in classProgramCodeGenerator
- Returns:
- Return the definition of the main entry point for a program. In C, this would be defining main().
- Throws:
IllegalActionException
- Not thrown in this base class.
-
_generateCode
protected int _generateCode(java.lang.StringBuffer code) throws KernelException
Generate FMIMA and append it to the given string buffer. Write the code to the directory specified by the codeDirectory parameter. The file name is a sanitized version of the model name with a suffix that is based on last package name of the generatorPackage parameter. Thus if the codeDirectory is$HOME
, the name of the model isFoo
and the generatorPackage isptolemy.cg.kernel.generic.program.procedural.fmima
, then the file that is written will be$HOME/Foo.html
This method is the main entry point to generate fmima- Overrides:
_generateCode
in classProgramCodeGenerator
- Parameters:
code
- The given string buffer.- Returns:
- The return value of the last subprocess that was executed. or -1 if no commands were executed.
- Throws:
KernelException
- If the target file cannot be overwritten or write-to-file throw any exception.
-
_getAdapterClassFilter
protected java.lang.Class<?> _getAdapterClassFilter()
Return the filter class to find adapters. All adapters have to extend this class.- Overrides:
_getAdapterClassFilter
in classGenericCodeGenerator
- Returns:
- The base class for the adapters.
-
_writeMakefile
protected void _writeMakefile(CompositeEntity container, java.lang.String currentDirectory) throws IllegalActionException
Read in a template makefile, substitute variables and write the resulting makefile.See
ProceduralCodeGenerator._writeMakefile(CompositeEntity, String)
for a complete list of variables that are substituted.In this class, the following variables are substituted
@PTCGPPCompiler@
- The g++ compiler
@PTCGCompler@
- The gcc compiler
- Overrides:
_writeMakefile
in classProceduralCodeGenerator
- Parameters:
container
- The composite actor for which we generate the makefilecurrentDirectory
- The director in which the makefile is to be written.- Throws:
IllegalActionException
- If there is a problem reading a parameter, if there is a problem creating the codeDirectory directory or if there is a problem writing the code to a file.
-
-