Skip to content

Commit

Permalink
- Removed the plotSilent flag.
Browse files Browse the repository at this point in the history
- Added argument forceOMPlot to plot APIs.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25696 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 22, 2015
1 parent 753a764 commit e4baa36
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 199 deletions.
17 changes: 3 additions & 14 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -2460,20 +2460,6 @@ external "builtin";
annotation(preferredView="text");
end getPackages;

function setPlotSilent "Sets the plotSilent flag."
input Boolean silent;
output Boolean success;
algorithm
success := setCommandLineOptions("+plotSilent=" + String(silent));
annotation(__OpenModelica_EarlyInline = true, preferredView="text");
end setPlotSilent;

function getPlotSilent "Returns true if plotSilent flag is set."
output Boolean plotSilent;
external "builtin";
annotation(preferredView="text");
end getPlotSilent;

partial function basePlotFunction "Extending this does not seem to work at the moment. A real shame; functions below are copy-paste and all need to be updated if the interface changes."
input String fileName = "<default>" "The filename containing the variables. <default> will read the last simulation result";
input String interpolation = "linear" "
Expand Down Expand Up @@ -2512,6 +2498,7 @@ function plot "Launches a plot window using OMPlot."
input String legendPosition = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
input Boolean forceOMPlot = false "if true launches OMPlot and doesn't call callback function even if it is defined.";
output Boolean success "Returns true on success";
external "builtin";
annotation(preferredView="text",Documentation(info="<html>
Expand Down Expand Up @@ -2549,6 +2536,7 @@ function plotAll "Works in the same way as plot(), but does not accept any
input String legendPosition = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
input Boolean forceOMPlot = false "if true launches OMPlot and doesn't call callback function even if it is defined.";
output Boolean success "Returns true on success";
external "builtin";
annotation(preferredView="text");
Expand Down Expand Up @@ -2593,6 +2581,7 @@ function plotParametric "Launches a plotParametric window using OMPlot. Returns
input String legendPosition = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
input Boolean forceOMPlot = false "if true launches OMPlot and doesn't call callback function even if it is defined.";
output Boolean success "Returns true on success";
external "builtin";
annotation(preferredView="text");
Expand Down
242 changes: 70 additions & 172 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -928,7 +928,7 @@ algorithm
Real timeTotal,timeSimulation,timeStamp,val,x1,x2,y1,y2,r,r1,r2,linearizeTime,curveWidth,offset,offset1,offset2,scaleFactor,scaleFactor1,scaleFactor2;
GlobalScript.Statements istmts;
list<GlobalScript.Statements> istmtss;
Boolean have_corba, bval, anyCode, b, b1, b2, externalWindow, logX, logY, autoScale, gcc_res, omcfound, rm_res, touch_res, uname_res, ifcpp, ifmsvc,sort, builtin, showProtected, inputConnectors, outputConnectors;
Boolean have_corba, bval, anyCode, b, b1, b2, externalWindow, logX, logY, autoScale, forceOMPlot, gcc_res, omcfound, rm_res, touch_res, uname_res, ifcpp, ifmsvc,sort, builtin, showProtected, inputConnectors, outputConnectors;
FCore.Cache cache;
list<GlobalScript.LoadedFile> lf;
Absyn.ComponentRef crefCName;
Expand Down Expand Up @@ -2959,12 +2959,6 @@ algorithm
case (cache,_,"checkCodeGraph",_,st,_)
then (cache,Values.STRING("Error in checkCodeGraph"),st);

case (cache,_,"getPlotSilent",{},st,_)
equation
b = Config.getPlotSilent();
then
(cache,Values.BOOL(b),st);

//plotAll(model)
case (cache,env,"plotAll",
{
Expand All @@ -2982,13 +2976,12 @@ algorithm
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer),
Values.BOOL(autoScale)
Values.BOOL(autoScale),
Values.BOOL(forceOMPlot)
},
st,
_)
equation
// check if plot is set to silent or not
false = Config.getPlotSilent();
// get OPENMODELICAHOME
omhome = Settings.getInstallationDirectoryPath();
// get the simulation filename
Expand All @@ -2998,55 +2991,27 @@ algorithm
str1 = System.pwd() + pd + filename;
s1 = if System.os() == "Windows_NT" then ".exe" else "";
filename = if System.regularFileExists(str1) then str1 else filename;
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --plotAll --logx=" + boolString(logX) + " --logy=" + boolString(logY) + " --xlabel=\"" + xLabel + "\" --ylabel=\"" + yLabel + "\" --xrange=" + realString(x1) + ":" + realString(x2) + " --yrange=" + realString(y1) + ":" + realString(y2) + " --new-window=" + boolString(externalWindow) + " --curve-width=" + realString(curveWidth) + " --curve-style=" + intString(curveStyle) + " --legend-position=\"" + legendPosition + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale);
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
then
(cache,Values.BOOL(true),st);

