Skip to content

Commit

Permalink
Implemented the command plotParametric
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1991 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Kaj Nyström committed Nov 28, 2005
1 parent b5f6c2a commit 65484d6
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
48 changes: 48 additions & 0 deletions Compiler/Ceval.rml
Expand Up @@ -1421,6 +1421,54 @@ axiom ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("clear"),[],_,_),s
axiom ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("plot"),[Exp.ARRAY(_,_,vars)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> (Values.STRING("Unknown error while plotting"),st)


(*start plotparametric*)

rule (* plotparametric *)
Util.list_map(vars,Exp.print_exp_str) => vars' &
(* Util.list_union_elt("time",vars') => vars'' & *)
ceval(env,Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",[]),Exp.OTHER),true,SOME(st),NONE,msg)
=> (Values.RECORD(_,[Values.STRING(filename)],_),_) &
System.read_ptolemyplot_dataset(filename,vars',0) => value &
System.pwd() => pwd &
win_citation() => cit &
System.read_env("OPENMODELICAHOME") => omhome &
System.trim(omhome,"\"") => omhome' &
System.path_delimiter => pd &
Util.string_append_list([cit,omhome',pd,"Compiler",pd,"scripts",pd,"doPlot",cit]) => plotCmd &
Util.string_append_list([pwd,pd,"tmpPlot.plt"]) => tmpPlotFile &
Values.write_ptolemyplot_dataset(tmpPlotFile,value,vars',"Plot by OpenModelica")
=> res &
Util.string_append_list([cit,plotCmd, " \"", tmpPlotFile,"\"",cit]) => call &
System.system_call(call) => _
------------------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("plotParametric"),[Exp.ARRAY(_,_,vars)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> (Values.BOOL(true),st)

rule (* Catch error reading simulation file. *)
Util.list_map(vars,Exp.print_exp_str) => vars' &
(*Util.list_union_elt("time",vars') => vars'' & *)
ceval(env,Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",[]),Exp.OTHER),true,SOME(st),NONE,msg)
=> (Values.RECORD(_,[Values.STRING(filename)],_),_) &
not System.read_ptolemyplot_dataset(filename,vars',0) => _
---------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("plotParametric"),[Exp.ARRAY(_,_,vars)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> (Values.STRING("Error reading the simulation result."),st)

rule (* Catch error reading simulation file. *)
Util.list_map(vars,Exp.print_exp_str) => vars' &
(*Util.list_union_elt("time",vars') => vars'' &*)
not ceval(env,Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",[]),Exp.OTHER),true,SOME(st),NONE,NO_MSG)
=> (_,_)
---------------------------
ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("plotParametric"),[Exp.ARRAY(_,_,vars)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> (Values.STRING("No simulation result to plot."),st)

axiom ceval_interactive_functions (env, Exp.CALL(Absyn.IDENT("plotParametric"),[Exp.ARRAY(_,_,vars)],_,_),st as Interactive.SYMBOLTABLE(p,sp,ic,iv,cf),msg)
=> (Values.STRING("Unknown error while plotting"),st)

(*end plotparametric*)

rule System.time => t1 &
ceval(env,exp,true,SOME(st),NONE,msg) => (value,SOME(st')) &
System.time => t2 &
Expand Down
28 changes: 28 additions & 0 deletions Compiler/Static.rml
Expand Up @@ -2881,6 +2881,34 @@ relation elab_call_interactive : (Env.Env, Absyn.ComponentRef, Absyn.Exp list,Ab
Types.PROP((Types.T_BOOL([]),NONE),Types.C_VAR),
SOME(st))

(*plotParametric*)

rule elab_variablenames([cr]) => vars'
------------------------------------------------------------------
elab_call_interactive(env, Absyn.CREF_IDENT("plotParametric",_),
[cr as Absyn.CREF(_)],[],impl,
SOME(st))
=> (Exp.CALL(Absyn.IDENT("plotParametric"),
[Exp.ARRAY(Exp.OTHER,false,vars')],
false,
true),
Types.PROP((Types.T_BOOL([]),NONE),Types.C_VAR),
SOME(st))

rule elab_variablenames(vars) => vars'
------------------------------------------------------------------
elab_call_interactive(env, Absyn.CREF_IDENT("plotParametric",_),
[Absyn.ARRAY(vars)],[],impl,
SOME(st))
=> (Exp.CALL(Absyn.IDENT("plotParametric"),
[Exp.ARRAY(Exp.OTHER,false,vars')],
false,
true),
Types.PROP((Types.T_BOOL([]),NONE),Types.C_VAR),
SOME(st))

(*plotParametric*)


rule elab_exp(env,exp,impl,SOME(st)) => (exp',prop,st')
------------------------------------------------------------------
Expand Down
12 changes: 9 additions & 3 deletions Compiler/helptext.txt
Expand Up @@ -43,13 +43,19 @@ loadModel(name) - Load model, function, or package relative to $MODE
MODELICAPATH pointing at the wrong location.


plot(var) - Plot a variable from the most recently simulated model.
plot(var) - Plot a variable relative to time from the most recently
simulated model.
Ex: plot(x)

plot(vars) - Plot variables from the most recently simulated model
given as a vector.
plot(vars) - Plot variables given as a vector relative to time from
the most recently simulated model
Ex: plot({x,y})

plotParametric(vars) - Plot variables relative to the first variable in the
argument vector.
Ex: plot({x,y,z })
(Plotting y and z as functions of x)

readFile(str) - Load file given as string and return a string of the
file content.
Ex: readFile("myModel/myModelr.mo")
Expand Down

0 comments on commit 65484d6

Please sign in to comment.