org.slf4j.api,
gnu.trove3;bundle-version="3.0.3"
Export-Package: org.simantics.fmil.core
+Require-Capability: org.simantics.fmil.simulator.implementation.capability;filter:="(type=fmi)";effective:="active"
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
+import java.net.URL;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.file.Paths;
import java.util.UUID;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.osgi.framework.Bundle;
-import org.simantics.fmil.core.ExecEnvironment.ARCHType;
import org.simantics.fmil.core.ExecEnvironment.OSType;
import org.simantics.utils.FileUtils;
import org.slf4j.Logger;
*/
private static int OK = 0;
private static int ERROR = 1;
- private static String UNSATISFIED_LINK = "Method not found. DLL might not be loaded properly.";
- public static final String TEMP_FMU_DIRECTORY_NAME = "fmil";
- public static String TEMP_FMU_COMMON_DIRECTORY;
+ private static String UNSATISFIED_LINK = "Method not found. DLL might not be loaded properly.";
+ public static final String TEMP_FMU_DIRECTORY_NAME = "fmil";
+ public static String TEMP_FMU_COMMON_DIRECTORY;
public static String LOCK_FILE_NAME = "fmil.lock";
public static Object syncObject = new Object();
* Static: load native libraries required for the FMU simulation to work.
*/
static {
-
+
File[] libraries = new File[2];
- Bundle bundle = null;
-
ExecEnvironment env = ExecEnvironment.calculate();
- if (env.os == OSType.WINDOWS) {
- if (env.arch == ARCHType.X86) {
- bundle = Platform.getBundle("org.simantics.fmil.win32");
- } else if (env.arch == ARCHType.X86_64) {
- bundle = Platform.getBundle("org.simantics.fmil.win64");
- }
- }
-
- if (bundle != null) {
- try{
- String root = FileLocator.getBundleFile(bundle).getAbsolutePath();
-// if (env.arch == ARCHType.X86_64) {
-// File newFIle = new File(root, "libraries/libexpat.dll");
-// System.load(newFIle.getAbsolutePath());
-// }
-// libraries[0] = new File(root, "libraries/zlibwapi.dll");
-// libraries[1] = new File(root, "libraries/miniunz.dll");
- libraries[0] = new File(root, "libraries/fmilib_shared.dll");
- libraries[1] = new File(root, "libraries/FMUSimulator.dll");
- }
- catch (Exception e) {
- e.printStackTrace();
+
+ try {
+ URL sharedFMILIBUrl = null;
+ URL simulatorFMIUrl = null;
+ Bundle b = Platform.getBundle("org.simantics.fmil.core");
+
+ if (env.os == OSType.WINDOWS) {
+ sharedFMILIBUrl = FileLocator.find(b, new Path("libraries/fmilib_shared.dll"), null);
+ simulatorFMIUrl = FileLocator.find(b, new Path("libraries/FMUSimulator.dll"), null);
+ } else if(env.os == OSType.LINUX) {
+ sharedFMILIBUrl = FileLocator.find(b, new Path("libraries/libfmilib_shared.so"), null);
+ simulatorFMIUrl = FileLocator.find(b, new Path("libraries/FMUSimulator.so"), null);
}
+
+ libraries[0] = new File(FileLocator.toFileURL(sharedFMILIBUrl).getPath());
+ libraries[1] = new File(FileLocator.toFileURL(simulatorFMIUrl).getPath());
+ } catch (Exception e) {
+ LOGGER.error("Failed to resolve native FMU simulation library for execution environment {}.{}", env.os, env.arch, e);
}
for(File library : libraries) {
synchronized(syncObject) {
try {
- // TODO: printtaa id ja name, jotta saadaan virheessä kiinni
+ // TODO: printtaa id ja name, jotta saadaan virheessä kiinni
double result = getRealValue_(getModelIDNew(), variableMap.get(name));
System.err.println("getRealValue " + name + " = " + result);
return result;
Bundle-SymbolicName: org.simantics.fmil.linux64
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Semantum Oy
-Fragment-Host: org.simantics.fmil.core;bundle-version="1.0.0"
+Fragment-Host: org.simantics.fmil.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-PlatformFilter: (& (osgi.os=linux) (osgi.arch=x86_64))
Eclipse-BundleShape: dir
+Provide-Capability: org.simantics.fmil.simulator.implementation.capability;type:"fmi";effective:="active"
--- /dev/null
+Build FMI Library for Linux:
+Download 2.0.3-src.zip from here http://www.jmodelica.org/FMILibrary
+Derived guide: http://www.jmodelica.org/page/27916
+
+1) Download cmake (apt-get install -y cmake)
+2) Unzip the source file to a source directory (/path/to/source)
+3) Make an empty build directory (mkdir /path/to/build)
+4) Change directory to the build directory
+5) cmake /path/to/source
+6) make
+7) make install test
+ 7.1) If tests fail, look at the error and fix it
+ 7.2) Otherwise move on to step 8.
+8) Under your build directory should be five files:
+ - libfmu1_dll_me.so
+ - libfmu2_dll_me.so
+ - libfmu1_dll_cs.so
+ - libfmu2_dll_cs.so
+ - libfmilib_shared.so
+9) Copy the above files to where you want them (i.e. under org.simantics.fmil.linux64 libraries directory)
+10) Repeat steps 3 to 9 for "debug" shared objects, but replace the following steps:
+ "5") cmake -DFMILIB_ENABLE_LOG_LEVEL_DEBUG=ON /path/to/source (note the added param)
+ "9") Copy the files to libraries/debug directory (instead of libraries)
\ No newline at end of file
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <groupId>org.simantics.fmi</groupId>\r
- <artifactId>org.simantics.fmil.parent</artifactId>\r
- <version>0.0.1-SNAPSHOT</version>\r
- <packaging>pom</packaging>\r
-\r
- <!-- common settings for all modules -->\r
- <properties>\r
- <branch-spec>master</branch-spec>\r
- <simantics-download-site>http://www.simantics.org/download</simantics-download-site>\r
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
- <tycho-version>1.0.0</tycho-version>\r
- </properties>\r
-\r
- <repositories>\r
- <!-- configure p2 repository to resolve against -->\r
- <repository>\r
- <id>simantics-sdk</id>\r
- <layout>p2</layout>\r
- <url>${simantics-download-site}/${branch-spec}/sdk</url>\r
- </repository>\r
- </repositories>\r
-\r
- <build>\r
- <plugins>\r
- <plugin>\r
- <groupId>org.eclipse.tycho</groupId>\r
- <artifactId>tycho-compiler-plugin</artifactId>\r
- <version>${tycho-version}</version>\r
- <configuration>\r
- <compilerArgument>-err:-forbidden</compilerArgument>\r
- </configuration>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.eclipse.tycho</groupId>\r
- <artifactId>tycho-maven-plugin</artifactId>\r
- <version>${tycho-version}</version>\r
- <extensions>true</extensions>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.eclipse.tycho</groupId>\r
- <artifactId>tycho-versions-plugin</artifactId>\r
- <version>${tycho-version}</version>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.eclipse.tycho</groupId>\r
- <artifactId>target-platform-configuration</artifactId>\r
- <version>${tycho-version}</version>\r
- <configuration>\r
- <ignoreTychoRepositories>true</ignoreTychoRepositories>\r
- <resolver>p2</resolver>\r
- <environments>\r
- <environment>\r
- <os>win32</os>\r
- <ws>win32</ws>\r
- <arch>x86</arch>\r
- </environment>\r
- <environment>\r
- <os>win32</os>\r
- <ws>win32</ws>\r
- <arch>x86_64</arch>\r
- </environment>\r
- </environments>\r
- </configuration>\r
- </plugin>\r
- </plugins>\r
- </build>\r
-\r
- <modules>\r
- <module>../org.simantics.fmil.core</module>\r
- <module>../org.simantics.fmil.feature</module>\r
- <module>../org.simantics.fmil.linux64</module>\r
- <module>../org.simantics.fmil.win32</module>\r
- <module>../org.simantics.fmil.win64</module>\r
- <module>../org.simantics.fmil.repository</module>\r
- </modules>\r
-</project>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.simantics.fmi</groupId>
+ <artifactId>org.simantics.fmil.parent</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <!-- common settings for all modules -->
+ <properties>
+ <branch-spec>master</branch-spec>
+ <simantics-download-site>http://www.simantics.org/download</simantics-download-site>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <tycho-version>1.1.0</tycho-version>
+ </properties>
+
+ <repositories>
+ <!-- configure p2 repository to resolve against -->
+ <repository>
+ <id>simantics-sdk</id>
+ <layout>p2</layout>
+ <url>${simantics-download-site}/${branch-spec}/sdk</url>
+ </repository>
+ </repositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-compiler-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <compilerArgument>-err:-forbidden</compilerArgument>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-versions-plugin</artifactId>
+ <version>${tycho-version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <ignoreTychoRepositories>true</ignoreTychoRepositories>
+ <resolver>p2</resolver>
+ <environments>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86_64</arch>
+ </environment>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
+ <arch>x86_64</arch>
+ </environment>
+ </environments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>../org.simantics.fmil.core</module>
+ <module>../org.simantics.fmil.feature</module>
+ <module>../org.simantics.fmil.linux64</module>
+ <module>../org.simantics.fmil.win32</module>
+ <module>../org.simantics.fmil.win64</module>
+ <module>../org.simantics.fmil.repository</module>
+ </modules>
+</project>
Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86))
Bundle-Vendor: Semantum Oy
Eclipse-BundleShape: dir
+Provide-Capability: org.simantics.fmil.simulator.implementation.capability;type:"fmi";effective:="active"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86_64))
Eclipse-BundleShape: dir
+Provide-Capability: org.simantics.fmil.simulator.implementation.capability;type:"fmi";effective:="active"