From e063355f1972027798616bad43eb0604f9f535ae Mon Sep 17 00:00:00 2001 From: villberg Date: Mon, 25 Aug 2014 06:41:36 +0000 Subject: [PATCH] refs #5178 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30126 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.sysdyn/scl/Simantics/Sysdyn.scl | 1 + .../sysdyn/adapter/ValueIndexVariableI.java | 7 +++ .../sysdyn/utils/DocumentationUtils.java | 44 ++++++++++++++++--- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/org.simantics.sysdyn/scl/Simantics/Sysdyn.scl b/org.simantics.sysdyn/scl/Simantics/Sysdyn.scl index b75a31c8..878dffb5 100644 --- a/org.simantics.sysdyn/scl/Simantics/Sysdyn.scl +++ b/org.simantics.sysdyn/scl/Simantics/Sysdyn.scl @@ -92,6 +92,7 @@ importJava "org.simantics.sysdyn.utils.DocumentationUtils" where lastValue :: Resource -> String -> String -> Double lastValue2 :: Variable -> String -> Variable + currentValue :: Variable -> String -> Variable lastValueIndexed :: Variable -> String -> Variable equation :: Variable -> String -> Variable 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 c414f3d6..baed93ed 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java @@ -2,7 +2,9 @@ package org.simantics.sysdyn.adapter; import java.util.Arrays; +import org.simantics.databoard.Datatypes; import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.type.Datatype; import org.simantics.db.ReadGraph; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; @@ -48,4 +50,9 @@ public class ValueIndexVariableI extends ValueIndexVariableBase { return "$" + index; } + @Override + public Datatype getDatatype(ReadGraph graph) throws DatabaseException { + return Datatypes.DOUBLE; + } + } 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 28ec9bf6..966f9808 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java @@ -558,11 +558,17 @@ public class DocumentationUtils { } - public static org.simantics.db.layer0.variable.Variable lastValue2(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException { + public static org.simantics.db.layer0.variable.Variable lastValue2(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException { - if(run == null) return null; + if(input == null) return null; + + org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input); + if(context == null) { + context = Variables.getConfigurationContext(graph, input); + if(context == null) return null; + } - org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + path); + org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path); if(v == null) return null; org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#value#$0"); @@ -572,6 +578,26 @@ public class DocumentationUtils { } + public static org.simantics.db.layer0.variable.Variable currentValue(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException { + + if(input == null) return null; + + org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input); + if(context == null) { + context = Variables.getConfigurationContext(graph, input); + if(context == null) return null; + } + + org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path); + if(v == null) return null; + + org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#value#$0"); + if(p == null) return null; + + return p; + + } + /** * Splits indexed variable reference into name and indices part. * @@ -603,11 +629,17 @@ public class DocumentationUtils { return v; } - public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException { + public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException { - if(run == null) return null; + if(input == null) return null; + + org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input); + if(context == null) { + context = Variables.getConfigurationContext(graph, input); + if(context == null) return null; + } - org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + path); + org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path); if(v == null) return null; org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#equation"); -- 2.47.1