org.jmodelica.modelica.compiler.ModelicaCompiler Class Reference

Main compiler class which bundles the tasks needed to compile a Modelica model. More...

List of all members.

Classes

class  ModelicaLoggers
 Class which can be used to fetch static loggers with different purposes.

Public Member Functions

 ModelicaCompiler (OptionRegistry options, String xmlTpl, String xmlValuesTpl, String cTemplatefile)
 ModelicaCompiler (OptionRegistry options)
void defaultOptionsFMUME ()
void defaultOptionsFMUCS ()
void defaultOptionsFMUX ()
void defaultTemplatePathsJMU ()
void defaultTemplatePathsFMUME ()
void defaultTemplatePathsFMUCS ()
void defaultTemplatePathsFMUX ()
void setTempFileDir (File temp)
 Sets the directory new temporary files are created in.
void setOutDir (File out)
void setSubOutDir (String out)
void setRandomOutDir ()
void deleteOutDir ()
void addCompilationHooks (CompilationHooks hooks)
void removeCompilationHooks (CompilationHooks hooks)
IErrorHandler getErrorHandler ()
void setErrorHandler (IErrorHandler eh)
 Set the error handler to use for collection errors.
String getStringOption (String key) throws UnknownOptionException
void setStringOption (String key, String value) throws UnknownOptionException
int getIntegerOption (String key) throws UnknownOptionException
void setIntegerOption (String key, int value) throws UnknownOptionException
double getRealOption (String key) throws UnknownOptionException
void setRealOption (String key, double value) throws UnknownOptionException
boolean getBooleanOption (String key) throws UnknownOptionException
void setBooleanOption (String key, boolean value) throws UnknownOptionException
void setDiagnosticsGenerator (DiagnosticsGenerator diagGenerator)
DiagnosticsGenerator getDiagnosticsGenerator ()
String getOptionDescription (String key) throws UnknownOptionException
String getModelicapath ()
 Returns the modelicapath attribute set for this compiler instance.
void setModelicapath (String path)
 Set the modelicapath attribute.
String getXMLTpl ()
 Returns the XML model description template file path set for this compiler instance.
void setXMLTpl (String template)
 Set the XML model description template file path attribute.
String getXMLValuesTpl ()
 Returns the XML values template file path set for this compiler instance.
void setXMLValuesTpl (String template)
 Set the XML values template file path attribute.
String getCTemplate ()
 Returns the c template file path set for this compiler instance.
void setCTemplate (String template)
 Set the c template file path attribute.
void compileJMU (String className, String fileName[]) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates a JMU.
void compileJMU (String className, String fileName[], String compileTo) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates a JMU.
void compileJMU (String className, String fileName[], String target, String compileTo) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates a JMU.
void compileFMUME (String className, String fileName[]) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates an FMU for Model Exchange.
void compileFMUCS (String className, String fileName[]) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates an FMU for Co-simulation.
void compileFMUME (String className, String fileName[], String compileTo) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates an FMU for Model Exchange.
void compileFMUCS (String className, String fileName[], String compileTo) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates an FMU for Co-simulation.
void compileFMU (String className, String fileName[], String target, String compileTo) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates an FMU.
void compileFMUX (String className, String fileName[], String compileTo) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a model and creates an FMUX.
FClass compileModel (String name[], String cl) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception
 Compiles a Modelica model.
SourceRoot parseModel (String names[]) throws FileNotFoundException, IOException, beaver.Parser.Exception, CompilerException
 Parses a set of files and returns a reference to the root of a source tree where the content of all files is contained.
InstClassDecl instantiateModel (SourceRoot sr, String cl) throws ModelicaClassNotFoundException, CompilerException
 Computes a model instance tree from a source tree.
FClass createFlatTree (InstClassDecl icl, String flatFile)
 Create a flat tree with an empty FClass and return the FClass.
FClass flattenModel (InstClassDecl icl) throws CompilerException, ModelicaClassNotFoundException, IOException
 Computes the flattened model representation from a model instance.
void generateCode (FClass fc) throws FileNotFoundException
 Generates XML and c code for a flattened model represented as an instance of FClass using template files.

Static Public Member Functions

static CCompilerDelegator getCCompiler ()
static void setCCompiler (CCompilerDelegator cCompiler)
static String getJModelicaHome ()
static void setJModelicaHome (String jmHome)
static void addGlobalCompilationHooks (CompilationHooks hooks)
static void removeGlobalCompilationHooks (CompilationHooks hooks)
static void setLogger (ModelicaLogger log)
 Use the specified logger.
