- Index
- » Developer
- » OpenModelica development
- » Test with the "Util.if_ "function
Test with the "Util.if_ "function
Test with the "Util.if_ "function
Hi every one,
First, thank you for the attention and help you'll give to this post.
I don't succed to use the function "Util.if_ " in the following exemple , I don't know how to initialize the list<DAE.ComponentRef> connectorCref. !!
Thanks for your help
Regards
Alain
/-------------------------------------
protected function sortVars_ALAIN
input list<BackendDAE.Var> inVars;
input list<DAE.ComponentRef> inConnectorCref;
output list<DAE.ComponentRef> outConnectorCref;
protected
list<DAE.ComponentRef> outCref;
algorithm
outCref := sortConnectorVars(inVars,1);
outConnectorCref := listAppend(inConnectorCref,outCref);
end sortVars_ALAIN
//-----------------------------------------------------------------------------------------------
protected function sortConnectorVars
"Sort the variables keeping their componentReference."
input list<BackendDAE.Var> inVarLst;
input Integer inInteger;
output list<DAE.ComponentRef> outConnectorCref;
algorithm
outConnectorCref :=
matchcontinue (inVarLst,inInteger)
local
Integer varno;
list<DAE.ComponentRef> outCRLst;
Integer var_1;
list<DAE.ComponentRef> connectorCref;
BackendDAE.Var v;
DAE.ComponentRef cr;
DAE.ConnectorType ct;
list<BackendDAE.Var> xs;
case ({},_) then {};
case (((v as BackendDAE.VAR(varName=cr,connectorType=ct))::xs),varno)
equation
connectorCref = Util.if_(BackendVariable.isVarConnector(v),listAppend(connectorCref,{BackendVariable.varCref(v)}),connectorCref); <========= ?????
//connectorCref = ListAppend(Util.if_(BackendVariable.isVarConnector(v),BackendVariable.varCref(v),{}), connectorCref);
//connectorCref = List.fold(,addVcref,{});
var_1 = varno+1;
outCRLst = sortConnectorVars(xs,var_1);
then
outCRLst;
end matchcontinue;
end sortConnectorVars;
Re: Test with the "Util.if_ "function
According to me, this next development can be used
Regards
Alain
vars_cref = getCrefs(vars,vars_cref);
//-------------------------------------
protected function getCrefs
input list<BackendDAE.Var> inVars;
input list<DAE.ComponentRef> inCR;
output list<DAE.ComponentRef> outCR;
algorithm
outCR := match(inVars,inCR)
local
BackendDAE.Var v1;
list<BackendDAE.Var> tail;
DAE.ComponentRef lCR;
case ({},_) then inCR;
case (v1 :: tail,_)
equation
lCR = BackendVariable.varCref(v1);
then getCrefs(tail,listAppend(inCR,{lCR}));
end match;
end getCrefs;
- Index
- » Developer
- » OpenModelica development
- » Test with the "Util.if_ "function