@@ -145,6 +145,7 @@ public function getSimulationArguments
145145 input list< Absyn . NamedArg > inAbsynNamedArgLst;
146146 input Boolean inImplInst;
147147 input Prefix . Prefix inPrefix;
148+ input String callName;
148149 input SourceInfo inInfo;
149150 input Option < GlobalScript . SimulationOptions > defaultOption;
150151 output FCore . Cache outCache;
@@ -170,6 +171,7 @@ algorithm
170171 // fill in defaults
171172 case (cache,env,{crexp},args,impl,pre,info,_)
172173 equation
174+ checkSimulationArguments(args, callName, info);
173175 exp = Static . elabCodeExp(crexp,cache,env,DAE . C_TYPENAME (),info);
174176 // We need to force eval in order to get the correct prefix
175177 (cache,v) = Ceval . ceval(cache,env,exp,true ,Absyn . MSG (info),0 );
@@ -238,6 +240,36 @@ algorithm
238240 end match;
239241end getSimulationArguments;
240242
243+ constant list< String > VALID_SIMULATE_ARGS = {
244+ "startTime" ,
245+ "stopTime" ,
246+ "numberOfIntervals" ,
247+ "stepSize" ,
248+ "tolerance" ,
249+ "method" ,
250+ "fileNamePrefix" ,
251+ "options" ,
252+ "outputFormat" ,
253+ "variableFilter" ,
254+ "cflags" ,
255+ "simflags"
256+ };
257+
258+ function checkSimulationArguments
259+ input list< Absyn . NamedArg > args;
260+ input String callName;
261+ input SourceInfo info;
262+ protected
263+ list< String > valid_names;
264+ algorithm
265+ for arg in args loop
266+ if not listMember(arg. argName, VALID_SIMULATE_ARGS ) then
267+ Error . addSourceMessage(Error . NO_SUCH_PARAMETER , {callName, arg. argName}, info);
268+ fail();
269+ end if ;
270+ end for ;
271+ end checkSimulationArguments;
272+
241273public function elabCallInteractive "This function elaborates the functions defined in the interactive environment.
242274 Since some of these functions are meta-functions, they can not be described in the type
243275 system, and is thus given the the type T_UNKNOWN"
@@ -323,7 +355,7 @@ algorithm
323355
324356 case (cache,env,Absyn . CREF_IDENT (name = "translateModel" ),{Absyn . CREF ()},args,_,_,_)
325357 equation
326- (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, info, NONE ());
358+ (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, "translateModel" , info, NONE ());
327359 then
328360 (cache,Expression . makePureBuiltinCall("translateModel" ,simulationArgs,DAE . T_STRING_DEFAULT ),DAE . PROP (DAE . T_STRING_DEFAULT ,DAE . C_VAR ()));
329361
@@ -383,42 +415,42 @@ algorithm
383415
384416 case (cache,env,Absyn . CREF_IDENT (name = "buildModel" ),{Absyn . CREF ()},args,_,_,_)
385417 equation
386- (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, info, NONE ());
418+ (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, "buildModel" , info, NONE ());
387419 then
388420 (cache,Expression . makePureBuiltinCall("buildModel" ,simulationArgs,DAE . T_UNKNOWN_DEFAULT ),
389421 DAE . PROP (DAE . T_ARRAY (DAE . T_STRING_DEFAULT ,{DAE . DIM_INTEGER (2 )}),DAE . C_VAR ()));
390422
391423 case (cache,env,Absyn . CREF_IDENT (name = "buildModelBeast" ),{Absyn . CREF ()},args,_,_,_)
392424 equation
393- (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, info, NONE ());
425+ (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, "buildModelBeast" , info, NONE ());
394426 then
395427 (cache,Expression . makePureBuiltinCall("buildModelBeast" ,simulationArgs,DAE . T_UNKNOWN_DEFAULT ),
396428 DAE . PROP (DAE . T_ARRAY (DAE . T_STRING_DEFAULT ,{DAE . DIM_INTEGER (2 )}),DAE . C_VAR ()));
397429
398430 case (cache,env,Absyn . CREF_IDENT (name = "simulate" ),{Absyn . CREF ()},args,_,_,_) /* Fill in rest of defaults here */
399431 equation
400- (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, info, NONE ());
432+ (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, "simulate" , info, NONE ());
401433 recordtype = CevalScriptBackend . getSimulationResultType();
402434 then
403435 (cache,Expression . makePureBuiltinCall("simulate" ,simulationArgs,DAE . T_UNKNOWN_DEFAULT ),DAE . PROP (recordtype,DAE . C_VAR ()));
404436
405437 case (cache,env,Absyn . CREF_IDENT (name = "simulation" ),{Absyn . CREF ()},args,_,_,_) /* Fill in rest of defaults here */
406438 equation
407- (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, info, NONE ());
439+ (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, "simulation" , info, NONE ());
408440 recordtype = CevalScriptBackend . getDrModelicaSimulationResultType();
409441 then
410442 (cache,Expression . makePureBuiltinCall("simulation" ,simulationArgs,DAE . T_UNKNOWN_DEFAULT ),DAE . PROP (recordtype,DAE . C_VAR ()));
411443
412444 case (cache,env,Absyn . CREF_IDENT (name = "linearize" ),{Absyn . CREF ()},args,_,_,_) /* Fill in rest of defaults here */
413445 equation
414- (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, info, NONE ());
446+ (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, "linearize" , info, NONE ());
415447 recordtype = CevalScriptBackend . getSimulationResultType();
416448 then
417449 (cache,Expression . makePureBuiltinCall("linearize" ,simulationArgs,DAE . T_UNKNOWN_DEFAULT ),DAE . PROP (recordtype,DAE . C_VAR ()));
418450
419451 case (cache,env,Absyn . CREF_IDENT (name = "optimize" ),{Absyn . CREF ()},args,_,_,_) /* Fill in rest of defaults here */
420452 equation
421- (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, info, NONE ());
453+ (cache, simulationArgs) = getSimulationArguments(cache, env, inExps, args, inImplInst, inPrefix, "optimize" , info, NONE ());
422454 recordtype = CevalScriptBackend . getSimulationResultType();
423455 then
424456 (cache,Expression . makePureBuiltinCall("optimize" ,simulationArgs,DAE . T_UNKNOWN_DEFAULT ),DAE . PROP (recordtype,DAE . C_VAR ()));
0 commit comments