Skip to content

Commit

Permalink
- All clients runtimes are moved to OMTools/bin
Browse files Browse the repository at this point in the history
- All required qt libs are moved to OMTools/qtdlls
- Some updates in OMPlot and OMEdit
- plotParametric3 and plotAll3 is added.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8524 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 6, 2011
1 parent 410b0c7 commit d3ad836
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 8 deletions.
50 changes: 48 additions & 2 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -1101,7 +1101,7 @@ function plot3 "Launches a plot window using OMPlot. Returns true on success.
Example command sequences:
simulate(A);plot({x,y,z});
simulate(A);plot(x);
simulate(A);plot(x, externalWindow=true);
simulate(A,fileNamePrefix=\"B\");simulate(C);plot(z,\"B.mat\",legend=false);
"
input VariableNames vars "The variables you want to plot";
Expand All @@ -1110,7 +1110,6 @@ function plot3 "Launches a plot window using OMPlot. Returns true on success.
input String title := "Plot by OpenModelica" "This text will be used as the diagram title.";
input Boolean legend := true "Determines whether or not the variable legend is shown.";
input Boolean grid := true "Determines whether or not a grid is shown in the diagram.";
input String plotType := "plot" "This text will be used to tell OMPlot what type of plot is requested.";
input Boolean logX := false "Determines whether or not the horizontal axis is logarithmically scaled.";
input Boolean logY := false "Determines whether or not the vertical axis is logarithmically scaled.";
input String xLabel := "time" "This text will be used as the horizontal label in the diagram.";
Expand Down Expand Up @@ -1148,6 +1147,29 @@ function plotAll "Works in the same way as plot(), but does not accept any
external "builtin";
end plotAll;

function plotAll3 "Works in the same way as plot(), but does not accept any
variable names as input. Instead, all variables are part of the plot window.
Example command sequences:
simulate(A);plotAll();
simulate(A);plotAll(externalWindow=true);
simulate(A,fileNamePrefix=\"B\");simulate(C);plotAll(x,\"B.mat\");"

input Boolean externalWindow := false "Opens the plot in a new plot window";
input String fileName := "<default>" "The filename containing the variables. <default> will read the last simulation result";
input String title := "Plot by OpenModelica" "This text will be used as the diagram title.";
input Boolean legend := true "Determines whether or not the variable legend is shown.";
input Boolean grid := true "Determines whether or not a grid is shown in the diagram.";
input Boolean logX := false "Determines whether or not the horizontal axis is logarithmically scaled.";
input Boolean logY := false "Determines whether or not the vertical axis is logarithmically scaled.";
input String xLabel := "time" "This text will be used as the horizontal label in the diagram.";
input String yLabel := "" "This text will be used as the vertical label in the diagram.";
input Real xRange[2] := {0.0,0.0} "Determines the horizontal interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real yRange[2] := {0.0,0.0} "Determines the vertical interval that is visible in the diagram. {0,0} will select a suitable range.";
output Boolean success "Returns true on success";
external "builtin";
end plotAll3;

function plot2 "Uses the Java-based plot window (ptplot.jar) to launch a plot,
similar to the plot() command. This command accepts fewer options, but works
even when OpenModelica was not compiled with sendData support.
Expand Down Expand Up @@ -1214,6 +1236,30 @@ function plotParametric2 "Plots the y-variables as a function of the x-variable.
external "builtin";
end plotParametric2;

function plotParametric3 "Launches a plotParametric window using OMPlot. Returns true on success.
Don't require sendData support.
Example command sequences:
simulate(A);plotParametric2(x,y);
simulate(A);plotParametric2(x,y, externalWindow=true);
"
input VariableName xVariable;
input VariableName yVariable;
input Boolean externalWindow := false "Opens the plot in a new plot window";
input String fileName := "<default>" "The filename containing the variables. <default> will read the last simulation result";
input String title := "Plot by OpenModelica" "This text will be used as the diagram title.";
input Boolean legend := true "Determines whether or not the variable legend is shown.";
input Boolean grid := true "Determines whether or not a grid is shown in the diagram.";
input Boolean logX := false "Determines whether or not the horizontal axis is logarithmically scaled.";
input Boolean logY := false "Determines whether or not the vertical axis is logarithmically scaled.";
input String xLabel := "time" "This text will be used as the horizontal label in the diagram.";
input String yLabel := "" "This text will be used as the vertical label in the diagram.";
input Real xRange[2] := {0.0,0.0} "Determines the horizontal interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real yRange[2] := {0.0,0.0} "Determines the vertical interval that is visible in the diagram. {0,0} will select a suitable range.";
output Boolean success "Returns true on success";
external "builtin";
end plotParametric3;

function uriToFilename "Handles modelica:// and file:// URI's. The result is an absolute path on the local system.
The result depends on the current MODELICAPATH. Returns the empty string on failure."
input String uri;
Expand Down
90 changes: 86 additions & 4 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -633,7 +633,7 @@ algorithm
list<SCode.Class> scodeP,sp,fp;
list<Env.Frame> env;
SCode.Class c;
String s1,str,str1,str2,str3,re,token,varid,cmd,executable,method_str,outputFormat_str,initfilename,cit,pd,executableSuffixedExe,sim_call,result_file,filename_1,filename,omhome_1,plotCmd,tmpPlotFile,call,str_1,mp,pathstr,name,cname,fileNamePrefix_s,errMsg,errorStr,uniqueStr,interpolation,plotType,title,xLabel,yLabel,filename2,varNameStr,xml_filename,xml_contents,visvar_str,pwd,omhome,omlib,omcpath,os,platform,usercflags,senddata,res,workdir,gcc,confcmd,touch_file,uname,filenameprefix;
String s1,str,str1,str2,str3,re,token,varid,cmd,executable,method_str,outputFormat_str,initfilename,cit,pd,executableSuffixedExe,sim_call,result_file,filename_1,filename,omhome_1,plotCmd,tmpPlotFile,call,str_1,mp,pathstr,name,cname,fileNamePrefix_s,errMsg,errorStr,uniqueStr,interpolation,title,xLabel,yLabel,filename2,varNameStr,xml_filename,xml_contents,visvar_str,pwd,omhome,omlib,omcpath,os,platform,usercflags,senddata,res,workdir,gcc,confcmd,touch_file,uname,filenameprefix;
DAE.ComponentRef cr,cref,classname;
Interactive.InteractiveSymbolTable newst,st_1;
Absyn.Program p,pnew,newp,ptot;
Expand All @@ -651,7 +651,7 @@ algorithm
array<list<Integer>> m,mt;
Option<array<list<Integer>>> om,omt;
Option<list<tuple<Integer, Integer, BackendDAE.Equation>>> jac;
Values.Value ret_val,simValue,size_value,value,v,cvar,xRange,yRange,xRange1,xRange2,yRange1,yRange2;
Values.Value ret_val,simValue,size_value,value,v,cvar,cvar2,xRange,yRange,xRange1,xRange2,yRange1,yRange2;
DAE.Exp exp,size_expression,bool_exp,storeInTemp,translationLevel,addOriginalIncidenceMatrix,addSolvingInfo,addMathMLCode,dumpResiduals,varName,varTimeStamp;
Absyn.ComponentRef cr_1;
Integer size,length,resI,timeStampI,i,n;
Expand Down Expand Up @@ -1527,6 +1527,46 @@ algorithm
case (cache,env,"plotAll",_,st,msg)
then (cache,Values.BOOL(false),st);

//plotAll(model)
case (cache,env,"plotAll3",
{
Values.BOOL(externalWindow),
Values.STRING(filename),
Values.STRING(title),
Values.BOOL(legend),
Values.BOOL(grid),
Values.BOOL(logX),
Values.BOOL(logY),
Values.STRING(xLabel),
Values.STRING(yLabel),
Values.ARRAY(valueLst={Values.REAL(x1),Values.REAL(x2)}),
Values.ARRAY(valueLst={Values.REAL(y1),Values.REAL(y2)})
},
st,
msg)
equation
// get OPENMODELICAHOME
omhome = Settings.getInstallationDirectoryPath();
// get the simulation filename
(cache,filename) = cevalCurrentSimulationResultExp(cache,env,filename,st,msg);
pd = System.pathDelimiter();
// create absolute path of simulation result file
str1 = System.pwd() +& pd +& filename;
s1 = Util.if_(System.os() ==& "Windows_NT", ".exe", "");
filename = Util.if_(System.regularFileExists(str1), str1, filename);
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "\"" +& filename +& "\" \"" +& title +& "\" \"" +& boolString(legend) +& "\" \"" +& boolString(grid) +& "\" \"plotall\" \"" +& boolString(logX) +& "\" \"" +& boolString(logY) +& "\" \"" +& xLabel +& "\" \"" +& yLabel +& "\" \"" +& realString(x1) +& "\" \"" +& realString(x2) +& "\" \"" +& realString(y1) +& "\" \"" +& realString(y2) +& "\" -ew \"" +& boolString(externalWindow) +& "\"";
call = str2 +& " " +& str3;

0 = System.spawnCall(str2, call);
then
(cache,Values.BOOL(true),st);

case (cache,env,"plotAll3",_,st,msg)
then (cache,Values.BOOL(false),st);

// plot without sendData support is plot2()
case (cache,env,"plot",_,st,msg)
equation
Expand Down Expand Up @@ -1575,7 +1615,6 @@ algorithm
Values.STRING(title),
Values.BOOL(legend),
Values.BOOL(grid),
Values.STRING(plotType),
Values.BOOL(logX),
Values.BOOL(logY),
Values.STRING(xLabel),
Expand All @@ -1601,7 +1640,7 @@ algorithm
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "\"" +& filename +& "\" \"" +& title +& "\" \"" +& boolString(legend) +& "\" \"" +& boolString(grid) +& "\" \"" +& plotType +& "\" \"" +& boolString(logX) +& "\" \"" +& boolString(logY) +& "\" \"" +& xLabel +& "\" \"" +& yLabel +& "\" \"" +& realString(x1) +& "\" \"" +& realString(x2) +& "\" \"" +& realString(y1) +& "\" \"" +& realString(y2) +& "\" \"" +& str +& "\" -ew \"" +& boolString(externalWindow) +& "\"";
str3 = "\"" +& filename +& "\" \"" +& title +& "\" \"" +& boolString(legend) +& "\" \"" +& boolString(grid) +& "\" \"plot\" \"" +& boolString(logX) +& "\" \"" +& boolString(logY) +& "\" \"" +& xLabel +& "\" \"" +& yLabel +& "\" \"" +& realString(x1) +& "\" \"" +& realString(x2) +& "\" \"" +& realString(y1) +& "\" \"" +& realString(y2) +& "\" \"" +& str +& "\" -ew \"" +& boolString(externalWindow) +& "\"";
call = str2 +& " " +& str3;

0 = System.spawnCall(str2, call);
Expand Down Expand Up @@ -1711,6 +1750,49 @@ algorithm
case (cache,env,"plotParametric",_,st,msg)
then (cache,Values.BOOL(false),st);

// plotParametric3
case (cache,env,"plotParametric3",
{
cvar,
cvar2,
Values.BOOL(externalWindow),
Values.STRING(filename),
Values.STRING(title),
Values.BOOL(legend),
Values.BOOL(grid),
Values.BOOL(logX),
Values.BOOL(logY),
Values.STRING(xLabel),
Values.STRING(yLabel),
Values.ARRAY(valueLst={Values.REAL(x1),Values.REAL(x2)}),
Values.ARRAY(valueLst={Values.REAL(y1),Values.REAL(y2)})
},
st,msg)
equation
// get the variables
str = ValuesUtil.printCodeVariableName(cvar) +& "\" \"" +& ValuesUtil.printCodeVariableName(cvar2);
// get OPENMODELICAHOME
omhome = Settings.getInstallationDirectoryPath();
// get the simulation filename
(cache,filename) = cevalCurrentSimulationResultExp(cache,env,filename,st,msg);
pd = System.pathDelimiter();
// create absolute path of simulation result file
str1 = System.pwd() +& pd +& filename;
s1 = Util.if_(System.os() ==& "Windows_NT", ".exe", "");
filename = Util.if_(System.regularFileExists(str1), str1, filename);
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "\"" +& filename +& "\" \"" +& title +& "\" \"" +& boolString(legend) +& "\" \"" +& boolString(grid) +& "\" \"plotparametric\" \"" +& boolString(logX) +& "\" \"" +& boolString(logY) +& "\" \"" +& xLabel +& "\" \"" +& yLabel +& "\" \"" +& realString(x1) +& "\" \"" +& realString(x2) +& "\" \"" +& realString(y1) +& "\" \"" +& realString(y2) +& "\" \"" +& str +& "\" -ew \"" +& boolString(externalWindow) +& "\"";
call = str2 +& " " +& str3;

0 = System.spawnCall(str2, call);
then
(cache,Values.BOOL(true),st);

case (cache,env,"plotParametric3",_,st,msg)
then (cache,Values.BOOL(false),st);

case (cache,env,"echo",{v as Values.BOOL(bval)},st,msg)
equation
setEcho(bval);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/systemimpl.c
Expand Up @@ -531,7 +531,7 @@ int SystemImpl__spawnCall(const char* path, const char* str)

fflush(NULL); /* flush output so the testsuite is deterministic */
#if defined(__MINGW32__) || defined(_MSC_VER)
status = spawnl(P_NOWAIT, path, str, "", NULL);
status = spawnl(P_DETACH, path, str, "", NULL);
#else
pid_t pID = vfork();
if (pID == 0) { // child
Expand Down
6 changes: 5 additions & 1 deletion OMTools/OMTools.pro
@@ -1,6 +1,10 @@
TEMPLATE = subdirs

CONFIG = release

SUBDIRS += ../OMEdit/OMEditGUI \
../OMShell/OMShellGUI \
../OMNotebook/OMNotebookGUI \
../OMNotebook/OMPlotWindow
../OMNotebook/OMPlotWindow \
../OMOptim/build/OMOptim.pro \
../OMPlot/OMPlotGUI

0 comments on commit d3ad836

Please sign in to comment.