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
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