]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
fixes #5067
authorjussi.koskela <jussi.koskela@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 7 Jul 2014 11:38:52 +0000 (11:38 +0000)
committerjussi.koskela <jussi.koskela@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 7 Jul 2014 11:38:52 +0000 (11:38 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29812 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java

index 3b05dd71791a48400589be5d09642d98dd958e61..6fb6f77d5b7c1c40f1dca6716a60cdc32337345f 100644 (file)
@@ -4,16 +4,28 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 \r
-public class ValueIndexVariable extends ValueIndexVariableBase<double[]> {\r
-\r
+public class ValueIndexVariable extends ValueIndexVariableBase<Object> {\r
+       \r
+       private final boolean scalar;\r
+       \r
        public ValueIndexVariable(ReadGraph graph, Variable parent, String indexes)\r
                        throws DatabaseException {\r
            super(graph, parent, indexes);\r
+           scalar = indexes.indexOf(":") == -1;\r
        }\r
        \r
        @Override\r
-       public double[] getValue() {\r
-               return getValueFull();\r
+       public Object getValue() {\r
+               double[] value = getValueFull();\r
+               if (scalar) {\r
+                       if (value == UNRESOLVED) { \r
+                               return Double.NaN;\r
+                       } else {\r
+                               return value[0];\r
+                       }\r
+               } else {\r
+                       return value;\r
+               }\r
        }\r
        \r
 }\r
index 1e7bf51b6c7e99304b35f13726da6125942d87a7..0b308f70ef7564691982be8baa8b147cfb46651e 100644 (file)
@@ -58,10 +58,16 @@ abstract public class ValueIndexVariableBase<T> extends IndexVariable<T> {
                Variable var = parent.getParent(graph);\r
                Resource resource = var.getRepresents(graph);\r
                \r
-               if(!(value instanceof double[]) || resource == null)\r
+               if(!(value instanceof Double || value instanceof double[]) || resource == null)\r
                        return;\r
                \r
-               double[] values = (double[]) value;\r
+               double[] values = null;\r
+               if (value instanceof Double) {\r
+                       values = new double[1];\r
+                       values[0] = (Double)value;\r
+               } else if (value instanceof double[]) {\r
+                       values = (double[]) value;      \r
+               }\r
                \r
 //             FMUControlJNI control = null;\r
                if(experiment instanceof SysdynGameExperimentBase) { // Support only game experiments for now..\r