]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Small improvements: Alphabetic order for variables in model browser, module structure...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 1 Jun 2012 11:33:44 +0000 (11:33 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 1 Jun 2012 11:33:44 +0000 (11:33 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@25091 ac1ea38d-2e2b-0410-8846-a27921b304fc

15 files changed:
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryFunctions.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/structure/ModuleStructureGraphRequest.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/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Configuration.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/WithLookupExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationJob.java

index 185aa2016d61749af563452940037e17ea6eb9a0..8185e6cc23e6ced9e888f380ad97437aa17e3792 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index 09ced343f87e7c384f8029f419f063ca68d97b9e..4595b360b43f5863b9f7d4f13368185f6fe660e8 100644 (file)
@@ -3,6 +3,15 @@ SYSDYN = <http://www.simantics.org/Sysdyn-1.1>
 \r
 FL = <http://www.simantics.org/Sysdyn-1.1/Built-in Functions> : SYSDYN.SysdynModelicaFunctionLibrary\r
 \r
+FL.minmax : SYSDYN.SysdynModelicaFunction\r
+    L0.HasDescription "Limits the result of an equation to between the given minimum and maximum values."\r
+    SYSDYN.SysdynModelicaFunction.modelicaFunctionCode """    input Real expression;\r
+    input Real minimum;\r
+    input Real maximum;\r
+    output Real result;\r
+algorithm\r
+    result := min(maximum, max(minimum, expression));"""\r
+\r
 \r
 FL.xidz : SYSDYN.SysdynModelicaFunction\r
     L0.HasDescription "X if divided by zero"\r
index c4f222e9ec16397c94f9afdb39f9b184071a948f..79f98c2a6db7baa2f3968d040b5f4b653fc4073d 100644 (file)
@@ -51,6 +51,7 @@ public class SysdynResource {
     public final Resource Built$in_Functions_Vensim_Functions_ZIDZ;\r
     public final Resource Built$in_Functions_interpolate;\r
     public final Resource Built$in_Functions_interpolateFull;\r
+    public final Resource Built$in_Functions_minmax;\r
     public final Resource Built$in_Functions_xidz;\r
     public final Resource Built$in_Functions_zidz;\r
     public final Resource Center;\r
@@ -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";\r
         public static final String Built$in_Functions_interpolate = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/interpolate";\r
         public static final String Built$in_Functions_interpolateFull = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/interpolateFull";\r
+        public static final String Built$in_Functions_minmax = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/minmax";\r
         public static final String Built$in_Functions_xidz = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz";\r
         public static final String Built$in_Functions_zidz = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/zidz";\r
         public static final String Center = "http://www.simantics.org/Sysdyn-1.1/Center";\r
@@ -765,6 +767,7 @@ public class SysdynResource {
         Built$in_Functions_Vensim_Functions_ZIDZ = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_ZIDZ);\r
         Built$in_Functions_interpolate = getResourceOrNull(graph, URIs.Built$in_Functions_interpolate);\r
         Built$in_Functions_interpolateFull = getResourceOrNull(graph, URIs.Built$in_Functions_interpolateFull);\r
+        Built$in_Functions_minmax = getResourceOrNull(graph, URIs.Built$in_Functions_minmax);\r
         Built$in_Functions_xidz = getResourceOrNull(graph, URIs.Built$in_Functions_xidz);\r
         Built$in_Functions_zidz = getResourceOrNull(graph, URIs.Built$in_Functions_zidz);\r
         Center = getResourceOrNull(graph, URIs.Center);\r
index c874e0428c6fee8ca7b8080f3dbe5068469dedda..d50bfbc2ab00658f77e3999669bc8db57aa47d11 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.TreeMap;\r
 \r
 import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
 import org.simantics.db.ReadGraph;\r
@@ -22,7 +23,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.layer0.Layer0;\r
-import org.simantics.modeling.ui.modelBrowser2.model.SheetsNode;\r
 import org.simantics.spreadsheet.resource.SpreadsheetResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.BookNode;\r
@@ -31,6 +31,7 @@ import org.simantics.sysdyn.ui.browser.nodes.EnumerationNode;
 import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+import org.simantics.utils.strings.AlphanumComparator;\r
 \r
 public class Configuration extends ViewpointContributor<ConfigurationNode<Resource>> {\r
 \r
@@ -44,37 +45,45 @@ public class Configuration extends ViewpointContributor<ConfigurationNode<Resour
                }\r
                \r
                SysdynResource sr = SysdynResource.getInstance(graph);\r
-               ArrayList<Variable> variables = new ArrayList<Variable>();\r
-               ArrayList<Variable> inputs = new ArrayList<Variable>();\r
-               ArrayList<Variable> modules = new ArrayList<Variable>();\r
-               ArrayList<Variable> enumerations = new ArrayList<Variable>();\r
+               TreeMap<String, Variable> variables = new TreeMap<String, Variable>(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
+               TreeMap<String, Variable> inputs = new TreeMap<String, Variable>(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
+               TreeMap<String, Variable> modules = new TreeMap<String, Variable>(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
+               TreeMap<String, Variable> enumerations = new TreeMap<String, Variable>(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
+\r
 \r
                for(Variable child : variable.browseChildren(graph)) {\r
                        Resource represents = (Resource)child.getPropertyValue(graph, Variables.REPRESENTS);\r
                        if(graph.isInstanceOf(represents, sr.IndependentVariable)) {\r
-                               variables.add(child);\r
+                               variables.put(child.getName(graph), child);\r
                        } else if (graph.isInstanceOf(represents, sr.Input)) {\r
-                               inputs.add(child);\r
+                               inputs.put(child.getName(graph), child);\r
                        } else if (graph.isInstanceOf(represents, sr.Module)) {\r
-                               modules.add(child);\r
+                               modules.put(child.getName(graph), child);\r
                        } else if (graph.isInstanceOf(represents, sr.Enumeration)) {\r
-                               enumerations.add(child);\r
+                               enumerations.put(child.getName(graph), child);\r
                        }\r
                }\r
                \r
-               for (Variable v : variables) {\r
+               for (String s : variables.keySet()) {\r
+                       Variable v = variables.get(s);\r
                        Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
                        result.add(new VariableNode<Variable>(v, represents));\r
                }\r
-               for (Variable v : inputs) {\r
+               \r
+               for (String s : inputs.keySet()) {\r
+                       Variable v = inputs.get(s);\r
                        Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
                        result.add(new InputNode(v, represents));\r
                }\r
-               for (Variable v : modules) { \r
+               \r
+               for (String s : modules.keySet()) {\r
+                       Variable v = modules.get(s);\r
                        Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
                        result.add(new ModuleNode(v, represents));\r
                }\r
-               for (Variable v : enumerations) {\r
+               \r
+               for (String s : enumerations.keySet()) {\r
+                       Variable v = enumerations.get(s);\r
                        Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
                        result.add(new EnumerationNode(v, represents));\r
                }\r
index 87151394996dd77b890a6c018a3ca2ae9cf3e162..5cd6bbeeff727c0e1895fba170e0f6f9905241a4 100644 (file)
@@ -13,12 +13,14 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.TreeMap;\r
 \r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -26,6 +28,7 @@ import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode;
 import org.simantics.sysdyn.ui.browser.nodes.FunctionNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
 import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
+import org.simantics.utils.strings.AlphanumComparator;\r
 \r
 public class FunctionLibraries  extends ViewpointContributor<FunctionsFolder> {\r
 \r
@@ -38,16 +41,23 @@ public class FunctionLibraries  extends ViewpointContributor<FunctionsFolder> {
        \r
         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
         \r
-        // Find model functions\r
+               TreeMap<String, Resource> sortResult = new TreeMap<String, Resource>(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
+        // Find and sort model functions\r
         for(Resource function : graph.syncRequest(new ObjectsWithType(functionsFolder.data, l0.ConsistsOf, sr.SysdynModelicaFunction))) {\r
-               result.add(new FunctionNode(function));\r
+                       sortResult.put(NameUtils.getSafeName(graph, function), function);\r
         }\r
+               for(Resource function : sortResult.values())\r
+                       result.add(new FunctionNode(function));\r
         \r
-        // Find model function libraries\r
+        // Find and sort model function libraries\r
+               sortResult.clear();\r
         for(Resource functionLibrary : graph.syncRequest(new ObjectsWithType(functionsFolder.data, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) {\r
-               result.add(new FunctionLibraryNode<Resource>(functionLibrary));\r
-        }       \r
-        \r
+                       sortResult.put(NameUtils.getSafeName(graph, functionLibrary), functionLibrary);\r
+               }\r
+               for(Resource functionLibrary : sortResult.values())\r
+                       result.add(new FunctionLibraryNode<Resource>(functionLibrary));\r
+               \r
+               // Find built-in functions\r
         Resource sysdyn = graph.getPossibleResource("http://www.simantics.org/Sysdyn-1.1");\r
         if(sysdyn != null) {\r
                for(Resource library : graph.syncRequest(new ObjectsWithType(sysdyn, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) {\r
index c37ea4657f8e81f0e69a738141ebe92503f76d29..6e3a1a1fa6ddcec185a53897eca789af50fc34f9 100644 (file)
@@ -13,17 +13,20 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.TreeMap;\r
 \r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.FunctionNode;\r
+import org.simantics.utils.strings.AlphanumComparator;\r
 \r
 public class LibraryFunctions extends ViewpointContributor<FunctionLibraryNode<Resource>> {\r
 \r
@@ -32,16 +35,28 @@ public class LibraryFunctions extends ViewpointContributor<FunctionLibraryNode<R
                        FunctionLibraryNode<Resource> library) throws DatabaseException {\r
                Layer0 l0 = Layer0.getInstance(graph);\r
                ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+               \r
+               TreeMap<String, Resource> sortResult = new TreeMap<String, Resource>(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
+\r
+               // Find and sort functions in library\r
                for(Resource function : graph.syncRequest(new ObjectsWithType(library.data, l0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModelicaFunction))) {\r
-                       result.add(new FunctionNode(function));\r
+                       sortResult.put(NameUtils.getSafeName(graph, function), function);\r
                }\r
+               for(Resource function : sortResult.values())\r
+                       result.add(new FunctionNode(function));\r
+\r
+               // Find and sort libraries in library\r
+               sortResult.clear();\r
                for(Resource functionLibrary : graph.syncRequest(new ObjectsWithType(library.data, l0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModelicaFunctionLibrary))) {\r
-                       result.add(new FunctionLibraryNode<Resource>(functionLibrary));\r
+                       sortResult.put(NameUtils.getSafeName(graph, functionLibrary), functionLibrary);\r
                }\r
+               for(Resource functionLibrary : sortResult.values())\r
+                       result.add(new FunctionLibraryNode<Resource>(functionLibrary));\r
+               \r
                return result;\r
 \r
     }\r
-\r
+       \r
     @Override\r
     public String getViewpointId() {\r
         return "Standard";\r
index ed5a9ead174ae68949b9724168521b740d9107d8..4ebe335e712aea0e6c088e2fd67486ed2f4f33f2 100644 (file)
@@ -13,9 +13,11 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.TreeMap;\r
 \r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
@@ -29,6 +31,7 @@ import org.simantics.sysdyn.ui.browser.nodes.InputNode;
 import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+import org.simantics.utils.strings.AlphanumComparator;\r
 \r
 public class ModuleType extends ViewpointContributor<ModuleTypeNode> {\r
 \r
@@ -44,18 +47,39 @@ public class ModuleType extends ViewpointContributor<ModuleTypeNode> {
 \r
                if(instance == null) return result;\r
                Resource conf = graph.getSingleObject(instance, str.IsDefinedBy);\r
+               \r
+               // Independent variables\r
+               TreeMap<String, Resource> variables = new TreeMap<String, Resource>(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
                for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.IndependentVariable))) {\r
-                       result.add(new VariableNode<Resource>(r));\r
+                       variables.put((String)graph.getPossibleRelatedValue(r, l0.HasName, Bindings.STRING), r);\r
                }\r
+               for(String key : variables.keySet())\r
+                       result.add(new VariableNode<Resource>(variables.get(key)));\r
+               \r
+               // Inputs\r
+               variables.clear();\r
                for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Input))) {\r
-                       result.add(new InputNode(r));\r
+                       variables.put((String)graph.getPossibleRelatedValue(r, l0.HasName, Bindings.STRING), r);\r
                }\r
+               for(String key : variables.keySet())\r
+                       result.add(new InputNode(variables.get(key)));\r
+               \r
+               // Modules\r
+               variables.clear();\r
                for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Module))) {\r
-                       result.add(new ModuleNode(r));\r
+                       variables.put((String)graph.getPossibleRelatedValue(r, l0.HasName, Bindings.STRING), r);\r
                }\r
+               for(String key : variables.keySet())\r
+                       result.add(new ModuleNode(variables.get(key)));\r
+               \r
+               // Enumerations\r
+               variables.clear();\r
                for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Enumeration))) {\r
-                       result.add(new EnumerationNode(r));\r
+                       variables.put((String)graph.getPossibleRelatedValue(r, l0.HasName, Bindings.STRING), r);\r
                }\r
+               for(String key : variables.keySet())\r
+                       result.add(new EnumerationNode(variables.get(key)));\r
+               \r
                return result;\r
        }\r
 \r
index 4724a0d5c4ae713a228ac509f09e072e6a65019a..c32a30047fe77e5b3241fcfc90c5c429ca046e3a 100644 (file)
@@ -24,6 +24,8 @@ import org.simantics.graphviz.Edge;
 import org.simantics.graphviz.Graph;\r
 import org.simantics.graphviz.Node;\r
 import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
 \r
 /**\r
@@ -61,13 +63,21 @@ public class ModuleStructureGraphRequest implements Read<Graph> {
         // Model root was not found, return empty graph\r
         if(model == null)\r
             return g;\r
+        \r
+        // Find the parent module/model of the selected resource\r
+        Resource parentResource = graph.getPossibleObject(resource, l0.PartOf);\r
+        if(graph.isInstanceOf(parentResource, sr.ConfigurationDiagram)) {\r
+               parentResource = graph.getPossibleObject(parentResource, ModelingResources.getInstance(graph).DiagramToComposite);\r
+        } else if(graph.isInstanceOf(parentResource, sr.SysdynModel)) {\r
+               parentResource = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
+        }\r
 \r
         // Set root node\r
         Node rootNode = new Node(g, NameUtils.getSafeLabel(graph, model));\r
         rootNode.setShape("rectangle");\r
         HashSet<Resource> visited = new HashSet<Resource>();\r
         visited.add(model);\r
-        findChildModules(g, rootNode, graph, model, visited);\r
+        findChildModules(g, rootNode, graph, model, parentResource, visited);\r
 \r
 \r
         return g;\r
@@ -79,17 +89,23 @@ public class ModuleStructureGraphRequest implements Read<Graph> {
      * @param parent Parent module or model\r
      * @param graph ReadGraph\r
      * @param resource Module type or model\r
+     * @param parent2 \r
      * @param visited All visited modules. Needed to check for loops in the structure. Loops are not allowed.\r
      * @throws DatabaseException\r
      */\r
-    private void findChildModules(Graph g, Node parent, ReadGraph graph, Resource resource, HashSet<Resource> visited) throws DatabaseException {\r
+    private void findChildModules(Graph g, Node parent, ReadGraph graph, Resource resource, Resource parentResource, HashSet<Resource> visited) throws DatabaseException {\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r
         Layer0 l0 = Layer0.getInstance(graph);\r
 \r
+        Resource configuration = graph.syncRequest(new PossibleObjectWithType(resource, l0.ConsistsOf, sr.Configuration));\r
+\r
+        // Set the parent color different, if it is the parent of the selected resource\r
+        if(configuration.equals(parentResource))\r
+               parent.setColor("#ff8c00");\r
+        \r
         HashMap<Resource, Integer> modules = new HashMap<Resource, Integer>();\r
 \r
         // Find all module children\r
-        Resource configuration = graph.syncRequest(new PossibleObjectWithType(resource, l0.ConsistsOf, sr.Configuration));\r
         for(Resource m : graph.getObjects(configuration, l0.ConsistsOf)) {\r
             Resource type = graph.getPossibleObject(m, l0.InstanceOf);\r
             if(graph.isInheritedFrom(type, sr.Module)) {\r
@@ -120,8 +136,9 @@ public class ModuleStructureGraphRequest implements Read<Graph> {
                 node.setFontColor("#FF0000");\r
                 continue;\r
             } else {\r
-                visited.add(type);\r
-                findChildModules(g, node, graph, type, visited);\r
+               HashSet<Resource> copy = new HashSet<Resource>(visited);\r
+               copy.add(type);\r
+                findChildModules(g, node, graph, type, parentResource, copy);\r
             }\r
             \r
         }\r
index d0e8f385ec0942e17f05c82911fa019de90da30c..1c1852b1c01a3f553f62e17ef42295e28dc42a41 100644 (file)
@@ -352,7 +352,7 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment {
        protected static SimulationLocation createSimulationFiles(SysdynModel sysdynModel, String modelText, HashMap<String, String> inits, String additionalScript, boolean fmu) throws IOException {\r
                return ModelicaManager.createSimulationFiles(\r
                                sysdynModel.getSimulationDir(),\r
-                               sysdynModel.getConfiguration().getName(),\r
+                               sysdynModel.getConfiguration().getLabel(),\r
                                modelText,\r
                                inits,\r
                                additionalScript,\r
index 8bb2e09cd376813610eaeec5d32c9a210f604b03..f5918430342fe8f5c4e5cc89513366cb7490802e 100644 (file)
@@ -274,6 +274,8 @@ public class SysdynGameExperiment extends SysdynExperiment {
                                                for(int k = 0; k < subscription.length; k++) {\r
                                                        SysdynGameExperiment.this.results.get(subscription[k]).add(results[k]);\r
                                                }\r
+                                       } else {\r
+                                               monitor.worked(1);\r
                                        }\r
                                        stepNumber++;\r
                                        monitor.worked(1);\r
index 740ae5a2c3e7f1e86f04324e863ac998cfeb8899..3912a70eecd9cfac669eef243e6e3029ec538d33 100644 (file)
@@ -213,10 +213,6 @@ public class SysdynModel implements IMappingListener, IModel {
                     e.printStackTrace();\r
                 }\r
 \r
-                // Add the current result if there is one\r
-                if(getSysdynResult() != null)\r
-                    activeResults.add(0, getSysdynResult() );\r
-\r
                 return activeResults;\r
             }\r
 \r
@@ -224,6 +220,10 @@ public class SysdynModel implements IMappingListener, IModel {
 \r
             @Override\r
             public void execute(ArrayList<SysdynResult> result) {\r
+                // Add the current result if there is one\r
+                if(result != null && getSysdynResult() != null)\r
+                       result.add(0, getSysdynResult() );\r
+                \r
                 activeResults = result;\r
                 resultChanged();\r
             }\r
@@ -497,7 +497,7 @@ public class SysdynModel implements IMappingListener, IModel {
     public File getSimulationDir() {\r
         if(simulationDir == null) {\r
             File modelsDir = Activator.getBundleContext().getDataFile("models");\r
-            String configName = configuration.getName();\r
+            String configName = configuration.getLabel();\r
             List<String> files = Arrays.asList(modelsDir.list());\r
             if (files.contains(configName)) {\r
                 int i = 2;\r
index 090af57a0ec0607fce41b24622ca95f63b19693e..ea24ec7088d6815aedb3bf656d25eb20dbc7b307 100644 (file)
@@ -141,7 +141,7 @@ public class ModelicaWriter {
 \r
         // If the configuration is model configuration, use model name. Otherwise, use configuration name.\r
         ModuleType mt = configuration.getModuleType();\r
-        String className = mt != null ? (mt.getName().replace(" ", "")) : (configuration.getName().replace(" ", ""));\r
+        String className = mt != null ? (mt.getName().replace(" ", "")) : (configuration.getLabel().replace(" ", ""));\r
         \r
         b.append("class ").append(className);\r
         \r
index f13b4044d162d906ac156e693663293ca75a0347..00d0efb389b4ce36ef69466b91ceda286406b966 100644 (file)
@@ -75,7 +75,7 @@ public class Configuration {
     }\r
 \r
     public String getLabel() {\r
-        return label;\r
+        return label != null ? label : name;\r
     }\r
     \r
     public ModuleType getModuleType() {\r
index 15e3476653d363e5d41925d17e349d6a54bcf23c..f40cc43e35c1ea8886e18829142b1b16b7d8bb9e 100644 (file)
@@ -17,6 +17,7 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.sysdyn.representation.IndependentVariable;\r
 import org.simantics.sysdyn.representation.utils.FormatUtils;\r
 import org.simantics.sysdyn.representation.utils.IndexUtils;\r
+import org.simantics.sysdyn.representation.utils.SheetFormatUtils;\r
 \r
 /**\r
  * Representation of a withlookup expression\r
@@ -38,7 +39,7 @@ public class WithLookupExpression extends Expression {
        String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange());\r
 \r
         return \r
-        "    " + variable.getName() + (range.equals("[:]") ? "" : range) + " = interpolate(" + equation + ", " + lookupTable + ");\n";\r
+        "    " + variable.getName() + (range.equals("[:]") ? "" : range) + " = interpolate(" + equation + ", " + SheetFormatUtils.reformatSheetReferences(variable, lookupTable) + ");\n";\r
     }\r
     \r
     @Override\r
index df6b06ae087fc2d7c445844d9e14deadba8fe1af..ccb4d92e92821d9d05b1a563824976979458591d 100644 (file)
@@ -42,7 +42,7 @@ public class SimulationJob extends Job {
     IModelicaMonitor monitor;\r
 \r
     public SimulationJob(SysdynModel model, Experiment experiment) {\r
-        super("Simulate " + model.getConfiguration().getName());\r
+        super("Simulate " + model.getConfiguration().getLabel());\r
         this.model = model;\r
         this.experiment = experiment;\r
         if(PlatformUI.isWorkbenchRunning()) {\r
@@ -55,8 +55,8 @@ public class SimulationJob extends Job {
 \r
     @Override\r
     protected IStatus run(IProgressMonitor monitor) {\r
-        monitor.beginTask("Simulate " + model.getConfiguration().getName(), 5);        \r
-        this.monitor.message("Simulate " + model.getConfiguration().getName());\r
+        monitor.beginTask("Simulate " + model.getConfiguration().getLabel(), 5);        \r
+        this.monitor.message("Simulate " + model.getConfiguration().getLabel());\r
         try {\r
             model.update();\r
             if(experiment instanceof SysdynExperiment)\r