diff --git a/Compiler/BackendDAECreate.mo b/Compiler/BackendDAECreate.mo index 986eaedadd1..52dacb3eecd 100644 --- a/Compiler/BackendDAECreate.mo +++ b/Compiler/BackendDAECreate.mo @@ -61,7 +61,6 @@ protected import OptManager; protected import RTOpts; protected import SCode; protected import Util; -protected import Values; public function lower @@ -89,11 +88,11 @@ algorithm BackendDAE.BinTree s; BackendDAE.Variables vars,knvars,vars_1,extVars; BackendDAE.AliasVariables aliasVars "hash table with alias vars' replacements (a=b or a=-b)"; - list eqns,reqns,ieqns,algeqns,multidimeqns,imultidimeqns,eqns_1; + list eqns,reqns,ieqns,algeqns,algeqns1,multidimeqns,imultidimeqns,eqns_1; list aeqns,aeqns1,iaeqns; list algs,algs_1; list whenclauses,whenclauses_1; - list zero_crossings; + list zero_crossings,zero_crossings1; BackendDAE.EquationArray eqnarr,reqnarr,ieqnarr; array arr_md_eqns; array algarr; @@ -119,17 +118,19 @@ algorithm (vars,eqns) = addDummyState(vars, eqns, shouldAddDummyDerivative); whenclauses_1 = listReverse(whenclauses); - algeqns = lowerAlgorithms(vars, algs); + (algeqns,algeqns1) = lowerAlgorithms(vars, algs); (multidimeqns,imultidimeqns) = lowerMultidimeqns(vars, aeqns, iaeqns); eqns = listAppend(algeqns, eqns); eqns = listAppend(multidimeqns, eqns); ieqns = listAppend(imultidimeqns, ieqns); aeqns = listAppend(aeqns,iaeqns); + reqns = listAppend(algeqns1, reqns); (vars,knvars,eqns,reqns,ieqns,aeqns1,algs_1,aliasVars) = BackendDAEOptimize.removeSimpleEquations(vars, knvars, eqns, reqns, ieqns, aeqns, algs, s); vars_1 = detectImplicitDiscrete(vars, eqns); + vars_1 = detectImplicitDiscreteAlgs(vars_1, algs_1); eqns_1 = sortEqn(eqns); (eqns_1,ieqns,aeqns1,algs,vars_1) = expandDerOperator(vars_1,eqns_1,ieqns,aeqns1,algs_1,functionTree); - (zero_crossings) = findZeroCrossings(vars_1,knvars,eqns_1,aeqns1,whenclauses_1,algs); + (zero_crossings) = findZeroCrossings(vars_1,knvars,listAppend(eqns_1,reqns),aeqns1,whenclauses_1,algs); eqnarr = BackendDAEUtil.listEquation(eqns_1); reqnarr = BackendDAEUtil.listEquation(reqns); ieqnarr = BackendDAEUtil.listEquation(ieqns); @@ -155,17 +156,19 @@ algorithm (vars,eqns) = addDummyState(vars, eqns, shouldAddDummyDerivative); whenclauses_1 = listReverse(whenclauses); - algeqns = lowerAlgorithms(vars, algs); + (algeqns,algeqns1) = lowerAlgorithms(vars, algs); (multidimeqns,imultidimeqns) = lowerMultidimeqns(vars, aeqns, iaeqns); eqns = listAppend(algeqns, eqns); eqns = listAppend(multidimeqns, eqns); ieqns = listAppend(imultidimeqns, ieqns); + reqns = listAppend(algeqns1, reqns); // no simplify (vars,knvars,eqns,reqns,ieqns,aeqns1) = .BackendDAEOptimize.removeSimpleEquations(vars, knvars, eqns, reqns, ieqns, aeqns, s); aliasVars = BackendDAEUtil.emptyAliasVariables(); vars_1 = detectImplicitDiscrete(vars, eqns); + vars_1 = detectImplicitDiscreteAlgs(vars_1, algs); eqns_1 = sortEqn(eqns); // no simplify (eqns_1,ieqns,aeqns1,algs,vars_1) = expandDerOperator(vars_1,eqns_1,ieqns,aeqns1,algs); - (zero_crossings) = findZeroCrossings(vars_1,knvars,eqns_1,aeqns,whenclauses_1,algs); + (zero_crossings) = findZeroCrossings(vars_1,knvars,listAppend(eqns_1,reqns),aeqns,whenclauses_1,algs); eqnarr = BackendDAEUtil.listEquation(eqns_1); reqnarr = BackendDAEUtil.listEquation(reqns); ieqnarr = BackendDAEUtil.listEquation(ieqns); @@ -1503,8 +1506,9 @@ protected function lowerAlgorithms input BackendDAE.Variables vars; input list algs; output list eqns; + output list eqns1 "algorithms with no outputs will be moved to known equations"; algorithm - (eqns,_) := lowerAlgorithms2(vars, algs, 0); + (eqns,eqns1,_) := lowerAlgorithms2(vars, algs, 0); end lowerAlgorithms; protected function lowerAlgorithms2 @@ -1517,24 +1521,26 @@ protected function lowerAlgorithms2 input list inAlgorithmAlgorithmLst; input Integer inInteger; output list outEquationLst; + output list outEquationLst1 "algorithms with no outputs will be moved to known equations"; output Integer outInteger; algorithm - (outEquationLst,outInteger) := matchcontinue (inVariables,inAlgorithmAlgorithmLst,inInteger) + (outEquationLst,outEquationLst1,outInteger) := matchcontinue (inVariables,inAlgorithmAlgorithmLst,inInteger) local BackendDAE.Variables vars; BackendDAE.Value aindx; - list eqns,eqns2,res; + list eqns,eqns_1,eqns1,eqns1_1,res,res1; DAE.Algorithm a; list algs; - case (vars,{},aindx) then ({},aindx); + case (vars,{},aindx) then ({},{},aindx); case (vars,(a :: algs),aindx) equation - eqns = lowerAlgorithm(vars, a, aindx); + (eqns,eqns1) = lowerAlgorithm(vars, a, aindx); aindx = aindx + 1; - (eqns2,aindx) = lowerAlgorithms2(vars, algs, aindx); - res = listAppend(eqns, eqns2); + (eqns_1,eqns1_1,aindx) = lowerAlgorithms2(vars, algs, aindx); + res = listAppend(eqns_1, eqns); + res1 = listAppend(eqns1_1, eqns1); then - (res,aindx); + (res,res1,aindx); end matchcontinue; end lowerAlgorithms2; @@ -1549,12 +1555,13 @@ protected function lowerAlgorithm input DAE.Algorithm a; input Integer aindx; output list lst; + output list lst1 "algorithms with no outputs will be moved to known equations"; list inputs,outputs; BackendDAE.Value numnodes; algorithm ((inputs,outputs)) := lowerAlgorithmInputsOutputs(vars, a); numnodes := listLength(outputs); - lst := lowerAlgorithm2(inputs, outputs, numnodes, aindx); + (lst,lst1) := lowerAlgorithm2(inputs, outputs, numnodes, aindx); end lowerAlgorithm; protected function lowerAlgorithm2 @@ -1570,19 +1577,23 @@ protected function lowerAlgorithm2 input Integer inInteger3; input Integer inInteger4; output list outEquationLst; + output list outEquationLst1 "algorithms with no outputs will be moved to known equations"; algorithm - outEquationLst := matchcontinue (inExpExpLst1,inExpExpLst2,inInteger3,inInteger4) + (outEquationLst,outEquationLst1) := matchcontinue (inExpExpLst1,inExpExpLst2,inInteger3,inInteger4) local BackendDAE.Value numnodes_1,numnodes,aindx; - list res; + list res,res1; list inputs,outputs; - case (_,_,0,_) then {}; + case ({},_,0,_) then ({},{}); + case (inputs,outputs,0,aindx) + then + ({},{BackendDAE.ALGORITHM(aindx,inputs,outputs,DAE.emptyElementSource)}); case (inputs,outputs,numnodes,aindx) equation numnodes_1 = numnodes - 1; - res = lowerAlgorithm2(inputs, outputs, numnodes_1, aindx); + (res,res1) = lowerAlgorithm2(inputs, outputs, numnodes_1, aindx); then - (BackendDAE.ALGORITHM(aindx,inputs,outputs,DAE.emptyElementSource) :: res); + (BackendDAE.ALGORITHM(aindx,inputs,outputs,DAE.emptyElementSource) :: res,res1); end matchcontinue; end lowerAlgorithm2; @@ -1668,7 +1679,7 @@ algorithm inputs = Util.listListUnionOnTrue({inputs1, inputs2,inputs3}, Expression.expEqual); outputs = Util.listUnionOnTrue(outputs1, outputs2, Expression.expEqual); then (inputs,outputs); - case(vars, DAE.STMT_FOR(type_= tp, ident = iteratorName, exp = e, statementLst = stmts)) + case(vars, DAE.STMT_FOR(type_= tp, iter = iteratorName, range = e, statementLst = stmts)) local DAE.Ident iteratorName; DAE.Exp iteratorExp; @@ -1726,7 +1737,7 @@ algorithm equation inputs = BackendDAEUtil.statesAndVarsExp(e2, vars); then - (inputs, {e}); + (inputs, {}); case(vars, DAE.STMT_NORETCALL(exp = e)) equation inputs = BackendDAEUtil.statesAndVarsExp(e, vars); @@ -1994,28 +2005,18 @@ algorithm outVariables := matchcontinue (inVariables,inEquationLst) local BackendDAE.Variables v,v_1,v_2; - DAE.ComponentRef cr,orig; - DAE.VarDirection dir; - BackendDAE.Type vartype; - Option bind; - Option value; - list dims; - BackendDAE.Value ind; - DAE.ElementSource source "origin of equation"; - Option attr; - Option comment; - DAE.Flow flowPrefix; - DAE.Stream streamPrefix; + DAE.ComponentRef cr; list xs; + BackendDAE.Var var; case (v,{}) then v; case (v,(BackendDAE.WHEN_EQUATION(whenEquation = BackendDAE.WHEN_EQ(left = cr)) :: xs)) equation - ((BackendDAE.VAR(cr,_,dir,vartype,bind,value,dims,ind,source,attr,comment,flowPrefix,streamPrefix) :: _),_) = BackendVariable.getVar(cr, v); - v_1 = BackendVariable.addVar(BackendDAE.VAR(cr,BackendDAE.DISCRETE(),dir,vartype,bind,value,dims,ind,source,attr,comment,flowPrefix,streamPrefix), v); + ((var :: _),_) = BackendVariable.getVar(cr, v); + var = BackendVariable.setVarKind(var,BackendDAE.DISCRETE()); + v_1 = BackendVariable.addVar(var, v); v_2 = detectImplicitDiscrete(v_1, xs); then v_2; - /* TODO: should also check when-algorithms */ case (v,(_ :: xs)) equation v_1 = detectImplicitDiscrete(v, xs); @@ -2024,6 +2025,103 @@ algorithm end matchcontinue; end detectImplicitDiscrete; +protected function detectImplicitDiscreteAlgs +"function: detectImplicitDiscreteAlgs + This function updates the variable kind to discrete + for variables set in when equations." + input BackendDAE.Variables inVariables; + input list inAlgsLst; + output BackendDAE.Variables outVariables; +algorithm + outVariables := matchcontinue (inVariables,inAlgsLst) + local + BackendDAE.Variables v,v_1,v_2; + list statementLst; + list xs; + case (v,{}) then v; + case (v,(DAE.ALGORITHM_STMTS(statementLst = statementLst) :: xs)) + equation + v_1 = detectImplicitDiscreteAlgsStatemens(v,statementLst,false); + v_2 = detectImplicitDiscreteAlgs(v_1, xs); + then + v_2; + case (v,(_ :: xs)) + equation + v_1 = detectImplicitDiscreteAlgs(v, xs); + then + v_1; + end matchcontinue; +end detectImplicitDiscreteAlgs; + +protected function detectImplicitDiscreteAlgsStatemens +"function: detectImplicitDiscreteAlgsStatemens + This function updates the variable kind to discrete + for variables set in when equations." + input BackendDAE.Variables inVariables; + input list inStatementLst; + input Boolean insideWhen "true if its called from a when statement"; + output BackendDAE.Variables outVariables; +algorithm + outVariables := matchcontinue (inVariables,inStatementLst,insideWhen) + local + BackendDAE.Variables v,v_1,v_2,v_3; + DAE.ComponentRef cr; + list xs,statementLst; + BackendDAE.Var var; + list vars; + DAE.Statement statement; + Boolean b; + case (v,{},_) then v; + case (v,(DAE.STMT_ASSIGN(exp1 =DAE.CREF(componentRef = cr)) :: xs),true) + equation + ((var :: _),_) = BackendVariable.getVar(cr, v); + var = BackendVariable.setVarKind(var,BackendDAE.DISCRETE()); + v_1 = BackendVariable.addVar(var, v); + v_2 = detectImplicitDiscreteAlgsStatemens(v_1, xs,true); + then + v_2; + case (v,(DAE.STMT_ASSIGN_ARR(componentRef = cr) :: xs),true) + equation + (vars,_) = BackendVariable.getVar(cr, v); + vars = Util.listMap1(vars,BackendVariable.setVarKind,BackendDAE.DISCRETE()); + v_1 = BackendVariable.addVars(vars,v); + v_2 = detectImplicitDiscreteAlgsStatemens(v_1, xs,true); + then + v_2; + case (v,(DAE.STMT_IF(statementLst = statementLst) :: xs),true) + equation + v_1 = detectImplicitDiscreteAlgsStatemens(v,statementLst,true); + v_2 = detectImplicitDiscreteAlgsStatemens(v_1, xs,true); + then + v_2; + case (v,(DAE.STMT_FOR(statementLst = statementLst) :: xs),true) + equation + /* TODO: use the range for the componentreferences */ + v_1 = detectImplicitDiscreteAlgsStatemens(v,statementLst,true); + v_2 = detectImplicitDiscreteAlgsStatemens(v_1, xs,true); + then + v_2; + case (v,(DAE.STMT_WHEN(statementLst = statementLst,elseWhen = NONE()) :: xs),_) + equation + v_1 = detectImplicitDiscreteAlgsStatemens(v,statementLst,true); + v_2 = detectImplicitDiscreteAlgsStatemens(v_1, xs,false); + then + v_2; + case (v,(DAE.STMT_WHEN(statementLst = statementLst,elseWhen = SOME(statement)) :: xs),_) + equation + v_1 = detectImplicitDiscreteAlgsStatemens(v,statementLst,true); + v_2 = detectImplicitDiscreteAlgsStatemens(v_1,{statement},true); + v_3 = detectImplicitDiscreteAlgsStatemens(v_2, xs,false); + then + v_3; + case (v,(_ :: xs),b) + equation + v_1 = detectImplicitDiscreteAlgsStatemens(v, xs,b); + then + v_1; + end matchcontinue; +end detectImplicitDiscreteAlgsStatemens; + protected function sortEqn "function: sortEqn This function sorts the equation. It puts first the algebraic eqns @@ -2456,7 +2554,7 @@ algorithm case(DAE.STMT_REINIT(e1,e2,source),vars) equation ((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars); - ((e1,vars)) = Expression.traverseExp(e2,expandDerExp,vars); + ((e2,vars)) = Expression.traverseExp(e2,expandDerExp,vars); then (DAE.STMT_REINIT(e1,e2,source),vars); case(stmt,vars) then (stmt,vars); diff --git a/Compiler/BackendDAEOptimize.mo b/Compiler/BackendDAEOptimize.mo index e20fa6ced06..01a2a275802 100644 --- a/Compiler/BackendDAEOptimize.mo +++ b/Compiler/BackendDAEOptimize.mo @@ -1021,16 +1021,16 @@ algorithm nvars = arrayLength(m_1); neqns = arrayLength(mT_1); memsize = nvars + nvars "Worst case, all eqns are differentiated once. Create nvars2 assignment elements" ; - assign1 = BackendDAETransform.assignmentsCreate(nvars, memsize, 0); - assign2 = BackendDAETransform.assignmentsCreate(nvars, memsize, 0); + assign1 = BackendDAETransform.assignmentsCreate(nvars, memsize, 0); + assign2 = BackendDAETransform.assignmentsCreate(nvars, memsize, 0); // try matching - BackendDAETransform.checkMatching(dlow_1, (BackendDAE.NO_INDEX_REDUCTION(), BackendDAE.EXACT(), BackendDAE.KEEP_SIMPLE_EQN())); + BackendDAETransform.checkMatching(dlow_1, (BackendDAE.NO_INDEX_REDUCTION(), BackendDAE.EXACT(), BackendDAE.KEEP_SIMPLE_EQN())); Debug.fcall("tearingdump", BackendDump.dumpIncidenceMatrix, m_1); Debug.fcall("tearingdump", BackendDump.dumpIncidenceMatrixT, mT_1); Debug.fcall("tearingdump", BackendDump.dump, dlow_1); - (ass1,ass2,dlow_2,m_2,mT_2,_,_) = BackendDAETransform.matchingAlgorithm2(dlow_1, m_1, mT_1, nvars, neqns, 1, assign1, assign2, (BackendDAE.NO_INDEX_REDUCTION(), BackendDAE.EXACT(), BackendDAE.KEEP_SIMPLE_EQN()),DAEUtil.avlTreeNew(),{},{}); - v1_1 = BackendDAETransform.assignmentsVector(ass1); - v2_1 = BackendDAETransform.assignmentsVector(ass2); + (ass1,ass2,dlow_2,m_2,mT_2,_,_) = BackendDAETransform.matchingAlgorithm2(dlow_1, m_1, mT_1, nvars, neqns, 1, assign1, assign2, (BackendDAE.NO_INDEX_REDUCTION(), BackendDAE.EXACT(), BackendDAE.KEEP_SIMPLE_EQN()),DAEUtil.avlTreeNew(),{},{}); + v1_1 = BackendDAETransform.assignmentsVector(ass1); + v2_1 = BackendDAETransform.assignmentsVector(ass2); (comps) = BackendDAETransform.strongComponents(m_2, mT_2, v1_1, v2_1); Debug.fcall("tearingdump", BackendDump.dumpMatching, v1_1); Debug.fcall("tearingdump", BackendDump.dumpComponents, comps); diff --git a/Compiler/BackendDAETransform.mo b/Compiler/BackendDAETransform.mo index 9f02d32d83b..cadc2d1fdbb 100644 --- a/Compiler/BackendDAETransform.mo +++ b/Compiler/BackendDAETransform.mo @@ -166,7 +166,7 @@ algorithm algs = arrayList(al); (v,kv,e_lst,re_lst,ie_lst,ae_lst,algs,av) = BackendDAEOptimize.removeSimpleEquations(v,kv, e_lst, re_lst, ie_lst, ae_lst, algs, s); BackendDAE.EVENT_INFO(whenClauseLst=whenclauses) = ev; - (zero_crossings) = BackendDAECreate.findZeroCrossings(v,kv,e_lst,ae_lst,whenclauses,algs); + (zero_crossings) = BackendDAECreate.findZeroCrossings(v,kv,listAppend(e_lst,re_lst),ae_lst,whenclauses,algs); e = BackendDAEUtil.listEquation(e_lst); re = BackendDAEUtil.listEquation(re_lst); ie = BackendDAEUtil.listEquation(ie_lst); @@ -1653,7 +1653,7 @@ algorithm st = replaceDummyDerAlgs1(rest,inExp2,inExp3); then (DAE.STMT_IF(e1,stlst1,else_1,source)::st); - case (DAE.STMT_FOR(type_=t,iterIsArray=b,ident=id,exp=e,statementLst=stlst,source=source)::rest,inExp2,inExp3) + case (DAE.STMT_FOR(type_=t,iterIsArray=b,iter=id,range=e,statementLst=stlst,source=source)::rest,inExp2,inExp3) local Boolean b; DAE.Ident id; @@ -2002,7 +2002,7 @@ algorithm (st,vars3) = replaceDummyDerOthersAlgs1(rest,vars2); then (DAE.STMT_IF(e1,stlst1,else_1,source)::st,vars3); - case (DAE.STMT_FOR(type_=t,iterIsArray=b,ident=id,exp=e,statementLst=stlst,source=source)::rest,inVariables) + case (DAE.STMT_FOR(type_=t,iterIsArray=b,iter=id,range=e,statementLst=stlst,source=source)::rest,inVariables) local Boolean b; DAE.Ident id; diff --git a/Compiler/BackendDAEUtil.mo b/Compiler/BackendDAEUtil.mo index 6f29194b4f6..dcb63847ec8 100644 --- a/Compiler/BackendDAEUtil.mo +++ b/Compiler/BackendDAEUtil.mo @@ -690,20 +690,6 @@ algorithm end matchcontinue; end makeExpType; -public function systemSize "returns the size of the dae system" -input BackendDAE.BackendDAE dae; -output Integer n; -algorithm - n := matchcontinue(dae) - local BackendDAE.EquationArray eqns; - case(BackendDAE.DAE(orderedEqs = eqns)) - equation - n = equationSize(eqns); - then n; - - end matchcontinue; -end systemSize; - public function statesDaelow "function: statesDaelow author: PA @@ -1758,10 +1744,31 @@ algorithm end matchcontinue; end equationNth; +public function systemSize +"function: equationSize + author: Frenkel TUD + + Returns the size of the dae system, which + corresponds to the number of equations in a system. +" +input BackendDAE.BackendDAE dae; +output Integer n; +algorithm + n := matchcontinue(dae) + local + BackendDAE.EquationArray eqns; + case(BackendDAE.DAE(orderedEqs = eqns)) + equation + n = equationSize(eqns); + then n; + end matchcontinue; +end systemSize; + + public function equationSize "function: equationSize author: PA - Returns the number of equations in an EquationArray, which + Returns the number of equations in an EquationArray, which corresponds to the number of equations in a system. NOTE: Array equations and algorithms are represented several times in the array so the number of elements of the array corresponds to @@ -4943,7 +4950,7 @@ algorithm talst3 = traverseExpsElse(else_,func,inTypeA); talst4 = listAppend(talst2,talst3); then talst4; - case (DAE.STMT_FOR(type_ = expty,iterIsArray = flag,ident = id,exp = exp,statementLst = stmts),func,inTypeA) + case (DAE.STMT_FOR(type_ = expty,iterIsArray = flag,iter = id,range = exp,statementLst = stmts),func,inTypeA) equation talst = traverseExpsStmts(stmts,func,inTypeA); talst1 = func(exp,inTypeA); diff --git a/Compiler/BackendVarTransform.mo b/Compiler/BackendVarTransform.mo index 26ab61e3c92..82738c7b5e3 100644 --- a/Compiler/BackendVarTransform.mo +++ b/Compiler/BackendVarTransform.mo @@ -458,7 +458,7 @@ algorithm es_1 = replaceStatementLst(es, repl); then (DAE.STMT_IF(e1_2,statementLst_1,else_1,source):: es_1); - case ((DAE.STMT_FOR(type_=type_,iterIsArray=iterIsArray,ident=ident,exp=e1,statementLst=statementLst,source=source)::es),repl) + case ((DAE.STMT_FOR(type_=type_,iterIsArray=iterIsArray,iter=ident,range=e1,statementLst=statementLst,source=source)::es),repl) local Boolean iterIsArray; DAE.Ident ident; diff --git a/Compiler/DAE.mo b/Compiler/DAE.mo index b9b720934d1..1622c1419f7 100644 --- a/Compiler/DAE.mo +++ b/Compiler/DAE.mo @@ -496,8 +496,8 @@ uniontype Statement "There are four kinds of statements. Assignments (`a := b;\ record STMT_FOR ExpType type_ "this is the type of the iterator"; Boolean iterIsArray "True if the iterator has an array type, otherwise false."; - Ident ident; - Exp exp; + Ident iter "the iterator variable"; + Exp range "range for the loop"; list statementLst; ElementSource source "the origin of the component/equation/algorithm"; end STMT_FOR; @@ -1093,9 +1093,9 @@ uniontype Exp "Expressions record RANGE ExpType ty; - Exp exp; - Option expOption; - Exp range "Range constructor, e.g. 1:0.5:10" ; + Exp exp "start value"; + Option expOption "step value"; + Exp range "stop value; Range constructor, e.g. 1:0.5:10" ; end RANGE; record TUPLE diff --git a/Compiler/DAEDump.mo b/Compiler/DAEDump.mo index 8d090a52f54..1cb206d8dc8 100644 --- a/Compiler/DAEDump.mo +++ b/Compiler/DAEDump.mo @@ -1480,7 +1480,7 @@ algorithm Print.printBuf("end if;\n"); then (); - case (DAE.STMT_FOR(ident = id,exp = e,statementLst = stmts),i) + case (DAE.STMT_FOR(iter = id,range = e,statementLst = stmts),i) equation indent(i); Print.printBuf("for "); @@ -1737,7 +1737,7 @@ algorithm str = stringAppend(s11, "end if;\n"); then str; - case (DAE.STMT_FOR(ident = id,exp = e,statementLst = stmts),i) + case (DAE.STMT_FOR(iter = id,range = e,statementLst = stmts),i) equation s1 = indentStr(i); s2 = stringAppend(s1, "for "); diff --git a/Compiler/DAEUtil.mo b/Compiler/DAEUtil.mo index 03dcc812bb3..cc9200b10a2 100644 --- a/Compiler/DAEUtil.mo +++ b/Compiler/DAEUtil.mo @@ -3769,7 +3769,7 @@ algorithm (xs_1,extraArg) = traverseDAEEquationsStmts(xs, func, extraArg); then (DAE.STMT_IF(e_1,stmts2,el_1,source) :: xs_1,extraArg); - case (((x as DAE.STMT_FOR(type_=tp,iterIsArray=b1,ident=id1,exp=e,statementLst=stmts, source = source)) :: xs),func,extraArg) + case (((x as DAE.STMT_FOR(type_=tp,iterIsArray=b1,iter=id1,range=e,statementLst=stmts, source = source)) :: xs),func,extraArg) equation (stmts2, extraArg) = traverseDAEEquationsStmts(stmts,func,extraArg); (e_1, extraArg) = func(e, extraArg); diff --git a/Compiler/Linearization.mo b/Compiler/Linearization.mo index 092bb5be4cf..24330ce57d5 100644 --- a/Compiler/Linearization.mo +++ b/Compiler/Linearization.mo @@ -1171,7 +1171,7 @@ algorithm derivedStatements1 = listAppend(derivedStatements1, derivedStatements2); then derivedStatements1; - case(DAE.STMT_FOR(type_=type_, iterIsArray=iterIsArray, ident=ident, exp=exp, statementLst=statementLst, source=elemSrc)::restStatements, var, functions) local + case(DAE.STMT_FOR(type_=type_, iterIsArray=iterIsArray, iter=ident, range=exp, statementLst=statementLst, source=elemSrc)::restStatements, var, functions) local DAE.ExpType type_; Boolean iterIsArray; DAE.Ident ident; diff --git a/Compiler/SimCode.mo b/Compiler/SimCode.mo index a5ed41213c3..f81907bf30e 100644 --- a/Compiler/SimCode.mo +++ b/Compiler/SimCode.mo @@ -2433,12 +2433,13 @@ algorithm local BackendDAE.EquationArray r; list removedEquationsTmp; - case (BackendDAE.DAE(removedEqs=r)) + array algs; + case (BackendDAE.DAE(removedEqs=r,algorithms=algs)) equation removedEquationsTmp = BackendDAEUtil.equationList(r); - removedEquations = Util.listMap(removedEquationsTmp, - dlowEqToSimEqSystem); + removedEquations = Util.listMap1(removedEquationsTmp, + dlowEqToSimEqSystem,algs); then removedEquations; end matchcontinue; end createRemovedEquations; @@ -2885,7 +2886,7 @@ algorithm SES_NONLINEAR(index, resEqs, {cr_1}); /* Algorithm for single variable. */ - case (e, BackendDAE.DAE(orderedVars=vars,orderedEqs=eqns,algorithms=alg), ass1, ass2, helpVarInfo) + case (e, BackendDAE.DAE(orderedVars=vars,orderedEqs=eqns,algorithms=algs), ass1, ass2, helpVarInfo) local Integer indx; list algInputs,algOutputs; @@ -2898,7 +2899,7 @@ algorithm // for, otherwise we need to solve an inverse problem of an algorithm // section. true = ComponentReference.crefEqualNoStringCompare(BackendVariable.varCref(v),varOutput); - alg = alg[indx + 1]; + alg = algs[indx + 1]; DAE.ALGORITHM_STMTS(algStatements) = BackendDAEUtil.collateAlgorithm(alg, NONE()); then SES_ALGORITHM(algStatements); @@ -4478,8 +4479,8 @@ algorithm residualEquationsTmp = Util.listFilter(residualEquationsTmp, failUnlessResidual); - residualEquations = Util.listMap(residualEquationsTmp, - dlowEqToSimEqSystem); + residualEquations = Util.listMap1(residualEquationsTmp, + dlowEqToSimEqSystem,al); then residualEquations; case (_,_,_) @@ -4493,17 +4494,27 @@ end createResidualEquations; protected function dlowEqToSimEqSystem input BackendDAE.Equation inEquation; + input array algs; output SimEqSystem outEquation; algorithm outEquation:= - matchcontinue (inEquation) + matchcontinue (inEquation,algs) local DAE.ComponentRef cr; DAE.Exp exp_; - case (BackendDAE.SOLVED_EQUATION(cr, exp_, _)) + Algorithm.Algorithm alg; + Integer indx; + list algStatements; + case (BackendDAE.SOLVED_EQUATION(cr, exp_, _),_) then SES_SIMPLE_ASSIGN(cr, exp_); - case (BackendDAE.RESIDUAL_EQUATION(exp_, _)) + case (BackendDAE.RESIDUAL_EQUATION(exp_, _),_) then SES_RESIDUAL(exp_); + case (BackendDAE.ALGORITHM(index=indx),algs) + equation + alg = algs[indx + 1]; + DAE.ALGORITHM_STMTS(algStatements) = BackendDAEUtil.collateAlgorithm(alg, NONE()); + then + SES_ALGORITHM(algStatements); end matchcontinue; end dlowEqToSimEqSystem; @@ -4529,7 +4540,8 @@ algorithm list eqns_lst; BackendDAE.Variables vars; BackendDAE.Variables knvars; - case (BackendDAE.DAE(orderedVars=vars, knownVars=knvars)) + array algs; + case (BackendDAE.DAE(orderedVars=vars, knownVars=knvars,algorithms=algs)) equation initialEquationsTmp2 = {}; // vars @@ -4541,8 +4553,8 @@ algorithm initialEquationsTmp = createInitialAssignmentsFromStart(knvars_lst); initialEquationsTmp2 = listAppend(initialEquationsTmp2, initialEquationsTmp); - initialEquations = Util.listMap(initialEquationsTmp2, - dlowEqToSimEqSystem); + initialEquations = Util.listMap1(initialEquationsTmp2, + dlowEqToSimEqSystem,algs); then initialEquations; case (_) @@ -4567,7 +4579,8 @@ algorithm list eqns_lst; BackendDAE.Variables vars; BackendDAE.Variables knvars; - case (BackendDAE.DAE(orderedVars=vars, knownVars=knvars)) + array algs; + case (BackendDAE.DAE(orderedVars=vars, knownVars=knvars,algorithms=algs)) equation parameterEquationsTmp = {}; // kvars params @@ -4575,8 +4588,8 @@ algorithm tempEqs = createInitialParamAssignments(knvars_lst); parameterEquationsTmp = listAppend(parameterEquationsTmp, tempEqs); - parameterEquations = Util.listMap(parameterEquationsTmp, - dlowEqToSimEqSystem); + parameterEquations = Util.listMap1(parameterEquationsTmp, + dlowEqToSimEqSystem,algs); //?? why is this reversed ??? parameterEquations = listReverse(parameterEquations); then @@ -4764,6 +4777,11 @@ algorithm simvar = dlowvarToSimvar(dlowvar); then (simvar :: crs); + case (_,_,_,_,_) + equation + Error.addMessage(Error.INTERNAL_ERROR, {"SimCode.createZeroCrossingNeedSave failed"}); + then + fail(); end matchcontinue; end createZeroCrossingNeedSave; @@ -4800,7 +4818,7 @@ algorithm MODELINFO(class_, directory, varInfo, vars); case (_,_,_,_,_) equation - Error.addMessage(Error.INTERNAL_ERROR, {"createModelInfo failed"}); + Error.addMessage(Error.INTERNAL_ERROR, {"SimCode.createModelInfo failed"}); then fail(); end matchcontinue; diff --git a/Compiler/SimCodeC.mo b/Compiler/SimCodeC.mo index 119281d2174..a880f48c4c9 100644 --- a/Compiler/SimCodeC.mo +++ b/Compiler/SimCodeC.mo @@ -19912,6 +19912,16 @@ algorithm (txt, i_varDecls) = algStmtAssert(txt, i_s, i_context, i_varDecls); then (txt, i_varDecls); + case ( txt, + (i_s as DAE.STMT_TERMINATE(msg = _)), + i_context, + i_varDecls ) + local + DAE.Statement i_s; + equation + (txt, i_varDecls) = algStmtTerminate(txt, i_s, i_context, i_varDecls); + then (txt, i_varDecls); + case ( txt, (i_s as DAE.STMT_WHEN(exp = _)), i_context, @@ -20950,7 +20960,7 @@ algorithm Tpl.Text i_varDecls; case ( txt, - (i_s as DAE.STMT_FOR(exp = (i_rng as DAE.RANGE(ty = _)))), + (i_s as DAE.STMT_FOR(range = (i_rng as DAE.RANGE(ty = _)))), i_context, i_varDecls ) local @@ -21042,11 +21052,11 @@ algorithm Tpl.Text i_varDecls; case ( txt, - DAE.STMT_FOR(exp = (i_rng as DAE.RANGE(ty = _)), type_ = i_type__, iterIsArray = i_iterIsArray, statementLst = i_statementLst, ident = i_ident), + DAE.STMT_FOR(range = (i_rng as DAE.RANGE(ty = _)), type_ = i_type__, iterIsArray = i_iterIsArray, statementLst = i_statementLst, iter = i_iter), i_context, i_varDecls ) local - DAE.Ident i_ident; + DAE.Ident i_iter; list i_statementLst; Boolean i_iterIsArray; DAE.ExpType i_type__; @@ -21060,7 +21070,7 @@ algorithm i_stmtStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); (i_stmtStr, i_varDecls) = lm_496(i_stmtStr, i_statementLst, i_varDecls, i_context); i_stmtStr = Tpl.popIter(i_stmtStr); - (txt, i_stmtStr, i_varDecls) = algStmtForRange_impl(txt, i_rng, i_ident, Tpl.textString(i_identType), Tpl.textString(i_identTypeShort), i_stmtStr, i_context, i_varDecls); + (txt, i_stmtStr, i_varDecls) = algStmtForRange_impl(txt, i_rng, i_iter, Tpl.textString(i_identType), Tpl.textString(i_identTypeShort), i_stmtStr, i_context, i_varDecls); then (txt, i_varDecls); case ( txt, @@ -21402,12 +21412,12 @@ algorithm Tpl.Text i_varDecls; case ( txt, - DAE.STMT_FOR(type_ = i_type__, iterIsArray = i_iterIsArray, statementLst = i_statementLst, exp = i_exp, ident = i_ident), + DAE.STMT_FOR(type_ = i_type__, iterIsArray = i_iterIsArray, statementLst = i_statementLst, range = i_range, iter = i_iter), i_context, i_varDecls ) local - DAE.Ident i_ident; - DAE.Exp i_exp; + DAE.Ident i_iter; + DAE.Exp i_range; list i_statementLst; Boolean i_iterIsArray; DAE.ExpType i_type__; @@ -21420,7 +21430,7 @@ algorithm i_stmtStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); (i_stmtStr, i_varDecls) = lm_504(i_stmtStr, i_statementLst, i_varDecls, i_context); i_stmtStr = Tpl.popIter(i_stmtStr); - (txt, i_stmtStr, i_varDecls) = algStmtForGeneric_impl(txt, i_exp, i_ident, Tpl.textString(i_iterType), Tpl.textString(i_arrayType), i_iterIsArray, i_stmtStr, i_context, i_varDecls); + (txt, i_stmtStr, i_varDecls) = algStmtForGeneric_impl(txt, i_range, i_iter, Tpl.textString(i_iterType), Tpl.textString(i_arrayType), i_iterIsArray, i_stmtStr, i_context, i_varDecls); then (txt, i_varDecls); case ( txt, @@ -21799,7 +21809,49 @@ algorithm end matchcontinue; end algStmtAssert; -protected function lm_514 +public function algStmtTerminate + input Tpl.Text in_txt; + input DAE.Statement in_i_stmt; + input SimCode.Context in_i_context; + input Tpl.Text in_i_varDecls; + + output Tpl.Text out_txt; + output Tpl.Text out_i_varDecls; +algorithm + (out_txt, out_i_varDecls) := + matchcontinue(in_txt, in_i_stmt, in_i_context, in_i_varDecls) + local + Tpl.Text txt; + SimCode.Context i_context; + Tpl.Text i_varDecls; + + case ( txt, + DAE.STMT_TERMINATE(msg = i_msg), + i_context, + i_varDecls ) + local + DAE.Exp i_msg; + Tpl.Text i_msgVar; + Tpl.Text i_preExp; + equation + i_preExp = emptyTxt; + (i_msgVar, i_preExp, i_varDecls) = daeExp(emptyTxt, i_msg, i_context, i_preExp, i_varDecls); + txt = Tpl.writeText(txt, i_preExp); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("MODELICA_TERMINATE(")); + txt = Tpl.writeText(txt, i_msgVar); + txt = Tpl.writeTok(txt, Tpl.ST_STRING(");")); + then (txt, i_varDecls); + + case ( txt, + _, + _, + i_varDecls ) + then (txt, i_varDecls); + end matchcontinue; +end algStmtTerminate; + +protected function lm_515 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varAssign; @@ -21855,7 +21907,7 @@ algorithm txt = Tpl.writeText(txt, i_decl); txt = Tpl.writeTok(txt, Tpl.ST_STRING(";")); txt = Tpl.nextIter(txt); - (txt, i_varAssign, i_preExp, i_varDecls) = lm_514(txt, rest, i_varAssign, i_preExp, i_context, i_varDecls); + (txt, i_varAssign, i_preExp, i_varDecls) = lm_515(txt, rest, i_varAssign, i_preExp, i_context, i_varDecls); then (txt, i_varAssign, i_preExp, i_varDecls); case ( txt, @@ -21867,10 +21919,10 @@ algorithm local list rest; equation - (txt, i_varAssign, i_preExp, i_varDecls) = lm_514(txt, rest, i_varAssign, i_preExp, i_context, i_varDecls); + (txt, i_varAssign, i_preExp, i_varDecls) = lm_515(txt, rest, i_varAssign, i_preExp, i_context, i_varDecls); then (txt, i_varAssign, i_preExp, i_varDecls); end matchcontinue; -end lm_514; +end lm_515; public function algStmtMatchcasesVarDeclsAndAssign input Tpl.Text txt; @@ -21886,11 +21938,11 @@ public function algStmtMatchcasesVarDeclsAndAssign output Tpl.Text out_i_preExp; algorithm out_txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (out_txt, out_i_varAssign, out_i_preExp, out_i_varDecls) := lm_514(out_txt, i_expList, i_varAssign, i_preExp, i_context, i_varDecls); + (out_txt, out_i_varAssign, out_i_preExp, out_i_varDecls) := lm_515(out_txt, i_expList, i_varAssign, i_preExp, i_context, i_varDecls); out_txt := Tpl.popIter(out_txt); end algStmtMatchcasesVarDeclsAndAssign; -protected function fun_516 +protected function fun_517 input Tpl.Text in_txt; input Absyn.MatchType in_i_matchType; @@ -21913,9 +21965,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("{")); then txt; end matchcontinue; -end fun_516; +end fun_517; -protected function lm_517 +protected function lm_518 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_doneVar; @@ -21969,7 +22021,7 @@ algorithm txt = Tpl.popBlock(txt); txt = Tpl.writeTok(txt, Tpl.ST_STRING("};")); txt = Tpl.nextIter(txt); - (txt, i_varDecls) = lm_517(txt, rest, i_doneVar, i_varDecls, i_context); + (txt, i_varDecls) = lm_518(txt, rest, i_doneVar, i_varDecls, i_context); then (txt, i_varDecls); case ( txt, @@ -21980,12 +22032,12 @@ algorithm local list rest; equation - (txt, i_varDecls) = lm_517(txt, rest, i_doneVar, i_varDecls, i_context); + (txt, i_varDecls) = lm_518(txt, rest, i_doneVar, i_varDecls, i_context); then (txt, i_varDecls); end matchcontinue; -end lm_517; +end lm_518; -protected function fun_518 +protected function fun_519 input Tpl.Text in_txt; input Absyn.MatchType in_i_matchType; @@ -22011,7 +22063,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("}")); then txt; end matchcontinue; -end fun_518; +end fun_519; public function algStmtMatchcases input Tpl.Text in_txt; @@ -22077,7 +22129,7 @@ algorithm txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); txt = Tpl.writeText(txt, i_inVarAssignLoop); txt = Tpl.softNewLine(txt); - txt = fun_516(txt, i_matchType); + txt = fun_517(txt, i_matchType); txt = Tpl.softNewLine(txt); txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); txt = Tpl.writeTok(txt, Tpl.ST_STRING("switch (")); @@ -22085,13 +22137,13 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_LINE(") {\n")); txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (txt, i_varDecls) = lm_517(txt, i_caseStmt, i_doneVar, i_varDecls, i_context); + (txt, i_varDecls) = lm_518(txt, i_caseStmt, i_doneVar, i_varDecls, i_context); txt = Tpl.popIter(txt); txt = Tpl.softNewLine(txt); txt = Tpl.popBlock(txt); txt = Tpl.writeTok(txt, Tpl.ST_LINE("} /* end match switch */\n")); txt = Tpl.popBlock(txt); - txt = fun_518(txt, i_matchType); + txt = fun_519(txt, i_matchType); txt = Tpl.softNewLine(txt); txt = Tpl.popBlock(txt); txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ @@ -22110,7 +22162,7 @@ algorithm end matchcontinue; end algStmtMatchcases; -protected function lm_520 +protected function lm_521 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -22142,7 +22194,7 @@ algorithm equation (txt, i_varDecls) = algStatement(txt, i_stmt, i_context, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls) = lm_520(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_521(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); case ( txt, @@ -22152,10 +22204,10 @@ algorithm local list rest; equation - (txt, i_varDecls) = lm_520(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_521(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); end matchcontinue; -end lm_520; +end lm_521; public function algStmtFailure input Tpl.Text in_txt; @@ -22184,7 +22236,7 @@ algorithm equation (i_tmp, i_varDecls) = tempDecl(emptyTxt, "modelica_boolean", i_varDecls); i_stmtBody = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_stmtBody, i_varDecls) = lm_520(i_stmtBody, i_body, i_varDecls, i_context); + (i_stmtBody, i_varDecls) = lm_521(i_stmtBody, i_body, i_varDecls, i_context); i_stmtBody = Tpl.popIter(i_stmtBody); txt = Tpl.writeText(txt, i_tmp); txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ @@ -22213,7 +22265,7 @@ algorithm end matchcontinue; end algStmtFailure; -protected function lm_522 +protected function lm_523 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -22245,7 +22297,7 @@ algorithm equation (txt, i_varDecls) = algStatement(txt, i_stmt, i_context, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls) = lm_522(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_523(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); case ( txt, @@ -22255,10 +22307,10 @@ algorithm local list rest; equation - (txt, i_varDecls) = lm_522(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_523(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); end matchcontinue; -end lm_522; +end lm_523; public function algStmtTry input Tpl.Text in_txt; @@ -22285,7 +22337,7 @@ algorithm Tpl.Text i_body; equation i_body = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_body, i_varDecls) = lm_522(i_body, i_tryBody, i_varDecls, i_context); + (i_body, i_varDecls) = lm_523(i_body, i_tryBody, i_varDecls, i_context); i_body = Tpl.popIter(i_body); txt = Tpl.writeTok(txt, Tpl.ST_LINE("try {\n")); txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); @@ -22303,7 +22355,7 @@ algorithm end matchcontinue; end algStmtTry; -protected function lm_524 +protected function lm_525 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -22335,7 +22387,7 @@ algorithm equation (txt, i_varDecls) = algStatement(txt, i_stmt, i_context, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls) = lm_524(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_525(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); case ( txt, @@ -22345,10 +22397,10 @@ algorithm local list rest; equation - (txt, i_varDecls) = lm_524(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_525(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); end matchcontinue; -end lm_524; +end lm_525; public function algStmtCatch input Tpl.Text in_txt; @@ -22375,7 +22427,7 @@ algorithm Tpl.Text i_body; equation i_body = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_body, i_varDecls) = lm_524(i_body, i_catchBody, i_varDecls, i_context); + (i_body, i_varDecls) = lm_525(i_body, i_catchBody, i_varDecls, i_context); i_body = Tpl.popIter(i_body); txt = Tpl.writeTok(txt, Tpl.ST_LINE("catch (int i) {\n")); txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); @@ -22434,7 +22486,7 @@ algorithm end matchcontinue; end algStmtNoretcall; -protected function lm_527 +protected function lm_528 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -22466,7 +22518,7 @@ algorithm equation (txt, i_varDecls) = algStatement(txt, i_stmt, i_context, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls) = lm_527(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_528(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); case ( txt, @@ -22476,12 +22528,12 @@ algorithm local list rest; equation - (txt, i_varDecls) = lm_527(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_528(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); end matchcontinue; -end lm_527; +end lm_528; -protected function lm_528 +protected function lm_529 input Tpl.Text in_txt; input list in_items; @@ -22506,7 +22558,7 @@ algorithm txt = Tpl.writeStr(txt, intString(i_idx)); txt = Tpl.writeTok(txt, Tpl.ST_STRING("])")); txt = Tpl.nextIter(txt); - txt = lm_528(txt, rest); + txt = lm_529(txt, rest); then txt; case ( txt, @@ -22514,12 +22566,12 @@ algorithm local list rest; equation - txt = lm_528(txt, rest); + txt = lm_529(txt, rest); then txt; end matchcontinue; -end lm_528; +end lm_529; -protected function fun_529 +protected function fun_530 input Tpl.Text in_txt; input DAE.Statement in_i_when; input SimCode.Context in_i_context; @@ -22550,14 +22602,14 @@ algorithm equation (i_preIf, i_varDecls) = algStatementWhenPre(emptyTxt, i_when, i_varDecls); i_statements = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_statements, i_varDecls) = lm_527(i_statements, i_statementLst, i_varDecls, i_context); + (i_statements, i_varDecls) = lm_528(i_statements, i_statementLst, i_varDecls, i_context); i_statements = Tpl.popIter(i_statements); (i_else, i_varDecls) = algStatementWhenElse(emptyTxt, i_elseWhen, i_varDecls); txt = Tpl.writeText(txt, i_preIf); txt = Tpl.softNewLine(txt); txt = Tpl.writeTok(txt, Tpl.ST_STRING("if (")); txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(" || ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_528(txt, i_helpVarIndices); + txt = lm_529(txt, i_helpVarIndices); txt = Tpl.popIter(txt); txt = Tpl.writeTok(txt, Tpl.ST_LINE(") {\n")); txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); @@ -22574,9 +22626,9 @@ algorithm i_varDecls ) then (txt, i_varDecls); end matchcontinue; -end fun_529; +end fun_530; -protected function fun_530 +protected function fun_531 input Tpl.Text in_txt; input SimCode.Context in_i_context; input DAE.Statement in_i_when; @@ -22599,7 +22651,7 @@ algorithm local SimCode.Context i_context; equation - (txt, i_varDecls) = fun_529(txt, i_when, i_context, i_varDecls); + (txt, i_varDecls) = fun_530(txt, i_when, i_context, i_varDecls); then (txt, i_varDecls); case ( txt, @@ -22608,7 +22660,7 @@ algorithm i_varDecls ) then (txt, i_varDecls); end matchcontinue; -end fun_530; +end fun_531; public function algStmtWhen input Tpl.Text txt; @@ -22619,10 +22671,10 @@ public function algStmtWhen output Tpl.Text out_txt; output Tpl.Text out_i_varDecls; algorithm - (out_txt, out_i_varDecls) := fun_530(txt, i_context, i_when, i_varDecls); + (out_txt, out_i_varDecls) := fun_531(txt, i_context, i_when, i_varDecls); end algStmtWhen; -protected function fun_532 +protected function fun_533 input Tpl.Text in_txt; input Option in_i_elseWhen; input Tpl.Text in_i_varDecls; @@ -22650,9 +22702,9 @@ algorithm i_varDecls ) then (txt, i_varDecls); end matchcontinue; -end fun_532; +end fun_533; -protected function fun_533 +protected function fun_534 input Tpl.Text in_txt; input Option in_i_when_elseWhen; input Tpl.Text in_i_varDecls; @@ -22680,9 +22732,9 @@ algorithm i_varDecls ) then (txt, i_varDecls); end matchcontinue; -end fun_533; +end fun_534; -protected function fun_534 +protected function fun_535 input Tpl.Text in_txt; input list in_i_helpVarIndices; input DAE.Exp in_i_when_exp; @@ -22711,7 +22763,7 @@ algorithm Tpl.Text i_preExp; Tpl.Text i_restPre; equation - (i_restPre, i_varDecls) = fun_533(emptyTxt, i_when_elseWhen, i_varDecls); + (i_restPre, i_varDecls) = fun_534(emptyTxt, i_when_elseWhen, i_varDecls); i_preExp = emptyTxt; (i_res, i_preExp, i_varDecls) = daeExp(emptyTxt, i_when_exp, SimCode.contextSimulationDiscrete, i_preExp, i_varDecls); txt = Tpl.writeText(txt, i_preExp); @@ -22731,7 +22783,7 @@ algorithm _ ) then (txt, i_varDecls); end matchcontinue; -end fun_534; +end fun_535; public function algStatementWhenPre input Tpl.Text in_txt; @@ -22758,7 +22810,7 @@ algorithm Tpl.Text i_preExp; Tpl.Text i_restPre; equation - (i_restPre, i_varDecls) = fun_532(emptyTxt, i_elseWhen, i_varDecls); + (i_restPre, i_varDecls) = fun_533(emptyTxt, i_elseWhen, i_varDecls); i_preExp = emptyTxt; (i_assignments, i_preExp, i_varDecls) = algStatementWhenPreAssigns(emptyTxt, i_el, i_helpVarIndices, i_preExp, i_varDecls); txt = Tpl.writeText(txt, i_preExp); @@ -22777,7 +22829,7 @@ algorithm list i_helpVarIndices; DAE.Statement i_when; equation - (txt, i_varDecls) = fun_534(txt, i_helpVarIndices, i_when_exp, i_varDecls, i_when_elseWhen); + (txt, i_varDecls) = fun_535(txt, i_helpVarIndices, i_when_exp, i_varDecls, i_when_elseWhen); then (txt, i_varDecls); case ( txt, @@ -22787,7 +22839,7 @@ algorithm end matchcontinue; end algStatementWhenPre; -protected function lm_536 +protected function lm_537 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -22815,7 +22867,7 @@ algorithm equation (txt, i_varDecls) = algStatement(txt, i_stmt, SimCode.contextSimulationDiscrete, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls) = lm_536(txt, rest, i_varDecls); + (txt, i_varDecls) = lm_537(txt, rest, i_varDecls); then (txt, i_varDecls); case ( txt, @@ -22824,12 +22876,12 @@ algorithm local list rest; equation - (txt, i_varDecls) = lm_536(txt, rest, i_varDecls); + (txt, i_varDecls) = lm_537(txt, rest, i_varDecls); then (txt, i_varDecls); end matchcontinue; -end lm_536; +end lm_537; -protected function lm_537 +protected function lm_538 input Tpl.Text in_txt; input list in_items; @@ -22854,7 +22906,7 @@ algorithm txt = Tpl.writeStr(txt, intString(i_idx)); txt = Tpl.writeTok(txt, Tpl.ST_STRING("])")); txt = Tpl.nextIter(txt); - txt = lm_537(txt, rest); + txt = lm_538(txt, rest); then txt; case ( txt, @@ -22862,10 +22914,10 @@ algorithm local list rest; equation - txt = lm_537(txt, rest); + txt = lm_538(txt, rest); then txt; end matchcontinue; -end lm_537; +end lm_538; public function algStatementWhenElse input Tpl.Text in_txt; @@ -22894,11 +22946,11 @@ algorithm Tpl.Text i_statements; equation i_statements = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_statements, i_varDecls) = lm_536(i_statements, i_when_statementLst, i_varDecls); + (i_statements, i_varDecls) = lm_537(i_statements, i_when_statementLst, i_varDecls); i_statements = Tpl.popIter(i_statements); (i_else, i_varDecls) = algStatementWhenElse(emptyTxt, i_when_elseWhen, i_varDecls); i_elseCondStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(" || ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - i_elseCondStr = lm_537(i_elseCondStr, i_when_helpVarIndices); + i_elseCondStr = lm_538(i_elseCondStr, i_when_helpVarIndices); i_elseCondStr = Tpl.popIter(i_elseCondStr); txt = Tpl.writeTok(txt, Tpl.ST_STRING("else if (")); txt = Tpl.writeText(txt, i_elseCondStr); @@ -22918,7 +22970,7 @@ algorithm end matchcontinue; end algStatementWhenElse; -protected function fun_539 +protected function fun_540 input Tpl.Text in_txt; input list in_i_ints; input DAE.Exp in_i_firstExp; @@ -22969,7 +23021,7 @@ algorithm _ ) then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_539; +end fun_540; public function algStatementWhenPreAssigns input Tpl.Text in_txt; @@ -23006,7 +23058,7 @@ algorithm list i_restExps; DAE.Exp i_firstExp; equation - (txt, i_varDecls, i_preExp) = fun_539(txt, i_ints, i_firstExp, i_varDecls, i_preExp, i_restExps); + (txt, i_varDecls, i_preExp) = fun_540(txt, i_ints, i_firstExp, i_varDecls, i_preExp, i_restExps); then (txt, i_preExp, i_varDecls); case ( txt, @@ -23057,7 +23109,7 @@ algorithm end matchcontinue; end indexSpecFromCref; -protected function lm_542 +protected function lm_543 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -23089,7 +23141,7 @@ algorithm equation (txt, i_varDecls) = algStatement(txt, i_stmt, i_context, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls) = lm_542(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_543(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); case ( txt, @@ -23099,12 +23151,12 @@ algorithm local list rest; equation - (txt, i_varDecls) = lm_542(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_543(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); end matchcontinue; -end lm_542; +end lm_543; -protected function lm_543 +protected function lm_544 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -23136,7 +23188,7 @@ algorithm equation (txt, i_varDecls) = algStatement(txt, i_stmt, i_context, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls) = lm_543(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_544(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); case ( txt, @@ -23146,10 +23198,10 @@ algorithm local list rest; equation - (txt, i_varDecls) = lm_543(txt, rest, i_varDecls, i_context); + (txt, i_varDecls) = lm_544(txt, rest, i_varDecls, i_context); then (txt, i_varDecls); end matchcontinue; -end lm_543; +end lm_544; public function elseExpr input Tpl.Text in_txt; @@ -23195,7 +23247,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_LINE(") {\n")); txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (txt, i_varDecls) = lm_542(txt, i_statementLst, i_varDecls, i_context); + (txt, i_varDecls) = lm_543(txt, i_statementLst, i_varDecls, i_context); txt = Tpl.popIter(txt); txt = Tpl.softNewLine(txt); txt = Tpl.popBlock(txt); @@ -23216,7 +23268,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_LINE("else {\n")); txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (txt, i_varDecls) = lm_543(txt, i_statementLst, i_varDecls, i_context); + (txt, i_varDecls) = lm_544(txt, i_statementLst, i_varDecls, i_context); txt = Tpl.popIter(txt); txt = Tpl.softNewLine(txt); txt = Tpl.popBlock(txt); @@ -23231,7 +23283,7 @@ algorithm end matchcontinue; end elseExpr; -protected function fun_545 +protected function fun_546 input Tpl.Text in_txt; input Boolean in_it; input DAE.ComponentRef in_i_ecr_componentRef; @@ -23276,7 +23328,7 @@ algorithm txt = contextCref(txt, i_ecr_componentRef, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_545; +end fun_546; public function scalarLhsCref input Tpl.Text in_txt; @@ -23321,7 +23373,7 @@ algorithm Boolean ret_0; equation ret_0 = SimCode.crefNoSub(i_ecr_componentRef); - (txt, i_varDecls, i_preExp) = fun_545(txt, ret_0, i_ecr_componentRef, i_varDecls, i_preExp, i_context, i_ecr); + (txt, i_varDecls, i_preExp) = fun_546(txt, ret_0, i_ecr_componentRef, i_varDecls, i_preExp, i_context, i_ecr); then (txt, i_preExp, i_varDecls); case ( txt, @@ -23415,7 +23467,7 @@ algorithm end matchcontinue; end rhsCrefType; -protected function fun_549 +protected function fun_550 input Tpl.Text in_txt; input Boolean in_i_bool; @@ -23438,7 +23490,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("(1)")); then txt; end matchcontinue; -end fun_549; +end fun_550; public function daeExp input Tpl.Text in_txt; @@ -23504,7 +23556,7 @@ algorithm Boolean i_bool; DAE.Exp i_e; equation - txt = fun_549(txt, i_bool); + txt = fun_550(txt, i_bool); then (txt, i_preExp, i_varDecls); case ( txt, @@ -23779,7 +23831,7 @@ algorithm out_txt := Tpl.writeText(txt, i_strVar); end daeExpSconst; -protected function fun_552 +protected function fun_553 input Tpl.Text in_txt; input SimCode.Context in_i_context; input DAE.ComponentRef in_i_cr; @@ -23828,7 +23880,7 @@ algorithm (txt, i_preExp, i_varDecls) = daeExpRecordCrefRhs(txt, i_t, i_cr, i_context, i_preExp, i_varDecls); then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_552; +end fun_553; public function daeExpCrefRhs input Tpl.Text in_txt; @@ -23859,7 +23911,7 @@ algorithm DAE.ComponentRef i_cr; DAE.Exp i_exp; equation - (txt, i_varDecls, i_preExp) = fun_552(txt, i_context, i_cr, i_t, i_varDecls, i_preExp, i_exp); + (txt, i_varDecls, i_preExp) = fun_553(txt, i_context, i_cr, i_t, i_varDecls, i_preExp, i_exp); then (txt, i_preExp, i_varDecls); case ( txt, @@ -23901,7 +23953,7 @@ algorithm end matchcontinue; end daeExpCrefRhs; -protected function lm_554 +protected function lm_555 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -23938,7 +23990,7 @@ algorithm equation (txt, i_preExp, i_varDecls) = daeExp(txt, i_exp, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_554(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_555(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); case ( txt, @@ -23949,12 +24001,12 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_554(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_555(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_554; +end lm_555; -protected function fun_555 +protected function fun_556 input Tpl.Text in_txt; input Boolean in_it; input Tpl.Text in_i_preExp; @@ -24034,7 +24086,7 @@ algorithm i_dimsLenStr = Tpl.writeStr(emptyTxt, intString(ret_5)); ret_7 = ComponentReference.crefSubs(i_cr); i_dimsValuesStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_dimsValuesStr, i_varDecls, i_preExp) = lm_554(i_dimsValuesStr, ret_7, i_varDecls, i_preExp, i_context); + (i_dimsValuesStr, i_varDecls, i_preExp) = lm_555(i_dimsValuesStr, ret_7, i_varDecls, i_preExp, i_context); i_dimsValuesStr = Tpl.popIter(i_dimsValuesStr); txt = Tpl.writeTok(txt, Tpl.ST_STRING("(*")); txt = Tpl.writeText(txt, i_arrayType); @@ -24047,9 +24099,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("))")); then (txt, i_preExp, i_varDecls); end matchcontinue; -end fun_555; +end fun_556; -protected function fun_556 +protected function fun_557 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -24070,9 +24122,9 @@ algorithm _ ) then txt; end matchcontinue; -end fun_556; +end fun_557; -protected function fun_557 +protected function fun_558 input Tpl.Text in_txt; input Boolean in_it; input Tpl.Text in_i_preExp; @@ -24106,7 +24158,7 @@ algorithm Boolean ret_0; equation ret_0 = SimCode.crefSubIsScalar(i_cr); - (txt, i_preExp, i_varDecls) = fun_555(txt, ret_0, i_preExp, i_varDecls, i_ty, i_context, i_cr); + (txt, i_preExp, i_varDecls) = fun_556(txt, ret_0, i_preExp, i_varDecls, i_ty, i_context, i_cr); then (txt, i_preExp, i_varDecls); case ( txt, @@ -24119,14 +24171,14 @@ algorithm local Tpl.Text i_cast; equation - i_cast = fun_556(emptyTxt, i_ty); + i_cast = fun_557(emptyTxt, i_ty); txt = Tpl.writeText(txt, i_cast); txt = contextCref(txt, i_cr, i_context); then (txt, i_preExp, i_varDecls); end matchcontinue; -end fun_557; +end fun_558; -protected function fun_558 +protected function fun_559 input Tpl.Text in_txt; input String in_it; input Tpl.Text in_i_box; @@ -24163,7 +24215,7 @@ algorithm Boolean ret_0; equation ret_0 = SimCode.crefIsScalar(i_cr, i_context); - (txt, i_preExp, i_varDecls) = fun_557(txt, ret_0, i_preExp, i_varDecls, i_ty, i_context, i_cr); + (txt, i_preExp, i_varDecls) = fun_558(txt, ret_0, i_preExp, i_varDecls, i_ty, i_context, i_cr); then (txt, i_preExp, i_varDecls); case ( txt, @@ -24178,7 +24230,7 @@ algorithm txt = Tpl.writeText(txt, i_box); then (txt, i_preExp, i_varDecls); end matchcontinue; -end fun_558; +end fun_559; public function daeExpCrefRhs2 input Tpl.Text in_txt; @@ -24213,7 +24265,7 @@ algorithm equation (i_box, i_preExp, i_varDecls) = daeExpCrefRhsArrayBox(emptyTxt, i_ecr, i_context, i_preExp, i_varDecls); str_1 = Tpl.textString(i_box); - (txt, i_preExp, i_varDecls) = fun_558(txt, str_1, i_box, i_preExp, i_varDecls, i_ty, i_context, i_cr); + (txt, i_preExp, i_varDecls) = fun_559(txt, str_1, i_box, i_preExp, i_varDecls, i_ty, i_context, i_cr); then (txt, i_preExp, i_varDecls); case ( txt, @@ -24225,7 +24277,7 @@ algorithm end matchcontinue; end daeExpCrefRhs2; -protected function fun_560 +protected function fun_561 input Tpl.Text in_txt; input DAE.Subscript in_i_sub; input Tpl.Text in_i_varDecls; @@ -24298,9 +24350,9 @@ algorithm _ ) then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_560; +end fun_561; -protected function lm_561 +protected function lm_562 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -24335,9 +24387,9 @@ algorithm list rest; DAE.Subscript i_sub; equation - (txt, i_varDecls, i_preExp) = fun_560(txt, i_sub, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = fun_561(txt, i_sub, i_varDecls, i_preExp, i_context); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_561(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_562(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); case ( txt, @@ -24348,10 +24400,10 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_561(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_562(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_561; +end lm_562; public function daeExpCrefRhsIndexSpec input Tpl.Text txt; @@ -24372,7 +24424,7 @@ algorithm ret_1 := listLength(i_subs); i_nridx__str := Tpl.writeStr(emptyTxt, intString(ret_1)); i_idx__str := Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_idx__str, out_i_varDecls, out_i_preExp) := lm_561(i_idx__str, i_subs, i_varDecls, i_preExp, i_context); + (i_idx__str, out_i_varDecls, out_i_preExp) := lm_562(i_idx__str, i_subs, i_varDecls, i_preExp, i_context); i_idx__str := Tpl.popIter(i_idx__str); (i_tmp, out_i_varDecls) := tempDecl(emptyTxt, "index_spec_t", out_i_varDecls); out_i_preExp := Tpl.writeTok(out_i_preExp, Tpl.ST_STRING("create_index_spec(&")); @@ -24386,7 +24438,7 @@ algorithm out_txt := Tpl.writeText(txt, i_tmp); end daeExpCrefRhsIndexSpec; -protected function lm_563 +protected function lm_564 input Tpl.Text in_txt; input list in_items; @@ -24409,7 +24461,7 @@ algorithm equation txt = dimension(txt, i_dim); txt = Tpl.nextIter(txt); - txt = lm_563(txt, rest); + txt = lm_564(txt, rest); then txt; case ( txt, @@ -24417,12 +24469,12 @@ algorithm local list rest; equation - txt = lm_563(txt, rest); + txt = lm_564(txt, rest); then txt; end matchcontinue; -end lm_563; +end lm_564; -protected function fun_564 +protected function fun_565 input Tpl.Text in_txt; input SimCode.Context in_i_context; input DAE.ComponentRef in_i_ecr_componentRef; @@ -24473,7 +24525,7 @@ algorithm ret_3 = listLength(i_dims); i_dimsLenStr = Tpl.writeStr(emptyTxt, intString(ret_3)); i_dimsValuesStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - i_dimsValuesStr = lm_563(i_dimsValuesStr, i_dims); + i_dimsValuesStr = lm_564(i_dimsValuesStr, i_dims); i_dimsValuesStr = Tpl.popIter(i_dimsValuesStr); i_preExp = expTypeShort(i_preExp, i_aty); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING("_array_create(&")); @@ -24489,7 +24541,7 @@ algorithm txt = Tpl.writeText(txt, i_tmpArr); then (txt, i_preExp, i_varDecls); end matchcontinue; -end fun_564; +end fun_565; public function daeExpCrefRhsArrayBox input Tpl.Text in_txt; @@ -24521,7 +24573,7 @@ algorithm DAE.ExpType i_aty; DAE.Exp i_ecr; equation - (txt, i_preExp, i_varDecls) = fun_564(txt, i_context, i_ecr_componentRef, i_preExp, i_dims, i_varDecls, i_aty); + (txt, i_preExp, i_varDecls) = fun_565(txt, i_context, i_ecr_componentRef, i_preExp, i_dims, i_varDecls, i_aty); then (txt, i_preExp, i_varDecls); case ( txt, @@ -24533,7 +24585,7 @@ algorithm end matchcontinue; end daeExpCrefRhsArrayBox; -protected function lm_566 +protected function lm_567 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -24576,7 +24628,7 @@ algorithm ret_0 = SimCode.makeCrefRecordExp(i_cr, i_v); (txt, i_preExp, i_varDecls) = daeExp(txt, ret_0, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_566(txt, rest, i_varDecls, i_preExp, i_context, i_cr); + (txt, i_varDecls, i_preExp) = lm_567(txt, rest, i_varDecls, i_preExp, i_context, i_cr); then (txt, i_varDecls, i_preExp); case ( txt, @@ -24588,10 +24640,10 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_566(txt, rest, i_varDecls, i_preExp, i_context, i_cr); + (txt, i_varDecls, i_preExp) = lm_567(txt, rest, i_varDecls, i_preExp, i_context, i_cr); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_566; +end lm_567; public function daeExpRecordCrefRhs input Tpl.Text in_txt; @@ -24629,7 +24681,7 @@ algorithm Tpl.Text i_vars; equation i_vars = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_vars, i_varDecls, i_preExp) = lm_566(i_vars, i_var__lst, i_varDecls, i_preExp, i_context, i_cr); + (i_vars, i_varDecls, i_preExp) = lm_567(i_vars, i_var__lst, i_varDecls, i_preExp, i_context, i_cr); i_vars = Tpl.popIter(i_vars); i_record__type__name = underscorePath(emptyTxt, i_record__path); i_ret__type = Tpl.writeText(emptyTxt, i_record__type__name); @@ -24658,7 +24710,7 @@ algorithm end matchcontinue; end daeExpRecordCrefRhs; -protected function fun_568 +protected function fun_569 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -24681,9 +24733,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("real_array")); then txt; end matchcontinue; -end fun_568; +end fun_569; -protected function fun_569 +protected function fun_570 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -24706,9 +24758,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("real_array")); then txt; end matchcontinue; -end fun_569; +end fun_570; -protected function fun_570 +protected function fun_571 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -24731,9 +24783,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("real_array")); then txt; end matchcontinue; -end fun_570; +end fun_571; -protected function fun_571 +protected function fun_572 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -24756,9 +24808,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("real_array")); then txt; end matchcontinue; -end fun_571; +end fun_572; -protected function fun_572 +protected function fun_573 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -24781,9 +24833,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("real_scalar")); then txt; end matchcontinue; -end fun_572; +end fun_573; -protected function fun_573 +protected function fun_574 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -24806,9 +24858,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("real")); then txt; end matchcontinue; -end fun_573; +end fun_574; -protected function fun_574 +protected function fun_575 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -24831,9 +24883,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("real_array")); then txt; end matchcontinue; -end fun_574; +end fun_575; -protected function fun_575 +protected function fun_576 input Tpl.Text in_txt; input DAE.Operator in_i_operator; input SimCode.Context in_i_context; @@ -24986,7 +25038,7 @@ algorithm Tpl.Text i_var; Tpl.Text i_type; equation - i_type = fun_568(emptyTxt, i_ty); + i_type = fun_569(emptyTxt, i_ty); (i_var, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_type), i_varDecls); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING("add_alloc_")); i_preExp = Tpl.writeText(i_preExp, i_type); @@ -25014,7 +25066,7 @@ algorithm Tpl.Text i_var; Tpl.Text i_type; equation - i_type = fun_569(emptyTxt, i_ty); + i_type = fun_570(emptyTxt, i_ty); (i_var, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_type), i_varDecls); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING("sub_alloc_")); i_preExp = Tpl.writeText(i_preExp, i_type); @@ -25066,7 +25118,7 @@ algorithm Tpl.Text i_var; Tpl.Text i_type; equation - i_type = fun_570(emptyTxt, i_ty); + i_type = fun_571(emptyTxt, i_ty); (i_var, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_type), i_varDecls); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING("mul_alloc_scalar_")); i_preExp = Tpl.writeText(i_preExp, i_type); @@ -25094,7 +25146,7 @@ algorithm Tpl.Text i_var; Tpl.Text i_type; equation - i_type = fun_571(emptyTxt, i_ty); + i_type = fun_572(emptyTxt, i_ty); (i_var, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_type), i_varDecls); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING("mul_alloc_")); i_preExp = Tpl.writeText(i_preExp, i_type); @@ -25169,7 +25221,7 @@ algorithm DAE.ExpType i_ty; Tpl.Text i_type; equation - i_type = fun_572(emptyTxt, i_ty); + i_type = fun_573(emptyTxt, i_ty); txt = Tpl.writeTok(txt, Tpl.ST_STRING("mul_")); txt = Tpl.writeText(txt, i_type); txt = Tpl.writeTok(txt, Tpl.ST_STRING("_product(&")); @@ -25193,7 +25245,7 @@ algorithm Tpl.Text i_type; Tpl.Text i_typeShort; equation - i_typeShort = fun_573(emptyTxt, i_ty); + i_typeShort = fun_574(emptyTxt, i_ty); i_type = Tpl.writeText(emptyTxt, i_typeShort); i_type = Tpl.writeTok(i_type, Tpl.ST_STRING("_array")); (i_var, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_type), i_varDecls); @@ -25223,7 +25275,7 @@ algorithm Tpl.Text i_var; Tpl.Text i_type; equation - i_type = fun_574(emptyTxt, i_ty); + i_type = fun_575(emptyTxt, i_ty); (i_var, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_type), i_varDecls); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING("div_alloc_")); i_preExp = Tpl.writeText(i_preExp, i_type); @@ -25310,7 +25362,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR")); then (txt, i_preExp, i_varDecls); end matchcontinue; -end fun_575; +end fun_576; public function daeExpBinary input Tpl.Text in_txt; @@ -25346,7 +25398,7 @@ algorithm equation (i_e1, i_preExp, i_varDecls) = daeExp(emptyTxt, i_exp1, i_context, i_preExp, i_varDecls); (i_e2, i_preExp, i_varDecls) = daeExp(emptyTxt, i_exp2, i_context, i_preExp, i_varDecls); - (txt, i_preExp, i_varDecls) = fun_575(txt, i_operator, i_context, i_exp, i_e2, i_e1, i_preExp, i_varDecls); + (txt, i_preExp, i_varDecls) = fun_576(txt, i_operator, i_context, i_exp, i_e2, i_e1, i_preExp, i_varDecls); then (txt, i_preExp, i_varDecls); case ( txt, @@ -25358,7 +25410,7 @@ algorithm end matchcontinue; end daeExpBinary; -protected function fun_577 +protected function fun_578 input Tpl.Text in_txt; input DAE.Operator in_i_operator; input Tpl.Text in_i_preExp; @@ -25430,7 +25482,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("daeExpUnary:ERR")); then (txt, i_preExp); end matchcontinue; -end fun_577; +end fun_578; public function daeExpUnary input Tpl.Text in_txt; @@ -25462,7 +25514,7 @@ algorithm Tpl.Text i_e; equation (i_e, i_preExp, i_varDecls) = daeExp(emptyTxt, i_exp, i_context, i_preExp, i_varDecls); - (txt, i_preExp) = fun_577(txt, i_operator, i_preExp, i_e); + (txt, i_preExp) = fun_578(txt, i_operator, i_preExp, i_e); then (txt, i_preExp, i_varDecls); case ( txt, @@ -25474,7 +25526,7 @@ algorithm end matchcontinue; end daeExpUnary; -protected function fun_579 +protected function fun_580 input Tpl.Text in_txt; input DAE.Operator in_i_operator; input Tpl.Text in_i_e2; @@ -25521,7 +25573,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("daeExpLbinary:ERR")); then txt; end matchcontinue; -end fun_579; +end fun_580; public function daeExpLbinary input Tpl.Text in_txt; @@ -25556,7 +25608,7 @@ algorithm equation (i_e1, i_preExp, i_varDecls) = daeExp(emptyTxt, i_exp1, i_context, i_preExp, i_varDecls); (i_e2, i_preExp, i_varDecls) = daeExp(emptyTxt, i_exp2, i_context, i_preExp, i_varDecls); - txt = fun_579(txt, i_operator, i_e2, i_e1); + txt = fun_580(txt, i_operator, i_e2, i_e1); then (txt, i_preExp, i_varDecls); case ( txt, @@ -25568,7 +25620,7 @@ algorithm end matchcontinue; end daeExpLbinary; -protected function fun_581 +protected function fun_582 input Tpl.Text in_txt; input DAE.Operator in_i_operator; input Tpl.Text in_i_e; @@ -25595,7 +25647,7 @@ algorithm _ ) then txt; end matchcontinue; -end fun_581; +end fun_582; public function daeExpLunary input Tpl.Text in_txt; @@ -25627,7 +25679,7 @@ algorithm Tpl.Text i_e; equation (i_e, i_preExp, i_varDecls) = daeExp(emptyTxt, i_exp, i_context, i_preExp, i_varDecls); - txt = fun_581(txt, i_operator, i_e); + txt = fun_582(txt, i_operator, i_e); then (txt, i_preExp, i_varDecls); case ( txt, @@ -25639,7 +25691,7 @@ algorithm end matchcontinue; end daeExpLunary; -protected function fun_583 +protected function fun_584 input Tpl.Text in_txt; input DAE.Operator in_i_rel_operator; input Tpl.Text in_i_e2; @@ -25954,9 +26006,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("daeExpRelation:ERR")); then txt; end matchcontinue; -end fun_583; +end fun_584; -protected function fun_584 +protected function fun_585 input Tpl.Text in_txt; input String in_it; input Tpl.Text in_i_simRel; @@ -25998,7 +26050,7 @@ algorithm equation (i_e1, i_preExp, i_varDecls) = daeExp(emptyTxt, i_rel_exp1, i_context, i_preExp, i_varDecls); (i_e2, i_preExp, i_varDecls) = daeExp(emptyTxt, i_rel_exp2, i_context, i_preExp, i_varDecls); - txt = fun_583(txt, i_rel_operator, i_e2, i_e1); + txt = fun_584(txt, i_rel_operator, i_e2, i_e1); then (txt, i_varDecls, i_preExp); case ( txt, @@ -26014,7 +26066,7 @@ algorithm txt = Tpl.writeText(txt, i_simRel); then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_584; +end fun_585; public function daeExpRelation input Tpl.Text in_txt; @@ -26050,7 +26102,7 @@ algorithm equation (i_simRel, i_preExp, i_varDecls) = daeExpRelationSim(emptyTxt, i_rel, i_context, i_preExp, i_varDecls); str_1 = Tpl.textString(i_simRel); - (txt, i_varDecls, i_preExp) = fun_584(txt, str_1, i_simRel, i_rel_operator, i_rel_exp2, i_varDecls, i_preExp, i_context, i_rel_exp1); + (txt, i_varDecls, i_preExp) = fun_585(txt, str_1, i_simRel, i_rel_operator, i_rel_exp2, i_varDecls, i_preExp, i_context, i_rel_exp1); then (txt, i_preExp, i_varDecls); case ( txt, @@ -26062,7 +26114,7 @@ algorithm end matchcontinue; end daeExpRelation; -protected function fun_586 +protected function fun_587 input Tpl.Text in_txt; input DAE.Operator in_i_rel_operator; input Tpl.Text in_i_e2; @@ -26162,9 +26214,9 @@ algorithm i_preExp ) then (txt, i_preExp); end matchcontinue; -end fun_586; +end fun_587; -protected function fun_587 +protected function fun_588 input Tpl.Text in_txt; input SimCode.Context in_i_context; input DAE.Operator in_i_rel_operator; @@ -26203,7 +26255,7 @@ algorithm (i_e1, i_preExp, i_varDecls) = daeExp(emptyTxt, i_rel_exp1, i_context, i_preExp, i_varDecls); (i_e2, i_preExp, i_varDecls) = daeExp(emptyTxt, i_rel_exp2, i_context, i_preExp, i_varDecls); (i_res, i_varDecls) = tempDecl(emptyTxt, "modelica_boolean", i_varDecls); - (txt, i_preExp) = fun_586(txt, i_rel_operator, i_e2, i_e1, i_res, i_preExp); + (txt, i_preExp) = fun_587(txt, i_rel_operator, i_e2, i_e1, i_res, i_preExp); then (txt, i_varDecls, i_preExp); case ( txt, @@ -26215,7 +26267,7 @@ algorithm _ ) then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_587; +end fun_588; public function daeExpRelationSim input Tpl.Text in_txt; @@ -26247,7 +26299,7 @@ algorithm DAE.Exp i_rel_exp1; DAE.Exp i_rel; equation - (txt, i_varDecls, i_preExp) = fun_587(txt, i_context, i_rel_operator, i_rel_exp2, i_varDecls, i_preExp, i_rel_exp1); + (txt, i_varDecls, i_preExp) = fun_588(txt, i_context, i_rel_operator, i_rel_exp2, i_varDecls, i_preExp, i_rel_exp1); then (txt, i_preExp, i_varDecls); case ( txt, @@ -26344,7 +26396,7 @@ algorithm end matchcontinue; end daeExpIf; -protected function fun_590 +protected function fun_591 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -26367,9 +26419,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("real_array")); then txt; end matchcontinue; -end fun_590; +end fun_591; -protected function fun_591 +protected function fun_592 input Tpl.Text in_txt; input DAE.ExpType in_i_arg_ty; @@ -26390,9 +26442,9 @@ algorithm _ ) then txt; end matchcontinue; -end fun_591; +end fun_592; -protected function lm_592 +protected function lm_593 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -26429,7 +26481,7 @@ algorithm equation (txt, i_preExp, i_varDecls) = daeExp(txt, i_exp, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_592(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_593(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); case ( txt, @@ -26440,12 +26492,12 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_592(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_593(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_592; +end lm_593; -protected function lm_593 +protected function lm_594 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -26482,7 +26534,7 @@ algorithm equation (txt, i_preExp, i_varDecls) = daeExp(txt, i_exp, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_593(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_594(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); case ( txt, @@ -26493,12 +26545,12 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_593(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_594(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_593; +end lm_594; -protected function fun_594 +protected function fun_595 input Tpl.Text in_txt; input Boolean in_i_builtin; input Tpl.Text in_i_retType; @@ -26532,9 +26584,9 @@ algorithm txt = Tpl.writeText(txt, i_retVar); then txt; end matchcontinue; -end fun_594; +end fun_595; -protected function lm_595 +protected function lm_596 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -26571,7 +26623,7 @@ algorithm equation (txt, i_preExp, i_varDecls) = daeExp(txt, i_exp, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_595(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_596(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); case ( txt, @@ -26582,10 +26634,10 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_595(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_596(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_595; +end lm_596; public function daeExpCall input Tpl.Text in_txt; @@ -26650,7 +26702,7 @@ algorithm Tpl.Text i_var; Tpl.Text i_type; equation - i_type = fun_590(emptyTxt, i_ty); + i_type = fun_591(emptyTxt, i_ty); (i_var, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_type), i_varDecls); (i_var1, i_preExp, i_varDecls) = daeExp(emptyTxt, i_e1, i_context, i_preExp, i_varDecls); (i_var2, i_preExp, i_varDecls) = daeExp(emptyTxt, i_e2, i_context, i_preExp, i_varDecls); @@ -26699,7 +26751,7 @@ algorithm equation i_retType = expTypeArrayIf(emptyTxt, i_arg_ty); (i_retVar, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_retType), i_varDecls); - i_cast = fun_591(emptyTxt, i_arg_ty); + i_cast = fun_592(emptyTxt, i_arg_ty); i_preExp = Tpl.writeText(i_preExp, i_retVar); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING(" = ")); i_preExp = Tpl.writeText(i_preExp, i_cast); @@ -27148,7 +27200,7 @@ algorithm Tpl.Text i_argStr; equation i_argStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_argStr, i_varDecls, i_preExp) = lm_592(i_argStr, i_expLst, i_varDecls, i_preExp, i_context); + (i_argStr, i_varDecls, i_preExp) = lm_593(i_argStr, i_expLst, i_varDecls, i_preExp, i_context); i_argStr = Tpl.popIter(i_argStr); i_funName = underscorePath(emptyTxt, i_path); i_preExp = daeExpCallBuiltinPrefix(i_preExp, i_builtin); @@ -27175,7 +27227,7 @@ algorithm Tpl.Text i_argStr; equation i_argStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_argStr, i_varDecls, i_preExp) = lm_593(i_argStr, i_expLst, i_varDecls, i_preExp, i_context); + (i_argStr, i_varDecls, i_preExp) = lm_594(i_argStr, i_expLst, i_varDecls, i_preExp, i_context); i_argStr = Tpl.popIter(i_argStr); i_funName = underscorePath(emptyTxt, i_path); i_retType = Tpl.writeText(emptyTxt, i_funName); @@ -27189,7 +27241,7 @@ algorithm i_preExp = Tpl.writeText(i_preExp, i_argStr); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING(");")); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_NEW_LINE()); - txt = fun_594(txt, i_builtin, i_retType, i_retVar); + txt = fun_595(txt, i_builtin, i_retType, i_retVar); then (txt, i_preExp, i_varDecls); case ( txt, @@ -27207,7 +27259,7 @@ algorithm Tpl.Text i_argStr; equation i_argStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_argStr, i_varDecls, i_preExp) = lm_595(i_argStr, i_expLst, i_varDecls, i_preExp, i_context); + (i_argStr, i_varDecls, i_preExp) = lm_596(i_argStr, i_expLst, i_varDecls, i_preExp, i_context); i_argStr = Tpl.popIter(i_argStr); i_funName = underscorePath(emptyTxt, i_path); i_retType = Tpl.writeText(emptyTxt, i_funName); @@ -27260,7 +27312,7 @@ algorithm end matchcontinue; end daeExpCallBuiltinPrefix; -protected function fun_598 +protected function fun_599 input Tpl.Text in_txt; input Boolean in_i_scalar; @@ -27281,9 +27333,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("scalar_")); then txt; end matchcontinue; -end fun_598; +end fun_599; -protected function fun_599 +protected function fun_600 input Tpl.Text in_txt; input Boolean in_i_scalar; @@ -27304,9 +27356,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("&")); then txt; end matchcontinue; -end fun_599; +end fun_600; -protected function fun_600 +protected function fun_601 input Tpl.Text in_txt; input Boolean in_i_scalar; input DAE.Exp in_i_e; @@ -27335,9 +27387,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING(")")); then txt; end matchcontinue; -end fun_600; +end fun_601; -protected function lm_601 +protected function lm_602 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -27377,11 +27429,11 @@ algorithm DAE.Exp i_e; Tpl.Text i_prefix; equation - i_prefix = fun_600(emptyTxt, i_scalar, i_e); + i_prefix = fun_601(emptyTxt, i_scalar, i_e); txt = Tpl.writeText(txt, i_prefix); (txt, i_preExp, i_varDecls) = daeExp(txt, i_e, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_601(txt, rest, i_varDecls, i_preExp, i_context, i_scalar); + (txt, i_varDecls, i_preExp) = lm_602(txt, rest, i_varDecls, i_preExp, i_context, i_scalar); then (txt, i_varDecls, i_preExp); case ( txt, @@ -27393,10 +27445,10 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_601(txt, rest, i_varDecls, i_preExp, i_context, i_scalar); + (txt, i_varDecls, i_preExp) = lm_602(txt, rest, i_varDecls, i_preExp, i_context, i_scalar); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_601; +end lm_602; public function daeExpArray input Tpl.Text in_txt; @@ -27435,10 +27487,10 @@ algorithm equation i_arrayTypeStr = expTypeArray(emptyTxt, i_ty); (i_arrayVar, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(i_arrayTypeStr), i_varDecls); - i_scalarPrefix = fun_598(emptyTxt, i_scalar); - i_scalarRef = fun_599(emptyTxt, i_scalar); + i_scalarPrefix = fun_599(emptyTxt, i_scalar); + i_scalarRef = fun_600(emptyTxt, i_scalar); i_params = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_params, i_varDecls, i_preExp) = lm_601(i_params, i_array, i_varDecls, i_preExp, i_context, i_scalar); + (i_params, i_varDecls, i_preExp) = lm_602(i_params, i_array, i_varDecls, i_preExp, i_context, i_scalar); i_params = Tpl.popIter(i_params); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING("array_alloc_")); i_preExp = Tpl.writeText(i_preExp, i_scalarPrefix); @@ -27464,7 +27516,7 @@ algorithm end matchcontinue; end daeExpArray; -protected function lm_603 +protected function lm_604 input Tpl.Text in_txt; input list>> in_items; input Tpl.Text in_i_vars2; @@ -27525,7 +27577,7 @@ algorithm txt = Tpl.writeText(txt, i_vars); txt = Tpl.writeTok(txt, Tpl.ST_STRING(");")); txt = Tpl.nextIter(txt); - (txt, i_vars2, i_promote, i_varDecls) = lm_603(txt, rest, i_vars2, i_promote, i_context, i_varDecls, i_arrayTypeStr); + (txt, i_vars2, i_promote, i_varDecls) = lm_604(txt, rest, i_vars2, i_promote, i_context, i_varDecls, i_arrayTypeStr); then (txt, i_vars2, i_promote, i_varDecls); case ( txt, @@ -27538,10 +27590,10 @@ algorithm local list>> rest; equation - (txt, i_vars2, i_promote, i_varDecls) = lm_603(txt, rest, i_vars2, i_promote, i_context, i_varDecls, i_arrayTypeStr); + (txt, i_vars2, i_promote, i_varDecls) = lm_604(txt, rest, i_vars2, i_promote, i_context, i_varDecls, i_arrayTypeStr); then (txt, i_vars2, i_promote, i_varDecls); end matchcontinue; -end lm_603; +end lm_604; public function daeExpMatrix input Tpl.Text in_txt; @@ -27624,7 +27676,7 @@ algorithm i_vars2 = emptyTxt; i_promote = emptyTxt; i_catAlloc = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_catAlloc, i_vars2, i_promote, i_varDecls) = lm_603(i_catAlloc, i_m_scalar, i_vars2, i_promote, i_context, i_varDecls, i_arrayTypeStr); + (i_catAlloc, i_vars2, i_promote, i_varDecls) = lm_604(i_catAlloc, i_m_scalar, i_vars2, i_promote, i_context, i_varDecls, i_arrayTypeStr); i_catAlloc = Tpl.popIter(i_catAlloc); i_preExp = Tpl.writeText(i_preExp, i_promote); i_preExp = Tpl.writeText(i_preExp, i_catAlloc); @@ -27652,7 +27704,7 @@ algorithm end matchcontinue; end daeExpMatrix; -protected function fun_605 +protected function fun_606 input Tpl.Text in_txt; input Boolean in_i_b; @@ -27673,9 +27725,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("scalar_")); then txt; end matchcontinue; -end fun_605; +end fun_606; -protected function fun_606 +protected function fun_607 input Tpl.Text in_txt; input Boolean in_i_b; @@ -27696,9 +27748,9 @@ algorithm _ ) then txt; end matchcontinue; -end fun_606; +end fun_607; -protected function lm_607 +protected function lm_608 input Tpl.Text in_txt; input list> in_items; input Tpl.Text in_i_varLstStr; @@ -27748,8 +27800,8 @@ algorithm Tpl.Text i_scalarRefStr; Tpl.Text i_scalarStr; equation - i_scalarStr = fun_605(emptyTxt, i_b); - i_scalarRefStr = fun_606(emptyTxt, i_b); + i_scalarStr = fun_606(emptyTxt, i_b); + i_scalarRefStr = fun_607(emptyTxt, i_b); (i_expVar, i_preExp, i_varDecls) = daeExp(emptyTxt, i_e, i_context, i_preExp, i_varDecls); (i_tmp, i_varDecls) = tempDecl(emptyTxt, i_arrayTypeStr, i_varDecls); i_varLstStr = Tpl.writeTok(i_varLstStr, Tpl.ST_STRING(", &")); @@ -27764,7 +27816,7 @@ algorithm txt = Tpl.writeText(txt, i_tmp); txt = Tpl.writeTok(txt, Tpl.ST_STRING(");")); txt = Tpl.nextIter(txt); - (txt, i_varLstStr, i_varDecls, i_preExp) = lm_607(txt, rest, i_varLstStr, i_arrayTypeStr, i_varDecls, i_preExp, i_context); + (txt, i_varLstStr, i_varDecls, i_preExp) = lm_608(txt, rest, i_varLstStr, i_arrayTypeStr, i_varDecls, i_preExp, i_context); then (txt, i_varLstStr, i_varDecls, i_preExp); case ( txt, @@ -27777,10 +27829,10 @@ algorithm local list> rest; equation - (txt, i_varLstStr, i_varDecls, i_preExp) = lm_607(txt, rest, i_varLstStr, i_arrayTypeStr, i_varDecls, i_preExp, i_context); + (txt, i_varLstStr, i_varDecls, i_preExp) = lm_608(txt, rest, i_varLstStr, i_arrayTypeStr, i_varDecls, i_preExp, i_context); then (txt, i_varLstStr, i_varDecls, i_preExp); end matchcontinue; -end lm_607; +end lm_608; public function daeExpMatrixRow input Tpl.Text txt; @@ -27799,14 +27851,14 @@ protected algorithm i_varLstStr := emptyTxt; i_preExp2 := Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_preExp2, i_varLstStr, out_i_varDecls, out_i_preExp) := lm_607(i_preExp2, i_row, i_varLstStr, i_arrayTypeStr, i_varDecls, i_preExp, i_context); + (i_preExp2, i_varLstStr, out_i_varDecls, out_i_preExp) := lm_608(i_preExp2, i_row, i_varLstStr, i_arrayTypeStr, i_varDecls, i_preExp, i_context); i_preExp2 := Tpl.popIter(i_preExp2); i_preExp2 := Tpl.writeTok(i_preExp2, Tpl.ST_NEW_LINE()); out_i_preExp := Tpl.writeText(out_i_preExp, i_preExp2); out_txt := Tpl.writeText(txt, i_varLstStr); end daeExpMatrixRow; -protected function fun_609 +protected function fun_610 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; input Tpl.Text in_i_preExp; @@ -27889,7 +27941,7 @@ algorithm _ ) then (txt, i_preExp, i_varDecls); end matchcontinue; -end fun_609; +end fun_610; public function daeExpCast input Tpl.Text in_txt; @@ -27921,7 +27973,7 @@ algorithm Tpl.Text i_expVar; equation (i_expVar, i_preExp, i_varDecls) = daeExp(emptyTxt, i_exp, i_context, i_preExp, i_varDecls); - (txt, i_preExp, i_varDecls) = fun_609(txt, i_ty, i_preExp, i_exp, i_varDecls, i_expVar); + (txt, i_preExp, i_varDecls) = fun_610(txt, i_ty, i_preExp, i_exp, i_varDecls, i_expVar); then (txt, i_preExp, i_varDecls); case ( txt, @@ -27933,7 +27985,7 @@ algorithm end matchcontinue; end daeExpCast; -protected function fun_611 +protected function fun_612 input Tpl.Text in_txt; input DAE.Exp in_i_exp; input Tpl.Text in_i_varDecls; @@ -27979,9 +28031,9 @@ algorithm _ ) then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_611; +end fun_612; -protected function fun_612 +protected function fun_613 input Tpl.Text in_txt; input SimCode.Context in_i_context; input Tpl.Text in_i_varDecls; @@ -28028,9 +28080,9 @@ algorithm (txt, i_preExp, i_varDecls) = arrayScalarRhs(txt, i_ecr_ty, i_subs, Tpl.textString(i_arrName), i_context, i_preExp, i_varDecls); then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_612; +end fun_613; -protected function fun_613 +protected function fun_614 input Tpl.Text in_txt; input DAE.Exp in_i_exp; input Tpl.Text in_i_varDecls; @@ -28197,7 +28249,7 @@ algorithm equation ret_1 = SimCode.buildCrefExpFromAsub(i_ecr, i_subs); (i_arrName, i_preExp, i_varDecls) = daeExpCrefRhs(emptyTxt, ret_1, i_context, i_preExp, i_varDecls); - (txt, i_varDecls, i_preExp) = fun_612(txt, i_context, i_varDecls, i_preExp, i_subs, i_ecr_ty, i_arrName); + (txt, i_varDecls, i_preExp) = fun_613(txt, i_context, i_varDecls, i_preExp, i_subs, i_ecr_ty, i_arrName); then (txt, i_varDecls, i_preExp); case ( txt, @@ -28209,9 +28261,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("OTHER_ASUB")); then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_613; +end fun_614; -protected function fun_614 +protected function fun_615 input Tpl.Text in_txt; input String in_it; input DAE.Exp in_i_exp; @@ -28239,7 +28291,7 @@ algorithm i_preExp, i_varDecls ) equation - (txt, i_varDecls, i_preExp) = fun_611(txt, i_exp, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = fun_612(txt, i_exp, i_varDecls, i_preExp, i_context); then (txt, i_preExp, i_varDecls); case ( txt, @@ -28249,10 +28301,10 @@ algorithm i_preExp, i_varDecls ) equation - (txt, i_varDecls, i_preExp) = fun_613(txt, i_exp, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = fun_614(txt, i_exp, i_varDecls, i_preExp, i_context); then (txt, i_preExp, i_varDecls); end matchcontinue; -end fun_614; +end fun_615; public function daeExpAsub input Tpl.Text txt; @@ -28270,7 +28322,7 @@ protected algorithm txt_0 := expTypeFromExpShort(emptyTxt, i_exp); str_1 := Tpl.textString(txt_0); - (out_txt, out_i_preExp, out_i_varDecls) := fun_614(txt, str_1, i_exp, i_context, i_preExp, i_varDecls); + (out_txt, out_i_preExp, out_i_varDecls) := fun_615(txt, str_1, i_exp, i_context, i_preExp, i_varDecls); end daeExpAsub; public function daeExpSize @@ -28333,7 +28385,7 @@ algorithm end matchcontinue; end daeExpSize; -protected function fun_617 +protected function fun_618 input Tpl.Text in_txt; input String in_it; @@ -28360,7 +28412,7 @@ algorithm _ ) then txt; end matchcontinue; -end fun_617; +end fun_618; public function daeExpReduction input Tpl.Text in_txt; @@ -28407,7 +28459,7 @@ algorithm i_tmpExpPre = emptyTxt; (i_tmpExpVar, i_tmpExpPre, i_varDecls) = daeExp(emptyTxt, i_expr, i_context, i_tmpExpPre, i_varDecls); str_7 = Tpl.textString(i_accFun); - i_cast = fun_617(emptyTxt, str_7); + i_cast = fun_618(emptyTxt, str_7); i_body = Tpl.writeText(emptyTxt, i_tmpExpPre); i_body = Tpl.softNewLine(i_body); i_body = Tpl.writeText(i_body, i_res); @@ -28502,7 +28554,7 @@ algorithm end matchcontinue; end daeExpReductionLoop; -protected function fun_620 +protected function fun_621 input Tpl.Text in_txt; input String in_i_type; @@ -28531,9 +28583,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("INVALID_TYPE")); then txt; end matchcontinue; -end fun_620; +end fun_621; -protected function fun_621 +protected function fun_622 input Tpl.Text in_txt; input String in_i_type; @@ -28562,7 +28614,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("INVALID_TYPE")); then txt; end matchcontinue; -end fun_621; +end fun_622; public function daeExpReductionFnName input Tpl.Text in_txt; @@ -28581,14 +28633,14 @@ algorithm "sum", i_type ) equation - txt = fun_620(txt, i_type); + txt = fun_621(txt, i_type); then txt; case ( txt, "product", i_type ) equation - txt = fun_621(txt, i_type); + txt = fun_622(txt, i_type); then txt; case ( txt, @@ -28602,7 +28654,7 @@ algorithm end matchcontinue; end daeExpReductionFnName; -protected function fun_623 +protected function fun_624 input Tpl.Text in_txt; input String in_i_type; @@ -28631,9 +28683,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("INVALID_TYPE")); then txt; end matchcontinue; -end fun_623; +end fun_624; -protected function fun_624 +protected function fun_625 input Tpl.Text in_txt; input String in_i_type; @@ -28662,7 +28714,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("INVALID_TYPE")); then txt; end matchcontinue; -end fun_624; +end fun_625; public function daeExpReductionStartValue input Tpl.Text in_txt; @@ -28681,14 +28733,14 @@ algorithm "min", i_type ) equation - txt = fun_623(txt, i_type); + txt = fun_624(txt, i_type); then txt; case ( txt, "max", i_type ) equation - txt = fun_624(txt, i_type); + txt = fun_625(txt, i_type); then txt; case ( txt, @@ -28714,7 +28766,7 @@ algorithm end matchcontinue; end daeExpReductionStartValue; -protected function lm_626 +protected function lm_627 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_preExpInner; @@ -28746,7 +28798,7 @@ algorithm SimCode.Variable i_var; equation (txt, i_varDeclsInner, i_preExpInner) = varInit(txt, i_var, "", 0, i_varDeclsInner, i_preExpInner); - (txt, i_preExpInner, i_varDeclsInner) = lm_626(txt, rest, i_preExpInner, i_varDeclsInner); + (txt, i_preExpInner, i_varDeclsInner) = lm_627(txt, rest, i_preExpInner, i_varDeclsInner); then (txt, i_preExpInner, i_varDeclsInner); case ( txt, @@ -28756,12 +28808,12 @@ algorithm local list rest; equation - (txt, i_preExpInner, i_varDeclsInner) = lm_626(txt, rest, i_preExpInner, i_varDeclsInner); + (txt, i_preExpInner, i_varDeclsInner) = lm_627(txt, rest, i_preExpInner, i_varDeclsInner); then (txt, i_preExpInner, i_varDeclsInner); end matchcontinue; -end lm_626; +end lm_627; -protected function lm_627 +protected function lm_628 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDeclsInner; @@ -28793,7 +28845,7 @@ algorithm equation (txt, i_varDeclsInner) = algStatement(txt, i_stmt, i_context, i_varDeclsInner); txt = Tpl.nextIter(txt); - (txt, i_varDeclsInner) = lm_627(txt, rest, i_varDeclsInner, i_context); + (txt, i_varDeclsInner) = lm_628(txt, rest, i_varDeclsInner, i_context); then (txt, i_varDeclsInner); case ( txt, @@ -28803,12 +28855,12 @@ algorithm local list rest; equation - (txt, i_varDeclsInner) = lm_627(txt, rest, i_varDeclsInner, i_context); + (txt, i_varDeclsInner) = lm_628(txt, rest, i_varDeclsInner, i_context); then (txt, i_varDeclsInner); end matchcontinue; -end lm_627; +end lm_628; -protected function fun_628 +protected function fun_629 input Tpl.Text in_txt; input DAE.Exp in_i_exp; input SimCode.Context in_i_context; @@ -28850,12 +28902,12 @@ algorithm i_varDeclsInner = emptyTxt; i_ignore = emptyTxt; ret_5 = SimCode.valueblockVars(i_exp); - (i_0__, i_preExpInner, i_varDeclsInner) = lm_626(emptyTxt, ret_5, i_preExpInner, i_varDeclsInner); + (i_0__, i_preExpInner, i_varDeclsInner) = lm_627(emptyTxt, ret_5, i_preExpInner, i_varDeclsInner); i_resType = expTypeModelica(emptyTxt, i_ty); txt_8 = expTypeModelica(emptyTxt, i_ty); (i_res, i_preExp) = tempDecl(emptyTxt, Tpl.textString(txt_8), i_preExp); i_stmts = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_stmts, i_varDeclsInner) = lm_627(i_stmts, i_body, i_varDeclsInner, i_context); + (i_stmts, i_varDeclsInner) = lm_628(i_stmts, i_body, i_varDeclsInner, i_context); i_stmts = Tpl.popIter(i_stmts); (i_expPart, i_preExpRes, i_varDeclsInner) = daeExp(emptyTxt, i_result, i_context, i_preExpRes, i_varDeclsInner); i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_LINE("{\n")); @@ -28883,7 +28935,7 @@ algorithm i_preExp ) then (txt, i_preExp); end matchcontinue; -end fun_628; +end fun_629; public function daeExpValueblock input Tpl.Text txt; @@ -28896,11 +28948,11 @@ public function daeExpValueblock output Tpl.Text out_i_preExp; output Tpl.Text out_i_varDecls; algorithm - (out_txt, out_i_preExp) := fun_628(txt, i_exp, i_context, i_preExp); + (out_txt, out_i_preExp) := fun_629(txt, i_exp, i_context, i_preExp); out_i_varDecls := i_varDecls; end daeExpValueblock; -protected function lm_630 +protected function lm_631 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -28937,7 +28989,7 @@ algorithm equation (txt, i_preExp, i_varDecls) = daeExp(txt, i_exp, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_630(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_631(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); case ( txt, @@ -28948,10 +29000,10 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_630(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_631(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_630; +end lm_631; public function arrayScalarRhs input Tpl.Text txt; @@ -28975,7 +29027,7 @@ algorithm ret_2 := listLength(i_subs); i_dimsLenStr := Tpl.writeStr(emptyTxt, intString(ret_2)); i_dimsValuesStr := Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_dimsValuesStr, out_i_varDecls, out_i_preExp) := lm_630(i_dimsValuesStr, i_subs, i_varDecls, i_preExp, i_context); + (i_dimsValuesStr, out_i_varDecls, out_i_preExp) := lm_631(i_dimsValuesStr, i_subs, i_varDecls, i_preExp, i_context); i_dimsValuesStr := Tpl.popIter(i_dimsValuesStr); out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*")); out_txt := Tpl.writeText(out_txt, i_arrayType); @@ -29146,7 +29198,7 @@ algorithm end matchcontinue; end daeExpCons; -protected function lm_635 +protected function lm_636 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -29183,7 +29235,7 @@ algorithm equation (txt, i_preExp, i_varDecls) = daeExpMetaHelperConstant(txt, i_e, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_635(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_636(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); case ( txt, @@ -29194,10 +29246,10 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_635(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_636(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_635; +end lm_636; public function daeExpMetaTuple input Tpl.Text in_txt; @@ -29233,7 +29285,7 @@ algorithm ret_1 = listLength(i_listExp); i_start = daeExpMetaHelperBoxStart(emptyTxt, ret_1); i_args = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (i_args, i_varDecls, i_preExp) = lm_635(i_args, i_listExp, i_varDecls, i_preExp, i_context); + (i_args, i_varDecls, i_preExp) = lm_636(i_args, i_listExp, i_varDecls, i_preExp, i_context); i_args = Tpl.popIter(i_args); (i_tmp, i_varDecls) = tempDecl(emptyTxt, "modelica_metatype", i_varDecls); i_preExp = Tpl.writeText(i_preExp, i_tmp); @@ -29307,7 +29359,7 @@ algorithm end matchcontinue; end daeExpMetaOption; -protected function lm_638 +protected function lm_639 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -29344,7 +29396,7 @@ algorithm equation (txt, i_preExp, i_varDecls) = daeExpMetaHelperConstant(txt, i_exp, i_context, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_638(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_639(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); case ( txt, @@ -29355,12 +29407,12 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_638(txt, rest, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_639(txt, rest, i_varDecls, i_preExp, i_context); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_638; +end lm_639; -protected function fun_639 +protected function fun_640 input Tpl.Text in_txt; input list in_i_args; input Tpl.Text in_i_varDecls; @@ -29396,11 +29448,11 @@ algorithm equation txt = Tpl.writeTok(txt, Tpl.ST_STRING(", ")); txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (txt, i_varDecls, i_preExp) = lm_638(txt, i_args, i_varDecls, i_preExp, i_context); + (txt, i_varDecls, i_preExp) = lm_639(txt, i_args, i_varDecls, i_preExp, i_context); txt = Tpl.popIter(txt); then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_639; +end fun_640; public function daeExpMetarecordcall input Tpl.Text in_txt; @@ -29440,7 +29492,7 @@ algorithm equation ret_1 = SimCode.incrementInt(i_index, 3); i_newIndex = Tpl.writeStr(emptyTxt, intString(ret_1)); - (i_argsStr, i_varDecls, i_preExp) = fun_639(emptyTxt, i_args, i_varDecls, i_preExp, i_context); + (i_argsStr, i_varDecls, i_preExp) = fun_640(emptyTxt, i_args, i_varDecls, i_preExp, i_context); i_box = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("mmc_mk_box")); ret_4 = listLength(i_args); ret_5 = SimCode.incrementInt(ret_4, 1); @@ -29488,7 +29540,7 @@ algorithm (out_txt, i_expPart, out_i_preExp, out_i_varDecls) := daeExpMetaHelperConstantNameType(txt, i_expPart, ret_1, out_i_preExp, out_i_varDecls); end daeExpMetaHelperConstant; -protected function lm_642 +protected function lm_643 input Tpl.Text in_txt; input list in_items; input Tpl.Text in_i_varDecls; @@ -29531,7 +29583,7 @@ algorithm i_nameText = Tpl.writeStr(i_nameText, i_cvname); (txt, i_nameText, i_preExp, i_varDecls) = daeExpMetaHelperConstantNameType(txt, i_nameText, i_tp, i_preExp, i_varDecls); txt = Tpl.nextIter(txt); - (txt, i_varDecls, i_preExp) = lm_642(txt, rest, i_varDecls, i_preExp, i_varname); + (txt, i_varDecls, i_preExp) = lm_643(txt, rest, i_varDecls, i_preExp, i_varname); then (txt, i_varDecls, i_preExp); case ( txt, @@ -29542,12 +29594,12 @@ algorithm local list rest; equation - (txt, i_varDecls, i_preExp) = lm_642(txt, rest, i_varDecls, i_preExp, i_varname); + (txt, i_varDecls, i_preExp) = lm_643(txt, rest, i_varDecls, i_preExp, i_varname); then (txt, i_varDecls, i_preExp); end matchcontinue; -end lm_642; +end lm_643; -protected function fun_643 +protected function fun_644 input Tpl.Text in_txt; input list in_i_varLst; input Tpl.Text in_i_varDecls; @@ -29583,13 +29635,13 @@ algorithm equation txt = Tpl.writeTok(txt, Tpl.ST_STRING(", ")); txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - (txt, i_varDecls, i_preExp) = lm_642(txt, i_varLst, i_varDecls, i_preExp, i_varname); + (txt, i_varDecls, i_preExp) = lm_643(txt, i_varLst, i_varDecls, i_preExp, i_varname); txt = Tpl.popIter(txt); then (txt, i_varDecls, i_preExp); end matchcontinue; -end fun_643; +end fun_644; -protected function fun_644 +protected function fun_645 input Tpl.Text in_txt; input DAE.ExpType in_i_type; input Tpl.Text in_i_varname; @@ -29668,7 +29720,7 @@ algorithm ret_1 = listLength(i_varLst); ret_2 = SimCode.incrementInt(ret_1, 1); i_start = daeExpMetaHelperBoxStart(emptyTxt, ret_2); - (i_args, i_varDecls, i_preExp) = fun_643(emptyTxt, i_varLst, i_varDecls, i_preExp, i_varname); + (i_args, i_varDecls, i_preExp) = fun_644(emptyTxt, i_varLst, i_varDecls, i_preExp, i_varname); txt = Tpl.writeTok(txt, Tpl.ST_STRING("mmc_mk_box")); txt = Tpl.writeText(txt, i_start); txt = Tpl.writeTok(txt, Tpl.ST_STRING("2, &")); @@ -29687,7 +29739,7 @@ algorithm txt = Tpl.writeText(txt, i_varname); then (txt, i_preExp, i_varDecls); end matchcontinue; -end fun_644; +end fun_645; public function daeExpMetaHelperConstantNameType input Tpl.Text txt; @@ -29701,7 +29753,7 @@ public function daeExpMetaHelperConstantNameType output Tpl.Text out_i_preExp; output Tpl.Text out_i_varDecls; algorithm - (out_txt, out_i_preExp, out_i_varDecls) := fun_644(txt, i_type, i_varname, i_preExp, i_varDecls); + (out_txt, out_i_preExp, out_i_varDecls) := fun_645(txt, i_type, i_varname, i_preExp, i_varDecls); out_i_varname := i_varname; end daeExpMetaHelperConstantNameType; @@ -29884,7 +29936,7 @@ algorithm out_txt := Tpl.writeText(txt, i_newVar); end tempDeclConst; -protected function fun_650 +protected function fun_651 input Tpl.Text in_txt; input list in_i_instDims; input DAE.ExpType in_i_var_ty; @@ -29911,7 +29963,7 @@ algorithm txt = expTypeArray(txt, i_var_ty); then txt; end matchcontinue; -end fun_650; +end fun_651; public function varType input Tpl.Text in_txt; @@ -29931,7 +29983,7 @@ algorithm list i_instDims; SimCode.Variable i_var; equation - txt = fun_650(txt, i_instDims, i_var_ty); + txt = fun_651(txt, i_instDims, i_var_ty); then txt; case ( txt, @@ -30322,7 +30374,7 @@ algorithm end matchcontinue; end mmcExpTypeShort; -protected function fun_657 +protected function fun_658 input Tpl.Text in_txt; input Boolean in_i_array; input DAE.ExpType in_i_ty; @@ -30354,7 +30406,7 @@ algorithm _ ) then txt; end matchcontinue; -end fun_657; +end fun_658; public function expType input Tpl.Text txt; @@ -30363,7 +30415,7 @@ public function expType output Tpl.Text out_txt; algorithm - out_txt := fun_657(txt, i_array, i_ty); + out_txt := fun_658(txt, i_array, i_ty); end expType; public function expTypeModelica @@ -30429,7 +30481,7 @@ algorithm out_txt := expTypeFromExpFlag(txt, i_exp, 4); end expTypeFromExpArrayIf; -protected function fun_666 +protected function fun_667 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -30458,9 +30510,9 @@ algorithm txt = expTypeShort(txt, i_ty); then txt; end matchcontinue; -end fun_666; +end fun_667; -protected function fun_667 +protected function fun_668 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -30485,12 +30537,12 @@ algorithm local DAE.ExpType i_ty; equation - txt = fun_666(txt, i_ty); + txt = fun_667(txt, i_ty); then txt; end matchcontinue; -end fun_667; +end fun_668; -protected function fun_668 +protected function fun_669 input Tpl.Text in_txt; input DAE.ExpType in_i_ty; @@ -30518,9 +30570,9 @@ algorithm txt = expTypeFlag(txt, i_ty, 2); then txt; end matchcontinue; -end fun_668; +end fun_669; -protected function fun_669 +protected function fun_670 input Tpl.Text in_txt; input Integer in_i_flag; input DAE.ExpType in_i_ty; @@ -30544,7 +30596,7 @@ algorithm 2, i_ty ) equation - txt = fun_667(txt, i_ty); + txt = fun_668(txt, i_ty); then txt; case ( txt, @@ -30559,7 +30611,7 @@ algorithm 4, i_ty ) equation - txt = fun_668(txt, i_ty); + txt = fun_669(txt, i_ty); then txt; case ( txt, @@ -30567,7 +30619,7 @@ algorithm _ ) then txt; end matchcontinue; -end fun_669; +end fun_670; public function expTypeFlag input Tpl.Text txt; @@ -30576,10 +30628,10 @@ public function expTypeFlag output Tpl.Text out_txt; algorithm - out_txt := fun_669(txt, i_flag, i_ty); + out_txt := fun_670(txt, i_flag, i_ty); end expTypeFlag; -protected function fun_671 +protected function fun_672 input Tpl.Text in_txt; input Integer in_i_flag; @@ -30602,9 +30654,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("modelica_integer")); then txt; end matchcontinue; -end fun_671; +end fun_672; -protected function fun_672 +protected function fun_673 input Tpl.Text in_txt; input Integer in_i_flag; @@ -30627,9 +30679,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("modelica_real")); then txt; end matchcontinue; -end fun_672; +end fun_673; -protected function fun_673 +protected function fun_674 input Tpl.Text in_txt; input Integer in_i_flag; @@ -30652,9 +30704,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("modelica_string")); then txt; end matchcontinue; -end fun_673; +end fun_674; -protected function fun_674 +protected function fun_675 input Tpl.Text in_txt; input Integer in_i_flag; @@ -30677,7 +30729,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean")); then txt; end matchcontinue; -end fun_674; +end fun_675; public function expTypeFromExpFlag input Tpl.Text in_txt; @@ -30696,28 +30748,28 @@ algorithm DAE.ICONST(integer = _), i_flag ) equation - txt = fun_671(txt, i_flag); + txt = fun_672(txt, i_flag); then txt; case ( txt, DAE.RCONST(real = _), i_flag ) equation - txt = fun_672(txt, i_flag); + txt = fun_673(txt, i_flag); then txt; case ( txt, DAE.SCONST(string = _), i_flag ) equation - txt = fun_673(txt, i_flag); + txt = fun_674(txt, i_flag); then txt; case ( txt, DAE.BCONST(bool = _), i_flag ) equation - txt = fun_674(txt, i_flag); + txt = fun_675(txt, i_flag); then txt; case ( txt, @@ -30875,7 +30927,7 @@ algorithm end matchcontinue; end expTypeFromExpFlag; -protected function fun_676 +protected function fun_677 input Tpl.Text in_txt; input Integer in_i_flag; @@ -30898,9 +30950,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean")); then txt; end matchcontinue; -end fun_676; +end fun_677; -protected function fun_677 +protected function fun_678 input Tpl.Text in_txt; input Integer in_i_flag; @@ -30923,9 +30975,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean")); then txt; end matchcontinue; -end fun_677; +end fun_678; -protected function fun_678 +protected function fun_679 input Tpl.Text in_txt; input Integer in_i_flag; @@ -30948,7 +31000,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean")); then txt; end matchcontinue; -end fun_678; +end fun_679; public function expTypeFromOpFlag input Tpl.Text in_txt; @@ -31299,7 +31351,7 @@ algorithm local DAE.Operator i_o; equation - txt = fun_676(txt, i_flag); + txt = fun_677(txt, i_flag); then txt; case ( txt, @@ -31308,7 +31360,7 @@ algorithm local DAE.Operator i_o; equation - txt = fun_677(txt, i_flag); + txt = fun_678(txt, i_flag); then txt; case ( txt, @@ -31317,7 +31369,7 @@ algorithm local DAE.Operator i_o; equation - txt = fun_678(txt, i_flag); + txt = fun_679(txt, i_flag); then txt; case ( txt, diff --git a/Compiler/SimCodeCSharp.mo b/Compiler/SimCodeCSharp.mo index fad6cd49c62..ae1c604ad5f 100644 --- a/Compiler/SimCodeCSharp.mo +++ b/Compiler/SimCodeCSharp.mo @@ -6139,11 +6139,11 @@ algorithm then txt; case ( txt, - DAE.STMT_FOR(exp = (i_rng as DAE.RANGE(ty = _)), type_ = i_type__, iterIsArray = i_iterIsArray, statementLst = i_statementLst, ident = i_ident), + DAE.STMT_FOR(range = (i_rng as DAE.RANGE(ty = _)), type_ = i_type__, iterIsArray = i_iterIsArray, statementLst = i_statementLst, iter = i_iter), i_context, i_simCode ) local - DAE.Ident i_ident; + DAE.Ident i_iter; list i_statementLst; Boolean i_iterIsArray; DAE.ExpType i_type__; @@ -6157,7 +6157,7 @@ algorithm i_stmtStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); i_stmtStr = lm_150(i_stmtStr, i_statementLst, i_simCode, i_context); i_stmtStr = Tpl.popIter(i_stmtStr); - (txt, i_stmtStr) = algStmtForRange_impl(txt, i_rng, i_ident, Tpl.textString(i_identType), Tpl.textString(i_identTypeShort), i_stmtStr, i_context, i_simCode); + (txt, i_stmtStr) = algStmtForRange_impl(txt, i_rng, i_iter, Tpl.textString(i_identType), Tpl.textString(i_identTypeShort), i_stmtStr, i_context, i_simCode); then txt; case ( txt, diff --git a/Compiler/SimCodeFMU.mo b/Compiler/SimCodeFMU.mo index 42af5af3e41..29ed1b951f3 100644 --- a/Compiler/SimCodeFMU.mo +++ b/Compiler/SimCodeFMU.mo @@ -1,2296 +1,2296 @@ -package SimCodeFMU - -protected constant Tpl.Text emptyTxt = Tpl.MEM_TEXT({}, {}); - -public import Tpl; - -public import SimCode; -public import BackendDAE; -public import System; -public import Absyn; -public import DAE; -public import ClassInf; -public import Util; -public import ComponentReference; -public import Expression; -public import RTOpts; -public import Settings; -public import SimCodeC; - -public function translateModel - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode) - local - Tpl.Text txt; - - case ( txt, - (i_simCode as SimCode.SIMCODE(fileNamePrefix = i_fileNamePrefix)) ) - local - String i_fileNamePrefix; - SimCode.SimCode i_simCode; - Tpl.Text txt_6; - Tpl.Text txt_5; - Tpl.Text txt_4; - Tpl.Text txt_3; - Tpl.Text txt_2; - String ret_1; - Tpl.Text i_guid; - equation - ret_1 = System.getUUIDStr(); - i_guid = Tpl.writeStr(emptyTxt, ret_1); - txt_2 = fmuModelDescriptionFile(emptyTxt, i_simCode, Tpl.textString(i_guid)); - Tpl.textFile(txt_2, "modelDescription.xml"); - txt_3 = fmumodel_identifierFile(emptyTxt, i_simCode, Tpl.textString(i_guid)); - txt_4 = Tpl.writeStr(emptyTxt, i_fileNamePrefix); - txt_4 = Tpl.writeTok(txt_4, Tpl.ST_STRING("_FMU.cpp")); - Tpl.textFile(txt_3, Tpl.textString(txt_4)); - txt_5 = fmuMakefile(emptyTxt, i_simCode); - txt_6 = Tpl.writeStr(emptyTxt, i_fileNamePrefix); - txt_6 = Tpl.writeTok(txt_6, Tpl.ST_STRING("_FMU.makefile")); - Tpl.textFile(txt_5, Tpl.textString(txt_6)); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end translateModel; - -public function fmuModelDescriptionFile - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - input String in_i_guid; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode, in_i_guid) - local - Tpl.Text txt; - String i_guid; - - case ( txt, - (i_simCode as SimCode.SIMCODE(modelInfo = _)), - i_guid ) - local - SimCode.SimCode i_simCode; - equation - txt = Tpl.writeTok(txt, Tpl.ST_LINE("\n")); - txt = fmiModelDescription(txt, i_simCode, i_guid); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); - then txt; - - case ( txt, - _, - _ ) - then txt; - end matchcontinue; -end fmuModelDescriptionFile; - -public function fmiModelDescription - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - input String in_i_guid; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode, in_i_guid) - local - Tpl.Text txt; - String i_guid; - - case ( txt, - (i_simCode as SimCode.SIMCODE(simulationSettingsOpt = i_simulationSettingsOpt, modelInfo = i_modelInfo)), - i_guid ) - local - SimCode.ModelInfo i_modelInfo; - Option i_simulationSettingsOpt; - SimCode.SimCode i_simCode; - equation - txt = Tpl.writeTok(txt, Tpl.ST_LINE("\n")); - txt = DefaultExperiment(txt, i_simulationSettingsOpt); - txt = Tpl.softNewLine(txt); - txt = ModelVariables(txt, i_modelInfo); - txt = Tpl.softNewLine(txt); - txt = Tpl.popBlock(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - _, - _ ) - then txt; - end matchcontinue; -end fmiModelDescription; - -public function fmiModelDescriptionAttributes - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - input String in_i_guid; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode, in_i_guid) - local - Tpl.Text txt; - String i_guid; - - case ( txt, - SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(varInfo = (i_vi as SimCode.VARINFO(numStateVars = i_vi_numStateVars, numZeroCrossings = i_vi_numZeroCrossings)), name = i_modelInfo_name), fileNamePrefix = i_fileNamePrefix), - i_guid ) - local - String i_fileNamePrefix; - Absyn.Path i_modelInfo_name; - Integer i_vi_numZeroCrossings; - Integer i_vi_numStateVars; - SimCode.VarInfo i_vi; - Tpl.Text i_numberOfEventIndicators; - Tpl.Text i_numberOfContinuousStates; - Tpl.Text i_variableNamingConvention; - Util.DateTime ret_9; - Tpl.Text i_generationDateAndTime; - String ret_7; - Tpl.Text i_generationTool; - Tpl.Text i_version; - Tpl.Text i_author; - Tpl.Text i_description; - Tpl.Text i_modelIdentifier; - Tpl.Text i_modelName; - Tpl.Text i_fmiVersion; - equation - i_fmiVersion = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("1.0")); - i_modelName = SimCodeC.dotPath(emptyTxt, i_modelInfo_name); - i_modelIdentifier = Tpl.writeStr(emptyTxt, i_fileNamePrefix); - i_description = emptyTxt; - i_author = emptyTxt; - i_version = emptyTxt; - i_generationTool = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("OpenModelica Compiler ")); - ret_7 = Settings.getVersionNr(); - i_generationTool = Tpl.writeStr(i_generationTool, ret_7); - ret_9 = Util.getCurrentDateTime(); - i_generationDateAndTime = xsdateTime(emptyTxt, ret_9); - i_variableNamingConvention = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("structured")); - i_numberOfContinuousStates = Tpl.writeStr(emptyTxt, intString(i_vi_numStateVars)); - i_numberOfEventIndicators = Tpl.writeStr(emptyTxt, intString(i_vi_numZeroCrossings)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("fmiVersion=\"")); - txt = Tpl.writeText(txt, i_fmiVersion); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "modelName=\"" - }, false)); - txt = Tpl.writeText(txt, i_modelName); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "modelIdentifier=\"" - }, false)); - txt = Tpl.writeText(txt, i_modelIdentifier); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "guid=\"{" - }, false)); - txt = Tpl.writeStr(txt, i_guid); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "}\"\n", - "generationTool=\"" - }, false)); - txt = Tpl.writeText(txt, i_generationTool); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "generationDateAndTime=\"" - }, false)); - txt = Tpl.writeText(txt, i_generationDateAndTime); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "variableNamingConvention=\"" - }, false)); - txt = Tpl.writeText(txt, i_variableNamingConvention); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "numberOfContinuousStates=\"" - }, false)); - txt = Tpl.writeText(txt, i_numberOfContinuousStates); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "numberOfEventIndicators=\"" - }, false)); - txt = Tpl.writeText(txt, i_numberOfEventIndicators); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); - then txt; - - case ( txt, - _, - _ ) - then txt; - end matchcontinue; -end fmiModelDescriptionAttributes; - -public function xsdateTime - input Tpl.Text in_txt; - input Util.DateTime in_i_dt; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_dt) - local - Tpl.Text txt; - - case ( txt, - Util.DATETIME(year = i_year, mon = i_mon, mday = i_mday, hour = i_hour, min = i_min, sec = i_sec) ) - local - Integer i_sec; - Integer i_min; - Integer i_hour; - Integer i_mday; - Integer i_mon; - Integer i_year; - equation - txt = Tpl.writeStr(txt, intString(i_year)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("-")); - txt = Tpl.writeStr(txt, intString(i_mon)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("-")); - txt = Tpl.writeStr(txt, intString(i_mday)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("T")); - txt = Tpl.writeStr(txt, intString(i_hour)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING(":")); - txt = Tpl.writeStr(txt, intString(i_min)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING(":")); - txt = Tpl.writeStr(txt, intString(i_sec)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("Z")); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end xsdateTime; - -public function UnitDefinitions - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMCODE(modelInfo = _) ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\n", - "" - }, false)); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end UnitDefinitions; - -public function TypeDefinitions - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMCODE(modelInfo = _) ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\n", - "" - }, false)); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end TypeDefinitions; - -public function DefaultExperiment - input Tpl.Text in_txt; - input Option in_i_simulationSettingsOpt; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simulationSettingsOpt) - local - Tpl.Text txt; - - case ( txt, - SOME(i_v) ) - local - SimCode.SimulationSettings i_v; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end DefaultExperiment; - -public function DefaultExperimentAttribute - input Tpl.Text in_txt; - input SimCode.SimulationSettings in_i_simulationSettings; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simulationSettings) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMULATION_SETTINGS(startTime = i_startTime, stopTime = i_stopTime, tolerance = i_tolerance) ) - local - Real i_tolerance; - Real i_stopTime; - Real i_startTime; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("startTime=\"")); - txt = Tpl.writeStr(txt, realString(i_startTime)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\" stopTime=\"")); - txt = Tpl.writeStr(txt, realString(i_stopTime)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\" tolerance=\"")); - txt = Tpl.writeStr(txt, realString(i_tolerance)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end DefaultExperimentAttribute; - -public function VendorAnnotations - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMCODE(modelInfo = _) ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\n", - "" - }, false)); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end VendorAnnotations; - -protected function lm_24 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 0); - txt = Tpl.nextIter(txt); - txt = lm_24(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_24(txt, rest); - then txt; - end matchcontinue; -end lm_24; - -protected function lm_25 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 10000); - txt = Tpl.nextIter(txt); - txt = lm_25(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_25(txt, rest); - then txt; - end matchcontinue; -end lm_25; - -protected function lm_26 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "input", 100000); - txt = Tpl.nextIter(txt); - txt = lm_26(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_26(txt, rest); - then txt; - end matchcontinue; -end lm_26; - -protected function lm_27 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "output", 200000); - txt = Tpl.nextIter(txt); - txt = lm_27(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_27(txt, rest); - then txt; - end matchcontinue; -end lm_27; - -protected function lm_28 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 1000000); - txt = Tpl.nextIter(txt); - txt = lm_28(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_28(txt, rest); - then txt; - end matchcontinue; -end lm_28; - -protected function lm_29 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 5000000); - txt = Tpl.nextIter(txt); - txt = lm_29(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_29(txt, rest); - then txt; - end matchcontinue; -end lm_29; - -protected function lm_30 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 0); - txt = Tpl.nextIter(txt); - txt = lm_30(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_30(txt, rest); - then txt; - end matchcontinue; -end lm_30; - -protected function lm_31 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 1000000); - txt = Tpl.nextIter(txt); - txt = lm_31(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_31(txt, rest); - then txt; - end matchcontinue; -end lm_31; - -protected function lm_32 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 0); - txt = Tpl.nextIter(txt); - txt = lm_32(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_32(txt, rest); - then txt; - end matchcontinue; -end lm_32; - -protected function lm_33 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 1000000); - txt = Tpl.nextIter(txt); - txt = lm_33(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_33(txt, rest); - then txt; - end matchcontinue; -end lm_33; - -protected function lm_34 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 0); - txt = Tpl.nextIter(txt); - txt = lm_34(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_34(txt, rest); - then txt; - end matchcontinue; -end lm_34; - -protected function lm_35 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = ScalarVariable(txt, i_var, "internal", 1000000); - txt = Tpl.nextIter(txt); - txt = lm_35(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_35(txt, rest); - then txt; - end matchcontinue; -end lm_35; - -public function ModelVariables - input Tpl.Text in_txt; - input SimCode.ModelInfo in_i_modelInfo; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_modelInfo) - local - Tpl.Text txt; - - case ( txt, - SimCode.MODELINFO(vars = SimCode.SIMVARS(stateVars = i_vars_stateVars, derivativeVars = i_vars_derivativeVars, inputVars = i_vars_inputVars, outputVars = i_vars_outputVars, algVars = i_vars_algVars, paramVars = i_vars_paramVars, intAlgVars = i_vars_intAlgVars, intParamVars = i_vars_intParamVars, boolAlgVars = i_vars_boolAlgVars, boolParamVars = i_vars_boolParamVars, stringAlgVars = i_vars_stringAlgVars, stringParamVars = i_vars_stringParamVars)) ) - local - list i_vars_stringParamVars; - list i_vars_stringAlgVars; - list i_vars_boolParamVars; - list i_vars_boolAlgVars; - list i_vars_intParamVars; - list i_vars_intAlgVars; - list i_vars_paramVars; - list i_vars_algVars; - list i_vars_outputVars; - list i_vars_inputVars; - list i_vars_derivativeVars; - list i_vars_stateVars; - equation - txt = Tpl.writeTok(txt, Tpl.ST_LINE("\n")); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_24(txt, i_vars_stateVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_25(txt, i_vars_derivativeVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_26(txt, i_vars_inputVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_27(txt, i_vars_outputVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_28(txt, i_vars_algVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_29(txt, i_vars_paramVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_30(txt, i_vars_intAlgVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_31(txt, i_vars_intParamVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_32(txt, i_vars_boolAlgVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_33(txt, i_vars_boolParamVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_34(txt, i_vars_stringAlgVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_35(txt, i_vars_stringParamVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end ModelVariables; - -public function ScalarVariable - input Tpl.Text in_txt; - input SimCode.SimVar in_i_simVar; - input String in_i_causality; - input Integer in_i_offset; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simVar, in_i_causality, in_i_offset) - local - Tpl.Text txt; - String i_causality; - Integer i_offset; - - case ( txt, - (i_simVar as SimCode.SIMVAR(type_ = i_type__, unit = i_unit, displayUnit = i_displayUnit, initialValue = i_initialValue, isFixed = i_isFixed)), - i_causality, - i_offset ) - local - Boolean i_isFixed; - Option i_initialValue; - String i_displayUnit; - String i_unit; - DAE.ExpType i_type__; - SimCode.SimVar i_simVar; - equation - txt = Tpl.writeTok(txt, Tpl.ST_LINE("\n")); - txt = ScalarVariableType(txt, i_type__, i_unit, i_displayUnit, i_initialValue, i_isFixed); - txt = Tpl.softNewLine(txt); - txt = Tpl.popBlock(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - _, - _, - _ ) - then txt; - end matchcontinue; -end ScalarVariable; - -protected function fun_38 - input Tpl.Text in_txt; - input String in_i_comment; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_comment) - local - Tpl.Text txt; - - case ( txt, - "" ) - then txt; - - case ( txt, - i_comment ) - local - String i_comment; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("description=\"")); - txt = Tpl.writeStr(txt, i_comment); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); - then txt; - end matchcontinue; -end fun_38; - -public function ScalarVariableAttribute - input Tpl.Text in_txt; - input SimCode.SimVar in_i_simVar; - input String in_i_causality; - input Integer in_i_offset; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simVar, in_i_causality, in_i_offset) - local - Tpl.Text txt; - String i_causality; - Integer i_offset; - - case ( txt, - SimCode.SIMVAR(index = i_index, varKind = i_varKind, comment = i_comment, name = i_name), - i_causality, - i_offset ) - local - DAE.ComponentRef i_name; - String i_comment; - BackendDAE.VarKind i_varKind; - Integer i_index; - Tpl.Text i_alias; - Tpl.Text i_description; - Tpl.Text i_variability; - Integer ret_1; - Tpl.Text i_valueReference; - equation - ret_1 = intAdd(i_index, i_offset); - i_valueReference = Tpl.writeStr(emptyTxt, intString(ret_1)); - i_variability = getVariablity(emptyTxt, i_varKind); - i_description = fun_38(emptyTxt, i_comment); - i_alias = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("noAlias")); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("name=\"")); - txt = SimCodeC.crefStr(txt, i_name); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "valueReference=\"" - }, false)); - txt = Tpl.writeText(txt, i_valueReference); - txt = Tpl.writeTok(txt, Tpl.ST_LINE("\"\n")); - txt = Tpl.writeText(txt, i_description); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("variability=\"")); - txt = Tpl.writeText(txt, i_variability); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "causality=\"" - }, false)); - txt = Tpl.writeStr(txt, i_causality); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "alias=\"" - }, false)); - txt = Tpl.writeText(txt, i_alias); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); - then txt; - - case ( txt, - _, - _, - _ ) - then txt; - end matchcontinue; -end ScalarVariableAttribute; - -public function getVariablity - input Tpl.Text in_txt; - input BackendDAE.VarKind in_i_varKind; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_varKind) - local - Tpl.Text txt; - - case ( txt, - BackendDAE.DISCRETE() ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("discrete")); - then txt; - - case ( txt, - BackendDAE.PARAM() ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("parameter")); - then txt; - - case ( txt, - BackendDAE.CONST() ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("constant")); - then txt; - - case ( txt, - _ ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("continuous")); - then txt; - end matchcontinue; -end getVariablity; - -public function ScalarVariableType - input Tpl.Text in_txt; - input DAE.ExpType in_i_type__; - input String in_i_unit; - input String in_i_displayUnit; - input Option in_i_initialValue; - input Boolean in_i_isFixed; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_type__, in_i_unit, in_i_displayUnit, in_i_initialValue, in_i_isFixed) - local - Tpl.Text txt; - String i_unit; - String i_displayUnit; - Option i_initialValue; - Boolean i_isFixed; - - case ( txt, - DAE.ET_INT(), - _, - _, - _, - _ ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - DAE.ET_REAL(), - i_unit, - i_displayUnit, - i_initialValue, - i_isFixed ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - DAE.ET_BOOL(), - _, - _, - _, - _ ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - DAE.ET_STRING(), - _, - _, - _, - _ ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - DAE.ET_ENUMERATION(path = _), - _, - _, - _, - _ ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); - then txt; - - case ( txt, - _, - _, - _, - _, - _ ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("UNKOWN_TYPE")); - then txt; - end matchcontinue; -end ScalarVariableType; - -public function ScalarVariableTypeCommonAttribute - input Tpl.Text in_txt; - input Option in_i_initialValue; - input Boolean in_i_isFixed; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_initialValue, in_i_isFixed) - local - Tpl.Text txt; - Boolean i_isFixed; - - case ( txt, - SOME(i_exp), - i_isFixed ) - local - DAE.Exp i_exp; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("start=\"")); - txt = SimCodeC.initVal(txt, i_exp); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\" fixed=\"")); - txt = Tpl.writeStr(txt, Tpl.booleanString(i_isFixed)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); - then txt; - - case ( txt, - _, - _ ) - then txt; - end matchcontinue; -end ScalarVariableTypeCommonAttribute; - -protected function fun_43 - input Tpl.Text in_txt; - input String in_i_unit; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_unit) - local - Tpl.Text txt; - - case ( txt, - "" ) - then txt; - - case ( txt, - i_unit ) - local - String i_unit; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("unit=\"")); - txt = Tpl.writeStr(txt, i_unit); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); - then txt; - end matchcontinue; -end fun_43; - -protected function fun_44 - input Tpl.Text in_txt; - input String in_i_displayUnit; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_displayUnit) - local - Tpl.Text txt; - - case ( txt, - "" ) - then txt; - - case ( txt, - i_displayUnit ) - local - String i_displayUnit; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("displayUnit=\"")); - txt = Tpl.writeStr(txt, i_displayUnit); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); - then txt; - end matchcontinue; -end fun_44; - -public function ScalarVariableTypeRealAttribute - input Tpl.Text txt; - input String i_unit; - input String i_displayUnit; - - output Tpl.Text out_txt; -protected - Tpl.Text i_displayUnit__; - Tpl.Text i_unit__; -algorithm - i_unit__ := fun_43(emptyTxt, i_unit); - i_displayUnit__ := fun_44(emptyTxt, i_displayUnit); - out_txt := Tpl.writeText(txt, i_unit__); - out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" ")); - out_txt := Tpl.writeText(out_txt, i_displayUnit__); -end ScalarVariableTypeRealAttribute; - -public function fmumodel_identifierFile - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - input String in_i_guid; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode, in_i_guid) - local - Tpl.Text txt; - String i_guid; - - case ( txt, - (i_simCode as SimCode.SIMCODE(fileNamePrefix = i_fileNamePrefix, modelInfo = i_modelInfo)), - i_guid ) - local - SimCode.ModelInfo i_modelInfo; - String i_fileNamePrefix; - SimCode.SimCode i_simCode; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\n", - "// define class name and unique id\n", - "#define MODEL_IDENTIFIER " - }, false)); - txt = Tpl.writeStr(txt, i_fileNamePrefix); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define MODEL_GUID \"")); - txt = Tpl.writeStr(txt, i_guid); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\"\n", - "\n", - "// include fmu header files, typedefs and macros\n", - "#include \"fmiModelFunctions.h\"\n", - "\n", - "// implementation of the Model Exchange functions\n", - "#include \"fmu_model_interface.c\"\n", - "\n" - }, true)); - txt = ModelDefineData(txt, i_modelInfo); - txt = Tpl.softNewLine(txt); - txt = setStartValues(txt, i_simCode); - txt = Tpl.softNewLine(txt); - txt = initializeFunction(txt, i_simCode); - txt = Tpl.softNewLine(txt); - txt = eventUpdateFunction(txt, i_simCode); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); - then txt; - - case ( txt, - _, - _ ) - then txt; - end matchcontinue; -end fmumodel_identifierFile; - -protected function lm_47 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineStateVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_47(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_47(txt, rest); - then txt; - end matchcontinue; -end lm_47; - -protected function lm_48 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_48(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_48(txt, rest); - then txt; - end matchcontinue; -end lm_48; - -protected function lm_49 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_49(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_49(txt, rest); - then txt; - end matchcontinue; -end lm_49; - -protected function lm_50 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_50(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_50(txt, rest); - then txt; - end matchcontinue; -end lm_50; - -protected function lm_51 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_51(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_51(txt, rest); - then txt; - end matchcontinue; -end lm_51; - -protected function lm_52 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_52(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_52(txt, rest); - then txt; - end matchcontinue; -end lm_52; - -protected function lm_53 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_53(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_53(txt, rest); - then txt; - end matchcontinue; -end lm_53; - -protected function lm_54 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_54(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_54(txt, rest); - then txt; - end matchcontinue; -end lm_54; - -protected function lm_55 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_55(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_55(txt, rest); - then txt; - end matchcontinue; -end lm_55; - -protected function lm_56 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_56(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_56(txt, rest); - then txt; - end matchcontinue; -end lm_56; - -protected function lm_57 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_var :: rest ) - local - list rest; - SimCode.SimVar i_var; - equation - txt = DefineVariables(txt, i_var); - txt = Tpl.nextIter(txt); - txt = lm_57(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_57(txt, rest); - then txt; - end matchcontinue; -end lm_57; - -protected function lm_58 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - SimCode.SIMVAR(name = i_name) :: rest ) - local - list rest; - DAE.ComponentRef i_name; - equation - txt = SimCodeC.crefStr(txt, i_name); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("_")); - txt = Tpl.nextIter(txt); - txt = lm_58(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_58(txt, rest); - then txt; - end matchcontinue; -end lm_58; - -public function ModelDefineData - input Tpl.Text in_txt; - input SimCode.ModelInfo in_i_modelInfo; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_modelInfo) - local - Tpl.Text txt; - - case ( txt, - SimCode.MODELINFO(varInfo = SimCode.VARINFO(numStateVars = i_varInfo_numStateVars, numAlgVars = i_varInfo_numAlgVars, numParams = i_varInfo_numParams, numIntAlgVars = i_varInfo_numIntAlgVars, numIntParams = i_varInfo_numIntParams, numStringAlgVars = i_varInfo_numStringAlgVars, numStringParamVars = i_varInfo_numStringParamVars, numBoolAlgVars = i_varInfo_numBoolAlgVars, numBoolParams = i_varInfo_numBoolParams, numZeroCrossings = i_varInfo_numZeroCrossings), vars = SimCode.SIMVARS(stateVars = i_vars_stateVars, inputVars = i_vars_inputVars, outputVars = i_vars_outputVars, algVars = i_vars_algVars, paramVars = i_vars_paramVars, intAlgVars = i_vars_intAlgVars, intParamVars = i_vars_intParamVars, boolAlgVars = i_vars_boolAlgVars, boolParamVars = i_vars_boolParamVars, stringAlgVars = i_vars_stringAlgVars, stringParamVars = i_vars_stringParamVars)) ) - local - list i_vars_stringParamVars; - list i_vars_stringAlgVars; - list i_vars_boolParamVars; - list i_vars_boolAlgVars; - list i_vars_intParamVars; - list i_vars_intAlgVars; - list i_vars_paramVars; - list i_vars_algVars; - list i_vars_outputVars; - list i_vars_inputVars; - list i_vars_stateVars; - Integer i_varInfo_numZeroCrossings; - Integer i_varInfo_numBoolParams; - Integer i_varInfo_numBoolAlgVars; - Integer i_varInfo_numStringParamVars; - Integer i_varInfo_numStringAlgVars; - Integer i_varInfo_numIntParams; - Integer i_varInfo_numIntAlgVars; - Integer i_varInfo_numParams; - Integer i_varInfo_numAlgVars; - Integer i_varInfo_numStateVars; - Integer ret_8; - Tpl.Text i_numberOfBooleans; - Integer ret_6; - Tpl.Text i_numberOfStrings; - Integer ret_4; - Tpl.Text i_numberOfIntegers; - Integer ret_2; - Integer ret_1; - Tpl.Text i_numberOfReals; - equation - ret_1 = intAdd(i_varInfo_numAlgVars, i_varInfo_numParams); - ret_2 = intAdd(i_varInfo_numStateVars, ret_1); - i_numberOfReals = Tpl.writeStr(emptyTxt, intString(ret_2)); - ret_4 = intAdd(i_varInfo_numIntAlgVars, i_varInfo_numIntParams); - i_numberOfIntegers = Tpl.writeStr(emptyTxt, intString(ret_4)); - ret_6 = intAdd(i_varInfo_numStringAlgVars, i_varInfo_numStringParamVars); - i_numberOfStrings = Tpl.writeStr(emptyTxt, intString(ret_6)); - ret_8 = intAdd(i_varInfo_numBoolAlgVars, i_varInfo_numBoolParams); - i_numberOfBooleans = Tpl.writeStr(emptyTxt, intString(ret_8)); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "// define model size\n", - "#define NUMBER_OF_STATES " - }, false)); - txt = Tpl.writeStr(txt, intString(i_varInfo_numStateVars)); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_EVENT_INDICATORS ")); - txt = Tpl.writeStr(txt, intString(i_varInfo_numZeroCrossings)); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_REALS ")); - txt = Tpl.writeText(txt, i_numberOfReals); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_INTEGERS ")); - txt = Tpl.writeText(txt, i_numberOfIntegers); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_STRINGS ")); - txt = Tpl.writeText(txt, i_numberOfStrings); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_BOOLEANS ")); - txt = Tpl.writeText(txt, i_numberOfBooleans); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\n", - "// define variable data for model\n" - }, true)); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_47(txt, i_vars_stateVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_48(txt, i_vars_inputVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_49(txt, i_vars_outputVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_50(txt, i_vars_algVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_51(txt, i_vars_paramVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_52(txt, i_vars_intAlgVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_53(txt, i_vars_intParamVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_54(txt, i_vars_boolAlgVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_55(txt, i_vars_boolParamVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_56(txt, i_vars_stringAlgVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_57(txt, i_vars_stringParamVars); - txt = Tpl.popIter(txt); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\n", - "// define initial state vector as vector of value references\n", - "#define STATES { " - }, false)); - txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - txt = lm_58(txt, i_vars_stateVars); - txt = Tpl.popIter(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - " }\n", - "\n" - }, true)); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end ModelDefineData; - -public function DefineStateVariables - input Tpl.Text in_txt; - input SimCode.SimVar in_i_simVar; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simVar) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMVAR(name = i_name) ) - local - DAE.ComponentRef i_name; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define ")); - txt = SimCodeC.crefStr(txt, i_name); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "_\n", - "#define der_" - }, false)); - txt = SimCodeC.crefStr(txt, i_name); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("_")); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end DefineStateVariables; - -public function DefineVariables - input Tpl.Text in_txt; - input SimCode.SimVar in_i_simVar; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simVar) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMVAR(name = i_name) ) - local - DAE.ComponentRef i_name; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define ")); - txt = SimCodeC.crefStr(txt, i_name); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("_")); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end DefineVariables; - -public function setStartValues - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMCODE(modelInfo = _) ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "// Set values for all variables that define a start value\n", - "void setStartValues(ModelInstance *comp) {\n", - "}\n", - "\n" - }, true)); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end setStartValues; - -public function initializeFunction - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMCODE(modelInfo = _) ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "// Used to set the first time event, if any.\n", - "void initialize(ModelInstance* comp, fmiEventInfo* eventInfo) {\n", - "}\n", - "\n" - }, true)); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end initializeFunction; - -public function eventUpdateFunction - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMCODE(modelInfo = _) ) - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "// Used to set the next time event, if any.\n", - "void eventUpdate(ModelInstance* comp, fmiEventInfo* eventInfo) {\n", - "}\n", - "\n" - }, true)); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end eventUpdateFunction; - -protected function fun_65 - input Tpl.Text in_txt; - input String in_i_modelInfo_directory; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_modelInfo_directory) - local - Tpl.Text txt; - - case ( txt, - "" ) - then txt; - - case ( txt, - i_modelInfo_directory ) - local - String i_modelInfo_directory; - equation - txt = Tpl.writeTok(txt, Tpl.ST_STRING("-L\"")); - txt = Tpl.writeStr(txt, i_modelInfo_directory); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); - then txt; - end matchcontinue; -end fun_65; - -protected function lm_66 - input Tpl.Text in_txt; - input list in_items; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_items) - local - Tpl.Text txt; - - case ( txt, - {} ) - then txt; - - case ( txt, - i_lib :: rest ) - local - list rest; - String i_lib; - equation - txt = Tpl.writeStr(txt, i_lib); - txt = Tpl.nextIter(txt); - txt = lm_66(txt, rest); - then txt; - - case ( txt, - _ :: rest ) - local - list rest; - equation - txt = lm_66(txt, rest); - then txt; - end matchcontinue; -end lm_66; - -protected function fun_67 - input Tpl.Text in_txt; - input String in_it; - input Tpl.Text in_i_libsStr; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_it, in_i_libsStr) - local - Tpl.Text txt; - Tpl.Text i_libsStr; - - case ( txt, - "", - i_libsStr ) - equation - txt = Tpl.writeText(txt, i_libsStr); - then txt; - - case ( txt, - _, - _ ) - then txt; - end matchcontinue; -end fun_67; - -protected function fun_68 - input Tpl.Text in_txt; - input String in_it; - input Tpl.Text in_i_libsStr; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_it, in_i_libsStr) - local - Tpl.Text txt; - Tpl.Text i_libsStr; - - case ( txt, - "", - _ ) - then txt; - - case ( txt, - _, - i_libsStr ) - equation - txt = Tpl.writeText(txt, i_libsStr); - then txt; - end matchcontinue; -end fun_68; - -public function fmuMakefile - input Tpl.Text in_txt; - input SimCode.SimCode in_i_simCode; - - output Tpl.Text out_txt; -algorithm - out_txt := - matchcontinue(in_txt, in_i_simCode) - local - Tpl.Text txt; - - case ( txt, - SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(directory = i_modelInfo_directory), makefileParams = SimCode.MAKEFILE_PARAMS(libs = i_makefileParams_libs, ccompiler = i_makefileParams_ccompiler, cxxcompiler = i_makefileParams_cxxcompiler, linker = i_makefileParams_linker, exeext = i_makefileParams_exeext, dllext = i_makefileParams_dllext, omhome = i_makefileParams_omhome, cflags = i_makefileParams_cflags, ldflags = i_makefileParams_ldflags, senddatalibs = i_makefileParams_senddatalibs), fileNamePrefix = i_fileNamePrefix) ) - local - String i_fileNamePrefix; - String i_makefileParams_senddatalibs; - String i_makefileParams_ldflags; - String i_makefileParams_cflags; - String i_makefileParams_omhome; - String i_makefileParams_dllext; - String i_makefileParams_exeext; - String i_makefileParams_linker; - String i_makefileParams_cxxcompiler; - String i_makefileParams_ccompiler; - list i_makefileParams_libs; - String i_modelInfo_directory; - String str_5; - Tpl.Text i_libsPos2; - String str_3; - Tpl.Text i_libsPos1; - Tpl.Text i_libsStr; - Tpl.Text i_dirExtra; - equation - i_dirExtra = fun_65(emptyTxt, i_modelInfo_directory); - i_libsStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(" ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - i_libsStr = lm_66(i_libsStr, i_makefileParams_libs); - i_libsStr = Tpl.popIter(i_libsStr); - str_3 = Tpl.textString(i_dirExtra); - i_libsPos1 = fun_67(emptyTxt, str_3, i_libsStr); - str_5 = Tpl.textString(i_dirExtra); - i_libsPos2 = fun_68(emptyTxt, str_5, i_libsStr); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "# Makefile generated by OpenModelica\n", - "\n", - "CC=" - }, false)); - txt = Tpl.writeStr(txt, i_makefileParams_ccompiler); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("CXX=")); - txt = Tpl.writeStr(txt, i_makefileParams_cxxcompiler); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("LINK=")); - txt = Tpl.writeStr(txt, i_makefileParams_linker); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("EXEEXT=")); - txt = Tpl.writeStr(txt, i_makefileParams_exeext); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("DLLEXT=")); - txt = Tpl.writeStr(txt, i_makefileParams_dllext); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("CFLAGS=-I\"")); - txt = Tpl.writeStr(txt, i_makefileParams_omhome); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("/include/omc\" ")); - txt = Tpl.writeStr(txt, i_makefileParams_cflags); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("LDFLAGS=-L\"")); - txt = Tpl.writeStr(txt, i_makefileParams_omhome); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("/lib/omc\" ")); - txt = Tpl.writeStr(txt, i_makefileParams_ldflags); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("SENDDATALIBS=")); - txt = Tpl.writeStr(txt, i_makefileParams_senddatalibs); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ - "\n", - ".PHONY: " - }, false)); - txt = Tpl.writeStr(txt, i_fileNamePrefix); - txt = Tpl.softNewLine(txt); - txt = Tpl.writeStr(txt, i_fileNamePrefix); - txt = Tpl.writeTok(txt, Tpl.ST_STRING(": ")); - txt = Tpl.writeStr(txt, i_fileNamePrefix); - txt = Tpl.writeTok(txt, Tpl.ST_LINE(".cpp\n")); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("\t")); - txt = Tpl.writeTok(txt, Tpl.ST_STRING(" $(CXX) $(CFLAGS) -I. -o ")); - txt = Tpl.writeStr(txt, i_fileNamePrefix); - txt = Tpl.writeTok(txt, Tpl.ST_STRING("$(DLLEXT) ")); - txt = Tpl.writeStr(txt, i_fileNamePrefix); - txt = Tpl.writeTok(txt, Tpl.ST_STRING(".cpp ")); - txt = Tpl.writeText(txt, i_dirExtra); - txt = Tpl.writeTok(txt, Tpl.ST_STRING(" ")); - txt = Tpl.writeText(txt, i_libsPos1); - txt = Tpl.writeTok(txt, Tpl.ST_STRING(" -lsim $(LDFLAGS) -lf2c -linteractive $(SENDDATALIBS) ")); - txt = Tpl.writeText(txt, i_libsPos2); - then txt; - - case ( txt, - _ ) - then txt; - end matchcontinue; -end fmuMakefile; - +package SimCodeFMU + +protected constant Tpl.Text emptyTxt = Tpl.MEM_TEXT({}, {}); + +public import Tpl; + +public import SimCode; +public import BackendDAE; +public import System; +public import Absyn; +public import DAE; +public import ClassInf; +public import Util; +public import ComponentReference; +public import Expression; +public import RTOpts; +public import Settings; +public import SimCodeC; + +public function translateModel + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode) + local + Tpl.Text txt; + + case ( txt, + (i_simCode as SimCode.SIMCODE(fileNamePrefix = i_fileNamePrefix)) ) + local + String i_fileNamePrefix; + SimCode.SimCode i_simCode; + Tpl.Text txt_6; + Tpl.Text txt_5; + Tpl.Text txt_4; + Tpl.Text txt_3; + Tpl.Text txt_2; + String ret_1; + Tpl.Text i_guid; + equation + ret_1 = System.getUUIDStr(); + i_guid = Tpl.writeStr(emptyTxt, ret_1); + txt_2 = fmuModelDescriptionFile(emptyTxt, i_simCode, Tpl.textString(i_guid)); + Tpl.textFile(txt_2, "modelDescription.xml"); + txt_3 = fmumodel_identifierFile(emptyTxt, i_simCode, Tpl.textString(i_guid)); + txt_4 = Tpl.writeStr(emptyTxt, i_fileNamePrefix); + txt_4 = Tpl.writeTok(txt_4, Tpl.ST_STRING("_FMU.cpp")); + Tpl.textFile(txt_3, Tpl.textString(txt_4)); + txt_5 = fmuMakefile(emptyTxt, i_simCode); + txt_6 = Tpl.writeStr(emptyTxt, i_fileNamePrefix); + txt_6 = Tpl.writeTok(txt_6, Tpl.ST_STRING("_FMU.makefile")); + Tpl.textFile(txt_5, Tpl.textString(txt_6)); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end translateModel; + +public function fmuModelDescriptionFile + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + input String in_i_guid; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode, in_i_guid) + local + Tpl.Text txt; + String i_guid; + + case ( txt, + (i_simCode as SimCode.SIMCODE(modelInfo = _)), + i_guid ) + local + SimCode.SimCode i_simCode; + equation + txt = Tpl.writeTok(txt, Tpl.ST_LINE("\n")); + txt = fmiModelDescription(txt, i_simCode, i_guid); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); + then txt; + + case ( txt, + _, + _ ) + then txt; + end matchcontinue; +end fmuModelDescriptionFile; + +public function fmiModelDescription + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + input String in_i_guid; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode, in_i_guid) + local + Tpl.Text txt; + String i_guid; + + case ( txt, + (i_simCode as SimCode.SIMCODE(simulationSettingsOpt = i_simulationSettingsOpt, modelInfo = i_modelInfo)), + i_guid ) + local + SimCode.ModelInfo i_modelInfo; + Option i_simulationSettingsOpt; + SimCode.SimCode i_simCode; + equation + txt = Tpl.writeTok(txt, Tpl.ST_LINE("\n")); + txt = DefaultExperiment(txt, i_simulationSettingsOpt); + txt = Tpl.softNewLine(txt); + txt = ModelVariables(txt, i_modelInfo); + txt = Tpl.softNewLine(txt); + txt = Tpl.popBlock(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + _, + _ ) + then txt; + end matchcontinue; +end fmiModelDescription; + +public function fmiModelDescriptionAttributes + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + input String in_i_guid; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode, in_i_guid) + local + Tpl.Text txt; + String i_guid; + + case ( txt, + SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(varInfo = (i_vi as SimCode.VARINFO(numStateVars = i_vi_numStateVars, numZeroCrossings = i_vi_numZeroCrossings)), name = i_modelInfo_name), fileNamePrefix = i_fileNamePrefix), + i_guid ) + local + String i_fileNamePrefix; + Absyn.Path i_modelInfo_name; + Integer i_vi_numZeroCrossings; + Integer i_vi_numStateVars; + SimCode.VarInfo i_vi; + Tpl.Text i_numberOfEventIndicators; + Tpl.Text i_numberOfContinuousStates; + Tpl.Text i_variableNamingConvention; + Util.DateTime ret_9; + Tpl.Text i_generationDateAndTime; + String ret_7; + Tpl.Text i_generationTool; + Tpl.Text i_version; + Tpl.Text i_author; + Tpl.Text i_description; + Tpl.Text i_modelIdentifier; + Tpl.Text i_modelName; + Tpl.Text i_fmiVersion; + equation + i_fmiVersion = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("1.0")); + i_modelName = SimCodeC.dotPath(emptyTxt, i_modelInfo_name); + i_modelIdentifier = Tpl.writeStr(emptyTxt, i_fileNamePrefix); + i_description = emptyTxt; + i_author = emptyTxt; + i_version = emptyTxt; + i_generationTool = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("OpenModelica Compiler ")); + ret_7 = Settings.getVersionNr(); + i_generationTool = Tpl.writeStr(i_generationTool, ret_7); + ret_9 = Util.getCurrentDateTime(); + i_generationDateAndTime = xsdateTime(emptyTxt, ret_9); + i_variableNamingConvention = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("structured")); + i_numberOfContinuousStates = Tpl.writeStr(emptyTxt, intString(i_vi_numStateVars)); + i_numberOfEventIndicators = Tpl.writeStr(emptyTxt, intString(i_vi_numZeroCrossings)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("fmiVersion=\"")); + txt = Tpl.writeText(txt, i_fmiVersion); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "modelName=\"" + }, false)); + txt = Tpl.writeText(txt, i_modelName); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "modelIdentifier=\"" + }, false)); + txt = Tpl.writeText(txt, i_modelIdentifier); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "guid=\"{" + }, false)); + txt = Tpl.writeStr(txt, i_guid); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "}\"\n", + "generationTool=\"" + }, false)); + txt = Tpl.writeText(txt, i_generationTool); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "generationDateAndTime=\"" + }, false)); + txt = Tpl.writeText(txt, i_generationDateAndTime); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "variableNamingConvention=\"" + }, false)); + txt = Tpl.writeText(txt, i_variableNamingConvention); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "numberOfContinuousStates=\"" + }, false)); + txt = Tpl.writeText(txt, i_numberOfContinuousStates); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "numberOfEventIndicators=\"" + }, false)); + txt = Tpl.writeText(txt, i_numberOfEventIndicators); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); + then txt; + + case ( txt, + _, + _ ) + then txt; + end matchcontinue; +end fmiModelDescriptionAttributes; + +public function xsdateTime + input Tpl.Text in_txt; + input Util.DateTime in_i_dt; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_dt) + local + Tpl.Text txt; + + case ( txt, + Util.DATETIME(year = i_year, mon = i_mon, mday = i_mday, hour = i_hour, min = i_min, sec = i_sec) ) + local + Integer i_sec; + Integer i_min; + Integer i_hour; + Integer i_mday; + Integer i_mon; + Integer i_year; + equation + txt = Tpl.writeStr(txt, intString(i_year)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("-")); + txt = Tpl.writeStr(txt, intString(i_mon)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("-")); + txt = Tpl.writeStr(txt, intString(i_mday)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("T")); + txt = Tpl.writeStr(txt, intString(i_hour)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING(":")); + txt = Tpl.writeStr(txt, intString(i_min)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING(":")); + txt = Tpl.writeStr(txt, intString(i_sec)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("Z")); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end xsdateTime; + +public function UnitDefinitions + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMCODE(modelInfo = _) ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\n", + "" + }, false)); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end UnitDefinitions; + +public function TypeDefinitions + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMCODE(modelInfo = _) ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\n", + "" + }, false)); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end TypeDefinitions; + +public function DefaultExperiment + input Tpl.Text in_txt; + input Option in_i_simulationSettingsOpt; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simulationSettingsOpt) + local + Tpl.Text txt; + + case ( txt, + SOME(i_v) ) + local + SimCode.SimulationSettings i_v; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end DefaultExperiment; + +public function DefaultExperimentAttribute + input Tpl.Text in_txt; + input SimCode.SimulationSettings in_i_simulationSettings; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simulationSettings) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMULATION_SETTINGS(startTime = i_startTime, stopTime = i_stopTime, tolerance = i_tolerance) ) + local + Real i_tolerance; + Real i_stopTime; + Real i_startTime; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("startTime=\"")); + txt = Tpl.writeStr(txt, realString(i_startTime)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\" stopTime=\"")); + txt = Tpl.writeStr(txt, realString(i_stopTime)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\" tolerance=\"")); + txt = Tpl.writeStr(txt, realString(i_tolerance)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end DefaultExperimentAttribute; + +public function VendorAnnotations + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMCODE(modelInfo = _) ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\n", + "" + }, false)); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end VendorAnnotations; + +protected function lm_24 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 0); + txt = Tpl.nextIter(txt); + txt = lm_24(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_24(txt, rest); + then txt; + end matchcontinue; +end lm_24; + +protected function lm_25 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 10000); + txt = Tpl.nextIter(txt); + txt = lm_25(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_25(txt, rest); + then txt; + end matchcontinue; +end lm_25; + +protected function lm_26 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "input", 100000); + txt = Tpl.nextIter(txt); + txt = lm_26(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_26(txt, rest); + then txt; + end matchcontinue; +end lm_26; + +protected function lm_27 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "output", 200000); + txt = Tpl.nextIter(txt); + txt = lm_27(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_27(txt, rest); + then txt; + end matchcontinue; +end lm_27; + +protected function lm_28 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 1000000); + txt = Tpl.nextIter(txt); + txt = lm_28(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_28(txt, rest); + then txt; + end matchcontinue; +end lm_28; + +protected function lm_29 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 5000000); + txt = Tpl.nextIter(txt); + txt = lm_29(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_29(txt, rest); + then txt; + end matchcontinue; +end lm_29; + +protected function lm_30 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 0); + txt = Tpl.nextIter(txt); + txt = lm_30(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_30(txt, rest); + then txt; + end matchcontinue; +end lm_30; + +protected function lm_31 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 1000000); + txt = Tpl.nextIter(txt); + txt = lm_31(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_31(txt, rest); + then txt; + end matchcontinue; +end lm_31; + +protected function lm_32 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 0); + txt = Tpl.nextIter(txt); + txt = lm_32(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_32(txt, rest); + then txt; + end matchcontinue; +end lm_32; + +protected function lm_33 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 1000000); + txt = Tpl.nextIter(txt); + txt = lm_33(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_33(txt, rest); + then txt; + end matchcontinue; +end lm_33; + +protected function lm_34 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 0); + txt = Tpl.nextIter(txt); + txt = lm_34(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_34(txt, rest); + then txt; + end matchcontinue; +end lm_34; + +protected function lm_35 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = ScalarVariable(txt, i_var, "internal", 1000000); + txt = Tpl.nextIter(txt); + txt = lm_35(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_35(txt, rest); + then txt; + end matchcontinue; +end lm_35; + +public function ModelVariables + input Tpl.Text in_txt; + input SimCode.ModelInfo in_i_modelInfo; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_modelInfo) + local + Tpl.Text txt; + + case ( txt, + SimCode.MODELINFO(vars = SimCode.SIMVARS(stateVars = i_vars_stateVars, derivativeVars = i_vars_derivativeVars, inputVars = i_vars_inputVars, outputVars = i_vars_outputVars, algVars = i_vars_algVars, paramVars = i_vars_paramVars, intAlgVars = i_vars_intAlgVars, intParamVars = i_vars_intParamVars, boolAlgVars = i_vars_boolAlgVars, boolParamVars = i_vars_boolParamVars, stringAlgVars = i_vars_stringAlgVars, stringParamVars = i_vars_stringParamVars)) ) + local + list i_vars_stringParamVars; + list i_vars_stringAlgVars; + list i_vars_boolParamVars; + list i_vars_boolAlgVars; + list i_vars_intParamVars; + list i_vars_intAlgVars; + list i_vars_paramVars; + list i_vars_algVars; + list i_vars_outputVars; + list i_vars_inputVars; + list i_vars_derivativeVars; + list i_vars_stateVars; + equation + txt = Tpl.writeTok(txt, Tpl.ST_LINE("\n")); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_24(txt, i_vars_stateVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_25(txt, i_vars_derivativeVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_26(txt, i_vars_inputVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_27(txt, i_vars_outputVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_28(txt, i_vars_algVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_29(txt, i_vars_paramVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_30(txt, i_vars_intAlgVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_31(txt, i_vars_intParamVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_32(txt, i_vars_boolAlgVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_33(txt, i_vars_boolParamVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_34(txt, i_vars_stringAlgVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_35(txt, i_vars_stringParamVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end ModelVariables; + +public function ScalarVariable + input Tpl.Text in_txt; + input SimCode.SimVar in_i_simVar; + input String in_i_causality; + input Integer in_i_offset; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simVar, in_i_causality, in_i_offset) + local + Tpl.Text txt; + String i_causality; + Integer i_offset; + + case ( txt, + (i_simVar as SimCode.SIMVAR(type_ = i_type__, unit = i_unit, displayUnit = i_displayUnit, initialValue = i_initialValue, isFixed = i_isFixed)), + i_causality, + i_offset ) + local + Boolean i_isFixed; + Option i_initialValue; + String i_displayUnit; + String i_unit; + DAE.ExpType i_type__; + SimCode.SimVar i_simVar; + equation + txt = Tpl.writeTok(txt, Tpl.ST_LINE("\n")); + txt = ScalarVariableType(txt, i_type__, i_unit, i_displayUnit, i_initialValue, i_isFixed); + txt = Tpl.softNewLine(txt); + txt = Tpl.popBlock(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + _, + _, + _ ) + then txt; + end matchcontinue; +end ScalarVariable; + +protected function fun_38 + input Tpl.Text in_txt; + input String in_i_comment; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_comment) + local + Tpl.Text txt; + + case ( txt, + "" ) + then txt; + + case ( txt, + i_comment ) + local + String i_comment; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("description=\"")); + txt = Tpl.writeStr(txt, i_comment); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); + then txt; + end matchcontinue; +end fun_38; + +public function ScalarVariableAttribute + input Tpl.Text in_txt; + input SimCode.SimVar in_i_simVar; + input String in_i_causality; + input Integer in_i_offset; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simVar, in_i_causality, in_i_offset) + local + Tpl.Text txt; + String i_causality; + Integer i_offset; + + case ( txt, + SimCode.SIMVAR(index = i_index, varKind = i_varKind, comment = i_comment, name = i_name), + i_causality, + i_offset ) + local + DAE.ComponentRef i_name; + String i_comment; + BackendDAE.VarKind i_varKind; + Integer i_index; + Tpl.Text i_alias; + Tpl.Text i_description; + Tpl.Text i_variability; + Integer ret_1; + Tpl.Text i_valueReference; + equation + ret_1 = intAdd(i_index, i_offset); + i_valueReference = Tpl.writeStr(emptyTxt, intString(ret_1)); + i_variability = getVariablity(emptyTxt, i_varKind); + i_description = fun_38(emptyTxt, i_comment); + i_alias = Tpl.writeTok(emptyTxt, Tpl.ST_STRING("noAlias")); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("name=\"")); + txt = SimCodeC.crefStr(txt, i_name); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "valueReference=\"" + }, false)); + txt = Tpl.writeText(txt, i_valueReference); + txt = Tpl.writeTok(txt, Tpl.ST_LINE("\"\n")); + txt = Tpl.writeText(txt, i_description); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("variability=\"")); + txt = Tpl.writeText(txt, i_variability); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "causality=\"" + }, false)); + txt = Tpl.writeStr(txt, i_causality); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "alias=\"" + }, false)); + txt = Tpl.writeText(txt, i_alias); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); + then txt; + + case ( txt, + _, + _, + _ ) + then txt; + end matchcontinue; +end ScalarVariableAttribute; + +public function getVariablity + input Tpl.Text in_txt; + input BackendDAE.VarKind in_i_varKind; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_varKind) + local + Tpl.Text txt; + + case ( txt, + BackendDAE.DISCRETE() ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("discrete")); + then txt; + + case ( txt, + BackendDAE.PARAM() ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("parameter")); + then txt; + + case ( txt, + BackendDAE.CONST() ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("constant")); + then txt; + + case ( txt, + _ ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("continuous")); + then txt; + end matchcontinue; +end getVariablity; + +public function ScalarVariableType + input Tpl.Text in_txt; + input DAE.ExpType in_i_type__; + input String in_i_unit; + input String in_i_displayUnit; + input Option in_i_initialValue; + input Boolean in_i_isFixed; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_type__, in_i_unit, in_i_displayUnit, in_i_initialValue, in_i_isFixed) + local + Tpl.Text txt; + String i_unit; + String i_displayUnit; + Option i_initialValue; + Boolean i_isFixed; + + case ( txt, + DAE.ET_INT(), + _, + _, + _, + _ ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + DAE.ET_REAL(), + i_unit, + i_displayUnit, + i_initialValue, + i_isFixed ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + DAE.ET_BOOL(), + _, + _, + _, + _ ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + DAE.ET_STRING(), + _, + _, + _, + _ ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + DAE.ET_ENUMERATION(path = _), + _, + _, + _, + _ ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); + then txt; + + case ( txt, + _, + _, + _, + _, + _ ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("UNKOWN_TYPE")); + then txt; + end matchcontinue; +end ScalarVariableType; + +public function ScalarVariableTypeCommonAttribute + input Tpl.Text in_txt; + input Option in_i_initialValue; + input Boolean in_i_isFixed; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_initialValue, in_i_isFixed) + local + Tpl.Text txt; + Boolean i_isFixed; + + case ( txt, + SOME(i_exp), + i_isFixed ) + local + DAE.Exp i_exp; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("start=\"")); + txt = SimCodeC.initVal(txt, i_exp); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\" fixed=\"")); + txt = Tpl.writeStr(txt, Tpl.booleanString(i_isFixed)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); + then txt; + + case ( txt, + _, + _ ) + then txt; + end matchcontinue; +end ScalarVariableTypeCommonAttribute; + +protected function fun_43 + input Tpl.Text in_txt; + input String in_i_unit; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_unit) + local + Tpl.Text txt; + + case ( txt, + "" ) + then txt; + + case ( txt, + i_unit ) + local + String i_unit; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("unit=\"")); + txt = Tpl.writeStr(txt, i_unit); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); + then txt; + end matchcontinue; +end fun_43; + +protected function fun_44 + input Tpl.Text in_txt; + input String in_i_displayUnit; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_displayUnit) + local + Tpl.Text txt; + + case ( txt, + "" ) + then txt; + + case ( txt, + i_displayUnit ) + local + String i_displayUnit; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("displayUnit=\"")); + txt = Tpl.writeStr(txt, i_displayUnit); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); + then txt; + end matchcontinue; +end fun_44; + +public function ScalarVariableTypeRealAttribute + input Tpl.Text txt; + input String i_unit; + input String i_displayUnit; + + output Tpl.Text out_txt; +protected + Tpl.Text i_displayUnit__; + Tpl.Text i_unit__; +algorithm + i_unit__ := fun_43(emptyTxt, i_unit); + i_displayUnit__ := fun_44(emptyTxt, i_displayUnit); + out_txt := Tpl.writeText(txt, i_unit__); + out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" ")); + out_txt := Tpl.writeText(out_txt, i_displayUnit__); +end ScalarVariableTypeRealAttribute; + +public function fmumodel_identifierFile + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + input String in_i_guid; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode, in_i_guid) + local + Tpl.Text txt; + String i_guid; + + case ( txt, + (i_simCode as SimCode.SIMCODE(fileNamePrefix = i_fileNamePrefix, modelInfo = i_modelInfo)), + i_guid ) + local + SimCode.ModelInfo i_modelInfo; + String i_fileNamePrefix; + SimCode.SimCode i_simCode; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\n", + "// define class name and unique id\n", + "#define MODEL_IDENTIFIER " + }, false)); + txt = Tpl.writeStr(txt, i_fileNamePrefix); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define MODEL_GUID \"")); + txt = Tpl.writeStr(txt, i_guid); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\"\n", + "\n", + "// include fmu header files, typedefs and macros\n", + "#include \"fmiModelFunctions.h\"\n", + "\n", + "// implementation of the Model Exchange functions\n", + "#include \"fmu_model_interface.c\"\n", + "\n" + }, true)); + txt = ModelDefineData(txt, i_modelInfo); + txt = Tpl.softNewLine(txt); + txt = setStartValues(txt, i_simCode); + txt = Tpl.softNewLine(txt); + txt = initializeFunction(txt, i_simCode); + txt = Tpl.softNewLine(txt); + txt = eventUpdateFunction(txt, i_simCode); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); + then txt; + + case ( txt, + _, + _ ) + then txt; + end matchcontinue; +end fmumodel_identifierFile; + +protected function lm_47 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineStateVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_47(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_47(txt, rest); + then txt; + end matchcontinue; +end lm_47; + +protected function lm_48 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_48(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_48(txt, rest); + then txt; + end matchcontinue; +end lm_48; + +protected function lm_49 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_49(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_49(txt, rest); + then txt; + end matchcontinue; +end lm_49; + +protected function lm_50 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_50(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_50(txt, rest); + then txt; + end matchcontinue; +end lm_50; + +protected function lm_51 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_51(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_51(txt, rest); + then txt; + end matchcontinue; +end lm_51; + +protected function lm_52 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_52(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_52(txt, rest); + then txt; + end matchcontinue; +end lm_52; + +protected function lm_53 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_53(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_53(txt, rest); + then txt; + end matchcontinue; +end lm_53; + +protected function lm_54 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_54(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_54(txt, rest); + then txt; + end matchcontinue; +end lm_54; + +protected function lm_55 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_55(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_55(txt, rest); + then txt; + end matchcontinue; +end lm_55; + +protected function lm_56 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_56(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_56(txt, rest); + then txt; + end matchcontinue; +end lm_56; + +protected function lm_57 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_var :: rest ) + local + list rest; + SimCode.SimVar i_var; + equation + txt = DefineVariables(txt, i_var); + txt = Tpl.nextIter(txt); + txt = lm_57(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_57(txt, rest); + then txt; + end matchcontinue; +end lm_57; + +protected function lm_58 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + SimCode.SIMVAR(name = i_name) :: rest ) + local + list rest; + DAE.ComponentRef i_name; + equation + txt = SimCodeC.crefStr(txt, i_name); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("_")); + txt = Tpl.nextIter(txt); + txt = lm_58(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_58(txt, rest); + then txt; + end matchcontinue; +end lm_58; + +public function ModelDefineData + input Tpl.Text in_txt; + input SimCode.ModelInfo in_i_modelInfo; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_modelInfo) + local + Tpl.Text txt; + + case ( txt, + SimCode.MODELINFO(varInfo = SimCode.VARINFO(numStateVars = i_varInfo_numStateVars, numAlgVars = i_varInfo_numAlgVars, numParams = i_varInfo_numParams, numIntAlgVars = i_varInfo_numIntAlgVars, numIntParams = i_varInfo_numIntParams, numStringAlgVars = i_varInfo_numStringAlgVars, numStringParamVars = i_varInfo_numStringParamVars, numBoolAlgVars = i_varInfo_numBoolAlgVars, numBoolParams = i_varInfo_numBoolParams, numZeroCrossings = i_varInfo_numZeroCrossings), vars = SimCode.SIMVARS(stateVars = i_vars_stateVars, inputVars = i_vars_inputVars, outputVars = i_vars_outputVars, algVars = i_vars_algVars, paramVars = i_vars_paramVars, intAlgVars = i_vars_intAlgVars, intParamVars = i_vars_intParamVars, boolAlgVars = i_vars_boolAlgVars, boolParamVars = i_vars_boolParamVars, stringAlgVars = i_vars_stringAlgVars, stringParamVars = i_vars_stringParamVars)) ) + local + list i_vars_stringParamVars; + list i_vars_stringAlgVars; + list i_vars_boolParamVars; + list i_vars_boolAlgVars; + list i_vars_intParamVars; + list i_vars_intAlgVars; + list i_vars_paramVars; + list i_vars_algVars; + list i_vars_outputVars; + list i_vars_inputVars; + list i_vars_stateVars; + Integer i_varInfo_numZeroCrossings; + Integer i_varInfo_numBoolParams; + Integer i_varInfo_numBoolAlgVars; + Integer i_varInfo_numStringParamVars; + Integer i_varInfo_numStringAlgVars; + Integer i_varInfo_numIntParams; + Integer i_varInfo_numIntAlgVars; + Integer i_varInfo_numParams; + Integer i_varInfo_numAlgVars; + Integer i_varInfo_numStateVars; + Integer ret_8; + Tpl.Text i_numberOfBooleans; + Integer ret_6; + Tpl.Text i_numberOfStrings; + Integer ret_4; + Tpl.Text i_numberOfIntegers; + Integer ret_2; + Integer ret_1; + Tpl.Text i_numberOfReals; + equation + ret_1 = intAdd(i_varInfo_numAlgVars, i_varInfo_numParams); + ret_2 = intAdd(i_varInfo_numStateVars, ret_1); + i_numberOfReals = Tpl.writeStr(emptyTxt, intString(ret_2)); + ret_4 = intAdd(i_varInfo_numIntAlgVars, i_varInfo_numIntParams); + i_numberOfIntegers = Tpl.writeStr(emptyTxt, intString(ret_4)); + ret_6 = intAdd(i_varInfo_numStringAlgVars, i_varInfo_numStringParamVars); + i_numberOfStrings = Tpl.writeStr(emptyTxt, intString(ret_6)); + ret_8 = intAdd(i_varInfo_numBoolAlgVars, i_varInfo_numBoolParams); + i_numberOfBooleans = Tpl.writeStr(emptyTxt, intString(ret_8)); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "// define model size\n", + "#define NUMBER_OF_STATES " + }, false)); + txt = Tpl.writeStr(txt, intString(i_varInfo_numStateVars)); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_EVENT_INDICATORS ")); + txt = Tpl.writeStr(txt, intString(i_varInfo_numZeroCrossings)); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_REALS ")); + txt = Tpl.writeText(txt, i_numberOfReals); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_INTEGERS ")); + txt = Tpl.writeText(txt, i_numberOfIntegers); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_STRINGS ")); + txt = Tpl.writeText(txt, i_numberOfStrings); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_BOOLEANS ")); + txt = Tpl.writeText(txt, i_numberOfBooleans); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\n", + "// define variable data for model\n" + }, true)); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_47(txt, i_vars_stateVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_48(txt, i_vars_inputVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_49(txt, i_vars_outputVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_50(txt, i_vars_algVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_51(txt, i_vars_paramVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_52(txt, i_vars_intAlgVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_53(txt, i_vars_intParamVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_54(txt, i_vars_boolAlgVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_55(txt, i_vars_boolParamVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_56(txt, i_vars_stringAlgVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_57(txt, i_vars_stringParamVars); + txt = Tpl.popIter(txt); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\n", + "// define initial state vector as vector of value references\n", + "#define STATES { " + }, false)); + txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + txt = lm_58(txt, i_vars_stateVars); + txt = Tpl.popIter(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + " }\n", + "\n" + }, true)); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end ModelDefineData; + +public function DefineStateVariables + input Tpl.Text in_txt; + input SimCode.SimVar in_i_simVar; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simVar) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMVAR(name = i_name) ) + local + DAE.ComponentRef i_name; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define ")); + txt = SimCodeC.crefStr(txt, i_name); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "_\n", + "#define der_" + }, false)); + txt = SimCodeC.crefStr(txt, i_name); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("_")); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end DefineStateVariables; + +public function DefineVariables + input Tpl.Text in_txt; + input SimCode.SimVar in_i_simVar; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simVar) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMVAR(name = i_name) ) + local + DAE.ComponentRef i_name; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("#define ")); + txt = SimCodeC.crefStr(txt, i_name); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("_")); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end DefineVariables; + +public function setStartValues + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMCODE(modelInfo = _) ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "// Set values for all variables that define a start value\n", + "void setStartValues(ModelInstance *comp) {\n", + "}\n", + "\n" + }, true)); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end setStartValues; + +public function initializeFunction + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMCODE(modelInfo = _) ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "// Used to set the first time event, if any.\n", + "void initialize(ModelInstance* comp, fmiEventInfo* eventInfo) {\n", + "}\n", + "\n" + }, true)); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end initializeFunction; + +public function eventUpdateFunction + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMCODE(modelInfo = _) ) + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "// Used to set the next time event, if any.\n", + "void eventUpdate(ModelInstance* comp, fmiEventInfo* eventInfo) {\n", + "}\n", + "\n" + }, true)); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end eventUpdateFunction; + +protected function fun_65 + input Tpl.Text in_txt; + input String in_i_modelInfo_directory; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_modelInfo_directory) + local + Tpl.Text txt; + + case ( txt, + "" ) + then txt; + + case ( txt, + i_modelInfo_directory ) + local + String i_modelInfo_directory; + equation + txt = Tpl.writeTok(txt, Tpl.ST_STRING("-L\"")); + txt = Tpl.writeStr(txt, i_modelInfo_directory); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); + then txt; + end matchcontinue; +end fun_65; + +protected function lm_66 + input Tpl.Text in_txt; + input list in_items; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_items) + local + Tpl.Text txt; + + case ( txt, + {} ) + then txt; + + case ( txt, + i_lib :: rest ) + local + list rest; + String i_lib; + equation + txt = Tpl.writeStr(txt, i_lib); + txt = Tpl.nextIter(txt); + txt = lm_66(txt, rest); + then txt; + + case ( txt, + _ :: rest ) + local + list rest; + equation + txt = lm_66(txt, rest); + then txt; + end matchcontinue; +end lm_66; + +protected function fun_67 + input Tpl.Text in_txt; + input String in_it; + input Tpl.Text in_i_libsStr; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_it, in_i_libsStr) + local + Tpl.Text txt; + Tpl.Text i_libsStr; + + case ( txt, + "", + i_libsStr ) + equation + txt = Tpl.writeText(txt, i_libsStr); + then txt; + + case ( txt, + _, + _ ) + then txt; + end matchcontinue; +end fun_67; + +protected function fun_68 + input Tpl.Text in_txt; + input String in_it; + input Tpl.Text in_i_libsStr; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_it, in_i_libsStr) + local + Tpl.Text txt; + Tpl.Text i_libsStr; + + case ( txt, + "", + _ ) + then txt; + + case ( txt, + _, + i_libsStr ) + equation + txt = Tpl.writeText(txt, i_libsStr); + then txt; + end matchcontinue; +end fun_68; + +public function fmuMakefile + input Tpl.Text in_txt; + input SimCode.SimCode in_i_simCode; + + output Tpl.Text out_txt; +algorithm + out_txt := + matchcontinue(in_txt, in_i_simCode) + local + Tpl.Text txt; + + case ( txt, + SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(directory = i_modelInfo_directory), makefileParams = SimCode.MAKEFILE_PARAMS(libs = i_makefileParams_libs, ccompiler = i_makefileParams_ccompiler, cxxcompiler = i_makefileParams_cxxcompiler, linker = i_makefileParams_linker, exeext = i_makefileParams_exeext, dllext = i_makefileParams_dllext, omhome = i_makefileParams_omhome, cflags = i_makefileParams_cflags, ldflags = i_makefileParams_ldflags, senddatalibs = i_makefileParams_senddatalibs), fileNamePrefix = i_fileNamePrefix) ) + local + String i_fileNamePrefix; + String i_makefileParams_senddatalibs; + String i_makefileParams_ldflags; + String i_makefileParams_cflags; + String i_makefileParams_omhome; + String i_makefileParams_dllext; + String i_makefileParams_exeext; + String i_makefileParams_linker; + String i_makefileParams_cxxcompiler; + String i_makefileParams_ccompiler; + list i_makefileParams_libs; + String i_modelInfo_directory; + String str_5; + Tpl.Text i_libsPos2; + String str_3; + Tpl.Text i_libsPos1; + Tpl.Text i_libsStr; + Tpl.Text i_dirExtra; + equation + i_dirExtra = fun_65(emptyTxt, i_modelInfo_directory); + i_libsStr = Tpl.pushIter(emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(" ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); + i_libsStr = lm_66(i_libsStr, i_makefileParams_libs); + i_libsStr = Tpl.popIter(i_libsStr); + str_3 = Tpl.textString(i_dirExtra); + i_libsPos1 = fun_67(emptyTxt, str_3, i_libsStr); + str_5 = Tpl.textString(i_dirExtra); + i_libsPos2 = fun_68(emptyTxt, str_5, i_libsStr); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "# Makefile generated by OpenModelica\n", + "\n", + "CC=" + }, false)); + txt = Tpl.writeStr(txt, i_makefileParams_ccompiler); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("CXX=")); + txt = Tpl.writeStr(txt, i_makefileParams_cxxcompiler); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("LINK=")); + txt = Tpl.writeStr(txt, i_makefileParams_linker); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("EXEEXT=")); + txt = Tpl.writeStr(txt, i_makefileParams_exeext); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("DLLEXT=")); + txt = Tpl.writeStr(txt, i_makefileParams_dllext); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("CFLAGS=-I\"")); + txt = Tpl.writeStr(txt, i_makefileParams_omhome); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("/include/omc\" ")); + txt = Tpl.writeStr(txt, i_makefileParams_cflags); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("LDFLAGS=-L\"")); + txt = Tpl.writeStr(txt, i_makefileParams_omhome); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("/lib/omc\" ")); + txt = Tpl.writeStr(txt, i_makefileParams_ldflags); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("SENDDATALIBS=")); + txt = Tpl.writeStr(txt, i_makefileParams_senddatalibs); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ + "\n", + ".PHONY: " + }, false)); + txt = Tpl.writeStr(txt, i_fileNamePrefix); + txt = Tpl.softNewLine(txt); + txt = Tpl.writeStr(txt, i_fileNamePrefix); + txt = Tpl.writeTok(txt, Tpl.ST_STRING(": ")); + txt = Tpl.writeStr(txt, i_fileNamePrefix); + txt = Tpl.writeTok(txt, Tpl.ST_LINE(".cpp\n")); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("\t")); + txt = Tpl.writeTok(txt, Tpl.ST_STRING(" $(CXX) $(CFLAGS) -I. -o ")); + txt = Tpl.writeStr(txt, i_fileNamePrefix); + txt = Tpl.writeTok(txt, Tpl.ST_STRING("$(DLLEXT) ")); + txt = Tpl.writeStr(txt, i_fileNamePrefix); + txt = Tpl.writeTok(txt, Tpl.ST_STRING(".cpp ")); + txt = Tpl.writeText(txt, i_dirExtra); + txt = Tpl.writeTok(txt, Tpl.ST_STRING(" ")); + txt = Tpl.writeText(txt, i_libsPos1); + txt = Tpl.writeTok(txt, Tpl.ST_STRING(" -lsim $(LDFLAGS) -lf2c -linteractive $(SENDDATALIBS) ")); + txt = Tpl.writeText(txt, i_libsPos2); + then txt; + + case ( txt, + _ ) + then txt; + end matchcontinue; +end fmuMakefile; + end SimCodeFMU; \ No newline at end of file diff --git a/Compiler/VarTransform.mo b/Compiler/VarTransform.mo index dcc0a62fbf2..643023795df 100644 --- a/Compiler/VarTransform.mo +++ b/Compiler/VarTransform.mo @@ -653,7 +653,7 @@ algorithm xs_1 = replaceEquationsStmts(xs, repl,condExpFunc); then (DAE.STMT_IF(e_1,stmts2,el_1,source) :: xs_1); - case (((x as DAE.STMT_FOR(type_=tp,iterIsArray=b1,ident=id1,exp=e,statementLst=stmts,source = source)) :: xs),repl,condExpFunc) + case (((x as DAE.STMT_FOR(type_=tp,iterIsArray=b1,iter=id1,range=e,statementLst=stmts,source = source)) :: xs),repl,condExpFunc) equation stmts2 = replaceEquationsStmts(stmts,repl,condExpFunc); e_1 = replaceExp(e, repl, condExpFunc); diff --git a/Compiler/susan_codegen/SimCode/SimCodeC.tpl b/Compiler/susan_codegen/SimCode/SimCodeC.tpl index 6bdcae29544..55e9186715f 100644 --- a/Compiler/susan_codegen/SimCode/SimCodeC.tpl +++ b/Compiler/susan_codegen/SimCode/SimCodeC.tpl @@ -3693,6 +3693,7 @@ template algStatement(DAE.Statement stmt, Context context, Text &varDecls /*BUFP case s as STMT_FOR(__) then algStmtFor(s, context, &varDecls /*BUFC*/) case s as STMT_WHILE(__) then algStmtWhile(s, context, &varDecls /*BUFC*/) case s as STMT_ASSERT(__) then algStmtAssert(s, context, &varDecls /*BUFC*/) + case s as STMT_TERMINATE(__) then algStmtTerminate(s, context, &varDecls /*BUFC*/) case s as STMT_WHEN(__) then algStmtWhen(s, context, &varDecls /*BUFC*/) case s as STMT_MATCHCASES(__) then algStmtMatchcases(s, context, &varDecls /*BUFC*/) case s as STMT_BREAK(__) then 'break;<%\n%>' @@ -3888,7 +3889,7 @@ template algStmtFor(DAE.Statement stmt, Context context, Text &varDecls /*BUFP*/ "Generates a for algorithm statement." ::= match stmt - case s as STMT_FOR(exp=rng as RANGE(__)) then + case s as STMT_FOR(range=rng as RANGE(__)) then algStmtForRange(s, context, &varDecls /*BUFC*/) case s as STMT_FOR(__) then algStmtForGeneric(s, context, &varDecls /*BUFC*/) @@ -3899,12 +3900,12 @@ template algStmtForRange(DAE.Statement stmt, Context context, Text &varDecls /*B "Generates a for algorithm statement where range is RANGE." ::= match stmt -case STMT_FOR(exp=rng as RANGE(__)) then +case STMT_FOR(range=rng as RANGE(__)) then let identType = expType(type_, iterIsArray) let identTypeShort = expTypeShort(type_) let stmtStr = (statementLst |> stmt => algStatement(stmt, context, &varDecls) ;separator="\n") - algStmtForRange_impl(rng, ident, identType, identTypeShort, stmtStr, context, &varDecls) + algStmtForRange_impl(rng, iter, identType, identTypeShort, stmtStr, context, &varDecls) end algStmtForRange; template algStmtForRange_impl(Exp range, Ident iterator, String type, String shortType, Text body, Context context, Text &varDecls) @@ -3946,7 +3947,7 @@ case STMT_FOR(__) then let arrayType = expTypeArray(type_) let stmtStr = (statementLst |> stmt => algStatement(stmt, context, &varDecls) ;separator="\n") - algStmtForGeneric_impl(exp, ident, iterType, arrayType, iterIsArray, stmtStr, + algStmtForGeneric_impl(range, iter, iterType, arrayType, iterIsArray, stmtStr, context, &varDecls) end algStmtForGeneric; @@ -4010,6 +4011,19 @@ case STMT_ASSERT(__) then >> end algStmtAssert; +template algStmtTerminate(DAE.Statement stmt, Context context, Text &varDecls /*BUFP*/) + "Generates an assert algorithm statement." +::= +match stmt +case STMT_TERMINATE(__) then + let &preExp = buffer "" /*BUFD*/ + let msgVar = daeExp(msg, context, &preExp /*BUFC*/, &varDecls /*BUFC*/) + << + <%preExp%> + MODELICA_TERMINATE(<%msgVar%>); + >> +end algStmtTerminate; + template algStmtMatchcasesVarDeclsAndAssign(list expList, Context context, Text &varDecls, Text &varAssign, Text &preExp) ::= (expList |> exp => diff --git a/Compiler/susan_codegen/SimCode/SimCodeCSharp.tpl b/Compiler/susan_codegen/SimCode/SimCodeCSharp.tpl index 00b36179fcf..f49ba7d9994 100644 --- a/Compiler/susan_codegen/SimCode/SimCodeCSharp.tpl +++ b/Compiler/susan_codegen/SimCode/SimCodeCSharp.tpl @@ -1128,12 +1128,12 @@ template algStatement(DAE.Statement it, Context context, SimCode simCode) ::= } <%elseExpr(else_, context, simCode)%> >> - case STMT_FOR(exp=rng as RANGE(__)) then + case STMT_FOR(range=rng as RANGE(__)) then let identType = expType(type_, iterIsArray) //TODO: ?? what is this for ... no array typed iterator is possible ??? let identTypeShort = expTypeShort(type_) let stmtStr = (statementLst |> stmt => algStatement(stmt, context, simCode) ;separator="\n") - algStmtForRange_impl(rng, ident, identType, identTypeShort, stmtStr, context, simCode) + algStmtForRange_impl(rng, iter, identType, identTypeShort, stmtStr, context, simCode) case s as STMT_FOR(__) then "algStmtForGeneric_NOT_IMPLEMENTED" // algStmtForGeneric(s, context, &varDecls /*BUFC*/) @@ -1151,16 +1151,16 @@ template algStatement(DAE.Statement it, Context context, SimCode simCode) ::= case _ then "NOT_IMPLEMENTED_ALG_STATEMENT" /* - case STMT_FOR(exp = rng as RANGE(__)) then + case STMT_FOR(range = rng as RANGE(__)) then << { <%expTypeA(type_, boolean)%> _r1 = <%daeExp(rng.exp,isSimulationCode)%>, _r2 = <%match rng.expOption case SOME(eo) then daeExp(eo,isSimulationCode) else "(1)"%>, _r3 = <%daeExp(rng.range,isSimulationCode)%>, - <%ident%>; + <%iter%>; - for (<%ident%> = _r1; in_range_<%expTypeShort(type_)%>(<%ident%>, _r1, _r3); <%ident%> += _r2) { + for (<%iter%> = _r1; in_range_<%expTypeShort(type_)%>(<%iter%>, _r1, _r3); <%iter%> += _r2) { <%statementLst |> it => algStatement(it) ;separator="\n" /* ??CONTEXT(codeContext,expContext,IN_FOR_LOOP(loopContext)*/ %> } } /*end for*/ diff --git a/Compiler/susan_codegen/SimCode/SimCodeTV.mo b/Compiler/susan_codegen/SimCode/SimCodeTV.mo index 6484bceddb7..0a85677d5ff 100644 --- a/Compiler/susan_codegen/SimCode/SimCodeTV.mo +++ b/Compiler/susan_codegen/SimCode/SimCodeTV.mo @@ -832,8 +832,8 @@ package DAE record STMT_FOR ExpType type_; Boolean iterIsArray; - Ident ident; - Exp exp; + Ident iter; + Exp range; list statementLst; ElementSource source; end STMT_FOR; @@ -849,6 +849,10 @@ package DAE list helpVarIndices; ElementSource source; end STMT_WHEN; + record STMT_TERMINATE + Exp msg; + ElementSource source; + end STMT_TERMINATE; record STMT_ASSERT Exp cond; Exp msg;