Class 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)
    • Field Detail

      • _pathToSupportFiles

        protected java.lang.String _pathToSupportFiles
        End of line character. Under Unix: "\n", under Windows: "\n\r". We use a end of line character so that the files we generate have the proper end of line character for use by other native tools.
    • 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 to generic.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 class ProgramCodeGenerator
        Parameters:
        comment - The string to put in the comment.
        Returns:
        A formatted comment.
      • _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 is Foo and the generatorPackage is ptolemy.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 class ProgramCodeGenerator
        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 class GenericCodeGenerator
        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 class ProceduralCodeGenerator
        Parameters:
        container - The composite actor for which we generate the makefile
        currentDirectory - 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.