From 15c2c2e2c0ee228223ba7f8e977d1f23767781c8 Mon Sep 17 00:00:00 2001 From: Jens Frenkel Date: Thu, 28 Oct 2010 21:35:18 +0000 Subject: [PATCH] - FMU - use to get the valueReference = string(prefix)+string(var.index) prefix: states 1 derivatives 2 real algebraics 3 real parameter 4 integer algebraics 1 integer parameter 2 bool algebraics 1 bool parameter 2 string algebraics 1 string parameter 2 git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6695 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- Compiler/SimCodeFMU.mo | 299 +++++++----------- Compiler/susan_codegen/SimCode/SimCodeFMU.tpl | 32 +- 2 files changed, 121 insertions(+), 210 deletions(-) diff --git a/Compiler/SimCodeFMU.mo b/Compiler/SimCodeFMU.mo index e77f2baccf8..9a39d63f987 100644 --- a/Compiler/SimCodeFMU.mo +++ b/Compiler/SimCodeFMU.mo @@ -434,7 +434,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "internal", 0); + txt = ScalarVariable(txt, i_var, "internal", "1"); txt = Tpl.nextIter(txt); txt = lm_23(txt, rest); then txt; @@ -470,7 +470,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "internal", 10000); + txt = ScalarVariable(txt, i_var, "internal", "2"); txt = Tpl.nextIter(txt); txt = lm_24(txt, rest); then txt; @@ -506,7 +506,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "input", 100000); + txt = ScalarVariable(txt, i_var, "internal", "3"); txt = Tpl.nextIter(txt); txt = lm_25(txt, rest); then txt; @@ -542,7 +542,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "output", 200000); + txt = ScalarVariable(txt, i_var, "internal", "4"); txt = Tpl.nextIter(txt); txt = lm_26(txt, rest); then txt; @@ -578,7 +578,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "internal", 1000000); + txt = ScalarVariable(txt, i_var, "internal", "1"); txt = Tpl.nextIter(txt); txt = lm_27(txt, rest); then txt; @@ -614,7 +614,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "internal", 5000000); + txt = ScalarVariable(txt, i_var, "internal", "2"); txt = Tpl.nextIter(txt); txt = lm_28(txt, rest); then txt; @@ -650,7 +650,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "internal", 0); + txt = ScalarVariable(txt, i_var, "internal", "1"); txt = Tpl.nextIter(txt); txt = lm_29(txt, rest); then txt; @@ -686,7 +686,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "internal", 1000000); + txt = ScalarVariable(txt, i_var, "internal", "2"); txt = Tpl.nextIter(txt); txt = lm_30(txt, rest); then txt; @@ -722,7 +722,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "internal", 0); + txt = ScalarVariable(txt, i_var, "internal", "1"); txt = Tpl.nextIter(txt); txt = lm_31(txt, rest); then txt; @@ -758,7 +758,7 @@ algorithm list rest; SimCode.SimVar i_var; equation - txt = ScalarVariable(txt, i_var, "internal", 1000000); + txt = ScalarVariable(txt, i_var, "internal", "2"); txt = Tpl.nextIter(txt); txt = lm_32(txt, rest); then txt; @@ -773,78 +773,6 @@ algorithm 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", 0); - 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", 1000000); - 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; - public function ModelVariables input Tpl.Text in_txt; input SimCode.ModelInfo in_i_modelInfo; @@ -857,7 +785,7 @@ algorithm 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)) ) + SimCode.MODELINFO(vars = SimCode.SIMVARS(stateVars = i_vars_stateVars, derivativeVars = i_vars_derivativeVars, 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; @@ -867,8 +795,6 @@ algorithm 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 @@ -882,43 +808,35 @@ algorithm 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_inputVars); + txt = lm_25(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_26(txt, i_vars_outputVars); + txt = lm_26(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_27(txt, i_vars_algVars); + txt = lm_27(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_28(txt, i_vars_paramVars); + txt = lm_28(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_29(txt, i_vars_intAlgVars); + txt = lm_29(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_30(txt, i_vars_intParamVars); + txt = lm_30(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_31(txt, i_vars_boolAlgVars); + txt = lm_31(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_32(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_33(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_34(txt, i_vars_stringParamVars); + txt = lm_32(txt, i_vars_stringParamVars); txt = Tpl.popIter(txt); txt = Tpl.softNewLine(txt); txt = Tpl.writeTok(txt, Tpl.ST_STRING("")); @@ -934,7 +852,7 @@ public function ScalarVariable input Tpl.Text in_txt; input SimCode.SimVar in_i_simVar; input String in_i_causality; - input Integer in_i_offset; + input String in_i_offset; output Tpl.Text out_txt; algorithm @@ -943,7 +861,7 @@ algorithm local Tpl.Text txt; String i_causality; - Integer i_offset; + String i_offset; case ( txt, (i_simVar as SimCode.SIMVAR(type_ = i_type__, unit = i_unit, displayUnit = i_displayUnit, initialValue = i_initialValue, isFixed = i_isFixed)), @@ -975,7 +893,7 @@ algorithm end matchcontinue; end ScalarVariable; -protected function fun_37 +protected function fun_35 input Tpl.Text in_txt; input String in_i_comment; @@ -1000,13 +918,13 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); then txt; end matchcontinue; -end fun_37; +end fun_35; public function ScalarVariableAttribute input Tpl.Text in_txt; input SimCode.SimVar in_i_simVar; input String in_i_causality; - input Integer in_i_offset; + input String in_i_offset; output Tpl.Text out_txt; algorithm @@ -1015,7 +933,7 @@ algorithm local Tpl.Text txt; String i_causality; - Integer i_offset; + String i_offset; case ( txt, SimCode.SIMVAR(index = i_index, varKind = i_varKind, comment = i_comment, name = i_name), @@ -1029,13 +947,12 @@ algorithm 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_valueReference = Tpl.writeStr(emptyTxt, i_offset); + i_valueReference = Tpl.writeStr(i_valueReference, intString(i_index)); i_variability = getVariablity(emptyTxt, i_varKind); - i_description = fun_37(emptyTxt, i_comment); + i_description = fun_35(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); @@ -1225,7 +1142,7 @@ algorithm end matchcontinue; end ScalarVariableTypeCommonAttribute; -protected function fun_42 +protected function fun_40 input Tpl.Text in_txt; input String in_i_unit; @@ -1250,9 +1167,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); then txt; end matchcontinue; -end fun_42; +end fun_40; -protected function fun_43 +protected function fun_41 input Tpl.Text in_txt; input String in_i_displayUnit; @@ -1277,7 +1194,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); then txt; end matchcontinue; -end fun_43; +end fun_41; public function ScalarVariableTypeRealAttribute input Tpl.Text txt; @@ -1289,8 +1206,8 @@ protected Tpl.Text i_displayUnit__; Tpl.Text i_unit__; algorithm - i_unit__ := fun_42(emptyTxt, i_unit); - i_displayUnit__ := fun_43(emptyTxt, i_displayUnit); + i_unit__ := fun_40(emptyTxt, i_unit); + i_displayUnit__ := fun_41(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__); @@ -1354,7 +1271,7 @@ algorithm end matchcontinue; end fmumodel_identifierFile; -protected function lm_46 +protected function lm_44 input Tpl.Text in_txt; input list in_items; @@ -1377,7 +1294,7 @@ algorithm equation txt = DefineStateVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_46(txt, rest); + txt = lm_44(txt, rest); then txt; case ( txt, @@ -1385,12 +1302,12 @@ algorithm local list rest; equation - txt = lm_46(txt, rest); + txt = lm_44(txt, rest); then txt; end matchcontinue; -end lm_46; +end lm_44; -protected function lm_47 +protected function lm_45 input Tpl.Text in_txt; input list in_items; @@ -1413,7 +1330,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_47(txt, rest); + txt = lm_45(txt, rest); then txt; case ( txt, @@ -1421,12 +1338,12 @@ algorithm local list rest; equation - txt = lm_47(txt, rest); + txt = lm_45(txt, rest); then txt; end matchcontinue; -end lm_47; +end lm_45; -protected function lm_48 +protected function lm_46 input Tpl.Text in_txt; input list in_items; @@ -1449,7 +1366,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_48(txt, rest); + txt = lm_46(txt, rest); then txt; case ( txt, @@ -1457,12 +1374,12 @@ algorithm local list rest; equation - txt = lm_48(txt, rest); + txt = lm_46(txt, rest); then txt; end matchcontinue; -end lm_48; +end lm_46; -protected function lm_49 +protected function lm_47 input Tpl.Text in_txt; input list in_items; @@ -1485,7 +1402,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_49(txt, rest); + txt = lm_47(txt, rest); then txt; case ( txt, @@ -1493,12 +1410,12 @@ algorithm local list rest; equation - txt = lm_49(txt, rest); + txt = lm_47(txt, rest); then txt; end matchcontinue; -end lm_49; +end lm_47; -protected function lm_50 +protected function lm_48 input Tpl.Text in_txt; input list in_items; @@ -1521,7 +1438,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_50(txt, rest); + txt = lm_48(txt, rest); then txt; case ( txt, @@ -1529,12 +1446,12 @@ algorithm local list rest; equation - txt = lm_50(txt, rest); + txt = lm_48(txt, rest); then txt; end matchcontinue; -end lm_50; +end lm_48; -protected function lm_51 +protected function lm_49 input Tpl.Text in_txt; input list in_items; @@ -1557,7 +1474,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_51(txt, rest); + txt = lm_49(txt, rest); then txt; case ( txt, @@ -1565,12 +1482,12 @@ algorithm local list rest; equation - txt = lm_51(txt, rest); + txt = lm_49(txt, rest); then txt; end matchcontinue; -end lm_51; +end lm_49; -protected function lm_52 +protected function lm_50 input Tpl.Text in_txt; input list in_items; @@ -1593,7 +1510,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_52(txt, rest); + txt = lm_50(txt, rest); then txt; case ( txt, @@ -1601,12 +1518,12 @@ algorithm local list rest; equation - txt = lm_52(txt, rest); + txt = lm_50(txt, rest); then txt; end matchcontinue; -end lm_52; +end lm_50; -protected function lm_53 +protected function lm_51 input Tpl.Text in_txt; input list in_items; @@ -1629,7 +1546,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_53(txt, rest); + txt = lm_51(txt, rest); then txt; case ( txt, @@ -1637,12 +1554,12 @@ algorithm local list rest; equation - txt = lm_53(txt, rest); + txt = lm_51(txt, rest); then txt; end matchcontinue; -end lm_53; +end lm_51; -protected function lm_54 +protected function lm_52 input Tpl.Text in_txt; input list in_items; @@ -1665,7 +1582,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_54(txt, rest); + txt = lm_52(txt, rest); then txt; case ( txt, @@ -1673,12 +1590,12 @@ algorithm local list rest; equation - txt = lm_54(txt, rest); + txt = lm_52(txt, rest); then txt; end matchcontinue; -end lm_54; +end lm_52; -protected function lm_55 +protected function lm_53 input Tpl.Text in_txt; input list in_items; @@ -1701,7 +1618,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_55(txt, rest); + txt = lm_53(txt, rest); then txt; case ( txt, @@ -1709,12 +1626,12 @@ algorithm local list rest; equation - txt = lm_55(txt, rest); + txt = lm_53(txt, rest); then txt; end matchcontinue; -end lm_55; +end lm_53; -protected function lm_56 +protected function lm_54 input Tpl.Text in_txt; input list in_items; @@ -1737,7 +1654,7 @@ algorithm equation txt = DefineVariables(txt, i_var); txt = Tpl.nextIter(txt); - txt = lm_56(txt, rest); + txt = lm_54(txt, rest); then txt; case ( txt, @@ -1745,12 +1662,12 @@ algorithm local list rest; equation - txt = lm_56(txt, rest); + txt = lm_54(txt, rest); then txt; end matchcontinue; -end lm_56; +end lm_54; -protected function lm_57 +protected function lm_55 input Tpl.Text in_txt; input list in_items; @@ -1774,7 +1691,7 @@ algorithm txt = SimCodeC.crefStr(txt, i_name); txt = Tpl.writeTok(txt, Tpl.ST_STRING("_")); txt = Tpl.nextIter(txt); - txt = lm_57(txt, rest); + txt = lm_55(txt, rest); then txt; case ( txt, @@ -1782,10 +1699,10 @@ algorithm local list rest; equation - txt = lm_57(txt, rest); + txt = lm_55(txt, rest); then txt; end matchcontinue; -end lm_57; +end lm_55; public function ModelDefineData input Tpl.Text in_txt; @@ -1867,47 +1784,47 @@ algorithm "// 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_46(txt, i_vars_stateVars); + txt = lm_44(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_47(txt, i_vars_inputVars); + txt = lm_45(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_48(txt, i_vars_outputVars); + txt = lm_46(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_49(txt, i_vars_algVars); + txt = lm_47(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_50(txt, i_vars_paramVars); + txt = lm_48(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_51(txt, i_vars_intAlgVars); + txt = lm_49(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_52(txt, i_vars_intParamVars); + txt = lm_50(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_53(txt, i_vars_boolAlgVars); + txt = lm_51(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_54(txt, i_vars_boolParamVars); + txt = lm_52(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_55(txt, i_vars_stringAlgVars); + txt = lm_53(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_56(txt, i_vars_stringParamVars); + txt = lm_54(txt, i_vars_stringParamVars); txt = Tpl.popIter(txt); txt = Tpl.softNewLine(txt); txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ @@ -1916,7 +1833,7 @@ algorithm "#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_57(txt, i_vars_stateVars); + txt = lm_55(txt, i_vars_stateVars); txt = Tpl.popIter(txt); txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ " }\n", @@ -2073,7 +1990,7 @@ algorithm end matchcontinue; end eventUpdateFunction; -protected function fun_64 +protected function fun_62 input Tpl.Text in_txt; input String in_i_modelInfo_directory; @@ -2098,9 +2015,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); then txt; end matchcontinue; -end fun_64; +end fun_62; -protected function lm_65 +protected function lm_63 input Tpl.Text in_txt; input list in_items; @@ -2123,7 +2040,7 @@ algorithm equation txt = Tpl.writeStr(txt, i_lib); txt = Tpl.nextIter(txt); - txt = lm_65(txt, rest); + txt = lm_63(txt, rest); then txt; case ( txt, @@ -2131,12 +2048,12 @@ algorithm local list rest; equation - txt = lm_65(txt, rest); + txt = lm_63(txt, rest); then txt; end matchcontinue; -end lm_65; +end lm_63; -protected function fun_66 +protected function fun_64 input Tpl.Text in_txt; input String in_it; input Tpl.Text in_i_libsStr; @@ -2161,9 +2078,9 @@ algorithm _ ) then txt; end matchcontinue; -end fun_66; +end fun_64; -protected function fun_67 +protected function fun_65 input Tpl.Text in_txt; input String in_it; input Tpl.Text in_i_libsStr; @@ -2188,7 +2105,7 @@ algorithm txt = Tpl.writeText(txt, i_libsStr); then txt; end matchcontinue; -end fun_67; +end fun_65; public function fmuMakefile input Tpl.Text in_txt; @@ -2223,14 +2140,14 @@ algorithm Tpl.Text i_libsStr; Tpl.Text i_dirExtra; equation - i_dirExtra = fun_64(emptyTxt, i_modelInfo_directory); + i_dirExtra = fun_62(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_65(i_libsStr, i_makefileParams_libs); + i_libsStr = lm_63(i_libsStr, i_makefileParams_libs); i_libsStr = Tpl.popIter(i_libsStr); str_3 = Tpl.textString(i_dirExtra); - i_libsPos1 = fun_66(emptyTxt, str_3, i_libsStr); + i_libsPos1 = fun_64(emptyTxt, str_3, i_libsStr); str_5 = Tpl.textString(i_dirExtra); - i_libsPos2 = fun_67(emptyTxt, str_5, i_libsStr); + i_libsPos2 = fun_65(emptyTxt, str_5, i_libsStr); txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ "# Makefile generated by OpenModelica\n", "\n", diff --git a/Compiler/susan_codegen/SimCode/SimCodeFMU.tpl b/Compiler/susan_codegen/SimCode/SimCodeFMU.tpl index 00a54be2d39..daab7565b6f 100644 --- a/Compiler/susan_codegen/SimCode/SimCodeFMU.tpl +++ b/Compiler/susan_codegen/SimCode/SimCodeFMU.tpl @@ -193,46 +193,40 @@ case MODELINFO(vars=SIMVARS(__)) then << <%vars.stateVars |> var => - ScalarVariable(var,"internal",0) + ScalarVariable(var,"internal",1) ;separator="\n"%> <%vars.derivativeVars |> var => - ScalarVariable(var,"internal",10000) - ;separator="\n"%> - <%vars.inputVars |> var => - ScalarVariable(var,"input",100000) - ;separator="\n"%> - <%vars.outputVars |> var => - ScalarVariable(var,"output",200000) + ScalarVariable(var,"internal",2) ;separator="\n"%> <%vars.algVars |> var => - ScalarVariable(var,"internal",1000000) + ScalarVariable(var,"internal",3) ;separator="\n"%> <%vars.paramVars |> var => - ScalarVariable(var,"internal",5000000) + ScalarVariable(var,"internal",4) ;separator="\n"%> <%vars.intAlgVars |> var => - ScalarVariable(var,"internal",0) + ScalarVariable(var,"internal",1) ;separator="\n"%> <%vars.intParamVars |> var => - ScalarVariable(var,"internal",1000000) + ScalarVariable(var,"internal",2) ;separator="\n"%> <%vars.boolAlgVars |> var => - ScalarVariable(var,"internal",0) + ScalarVariable(var,"internal",1) ;separator="\n"%> <%vars.boolParamVars |> var => - ScalarVariable(var,"internal",1000000) + ScalarVariable(var,"internal",2) ;separator="\n"%> <%vars.stringAlgVars |> var => - ScalarVariable(var,"internal",0) + ScalarVariable(var,"internal",1) ;separator="\n"%> <%vars.stringParamVars |> var => - ScalarVariable(var,"internal",1000000) + ScalarVariable(var,"internal",2) ;separator="\n"%> >> end ModelVariables; -template ScalarVariable(SimVar simVar, String causality, Integer offset) +template ScalarVariable(SimVar simVar, String causality, String offset) "Generates code for ScalarVariable file for FMU target." ::= match simVar @@ -245,12 +239,12 @@ case SIMVAR(__) then >> end ScalarVariable; -template ScalarVariableAttribute(SimVar simVar, String causality, Integer offset) +template ScalarVariableAttribute(SimVar simVar, String causality, String offset) "Generates code for ScalarVariable Attribute file for FMU target." ::= match simVar case SIMVAR(__) then - let valueReference = intAdd(index,offset) + let valueReference = '<%offset%><%index%>' let variability = getVariablity(varKind) let description = if comment then 'description="<%comment%>"' let alias = 'noAlias' //TODO get the right information about alias {noAlias,alias,negatedAlias}