static void setDefaultLogger ()
 Use the default logger.
static void setStreamLogger (OutputStream stream)
 Create and use a logger that logs to a stream.
static void closeStreamLogger ()
 Close and disconnect any stream connected to the stream logger.
static void setLogLevel (String level)
 Sets logging to the level specified.
static String getLogLevel ()
 Returns the log level that is currently set.
static void setLogLevel (ModelicaLogger logger, String level)
 Sets logging to the level specified.
static String getLogLevel (ModelicaLogger logger)
 Returns the log level that is currently set.
static void setLogLevel (String logger, String level)
 Sets logging to the level specified.
static String getLogLevel (String logger)
 Returns the log level that is currently set.
static int loggedProcess (String[] cmd, String[] env, File workDir)
 Executes the given command as a separate process, writing any output to the logger.
static void main (String[] args)
static String getPlatform ()
 Helper function.

Static Public Attributes

static final String DEBUG = "d"
static final String INFO = "i"
static final String WARNING = "w"
static final String ERROR = "e"
static final String INHERITED = "inh"
static final String DEFAULT_LEVEL = ERROR

Protected Member Functions

 ModelicaCompiler ()
void recursiveDelete (File dir)
void hookCheckAbort ()
 Throws a CompilationAbortedException if any hooks class signals an abort.
void hookFilesParsed (SourceRoot sr)
 Calls the hook to be called after the supplied code files are parsed.
void hookModelInstantiatied (InstClassDecl icd)
 Calls the hook to be called after the error checks on the instantiated model are finished without errors.
void hookModelFlattened (FClass fc)
 Calls the hook to be called after the model is flattened.
void hookModelTransformed (FClass fc)
 Calls the hook to be called after transformations are applied to the model.
void hookFlatModelChecked (FClass fc)
 Calls the hook to be called after error checks of the flat model are finished without errors.
void hookCodeGeneratorCreated (AbstractGenerator gen)
 Calls the hook to be called after a code generator is created.
void hookCodeGenerated (File dir)
 Calls the hook to be called after output code is generated.
void hookCodeCompiled ()
 Calls the hook to be called after the generated C code is compiled.
void hookFmuPacked (File path)
 Calls the hook to be called after the FMU is packed.
void resetCompilationInfo ()
 Initilize vars gathering debug information about compilation.
void logCompilationInfo ()
 Log debug information about compilation.
void noteUsedMemory ()
 Saves away the current amount of memory used.
void dumpMemoryUseFile (ASTNode root, String type) throws FileNotFoundException
 Save a dump of the memory use of an AST.
void dumpMemoryUseFile (ASTNode root, String type, String name) throws FileNotFoundException
 Save a dump of the memory use of an AST.
void dumpNodeCountFile (String file) throws FileNotFoundException
 Save a dump of the number of AST nodes created of each type.
void packUnit (String className, String path, String unitType)
 Packs either a JMU or FMU (helper function for compileUnit).
void parseFiles (String[] files)
void zipDir (File dir, ZipOutputStream out)
 Write all files in a directory and its subdirectories to a zip stream.
void zipDir (File dir, ZipOutputStream out, File zipDir)
 Write all files in a directory and its subdirectories to a zip stream.
String getUnitSuffix (String unitType)
 Gets the file suffix for a given unit type.
void handleCompilerProblems (Collection< Problem > problems) throws CompilerException
FClass createFClass (InstClassDecl icd)
 Create a new FClass object.
XMLGenerator createXMLGenerator (FClass fc)
 Create a new XMLGenerator object.
XMLValueGenerator createXMLValueGenerator (FClass fc)
 Create a new XMLValueGenerator object.
CGenerator createCGenerator (FClass fc)
 Create a new CGenerator object.
String getXmlTpl (FClass fc)
 get the XML template.
String getXmlValuesTpl (FClass fc)
 get the XML values template.
String getCTemplatefile (FClass fc)
 get the C template.
void setArguments (String compilerName, String[] args, Hashtable< String, String > programarguments) throws JModelicaHomeNotFoundException
void compileModelFromCommandLine (String[] args, Hashtable< String, String > programarguments)
 Compile model given in command line options and and print any error messages.
String[] splitFiles (String arg)
 Split the argument containing the list of files into an array of filenames.
