]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
The default Modelica solver set to the bundled one in Windows (refs #4401).
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 23 Aug 2013 09:59:36 +0000 (09:59 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 23 Aug 2013 09:59:36 +0000 (09:59 +0000)
Print to the Sysdyn console which solver is used when simulating.
Some little fixes, too.

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27770 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.modelica/src/org/simantics/modelica/ModelicaManager.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynConsole.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiment.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynSensitivityAnalysisExperiment.java
org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationJob.java

index d2f2d43a31a58cd325f710f39404415951009ade..a9535e73c3c8fa5e1e35222f7c49fbe6c94b2535 100644 (file)
@@ -114,21 +114,20 @@ public class ModelicaManager {
     }\r
     \r
     public static File getDefaultModelicaHome() {\r
-        // Try to find installed openModelica\r
-        File omhome = getInstalledOpenModelicaHome();\r
-        if(omhome != null)\r
-            return omhome;\r
-\r
         // Get operating system\r
         OSType os = calculateOS();\r
         \r
-        // OPENMODELICAHOMe was not found or the folder does not exist. Try built-in OpenModelica for windows\r
+        // Try built-in OpenModelica for windows\r
         if(os.equals(OSType.WINDOWS)) {\r
             File builtin = getBuiltinOpenModelicaHome();\r
             if(builtin != null)\r
                 return builtin;\r
         }\r
 \r
+        // Try to find installed openModelica\r
+        File omhome = getInstalledOpenModelicaHome();\r
+        if(omhome != null)\r
+            return omhome;\r
 \r
         // OS was not windows or built-in OpenModelica did not work\r
         switch (os) {\r
index 604c924bbc95d4292782dd78afca4390eb8507ec..744e6316bc348bbcaea0139b22987b8c816fe666 100644 (file)
@@ -177,7 +177,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             // If shadow variable, display properties of the original variable\r
             if(backend.isInstanceOf(r, sr.Shadow)) {\r
                 Resource original = backend.getPossibleObject(r, sr.Shadow_original);\r
-                if(original != null) {\r
+                if(original != null && var != null) {\r
                     r = original;\r
                     Variable parent = var.getParent(backend);\r
                     var = parent.getPossibleChild(backend, NameUtils.getSafeName(backend, r));\r
index a985f7900cf96269da9cdfd5eb4f99cdaf224741..c6334cfa5f74aa0da942b4a1dd91db55e5233bc2 100644 (file)
@@ -19,7 +19,7 @@ import org.simantics.modelica.IModelicaMonitor;
 \r
 public class SysdynConsole  implements IModelicaMonitor {\r
 \r
-    private static String SYSDYN_CONSOLE = "Sysyn modelica console";\r
+    private static String SYSDYN_CONSOLE = "Sysdyn modelica console";\r
     private MessageConsole console;\r
 \r
     public static SysdynConsole INSTANCE = new SysdynConsole();\r
index e20dda89b7cb9281008d375142ca221a03a46262..e690510951a736a282f41f8788e4e516d76f5735 100644 (file)
@@ -445,7 +445,7 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment,
      * @param progressMonitor\r
      * @throws IOException\r
      */\r
-    public synchronized void simulate(final IModelicaMonitor monitor, final IProgressMonitor progressMonitor) throws IOException {\r
+    public synchronized void simulate(final IModelicaMonitor monitor, final IProgressMonitor progressMonitor, String modelName) throws IOException {\r
         canceled = false;\r
         progressMonitor.subTask("Write modelica classes");\r
 \r
@@ -454,6 +454,7 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment,
             omcVersion = ModelicaManager.getOMCVersion(home);\r
             omcHome = home.getAbsolutePath();\r
         }\r
+        monitor.message("Simulate " + modelName + " using OpenModelica " + omcVersion);\r
         \r
         // Get Modelica code\r
         String modelText = getModelicaCode(monitor, false, omcVersion);\r
index b2e05e16c461d7b77c53067cfb6f856a983d393d..d99f014f9f1d5f7745cc3636de967ebdfefe1087 100644 (file)
@@ -36,6 +36,7 @@ import org.simantics.db.request.Read;
 import org.simantics.fmu.FMUControlJNI;\r
 import org.simantics.fmu.FMUJNIException;\r
 import org.simantics.modelica.IModelicaMonitor;\r
+import org.simantics.modelica.ModelicaManager;\r
 import org.simantics.modelica.SimulationLocation;\r
 import org.simantics.modelica.data.DataSet;\r
 import org.simantics.modelica.data.SimulationResult;\r
@@ -176,7 +177,7 @@ public class SysdynGameExperiment extends SysdynExperiment {
        \r
 \r
        @Override\r
-       public synchronized void simulate(final IModelicaMonitor monitor, final IProgressMonitor progressMonitor) throws IOException {\r
+       public synchronized void simulate(final IModelicaMonitor monitor, final IProgressMonitor progressMonitor, String modelName) throws IOException {\r
                canceled = false;\r
 \r
                progressMonitor.subTask("Write modelica classes");\r
@@ -185,7 +186,14 @@ public class SysdynGameExperiment extends SysdynExperiment {
                String modelText = getModelicaCode(monitor, true, getOpenModelicaVersion());\r
                if(modelText == null)\r
                        return;\r
-\r
+               \r
+               File home = ModelicaManager.getModelicaHome();\r
+        if (omcHome == null || !home.getAbsolutePath().equals(omcHome)) {\r
+            omcVersion = ModelicaManager.getOMCVersion(home);\r
+            omcHome = home.getAbsolutePath();\r
+        }\r
+        monitor.message("Simulate " + modelName + " using OpenModelica " + omcVersion);\r
+        \r
                progressMonitor.worked(1);\r
 \r
                // Write initial files and add init-parameters\r
index c1b8ad508b3f12037654838d95047f378acbc56c..182f043031f22e8a1a872bb13af23f3f8dd6c190 100644 (file)
@@ -354,7 +354,7 @@ public class SysdynSensitivityAnalysisExperiment extends SysdynExperiment {
     \r
     \r
     @Override\r
-    public synchronized void simulate(IModelicaMonitor monitor, IProgressMonitor progressMonitor) throws IOException {\r
+    public synchronized void simulate(IModelicaMonitor monitor, IProgressMonitor progressMonitor, String modelName) throws IOException {\r
         \r
         File home = ModelicaManager.getModelicaHome();\r
         if (omcHome == null || !home.getAbsolutePath().equals(omcHome)) {\r
@@ -377,6 +377,6 @@ public class SysdynSensitivityAnalysisExperiment extends SysdynExperiment {
             } catch (NumberFormatException e) {}\r
         }\r
         \r
-        super.simulate(monitor, progressMonitor);\r
+        super.simulate(monitor, progressMonitor, modelName);\r
     }\r
 }\r
index 2823b33e12e12bb1c0284fa99ff138566975cf55..5daae2504265299cc951617c706bc82cb335b3eb 100644 (file)
@@ -45,11 +45,10 @@ public class SimulationJob extends Job {
     @Override\r
     protected IStatus run(IProgressMonitor monitor) {\r
         monitor.beginTask("Simulate " + model.getConfiguration().getLabel(), experiment.numberOfSimulationRunSteps());        \r
-        this.monitor.message("Simulate " + model.getConfiguration().getLabel());\r
         try {\r
             model.update();\r
             if(experiment instanceof SysdynExperiment) {\r
-               ((SysdynExperiment)experiment).simulate(this.monitor, monitor);\r
+               ((SysdynExperiment)experiment).simulate(this.monitor, monitor, model.getConfiguration().getLabel());\r
                model.setStructureModified(false);\r
             }\r
         } catch (Exception e) {\r