Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
set hideResult to false for visualization vars
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich authored and OpenModelica-Hudson committed Nov 7, 2016
1 parent e0cca96 commit 39d920f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
9 changes: 9 additions & 0 deletions Compiler/BackEnd/BackendVariable.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,15 @@ algorithm
outVar.bindValue := inBindValue;
end setBindValue;

public function setHideResult "Sets BackendDAE.VAR.hideResult expression.
author: vwaurich 10 2016"
input BackendDAE.Var varIn;
input DAE.Exp hideResultB;
output BackendDAE.Var varOut=varIn;
algorithm
varOut.hideResult := hideResultB;
end setHideResult;

public function setVarDirectionTpl
input output BackendDAE.Var var;
input output DAE.VarDirection dir;
Expand Down
17 changes: 9 additions & 8 deletions Compiler/BackEnd/VisualXML.mo
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,19 @@ algorithm
end try;
end getConstCrefBinding;

public function setVisVarsPublic"Sets the VariableAttributes of protected visualization vars to public.
public function setVisVarsPublic "Sets the VariableAttributes of protected visualization vars to public.
author: waurich TUD 08-2016"
input BackendDAE.Var inVar;
input String dummyArgIn;
output BackendDAE.Var outVar = inVar;
output String dummyArgOut = dummyArgIn;
algorithm
if isVisualizationVar(inVar) then
outVar := makeVarPublic(inVar);
outVar := makeVarPublicHideResultFalse(inVar);
end if;
end setVisVarsPublic;

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

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

protected function setBindingForProtectedVars1"checks if the var is protected and sets the binding (i.e. the solved equation)"
protected function setBindingForProtectedVars1 "checks if the var is protected and sets the binding (i.e. the solved equation)"
input BackendDAE.Var varIn;
input tuple<Integer,array<Integer>,BackendDAE.EquationArray> tplIn;
output BackendDAE.Var varOut;
Expand All @@ -244,12 +245,12 @@ algorithm
BackendDAE.EQUATION(exp=exp1, scalar=exp2) = eq;
(exp1,_) = ExpressionSolve.solve(exp1,exp2,BackendVariable.varExp(varIn));
var = BackendVariable.setBindExp(varIn,SOME(exp1));
var = makeVarPublic(var);
var = makeVarPublicHideResultFalse(var);
then (var,(idx+1,ass1,eqs));
case(_,(idx,ass1,eqs))
equation
if (BackendVariable.isProtectedVar(varIn) and isVisualizationVar(varIn)) then
var = makeVarPublic(varIn);
var = makeVarPublicHideResultFalse(varIn);
else
var = varIn;
end if;
Expand Down
19 changes: 11 additions & 8 deletions Compiler/SimCode/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7306,37 +7306,40 @@ public function simVarString
algorithm
s := match(inVar)
local
Boolean isProtected;
Boolean isProtected,hideResult;
Integer i;
DAE.ComponentRef name, name2;
Option<DAE.Exp> init;
Option<DAE.ComponentRef> arrCref;
Option<Integer> variable_index;
SimCodeVar.AliasVariable aliasvar;
String s1, s2, s3, sProt;
String s1, s2, s3, sProt, sRes;
list<String> numArrayElement;
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NOALIAS(), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NOALIAS(), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected, hideResult=hideResult))
equation
s1 = ComponentReference.printComponentRefStr(name);
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
sProt = if isProtected then " protected " else "";
s = "index: "+intString(i)+": "+s1+" (no alias) "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
sRes = if hideResult then " hideResult " else "";
s = "index: "+intString(i)+": "+s1+" (no alias) "+sProt+sRes+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
then s;
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.ALIAS(varName = name2), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
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))
equation
s1 = ComponentReference.printComponentRefStr(name);
s2 = ComponentReference.printComponentRefStr(name2);
sProt = if isProtected then " protected "else "";
sRes = if hideResult then " hideResult " else "";
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
s = "index: "+intString(i)+": "+s1+" (alias: "+s2+") "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
s = "index: "+intString(i)+": "+s1+" (alias: "+s2+") "+sProt+sRes+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
then s;
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NEGATEDALIAS(varName = name2), index = i, initialValue=init, arrayCref=arrCref,variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
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))
equation
s1 = ComponentReference.printComponentRefStr(name);
s2 = ComponentReference.printComponentRefStr(name2);
sProt = if isProtected then " protected "else "";
sRes = if hideResult then " hideResult " else "";
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
s = "index: "+intString(i)+": "+s1+" (negated alias: "+s2+") "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
s = "index: "+intString(i)+": "+s1+" (negated alias: "+s2+") "+sProt+sRes+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
then s;
end match;
end simVarString;
Expand Down

0 comments on commit 39d920f

Please sign in to comment.