]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
ValueIndexVariable provides the possibly changed value in game experiments without...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 11 Jan 2013 10:57:03 +0000 (10:57 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 11 Jan 2013 10:57:03 +0000 (10:57 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26599 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValuesIndexVariable.java

index 9485369f96f049475eb0fea81b45b8bf5c34e70c..cd237d2c44e992d8223698367532642dfc73afd5 100644 (file)
@@ -7,7 +7,9 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.fmu.FMUJNIException;\r
 import org.simantics.sysdyn.manager.SysdynDataSet;\r
+import org.simantics.sysdyn.manager.SysdynGameExperiment;\r
 import org.simantics.sysdyn.manager.SysdynResult;\r
 \r
 public class ValuesIndexVariable extends IndexVariable<double[][]> {\r
@@ -31,6 +33,18 @@ public class ValuesIndexVariable extends IndexVariable<double[][]> {
                     for(int j = 0; j < ds.values.length; j++) {\r
                         result[i][j] = ds.values[j];\r
                     }\r
+                    \r
+                    // if this is the actual simulation result and experiment is game experiment, \r
+                    // get the last value from fmu control.\r
+                    if(experiment instanceof SysdynGameExperiment && ds.result == null) {\r
+                        try {\r
+                            double d = ((SysdynGameExperiment)experiment).getFMUControl().getRealValue(variableNames.get(i));\r
+                            result[i][ds.values.length - 1] = d;\r
+                        } catch (FMUJNIException e) {\r
+                            e.printStackTrace();\r
+                        }\r
+                    }\r
+                    \r
                 } else {\r
                     result[i] = new double[0];\r
                 }\r