@@ -19,7 +19,6 @@ protected import ExpressionSimplify;
1919protected import Flags ;
2020protected import Static ;
2121protected import Types ;
22- protected import Dump ;
2322
2423
2524protected function calculateSimulationTimes
@@ -49,28 +48,35 @@ algorithm
4948 Prefix . Prefix pre;
5049 Absyn . Info info;
5150 Integer intervals;
52- Real stepTime ;
51+ Real rstepTime, rstopTime, rstartTime ;
5352 Env . Cache cache;
5453 Env . Env env;
5554
5655 // special case for Parham Vaseles OpenModelica Interactive, where buildModel takes stepSize instead of startTime, stopTime and numberOfIntervals
5756 case (cache,env,{Absyn . CREF (componentRef = cr)},args,impl,SOME (st),pre,info,_)
5857 equation
5958 // An ICONST is used as the default value of stepSize so that this case
60- // fails if stepSize isn't given as argument to buildModel.
61-
62- (cache, DAE . RCONST (stepTime)) =
59+ // fails if stepSize isn't given as argument to buildModel.
60+ (cache, DAE . RCONST (rstepTime)) =
6361 Static . getOptionalNamedArg(cache, env, SOME (st), impl, "stepSize" , DAE . T_REAL_DEFAULT ,
6462 args, DAE . ICONST (0 ), // force failure if stepSize is not found via division by zero below!
6563 pre, info);
66-
67- startTime = DAE . RCONST (0 . 0 );
68- stopTime = DAE . RCONST (1 . 0 );
69- intervals = realInt(1 . 0 /. stepTime);
64+
65+ (cache,startTime as DAE . RCONST (rstartTime)) =
66+ Static . getOptionalNamedArg(cache, env, SOME (st), impl, "startTime" , DAE . T_REAL_DEFAULT ,
67+ args, CevalScript . getSimulationOption(inSimOpt, "startTime" ),
68+ pre, info);
69+
70+ (cache,stopTime as DAE . RCONST (rstopTime)) =
71+ Static . getOptionalNamedArg(cache, env, SOME (st), impl, "stopTime" , DAE . T_REAL_DEFAULT ,
72+ args, CevalScript . getSimulationOption(inSimOpt, "stopTime" ),
73+ pre, info);
74+
75+ intervals = realInt((rstopTime -. rstartTime) /. rstepTime);
7076 numberOfIntervals = DAE . ICONST (intervals);
7177 then
7278 (cache, startTime, stopTime, numberOfIntervals);
73-
79+
7480 // normal case, fill in defaults
7581 case (cache,env,{Absyn . CREF (componentRef = cr)},args,impl,SOME (st),pre,info,_)
7682 equation
@@ -92,7 +98,7 @@ algorithm
9298 pre, info);
9399 then
94100 (cache, startTime, stopTime, numberOfIntervals);
95-
101+
96102 end matchcontinue;
97103end calculateSimulationTimes;
98104
0 commit comments