]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Merged /sysdyn/trunk:r30429-30524 to /sysdyn/branches/1.8 for sysdyn 1.8.2.
authorlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 6 Nov 2014 13:14:42 +0000 (13:14 +0000)
committerlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 6 Nov 2014 13:14:42 +0000 (13:14 +0000)
refs #5399
refs #5417
refs #5418
refs #5419
refs #5420
refs #5428
refs #5437
refs #5440
refs #5441

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/1.8@30525 ac1ea38d-2e2b-0410-8846-a27921b304fc

28 files changed:
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Assignment.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/CodeCache.java [new file with mode: 0644]
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ParameterDeclaration.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Parser.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/VariableDeclaration.java
org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java
org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/childrules/VariableChildRule.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/imagerules/VariableImageRule.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSCLModuleHandler.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ActiveDatasetsIndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/NamesIndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/TimesIndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java

index 67752379c360df09395883314cd46caa9e80ebdb..2a49d408bdf4f875ec1440536bc00ce9aaea828d 100644 (file)
@@ -18,7 +18,7 @@ public class Assignment {
        public Variable target;\r
        public IExpression[] subscripts;\r
     public IExpression expression;\r
-    public boolean assigned = false;\r
+    //public boolean assigned = false;\r
     public boolean isConstant = false;\r
     \r
     public Assignment(IFrame model, Variable target, IExpression[] subscripts, IExpression expression) {\r
@@ -44,13 +44,13 @@ public class Assignment {
        }\r
     }\r
     \r
-    public void assign(IEnvironment env) {\r
+    public void assign(Environment env) {\r
        try {\r
                        Object value = expression.evaluate(env);\r
                        if(value != null) {\r
                                validate(target, value);\r
                                target.assign(env, subscripts, value);\r
-                               assigned = true;\r
+                               env.setAssigned(this);\r
                        }\r
        } catch (ExecutionException e) {\r
                if(model instanceof Model) {\r
diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/CodeCache.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/CodeCache.java
new file mode 100644 (file)
index 0000000..f43cb99
--- /dev/null
@@ -0,0 +1,60 @@
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.io.StringReader;\r
+import java.util.HashMap;\r
+import java.util.LinkedList;\r
+import java.util.Map;\r
+\r
+import fi.semantum.sysdyn.solver.Model.Globals;\r
+import fi.semantum.sysdyn.solver.parser.ModelParser;\r
+import fi.semantum.sysdyn.solver.parser.ParseException;\r
+import fi.semantum.sysdyn.solver.parser.SimpleNode;\r
+\r
+public class CodeCache {\r
+\r
+       final static int CACHE_SIZE = 5;\r
+       \r
+       private static CodeCache INSTANCE;\r
+       \r
+       final Map<String,Model> models = new HashMap<String,Model>();\r
+       final LinkedList<String> codes = new LinkedList<String>();\r
+       \r
+       public static CodeCache getInstance() {\r
+               if(INSTANCE == null) INSTANCE = new CodeCache();\r
+               return INSTANCE;\r
+       }\r
+       \r
+       private CodeCache() {\r
+       }\r
+       \r
+       public Model getModel(String code) throws ParseException {\r
+               \r
+               Model model = models.get(code);\r
+               if(model == null) {\r
+\r
+                       StringReader reader = new StringReader(code);\r
+                       ModelParser modelParser = new ModelParser(reader);\r
+                       SimpleNode n = (SimpleNode)modelParser.stored_definition();\r
+\r
+                   Parser parser = new Parser();\r
+                   model = new Model(new Globals(), "", false);\r
+                       parser.walk(n, 0, model);\r
+                       \r
+                       model.prepare();\r
+                       model.prepareFunctions();\r
+                       model.sortAssignments();\r
+                       \r
+                       models.put(code, model);\r
+                       if(codes.size() == 5) {\r
+                               String last = codes.removeLast();\r
+                               models.remove(last);\r
+                               codes.addFirst(code);\r
+                       }\r
+                       \r
+               }\r
+               \r
+               return model;\r
+               \r
+       }\r
+       \r
+}\r
index 135410d7283d6e4f1abd23901ffdc2232c0e5ab2..247a93d1ec1de650078a55ef25c9ad58992f9f12 100644 (file)
@@ -734,4 +734,14 @@ final public class Environment implements IEnvironment, ISystem {
                put(index, value);\r
        }\r
        \r
+       public void setAssigned(Object ass) {\r
+               assigned.add(ass);\r
+       }\r
+       \r
+       public boolean isAssigned(Object o) {\r
+               return assigned.contains(o);\r
+       }\r
+       \r
+       private Set<Object> assigned = new HashSet<Object>();\r
+       \r
 }\r
index ab861d89034a5da8b5726e88d7f5a42ba512508c..ff2527ff19c28cd7304f1b0bfc3514028c4f6c85 100644 (file)
@@ -12,11 +12,19 @@ package fi.semantum.sysdyn.solver;
 \r
 import java.util.ArrayList;\r
 import java.util.Arrays;\r
+import java.util.Collections;\r
+import java.util.Comparator;\r
 import java.util.HashMap;\r
+import java.util.HashSet;\r
 import java.util.List;\r
 import java.util.Map;\r
+import java.util.Set;\r
 import java.util.TreeMap;\r
 \r
+import org.simantics.utils.datastructures.MapList;\r
+\r
+import fi.semantum.sysdyn.solver.IExpression.ExpressionVisitor;\r
+\r
 class Model implements IFrame {\r
        \r
        static class Globals {\r
@@ -41,9 +49,11 @@ class Model implements IFrame {
        public final Globals globals;\r
        \r
        public int line = -1;\r
-       public String name;\r
        public boolean isEnumClass;\r
        \r
+       private String name;\r
+       private int size;\r
+       \r
        public Model(Globals globals, String name, boolean isEnumClass) {\r
                this.globals = globals;\r
                this.name = name;\r
@@ -333,24 +343,28 @@ class Model implements IFrame {
                \r
                if(!done) throw new IllegalStateException();\r
                \r
-               int nextIndex = 0;\r
+               size = 0;\r
                for(Map.Entry<String, VariableBase> entry : names.entrySet()) {\r
                        VariableBase base = entry.getValue();\r
-                       base.index = nextIndex;\r
+                       base.index = size;\r
                        if(PRINT)\r
                                System.err.println("Variable: " + entry.getKey() + " " + base.index + " " + Arrays.toString(base.dimensions));\r
                        int dim = base.dimension();\r
                        if(dim == -1) dim = 1;\r
-                       nextIndex += dim;\r
+                       size += dim;\r
                }\r
                \r
                if(PRINT)\r
                        System.err.println("==================");\r
                \r
-               return nextIndex;\r
+               return size;\r
                \r
        }\r
        \r
+       public int getSize() {\r
+               return size;\r
+       }\r
+       \r
        public void prettyPrint() {\r
 \r
                System.err.println("initials");\r
@@ -441,4 +455,63 @@ class Model implements IFrame {
                \r
        }\r
        \r
+       public void prepareFunctions() {\r
+               \r
+               for(Fn fn : functions.values()) {\r
+                       if(fn instanceof Function)\r
+                               ((Function)fn).prepare();\r
+               }\r
+\r
+       }\r
+       \r
+       public void sortAssignments() {\r
+\r
+               final MapList<String,Assignment> asses = new MapList<String,Assignment>();\r
+               for(Assignment ass : assignments) asses.add(ass.target.base.name, ass);\r
+               \r
+               final List<VariableBase> found = new ArrayList<VariableBase>();\r
+               final Set<String> visited = new HashSet<String>();\r
+\r
+               ExpressionVisitor sortVisitor = new ExpressionVisitor() {\r
+                       @Override\r
+                       public void visit(IExpression expression) {\r
+                               if(expression instanceof Variable) {\r
+                                       Variable var = (Variable)expression;\r
+                                       if(visited.add(var.base.name)) {\r
+                                               for(Assignment ass : asses.getValues(var.base.name)) {\r
+                                                       ass.expression.accept(this);\r
+                                                       if(ass.subscripts != null)\r
+                                                               for(IExpression e : ass.subscripts) e.accept(this);\r
+                                               }\r
+                                               found.add(var.base);\r
+                                       }\r
+                               }\r
+                       }\r
+               };\r
+               \r
+               // Sort assignments\r
+               for(Assignment ass : assignments) {\r
+                       ass.target.accept(sortVisitor);\r
+               }\r
+\r
+               Collections.sort(assignments, new Comparator<Assignment>() {\r
+\r
+                       @Override\r
+                       public int compare(Assignment o1, Assignment o2) {\r
+                               int i1 = found.indexOf(o1.target.base); \r
+                               int i2 = found.indexOf(o2.target.base);\r
+                               if(i1 < i2) return -1;\r
+                               else if (i1 > i2) return 1;\r
+                               return 0;\r
+                       }\r
+\r
+                       \r
+               });\r
+               \r
+               assignmentArray = assignments.toArray(new Assignment[assignments.size()]);\r
+               derivativeArray = derivatives.toArray(new Assignment[derivatives.size()]);\r
+               parameterArray = parameters.toArray(new ParameterDeclaration[parameters.size()]);\r
+               \r
+       }\r
+       \r
 }
\ No newline at end of file
index 72cbab5e08ade7e3be89addaf70c2c97deba1e04..45ec0f0b5a22b8447c6b1e50fafbb914b5a26903 100644 (file)
@@ -17,7 +17,7 @@ public class ParameterDeclaration implements IExpression {
 \r
        public Variable variable;\r
        public IExpression modification;\r
-       public boolean assigned = false;\r
+//     public boolean assigned = false;\r
 \r
        public ParameterDeclaration(Variable variable, IExpression modification) {\r
                this.variable = variable;\r
index 32695d7417049f5454c02d48c93c459925b87dd5..3fe43ba4ec2baee554c745d0709de73f1b9dcc35 100644 (file)
@@ -365,7 +365,6 @@ public class Parser {
                                SimpleNode child = (SimpleNode)n.jjtGetChild(0);\r
                                String packagePath = getPackagePath(child);\r
                                String functionName = packagePath + child.op;\r
-                               System.err.println("function " + functionName + " at line " + child.line);\r
                                ArrayList<IStatement> stms2 = new ArrayList<IStatement>();\r
                                Function function = new Function(functionName, new StatementList(stms2), child.line);\r
                                ArrayList<Object> composition = (ArrayList<Object>)walk(child, indent+2, function);\r
index 80484a5608303380faa4de56761e03b812d1fe79..d33e12cc4671d2b762d8fd4af4333706940e2ee6 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
-import java.io.StringReader;\r
 import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
 \r
-import org.simantics.utils.datastructures.MapList;\r
-\r
-import fi.semantum.sysdyn.solver.IExpression.ExpressionVisitor;\r
-import fi.semantum.sysdyn.solver.Model.Globals;\r
-import fi.semantum.sysdyn.solver.parser.ModelParser;\r
 import fi.semantum.sysdyn.solver.parser.SimpleNode;\r
 \r
 public class Solver {\r
@@ -62,52 +51,6 @@ public class Solver {
                ready = false;\r
        }\r
        \r
-       private void sortAssignments() {\r
-\r
-               final MapList<String,Assignment> asses = new MapList<String,Assignment>();\r
-               for(Assignment ass : model.assignments) asses.add(ass.target.base.name, ass);\r
-               \r
-               final List<VariableBase> found = new ArrayList<VariableBase>();\r
-               final Set<String> visited = new HashSet<String>();\r
-\r
-               ExpressionVisitor sortVisitor = new ExpressionVisitor() {\r
-                       @Override\r
-                       public void visit(IExpression expression) {\r
-                               if(expression instanceof Variable) {\r
-                                       Variable var = (Variable)expression;\r
-                                       if(visited.add(var.base.name)) {\r
-                                               for(Assignment ass : asses.getValues(var.base.name)) {\r
-                                                       ass.expression.accept(this);\r
-                                                       if(ass.subscripts != null)\r
-                                                               for(IExpression e : ass.subscripts) e.accept(this);\r
-                                               }\r
-                                               found.add(var.base);\r
-                                       }\r
-                               }\r
-                       }\r
-               };\r
-               \r
-               // Sort assignments\r
-               for(Assignment ass : model.assignments) {\r
-                       ass.target.accept(sortVisitor);\r
-               }\r
-\r
-               Collections.sort(model.assignments, new Comparator<Assignment>() {\r
-\r
-                       @Override\r
-                       public int compare(Assignment o1, Assignment o2) {\r
-                               int i1 = found.indexOf(o1.target.base); \r
-                               int i2 = found.indexOf(o2.target.base);\r
-                               if(i1 < i2) return -1;\r
-                               else if (i1 > i2) return 1;\r
-                               return 0;\r
-                       }\r
-\r
-                       \r
-               });\r
-               \r
-       }\r
-\r
        private SimpleNode n;\r
        private String codeCache = null;\r
        \r
@@ -133,37 +76,32 @@ public class Solver {
                \r
                long startNanos = System.nanoTime();\r
                \r
-               if(!input.equals(codeCache)) {\r
+               model = CodeCache.getInstance().getModel(input);\r
                \r
-                       StringReader reader = new StringReader(input);\r
-                       ModelParser modelParser = new ModelParser(reader);\r
-                       n = (SimpleNode)modelParser.stored_definition();\r
+//             if(!input.equals(codeCache)) {\r
+//             \r
+//                     StringReader reader = new StringReader(input);\r
+//                     ModelParser modelParser = new ModelParser(reader);\r
+//                     n = (SimpleNode)modelParser.stored_definition();\r
+//\r
+//                 Parser parser = new Parser();\r
+//                 model = new Model(new Globals(), "", false);\r
+//                     parser.walk(n, 0, model);\r
+//                     \r
+//                     model.prepare();\r
+//                     model.prepareFunctions();\r
+//                     model.sortAssignments();\r
+//\r
+//                     codeCache = input;\r
+//\r
+//             }\r
                \r
-               }\r
-\r
-           Parser parser = new Parser();\r
-           model = new Model(new Globals(), "", false);\r
-               parser.walk(n, 0, model);\r
-               codeCache = input;\r
-\r
-               env = new Environment(model, defaultStep, start);\r
+               int size = model.getSize();\r
                \r
-               int size = model.prepare();\r
+               env = new Environment(model, defaultStep, start);\r
                env.setSize(size);\r
-               \r
-               for(Fn fn : model.functions.values()) {\r
-                       if(fn instanceof Function)\r
-                               ((Function)fn).prepare();\r
-               }\r
-               \r
                env.valueTable = new Object[size+STACK_SIZE];\r
                \r
-               sortAssignments();\r
-               \r
-               model.assignmentArray = model.assignments.toArray(new Assignment[model.assignments.size()]);\r
-               model.derivativeArray = model.derivatives.toArray(new Assignment[model.derivatives.size()]);\r
-               model.parameterArray = model.parameters.toArray(new ParameterDeclaration[model.parameters.size()]);\r
-               \r
                newValues = new Object[Math.max(model.assignments.size(),model.derivatives.size())];\r
                \r
                int condition = 1;\r
@@ -171,6 +109,10 @@ public class Solver {
                \r
                StringBuilder errors = null;\r
                \r
+               ArrayList<Assignment> assignments = new ArrayList<Assignment>();\r
+               assignments.addAll(model.assignments);\r
+               assignments.addAll(model.initials);\r
+\r
                while(condition > 0 && loops++ < MAX_LOOPS) {\r
 \r
                        if(loops == MAX_LOOPS) errors = new StringBuilder();\r
@@ -183,11 +125,11 @@ public class Solver {
 \r
                        for(ParameterDeclaration pd : model.parameters) {\r
                                try {\r
-                                       if(!pd.assigned) {\r
+                                       if(!env.isAssigned(pd)) {\r
                                                Object value = pd.modification.evaluate(env);\r
                                                validate(pd.variable, value);\r
                                                pd.variable.assign(env, null, value);\r
-                                               pd.assigned = true;\r
+                                               env.setAssigned(pd);\r
                                        }\r
                                } catch (Exception e) {\r
                                        String error = "  -" + pd.variable.toString() + ": " + e.getMessage();\r
@@ -203,13 +145,9 @@ public class Solver {
                                }\r
                        }\r
                        \r
-                       ArrayList<Assignment> assignments = new ArrayList<Assignment>();\r
-                       assignments.addAll(model.assignments);\r
-                       assignments.addAll(model.initials);\r
-\r
                        for(VariableDeclaration vd : model.variables) {\r
                                try {\r
-                                       if(!vd.assigned) {\r
+                                       if(!env.isAssigned(vd)) {\r
                                                for(Argument arg : vd.modification.args) {\r
                                                        if(arg.name.endsWith("start")) {\r
                                                                Object value = arg.modification.evaluate(env);\r
@@ -233,7 +171,7 @@ public class Solver {
                                                                // efficient way\r
                                                                for (Assignment a : assignments) {\r
                                                                        if (vd.variable.base.equals(a.target.base)) {\r
-                                                                               a.assigned = true;\r
+                                                                               env.setAssigned(a);\r
                                                                        }\r
                                                                }\r
                                                        }\r
@@ -255,7 +193,7 @@ public class Solver {
                        \r
                        for(Assignment ass : assignments) {\r
                                try {\r
-                                       if(!ass.assigned)\r
+                                       if(!env.isAssigned(ass))\r
                                                ass.assign(env);\r
                                } catch (Exception e) {\r
                                        String error = "  -" + ass.target.toString() + ": " + e.getMessage();\r
index 83958d394b8102aa4ad8fb0cf397ca1e239f5d86..eb92bfa5f2ea0df53017e5288ac0f29dcc3708af 100644 (file)
@@ -19,7 +19,7 @@ public class VariableDeclaration implements IExpression {
        public String direction;\r
        public String type;\r
        public ArgumentList modification;\r
-       public boolean assigned = false;\r
+//     public boolean assigned = false;\r
 \r
        public VariableDeclaration(Variable variable, String direction, String type, ArgumentList modification) {\r
                this.variable = variable;\r
index 4b6314ed606b3c6b35d06454b6da4fd1dce0bce4..7fc2b604c57246208eaadb2eb3f7cc0fea8d2247 100644 (file)
@@ -2,7 +2,10 @@ package org.simantics.jfreechart;
 \r
 public class ChartPropertyOptions {\r
        \r
-       public static final int SHOW_TIME   = 1 << 0;\r
-       public static final int SHOW_FILTER = 1 << 1;\r
+       public static final int SHOW_TIME      = 1 << 0;\r
+       public static final int SHOW_FILTER    = 1 << 1;\r
+       public static final int SHOW_VARIABLES = 1 << 2;\r
+       public static final int SHOW_AXIS      = 1 << 3;\r
+       public static final int SHOW_CHART     = 1 << 4;\r
 \r
 }\r
index df95e7144a3e43bacf2771df66f9da31582b96b9..48033d846c50d5b1d298879138f11dd0f7a5dd77 100644 (file)
@@ -24,7 +24,7 @@ import org.simantics.sysdyn.JFreeChartResource;
 public class ChartSelectionTabContributor {\r
 \r
        public static boolean contibuteTabs(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException{\r
-               return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME);\r
+               return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME|ChartPropertyOptions.SHOW_AXIS|ChartPropertyOptions.SHOW_VARIABLES|ChartPropertyOptions.SHOW_CHART);\r
        }\r
        public static boolean contibuteTabs(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs, int options) throws DatabaseException {\r
                JFreeChartResource jfree = JFreeChartResource.getInstance(backend);\r
@@ -45,45 +45,49 @@ public class ChartSelectionTabContributor {
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new XYLineAxisAndVariablesTab(r),\r
-                             9,\r
-                             r,\r
-                             "Axis and Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_AXIS )>0 ||(options&ChartPropertyOptions.SHOW_VARIABLES)>0 )\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new XYLineAxisAndVariablesTab(r),\r
+                                    9,\r
+                                    r,\r
+                                    "Axis and Variables"));\r
                  } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
                              new BarGeneralPropertiesTab(r, options),\r
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new BarSeriesTab(r, options),\r
-                             9,\r
-                             r,\r
-                             "Variables"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new BarAxisTab(r),\r
-                             8,\r
-                             r,\r
-                             "Axis"));                        \r
+                     if ((options&ChartPropertyOptions.SHOW_VARIABLES )>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new BarSeriesTab(r, options),\r
+                                    9,\r
+                                    r,\r
+                                    "Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_AXIS )>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new BarAxisTab(r),\r
+                                    8,\r
+                                    r,\r
+                                    "Axis"));                        \r
                  } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
                              new PieGeneralPropertiesTab(r, options),\r
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new PieSeriesTab(r, options),\r
-                             9,\r
-                             r,\r
-                             "Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_VARIABLES )>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new PieSeriesTab(r, options),\r
+                                    9,\r
+                                    r,\r
+                                    "Variables"));\r
                  }\r
-\r
-                 tabs.add(new ComparableTabContributor(\r
-                         new ChartTab(r),\r
-                         1,\r
-                         r,\r
-                         "Chart"));\r
+                 if ((options&ChartPropertyOptions.SHOW_CHART )>0)\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new ChartTab(r),\r
+                                1,\r
+                                r,\r
+                                "Chart"));\r
                 \r
                  return true;\r
              } \r
@@ -92,7 +96,7 @@ public class ChartSelectionTabContributor {
        }\r
        \r
        public static boolean contibuteTabs2(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException{\r
-               return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME);\r
+               return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME|ChartPropertyOptions.SHOW_AXIS|ChartPropertyOptions.SHOW_VARIABLES|ChartPropertyOptions.SHOW_CHART);\r
        }\r
        \r
        public static boolean contibuteTabs2(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs, int options) throws DatabaseException {\r
@@ -114,45 +118,49 @@ public class ChartSelectionTabContributor {
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new XYLineAxisAndVariablesTab(r),\r
-                             9,\r
-                             r,\r
-                             "Axis and Variables"));\r
-                 } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
-                     tabs.add(new ComparableTabContributor(\r
+                     if ((options&ChartPropertyOptions.SHOW_AXIS )>0 ||(options&ChartPropertyOptions.SHOW_VARIABLES)>0 )\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new XYLineAxisAndVariablesTab(r),\r
+                                    9,\r
+                                    r,\r
+                                    "Axis and Variables"));\r
+                               } else if (backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
+                                       tabs.add(new ComparableTabContributor(\r
                              new BarGeneralPropertiesTab(r, options),\r
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new BarSeriesTab2(r, options),\r
-                             9,\r
-                             r,\r
-                             "Variables"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new BarAxisTab(r),\r
-                             8,\r
-                             r,\r
-                             "Axis"));                        \r
+                     if ((options&ChartPropertyOptions.SHOW_VARIABLES)>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new BarSeriesTab2(r, options),\r
+                                    9,\r
+                                    r,\r
+                                    "Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_AXIS )>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new BarAxisTab(r),\r
+                                    8,\r
+                                    r,\r
+                                    "Axis"));                        \r
                  } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
                              new PieGeneralPropertiesTab(r, options),\r
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new PieSeriesTab2(r, options),\r
-                             9,\r
-                             r,\r
-                             "Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_VARIABLES)>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new PieSeriesTab2(r, options),\r
+                                    9,\r
+                                    r,\r
+                                    "Variables"));\r
                  }\r
-\r
-                 tabs.add(new ComparableTabContributor(\r
-                         new ChartTab(r),\r
-                         1,\r
-                         r,\r
-                         "Chart"));\r
+                 if ((options&ChartPropertyOptions.SHOW_CHART )>0)\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new ChartTab(r),\r
+                                1,\r
+                                r,\r
+                                "Chart"));\r
                 \r
                  return true;\r
              } \r
index 4b49d0567142e800684ab25ebaf09725e0982e9e..fa218087b2d4136b6810b875973ba0baade063d2 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index eda75ae22e18c07ad70ff1d21df19898cb3c65b2..ffd674d8c42cf494e589ad99d4a4ea3891b063df 100644 (file)
@@ -437,7 +437,7 @@ SYSDYN.HistoryDataset <T SYSDYN.Result
 SYSDYN.ResultSet <T L0.Entity
     >-- SYSDYN.Experiment.result --> SYSDYN.Result <R L0.IsComposedOf
 
-SYSDYN.InitialCondition <T SIMU.State
+SYSDYN.InitialCondition <T MOD.InitialCondition
     >-- SYSDYN.InitialCondition.HasInitialValues --> MOD.PartialIC <R L0.HasProperty : L0.FunctionalRelation
 
 
index 3cac4f5ea6b80ee9858cb227aec41d8972a90cda..7bf5389964da7b093e9b1bd7f68e7f5762d431a9 100644 (file)
                      checkEnabled="true">\r
                   <with\r
                         variable="selection">\r
+                        <or>\r
                      <test\r
                            args="org.simantics.sysdyn.ui.browser.nodes.SCLModulesFolder"\r
                            property="org.simantics.sysdyn.ui.nodeClass">\r
                      </test>\r
+                 <test\r
+                       args="http://www.simantics.org/Layer0-0.0/SharedOntology"\r
+                       property="org.simantics.graph.resourceType"\r
+                       value="true">\r
+                 </test>\r
+                 <test\r
+                       args="http://www.simantics.org/Layer0-0.0/Library"\r
+                       property="org.simantics.graph.resourceType"\r
+                       value="true">\r
+                 </test>\r
+                 <test\r
+                       args="http://www.simantics.org/Simulation-0.0/Model"\r
+                       property="org.simantics.graph.resourceType"\r
+                       value="true">\r
+                 </test>\r
+                     </or>\r
                   </with>\r
                </visibleWhen>\r
             </command>\r
                         args="org.simantics.sysdyn.ui.browser.nodes.SCLModulesFolder"\r
                         property="org.simantics.sysdyn.ui.nodeClass">\r
                   </test>\r
+                 <test\r
+                       args="http://www.simantics.org/Layer0-0.0/SharedOntology"\r
+                       property="org.simantics.graph.resourceType"\r
+                       value="true">\r
+                 </test>\r
+                 <test\r
+                       args="http://www.simantics.org/Layer0-0.0/Library"\r
+                       property="org.simantics.graph.resourceType"\r
+                       value="true">\r
+                 </test>\r
+                 <test\r
+                       args="http://www.simantics.org/Simulation-0.0/Model"\r
+                       property="org.simantics.graph.resourceType"\r
+                       value="true">\r
+                 </test>\r
                </or>\r
             </with>\r
          </activeWhen>\r
index e5e308acf4d64a9c60f7a3d8989f5e1c513a3088..72d6a34d76165b49b7dc34f1fcb22edabb1bd840 100644 (file)
@@ -69,7 +69,7 @@ public class ChartDropAction implements DropActionFactory {
                             if(variable == null)\r
                                 continue;\r
 \r
-                            Resource represents = (Resource)variable.getPropertyValue(graph, Variables.REPRESENTS);\r
+                            Resource represents = (Resource)variable.getRepresents(graph);\r
                             if(represents == null || \r
                                     !(graph.isInstanceOf(represents, sr.IndependentVariable) || \r
                                             graph.isInstanceOf(represents, sr.Input)))\r
index 270ad2280390c35b3ea413a4378203ec9ef37918..783961af6d17aba70cdb170ae176793733eef01c 100644 (file)
@@ -59,7 +59,7 @@ public class VariableChildRule implements ChildRule {
         ArrayList<Variable> variables = new ArrayList<Variable>();\r
 \r
         for(Variable child : variable.getChildren(graph)) {\r
-            Resource represents = (Resource)child.getPropertyValue(graph, Variables.REPRESENTS);\r
+            Resource represents = child.getRepresents(graph);\r
             if(graph.isInstanceOf(represents, sr.IndependentVariable)) {\r
                 variables.add(child);\r
             } else if (graph.isInstanceOf(represents, sr.Input)) {\r
index fdb9ee0b608cd9fa8e77b622b1dc5d336f5ef412..659f63f24a55010b225504c68caf15c0a9f6b25e 100644 (file)
@@ -52,7 +52,7 @@ public class Configuration extends ViewpointContributor<ConfigurationNode<Resour
 \r
 \r
                for(Variable child : variable.getChildren(graph)) {\r
-                       Resource represents = (Resource)child.getPropertyValue(graph, Variables.REPRESENTS);\r
+                       Resource represents = child.getRepresents(graph);\r
                        if(graph.isInstanceOf(represents, sr.IndependentVariable)) {\r
                                variables.put(child.getName(graph), child);\r
                        } else if (graph.isInstanceOf(represents, sr.Input)) {\r
@@ -66,25 +66,25 @@ public class Configuration extends ViewpointContributor<ConfigurationNode<Resour
                \r
                for (String s : variables.keySet()) {\r
                        Variable v = variables.get(s);\r
-                       Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
+                       Resource represents = v.getRepresents(graph);\r
                        result.add(new VariableNode<Variable>(v, represents));\r
                }\r
                \r
                for (String s : inputs.keySet()) {\r
                        Variable v = inputs.get(s);\r
-                       Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
+                       Resource represents = v.getRepresents(graph);\r
                        result.add(new InputNode(v, represents));\r
                }\r
                \r
                for (String s : modules.keySet()) {\r
                        Variable v = modules.get(s);\r
-                       Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
+                       Resource represents = v.getRepresents(graph);\r
                        result.add(new ModuleNode(v, represents));\r
                }\r
                \r
                for (String s : enumerations.keySet()) {\r
                        Variable v = enumerations.get(s);\r
-                       Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
+                       Resource represents = v.getRepresents(graph);\r
                        result.add(new EnumerationNode(v, represents));\r
                }\r
                \r
index ba780a646d131d297aa037c45963bb8e9bc2f75f..7c1b577952d76f3084c1e80f90b5069ddb520dc7 100644 (file)
@@ -21,7 +21,6 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 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.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.Activator;\r
@@ -40,7 +39,7 @@ public class VariableImageRule implements ImageRule {
 \r
         String image =  "icons/brick.png";\r
         \r
-        Resource r =  (Resource)var.getPropertyValue(graph, Variables.REPRESENTS);\r
+        Resource r =  var.getRepresents(graph);\r
         if(r != null) {\r
             Layer0 L0 = Layer0.getInstance(graph);\r
             SysdynResource sr = SysdynResource.getInstance(graph);\r
index a026c31b1301d52858711ace27a977e2e58898e6..7dee59c845b8348c9503b2b393b7401367a7040b 100644 (file)
@@ -25,11 +25,16 @@ public class NewSCLModuleHandler  extends AbstractHandler {
         ISelection sel = HandlerUtil.getCurrentSelection(event);\r
         \r
         @SuppressWarnings("unchecked")\r
-               AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
-        if (node == null)\r
-            return null;\r
+               Resource res = AdaptionUtils.adaptToSingle(sel, Resource.class);\r
+        if(res == null) {\r
+               @SuppressWarnings("unchecked")\r
+                       AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
+               if (node == null)\r
+                       return null;\r
+               res = node.data;\r
+        }\r
 \r
-        final Resource parent = node.data;\r
+        final Resource parent = res;\r
         \r
         SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
                \r
index 4b57b97d3257b1bd34a5aca5c37b3cf981c12a41..3039cea702b56a51f730018e5751cbf98d3eaeb7 100644 (file)
@@ -2,6 +2,7 @@ package org.simantics.sysdyn.adapter;
 \r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.List;\r
 \r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.WriteGraph;\r
@@ -26,8 +27,8 @@ public class ActiveDatasetsIndexVariable extends IndexVariable< ArrayList<DataSe
                        return datasets;\r
 \r
                Collection<SysdynResult> results = experiment.getActiveResults();\r
-               ArrayList<String> variableNamesWithIndexes = getVariableNamesWithIndexNumbers();\r
-               ArrayList<String> variableNames = getVariableNames();\r
+               List<String> variableNamesWithIndexes = getVariableNamesWithIndexNumbers();\r
+               List<String> variableNames = getVariableNames();\r
 \r
                for(int i = 0; i < variableNamesWithIndexes.size(); i++) {\r
                        for(SysdynResult result : results) {\r
index bf71e39fd2d4e3fd5e4bc5154a52225323e73d90..4211a80a91e361e71ea2c484753746d945cba24c 100644 (file)
@@ -1,7 +1,9 @@
 package org.simantics.sysdyn.adapter;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.HashMap;\r
+import java.util.List;\r
 \r
 import org.simantics.Simantics;\r
 import org.simantics.databoard.Bindings;\r
@@ -38,7 +40,7 @@ public abstract class IndexVariable<T> extends AbstractPropertyVariable {
        protected HashMap<String, String> rvis;\r
        protected String indexes;\r
        protected VariableSubscriptionManager subscriptionManager;\r
-       protected Pair<ArrayList<String>,ArrayList<String>> variableNameArrays;\r
+       private Pair<List<String>,List<String>> variableNameArrays;\r
        \r
        public IndexVariable(ReadGraph graph, Variable parent, String indexes) throws DatabaseException {\r
                this.parent = parent;\r
@@ -208,28 +210,53 @@ public abstract class IndexVariable<T> extends AbstractPropertyVariable {
                \r
        }\r
        \r
-       private Pair<ArrayList<String>,ArrayList<String>> getVariableNameArrays() {\r
+       private Pair<List<String>,List<String>> getVariableNameArrays() {\r
                \r
                if(variableNameArrays == null) {\r
                \r
-                       Pair<ArrayList<String>,ArrayList<String>> result = new Pair<ArrayList<String>,ArrayList<String>>(new ArrayList<String>(), new ArrayList<String>());\r
                        if(rvi != null && rvis != null) {\r
                        \r
                        if(rvi.indexOf('#') > 0)\r
                                rvi = rvi.substring(0, rvi.indexOf('#'));\r
                        \r
+                       boolean regexp = false;\r
                        String test = rvi;\r
                        if(indexes != null && !indexes.isEmpty()) {\r
-                               String regexIndexes = indexes.trim().replaceAll(":", "[a-zA-Z0-9_]*"); // Why was there was ".replace('.', ',')" ? - Removed by Teemu 2.9.2012\r
-                               test = rvi + "\\[" + regexIndexes + "\\]";\r
+                               regexp = indexes.contains(":");\r
+                               if(regexp) {\r
+                                       String regexIndexes = indexes.trim().replaceAll(":", "[a-zA-Z0-9_]*"); // Why was there was ".replace('.', ',')" ? - Removed by Teemu 2.9.2012\r
+                                       test = rvi + "\\[" + regexIndexes + "\\]";\r
+                               } else {\r
+                                       test = rvi + "[" + indexes + "]";\r
+                               }\r
                        } else {\r
                                test = rvi + "(\\[.*\\])?";\r
+                               regexp = true;\r
                        }\r
-                       for(String k : rvis.keySet()) {\r
-                               String value = rvis.get(k);\r
-                               if(k.matches(test) || value.matches(test)) {\r
-                                       result.first.add(k.substring(1).replace("/", ".").replace("%20", "_"));\r
-                                       result.second.add(value.substring(1).replace("/", ".").replace("%20", " "));\r
+                       \r
+                       Pair<List<String>,List<String>> result = null;\r
+                       \r
+                       if(regexp) {\r
+                                       result = new Pair<List<String>,List<String>>(new ArrayList<String>(), new ArrayList<String>());\r
+                               for(String k : rvis.keySet()) {\r
+                                       String value = rvis.get(k);\r
+                                       if(k.matches(test) || value.matches(test)) {\r
+                                               result.first.add(transform(k));\r
+                                               result.second.add(transform(value));\r
+                                       }\r
+                               }\r
+                       } else {\r
+                               String value = rvis.get(test);\r
+                               if(value != null) {\r
+                                       result = new Pair<List<String>,List<String>>(Collections.singletonList(transform(test)), Collections.singletonList(transform(value)));\r
+                               } else {\r
+                                       for(String k : rvis.keySet()) {\r
+                                               value = rvis.get(k);\r
+                                               if(value.equals(test)) {\r
+                                                       result = new Pair<List<String>,List<String>>(Collections.singletonList(transform(k)), Collections.singletonList(transform(test)));\r
+                                                       break;\r
+                                               }\r
+                                       }\r
                                }\r
                        }\r
                        \r
@@ -239,17 +266,21 @@ public abstract class IndexVariable<T> extends AbstractPropertyVariable {
                \r
                }\r
                \r
-               if(variableNameArrays == null) return new Pair<ArrayList<String>,ArrayList<String>>(new ArrayList<String>(), new ArrayList<String>());\r
+               if(variableNameArrays == null) return new Pair<List<String>,List<String>>(new ArrayList<String>(), new ArrayList<String>());\r
                \r
                return variableNameArrays;\r
                \r
        }\r
        \r
-       protected ArrayList<String> getVariableNames() {\r
+       private String transform(String s) {\r
+               return s.substring(1).replace("/", ".").replace("%20", "_");\r
+       }\r
+       \r
+       protected List<String> getVariableNames() {\r
                return getVariableNameArrays().second;\r
        }\r
        \r
-       protected ArrayList<String> getVariableNamesWithIndexNumbers() {\r
+       protected List<String> getVariableNamesWithIndexNumbers() {\r
                return getVariableNameArrays().first;\r
        }\r
        \r
@@ -267,19 +298,12 @@ public abstract class IndexVariable<T> extends AbstractPropertyVariable {
        }\r
 \r
        abstract protected void setIndexedValue(WriteGraph graph, Object value) throws DatabaseException;\r
-       \r
-\r
 \r
        @Override\r
        public String getName(ReadGraph graph) throws DatabaseException {\r
                return indexes;\r
        }\r
 \r
-       @Override\r
-       public Object getSerialized(ReadGraph graph) throws DatabaseException {\r
-               return indexes;\r
-       }\r
-\r
        @Override\r
        public Variable getParent(ReadGraph graph) throws DatabaseException {\r
                return parent;\r
index 7e32bbad004d629fae432f9f40968ff6bcba8f6d..2ef5afa33e5ad743ddf671d58834946076bc70f0 100644 (file)
@@ -1,6 +1,7 @@
 package org.simantics.sysdyn.adapter;\r
 \r
 import java.util.ArrayList;\r
+import java.util.List;\r
 \r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.WriteGraph;\r
@@ -16,7 +17,7 @@ public class NamesIndexVariable extends IndexVariable<String[]> {
 \r
        @Override\r
        public String[] getValue() {\r
-               ArrayList<String> names = getVariableNames();\r
+               List<String> names = getVariableNames();\r
                return names.toArray(new String[names.size()]);\r
        }\r
 \r
index 329e4cd2947a56ee935471bce302ad91c37c89f1..57e2e12547a6b6b0ed4c3b57bb26a31a110ee924 100644 (file)
@@ -1,7 +1,7 @@
 package org.simantics.sysdyn.adapter;\r
 \r
-import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.List;\r
 \r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.WriteGraph;\r
@@ -24,7 +24,7 @@ public class TimesIndexVariable extends IndexVariable<double[][]> {
                return new double[0][0];\r
            \r
            Collection<SysdynResult> results = experiment.getActiveResults();\r
-           ArrayList<String> variableNames = getVariableNamesWithIndexNumbers();\r
+           List<String> variableNames = getVariableNamesWithIndexNumbers();\r
 \r
            double[][] result = new double[variableNames.size()][];\r
            for(int i = 0; i < variableNames.size(); i++) {\r
index cbb948bca58ae4c2417d3eb64388bd5f85bd0a51..53db9ef8d77b78849ce5ce8d540ff6aec69be387 100644 (file)
@@ -1,7 +1,7 @@
 package org.simantics.sysdyn.adapter;\r
 \r
-import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.List;\r
 \r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -46,7 +46,7 @@ abstract public class ValueIndexVariableBase<T> extends IndexVariable<T> {
 \r
            \r
         Collection<SysdynResult> results = experiment.getActiveResults();\r
-               ArrayList<String> variableNames = getVariableNamesWithIndexNumbers();\r
+               List<String> variableNames = getVariableNamesWithIndexNumbers();\r
 \r
                double[] result = new double[variableNames.size()];\r
                for(int i = 0; i < variableNames.size(); i++) {\r
@@ -101,7 +101,7 @@ abstract public class ValueIndexVariableBase<T> extends IndexVariable<T> {
 \r
                        try {\r
                        \r
-                               ArrayList<String> variableNames = getVariableNamesWithIndexNumbers();\r
+                               List<String> variableNames = getVariableNamesWithIndexNumbers();\r
                                for(int i = 0; i < variableNames.size() && i < values.length; i++) {\r
 \r
                                        if(values[i] == Double.NaN)\r
index baed93ed56d375a65518807c479937a72444efe2..229cb172e87b4def27adeba7bfeb6ea80e002579 100644 (file)
@@ -45,11 +45,6 @@ public class  ValueIndexVariableI extends ValueIndexVariableBase<Double> {
                return "$" + index;\r
        }\r
        \r
-       @Override\r
-       public Object getSerialized(ReadGraph graph) throws DatabaseException {\r
-               return "$" + index;\r
-       }\r
-       \r
        @Override\r
        public Datatype getDatatype(ReadGraph graph) throws DatabaseException {\r
                return Datatypes.DOUBLE;\r
index d0eb203211131a0e690262c92d5e0b02c69cee25..2ed53f3f42e5503eddc3c0a53dd4f6684e8dfeb3 100644 (file)
@@ -1,7 +1,7 @@
 package org.simantics.sysdyn.adapter;\r
 \r
-import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.List;\r
 \r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.WriteGraph;\r
@@ -20,7 +20,7 @@ public class ValuesIndexVariable extends IndexVariable<double[][]> {
 \r
        @Override\r
        public double[][] getValue() {\r
-        ArrayList<String> variableNames = getVariableNamesWithIndexNumbers();\r
+        List<String> variableNames = getVariableNamesWithIndexNumbers();\r
         double[][] result = new double[variableNames.size()][];\r
 \r
         if (experiment != null) {\r
index 7b6a68bcd492a97c28f56770bd12aa1a71e8acb0..986e2cc9453f5919d562a58b8212021c276756fb 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.adapter;\r
 \r
+import gnu.trove.map.hash.THashMap;\r
+\r
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.LinkedHashMap;\r
 import java.util.List;\r
+import java.util.Map;\r
 \r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
@@ -25,6 +28,8 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.VariableRead;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.request.ReadExt;\r
+import org.simantics.db.request.RequestFlags;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.manager.SysdynDataSet;\r
@@ -151,18 +156,18 @@ public class VariableRVIUtils {
     }\r
 \r
 \r
-    /**\r
-     * Returns rvis in a map in format /ModuleInstance/Variable[1] = /ModuleInstance/Variable[index1]\r
-     * @param graph ReadGraph\r
-     * @param variable Variable for the rvis\r
-     * @return rvis in a map. Keys are numerical formatted array indexes and values are textual.\r
-     * @throws DatabaseException\r
-     */\r
-    public static HashMap<String, String> getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException {\r
-        return graph.syncRequest(new GetActiveRVIs(variable));\r
-    }\r
+//    /**\r
+//     * Returns rvis in a map in format /ModuleInstance/Variable[1] = /ModuleInstance/Variable[index1]\r
+//     * @param graph ReadGraph\r
+//     * @param variable Variable for the rvis\r
+//     * @return rvis in a map. Keys are numerical formatted array indexes and values are textual.\r
+//     * @throws DatabaseException\r
+//     */\r
+//    public static HashMap<String, String> getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException {\r
+//        return graph.syncRequest(new GetActiveRVIs(variable));\r
+//    }\r
     \r
-    public static class GetActiveRVIs extends VariableRead<HashMap<String, String>> {\r
+    public static class GetActiveRVIs extends VariableRead<HashMap<String, String>> implements ReadExt {\r
 \r
         public GetActiveRVIs(Variable variable) {\r
             super(variable);\r
@@ -192,6 +197,16 @@ public class VariableRVIUtils {
             }\r
             return rvis;\r
         }\r
+\r
+               @Override\r
+               public boolean isImmutable(ReadGraph graph) throws DatabaseException {\r
+                       return false;\r
+               }\r
+\r
+               @Override\r
+               public int getType() {\r
+                       return RequestFlags.IMMEDIATE_UPDATE;\r
+               }\r
     }\r
 \r
     \r
@@ -244,7 +259,7 @@ public class VariableRVIUtils {
             String currentFilter = filter[i].trim();\r
             \r
             ArrayList<SysdynDataSet> tempResult = new ArrayList<SysdynDataSet>();\r
-            HashMap<String, SysdynDataSet> sums = new HashMap<String, SysdynDataSet>();\r
+            Map<String, SysdynDataSet> sums = new THashMap<String, SysdynDataSet>();\r
             for(SysdynDataSet dataset : result) {\r
                 String tempIndexes = dataset.name.substring(dataset.name.indexOf('[') + 1, dataset.name.indexOf(']'));\r
                 String[] indexes = tempIndexes.split(",");\r
index 7bf5b1ff40172fa90bfb75dcd114cf9cdb44ee79..7b1c550be9c56242b312746733891a56e4db96c8 100644 (file)
@@ -238,6 +238,14 @@ public class SysdynExperiments {
                        }\r
                        \r
                    }, new DefaultPasteHandler(ic));\r
+                   \r
+//                 String id = input.getName(graph);\r
+//                 SCLRealm realm = SCLSessionManager.sclRealmById(id);\r
+//                 if(realm != null) {\r
+//                     byte[] blob = realm.serialize();\r
+//                             //graph.addLiteral(ic, SYSDYN.InitialCondition_HasInitialValues, SYSDYN.InitialCondition_HasInitialValues_Inverse, MOD.PartialIC, IC, PartialIC.BINDING);\r
+//                 }\r
+                   \r
                }\r
                \r
                Layer0Utils.addCommentMetadata(graph, "Saved new Initial Condition " + name + " " + ic);\r
index b8b06837bb56871ae0ae391a4f597a4af2fc4303..b2c4b7164a0582dcd6c3d030bf4b7652684f1080 100644 (file)
@@ -22,11 +22,12 @@ import org.simantics.db.common.request.UniqueRead;
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.exception.MissingVariableException;\r
 import org.simantics.db.layer0.util.EvaluatingListener;\r
 import org.simantics.db.layer0.util.EvaluatingListener.Criterion;\r
 import org.simantics.db.layer0.util.EvaluatingListener.Evaluation;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.request.ReadExt;\r
+import org.simantics.db.request.RequestFlags;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.scl.runtime.function.FunctionImpl1;\r
@@ -618,27 +619,42 @@ public class DocumentationUtils {
 \r
     }\r
     \r
-    public static class LastValueIndexed extends BinaryRead<Resource, String, org.simantics.db.layer0.variable.Variable> {\r
+    public static class LastValueIndexed extends BinaryRead<org.simantics.db.layer0.variable.Variable, String, org.simantics.db.layer0.variable.Variable> implements ReadExt {\r
 \r
-        public LastValueIndexed(Resource resource, String path) {\r
-            super(resource, path);\r
+        public LastValueIndexed(org.simantics.db.layer0.variable.Variable run, String path) {\r
+            super(run, path);\r
         }\r
 \r
         @Override\r
         public org.simantics.db.layer0.variable.Variable perform(ReadGraph graph) throws DatabaseException {\r
             \r
-            org.simantics.db.layer0.variable.Variable run = Variables.getVariable(graph, parameter);\r
-            Pair<String, String> nameAndIndices = splitToNameAndIndices(parameter2);\r
-            org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second);\r
-            if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2);\r
-            return v;\r
+               try {\r
+                   Pair<String, String> nameAndIndices = splitToNameAndIndices(parameter2);\r
+                   org.simantics.db.layer0.variable.Variable v = parameter.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second);\r
+                   //if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2);\r
+                   if(v == null) return null;\r
+                   return v;\r
+               } catch (Throwable e) {\r
+                       throw new DatabaseException(e);\r
+               }\r
         }\r
+\r
+               @Override\r
+               public boolean isImmutable(ReadGraph graph) throws DatabaseException {\r
+                       return false;\r
+               }\r
+\r
+               @Override\r
+               public int getType() {\r
+                       return RequestFlags.IMMEDIATE_UPDATE;\r
+               }\r
+        \r
     }\r
     \r
     \r
     public static org.simantics.db.layer0.variable.Variable lastValueIndexed(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException {\r
        if(run == null) return null;\r
-       return graph.syncRequest(new LastValueIndexed(run.getRepresents(graph), path));\r
+       return graph.syncRequest(new LastValueIndexed(run, path));\r
     }    \r
     \r
     public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException {\r