}\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
// 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
\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
* @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
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
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
\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
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
\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
} catch (NumberFormatException e) {}\r
}\r
\r
- super.simulate(monitor, progressMonitor);\r
+ super.simulate(monitor, progressMonitor, modelName);\r
}\r
}\r
@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