]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #3511
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 20 Nov 2012 11:07:08 +0000 (11:07 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 20 Nov 2012 11:07:08 +0000 (11:07 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26373 ac1ea38d-2e2b-0410-8846-a27921b304fc

17 files changed:
org.simantics.fmu.me.win32/libraries/FMUSimulator.dll
org.simantics.fmu/FMUSolution/FMUSimulator/include/org_simantics_fmu_FMUControlJNI.h
org.simantics.fmu/FMUSolution/FMUSimulator/src/fmu_control.cpp
org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java
org.simantics.fmu/src/org_simantics_fmu_FMUControlJNI.h
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SimulationResult.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/CloudFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/StockFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ValveFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/menu/FontContextMenuContribution.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ValidationUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java

index b07fd46a1771ab476f24602b29e4b50003811a18..52c78ab79ca12790bf8138918d32728dd92a79d4 100644 (file)
Binary files a/org.simantics.fmu.me.win32/libraries/FMUSimulator.dll and b/org.simantics.fmu.me.win32/libraries/FMUSimulator.dll differ
index 5f0cf1f9af5caecd984640729b598e18f571f038..9f2697b477a1d22058c6f608cdb912a6df3965e0 100644 (file)
@@ -63,6 +63,14 @@ JNIEXPORT jint JNICALL Java_org_simantics_fmu_FMUControlJNI_setIntegerValue_1
 JNIEXPORT jint JNICALL Java_org_simantics_fmu_FMUControlJNI_setBooleanValue_1\r
   (JNIEnv *, jobject, jstring, jstring, jboolean);\r
 \r
+/*\r
+ * Class:     org_simantics_fmu_FMUControlJNI\r
+ * Method:    setTime_\r
+ * Signature: (Ljava/lang/String;D)I\r
+ */\r
+JNIEXPORT jint JNICALL Java_org_simantics_fmu_FMUControlJNI_setTime_1\r
+  (JNIEnv *, jobject, jstring, jdouble);\r
+\r
 /*\r
  * Class:     org_simantics_fmu_FMUControlJNI\r
  * Method:    simulateStep_\r
index c5eb62aae95b7e2f9e06864b23e9742341daf84b..f1384510f3e4966bda5345b9c8c72b968c9fffbd 100644 (file)
@@ -27,6 +27,11 @@ extern "C" {
        #include "sim_support.h"\r
 }\r
 \r
+#define PRINT(fmt,args) { FILE *fp = fopen("R:\\Simantics\\Sysdyn\\log.txt", "ab"); fprintf(fp, fmt, args); fclose(fp); }\r
+\r
+#include <direct.h>\r
+#define GetCurrentDir _getcwd\r
+\r
 using namespace std;\r
 \r
 \r
@@ -529,6 +534,25 @@ JNIEXPORT jint JNICALL Java_org_simantics_fmu_FMUControlJNI_initializeSimulation
        }\r
 }\r
 \r
+JNIEXPORT jint JNICALL Java_org_simantics_fmu_FMUControlJNI_setTime_1\r
+  (JNIEnv *env, jobject obj, jstring id, jdouble time) {\r
+\r
+       const char *fmuId = env->GetStringUTFChars(id, 0);\r
+       if(exists(fmuId)) {\r
+               FMUControlStruct& fmuStruct = fmus[fmuId];\r
+               env->ReleaseStringUTFChars(id, fmuId);\r
+\r
+               FMU& fmu = fmuStruct.fmu;\r
+\r
+               fmu.setTime(fmuStruct.c, time);\r
+               return 1;\r
+       } else {\r
+               string message = fmuId;\r
+               env->ReleaseStringUTFChars(id, fmuId);\r
+               return throwException(env, "setTime: Model id " + message + " not found");\r
+       }\r
+}\r
+\r
 jobjectArray filterVariables(JNIEnv *env, jobject obj, jstring id, string regexp) {\r
        const char *fmuId = env->GetStringUTFChars(id, 0);\r
        if(exists(fmuId)) {\r
@@ -739,9 +763,11 @@ JNIEXPORT jdouble JNICALL Java_org_simantics_fmu_FMUControlJNI_getRealValue_1
 \r
                if(referenceExists(fmuStruct, name)) {\r
                        fmiValueReference vr = getReference(fmuStruct, name);\r
+\r
                        double real;\r
                        fmuStruct.fmu.getReal(fmuStruct.c, &vr, 1, &real);\r
                        env->ReleaseStringUTFChars(variable, name);\r
+\r
                        return real;\r
 \r
                } else {\r
index 1a778c3c05f3a9bded0968c8829f74e6ad1593b4..f49c26272511b845d9a0c8b4116295c866a29080 100644 (file)
@@ -26,6 +26,8 @@ public class FMUControlJNI {
     public static String    TEMP_FMU_COMMON_DIRECTORY;  \r
     public static String    LOCK_FILE_NAME      = "fmu.lock";\r
 \r
+    public static Object syncObject = new Object();\r
+\r
     /**\r
      * Static: load native libraries required for the FMU simulation to work.\r
      */\r
@@ -106,11 +108,11 @@ public class FMUControlJNI {
 \r
         TEMP_FOLDER_1 = fmuDir.toString();\r
         TEMP_FOLDER_2 = fmuDir.toString() + "_2";\r
-        \r
+\r
         // Lock fmu directory in temp directory\r
         lockFMUDirectory();\r
     }\r
-    \r
+\r
     public String getModelID() {\r
         return dirName;\r
     }\r
@@ -130,40 +132,43 @@ public class FMUControlJNI {
     private boolean fmuLoaded = false;\r
     public void loadFMUFile(String path) throws FMUJNIException {\r
 \r
-        if(fmuN % 2 == 0) {\r
-            fmuDir = TEMP_FOLDER_1;\r
-            fmuN++;\r
-        } else {\r
-            fmuDir = TEMP_FOLDER_2;\r
-            fmuN = 0;\r
-        }\r
+        synchronized(syncObject) {\r
 \r
-        File tempDir = new File(fmuDir);\r
-        if(tempDir.isDirectory()) {\r
-            try {\r
-                FileUtils.deleteAll(tempDir);\r
-            } catch (IOException e) {\r
-                throw new FMUJNIException("Could not create temp folder for fmu");\r
+            if(fmuN % 2 == 0) {\r
+                fmuDir = TEMP_FOLDER_1;\r
+                fmuN++;\r
+            } else {\r
+                fmuDir = TEMP_FOLDER_2;\r
+                fmuN = 0;\r
             }\r
-            tempDir.mkdir();\r
-        } else {\r
-            tempDir.mkdir();\r
-        }\r
 \r
+            File tempDir = new File(fmuDir);\r
+            if(tempDir.isDirectory()) {\r
+                try {\r
+                    FileUtils.deleteAll(tempDir);\r
+                } catch (IOException e) {\r
+                    throw new FMUJNIException("Could not create temp folder for fmu");\r
+                }\r
+                tempDir.mkdir();\r
+            } else {\r
+                tempDir.mkdir();\r
+            }\r
 \r
-        try {\r
-            String tmpPath = tempDir.getAbsolutePath();\r
-            if(!tmpPath.endsWith("\\"))\r
-                tmpPath = tmpPath + "\\";\r
-            int ret = loadFMUFile_(getModelID(), path, tmpPath);\r
-            if(ret == ERROR)\r
-                throw new FMUJNIException(getLastErrorMessage());\r
-            \r
-            fmuLoaded = true;\r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+\r
+            try {\r
+                String tmpPath = tempDir.getAbsolutePath();\r
+                if(!tmpPath.endsWith("\\"))\r
+                    tmpPath = tmpPath + "\\";\r
+                int ret = loadFMUFile_(getModelID(), path, tmpPath);\r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
+\r
+                fmuLoaded = true;\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -176,16 +181,19 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public void setStepLength(double step) throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            int ret = setStepLength_(getModelID(), step);\r
-            if(ret == ERROR)\r
-                throw new FMUJNIException(getLastErrorMessage());\r
+            try {\r
+\r
+                int ret = setStepLength_(getModelID(), step);\r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -198,16 +206,19 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public void initializeSimulation() throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            int ret = initializeSimulation_(getModelID()); \r
-            if(ret == ERROR)\r
-                throw new FMUJNIException(getLastErrorMessage());\r
+            try {\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+                int ret = initializeSimulation_(getModelID()); \r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -221,16 +232,19 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public void subscribe(String[] variables) throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
 \r
-            int ret = subscribe_(getModelID(), variables, variables.length); \r
-            if(ret == ERROR)\r
-                throw new FMUJNIException(getLastErrorMessage());\r
+                int ret = subscribe_(getModelID(), variables, variables.length); \r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -246,16 +260,19 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public void setRealValue(String name, double value) throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            int ret = setRealValue_(getModelID(), name, value); \r
-            if(ret == ERROR)\r
-                throw new FMUJNIException(getLastErrorMessage());\r
+            try {\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+                int ret = setRealValue_(getModelID(), name, value); \r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -270,16 +287,19 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public void setIntegerValue(String name, int value) throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            int ret = setIntegerValue_(getModelID(), name, value); \r
-            if(ret == ERROR)\r
-                throw new FMUJNIException(getLastErrorMessage());\r
+            try {\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+                int ret = setIntegerValue_(getModelID(), name, value); \r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
     private native int setIntegerValue_(String id, String name, int value);\r
@@ -293,20 +313,40 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public void setBooleanValue(String name, boolean value) throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            int ret = setBooleanValue_(getModelID(), name, value); \r
-            if(ret == ERROR)\r
-                throw new FMUJNIException(getLastErrorMessage());\r
+            try {\r
+\r
+                int ret = setBooleanValue_(getModelID(), name, value); \r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
     private native int setBooleanValue_(String id, String name, boolean value);\r
 \r
+    public void setTime(double time) throws FMUJNIException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+                int ret = setTime_(getModelID(), time); \r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
+        }\r
+    }\r
+    private native int setTime_(String id, double time);\r
 \r
     /**\r
      * Simulate one step forward. The step length can be set with\r
@@ -315,16 +355,19 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public void simulateStep() throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            int ret = simulateStep_(getModelID()); \r
-            if(ret == ERROR)\r
-                throw new FMUJNIException(getLastErrorMessage());\r
+            try {\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+                int ret = simulateStep_(getModelID()); \r
+                if(ret == ERROR)\r
+                    throw new FMUJNIException(getLastErrorMessage());\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
     private native int simulateStep_(String id);\r
@@ -337,14 +380,17 @@ public class FMUControlJNI {
      * @return\r
      */\r
     public double[] getSubscribedResults(double[] results) throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            return getSubscribedResults_(getModelID(), results);\r
+            try {\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+                return getSubscribedResults_(getModelID(), results);\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -360,20 +406,23 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public void unloadFMU() throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            unlockFMUDirectory();\r
-            if(fmuLoaded) {\r
-                int ret = unloadFMU_(getModelID()); \r
-                if(ret == ERROR)\r
-                    throw new FMUJNIException(getLastErrorMessage());\r
-            }\r
-            removeFMUDirectoryContents();\r
+            try {\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+                unlockFMUDirectory();\r
+                if(fmuLoaded) {\r
+                    int ret = unloadFMU_(getModelID()); \r
+                    if(ret == ERROR)\r
+                        throw new FMUJNIException(getLastErrorMessage());\r
+                }\r
+                removeFMUDirectoryContents();\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
     private native int unloadFMU_(String id);\r
@@ -383,14 +432,17 @@ public class FMUControlJNI {
      * @return current simulation time\r
      */\r
     public double getTime() throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
 \r
-            return getTime_(getModelID());\r
+                return getTime_(getModelID());\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -401,19 +453,22 @@ public class FMUControlJNI {
      * @return all variables in a loaded model\r
      */\r
     public String[] getAllVariables() throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
 \r
-            return getAllVariables_(getModelID());\r
+                return getAllVariables_(getModelID());\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
     private native String[] getAllVariables_(String id);\r
-    \r
+\r
     /**\r
      * Get all variables from model that match the filter (and time variable)\r
      * \r
@@ -421,18 +476,20 @@ public class FMUControlJNI {
      * @return An array of variable names that match regexp filter (and time-variable)\r
      * @throws FMUJNIException\r
      */\r
-    public String[] filterVariables(String regexp) throws FMUJNIException {\r
-        try {\r
+    public String[] filterVariables(String regexp) throws FMUJNIException {       \r
+        synchronized(syncObject) {\r
+            try {\r
 \r
-            return filterVariables_(getModelID(), regexp + "|time");\r
+                return filterVariables_(getModelID(), regexp + "|time");\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
-    \r
+\r
     private native String[] filterVariables_(String id, String regexp);\r
 \r
     /**\r
@@ -440,14 +497,17 @@ public class FMUControlJNI {
      * @return Last error message\r
      */\r
     public String getLastErrorMessage() throws FMUJNIException {\r
-        try {\r
+        synchronized(syncObject) {\r
 \r
-            return getLastErrorMessage_(getModelID());\r
+            try {\r
 \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+                return getLastErrorMessage_(getModelID());\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -460,12 +520,16 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public double getRealValue(String name) throws FMUJNIException {\r
-        try {\r
-            return getRealValue_(getModelID(), name); \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+                // TODO: printtaa id ja name, jotta saadaan virheessä kiinni \r
+                return getRealValue_(getModelID(), name); \r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -478,17 +542,20 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public String getStringValue(String name) throws FMUJNIException {\r
-        try {\r
-            return getStringValue_(getModelID(), name); \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+                return getStringValue_(getModelID(), name); \r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
     private native String getStringValue_(String id, String name);\r
-    \r
+\r
     /**\r
      * Get an integer value for variable\r
      * @param name Name of the variable\r
@@ -496,17 +563,20 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public int getIntegerValue(String name) throws FMUJNIException {\r
-        try {\r
-            return getIntegerValue_(getModelID(), name); \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+                return getIntegerValue_(getModelID(), name); \r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
     private native int getIntegerValue_(String id, String name);\r
-    \r
+\r
     /**\r
      * Get a real (double) value for variable\r
      * @param name Name of the variable\r
@@ -514,12 +584,15 @@ public class FMUControlJNI {
      * @throws FMUJNIException\r
      */\r
     public boolean getBooleanValue(String name) throws FMUJNIException {\r
-        try {\r
-            return getBooleanValue_(getModelID(), name); \r
-        } catch (UnsatisfiedLinkError err) {\r
-            throw new FMUJNIException(UNSATISFIED_LINK);\r
-        } catch (Exception e) {\r
-            throw new FMUJNIException(e.getMessage());\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+                return getBooleanValue_(getModelID(), name); \r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMUJNIException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMUJNIException(e.getMessage());\r
+            }\r
         }\r
     }\r
 \r
@@ -571,7 +644,7 @@ public class FMUControlJNI {
         }\r
         return true;\r
     }\r
-    \r
+\r
     private boolean removeFMUDirectoryContents() {\r
         // Remove contents\r
         try {\r
index 5f0cf1f9af5caecd984640729b598e18f571f038..9f2697b477a1d22058c6f608cdb912a6df3965e0 100644 (file)
@@ -63,6 +63,14 @@ JNIEXPORT jint JNICALL Java_org_simantics_fmu_FMUControlJNI_setIntegerValue_1
 JNIEXPORT jint JNICALL Java_org_simantics_fmu_FMUControlJNI_setBooleanValue_1\r
   (JNIEnv *, jobject, jstring, jstring, jboolean);\r
 \r
+/*\r
+ * Class:     org_simantics_fmu_FMUControlJNI\r
+ * Method:    setTime_\r
+ * Signature: (Ljava/lang/String;D)I\r
+ */\r
+JNIEXPORT jint JNICALL Java_org_simantics_fmu_FMUControlJNI_setTime_1\r
+  (JNIEnv *, jobject, jstring, jdouble);\r
+\r
 /*\r
  * Class:     org_simantics_fmu_FMUControlJNI\r
  * Method:    simulateStep_\r
index 6e0ebb774c87dc8294e41ef075f0f858092d68f2..94ba196f587199812ae146e85c8e41ed5af25ddd 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index 7169987d094d3d2a5a515033b2596be9fefd7ade..4c7431052ae573e60b1a6344cdc3b358760e8c9d 100644 (file)
@@ -23,8 +23,8 @@ SYSDYN.ImportedOntologies : PROJ.NamespaceRequirement
         "http://www.simantics.org/Sysdyn-1.1" : L0.URI
         "http://www.simantics.org/Layer0-1.1" : L0.URI
         "http://www.simantics.org/SelectionView-1.2" : L0.URI
-//        "http://www.simantics.org/Documentation-1.1" : L0.URI // Experimental documentation tool
-//        "http://www.simantics.org/DocumentWorkbench-1.0" : L0.URI // Experimental documentation tool
+        "http://www.simantics.org/Documentation-1.1" : L0.URI // Experimental documentation tool
+        "http://www.simantics.org/DocumentWorkbench-1.0" : L0.URI // Experimental documentation tool
                 
 SYSDYN.SharedFunctionOntology <T L0.Ontology
 SYSDYN.SharedModuleOntology <T L0.Ontology      
@@ -229,7 +229,7 @@ SYSDYN.Flow <T STR.Connection
 SYSDYN.Expressions <T L0.OrderedSet <R L0.HasNext
 
 SYSDYN.Expression <T L0.Entity
-    >-- SYSDYN.Expression.equation --> L0.String <R L0.HasProperty : L0.TotalFunction
+    >-- SYSDYN.Expression.equation --> L0.String <R L0.HasProperty
     >-- SYSDYN.Expression.arrayRange --> L0.String <R L0.HasProperty : L0.TotalFunction
 
 SYSDYN.HasEquationOrEmpty <R SYSDYN.Expression.equation
@@ -464,7 +464,7 @@ SYSDYN.StockSymbol <T DIA.FontProvider <T DIA.ColorProvider
 // Diagram connection types
 //#####################################################################
 
-SYSDYN.FlowConnection <T DIA.RouteGraphConnection
+SYSDYN.FlowConnection <T DIA.RouteGraphConnection <T DIA.FontProvider <T DIA.ColorProvider
     MOD.DiagramConnectionTypeToConnectionType
         SYSDYN.Flow  
 
index 8c9a821b55cef2573a6b3abc5a0eb4820b14dc6d..dfa9897aed3273af07f0ca931f08dff78ef5cb59 100644 (file)
@@ -39,19 +39,22 @@ public class SimulationResult  extends ViewpointContributor<ExperimentNode> {
             if(graph.isInstanceOf(r, sr.HistoryDataset)) {\r
                 result.add(graph.adapt(r, AbstractNode.class));\r
             } else {\r
+                result.add(new HistoryDataNode(r));\r
+\r
                 String resultPath = (String)graph.getPossibleRelatedValue(r, sr.Result_resultFile);\r
                 File file = new File(resultPath);\r
-                if(file.exists()) {\r
-                    result.add(new HistoryDataNode(r));\r
-                } else {\r
+                if(!file.exists()) {\r
                     graph.asyncRequest(new WriteRequest() {\r
 \r
                         @Override\r
                         public void perform(WriteGraph graph) throws DatabaseException {\r
-                            Layer0 l0 = Layer0.getInstance(graph);\r
-                            graph.deny(r, l0.PartOf);\r
-                            graph.deny(r, graph.getInverse(SysdynResource.getInstance(graph).Experiment_result));\r
-\r
+                            String resultPath = (String)graph.getPossibleRelatedValue(r, SysdynResource.getInstance(graph).Result_resultFile);\r
+                            File file = new File(resultPath);\r
+                            if(!file.exists()) {\r
+                                Layer0 l0 = Layer0.getInstance(graph);\r
+                                graph.deny(r, l0.PartOf);\r
+                                graph.deny(r, graph.getInverse(SysdynResource.getInstance(graph).Experiment_result));\r
+                            }\r
                         }\r
                     });\r
                 }\r
index 2e5a55712f87dba7464bf1a2266b4865ba2f6e7d..e9280c6e42632ec7fcd88c14fce32e7f3fde68f8 100644 (file)
@@ -19,8 +19,13 @@ import java.awt.geom.Path2D;
 import java.awt.geom.Rectangle2D;\r
 import java.util.Collection;\r
 \r
+import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.G2DUtils;\r
+import org.simantics.diagram.stubs.G2DResource;\r
 import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.IDiagram;\r
 import org.simantics.g2d.element.ElementClass;\r
 import org.simantics.g2d.element.ElementHints;\r
 import org.simantics.g2d.element.ElementUtils;\r
@@ -29,6 +34,7 @@ import org.simantics.g2d.element.SceneGraphNodeKey;
 import org.simantics.g2d.element.handler.HandleMouseEvent;\r
 import org.simantics.g2d.element.handler.InternalSize;\r
 import org.simantics.g2d.element.handler.SceneGraph;\r
+import org.simantics.g2d.element.handler.impl.BorderColorImpl;\r
 import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
 import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
 import org.simantics.g2d.element.handler.impl.HoverImpl;\r
@@ -96,9 +102,23 @@ public class CloudFactory extends SysdynElementFactory {
                 CloudSceneGraph.INSTANCE,\r
                 HoverImpl.INSTANCE,\r
                 BoundsOutline.INSTANCE,\r
+                new BorderColorImpl(Color.BLACK),\r
                 new WholeElementTerminals(terminals)\r
         ).setId(CloudFactory.class.getSimpleName());\r
     }\r
+    \r
+    @Override\r
+    public void load(ReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource element, IElement e)\r
+            throws DatabaseException {\r
+        super.load(graph, canvas, diagram, element, e);\r
+        \r
+        Resource colorResource = graph.getPossibleObject(element, G2DResource.getInstance(graph).HasColor);\r
+        Color color = null;\r
+        if(colorResource != null) {\r
+            color = G2DUtils.getColor(graph, colorResource);\r
+            e.setHint(ElementHints.KEY_BORDER_COLOR, color);\r
+        }\r
+    }\r
 \r
     @Override\r
     protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
@@ -124,7 +144,7 @@ public class CloudFactory extends SysdynElementFactory {
             \r
             node.setStroke(STROKE);\r
             node.setScaleStroke(true);\r
-            node.setColor(Color.BLACK);\r
+            node.setColor(ElementUtils.getBorderColor(e, Color.BLACK));\r
             node.setShape(getCloudShape());\r
             \r
             if(at != null)\r
index fcba20c1beb07d7141afe1a694c8edcdce2b3ffa..765f25b207587d3aa8daad591763ada786ce5ca6 100644 (file)
 package org.simantics.sysdyn.ui.elements;\r
 \r
 import java.awt.BasicStroke;\r
+import java.awt.Color;\r
 import java.awt.geom.Rectangle2D;\r
 import java.util.Collection;\r
 \r
+import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.G2DUtils;\r
+import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.IDiagram;\r
 import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.impl.BorderColorImpl;\r
 import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
 import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
 import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
@@ -51,8 +61,21 @@ public class StockFactory extends SysdynElementFactory {
                 StaticSymbolImageInitializer.INSTANCE,\r
                 new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f),\r
                 BoundsOutline.INSTANCE,\r
+                new BorderColorImpl(Color.BLACK),\r
                 new WholeElementTerminals(terminals)\r
         ).setId(StockFactory.class.getSimpleName());\r
     }\r
 \r
+    @Override\r
+    public void load(ReadGraph graph, final ICanvasContext canvas, final IDiagram diagram, final Resource element, final IElement e) throws DatabaseException {\r
+        super.load(graph, canvas, diagram, element, e);\r
+        \r
+        Resource colorResource = graph.getPossibleObject(element, G2DResource.getInstance(graph).HasColor);\r
+        Color color = null;\r
+        if(colorResource != null) {\r
+            color = G2DUtils.getColor(graph, colorResource);\r
+            e.setHint(ElementHints.KEY_BORDER_COLOR, color);\r
+        }\r
+    }\r
+            \r
 }\r
index 00c89fd386f9062cdd51495f564260430d63c34c..b3c2d6fcbcc83f0f79f25c5479799521b889c816 100644 (file)
@@ -163,7 +163,8 @@ public class ValveFactory extends SysdynElementFactory {
             // Calculate borders from text node bounds.\r
             node.setStroke(STROKE);\r
             node.setScaleStroke(true);\r
-            node.setColor(Color.BLACK);\r
+            Color color = e.getHint(ElementHints.KEY_TEXT_COLOR);\r
+            node.setColor(color != null ? color : Color.BLACK);\r
             boolean rotated = false;\r
             String orientation = SysdynElementUtils.getOrientation(e);\r
             if(orientation != null && orientation.equals("Vertical"))\r
index 47120e9449071f751ca1ee5425ebc8eedd72548f..73d0879ae8d62597a4eadc0b35b58bcd3acd0393 100644 (file)
@@ -37,14 +37,20 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable {
     protected ArrowType type;\r
     protected Path2D path;\r
     protected double lineEndLength;\r
+    protected Color color;\r
     \r
-    public FlowArrowLineStyle(String desc) {\r
+    public FlowArrowLineStyle(String desc, Color color) {\r
         this.type = ArrowType.None;\r
         this.lineEndLength = 0.0;\r
 \r
         double l = length;\r
         double w = width;\r
         double s = space;\r
+        \r
+        if(color != null)\r
+            this.color = color;\r
+        else\r
+            this.color = Color.BLACK;\r
 \r
         StringTokenizer tokenizer = new StringTokenizer(desc);\r
         if (tokenizer.hasMoreTokens()) {\r
@@ -79,7 +85,7 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable {
         AffineTransform old = g.getTransform();\r
         g.translate(x, y);\r
         g.rotate(dir*Math.PI*0.5);\r
-        g.setColor(Color.BLACK);\r
+        g.setColor(color);\r
 \r
         switch (type) {\r
             case Fill:\r
index e30d2578d2d46875332680a2c6dc001281526dbf..f8c172bf5cee9a7c860b5444d4d5d56955294295 100644 (file)
@@ -35,6 +35,7 @@ import org.simantics.db.common.procedure.adapter.TransientCacheListener;
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.AsyncProcedure;\r
+import org.simantics.diagram.G2DUtils;\r
 import org.simantics.diagram.adapter.SyncElementFactory;\r
 import org.simantics.diagram.connection.ConnectionVisuals;\r
 import org.simantics.diagram.connection.RouteGraph;\r
@@ -50,6 +51,7 @@ import org.simantics.diagram.content.ResourceTerminal;
 import org.simantics.diagram.content.TerminalMap;\r
 import org.simantics.diagram.query.DiagramRequests;\r
 import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.diagram.stubs.G2DResource;\r
 import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;\r
 import org.simantics.diagram.synchronization.graph.RouteGraphConnection;\r
 import org.simantics.diagram.ui.DiagramModelHints;\r
@@ -73,7 +75,6 @@ import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.scenegraph.g2d.nodes.connection.IRouteGraphListener;\r
 import org.simantics.scenegraph.g2d.nodes.connection.RouteGraphChangeEvent;\r
-import org.simantics.scenegraph.utils.GeometryUtils;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.structural2.modelingRules.CPTerminal;\r
 import org.simantics.structural2.modelingRules.IAttachmentRelationMap;\r
@@ -127,6 +128,13 @@ public class RouteFlowConnectionFactory extends SyncElementFactory {
             // FIXME: With undo this seems to happen, don't know why yet!\r
             return;\r
 \r
+        Resource colorResource = graph.getPossibleObject(connection, G2DResource.getInstance(graph).HasColor);\r
+        Color color = null;\r
+        if(colorResource != null) {\r
+            color = G2DUtils.getColor(graph, colorResource);\r
+            element.setHint(ElementHints.KEY_TEXT_COLOR, color);\r
+        }\r
+        \r
         RouteGraph rg = new RouteGraph();\r
 \r
         Set<Resource> nodes = new HashSet<Resource>();\r
@@ -271,7 +279,7 @@ public class RouteFlowConnectionFactory extends SyncElementFactory {
                 direction = 0xf;\r
 \r
             //System.out.println("load line style: " + NameUtils.getSafeLabel(graph, attachmentRelation));\r
-            ILineEndStyle endStyle = loadLineEndStyle(graph, te, attachmentRelation);\r
+            ILineEndStyle endStyle = loadLineEndStyle(graph, te, attachmentRelation, color);\r
 \r
             RouteTerminal routeTerminal = rg.addBigTerminal(/*x, y,*/ minx, miny, maxx, maxy, /*direction,*/ endStyle);\r
             routeTerminal.setData( RouteGraphConnection.serialize(graph, connector) );\r
@@ -340,10 +348,12 @@ public class RouteFlowConnectionFactory extends SyncElementFactory {
         if (connectionType != null)\r
             cv = graph.syncRequest(DiagramRequests.getConnectionVisuals(connectionType),\r
                     TransientCacheListener.<ConnectionVisuals> instance());\r
-\r
-        Color lineColor = cv != null ? cv.toColor() : null;\r
+        \r
+        \r
+        Color lineColor = element.getHint(ElementHints.KEY_TEXT_COLOR);\r
         if (lineColor == null)\r
-            lineColor = Color.DARK_GRAY;\r
+            lineColor = cv != null ? cv.toColor() : Color.DARK_GRAY;\r
+            \r
         Stroke lineStroke = cv != null ? cv.stroke : null;\r
         if (lineStroke == null)\r
             lineStroke = new BasicStroke(0.1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10, null, 0);\r
@@ -372,17 +382,17 @@ public class RouteFlowConnectionFactory extends SyncElementFactory {
         return null;\r
     }\r
 \r
-    public ILineEndStyle loadLineEndStyle(ReadGraph graph, IElement te, Resource attachmentRelation)\r
+    public ILineEndStyle loadLineEndStyle(ReadGraph graph, IElement te, Resource attachmentRelation, Color color)\r
             throws DatabaseException {\r
         ILineEndStyle style;\r
         // TODO: change bounds according to terminal type: Very small rectangle for Valves, Text box size for Stocks and Clouds\r
         if(te.getElementClass().containsClass(ValveSceneGraph.class)) {\r
-            style =  new FlowArrowLineStyle("none 0 0 0");\r
+            style =  new FlowArrowLineStyle("none 0 0 0", color);\r
         } else {\r
             if (graph.isSubrelationOf(attachmentRelation, DIA.HasHeadConnector)) {\r
-                style = new FlowArrowLineStyle("fill 2 2 0");\r
+                style = new FlowArrowLineStyle("fill 2 2 0", color);\r
             } else {\r
-                style =  new FlowArrowLineStyle("none 0 0 0");\r
+                style =  new FlowArrowLineStyle("none 0 0 0", color);\r
             }\r
         }\r
         return style;\r
index dee43f15331626340378ea723729fb959a446537..9f69f7b379f395bd57a2dd6d716e6830338614ea 100644 (file)
@@ -91,17 +91,19 @@ public class FontContextMenuContribution extends DynamicMenuContribution {
                                        for(Object o : selections) {\r
                                                Resource element = ResourceAdaptionUtils\r
                                                                .adaptToResource(o);\r
-                                               Resource colorResource = graph.getPossibleObject(element, G2D.HasColor);\r
-                                               if(colorResource != null ) {\r
-                                                       Color newColor = G2DUtils.getColor(graph, colorResource);\r
-                                                       if(color == null)\r
-                                                               color = newColor;\r
-\r
-                                                       if(color != null && !color.equals(newColor))  {\r
-                                                               color = null;\r
-                                                               break;\r
-                                                       }\r
-                                               }                        \r
+                                               if(element != null) {\r
+                                                   Resource colorResource = graph.getPossibleObject(element, G2D.HasColor);\r
+                                                   if(colorResource != null ) {\r
+                                                       Color newColor = G2DUtils.getColor(graph, colorResource);\r
+                                                       if(color == null)\r
+                                                           color = newColor;\r
+\r
+                                                       if(color != null && !color.equals(newColor))  {\r
+                                                           color = null;\r
+                                                           break;\r
+                                                       }\r
+                                                   }                    \r
+                                               }\r
                                        }\r
                                } catch (DatabaseException e) {\r
                                }\r
index e8f840687318371f7c6d48bfa43fbec4049e71e2..5088e5b3b93d511683e96ed77529b93ec7ec3d24 100644 (file)
@@ -20,6 +20,7 @@ import java.util.List;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Statement;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
@@ -56,6 +57,7 @@ public class ValidationUtils {
         if(expressionList == null || expressionList.isEmpty())\r
             throw new UndefinedExpressionException();\r
         for(Resource expression : expressionList) {\r
+            \r
             Collection<Statement> statements = graph.getStatements(expression, sr.Expression_equation);\r
             if(statements.isEmpty())\r
                 throw new UndefinedExpressionException();\r
index 5ab097335549bf997b757c69cac0db4b6d7eff88..61e5d9f414cc0c28f96aee95c5a9a44e77fc3278 100644 (file)
@@ -113,7 +113,8 @@ public class ValueIndexVariable extends IndexVariable<double[]> {
                                        }\r
                                } catch (FMUJNIException e) {\r
                                }\r
-                       }   \r
+                       }\r
+                       exp.updateSubscriptions();\r
                }\r
        }\r
 \r
index 4d6a3dcb591dce45c811eaf98af090383b2ca87b..11706465ab9fab0f1ad7cb31b9fabad855dfeeac 100644 (file)
@@ -332,4 +332,45 @@ public class SysdynGameExperiment extends SysdynExperiment {
                        }\r
                }\r
        }\r
+       \r
+    @Override\r
+    public void rewindTo(double time) {\r
+        if(control == null)\r
+            return;\r
+        \r
+        if(time >-0.001 && time < 0.001) {\r
+            initialize();\r
+        } else {\r
+            System.out.println("rewindTo");\r
+        }\r
+    }\r
+    \r
+    private synchronized void initialize() {\r
+        try {\r
+            HashMap<String, String> inits = getExperimentParameters(null);\r
+\r
+            control.setStepLength(stepLength); // FIXME: fixed step lenghth\r
+            control.initializeSimulation(); // initialize simulation\r
+            if(inits.get("variableFilter") == null || inits.get("variableFilter").equals(".*"))\r
+                subscription = control.getAllVariables();\r
+            else\r
+                subscription = control.filterVariables(inits.get("variableFilter"));\r
+            control.subscribe(subscription); // subscribe all variables\r
+            \r
+            // Initialize results\r
+            results.clear();\r
+            \r
+            double[] initialValues = new double[subscription.length];\r
+            initialValues = control.getSubscribedResults(initialValues);\r
+            for(int k = 0; k < subscription.length; k++) {\r
+                results.put(subscription[k], new ArrayList<Double>());\r
+                results.get(subscription[k]).add(initialValues[k]);\r
+            }\r
+            \r
+            getCurrentResult().setResult(new GameResult(this.results, this.subscription));\r
+            resultsChanged();                \r
+        } catch (FMUJNIException e) {\r
+            System.err.println("SysdynGameExperiment rewind failed: " + e.getMessage());\r
+        }\r
+    }\r
  }\r