/* in case plot is set to silent */
case (cache,env,"plotAll",
{
Values.BOOL(externalWindow),
Values.STRING(filename),
Values.STRING(title),
Values.STRING(gridStr),
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)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,
_)
equation
// check if plot is set to silent or not
true = Config.getPlotSilent();
// 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;
filename = if System.regularFileExists(str1) then str1 else filename;
logXStr = boolString(logX);
logYStr = boolString(logY);
x1Str = realString(x1);
x2Str = realString(x2);
y1Str = realString(y1);
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
autoScaleStr = boolString(autoScale);
System.plotCallBack(externalWindow,filename,title,gridStr,"plotall",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr,"");
// check if plot callback is defined
b = System.plotCallBackDefined();
if boolOr(forceOMPlot, boolNot(b)) then
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --plotAll --logx=" + boolString(logX) + " --logy=" + boolString(logY) + " --xlabel=\"" + xLabel + "\" --ylabel=\"" + yLabel + "\" --xrange=" + realString(x1) + ":" + realString(x2) + " --yrange=" + realString(y1) + ":" + realString(y2) + " --new-window=" + boolString(externalWindow) + " --curve-width=" + realString(curveWidth) + " --curve-style=" + intString(curveStyle) + " --legend-position=\"" + legendPosition + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale);
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
elseif b then
logXStr = boolString(logX);
logYStr = boolString(logY);
x1Str = realString(x1);
x2Str = realString(x2);
y1Str = realString(y1);
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
autoScaleStr = boolString(autoScale);
System.plotCallBack(externalWindow,filename,title,gridStr,"plotall",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr,"");
end if;
then
(cache,Values.BOOL(true),st);

Expand All @@ -3071,12 +3036,11 @@ algorithm
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer),
Values.BOOL(autoScale)
Values.BOOL(autoScale),
Values.BOOL(forceOMPlot)
},
st,_)
equation
// check if plot is set to silent or not
false = Config.getPlotSilent();
// get the variables list
vars_1 = List.map(cvars, ValuesUtil.printCodeVariableName);
// seperate the variables
Expand All @@ -3090,59 +3054,27 @@ algorithm
str1 = System.pwd() + pd + filename;
s1 = if System.os() == "Windows_NT" then ".exe" else "";
filename = if System.regularFileExists(str1) then str1 else filename;
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --plot --logx=" + boolString(logX) + " --logy=" + boolString(logY) + " --xlabel=\"" + xLabel + "\" --ylabel=\"" + yLabel + "\" --xrange=" + realString(x1) + ":" + realString(x2) + " --yrange=" + realString(y1) + ":" + realString(y2) + " --new-window=" + boolString(externalWindow) + " --curve-width=" + realString(curveWidth) + " --curve-style=" + intString(curveStyle) + " --legend-position=\"" + legendPosition + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale) + " \"" + str + "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
then
(cache,Values.BOOL(true),st);

/* in case plot is set to silent */
case (cache,env,"plot",
{
Values.ARRAY(valueLst = cvars),
Values.BOOL(externalWindow),
Values.STRING(filename),
Values.STRING(title),
Values.STRING(gridStr),
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)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,_)
equation
// check if plot is set to silent or not
true = Config.getPlotSilent();
// get the variables list
vars_1 = List.map(cvars, ValuesUtil.printCodeVariableName);
// seperate the variables
str = stringDelimitList(vars_1,"\" \"");
// 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;
filename = if System.regularFileExists(str1) then str1 else filename;
logXStr = boolString(logX);
logYStr = boolString(logY);
x1Str = realString(x1);
x2Str = realString(x2);
y1Str = realString(y1);
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
autoScaleStr = boolString(autoScale);
System.plotCallBack(externalWindow,filename,title,gridStr,"plot",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr,str);
// check if plot callback is defined
b = System.plotCallBackDefined();
if boolOr(forceOMPlot, boolNot(b)) then
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --plot --logx=" + boolString(logX) + " --logy=" + boolString(logY) + " --xlabel=\"" + xLabel + "\" --ylabel=\"" + yLabel + "\" --xrange=" + realString(x1) + ":" + realString(x2) + " --yrange=" + realString(y1) + ":" + realString(y2) + " --new-window=" + boolString(externalWindow) + " --curve-width=" + realString(curveWidth) + " --curve-style=" + intString(curveStyle) + " --legend-position=\"" + legendPosition + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale) + " \"" + str + "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
elseif b then
logXStr = boolString(logX);
logYStr = boolString(logY);
x1Str = realString(x1);
x2Str = realString(x2);
y1Str = realString(y1);
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
autoScaleStr = boolString(autoScale);
System.plotCallBack(externalWindow,filename,title,gridStr,"plot",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr,str);
end if;
then
(cache,Values.BOOL(true),st);