void handleException (Throwable e, String msg)
 Log error message for exception and exit.
void handleException (Throwable e)
 Log error message for exception and exit.

Static Protected Member Functions

static File getTemplatesDir ()
static Hashtable< String, String > extractProgramArguments (String[] args, int pos)

Protected Attributes

String xmlTpl = null
String xmlValuesTpl = null
String cTemplatefile = null
LinkedList< CompilationHookshooksList = new LinkedList<CompilationHooks>(globalHooksList)
IErrorHandler errorHandler = null
File tempDir = null
File outDir = null
File sourceDir = null
File resourceDir = null
long[] usedMem = new long[NUM_USED_MEMORY_SLOTS]
int numUsedMemFilled
long timeCompilationStarted

Static Protected Attributes

static final String CONSOLE_LOG_NAME = ModelicaCompiler.class.getName() + ".console"
static final String STREAM_LOG_NAME = ModelicaCompiler.class.getName() + ".stream"
static ModelicaLogger log = ModelicaLoggers.getConsoleLogger(CONSOLE_LOG_NAME)
static final HashMap< String,
Level > 
levels = new HashMap<String, Level>()
static LinkedList
< CompilationHooks
globalHooksList = new LinkedList<CompilationHooks>()
static CCompilerDelegator cCompiler = new GccCompilerDelegator()
static String jmodelicaHome = System.getenv("JMODELICA_HOME")
static final int NUM_USED_MEMORY_SLOTS = 6


Detailed Description

Main compiler class which bundles the tasks needed to compile a Modelica model.

There are two usages with this class:

  1. Compile in one step either from the command line or by calling the static method <compileModel> in your own class.
  2. Split compilation into several steps by calling the static methods in your own class.

Use (1) for a simple and compact way of compiling a Modelica model. As a minimum, provide the modelfile name and class name as command line arguments. Optional arguments are XML template and c template files which are needed for code generation. If any of these are ommitted no code generation will be performed.

Command line example without code generation:
org.jmodelica.applications.ModelicaCompiler myModels/models.mo models.model1

Command line example with code generation:
org.jmodelica.applications.ModelicaCompiler myModels/models.mo models.model1 XMLtemplate1.xml XMLtemplate2.xml cppTemplate.cpp

Logging can be set with the optional argument -log=i, w or e where:

Example with log level set to INFO:
org.jmodelica.applications.ModelicaCompiler -i myModels/models.mo models.model1

The logs will be printed to standard out.

For method (2), the compilation steps are divided into 4 tasks which can be used via the methods:

  1. parseModel (source code -> attributed source representation)
  2. instantiateModel (source representation -> instance model)
  3. flattenModel (instance model -> flattened model)
  4. generateCode (flattened model -> c code and XML code)

They must be called in this order. Use provided methods to get/set logging level.

class :0


Constructor & Destructor Documentation

org.jmodelica.modelica.compiler.ModelicaCompiler.ModelicaCompiler ( OptionRegistry  options,
String  xmlTpl,
String  xmlValuesTpl,
String  cTemplatefile 
)

org.jmodelica.modelica.compiler.ModelicaCompiler.ModelicaCompiler ( OptionRegistry  options  ) 

org.jmodelica.modelica.compiler.ModelicaCompiler.ModelicaCompiler (  )  [protected]


Member Function Documentation

void org.jmodelica.modelica.compiler.ModelicaCompiler.addCompilationHooks ( CompilationHooks  hooks  ) 

static void org.jmodelica.modelica.compiler.ModelicaCompiler.addGlobalCompilationHooks ( CompilationHooks  hooks  )  [static]

static void org.jmodelica.modelica.compiler.ModelicaCompiler.closeStreamLogger (  )  [static]

