Skip to content

Commit 39d920f

Browse files
vwaurichOpenModelica-Hudson
authored andcommitted
set hideResult to false for visualization vars
1 parent e0cca96 commit 39d920f

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

Compiler/BackEnd/BackendVariable.mo

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,15 @@ algorithm
16291629
outVar.bindValue := inBindValue;
16301630
end setBindValue;
16311631

1632+
public function setHideResult "Sets BackendDAE.VAR.hideResult expression.
1633+
author: vwaurich 10 2016"
1634+
input BackendDAE.Var varIn;
1635+
input DAE.Exp hideResultB;
1636+
output BackendDAE.Var varOut=varIn;
1637+
algorithm
1638+
varOut.hideResult := hideResultB;
1639+
end setHideResult;
1640+
16321641
public function setVarDirectionTpl
16331642
input output BackendDAE.Var var;
16341643
input output DAE.VarDirection dir;

Compiler/BackEnd/VisualXML.mo

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,19 @@ algorithm
182182
end try;
183183
end getConstCrefBinding;
184184

185-
public function setVisVarsPublic"Sets the VariableAttributes of protected visualization vars to public.
185+
public function setVisVarsPublic "Sets the VariableAttributes of protected visualization vars to public.
186186
author: waurich TUD 08-2016"
187187
input BackendDAE.Var inVar;
188188
input String dummyArgIn;
189189
output BackendDAE.Var outVar = inVar;
190190
output String dummyArgOut = dummyArgIn;
191191
algorithm
192192
if isVisualizationVar(inVar) then
193-
outVar := makeVarPublic(inVar);
193+
outVar := makeVarPublicHideResultFalse(inVar);
194194
end if;
195195
end setVisVarsPublic;
196196

197-
protected function makeVarPublic"Sets the VariableAttributes to public.
197+
protected function makeVarPublicHideResultFalse "Sets the VariableAttributes to public and hideResult to false
198198
author: waurich TUD 08-2016"
199199
input BackendDAE.Var inVar;
200200
output BackendDAE.Var outVar;
@@ -204,9 +204,10 @@ algorithm
204204
vals := inVar.values;
205205
vals := DAEUtil.setProtectedAttr(vals,false);
206206
outVar := BackendVariable.setVarAttributes(inVar,vals);
207-
end makeVarPublic;
207+
outVar := BackendVariable.setHideResult(outVar,DAE.BCONST(false));
208+
end makeVarPublicHideResultFalse;
208209

209-
protected function setBindingForProtectedVars"searches for protected vars and sets the binding exp with their equation.
210+
protected function setBindingForProtectedVars "searches for protected vars and sets the binding exp with their equation.
210211
This is needed since protected, time-dependent variables are not stored in result files (in OMC and Dymola)"
211212
input BackendDAE.EqSystem eqSysIn;
212213
output BackendDAE.EqSystem eqSysOut;
@@ -223,7 +224,7 @@ algorithm
223224
eqSysOut := eqSysIn;
224225
end setBindingForProtectedVars;
225226

226-
protected function setBindingForProtectedVars1"checks if the var is protected and sets the binding (i.e. the solved equation)"
227+
protected function setBindingForProtectedVars1 "checks if the var is protected and sets the binding (i.e. the solved equation)"
227228
input BackendDAE.Var varIn;
228229
input tuple<Integer,array<Integer>,BackendDAE.EquationArray> tplIn;
229230
output BackendDAE.Var varOut;
@@ -244,12 +245,12 @@ algorithm
244245
BackendDAE.EQUATION(exp=exp1, scalar=exp2) = eq;
245246
(exp1,_) = ExpressionSolve.solve(exp1,exp2,BackendVariable.varExp(varIn));
246247
var = BackendVariable.setBindExp(varIn,SOME(exp1));
247-
var = makeVarPublic(var);
248+
var = makeVarPublicHideResultFalse(var);
248249
then (var,(idx+1,ass1,eqs));
249250
case(_,(idx,ass1,eqs))
250251
equation
251252
if (BackendVariable.isProtectedVar(varIn) and isVisualizationVar(varIn)) then
252-
var = makeVarPublic(varIn);
253+
var = makeVarPublicHideResultFalse(varIn);
253254
else
254255
var = varIn;
255256
end if;

Compiler/SimCode/SimCodeUtil.mo

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7306,37 +7306,40 @@ public function simVarString
73067306
algorithm
73077307
s := match(inVar)
73087308
local
7309-
Boolean isProtected;
7309+
Boolean isProtected,hideResult;
73107310
Integer i;
73117311
DAE.ComponentRef name, name2;
73127312
Option<DAE.Exp> init;
73137313
Option<DAE.ComponentRef> arrCref;
73147314
Option<Integer> variable_index;
73157315
SimCodeVar.AliasVariable aliasvar;
7316-
String s1, s2, s3, sProt;
7316+
String s1, s2, s3, sProt, sRes;
73177317
list<String> numArrayElement;
7318-
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NOALIAS(), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
7318+
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NOALIAS(), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected, hideResult=hideResult))
73197319
equation
73207320
s1 = ComponentReference.printComponentRefStr(name);
73217321
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
73227322
sProt = if isProtected then " protected " else "";
7323-
s = "index: "+intString(i)+": "+s1+" (no alias) "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
7323+
sRes = if hideResult then " hideResult " else "";
7324+
s = "index: "+intString(i)+": "+s1+" (no alias) "+sProt+sRes+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
73247325
then s;
7325-
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.ALIAS(varName = name2), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
7326+
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.ALIAS(varName = name2), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected, hideResult=hideResult))
73267327
equation
73277328
s1 = ComponentReference.printComponentRefStr(name);
73287329
s2 = ComponentReference.printComponentRefStr(name2);
73297330
sProt = if isProtected then " protected "else "";
7331+
sRes = if hideResult then " hideResult " else "";
73307332
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
7331-
s = "index: "+intString(i)+": "+s1+" (alias: "+s2+") "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
7333+
s = "index: "+intString(i)+": "+s1+" (alias: "+s2+") "+sProt+sRes+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
73327334
then s;
7333-
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NEGATEDALIAS(varName = name2), index = i, initialValue=init, arrayCref=arrCref,variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
7335+
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NEGATEDALIAS(varName = name2), index = i, initialValue=init, arrayCref=arrCref,variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected, hideResult=hideResult))
73347336
equation
73357337
s1 = ComponentReference.printComponentRefStr(name);
73367338
s2 = ComponentReference.printComponentRefStr(name2);
73377339
sProt = if isProtected then " protected "else "";
7340+
sRes = if hideResult then " hideResult " else "";
73387341
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
7339-
s = "index: "+intString(i)+": "+s1+" (negated alias: "+s2+") "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
7342+
s = "index: "+intString(i)+": "+s1+" (negated alias: "+s2+") "+sProt+sRes+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
73407343
then s;
73417344
end match;
73427345
end simVarString;

0 commit comments

Comments
 (0)