Expand Down Expand Up @@ -3426,12 +3358,11 @@ algorithm
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer),
Values.BOOL(autoScale)
Values.BOOL(autoScale),
Values.BOOL(forceOMPlot)
},
st,_)
equation
// check if plot is set to silent or not
false = Config.getPlotSilent();
// get the variables
str = ValuesUtil.printCodeVariableName(cvar) + "\" \"" + ValuesUtil.printCodeVariableName(cvar2);
// get OPENMODELICAHOME
Expand All @@ -3443,60 +3374,27 @@ algorithm
str1 = System.pwd() + pd + filename;
s1 = if System.os() == "Windows_NT" then ".exe" else "";
filename = if System.regularFileExists(str1) then str1 else filename;
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --plotParametric --logx=" + boolString(logX) + " --logy=" + boolString(logY) + " --xlabel=\"" + xLabel + "\" --ylabel=\"" + yLabel + "\" --xrange=" + realString(x1) + ":" + realString(x2) + " --yrange=" + realString(y1) + ":" + realString(y2) + " --new-window=" + boolString(externalWindow) + " --curve-width=" + realString(curveWidth) + " --curve-style=" + intString(curveStyle) + " --legend-position=\"" + legendPosition + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale) + " \"" + str + "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
then
(cache,Values.BOOL(true),st);

/* in case plot is set to silent */
case (cache,env,"plotParametric",
{
cvar,
cvar2,
Values.BOOL(externalWindow),
Values.STRING(filename),
Values.STRING(title),
Values.STRING(gridStr),
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)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,_)
equation
// check if plot is set to silent or not
true = Config.getPlotSilent();
// get the variables
str = ValuesUtil.printCodeVariableName(cvar);
str3 = ValuesUtil.printCodeVariableName(cvar2);
str = stringAppendList({str, " ", str3});
// 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;
filename = if System.regularFileExists(str1) then str1 else filename;
logXStr = boolString(logX);
logYStr = boolString(logY);
x1Str = realString(x1);
x2Str = realString(x2);
y1Str = realString(y1);
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
autoScaleStr = boolString(autoScale);
System.plotCallBack(externalWindow,filename,title,gridStr,"plotparametric",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr,str);
// check if plot callback is defined
b = System.plotCallBackDefined();
if boolOr(forceOMPlot, boolNot(b)) then
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --plotParametric --logx=" + boolString(logX) + " --logy=" + boolString(logY) + " --xlabel=\"" + xLabel + "\" --ylabel=\"" + yLabel + "\" --xrange=" + realString(x1) + ":" + realString(x2) + " --yrange=" + realString(y1) + ":" + realString(y2) + " --new-window=" + boolString(externalWindow) + " --curve-width=" + realString(curveWidth) + " --curve-style=" + intString(curveStyle) + " --legend-position=\"" + legendPosition + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale) + " \"" + str + "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
elseif b then
logXStr = boolString(logX);
logYStr = boolString(logY);
x1Str = realString(x1);
x2Str = realString(x2);
y1Str = realString(y1);
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
autoScaleStr = boolString(autoScale);
System.plotCallBack(externalWindow,filename,title,gridStr,"plotparametric",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr,str);
end if;
then
(cache,Values.BOOL(true),st);

Expand Down
6 changes: 0 additions & 6 deletions Compiler/Util/Config.mo
Expand Up @@ -302,12 +302,6 @@ algorithm
Flags.setConfigBool(Flags.ORDER_CONNECTIONS, show);
end setOrderConnections;

public function getPlotSilent
output Boolean show;
algorithm
show := Flags.getConfigBool(Flags.PLOT_SILENT);
end getPlotSilent;

public function getPreOptModules
output list<String> outStringLst;
algorithm
Expand Down

0 comments on commit e4baa36

Please sign in to comment.