Close and disconnect any stream connected to the stream logger.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileFMU ( String  className,
String  fileName[],
String  target,
String  compileTo 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates an FMU.

Compiles a model (parsing, instantiating, flattening, code generation and binary file compilation) and packs the result in a FMU.

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.
target The build target. Valid options are 'model_noad', 'model_fmume' and 'model_fmucs'.
compileTo Specify location of the compiled FMU. Directory will be created if it does not exist.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileFMUCS ( String  className,
String  fileName[],
String  compileTo 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates an FMU for Co-simulation.

Compiles a model (parsing, instantiating, flattening, code generation and binary file compilation) and packs the result in a FMU.

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.
compileTo Specify location of the compiled FMU. Directory will be created if it does not exist.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileFMUCS ( String  className,
String  fileName[] 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates an FMU for Co-simulation.

Compiles a model (parsing, instantiating, flattening, code generation and binary file compilation) and packs the result in a FMU.

Convenience metod, equivalent to compileFMUCS(className, fileName, ".").

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileFMUME ( String  className,
String  fileName[],
String  compileTo 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates an FMU for Model Exchange.

Compiles a model (parsing, instantiating, flattening, code generation and binary file compilation) and packs the result in a FMU.

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.
compileTo Specify location of the compiled FMU. Directory will be created if it does not exist.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileFMUME ( String  className,
String  fileName[] 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates an FMU for Model Exchange.

Compiles a model (parsing, instantiating, flattening, code generation and binary file compilation) and packs the result in a FMU.

Convenience metod, equivalent to compileFMUME(className, fileName, ".").

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileFMUX ( String  className,
String  fileName[],
String  compileTo 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates an FMUX.

Compiles a model (parsing, instantiating, flattening and XML code generation) and packs the result in a FMUX.

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.
compileTo Specify location of the compiled FMUX. Directory will be created if it does not exist.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileJMU ( String  className,
String  fileName[],
String  target,
String  compileTo 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates a JMU.

Compiles a model (parsing, instantiating, flattening, code generation and binary file compilation) and packs the result in a JMU.

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.
target The build target. Valid options are 'model', 'model_noad', 'algorithms' and 'ipopt'.
compileTo Specify location of the compiled JMU. Directory will be created if it does not exist.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileJMU ( String  className,
String  fileName[],
String  compileTo 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates a JMU.

Compiles a model (parsing, instantiating, flattening, code generation and binary file compilation) and packs the result in a JMU.

Convenience metod, equivalent to compileJMU(className, fileName, "model", compileTo).

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.
compileTo Specify location of the compiled JMU. Directory will be created if it does not exist.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileJMU ( String  className,
String  fileName[] 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a model and creates a JMU.

Compiles a model (parsing, instantiating, flattening, code generation and binary file compilation) and packs the result in a JMU.

Convenience metod, equivalent to compileJMU(className, fileName, "model", ".").

Parameters:
className Name of model class in the model file to compile.
fileName Array of model file paths.

FClass org.jmodelica.modelica.compiler.ModelicaCompiler.compileModel ( String  name[],
String  cl 
) throws ModelicaClassNotFoundException, CompilerException, FileNotFoundException, IOException, beaver.Parser.Exception

Compiles a Modelica model.

A model file name and class must be provided. Prints an error and returns without completion if, for example, a file can not be found or if the parsing fails. Supports multiple model files.

Parameters:
name Array of names of the model files.
cl The name of the class in the model file to compile.
Exceptions:
beaver.Parser.Exception If there was an Beaver parsing exception.
CompilerException If errors have been found during the parsing, instantiation or flattening.
FileNotFoundException If the model file can not be found.
IOException If there was an error reading the model file. (Beaver exception.)
IOException If there was an error creating the .mof file.
ModelicaClassNotFoundException If the Modelica class to parse, instantiate or flatten is not found.

void org.jmodelica.modelica.compiler.ModelicaCompiler.compileModelFromCommandLine ( String[]  args,
Hashtable< String, String >  programarguments 
) [protected]

Compile model given in command line options and and print any error messages.

CGenerator org.jmodelica.modelica.compiler.ModelicaCompiler.createCGenerator ( FClass  fc  )  [protected]

Create a new CGenerator object.

Override for subclasses needing another subclass of CGenerator.

FClass org.jmodelica.modelica.compiler.ModelicaCompiler.createFClass ( InstClassDecl  icd  )  [protected]

Create a new FClass object.

Override for subclasses needing a subclass of FClass.

Parameters:
icd the instance class to be flattened, for use by subclasses

FClass org.jmodelica.modelica.compiler.ModelicaCompiler.createFlatTree ( InstClassDecl  icl,
String  flatFile 
)

Create a flat tree with an empty FClass and return the FClass.

Parameters:
icl the instance class to be flattened
flatFile path to the file to report any errors on

XMLGenerator org.jmodelica.modelica.compiler.ModelicaCompiler.createXMLGenerator ( FClass  fc  )  [protected]

Create a new XMLGenerator object.

Override for subclasses needing another subclass of XMLGenerator.

XMLValueGenerator org.jmodelica.modelica.compiler.ModelicaCompiler.createXMLValueGenerator ( FClass  fc  )  [protected]

Create a new XMLValueGenerator object.

Override for subclasses needing another subclass of XMLValueGenerator.

void org.jmodelica.modelica.compiler.ModelicaCompiler.defaultOptionsFMUCS (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.defaultOptionsFMUME (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.defaultOptionsFMUX (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.defaultTemplatePathsFMUCS (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.defaultTemplatePathsFMUME (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.defaultTemplatePathsFMUX (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.defaultTemplatePathsJMU (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.deleteOutDir (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.dumpMemoryUseFile ( ASTNode  root,
String  type,
String  name 
) throws FileNotFoundException [protected]

Save a dump of the memory use of an AST.

The dump will be saved in a file named "size_" + name + ".txt".

Parameters:
root the root of the AST to dump memory use for
type a short description of the tree to dump
name the variable part of the file name

void org.jmodelica.modelica.compiler.ModelicaCompiler.dumpMemoryUseFile ( ASTNode  root,
String  type 
) throws FileNotFoundException [protected]

Save a dump of the memory use of an AST.

The dump will be saved in a file named "size_" + type + ".txt".

Parameters:
root the root of the AST to dump memory use for
type a one-word description of the tree to dump

void org.jmodelica.modelica.compiler.ModelicaCompiler.dumpNodeCountFile ( String  file  )  throws FileNotFoundException [protected]

Save a dump of the number of AST nodes created of each type.

ASTNode must be changed to inherit ProfilingNode for node type counting to work.

Parameters:
file the name of the file to save dump to

static Hashtable<String, String> org.jmodelica.modelica.compiler.ModelicaCompiler.extractProgramArguments ( String[]  args,
int  pos 
) [static, protected]

FClass org.jmodelica.modelica.compiler.ModelicaCompiler.flattenModel ( InstClassDecl  icl  )  throws CompilerException, ModelicaClassNotFoundException, IOException

Computes the flattened model representation from a model instance.

Parameters:
icd A reference to the model instance node.
Returns:
FClass object representing the flattened model.
Exceptions:
CompilerException If errors have been found during the flattening.
IOException If there was an error creating the .mof file.
ModelicaClassNotFoundException If the Modelica class to flatten is not found.

void org.jmodelica.modelica.compiler.ModelicaCompiler.generateCode ( FClass  fc  )  throws FileNotFoundException

Generates XML and c code for a flattened model represented as an instance of FClass using template files.

The XML variables, XML values and c files are given the default names <modelname>.xml, <modelname>_values.xml and <modelname>.c respectively.

Parameters:
fc The FClass instance for which the code generation should be computed.
Exceptions:
FileNotFoundException If either of the three template files can not be found.

boolean org.jmodelica.modelica.compiler.ModelicaCompiler.getBooleanOption ( String  key  )  throws UnknownOptionException

static CCompilerDelegator org.jmodelica.modelica.compiler.ModelicaCompiler.getCCompiler (  )  [static]

String org.jmodelica.modelica.compiler.ModelicaCompiler.getCTemplate (  ) 

Returns the c template file path set for this compiler instance.

Returns:
Reference to the c template file path attribute.

String org.jmodelica.modelica.compiler.ModelicaCompiler.getCTemplatefile ( FClass  fc  )  [protected]

get the C template.

Parameters:
fc A reference to an FClass object. This is convenient in extensions of ModelicaCompiler that need to distinguish between different kinds of flattened classes.

DiagnosticsGenerator org.jmodelica.modelica.compiler.ModelicaCompiler.getDiagnosticsGenerator (  ) 

IErrorHandler org.jmodelica.modelica.compiler.ModelicaCompiler.getErrorHandler (  ) 

int org.jmodelica.modelica.compiler.ModelicaCompiler.getIntegerOption ( String  key  )  throws UnknownOptionException

static String org.jmodelica.modelica.compiler.ModelicaCompiler.getJModelicaHome (  )  [static]

static String org.jmodelica.modelica.compiler.ModelicaCompiler.getLogLevel ( String  logger  )  [static]

Returns the log level that is currently set.

Returns:
Log level setting for this class.

static String org.jmodelica.modelica.compiler.ModelicaCompiler.getLogLevel ( ModelicaLogger  logger  )  [static]

Returns the log level that is currently set.

Returns:
Log level setting for this class.

static String org.jmodelica.modelica.compiler.ModelicaCompiler.getLogLevel (  )  [static]

Returns the log level that is currently set.

Returns:
Log level setting for this class.

String org.jmodelica.modelica.compiler.ModelicaCompiler.getModelicapath (  ) 

Returns the modelicapath attribute set for this compiler instance.

Returns:
Reference to the modelicapath attribute.

String org.jmodelica.modelica.compiler.ModelicaCompiler.getOptionDescription ( String  key  )  throws UnknownOptionException

static String org.jmodelica.modelica.compiler.ModelicaCompiler.getPlatform (  )  [static]

Helper function.

Returns string describing the platform on which jmodelica is run.

Possible return values:: win32 win64 darwin32 darwin64 linux32 linux64

double org.jmodelica.modelica.compiler.ModelicaCompiler.getRealOption ( String  key  )  throws UnknownOptionException

String org.jmodelica.modelica.compiler.ModelicaCompiler.getStringOption ( String  key  )  throws UnknownOptionException

static File org.jmodelica.modelica.compiler.ModelicaCompiler.getTemplatesDir (  )  [static, protected]

String org.jmodelica.modelica.compiler.ModelicaCompiler.getUnitSuffix ( String  unitType  )  [protected]

Gets the file suffix for a given unit type.

Should be updated when new unit types are added.

String org.jmodelica.modelica.compiler.ModelicaCompiler.getXmlTpl ( FClass  fc  )  [protected]

get the XML template.

Parameters:
fc A reference to an FClass object. This is convenient in extensions of ModelicaCompiler that need to distinguish between different kinds of flattened classes.

String org.jmodelica.modelica.compiler.ModelicaCompiler.getXMLTpl (  ) 

Returns the XML model description template file path set for this compiler instance.

Returns:
Reference to the XML variables template file path attribute.

String org.jmodelica.modelica.compiler.ModelicaCompiler.getXmlValuesTpl ( FClass  fc  )  [protected]

get the XML values template.

Parameters:
fc A reference to an FClass object. This is convenient in extensions of ModelicaCompiler that need to distinguish between different kinds of flattened classes.

String org.jmodelica.modelica.compiler.ModelicaCompiler.getXMLValuesTpl (  ) 

Returns the XML values template file path set for this compiler instance.

Returns:
Reference to the XML values template file path attribute.

void org.jmodelica.modelica.compiler.ModelicaCompiler.handleCompilerProblems ( Collection< Problem problems  )  throws CompilerException [protected]

void org.jmodelica.modelica.compiler.ModelicaCompiler.handleException ( Throwable  e  )  [protected]

Log error message for exception and exit.

void org.jmodelica.modelica.compiler.ModelicaCompiler.handleException ( Throwable  e,
String  msg 
) [protected]

Log error message for exception and exit.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookCheckAbort (  )  [protected]

Throws a CompilationAbortedException if any hooks class signals an abort.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookCodeCompiled (  )  [protected]

Calls the hook to be called after the generated C code is compiled.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookCodeGenerated ( File  dir  )  [protected]

Calls the hook to be called after output code is generated.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookCodeGeneratorCreated ( AbstractGenerator  gen  )  [protected]

Calls the hook to be called after a code generator is created.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookFilesParsed ( SourceRoot  sr  )  [protected]

Calls the hook to be called after the supplied code files are parsed.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookFlatModelChecked ( FClass  fc  )  [protected]

Calls the hook to be called after error checks of the flat model are finished without errors.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookFmuPacked ( File  path  )  [protected]

Calls the hook to be called after the FMU is packed.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookModelFlattened ( FClass  fc  )  [protected]

Calls the hook to be called after the model is flattened.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookModelInstantiatied ( InstClassDecl  icd  )  [protected]

Calls the hook to be called after the error checks on the instantiated model are finished without errors.

void org.jmodelica.modelica.compiler.ModelicaCompiler.hookModelTransformed ( FClass  fc  )  [protected]

Calls the hook to be called after transformations are applied to the model.

InstClassDecl org.jmodelica.modelica.compiler.ModelicaCompiler.instantiateModel ( SourceRoot  sr,
String  cl 
) throws ModelicaClassNotFoundException, CompilerException

Computes a model instance tree from a source tree.

Some error checks such as type checking is performed during the computation.

Parameters:
sr The reference to the model source root.
cl The name of the class in the model file to compile.
Returns:
The instance node corresponding to the instantiated model.
Exceptions:
CompilerException If errors have been found during the instantiation.
ModelicaClassNotFoundException If the Modelica class to instantiate is not found.

void org.jmodelica.modelica.compiler.ModelicaCompiler.logCompilationInfo (  )  [protected]

Log debug information about compilation.

Should be called after compilation process ends.

static int org.jmodelica.modelica.compiler.ModelicaCompiler.loggedProcess ( String[]  cmd,
String[]  env,
File  workDir 
) [static]

Executes the given command as a separate process, writing any output to the logger.

static void org.jmodelica.modelica.compiler.ModelicaCompiler.main ( String[]  args  )  [static]

void org.jmodelica.modelica.compiler.ModelicaCompiler.noteUsedMemory (  )  [protected]

Saves away the current amount of memory used.

void org.jmodelica.modelica.compiler.ModelicaCompiler.packUnit ( String  className,
String  path,
String  unitType 
) [protected]

Packs either a JMU or FMU (helper function for compileUnit).

Parameters:
className Name of model class that was compiled (will determine file names).
path Location on file system where the packed file should be saved (created if does not exist).
unitType "JMU" or "FMU".

void org.jmodelica.modelica.compiler.ModelicaCompiler.parseFiles ( String[]  files  )  [protected]

SourceRoot org.jmodelica.modelica.compiler.ModelicaCompiler.parseModel ( String  names[]  )  throws FileNotFoundException, IOException, beaver.Parser.Exception, CompilerException

Parses a set of files and returns a reference to the root of a source tree where the content of all files is contained.

Each file is parsed using the parseModel method.

Parameters:
names An array of file names.
Returns:
The root of the source tree.
Exceptions:
beaver.Parser.Exception If there was a Beaver parsing exception.
CompilerException If errors have been found during the parsing.
FileNotFoundException If the model file could not be found.
IOException If there was an error reading the model file. (Beaver exception.)

void org.jmodelica.modelica.compiler.ModelicaCompiler.recursiveDelete ( File  dir  )  [protected]

void org.jmodelica.modelica.compiler.ModelicaCompiler.removeCompilationHooks ( CompilationHooks  hooks  ) 

static void org.jmodelica.modelica.compiler.ModelicaCompiler.removeGlobalCompilationHooks ( CompilationHooks  hooks  )  [static]

void org.jmodelica.modelica.compiler.ModelicaCompiler.resetCompilationInfo (  )  [protected]

Initilize vars gathering debug information about compilation.

Should be called before compilation process begins.

void org.jmodelica.modelica.compiler.ModelicaCompiler.setArguments ( String  compilerName,
String[]  args,
Hashtable< String, String >  programarguments 
) throws JModelicaHomeNotFoundException [protected]

void org.jmodelica.modelica.compiler.ModelicaCompiler.setBooleanOption ( String  key,
boolean  value 
) throws UnknownOptionException

static void org.jmodelica.modelica.compiler.ModelicaCompiler.setCCompiler ( CCompilerDelegator  cCompiler  )  [static]

void org.jmodelica.modelica.compiler.ModelicaCompiler.setCTemplate ( String  template  ) 

Set the c template file path attribute.

Parameters:
template The new c template file path.

static void org.jmodelica.modelica.compiler.ModelicaCompiler.setDefaultLogger (  )  [static]

Use the default logger.

Retains the current log level.

void org.jmodelica.modelica.compiler.ModelicaCompiler.setDiagnosticsGenerator ( DiagnosticsGenerator  diagGenerator  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.setErrorHandler ( IErrorHandler  eh  ) 

Set the error handler to use for collection errors.

Passing null resets to default.

void org.jmodelica.modelica.compiler.ModelicaCompiler.setIntegerOption ( String  key,
int  value 
) throws UnknownOptionException

static void org.jmodelica.modelica.compiler.ModelicaCompiler.setJModelicaHome ( String  jmHome  )  [static]

static void org.jmodelica.modelica.compiler.ModelicaCompiler.setLogger ( ModelicaLogger  log  )  [static]

Use the specified logger.

Retains the current log level.

static void org.jmodelica.modelica.compiler.ModelicaCompiler.setLogLevel ( String  logger,
String  level 
) [static]

Sets logging to the level specified.

Valid values are: ModelicaCompiler.DEBUG, ModelicaCompiler.INFO, ModelicaCompiler.WARNING or ModelicaCompiler.ERROR

Default log level setting is ERROR. Messages will be printed to the standard out.

Parameters:
level The level of logging to use as of now.

static void org.jmodelica.modelica.compiler.ModelicaCompiler.setLogLevel ( ModelicaLogger  logger,
String  level 
) [static]

Sets logging to the level specified.

Valid values are: ModelicaCompiler.DEBUG, ModelicaCompiler.INFO, ModelicaCompiler.WARNING or ModelicaCompiler.ERROR

Default log level setting is ERROR. Messages will be printed to the standard out.

Parameters:
level The level of logging to use as of now.

static void org.jmodelica.modelica.compiler.ModelicaCompiler.setLogLevel ( String  level  )  [static]

Sets logging to the level specified.

Valid values are: ModelicaCompiler.DEBUG, ModelicaCompiler.INFO, ModelicaCompiler.WARNING or ModelicaCompiler.ERROR

Default log level setting is ERROR. Messages will be printed to the standard out.

Parameters:
level The level of logging to use as of now.

void org.jmodelica.modelica.compiler.ModelicaCompiler.setModelicapath ( String  path  ) 

Set the modelicapath attribute.

Parameters:
path The new modelicapath.

void org.jmodelica.modelica.compiler.ModelicaCompiler.setOutDir ( File  out  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.setRandomOutDir (  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.setRealOption ( String  key,
double  value 
) throws UnknownOptionException

static void org.jmodelica.modelica.compiler.ModelicaCompiler.setStreamLogger ( OutputStream  stream  )  [static]

Create and use a logger that logs to a stream.

Retains the current log level.

void org.jmodelica.modelica.compiler.ModelicaCompiler.setStringOption ( String  key,
String  value 
) throws UnknownOptionException

void org.jmodelica.modelica.compiler.ModelicaCompiler.setSubOutDir ( String  out  ) 

void org.jmodelica.modelica.compiler.ModelicaCompiler.setTempFileDir ( File  temp  ) 

Sets the directory new temporary files are created in.

The default value is null, and is interpreted as the current working directory.

void org.jmodelica.modelica.compiler.ModelicaCompiler.setXMLTpl ( String  template  ) 

Set the XML model description template file path attribute.

Parameters:
template The new XML variables template file path.

void org.jmodelica.modelica.compiler.ModelicaCompiler.setXMLValuesTpl ( String  template  ) 

Set the XML values template file path attribute.

Parameters:
template The new XML values template file path.

String [] org.jmodelica.modelica.compiler.ModelicaCompiler.splitFiles ( String  arg  )  [protected]

Split the argument containing the list of files into an array of filenames.

void org.jmodelica.modelica.compiler.ModelicaCompiler.zipDir ( File  dir,
ZipOutputStream  out,
File  zipDir 
) [protected]

Write all files in a directory and its subdirectories to a zip stream.

Parameters:
dir directory to zip
out zip stream to write to
zipDir directory within the zip file to write to, or null for the root

void org.jmodelica.modelica.compiler.ModelicaCompiler.zipDir ( File  dir,
ZipOutputStream  out 
) [protected]

Write all files in a directory and its subdirectories to a zip stream.

Parameters:
dir directory to zip
out zip stream to write to


Member Data Documentation

final String org.jmodelica.modelica.compiler.ModelicaCompiler.CONSOLE_LOG_NAME = ModelicaCompiler.class.getName() + ".console" [static, protected]

String org.jmodelica.modelica.compiler.ModelicaCompiler.jmodelicaHome = System.getenv("JMODELICA_HOME") [static, protected]

final HashMap<String, Level> org.jmodelica.modelica.compiler.ModelicaCompiler.levels = new HashMap<String, Level>() [static, protected]

ModelicaLogger org.jmodelica.modelica.compiler.ModelicaCompiler.log = ModelicaLoggers.getConsoleLogger(CONSOLE_LOG_NAME) [static, protected]

final String org.jmodelica.modelica.compiler.ModelicaCompiler.STREAM_LOG_NAME = ModelicaCompiler.class.getName() + ".stream" [static, protected]


The documentation for this class was generated from the following file:

Generated on Fri Oct 7 14:51:01 2011 for JModelica.org by  doxygen 1.5.8