From f92c40a007ae746f7ece2b26ccdb2143e315a670 Mon Sep 17 00:00:00 2001 From: lehtonen Date: Thu, 6 Nov 2014 13:14:42 +0000 Subject: [PATCH] Merged /sysdyn/trunk:r30429-30524 to /sysdyn/branches/1.8 for sysdyn 1.8.2. 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 --- .../fi/semantum/sysdyn/solver/Assignment.java | 6 +- .../fi/semantum/sysdyn/solver/CodeCache.java | 60 +++++++++ .../semantum/sysdyn/solver/Environment.java | 10 ++ .../src/fi/semantum/sysdyn/solver/Model.java | 83 +++++++++++- .../sysdyn/solver/ParameterDeclaration.java | 2 +- .../src/fi/semantum/sysdyn/solver/Parser.java | 1 - .../src/fi/semantum/sysdyn/solver/Solver.java | 120 +++++------------- .../sysdyn/solver/VariableDeclaration.java | 2 +- .../jfreechart/ChartPropertyOptions.java | 7 +- .../ChartSelectionTabContributor.java | 120 ++++++++++-------- org.simantics.sysdyn.ontology/graph.tg | Bin 182810 -> 182821 bytes .../graph/Sysdyn.pgraph | 2 +- org.simantics.sysdyn.ui/plugin.xml | 32 +++++ .../browser/actions/drop/ChartDropAction.java | 2 +- .../browser/childrules/VariableChildRule.java | 2 +- .../browser/contributions/Configuration.java | 10 +- .../browser/imagerules/VariableImageRule.java | 3 +- .../ui/handlers/NewSCLModuleHandler.java | 13 +- .../adapter/ActiveDatasetsIndexVariable.java | 5 +- .../sysdyn/adapter/IndexVariable.java | 64 +++++++--- .../sysdyn/adapter/NamesIndexVariable.java | 3 +- .../sysdyn/adapter/TimesIndexVariable.java | 4 +- .../adapter/ValueIndexVariableBase.java | 6 +- .../sysdyn/adapter/ValueIndexVariableI.java | 5 - .../sysdyn/adapter/ValuesIndexVariable.java | 4 +- .../sysdyn/adapter/VariableRVIUtils.java | 39 ++++-- .../sysdyn/manager/SysdynExperiments.java | 8 ++ .../sysdyn/utils/DocumentationUtils.java | 36 ++++-- 28 files changed, 418 insertions(+), 231 deletions(-) create mode 100644 fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/CodeCache.java diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Assignment.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Assignment.java index 67752379..2a49d408 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Assignment.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Assignment.java @@ -18,7 +18,7 @@ public class Assignment { public Variable target; public IExpression[] subscripts; public IExpression expression; - public boolean assigned = false; + //public boolean assigned = false; public boolean isConstant = false; public Assignment(IFrame model, Variable target, IExpression[] subscripts, IExpression expression) { @@ -44,13 +44,13 @@ public class Assignment { } } - public void assign(IEnvironment env) { + public void assign(Environment env) { try { Object value = expression.evaluate(env); if(value != null) { validate(target, value); target.assign(env, subscripts, value); - assigned = true; + env.setAssigned(this); } } catch (ExecutionException e) { if(model instanceof Model) { 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 index 00000000..f43cb99e --- /dev/null +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/CodeCache.java @@ -0,0 +1,60 @@ +package fi.semantum.sysdyn.solver; + +import java.io.StringReader; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import fi.semantum.sysdyn.solver.Model.Globals; +import fi.semantum.sysdyn.solver.parser.ModelParser; +import fi.semantum.sysdyn.solver.parser.ParseException; +import fi.semantum.sysdyn.solver.parser.SimpleNode; + +public class CodeCache { + + final static int CACHE_SIZE = 5; + + private static CodeCache INSTANCE; + + final Map models = new HashMap(); + final LinkedList codes = new LinkedList(); + + public static CodeCache getInstance() { + if(INSTANCE == null) INSTANCE = new CodeCache(); + return INSTANCE; + } + + private CodeCache() { + } + + public Model getModel(String code) throws ParseException { + + Model model = models.get(code); + if(model == null) { + + StringReader reader = new StringReader(code); + ModelParser modelParser = new ModelParser(reader); + SimpleNode n = (SimpleNode)modelParser.stored_definition(); + + Parser parser = new Parser(); + model = new Model(new Globals(), "", false); + parser.walk(n, 0, model); + + model.prepare(); + model.prepareFunctions(); + model.sortAssignments(); + + models.put(code, model); + if(codes.size() == 5) { + String last = codes.removeLast(); + models.remove(last); + codes.addFirst(code); + } + + } + + return model; + + } + +} diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java index 135410d7..247a93d1 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java @@ -734,4 +734,14 @@ final public class Environment implements IEnvironment, ISystem { put(index, value); } + public void setAssigned(Object ass) { + assigned.add(ass); + } + + public boolean isAssigned(Object o) { + return assigned.contains(o); + } + + private Set assigned = new HashSet(); + } diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java index ab861d89..ff2527ff 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java @@ -12,11 +12,19 @@ package fi.semantum.sysdyn.solver; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; +import org.simantics.utils.datastructures.MapList; + +import fi.semantum.sysdyn.solver.IExpression.ExpressionVisitor; + class Model implements IFrame { static class Globals { @@ -41,9 +49,11 @@ class Model implements IFrame { public final Globals globals; public int line = -1; - public String name; public boolean isEnumClass; + private String name; + private int size; + public Model(Globals globals, String name, boolean isEnumClass) { this.globals = globals; this.name = name; @@ -333,24 +343,28 @@ class Model implements IFrame { if(!done) throw new IllegalStateException(); - int nextIndex = 0; + size = 0; for(Map.Entry entry : names.entrySet()) { VariableBase base = entry.getValue(); - base.index = nextIndex; + base.index = size; if(PRINT) System.err.println("Variable: " + entry.getKey() + " " + base.index + " " + Arrays.toString(base.dimensions)); int dim = base.dimension(); if(dim == -1) dim = 1; - nextIndex += dim; + size += dim; } if(PRINT) System.err.println("=================="); - return nextIndex; + return size; } + public int getSize() { + return size; + } + public void prettyPrint() { System.err.println("initials"); @@ -441,4 +455,63 @@ class Model implements IFrame { } + public void prepareFunctions() { + + for(Fn fn : functions.values()) { + if(fn instanceof Function) + ((Function)fn).prepare(); + } + + } + + public void sortAssignments() { + + final MapList asses = new MapList(); + for(Assignment ass : assignments) asses.add(ass.target.base.name, ass); + + final List found = new ArrayList(); + final Set visited = new HashSet(); + + ExpressionVisitor sortVisitor = new ExpressionVisitor() { + @Override + public void visit(IExpression expression) { + if(expression instanceof Variable) { + Variable var = (Variable)expression; + if(visited.add(var.base.name)) { + for(Assignment ass : asses.getValues(var.base.name)) { + ass.expression.accept(this); + if(ass.subscripts != null) + for(IExpression e : ass.subscripts) e.accept(this); + } + found.add(var.base); + } + } + } + }; + + // Sort assignments + for(Assignment ass : assignments) { + ass.target.accept(sortVisitor); + } + + Collections.sort(assignments, new Comparator() { + + @Override + public int compare(Assignment o1, Assignment o2) { + int i1 = found.indexOf(o1.target.base); + int i2 = found.indexOf(o2.target.base); + if(i1 < i2) return -1; + else if (i1 > i2) return 1; + return 0; + } + + + }); + + assignmentArray = assignments.toArray(new Assignment[assignments.size()]); + derivativeArray = derivatives.toArray(new Assignment[derivatives.size()]); + parameterArray = parameters.toArray(new ParameterDeclaration[parameters.size()]); + + } + } \ No newline at end of file diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ParameterDeclaration.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ParameterDeclaration.java index 72cbab5e..45ec0f0b 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ParameterDeclaration.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ParameterDeclaration.java @@ -17,7 +17,7 @@ public class ParameterDeclaration implements IExpression { public Variable variable; public IExpression modification; - public boolean assigned = false; +// public boolean assigned = false; public ParameterDeclaration(Variable variable, IExpression modification) { this.variable = variable; diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Parser.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Parser.java index 32695d74..3fe43ba4 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Parser.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Parser.java @@ -365,7 +365,6 @@ public class Parser { SimpleNode child = (SimpleNode)n.jjtGetChild(0); String packagePath = getPackagePath(child); String functionName = packagePath + child.op; - System.err.println("function " + functionName + " at line " + child.line); ArrayList stms2 = new ArrayList(); Function function = new Function(functionName, new StatementList(stms2), child.line); ArrayList composition = (ArrayList)walk(child, indent+2, function); diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java index 80484a56..d33e12cc 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java @@ -11,19 +11,8 @@ *******************************************************************************/ package fi.semantum.sysdyn.solver; -import java.io.StringReader; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.simantics.utils.datastructures.MapList; - -import fi.semantum.sysdyn.solver.IExpression.ExpressionVisitor; -import fi.semantum.sysdyn.solver.Model.Globals; -import fi.semantum.sysdyn.solver.parser.ModelParser; import fi.semantum.sysdyn.solver.parser.SimpleNode; public class Solver { @@ -62,52 +51,6 @@ public class Solver { ready = false; } - private void sortAssignments() { - - final MapList asses = new MapList(); - for(Assignment ass : model.assignments) asses.add(ass.target.base.name, ass); - - final List found = new ArrayList(); - final Set visited = new HashSet(); - - ExpressionVisitor sortVisitor = new ExpressionVisitor() { - @Override - public void visit(IExpression expression) { - if(expression instanceof Variable) { - Variable var = (Variable)expression; - if(visited.add(var.base.name)) { - for(Assignment ass : asses.getValues(var.base.name)) { - ass.expression.accept(this); - if(ass.subscripts != null) - for(IExpression e : ass.subscripts) e.accept(this); - } - found.add(var.base); - } - } - } - }; - - // Sort assignments - for(Assignment ass : model.assignments) { - ass.target.accept(sortVisitor); - } - - Collections.sort(model.assignments, new Comparator() { - - @Override - public int compare(Assignment o1, Assignment o2) { - int i1 = found.indexOf(o1.target.base); - int i2 = found.indexOf(o2.target.base); - if(i1 < i2) return -1; - else if (i1 > i2) return 1; - return 0; - } - - - }); - - } - private SimpleNode n; private String codeCache = null; @@ -133,37 +76,32 @@ public class Solver { long startNanos = System.nanoTime(); - if(!input.equals(codeCache)) { + model = CodeCache.getInstance().getModel(input); - StringReader reader = new StringReader(input); - ModelParser modelParser = new ModelParser(reader); - n = (SimpleNode)modelParser.stored_definition(); +// if(!input.equals(codeCache)) { +// +// StringReader reader = new StringReader(input); +// ModelParser modelParser = new ModelParser(reader); +// n = (SimpleNode)modelParser.stored_definition(); +// +// Parser parser = new Parser(); +// model = new Model(new Globals(), "", false); +// parser.walk(n, 0, model); +// +// model.prepare(); +// model.prepareFunctions(); +// model.sortAssignments(); +// +// codeCache = input; +// +// } - } - - Parser parser = new Parser(); - model = new Model(new Globals(), "", false); - parser.walk(n, 0, model); - codeCache = input; - - env = new Environment(model, defaultStep, start); + int size = model.getSize(); - int size = model.prepare(); + env = new Environment(model, defaultStep, start); env.setSize(size); - - for(Fn fn : model.functions.values()) { - if(fn instanceof Function) - ((Function)fn).prepare(); - } - env.valueTable = new Object[size+STACK_SIZE]; - sortAssignments(); - - model.assignmentArray = model.assignments.toArray(new Assignment[model.assignments.size()]); - model.derivativeArray = model.derivatives.toArray(new Assignment[model.derivatives.size()]); - model.parameterArray = model.parameters.toArray(new ParameterDeclaration[model.parameters.size()]); - newValues = new Object[Math.max(model.assignments.size(),model.derivatives.size())]; int condition = 1; @@ -171,6 +109,10 @@ public class Solver { StringBuilder errors = null; + ArrayList assignments = new ArrayList(); + assignments.addAll(model.assignments); + assignments.addAll(model.initials); + while(condition > 0 && loops++ < MAX_LOOPS) { if(loops == MAX_LOOPS) errors = new StringBuilder(); @@ -183,11 +125,11 @@ public class Solver { for(ParameterDeclaration pd : model.parameters) { try { - if(!pd.assigned) { + if(!env.isAssigned(pd)) { Object value = pd.modification.evaluate(env); validate(pd.variable, value); pd.variable.assign(env, null, value); - pd.assigned = true; + env.setAssigned(pd); } } catch (Exception e) { String error = " -" + pd.variable.toString() + ": " + e.getMessage(); @@ -203,13 +145,9 @@ public class Solver { } } - ArrayList assignments = new ArrayList(); - assignments.addAll(model.assignments); - assignments.addAll(model.initials); - for(VariableDeclaration vd : model.variables) { try { - if(!vd.assigned) { + if(!env.isAssigned(vd)) { for(Argument arg : vd.modification.args) { if(arg.name.endsWith("start")) { Object value = arg.modification.evaluate(env); @@ -233,7 +171,7 @@ public class Solver { // efficient way for (Assignment a : assignments) { if (vd.variable.base.equals(a.target.base)) { - a.assigned = true; + env.setAssigned(a); } } } @@ -255,7 +193,7 @@ public class Solver { for(Assignment ass : assignments) { try { - if(!ass.assigned) + if(!env.isAssigned(ass)) ass.assign(env); } catch (Exception e) { String error = " -" + ass.target.toString() + ": " + e.getMessage(); diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/VariableDeclaration.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/VariableDeclaration.java index 83958d39..eb92bfa5 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/VariableDeclaration.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/VariableDeclaration.java @@ -19,7 +19,7 @@ public class VariableDeclaration implements IExpression { public String direction; public String type; public ArgumentList modification; - public boolean assigned = false; +// public boolean assigned = false; public VariableDeclaration(Variable variable, String direction, String type, ArgumentList modification) { this.variable = variable; diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java index 4b6314ed..7fc2b604 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java @@ -2,7 +2,10 @@ package org.simantics.jfreechart; public class ChartPropertyOptions { - public static final int SHOW_TIME = 1 << 0; - public static final int SHOW_FILTER = 1 << 1; + public static final int SHOW_TIME = 1 << 0; + public static final int SHOW_FILTER = 1 << 1; + public static final int SHOW_VARIABLES = 1 << 2; + public static final int SHOW_AXIS = 1 << 3; + public static final int SHOW_CHART = 1 << 4; } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java index df95e714..48033d84 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java @@ -24,7 +24,7 @@ import org.simantics.sysdyn.JFreeChartResource; public class ChartSelectionTabContributor { public static boolean contibuteTabs(ReadGraph backend, Resource r, List tabs) throws DatabaseException{ - return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME); + return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME|ChartPropertyOptions.SHOW_AXIS|ChartPropertyOptions.SHOW_VARIABLES|ChartPropertyOptions.SHOW_CHART); } public static boolean contibuteTabs(ReadGraph backend, Resource r, List tabs, int options) throws DatabaseException { JFreeChartResource jfree = JFreeChartResource.getInstance(backend); @@ -45,45 +45,49 @@ public class ChartSelectionTabContributor { 10, r, "General")); - tabs.add(new ComparableTabContributor( - new XYLineAxisAndVariablesTab(r), - 9, - r, - "Axis and Variables")); + if ((options&ChartPropertyOptions.SHOW_AXIS )>0 ||(options&ChartPropertyOptions.SHOW_VARIABLES)>0 ) + tabs.add(new ComparableTabContributor( + new XYLineAxisAndVariablesTab(r), + 9, + r, + "Axis and Variables")); } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) { tabs.add(new ComparableTabContributor( new BarGeneralPropertiesTab(r, options), 10, r, "General")); - tabs.add(new ComparableTabContributor( - new BarSeriesTab(r, options), - 9, - r, - "Variables")); - tabs.add(new ComparableTabContributor( - new BarAxisTab(r), - 8, - r, - "Axis")); + if ((options&ChartPropertyOptions.SHOW_VARIABLES )>0) + tabs.add(new ComparableTabContributor( + new BarSeriesTab(r, options), + 9, + r, + "Variables")); + if ((options&ChartPropertyOptions.SHOW_AXIS )>0) + tabs.add(new ComparableTabContributor( + new BarAxisTab(r), + 8, + r, + "Axis")); } else if(backend.isInstanceOf(plot, jfree.PiePlot)) { tabs.add(new ComparableTabContributor( new PieGeneralPropertiesTab(r, options), 10, r, "General")); - tabs.add(new ComparableTabContributor( - new PieSeriesTab(r, options), - 9, - r, - "Variables")); + if ((options&ChartPropertyOptions.SHOW_VARIABLES )>0) + tabs.add(new ComparableTabContributor( + new PieSeriesTab(r, options), + 9, + r, + "Variables")); } - - tabs.add(new ComparableTabContributor( - new ChartTab(r), - 1, - r, - "Chart")); + if ((options&ChartPropertyOptions.SHOW_CHART )>0) + tabs.add(new ComparableTabContributor( + new ChartTab(r), + 1, + r, + "Chart")); return true; } @@ -92,7 +96,7 @@ public class ChartSelectionTabContributor { } public static boolean contibuteTabs2(ReadGraph backend, Resource r, List tabs) throws DatabaseException{ - return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME); + return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME|ChartPropertyOptions.SHOW_AXIS|ChartPropertyOptions.SHOW_VARIABLES|ChartPropertyOptions.SHOW_CHART); } public static boolean contibuteTabs2(ReadGraph backend, Resource r, List tabs, int options) throws DatabaseException { @@ -114,45 +118,49 @@ public class ChartSelectionTabContributor { 10, r, "General")); - tabs.add(new ComparableTabContributor( - new XYLineAxisAndVariablesTab(r), - 9, - r, - "Axis and Variables")); - } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) { - tabs.add(new ComparableTabContributor( + if ((options&ChartPropertyOptions.SHOW_AXIS )>0 ||(options&ChartPropertyOptions.SHOW_VARIABLES)>0 ) + tabs.add(new ComparableTabContributor( + new XYLineAxisAndVariablesTab(r), + 9, + r, + "Axis and Variables")); + } else if (backend.isInstanceOf(plot, jfree.CategoryPlot)) { + tabs.add(new ComparableTabContributor( new BarGeneralPropertiesTab(r, options), 10, r, "General")); - tabs.add(new ComparableTabContributor( - new BarSeriesTab2(r, options), - 9, - r, - "Variables")); - tabs.add(new ComparableTabContributor( - new BarAxisTab(r), - 8, - r, - "Axis")); + if ((options&ChartPropertyOptions.SHOW_VARIABLES)>0) + tabs.add(new ComparableTabContributor( + new BarSeriesTab2(r, options), + 9, + r, + "Variables")); + if ((options&ChartPropertyOptions.SHOW_AXIS )>0) + tabs.add(new ComparableTabContributor( + new BarAxisTab(r), + 8, + r, + "Axis")); } else if(backend.isInstanceOf(plot, jfree.PiePlot)) { tabs.add(new ComparableTabContributor( new PieGeneralPropertiesTab(r, options), 10, r, "General")); - tabs.add(new ComparableTabContributor( - new PieSeriesTab2(r, options), - 9, - r, - "Variables")); + if ((options&ChartPropertyOptions.SHOW_VARIABLES)>0) + tabs.add(new ComparableTabContributor( + new PieSeriesTab2(r, options), + 9, + r, + "Variables")); } - - tabs.add(new ComparableTabContributor( - new ChartTab(r), - 1, - r, - "Chart")); + if ((options&ChartPropertyOptions.SHOW_CHART )>0) + tabs.add(new ComparableTabContributor( + new ChartTab(r), + 1, + r, + "Chart")); return true; } diff --git a/org.simantics.sysdyn.ontology/graph.tg b/org.simantics.sysdyn.ontology/graph.tg index 4b49d0567142e800684ab25ebaf09725e0982e9e..fa218087b2d4136b6810b875973ba0baade063d2 100644 GIT binary patch delta 39 vcmbO=g?s4~?hVKJHech5Vqs^U%E-XLpgcKHU%1&oxZOaQal3&q)2nR&10W0# delta 40 wcmZ2Fg?rW%?hVKJc&0KkFtC)d2A3q3q;5XK7t7LYE!=J`%(&fJnCaCv02PZ3SpWb4 diff --git a/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph b/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph index eda75ae2..ffd674d8 100644 --- a/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph +++ b/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph @@ -437,7 +437,7 @@ SYSDYN.HistoryDataset -- SYSDYN.Experiment.result --> SYSDYN.Result -- SYSDYN.InitialCondition.HasInitialValues --> MOD.PartialIC + + + + + + + + @@ -2022,6 +2039,21 @@ args="org.simantics.sysdyn.ui.browser.nodes.SCLModulesFolder" property="org.simantics.sysdyn.ui.nodeClass"> + + + + + + diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java index e5e308ac..72d6a34d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java @@ -69,7 +69,7 @@ public class ChartDropAction implements DropActionFactory { if(variable == null) continue; - Resource represents = (Resource)variable.getPropertyValue(graph, Variables.REPRESENTS); + Resource represents = (Resource)variable.getRepresents(graph); if(represents == null || !(graph.isInstanceOf(represents, sr.IndependentVariable) || graph.isInstanceOf(represents, sr.Input))) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/childrules/VariableChildRule.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/childrules/VariableChildRule.java index 270ad228..783961af 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/childrules/VariableChildRule.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/childrules/VariableChildRule.java @@ -59,7 +59,7 @@ public class VariableChildRule implements ChildRule { ArrayList variables = new ArrayList(); for(Variable child : variable.getChildren(graph)) { - Resource represents = (Resource)child.getPropertyValue(graph, Variables.REPRESENTS); + Resource represents = child.getRepresents(graph); if(graph.isInstanceOf(represents, sr.IndependentVariable)) { variables.add(child); } else if (graph.isInstanceOf(represents, sr.Input)) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java index fdb9ee0b..659f63f2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java @@ -52,7 +52,7 @@ public class Configuration extends ViewpointContributor(v, represents)); } for (String s : inputs.keySet()) { Variable v = inputs.get(s); - Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS); + Resource represents = v.getRepresents(graph); result.add(new InputNode(v, represents)); } for (String s : modules.keySet()) { Variable v = modules.get(s); - Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS); + Resource represents = v.getRepresents(graph); result.add(new ModuleNode(v, represents)); } for (String s : enumerations.keySet()) { Variable v = enumerations.get(s); - Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS); + Resource represents = v.getRepresents(graph); result.add(new EnumerationNode(v, represents)); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/imagerules/VariableImageRule.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/imagerules/VariableImageRule.java index ba780a64..7c1b5779 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/imagerules/VariableImageRule.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/imagerules/VariableImageRule.java @@ -21,7 +21,6 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.layer0.variable.Variables; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.Activator; @@ -40,7 +39,7 @@ public class VariableImageRule implements ImageRule { String image = "icons/brick.png"; - Resource r = (Resource)var.getPropertyValue(graph, Variables.REPRESENTS); + Resource r = var.getRepresents(graph); if(r != null) { Layer0 L0 = Layer0.getInstance(graph); SysdynResource sr = SysdynResource.getInstance(graph); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSCLModuleHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSCLModuleHandler.java index a026c31b..7dee59c8 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSCLModuleHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSCLModuleHandler.java @@ -25,11 +25,16 @@ public class NewSCLModuleHandler extends AbstractHandler { ISelection sel = HandlerUtil.getCurrentSelection(event); @SuppressWarnings("unchecked") - AbstractNode node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class); - if (node == null) - return null; + Resource res = AdaptionUtils.adaptToSingle(sel, Resource.class); + if(res == null) { + @SuppressWarnings("unchecked") + AbstractNode node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class); + if (node == null) + return null; + res = node.data; + } - final Resource parent = node.data; + final Resource parent = res; SimanticsUI.getSession().asyncRequest(new WriteRequest() { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ActiveDatasetsIndexVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ActiveDatasetsIndexVariable.java index 4b57b97d..3039cea7 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ActiveDatasetsIndexVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ActiveDatasetsIndexVariable.java @@ -2,6 +2,7 @@ package org.simantics.sysdyn.adapter; import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.simantics.db.ReadGraph; import org.simantics.db.WriteGraph; @@ -26,8 +27,8 @@ public class ActiveDatasetsIndexVariable extends IndexVariable< ArrayList results = experiment.getActiveResults(); - ArrayList variableNamesWithIndexes = getVariableNamesWithIndexNumbers(); - ArrayList variableNames = getVariableNames(); + List variableNamesWithIndexes = getVariableNamesWithIndexNumbers(); + List variableNames = getVariableNames(); for(int i = 0; i < variableNamesWithIndexes.size(); i++) { for(SysdynResult result : results) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java index bf71e39f..4211a80a 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java @@ -1,7 +1,9 @@ package org.simantics.sysdyn.adapter; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import org.simantics.Simantics; import org.simantics.databoard.Bindings; @@ -38,7 +40,7 @@ public abstract class IndexVariable extends AbstractPropertyVariable { protected HashMap rvis; protected String indexes; protected VariableSubscriptionManager subscriptionManager; - protected Pair,ArrayList> variableNameArrays; + private Pair,List> variableNameArrays; public IndexVariable(ReadGraph graph, Variable parent, String indexes) throws DatabaseException { this.parent = parent; @@ -208,28 +210,53 @@ public abstract class IndexVariable extends AbstractPropertyVariable { } - private Pair,ArrayList> getVariableNameArrays() { + private Pair,List> getVariableNameArrays() { if(variableNameArrays == null) { - Pair,ArrayList> result = new Pair,ArrayList>(new ArrayList(), new ArrayList()); if(rvi != null && rvis != null) { if(rvi.indexOf('#') > 0) rvi = rvi.substring(0, rvi.indexOf('#')); + boolean regexp = false; String test = rvi; if(indexes != null && !indexes.isEmpty()) { - String regexIndexes = indexes.trim().replaceAll(":", "[a-zA-Z0-9_]*"); // Why was there was ".replace('.', ',')" ? - Removed by Teemu 2.9.2012 - test = rvi + "\\[" + regexIndexes + "\\]"; + regexp = indexes.contains(":"); + if(regexp) { + String regexIndexes = indexes.trim().replaceAll(":", "[a-zA-Z0-9_]*"); // Why was there was ".replace('.', ',')" ? - Removed by Teemu 2.9.2012 + test = rvi + "\\[" + regexIndexes + "\\]"; + } else { + test = rvi + "[" + indexes + "]"; + } } else { test = rvi + "(\\[.*\\])?"; + regexp = true; } - for(String k : rvis.keySet()) { - String value = rvis.get(k); - if(k.matches(test) || value.matches(test)) { - result.first.add(k.substring(1).replace("/", ".").replace("%20", "_")); - result.second.add(value.substring(1).replace("/", ".").replace("%20", " ")); + + Pair,List> result = null; + + if(regexp) { + result = new Pair,List>(new ArrayList(), new ArrayList()); + for(String k : rvis.keySet()) { + String value = rvis.get(k); + if(k.matches(test) || value.matches(test)) { + result.first.add(transform(k)); + result.second.add(transform(value)); + } + } + } else { + String value = rvis.get(test); + if(value != null) { + result = new Pair,List>(Collections.singletonList(transform(test)), Collections.singletonList(transform(value))); + } else { + for(String k : rvis.keySet()) { + value = rvis.get(k); + if(value.equals(test)) { + result = new Pair,List>(Collections.singletonList(transform(k)), Collections.singletonList(transform(test))); + break; + } + } } } @@ -239,17 +266,21 @@ public abstract class IndexVariable extends AbstractPropertyVariable { } - if(variableNameArrays == null) return new Pair,ArrayList>(new ArrayList(), new ArrayList()); + if(variableNameArrays == null) return new Pair,List>(new ArrayList(), new ArrayList()); return variableNameArrays; } - protected ArrayList getVariableNames() { + private String transform(String s) { + return s.substring(1).replace("/", ".").replace("%20", "_"); + } + + protected List getVariableNames() { return getVariableNameArrays().second; } - protected ArrayList getVariableNamesWithIndexNumbers() { + protected List getVariableNamesWithIndexNumbers() { return getVariableNameArrays().first; } @@ -267,19 +298,12 @@ public abstract class IndexVariable extends AbstractPropertyVariable { } abstract protected void setIndexedValue(WriteGraph graph, Object value) throws DatabaseException; - - @Override public String getName(ReadGraph graph) throws DatabaseException { return indexes; } - @Override - public Object getSerialized(ReadGraph graph) throws DatabaseException { - return indexes; - } - @Override public Variable getParent(ReadGraph graph) throws DatabaseException { return parent; diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/NamesIndexVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/NamesIndexVariable.java index 7e32bbad..2ef5afa3 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/NamesIndexVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/NamesIndexVariable.java @@ -1,6 +1,7 @@ package org.simantics.sysdyn.adapter; import java.util.ArrayList; +import java.util.List; import org.simantics.db.ReadGraph; import org.simantics.db.WriteGraph; @@ -16,7 +17,7 @@ public class NamesIndexVariable extends IndexVariable { @Override public String[] getValue() { - ArrayList names = getVariableNames(); + List names = getVariableNames(); return names.toArray(new String[names.size()]); } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/TimesIndexVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/TimesIndexVariable.java index 329e4cd2..57e2e125 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/TimesIndexVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/TimesIndexVariable.java @@ -1,7 +1,7 @@ package org.simantics.sysdyn.adapter; -import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.simantics.db.ReadGraph; import org.simantics.db.WriteGraph; @@ -24,7 +24,7 @@ public class TimesIndexVariable extends IndexVariable { return new double[0][0]; Collection results = experiment.getActiveResults(); - ArrayList variableNames = getVariableNamesWithIndexNumbers(); + List variableNames = getVariableNamesWithIndexNumbers(); double[][] result = new double[variableNames.size()][]; for(int i = 0; i < variableNames.size(); i++) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java index cbb948bc..53db9ef8 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java @@ -1,7 +1,7 @@ package org.simantics.sysdyn.adapter; -import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -46,7 +46,7 @@ abstract public class ValueIndexVariableBase extends IndexVariable { Collection results = experiment.getActiveResults(); - ArrayList variableNames = getVariableNamesWithIndexNumbers(); + List variableNames = getVariableNamesWithIndexNumbers(); double[] result = new double[variableNames.size()]; for(int i = 0; i < variableNames.size(); i++) { @@ -101,7 +101,7 @@ abstract public class ValueIndexVariableBase extends IndexVariable { try { - ArrayList variableNames = getVariableNamesWithIndexNumbers(); + List variableNames = getVariableNamesWithIndexNumbers(); for(int i = 0; i < variableNames.size() && i < values.length; i++) { if(values[i] == Double.NaN) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java index baed93ed..229cb172 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java @@ -45,11 +45,6 @@ public class ValueIndexVariableI extends ValueIndexVariableBase { return "$" + index; } - @Override - public Object getSerialized(ReadGraph graph) throws DatabaseException { - return "$" + index; - } - @Override public Datatype getDatatype(ReadGraph graph) throws DatabaseException { return Datatypes.DOUBLE; diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java index d0eb2032..2ed53f3f 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java @@ -1,7 +1,7 @@ package org.simantics.sysdyn.adapter; -import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.simantics.db.ReadGraph; import org.simantics.db.WriteGraph; @@ -20,7 +20,7 @@ public class ValuesIndexVariable extends IndexVariable { @Override public double[][] getValue() { - ArrayList variableNames = getVariableNamesWithIndexNumbers(); + List variableNames = getVariableNamesWithIndexNumbers(); double[][] result = new double[variableNames.size()][]; if (experiment != null) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java index 7b6a68bc..986e2cc9 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java @@ -11,10 +11,13 @@ *******************************************************************************/ package org.simantics.sysdyn.adapter; +import gnu.trove.map.hash.THashMap; + import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; @@ -25,6 +28,8 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.request.VariableRead; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; +import org.simantics.db.request.ReadExt; +import org.simantics.db.request.RequestFlags; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.manager.SysdynDataSet; @@ -151,18 +156,18 @@ public class VariableRVIUtils { } - /** - * Returns rvis in a map in format /ModuleInstance/Variable[1] = /ModuleInstance/Variable[index1] - * @param graph ReadGraph - * @param variable Variable for the rvis - * @return rvis in a map. Keys are numerical formatted array indexes and values are textual. - * @throws DatabaseException - */ - public static HashMap getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException { - return graph.syncRequest(new GetActiveRVIs(variable)); - } +// /** +// * Returns rvis in a map in format /ModuleInstance/Variable[1] = /ModuleInstance/Variable[index1] +// * @param graph ReadGraph +// * @param variable Variable for the rvis +// * @return rvis in a map. Keys are numerical formatted array indexes and values are textual. +// * @throws DatabaseException +// */ +// public static HashMap getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException { +// return graph.syncRequest(new GetActiveRVIs(variable)); +// } - public static class GetActiveRVIs extends VariableRead> { + public static class GetActiveRVIs extends VariableRead> implements ReadExt { public GetActiveRVIs(Variable variable) { super(variable); @@ -192,6 +197,16 @@ public class VariableRVIUtils { } return rvis; } + + @Override + public boolean isImmutable(ReadGraph graph) throws DatabaseException { + return false; + } + + @Override + public int getType() { + return RequestFlags.IMMEDIATE_UPDATE; + } } @@ -244,7 +259,7 @@ public class VariableRVIUtils { String currentFilter = filter[i].trim(); ArrayList tempResult = new ArrayList(); - HashMap sums = new HashMap(); + Map sums = new THashMap(); for(SysdynDataSet dataset : result) { String tempIndexes = dataset.name.substring(dataset.name.indexOf('[') + 1, dataset.name.indexOf(']')); String[] indexes = tempIndexes.split(","); diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java index 7bf5b1ff..7b1c550b 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java @@ -238,6 +238,14 @@ public class SysdynExperiments { } }, new DefaultPasteHandler(ic)); + +// String id = input.getName(graph); +// SCLRealm realm = SCLSessionManager.sclRealmById(id); +// if(realm != null) { +// byte[] blob = realm.serialize(); +// //graph.addLiteral(ic, SYSDYN.InitialCondition_HasInitialValues, SYSDYN.InitialCondition_HasInitialValues_Inverse, MOD.PartialIC, IC, PartialIC.BINDING); +// } + } Layer0Utils.addCommentMetadata(graph, "Saved new Initial Condition " + name + " " + ic); diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java index b8b06837..b2c4b716 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java @@ -22,11 +22,12 @@ import org.simantics.db.common.request.UniqueRead; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.exception.MissingVariableException; import org.simantics.db.layer0.util.EvaluatingListener; import org.simantics.db.layer0.util.EvaluatingListener.Criterion; import org.simantics.db.layer0.util.EvaluatingListener.Evaluation; import org.simantics.db.layer0.variable.Variables; +import org.simantics.db.request.ReadExt; +import org.simantics.db.request.RequestFlags; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingResources; import org.simantics.scl.runtime.function.FunctionImpl1; @@ -618,27 +619,42 @@ public class DocumentationUtils { } - public static class LastValueIndexed extends BinaryRead { + public static class LastValueIndexed extends BinaryRead implements ReadExt { - public LastValueIndexed(Resource resource, String path) { - super(resource, path); + public LastValueIndexed(org.simantics.db.layer0.variable.Variable run, String path) { + super(run, path); } @Override public org.simantics.db.layer0.variable.Variable perform(ReadGraph graph) throws DatabaseException { - org.simantics.db.layer0.variable.Variable run = Variables.getVariable(graph, parameter); - Pair nameAndIndices = splitToNameAndIndices(parameter2); - org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second); - if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2); - return v; + try { + Pair nameAndIndices = splitToNameAndIndices(parameter2); + org.simantics.db.layer0.variable.Variable v = parameter.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second); + //if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2); + if(v == null) return null; + return v; + } catch (Throwable e) { + throw new DatabaseException(e); + } } + + @Override + public boolean isImmutable(ReadGraph graph) throws DatabaseException { + return false; + } + + @Override + public int getType() { + return RequestFlags.IMMEDIATE_UPDATE; + } + } public static org.simantics.db.layer0.variable.Variable lastValueIndexed(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException { if(run == null) return null; - return graph.syncRequest(new LastValueIndexed(run.getRepresents(graph), path)); + return graph.syncRequest(new LastValueIndexed(run, path)); } public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException { -- 2.47.1