From c24f2deffb560bdd524b8e4f86e356f1d844fb31 Mon Sep 17 00:00:00 2001 From: lempinen Date: Tue, 31 Dec 2013 11:06:33 +0000 Subject: [PATCH] refs #3511 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28581 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.fmu/META-INF/MANIFEST.MF | 3 ++- .../src/org/simantics/fmu/FMUControlJNI.java | 21 +++---------------- .../sysdyn/manager/SysdynGameExperiment.java | 14 +++++++------ 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/org.simantics.fmu/META-INF/MANIFEST.MF b/org.simantics.fmu/META-INF/MANIFEST.MF index 525a0185..21efdee9 100644 --- a/org.simantics.fmu/META-INF/MANIFEST.MF +++ b/org.simantics.fmu/META-INF/MANIFEST.MF @@ -6,7 +6,8 @@ Bundle-Version: 1.1.0.qualifier Bundle-Activator: org.simantics.fmu.Activator Bundle-Vendor: Semantum Oy Require-Bundle: org.eclipse.core.runtime, - org.simantics.utils;bundle-version="1.1.0" + org.simantics.utils;bundle-version="1.1.0", + org.simantics;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: org.simantics.fmu diff --git a/org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java b/org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java index 716a864b..0ea50c2d 100644 --- a/org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java +++ b/org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java @@ -10,6 +10,7 @@ import java.util.UUID; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; +import org.simantics.Simantics; import org.simantics.utils.FileUtils; @@ -21,7 +22,6 @@ public class FMUControlJNI { private static int ERROR = 0; private static int OK = 1; private static String UNSATISFIED_LINK = "Method not found. DLL might not be loaded properly."; - private static String TEMP_DIRECTORY; private static String TEMP_FMU_DIRECTORY_NAME = "fmu"; public static String TEMP_FMU_COMMON_DIRECTORY; public static String LOCK_FILE_NAME = "fmu.lock"; @@ -68,23 +68,8 @@ public class FMUControlJNI { * Static: initialize fmu temp folder */ static { - try { - // Create a temp directory marker. This shows the system temp directory. - File temp = File.createTempFile("tempMarker", null); - TEMP_DIRECTORY = temp.getParentFile().getAbsolutePath(); - // Delete the marker - temp.delete(); - - // Get common "fmu" directory in temp directory - File tempCommonDir = new File(TEMP_DIRECTORY, TEMP_FMU_DIRECTORY_NAME); - // If fmu is not a directory, create it - if(!tempCommonDir.isDirectory()) { - tempCommonDir.mkdir(); - } - TEMP_FMU_COMMON_DIRECTORY = tempCommonDir.getAbsolutePath(); - } catch (IOException e) { - e.printStackTrace(); - } + File dir = Simantics.getTemporaryDirectory(TEMP_FMU_DIRECTORY_NAME); + TEMP_FMU_COMMON_DIRECTORY = dir.getAbsolutePath(); } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java index 21e7ccb3..a5a9d7bc 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java @@ -376,20 +376,20 @@ public class SysdynGameExperiment extends OldSysdynExperiment { monitor.worked(1); int stepNumber = 1; - while(control.getTime() < eTime && !canceled) { - if(eTime - control.getTime() < stepLength) - control.setStepLength(eTime - control.getTime()); + while(time < eTime && !canceled) { + if(eTime - time < stepLength) + control.setStepLength(eTime - time); - monitor.subTask("Simulate step (time = " + control.getTime() + ")"); + monitor.subTask("Simulate step (time = " + time + ")"); control.simulateStep(); monitor.worked(1); if(stepNumber % savePer == 0) { - monitor.subTask("Get results (time = " + control.getTime() + ")"); + monitor.subTask("Get results (time = " + time + ")"); currentValues = control.getSubscribedResults(currentValues); monitor.worked(1); - monitor.subTask("Save results (time = " + control.getTime() + ")"); + monitor.subTask("Save results (time = " + time + ")"); for(int k = 0; k < subscription.length; k++) { SysdynGameExperiment.this.results.get(subscription[k]).add(currentValues[k]); } @@ -398,6 +398,8 @@ public class SysdynGameExperiment extends OldSysdynExperiment { } stepNumber++; monitor.worked(1); + + time = control.getTime(); } monitor.subTask("Display results"); -- 2.47.1