org.ptolemy.fmi
Class FMUBuilder

java.lang.Object
  extended by org.ptolemy.fmi.FMUBuilder

public class FMUBuilder
extends java.lang.Object

Build a FMU shared object.

Version:
$Id: FMUBuilder.java 66133 2013-04-25 21:59:22Z cxh $
Author:
Christopher Brooks
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Nested Class Summary
private static class FMUBuilder._StreamReaderThread
          Private class that reads a stream in a thread and updates the the FMUBuilder.
 
Field Summary
private  boolean _appendToStderrAndStdout
          If true, append to stderr and stdout as the commands are executed.
private static java.lang.String _eol
          End of line character.
 java.lang.StringBuffer buffer
          The StringBuffer to which the output is appended.
 
Constructor Summary
FMUBuilder()
          Create a FMUBuilder.
FMUBuilder(boolean appendToStderrAndStdout)
          Create a FMUBuilder and optionally append to stderr and stdout as the commands are executed.
 
Method Summary
private  void _appendToBuffer(java.lang.String text)
          Append to the internal StringBuffer.
 boolean build(java.io.File sharedLibraryFile)
          Build the specified shared library inside the FMU.
 void stderr(java.lang.String text)
          Append the text message to the StringBuffer.
 void stdout(java.lang.String text)
          Append the text message to the StringBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

public java.lang.StringBuffer buffer
The StringBuffer to which the output is appended. This variable is public so that callers can clear the buffer as necessary.


_appendToStderrAndStdout

private boolean _appendToStderrAndStdout
If true, append to stderr and stdout as the commands are executed.


_eol

private static java.lang.String _eol
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

FMUBuilder

public FMUBuilder()
Create a FMUBuilder. As the commands are executed, output is appended to the StringBuffer - no output will appear on stderr and stdout.


FMUBuilder

public FMUBuilder(boolean appendToStderrAndStdout)
Create a FMUBuilder and optionally append to stderr and stdout as the commands are executed.

Parameters:
appendToStderrAndStdout - If true, then as the commands are executed, the output is append to stderr and stdout.
Method Detail

build

public boolean build(java.io.File sharedLibraryFile)
              throws java.io.IOException
Build the specified shared library inside the FMU.

A typicaly value is /tmp/FMUFile12345/binaries/linux64/stepCounter.dylib.

Typically the sharedLibrary is inside a temporary directory that was created when the fmu file was unzipped. The directory names the platform for which the binary is to be built. This directory resides inside a directory named binaries/. Adjacent to the binaries/ directory is the sources/ directory.

Parameters:
sharedLibraryFile - The shared library that should be built.
Returns:
true if the sharedLibraryFile was built.
Throws:
java.io.IOException - If the FMU contains a makefile but there was a problem building the shared library.

stderr

public void stderr(java.lang.String text)
Append the text message to the StringBuffer. The output automatically gets a trailing end of line character(s) appended. Optionally, the text also appears on stderr

Parameters:
text - The text to append.

stdout

public void stdout(java.lang.String text)
Append the text message to the StringBuffer. The output automatically gets end of line character(s) appended. Optionally, the text also appears on stdout.

Parameters:
text - The text to append.

_appendToBuffer

private void _appendToBuffer(java.lang.String text)
Append to the internal StringBuffer.

Parameters:
text - The text to append. If the text does not end with an end of line character(s), then _eol is appended.