org.ptolemy.fmi
Class FMUFile

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

public class FMUFile
extends java.lang.Object

Parse a Functional Mock-up Interface (FMI) 1.0 Functional Mock-up Unit (FMU) file and create a FMIModelDescription for later use.

The parseFMUFile() method in this class is the primary entry point into this package.

FMI documentation may be found at http://www.modelisar.com/fmi.html.

Version:
$Id: FMUFile.java 66034 2013-04-08 17:31:11Z cxh $
Author:
Christopher Brooks
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
FMUFile()
           
 
Method Summary
private static boolean _is32Bit()
          Return true if this is a 32bit JVM.
private static java.util.List<java.io.File> _unzip(java.lang.String zipFileName)
          Unzip a file into a temporary directory.
static java.lang.String fmuSharedLibrary(FMIModelDescription fmiModelDescription)
          Return the name of the shared library from a .fmu file.
static FMIModelDescription parseFMUFile(java.lang.String fmuFileName)
          Read in a .fmu file and parse the modelDescription.xml file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FMUFile

public FMUFile()
Method Detail

fmuSharedLibrary

public static java.lang.String fmuSharedLibrary(FMIModelDescription fmiModelDescription)
                                         throws java.io.IOException
Return the name of the shared library from a .fmu file.

Parameters:
fmiModelDescription - The representation of the model that was read in by {#parseFMUFile}.
Returns:
The canonical path of the shared library.
Throws:
java.io.IOException - If thrown while determining the canonical path of the library.

parseFMUFile

public static FMIModelDescription parseFMUFile(java.lang.String fmuFileName)
                                        throws java.io.IOException
Read in a .fmu file and parse the modelDescription.xml file. Note that this does not load the shared library. That is loaded upon the first attempt to use the procedures in it. This is important because we want to be able to view a model that references an FMU even if the FMU does not support the current platform.

Parameters:
fmuFileName - the .fmu file
Returns:
An object that represents the structure of the modelDescriptionFile.xml file.
Throws:
java.io.IOException - If the file cannot be unzipped or the modelDescription.xml file contained by the fmuFileName zip file cannot be parsed.

_is32Bit

private static boolean _is32Bit()
Return true if this is a 32bit JVM.

Returns:
true if this is a 32bit JVM.

_unzip

private static java.util.List<java.io.File> _unzip(java.lang.String zipFileName)
                                            throws java.io.IOException
Unzip a file into a temporary directory. Based on http://java.sun.com/developer/technicalArticles/Programming/compression/.

Parameters:
zipFileName - The file to be unzipped.
Returns:
the list of files that were extracted.
Throws:
java.io.IOException - if the file cannot be opened, if there are problems reading the zip file or if there are problems creating the files or directories.