]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #5178
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 25 Aug 2014 06:41:36 +0000 (06:41 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 25 Aug 2014 06:41:36 +0000 (06:41 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30126 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/scl/Simantics/Sysdyn.scl
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java

index b75a31c8ab9562f15469bfb10cb2bf6a863902f0..878dffb539fd485bc8456b3165f55a82c35b3f79 100644 (file)
@@ -92,6 +92,7 @@ importJava "org.simantics.sysdyn.utils.DocumentationUtils" where
 \r
     lastValue :: Resource -> String -> String -> Double\r
     lastValue2 :: Variable -> String -> <ReadGraph> Variable\r
+    currentValue :: Variable -> String -> <ReadGraph> Variable\r
     lastValueIndexed :: Variable -> String -> <ReadGraph> Variable\r
     equation :: Variable -> String -> <ReadGraph> Variable\r
 \r
index c414f3d6857ff34dba58c7ae6a96e2e6d7fe2a67..baed93ed56d375a65518807c479937a72444efe2 100644 (file)
@@ -2,7 +2,9 @@ package org.simantics.sysdyn.adapter;
 \r
 import java.util.Arrays;\r
 \r
+import org.simantics.databoard.Datatypes;\r
 import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.type.Datatype;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.exception.DatabaseException;\r
@@ -48,4 +50,9 @@ public class  ValueIndexVariableI extends ValueIndexVariableBase<Double> {
                return "$" + index;\r
        }\r
        \r
+       @Override\r
+       public Datatype getDatatype(ReadGraph graph) throws DatabaseException {\r
+               return Datatypes.DOUBLE;\r
+       }\r
+       \r
 }\r
index 28ec9bf63d30876ba1c70d162eb4bf4281f388db..966f9808916e4685e9a96414bb0f145f9beaec1b 100644 (file)
@@ -558,11 +558,17 @@ public class DocumentationUtils {
        \r
     }\r
 \r
-    public static org.simantics.db.layer0.variable.Variable lastValue2(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException {\r
+    public static org.simantics.db.layer0.variable.Variable lastValue2(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException {\r
        \r
-       if(run == null) return null;\r
+       if(input == null) return null;\r
+       \r
+       org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input);\r
+       if(context == null) {\r
+               context = Variables.getConfigurationContext(graph, input);\r
+               if(context == null) return null;\r
+       }\r
 \r
-       org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + path);\r
+       org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path);\r
        if(v == null) return null;\r
 \r
        org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#value#$0");\r
@@ -572,6 +578,26 @@ public class DocumentationUtils {
        \r
     }\r
 \r
+    public static org.simantics.db.layer0.variable.Variable currentValue(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException {\r
+       \r
+       if(input == null) return null;\r
+       \r
+       org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input);\r
+       if(context == null) {\r
+               context = Variables.getConfigurationContext(graph, input);\r
+               if(context == null) return null;\r
+       }\r
+\r
+       org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path);\r
+       if(v == null) return null;\r
+\r
+       org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#value#$0");\r
+       if(p == null) return null;\r
+       \r
+       return p;\r
+       \r
+    }\r
+    \r
     /**\r
      * Splits indexed variable reference into name and indices part.\r
      * \r
@@ -603,11 +629,17 @@ public class DocumentationUtils {
        return v;\r
     }    \r
     \r
-    public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException {\r
+    public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException {\r
 \r
-       if(run == null) return null;\r
+       if(input == null) return null;\r
+       \r
+       org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input);\r
+       if(context == null) {\r
+               context = Variables.getConfigurationContext(graph, input);\r
+               if(context == null) return null;\r
+       }\r
        \r
-       org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + path);\r
+       org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path);\r
        if(v == null) return null;\r
 \r
        org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#equation");\r