From 1ded62785aabf5a28a943743e2884aafa92766a8 Mon Sep 17 00:00:00 2001 From: "jussi.koskela" Date: Mon, 7 Jul 2014 11:38:52 +0000 Subject: [PATCH] fixes #5067 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29812 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/adapter/ValueIndexVariable.java | 20 +++++++++++++++---- .../adapter/ValueIndexVariableBase.java | 10 ++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java index 3b05dd71..6fb6f77d 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java @@ -4,16 +4,28 @@ import org.simantics.db.ReadGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; -public class ValueIndexVariable extends ValueIndexVariableBase { - +public class ValueIndexVariable extends ValueIndexVariableBase { + + private final boolean scalar; + public ValueIndexVariable(ReadGraph graph, Variable parent, String indexes) throws DatabaseException { super(graph, parent, indexes); + scalar = indexes.indexOf(":") == -1; } @Override - public double[] getValue() { - return getValueFull(); + public Object getValue() { + double[] value = getValueFull(); + if (scalar) { + if (value == UNRESOLVED) { + return Double.NaN; + } else { + return value[0]; + } + } else { + return value; + } } } 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 1e7bf51b..0b308f70 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java @@ -58,10 +58,16 @@ abstract public class ValueIndexVariableBase extends IndexVariable { Variable var = parent.getParent(graph); Resource resource = var.getRepresents(graph); - if(!(value instanceof double[]) || resource == null) + if(!(value instanceof Double || value instanceof double[]) || resource == null) return; - double[] values = (double[]) value; + double[] values = null; + if (value instanceof Double) { + values = new double[1]; + values[0] = (Double)value; + } else if (value instanceof double[]) { + values = (double[]) value; + } // FMUControlJNI control = null; if(experiment instanceof SysdynGameExperimentBase) { // Support only game experiments for now.. -- 2.47.1