From: lempinen Date: Fri, 1 Jun 2012 11:33:44 +0000 (+0000) Subject: Small improvements: Alphabetic order for variables in model browser, module structure... X-Git-Tag: simantics-1.6~1^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=951fb51cea7634b6132acc7993ad0ebe9f9bd916;p=simantics%2Fsysdyn.git Small improvements: Alphabetic order for variables in model browser, module structure view displays where the selected variable is located in the module structure, game experiment progress displays the correct percentage when using output interval, withlookup expressions accept spreadsheet tables, modelicawriter uses model name instead of misguiding "Model_n", created a new "minmax" built-in function. (refs #3414) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@25091 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ontology/graph.tg b/org.simantics.sysdyn.ontology/graph.tg index 185aa201..8185e6cc 100644 Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ diff --git a/org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph b/org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph index 09ced343..4595b360 100644 --- a/org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph +++ b/org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph @@ -3,6 +3,15 @@ SYSDYN = FL = : SYSDYN.SysdynModelicaFunctionLibrary +FL.minmax : SYSDYN.SysdynModelicaFunction + L0.HasDescription "Limits the result of an equation to between the given minimum and maximum values." + SYSDYN.SysdynModelicaFunction.modelicaFunctionCode """ input Real expression; + input Real minimum; + input Real maximum; + output Real result; +algorithm + result := min(maximum, max(minimum, expression));""" + FL.xidz : SYSDYN.SysdynModelicaFunction L0.HasDescription "X if divided by zero" diff --git a/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java b/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java index c4f222e9..79f98c2a 100644 --- a/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java +++ b/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java @@ -51,6 +51,7 @@ public class SysdynResource { public final Resource Built$in_Functions_Vensim_Functions_ZIDZ; public final Resource Built$in_Functions_interpolate; public final Resource Built$in_Functions_interpolateFull; + public final Resource Built$in_Functions_minmax; public final Resource Built$in_Functions_xidz; public final Resource Built$in_Functions_zidz; public final Resource Center; @@ -403,6 +404,7 @@ public class SysdynResource { public static final String Built$in_Functions_Vensim_Functions_ZIDZ = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/ZIDZ"; public static final String Built$in_Functions_interpolate = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/interpolate"; public static final String Built$in_Functions_interpolateFull = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/interpolateFull"; + public static final String Built$in_Functions_minmax = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/minmax"; public static final String Built$in_Functions_xidz = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz"; public static final String Built$in_Functions_zidz = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/zidz"; public static final String Center = "http://www.simantics.org/Sysdyn-1.1/Center"; @@ -765,6 +767,7 @@ public class SysdynResource { Built$in_Functions_Vensim_Functions_ZIDZ = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_ZIDZ); Built$in_Functions_interpolate = getResourceOrNull(graph, URIs.Built$in_Functions_interpolate); Built$in_Functions_interpolateFull = getResourceOrNull(graph, URIs.Built$in_Functions_interpolateFull); + Built$in_Functions_minmax = getResourceOrNull(graph, URIs.Built$in_Functions_minmax); Built$in_Functions_xidz = getResourceOrNull(graph, URIs.Built$in_Functions_xidz); Built$in_Functions_zidz = getResourceOrNull(graph, URIs.Built$in_Functions_zidz); Center = getResourceOrNull(graph, URIs.Center); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java index c874e042..d50bfbc2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java @@ -13,6 +13,7 @@ package org.simantics.sysdyn.ui.browser.contributions; import java.util.ArrayList; import java.util.Collection; +import java.util.TreeMap; import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; import org.simantics.db.ReadGraph; @@ -22,7 +23,6 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.layer0.Layer0; -import org.simantics.modeling.ui.modelBrowser2.model.SheetsNode; import org.simantics.spreadsheet.resource.SpreadsheetResource; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.browser.nodes.BookNode; @@ -31,6 +31,7 @@ import org.simantics.sysdyn.ui.browser.nodes.EnumerationNode; import org.simantics.sysdyn.ui.browser.nodes.InputNode; import org.simantics.sysdyn.ui.browser.nodes.ModuleNode; import org.simantics.sysdyn.ui.browser.nodes.VariableNode; +import org.simantics.utils.strings.AlphanumComparator; public class Configuration extends ViewpointContributor> { @@ -44,37 +45,45 @@ public class Configuration extends ViewpointContributor variables = new ArrayList(); - ArrayList inputs = new ArrayList(); - ArrayList modules = new ArrayList(); - ArrayList enumerations = new ArrayList(); + TreeMap variables = new TreeMap(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR); + TreeMap inputs = new TreeMap(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR); + TreeMap modules = new TreeMap(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR); + TreeMap enumerations = new TreeMap(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR); + for(Variable child : variable.browseChildren(graph)) { Resource represents = (Resource)child.getPropertyValue(graph, Variables.REPRESENTS); if(graph.isInstanceOf(represents, sr.IndependentVariable)) { - variables.add(child); + variables.put(child.getName(graph), child); } else if (graph.isInstanceOf(represents, sr.Input)) { - inputs.add(child); + inputs.put(child.getName(graph), child); } else if (graph.isInstanceOf(represents, sr.Module)) { - modules.add(child); + modules.put(child.getName(graph), child); } else if (graph.isInstanceOf(represents, sr.Enumeration)) { - enumerations.add(child); + enumerations.put(child.getName(graph), child); } } - for (Variable v : variables) { + for (String s : variables.keySet()) { + Variable v = variables.get(s); Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS); result.add(new VariableNode(v, represents)); } - for (Variable v : inputs) { + + for (String s : inputs.keySet()) { + Variable v = inputs.get(s); Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS); result.add(new InputNode(v, represents)); } - for (Variable v : modules) { + + for (String s : modules.keySet()) { + Variable v = modules.get(s); Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS); result.add(new ModuleNode(v, represents)); } - for (Variable v : enumerations) { + + for (String s : enumerations.keySet()) { + Variable v = enumerations.get(s); Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS); result.add(new EnumerationNode(v, represents)); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java index 87151394..5cd6bbee 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java @@ -13,12 +13,14 @@ package org.simantics.sysdyn.ui.browser.contributions; import java.util.ArrayList; import java.util.Collection; +import java.util.TreeMap; import org.simantics.browsing.ui.common.node.AbstractNode; import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; @@ -26,6 +28,7 @@ import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode; import org.simantics.sysdyn.ui.browser.nodes.FunctionNode; import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder; import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder; +import org.simantics.utils.strings.AlphanumComparator; public class FunctionLibraries extends ViewpointContributor { @@ -38,16 +41,23 @@ public class FunctionLibraries extends ViewpointContributor { ArrayList> result = new ArrayList>(); - // Find model functions + TreeMap sortResult = new TreeMap(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR); + // Find and sort model functions for(Resource function : graph.syncRequest(new ObjectsWithType(functionsFolder.data, l0.ConsistsOf, sr.SysdynModelicaFunction))) { - result.add(new FunctionNode(function)); + sortResult.put(NameUtils.getSafeName(graph, function), function); } + for(Resource function : sortResult.values()) + result.add(new FunctionNode(function)); - // Find model function libraries + // Find and sort model function libraries + sortResult.clear(); for(Resource functionLibrary : graph.syncRequest(new ObjectsWithType(functionsFolder.data, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) { - result.add(new FunctionLibraryNode(functionLibrary)); - } - + sortResult.put(NameUtils.getSafeName(graph, functionLibrary), functionLibrary); + } + for(Resource functionLibrary : sortResult.values()) + result.add(new FunctionLibraryNode(functionLibrary)); + + // Find built-in functions Resource sysdyn = graph.getPossibleResource("http://www.simantics.org/Sysdyn-1.1"); if(sysdyn != null) { for(Resource library : graph.syncRequest(new ObjectsWithType(sysdyn, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryFunctions.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryFunctions.java index c37ea465..6e3a1a1f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryFunctions.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryFunctions.java @@ -13,17 +13,20 @@ package org.simantics.sysdyn.ui.browser.contributions; import java.util.ArrayList; import java.util.Collection; +import java.util.TreeMap; import org.simantics.browsing.ui.common.node.AbstractNode; import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode; import org.simantics.sysdyn.ui.browser.nodes.FunctionNode; +import org.simantics.utils.strings.AlphanumComparator; public class LibraryFunctions extends ViewpointContributor> { @@ -32,16 +35,28 @@ public class LibraryFunctions extends ViewpointContributor library) throws DatabaseException { Layer0 l0 = Layer0.getInstance(graph); ArrayList> result = new ArrayList>(); + + TreeMap sortResult = new TreeMap(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR); + + // Find and sort functions in library for(Resource function : graph.syncRequest(new ObjectsWithType(library.data, l0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModelicaFunction))) { - result.add(new FunctionNode(function)); + sortResult.put(NameUtils.getSafeName(graph, function), function); } + for(Resource function : sortResult.values()) + result.add(new FunctionNode(function)); + + // Find and sort libraries in library + sortResult.clear(); for(Resource functionLibrary : graph.syncRequest(new ObjectsWithType(library.data, l0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModelicaFunctionLibrary))) { - result.add(new FunctionLibraryNode(functionLibrary)); + sortResult.put(NameUtils.getSafeName(graph, functionLibrary), functionLibrary); } + for(Resource functionLibrary : sortResult.values()) + result.add(new FunctionLibraryNode(functionLibrary)); + return result; } - + @Override public String getViewpointId() { return "Standard"; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java index ed5a9ead..4ebe335e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java @@ -13,9 +13,11 @@ package org.simantics.sysdyn.ui.browser.contributions; import java.util.ArrayList; import java.util.Collection; +import java.util.TreeMap; import org.simantics.browsing.ui.common.node.AbstractNode; import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithType; @@ -29,6 +31,7 @@ import org.simantics.sysdyn.ui.browser.nodes.InputNode; import org.simantics.sysdyn.ui.browser.nodes.ModuleNode; import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode; import org.simantics.sysdyn.ui.browser.nodes.VariableNode; +import org.simantics.utils.strings.AlphanumComparator; public class ModuleType extends ViewpointContributor { @@ -44,18 +47,39 @@ public class ModuleType extends ViewpointContributor { if(instance == null) return result; Resource conf = graph.getSingleObject(instance, str.IsDefinedBy); + + // Independent variables + TreeMap variables = new TreeMap(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR); for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.IndependentVariable))) { - result.add(new VariableNode(r)); + variables.put((String)graph.getPossibleRelatedValue(r, l0.HasName, Bindings.STRING), r); } + for(String key : variables.keySet()) + result.add(new VariableNode(variables.get(key))); + + // Inputs + variables.clear(); for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Input))) { - result.add(new InputNode(r)); + variables.put((String)graph.getPossibleRelatedValue(r, l0.HasName, Bindings.STRING), r); } + for(String key : variables.keySet()) + result.add(new InputNode(variables.get(key))); + + // Modules + variables.clear(); for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Module))) { - result.add(new ModuleNode(r)); + variables.put((String)graph.getPossibleRelatedValue(r, l0.HasName, Bindings.STRING), r); } + for(String key : variables.keySet()) + result.add(new ModuleNode(variables.get(key))); + + // Enumerations + variables.clear(); for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Enumeration))) { - result.add(new EnumerationNode(r)); + variables.put((String)graph.getPossibleRelatedValue(r, l0.HasName, Bindings.STRING), r); } + for(String key : variables.keySet()) + result.add(new EnumerationNode(variables.get(key))); + return result; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/structure/ModuleStructureGraphRequest.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/structure/ModuleStructureGraphRequest.java index 4724a0d5..c32a3004 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/structure/ModuleStructureGraphRequest.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/structure/ModuleStructureGraphRequest.java @@ -24,6 +24,8 @@ import org.simantics.graphviz.Edge; import org.simantics.graphviz.Graph; import org.simantics.graphviz.Node; import org.simantics.layer0.Layer0; +import org.simantics.modeling.ModelingResources; +import org.simantics.simulation.ontology.SimulationResource; import org.simantics.sysdyn.SysdynResource; /** @@ -61,13 +63,21 @@ public class ModuleStructureGraphRequest implements Read { // Model root was not found, return empty graph if(model == null) return g; + + // Find the parent module/model of the selected resource + Resource parentResource = graph.getPossibleObject(resource, l0.PartOf); + if(graph.isInstanceOf(parentResource, sr.ConfigurationDiagram)) { + parentResource = graph.getPossibleObject(parentResource, ModelingResources.getInstance(graph).DiagramToComposite); + } else if(graph.isInstanceOf(parentResource, sr.SysdynModel)) { + parentResource = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration); + } // Set root node Node rootNode = new Node(g, NameUtils.getSafeLabel(graph, model)); rootNode.setShape("rectangle"); HashSet visited = new HashSet(); visited.add(model); - findChildModules(g, rootNode, graph, model, visited); + findChildModules(g, rootNode, graph, model, parentResource, visited); return g; @@ -79,17 +89,23 @@ public class ModuleStructureGraphRequest implements Read { * @param parent Parent module or model * @param graph ReadGraph * @param resource Module type or model + * @param parent2 * @param visited All visited modules. Needed to check for loops in the structure. Loops are not allowed. * @throws DatabaseException */ - private void findChildModules(Graph g, Node parent, ReadGraph graph, Resource resource, HashSet visited) throws DatabaseException { + private void findChildModules(Graph g, Node parent, ReadGraph graph, Resource resource, Resource parentResource, HashSet visited) throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(graph); Layer0 l0 = Layer0.getInstance(graph); + Resource configuration = graph.syncRequest(new PossibleObjectWithType(resource, l0.ConsistsOf, sr.Configuration)); + + // Set the parent color different, if it is the parent of the selected resource + if(configuration.equals(parentResource)) + parent.setColor("#ff8c00"); + HashMap modules = new HashMap(); // Find all module children - Resource configuration = graph.syncRequest(new PossibleObjectWithType(resource, l0.ConsistsOf, sr.Configuration)); for(Resource m : graph.getObjects(configuration, l0.ConsistsOf)) { Resource type = graph.getPossibleObject(m, l0.InstanceOf); if(graph.isInheritedFrom(type, sr.Module)) { @@ -120,8 +136,9 @@ public class ModuleStructureGraphRequest implements Read { node.setFontColor("#FF0000"); continue; } else { - visited.add(type); - findChildModules(g, node, graph, type, visited); + HashSet copy = new HashSet(visited); + copy.add(type); + findChildModules(g, node, graph, type, parentResource, copy); } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiment.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiment.java index d0e8f385..1c1852b1 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiment.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiment.java @@ -352,7 +352,7 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment { protected static SimulationLocation createSimulationFiles(SysdynModel sysdynModel, String modelText, HashMap inits, String additionalScript, boolean fmu) throws IOException { return ModelicaManager.createSimulationFiles( sysdynModel.getSimulationDir(), - sysdynModel.getConfiguration().getName(), + sysdynModel.getConfiguration().getLabel(), modelText, inits, additionalScript, 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 8bb2e09c..f5918430 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java @@ -274,6 +274,8 @@ public class SysdynGameExperiment extends SysdynExperiment { for(int k = 0; k < subscription.length; k++) { SysdynGameExperiment.this.results.get(subscription[k]).add(results[k]); } + } else { + monitor.worked(1); } stepNumber++; monitor.worked(1); diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java index 740ae5a2..3912a70e 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java @@ -213,10 +213,6 @@ public class SysdynModel implements IMappingListener, IModel { e.printStackTrace(); } - // Add the current result if there is one - if(getSysdynResult() != null) - activeResults.add(0, getSysdynResult() ); - return activeResults; } @@ -224,6 +220,10 @@ public class SysdynModel implements IMappingListener, IModel { @Override public void execute(ArrayList result) { + // Add the current result if there is one + if(result != null && getSysdynResult() != null) + result.add(0, getSysdynResult() ); + activeResults = result; resultChanged(); } @@ -497,7 +497,7 @@ public class SysdynModel implements IMappingListener, IModel { public File getSimulationDir() { if(simulationDir == null) { File modelsDir = Activator.getBundleContext().getDataFile("models"); - String configName = configuration.getName(); + String configName = configuration.getLabel(); List files = Arrays.asList(modelsDir.list()); if (files.contains(configName)) { int i = 2; diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java index 090af57a..ea24ec70 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java @@ -141,7 +141,7 @@ public class ModelicaWriter { // If the configuration is model configuration, use model name. Otherwise, use configuration name. ModuleType mt = configuration.getModuleType(); - String className = mt != null ? (mt.getName().replace(" ", "")) : (configuration.getName().replace(" ", "")); + String className = mt != null ? (mt.getName().replace(" ", "")) : (configuration.getLabel().replace(" ", "")); b.append("class ").append(className); diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Configuration.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Configuration.java index f13b4044..00d0efb3 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Configuration.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Configuration.java @@ -75,7 +75,7 @@ public class Configuration { } public String getLabel() { - return label; + return label != null ? label : name; } public ModuleType getModuleType() { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/WithLookupExpression.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/WithLookupExpression.java index 15e34766..f40cc43e 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/WithLookupExpression.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/WithLookupExpression.java @@ -17,6 +17,7 @@ import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.representation.IndependentVariable; import org.simantics.sysdyn.representation.utils.FormatUtils; import org.simantics.sysdyn.representation.utils.IndexUtils; +import org.simantics.sysdyn.representation.utils.SheetFormatUtils; /** * Representation of a withlookup expression @@ -38,7 +39,7 @@ public class WithLookupExpression extends Expression { String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange()); return - " " + variable.getName() + (range.equals("[:]") ? "" : range) + " = interpolate(" + equation + ", " + lookupTable + ");\n"; + " " + variable.getName() + (range.equals("[:]") ? "" : range) + " = interpolate(" + equation + ", " + SheetFormatUtils.reformatSheetReferences(variable, lookupTable) + ");\n"; } @Override diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationJob.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationJob.java index df6b06ae..ccb4d92e 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationJob.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationJob.java @@ -42,7 +42,7 @@ public class SimulationJob extends Job { IModelicaMonitor monitor; public SimulationJob(SysdynModel model, Experiment experiment) { - super("Simulate " + model.getConfiguration().getName()); + super("Simulate " + model.getConfiguration().getLabel()); this.model = model; this.experiment = experiment; if(PlatformUI.isWorkbenchRunning()) { @@ -55,8 +55,8 @@ public class SimulationJob extends Job { @Override protected IStatus run(IProgressMonitor monitor) { - monitor.beginTask("Simulate " + model.getConfiguration().getName(), 5); - this.monitor.message("Simulate " + model.getConfiguration().getName()); + monitor.beginTask("Simulate " + model.getConfiguration().getLabel(), 5); + this.monitor.message("Simulate " + model.getConfiguration().getLabel()); try { model.update(); if(experiment instanceof SysdynExperiment)