From 3bcac08e7d23f59b5b0665a41665000f582d1a6a Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 11 Jan 2013 10:57:03 +0000 Subject: [PATCH] ValueIndexVariable provides the possibly changed value in game experiments without having to simulate steps. (fixes #3976) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26599 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/adapter/ValuesIndexVariable.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java index 9485369f..cd237d2c 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java @@ -7,7 +7,9 @@ import org.simantics.db.ReadGraph; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; +import org.simantics.fmu.FMUJNIException; import org.simantics.sysdyn.manager.SysdynDataSet; +import org.simantics.sysdyn.manager.SysdynGameExperiment; import org.simantics.sysdyn.manager.SysdynResult; public class ValuesIndexVariable extends IndexVariable { @@ -31,6 +33,18 @@ public class ValuesIndexVariable extends IndexVariable { for(int j = 0; j < ds.values.length; j++) { result[i][j] = ds.values[j]; } + + // if this is the actual simulation result and experiment is game experiment, + // get the last value from fmu control. + if(experiment instanceof SysdynGameExperiment && ds.result == null) { + try { + double d = ((SysdynGameExperiment)experiment).getFMUControl().getRealValue(variableNames.get(i)); + result[i][ds.values.length - 1] = d; + } catch (FMUJNIException e) { + e.printStackTrace(); + } + } + } else { result[i] = new double[0]; } -- 2.47.1