Skip to content

Commit

Permalink
Implemented readSimulationResultSize in the Interactive API
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1904 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Kaj Nyström committed Sep 30, 2005
1 parent b773cc3 commit 14d6fbb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
28 changes: 25 additions & 3 deletions Compiler/Ceval.rml
Expand Up @@ -1276,18 +1276,40 @@ end
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("instantiateModel"),[Exp.CREF(cr,_)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> (Values.STRING(str),Interactive.SYMBOLTABLE(p,sp,ic,iv,cf))

rule Util.list_map(vars,Exp.print_exp_str) => vars' &
(* relation ceval : (Env.Env, Exp.Exp, bool (implicit) ,
Interactive.InteractiveSymbolTable option,
int option, ( dimensions )
Msg)
=> (Values.Value, Interactive.InteractiveSymbolTable option)
*)

rule ceval(env,size_expression,true,SOME(st),NONE,msg) =>
(size_value as Values.INTEGER(size),SOME(st)) &
Util.list_map(vars,Exp.print_exp_str) => vars' &
System.pwd() => pwd &
System.path_delimiter => pd &
Util.string_append_list([pwd,pd,filename]) => filename' &
System.read_ptolemyplot_dataset(filename',vars',size) => value
------------------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("readSimulationResult"),[Exp.SCONST(filename),Exp.ARRAY(_,_,vars),Exp.ICONST(size)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("readSimulationResult"),[Exp.SCONST(filename),Exp.ARRAY(_,_,vars),size_expression],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> (value,st)

rule Print.print_error_buf "#Error reading simulation result. Check that filename and variablenames are correct.\n"
------------------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("readSimulationResult"),[Exp.SCONST(filename),Exp.ARRAY(_,_,vars),Exp.ICONST(size)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("readSimulationResult"),[Exp.SCONST(filename),Exp.ARRAY(_,_,_),_],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> fail

rule System.pwd() => pwd &
System.path_delimiter => pd &
Util.string_append_list([pwd,pd,filename]) => filename' &
System.read_ptolemyplot_dataset_size(filename') => value
------------------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("readSimulationResultSize"),[Exp.SCONST(filename)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> (value,st)

rule Print.print_error_buf "#Error reading simulation result when checking its size. Check that filename and variablenames are correct.\n"
------------------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("readSimulationResultSize"),[Exp.SCONST(filename)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> fail

rule (* plot *)
Expand Down
22 changes: 19 additions & 3 deletions Compiler/Static.rml
Expand Up @@ -2409,23 +2409,39 @@ relation elab_call_interactive : (Env.Env, Absyn.ComponentRef, Absyn.Exp list,Ab
SOME(st))

rule elab_variablenames(vars) => vars' &
elab_exp(env,size_absyn,false,SOME(st)) => (size_exp,ptop, st') &
list_length(vars) => var_len
------------------------------------------------------------------
elab_call_interactive(env, Absyn.CREF_IDENT("readSimulationResult",_),
[ Absyn.STRING(filename),
Absyn.ARRAY(vars),
Absyn.INTEGER(size)
size_absyn
],args,impl,
SOME(st))
=> (Exp.CALL(Absyn.IDENT("readSimulationResult"),
[Exp.SCONST(filename),
Exp.ARRAY(Exp.OTHER,false,vars'),
Exp.ICONST(size)],
size_exp],
false,
true),
Types.PROP((Types.T_ARRAY(Types.DIM(SOME(size)),
Types.PROP((Types.T_ARRAY(Types.DIM(NONE),
(Types.T_ARRAY(Types.DIM(SOME(var_len)), (Types.T_REAL([]),NONE)),NONE)),NONE),Types.C_VAR),
SOME(st))

rule (*elab_variablenames(vars) => vars' &
list_length(vars) => var_len *)
------------------------------------------------------------------
elab_call_interactive(env, Absyn.CREF_IDENT("readSimulationResultSize",_),
[ Absyn.STRING(filename)],
args,impl,
SOME(st))
=> (Exp.CALL(Absyn.IDENT("readSimulationResultSize"),
[Exp.SCONST(filename)],
false,
true),
Types.PROP((Types.T_INTEGER([]),NONE),Types.C_VAR),
SOME(st))


rule elab_variablenames(vars) => vars'
------------------------------------------------------------------
Expand Down

0 comments on commit 14d6fbb

Please sign in to comment.