return new ValuesIndexVariable(graph, context, name);\r
else if(TIMES.equals(property))\r
return new TimesIndexVariable(graph, context, name);\r
+ else if(TIME.equals(property))\r
+ return new TimeIndexVariable(graph, context, name); \r
else if(NAMES.equals(property))\r
return new NamesIndexVariable(graph, context, name);\r
else if(ACTIVE_DATASETS.equals(property))\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.sysdyn.manager.SysdynGameExperiment;\r
import org.simantics.sysdyn.manager.SysdynPlaybackExperiment;\r
\r
public class TimeIndexVariable extends IndexVariable<Double> {\r
public Double getValue() {\r
if(experiment != null && experiment instanceof SysdynPlaybackExperiment)\r
return ((SysdynPlaybackExperiment)experiment).getTime();\r
- else\r
- return null;\r
+ if(experiment != null && experiment instanceof SysdynGameExperiment)\r
+ return ((SysdynGameExperiment)experiment).getTime();\r
+ return null;\r
}\r
\r
@Override\r
public FMUControlJNI getFMUControl() {\r
return control;\r
}\r
+ \r
+ public double getTime() {\r
+ if(control != null) {\r
+ try {\r
+ return control.getTime();\r
+ } catch (FMUJNIException e) {\r
+ }\r
+ }\r
+ return 0.0;\r
+ }\r
+ \r
\r
@Override\r
public void init(ReadGraph g) {\r
monitor.worked(1);\r
\r
int stepNumber = 1;\r
- while(control.getTime() < (eTime - 1e-9) && !canceled) { // Substract a very small number, because OpenModelica is not very precise with its Real numbers\r
+ while(control.getTime() < eTime && !canceled) {\r
+ if(eTime - control.getTime() < stepLength)\r
+ control.setStepLength(eTime - control.getTime());\r
+ \r
monitor.subTask("Simulate step (time = " + control.getTime() + ")");\r
control.simulateStep();\r
monitor.worked(1);\r