build_cmake/OMCompiler/Compiler/generated-mo/Template/CodegenFMUCpp.mo
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | encapsulated package CodegenFMUCpp | ||
| 2 | " | ||
| 3 | file: CodegenFMUCpp.mo | ||
| 4 | package: CodegenFMUCpp | ||
| 5 | description: Generated by Susan. | ||
| 6 | " | ||
| 7 | |||
| 8 | public import Tpl; | ||
| 9 | |||
| 10 | public import SimCodeVar; | ||
| 11 | public import HashTableCrefSimVar; | ||
| 12 | public import SimCode; | ||
| 13 | public import SimCodeFunction; | ||
| 14 | public import SimCodeCodegenUtil; | ||
| 15 | public import SimCodeFunctionUtil; | ||
| 16 | public import BackendDAE; | ||
| 17 | public import System; | ||
| 18 | public import Autoconf; | ||
| 19 | protected import Absyn; | ||
| 20 | protected import AbsynUtil; | ||
| 21 | public import MMath; | ||
| 22 | public import DAE; | ||
| 23 | public import ClassInf; | ||
| 24 | public import ClassInfUtil; | ||
| 25 | protected import SCode; | ||
| 26 | protected import SCodeDump; | ||
| 27 | public import StringUtil; | ||
| 28 | public import Util; | ||
| 29 | public import List; | ||
| 30 | public import ComponentReferenceBasics; | ||
| 31 | public import ComponentReference; | ||
| 32 | public import Expression; | ||
| 33 | protected import ExpressionDump; | ||
| 34 | public import ExpressionBasics; | ||
| 35 | public import Config; | ||
| 36 | public import Testsuite; | ||
| 37 | public import Flags; | ||
| 38 | public import FlagsUtil; | ||
| 39 | public import Settings; | ||
| 40 | public import Patternm; | ||
| 41 | public import Error; | ||
| 42 | public import Values; | ||
| 43 | public import ValuesUtil; | ||
| 44 | public import DAEDump; | ||
| 45 | public import Algorithm; | ||
| 46 | protected import ElementSource; | ||
| 47 | public import DAEUtil; | ||
| 48 | public import TypesDump; | ||
| 49 | public import Types; | ||
| 50 | public import HashTableCrIListArray; | ||
| 51 | public import BackendVariable; | ||
| 52 | public import HpcOmSimCode; | ||
| 53 | public import HpcOmCodegenUtil; | ||
| 54 | public import FMI; | ||
| 55 | public import CodegenUtil; | ||
| 56 | public import CodegenCpp; | ||
| 57 | public import CodegenCppCommon; | ||
| 58 | protected import CodegenFMUModelDescription; | ||
| 59 | protected import CodegenCppInit; | ||
| 60 | protected import CodegenFMUCommon; | ||
| 61 | protected import CodegenFMU2; | ||
| 62 | |||
| 63 | protected function fun_54 | ||
| 64 | input Tpl.Text in_txt; | ||
| 65 | input Boolean in_mArg; | ||
| 66 | input Tpl.Text in_a_stateDerVectorName; | ||
| 67 | input Tpl.Text in_a_complexStartExpressions; | ||
| 68 | input Tpl.Text in_a_numStringVars; | ||
| 69 | input Tpl.Text in_a_numBoolVars; | ||
| 70 | input Tpl.Text in_a_numIntVars; | ||
| 71 | input Tpl.Text in_a_numRealVars; | ||
| 72 | input list<String> in_a_sourceFiles; | ||
| 73 | input String in_a_FMUType; | ||
| 74 | input String in_a_FMUVersion; | ||
| 75 | input Tpl.Text in_a_guid; | ||
| 76 | input SimCode.SimCode in_a_simCode; | ||
| 77 | |||
| 78 | output Tpl.Text out_txt; | ||
| 79 | output Tpl.Text out_a_stateDerVectorName; | ||
| 80 | output Tpl.Text out_a_complexStartExpressions; | ||
| 81 | algorithm | ||
| 82 | (out_txt, out_a_stateDerVectorName, out_a_complexStartExpressions) := | ||
| 83 | match(in_txt, in_mArg, in_a_stateDerVectorName, in_a_complexStartExpressions, in_a_numStringVars, in_a_numBoolVars, in_a_numIntVars, in_a_numRealVars, in_a_sourceFiles, in_a_FMUType, in_a_FMUVersion, in_a_guid, in_a_simCode) | ||
| 84 | local | ||
| 85 | Tpl.Text txt; | ||
| 86 | Tpl.Text a_stateDerVectorName; | ||
| 87 | Tpl.Text a_complexStartExpressions; | ||
| 88 | Tpl.Text a_numStringVars; | ||
| 89 | Tpl.Text a_numBoolVars; | ||
| 90 | Tpl.Text a_numIntVars; | ||
| 91 | Tpl.Text a_numRealVars; | ||
| 92 | list<String> a_sourceFiles; | ||
| 93 | String a_FMUType; | ||
| 94 | String a_FMUVersion; | ||
| 95 | Tpl.Text a_guid; | ||
| 96 | SimCode.SimCode a_simCode; | ||
| 97 | |||
| 98 | case ( txt, | ||
| 99 | false, | ||
| 100 | a_stateDerVectorName, | ||
| 101 | a_complexStartExpressions, | ||
| 102 | _, | ||
| 103 | _, | ||
| 104 | _, | ||
| 105 | _, | ||
| 106 | a_sourceFiles, | ||
| 107 | a_FMUType, | ||
| 108 | a_FMUVersion, | ||
| 109 | a_guid, | ||
| 110 | a_simCode ) | ||
| 111 | algorithm | ||
| 112 | 8 | txt := CodegenFMUModelDescription.fmuModelDescriptionFile(txt, a_simCode, Tpl.textString(a_guid), a_FMUVersion, a_FMUType, a_sourceFiles); | |
| 113 | 8 | then (txt, a_stateDerVectorName, a_complexStartExpressions); | |
| 114 | |||
| 115 | case ( txt, | ||
| 116 | _, | ||
| 117 | a_stateDerVectorName, | ||
| 118 | a_complexStartExpressions, | ||
| 119 | a_numStringVars, | ||
| 120 | a_numBoolVars, | ||
| 121 | a_numIntVars, | ||
| 122 | a_numRealVars, | ||
| 123 | _, | ||
| 124 | a_FMUType, | ||
| 125 | a_FMUVersion, | ||
| 126 | a_guid, | ||
| 127 | a_simCode ) | ||
| 128 | algorithm | ||
| 129 | 1 | (txt, a_complexStartExpressions, a_stateDerVectorName) := CodegenCppInit.modelInitXMLFile(txt, a_simCode, Tpl.textString(a_numRealVars), Tpl.textString(a_numIntVars), Tpl.textString(a_numBoolVars), Tpl.textString(a_numStringVars), a_FMUVersion, a_FMUType, Tpl.textString(a_guid), true, "cpp-runtime", a_complexStartExpressions, a_stateDerVectorName); | |
| 130 | 1 | then (txt, a_stateDerVectorName, a_complexStartExpressions); | |
| 131 | end match; | ||
| 132 | end fun_54; | ||
| 133 | |||
| 134 | public function translateModel | ||
| 135 | input Tpl.Text in_txt; | ||
| 136 | input SimCode.SimCode in_a_simCode; | ||
| 137 | input String in_a_FMUVersion; | ||
| 138 | input String in_a_FMUType; | ||
| 139 | input list<String> in_a_sourceFiles; | ||
| 140 | |||
| 141 | output Tpl.Text out_txt; | ||
| 142 | algorithm | ||
| 143 | out_txt := | ||
| 144 | match(in_txt, in_a_simCode, in_a_FMUVersion, in_a_FMUType, in_a_sourceFiles) | ||
| 145 | local | ||
| 146 | Tpl.Text txt; | ||
| 147 | String a_FMUVersion; | ||
| 148 | String a_FMUType; | ||
| 149 | list<String> a_sourceFiles; | ||
| 150 | String i_fileNamePrefix; | ||
| 151 | SimCode.SimCode i_simCode; | ||
| 152 | SimCode.ModelInfo i_modelInfo; | ||
| 153 | Boolean ret_32; | ||
| 154 | Tpl.Text l_0___1; | ||
| 155 | Tpl.Text txt_30; | ||
| 156 | Tpl.Text txt_29; | ||
| 157 | Tpl.Text txt_28; | ||
| 158 | Tpl.Text txt_27; | ||
| 159 | Tpl.Text txt_26; | ||
| 160 | Tpl.Text txt_25; | ||
| 161 | Tpl.Text txt_23; | ||
| 162 | Boolean ret_23; | ||
| 163 | Tpl.Text txt_22; | ||
| 164 | Tpl.Text txt_21; | ||
| 165 | Tpl.Text txt_20; | ||
| 166 | Tpl.Text txt_19; | ||
| 167 | Tpl.Text txt_18; | ||
| 168 | Tpl.Text txt_17; | ||
| 169 | Tpl.Text l_cpp; | ||
| 170 | Boolean ret_15; | ||
| 171 | Tpl.Text l_0__; | ||
| 172 | String ret_13; | ||
| 173 | Tpl.Text l_extraAnnotations; | ||
| 174 | Tpl.Text l_numStringVars; | ||
| 175 | Tpl.Text l_numBoolVars; | ||
| 176 | Tpl.Text l_numIntVars; | ||
| 177 | Tpl.Text l_numRealVars; | ||
| 178 | Tpl.Text l_complexStartExpressions; | ||
| 179 | Tpl.Text l_extraFuncsDecl; | ||
| 180 | Tpl.Text l_extraFuncs; | ||
| 181 | Tpl.Text l_stateDerVectorName; | ||
| 182 | String ret_3; | ||
| 183 | Tpl.Text l_target; | ||
| 184 | String ret_1; | ||
| 185 | Tpl.Text l_guid; | ||
| 186 | |||
| 187 | case ( txt, | ||
| 188 | (i_simCode as SimCode.SIMCODE(modelInfo = (i_modelInfo as SimCode.MODELINFO(name = _)), fileNamePrefix = i_fileNamePrefix)), | ||
| 189 | a_FMUVersion, | ||
| 190 | a_FMUType, | ||
| 191 | a_sourceFiles ) | ||
| 192 | algorithm | ||
| 193 | 9 | ret_1 := System.getUUIDStr(); | |
| 194 | 9 | l_guid := Tpl.writeStr(Tpl.emptyTxt, ret_1); | |
| 195 | 9 | ret_3 := Config.simulationCodeTarget(); | |
| 196 | 9 | l_target := Tpl.writeStr(Tpl.emptyTxt, ret_3); | |
| 197 | 9 | l_stateDerVectorName := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("__zDot")); | |
| 198 | 9 | l_extraFuncs := Tpl.emptyTxt; | |
| 199 | 9 | l_extraFuncsDecl := Tpl.emptyTxt; | |
| 200 | 9 | l_complexStartExpressions := Tpl.emptyTxt; | |
| 201 | 9 | l_numRealVars := CodegenCpp.numRealvars(Tpl.emptyTxt, i_modelInfo); | |
| 202 | 9 | l_numIntVars := CodegenCpp.numIntvars(Tpl.emptyTxt, i_modelInfo); | |
| 203 | 9 | l_numBoolVars := CodegenCpp.numBoolvars(Tpl.emptyTxt, i_modelInfo); | |
| 204 | 9 | l_numStringVars := CodegenCpp.numStringvars(Tpl.emptyTxt, i_modelInfo); | |
| 205 | 9 | ret_13 := Flags.getConfigString(Flags.FMI_EXTRA_ANNOTATIONS); | |
| 206 | 9 | l_extraAnnotations := Tpl.writeStr(Tpl.emptyTxt, ret_13); | |
| 207 | 9 | ret_15 := FlagsUtil.set(Flags.HARDCODED_START_VALUES, true); | |
| 208 | 9 | l_0__ := Tpl.writeStr(Tpl.emptyTxt, Tpl.booleanString(ret_15)); | |
| 209 | 9 | l_cpp := CodegenCpp.translateModel(Tpl.emptyTxt, i_simCode); | |
| 210 | 9 | (txt_17, l_extraFuncs, l_extraFuncsDecl, _) := fmuWriteOutputHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING(""))); | |
| 211 | 9 | txt_18 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp")); | |
| 212 | 9 | txt_18 := Tpl.writeStr(txt_18, i_fileNamePrefix); | |
| 213 | 9 | txt_18 := Tpl.writeTok(txt_18, Tpl.ST_STRING("WriteOutput.h")); | |
| 214 | 9 | Tpl.textFile(txt_17, Tpl.textString(txt_18)); | |
| 215 | 9 | (txt_19, l_extraFuncs, l_extraFuncsDecl, _) := fmuModelHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.textString(l_guid), a_FMUVersion); | |
| 216 | 9 | txt_20 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp")); | |
| 217 | 9 | txt_20 := Tpl.writeStr(txt_20, i_fileNamePrefix); | |
| 218 | 9 | txt_20 := Tpl.writeTok(txt_20, Tpl.ST_STRING("FMU.h")); | |
| 219 | 9 | Tpl.textFile(txt_19, Tpl.textString(txt_20)); | |
| 220 | 9 | (txt_21, l_extraFuncs, l_extraFuncsDecl, _) := fmuModelCppFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.textString(l_guid), a_FMUVersion); | |
| 221 | 9 | txt_22 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp")); | |
| 222 | 9 | txt_22 := Tpl.writeStr(txt_22, i_fileNamePrefix); | |
| 223 | 9 | txt_22 := Tpl.writeTok(txt_22, Tpl.ST_STRING("FMU.cpp")); | |
| 224 | 9 | Tpl.textFile(txt_21, Tpl.textString(txt_22)); | |
| 225 | 9 | ret_23 := FMI.isFMIVersion10(a_FMUVersion); | |
| 226 | 9 | (txt_23, l_stateDerVectorName, l_complexStartExpressions) := fun_54(Tpl.emptyTxt, ret_23, l_stateDerVectorName, l_complexStartExpressions, l_numStringVars, l_numBoolVars, l_numIntVars, l_numRealVars, a_sourceFiles, a_FMUType, a_FMUVersion, l_guid, i_simCode); | |
| 227 | 9 | Tpl.textFile(txt_23, "modelDescription.xml"); | |
| 228 | 9 | txt_25 := CodegenFMUCommon.fmudeffile(Tpl.emptyTxt, i_simCode, a_FMUVersion); | |
| 229 | 9 | txt_26 := Tpl.writeStr(Tpl.emptyTxt, i_fileNamePrefix); | |
| 230 | 9 | txt_26 := Tpl.writeTok(txt_26, Tpl.ST_STRING(".def")); | |
| 231 | 9 | Tpl.textFile(txt_25, Tpl.textString(txt_26)); | |
| 232 | 9 | (txt_27, l_extraFuncs, l_extraFuncsDecl, _) := fmuMakefile(Tpl.emptyTxt, Tpl.textString(l_target), i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), a_FMUVersion, "", "", "", "", Tpl.textString(l_extraAnnotations)); | |
| 233 | 9 | txt_28 := Tpl.writeStr(Tpl.emptyTxt, i_fileNamePrefix); | |
| 234 | 9 | txt_28 := Tpl.writeTok(txt_28, Tpl.ST_STRING("_FMU.makefile")); | |
| 235 | 9 | Tpl.textFile(txt_27, Tpl.textString(txt_28)); | |
| 236 | 9 | txt_29 := fmuCalcHelperMainfile(Tpl.emptyTxt, i_simCode); | |
| 237 | 9 | txt_30 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp")); | |
| 238 | 9 | txt_30 := Tpl.writeStr(txt_30, i_fileNamePrefix); | |
| 239 | 9 | txt_30 := Tpl.writeTok(txt_30, Tpl.ST_STRING("CalcHelperMain.cpp")); | |
| 240 | 9 | Tpl.textFile(txt_29, Tpl.textString(txt_30)); | |
| 241 | 9 | ret_32 := FlagsUtil.set(Flags.HARDCODED_START_VALUES, false); | |
| 242 | 9 | l_0___1 := Tpl.writeStr(Tpl.emptyTxt, Tpl.booleanString(ret_32)); | |
| 243 | then txt; | ||
| 244 | |||
| 245 | case ( txt, | ||
| 246 | _, | ||
| 247 | _, | ||
| 248 | _, | ||
| 249 | _ ) | ||
| 250 | then txt; | ||
| 251 | end match; | ||
| 252 | end translateModel; | ||
| 253 | |||
| 254 | protected function fun_56 | ||
| 255 | input Tpl.Text in_txt; | ||
| 256 | input Boolean in_mArg; | ||
| 257 | input String in_a_fileNamePrefix; | ||
| 258 | |||
| 259 | output Tpl.Text out_txt; | ||
| 260 | algorithm | ||
| 261 | out_txt := | ||
| 262 | match(in_txt, in_mArg, in_a_fileNamePrefix) | ||
| 263 | local | ||
| 264 | Tpl.Text txt; | ||
| 265 | String a_fileNamePrefix; | ||
| 266 | |||
| 267 | case ( txt, | ||
| 268 | false, | ||
| 269 | _ ) | ||
| 270 | then txt; | ||
| 271 | |||
| 272 | case ( txt, | ||
| 273 | _, | ||
| 274 | a_fileNamePrefix ) | ||
| 275 | algorithm | ||
| 276 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include \"OMCpp")); | |
| 277 | 9 | txt := Tpl.writeStr(txt, a_fileNamePrefix); | |
| 278 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 279 | "InitializeParameter.cpp\"\n", | ||
| 280 | "#include \"OMCpp" | ||
| 281 | }, false)); | ||
| 282 | 9 | txt := Tpl.writeStr(txt, a_fileNamePrefix); | |
| 283 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("InitializeAlgVars.cpp\"")); | |
| 284 | then txt; | ||
| 285 | end match; | ||
| 286 | end fun_56; | ||
| 287 | |||
| 288 | public function fmuCalcHelperMainfile | ||
| 289 | input Tpl.Text in_txt; | ||
| 290 | input SimCode.SimCode in_a_simCode; | ||
| 291 | |||
| 292 | output Tpl.Text out_txt; | ||
| 293 | algorithm | ||
| 294 | out_txt := | ||
| 295 | match(in_txt, in_a_simCode) | ||
| 296 | local | ||
| 297 | Tpl.Text txt; | ||
| 298 | String i_fileNamePrefix; | ||
| 299 | Boolean ret_2; | ||
| 300 | Boolean ret_1; | ||
| 301 | Boolean ret_0; | ||
| 302 | |||
| 303 | case ( txt, | ||
| 304 | SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(name = _), fileNamePrefix = i_fileNamePrefix) ) | ||
| 305 | algorithm | ||
| 306 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 307 | "/*****************************************************************************\n", | ||
| 308 | "*\n", | ||
| 309 | "* Helper file that includes all generated calculation files, except the alg loops.\n", | ||
| 310 | "* This file is generated by the OpenModelica Compiler and produced to speed-up the compile time.\n", | ||
| 311 | "*\n", | ||
| 312 | "*****************************************************************************/\n", | ||
| 313 | "#include <Core/ModelicaDefine.h>\n", | ||
| 314 | "#include <Core/Modelica.h>\n", | ||
| 315 | "#include <Core/System/FactoryExport.h>\n", | ||
| 316 | "#include <Core/DataExchange/SimData.h>\n", | ||
| 317 | "#include <Core/System/SimVars.h>\n", | ||
| 318 | "#include <Core/System/DiscreteEvents.h>\n", | ||
| 319 | "#include <Core/System/EventHandling.h>\n", | ||
| 320 | "#include <Core/Utils/extension/logger.hpp>\n", | ||
| 321 | "\n", | ||
| 322 | "#include \"OMCpp" | ||
| 323 | }, false)); | ||
| 324 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 325 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 326 | "Types.h\"\n", | ||
| 327 | "#include \"OMCpp" | ||
| 328 | }, false)); | ||
| 329 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 330 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 331 | "Functions.h\"\n", | ||
| 332 | "#include \"OMCpp" | ||
| 333 | }, false)); | ||
| 334 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 335 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 336 | ".h\"\n", | ||
| 337 | "\n", | ||
| 338 | "#include \"OMCpp" | ||
| 339 | }, false)); | ||
| 340 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 341 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 342 | "Jacobian.h\"\n", | ||
| 343 | "#include \"OMCpp" | ||
| 344 | }, false)); | ||
| 345 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 346 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 347 | "Mixed.h\"\n", | ||
| 348 | "#include \"OMCpp" | ||
| 349 | }, false)); | ||
| 350 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 351 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 352 | "StateSelection.h\"\n", | ||
| 353 | "#include \"OMCpp" | ||
| 354 | }, false)); | ||
| 355 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 356 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 357 | "WriteOutput.h\"\n", | ||
| 358 | "#include \"OMCpp" | ||
| 359 | }, false)); | ||
| 360 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 361 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 362 | "Initialize.h\"\n", | ||
| 363 | "\n", | ||
| 364 | "#include \"OMCpp" | ||
| 365 | }, false)); | ||
| 366 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 367 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 368 | "FMU.h\"\n", | ||
| 369 | "\n", | ||
| 370 | "#include \"OMCpp" | ||
| 371 | }, false)); | ||
| 372 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 373 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 374 | "AlgLoopMain.cpp\"\n", | ||
| 375 | "#include \"OMCpp" | ||
| 376 | }, false)); | ||
| 377 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 378 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 379 | "Mixed.cpp\"\n", | ||
| 380 | "#include \"OMCpp" | ||
| 381 | }, false)); | ||
| 382 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 383 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("Functions.cpp\"\n")); | |
| 384 | 9 | ret_0 := Flags.isSet(Flags.HARDCODED_START_VALUES); | |
| 385 | 9 | ret_1 := Flags.isSet(Flags.GEN_DEBUG_SYMBOLS); | |
| 386 | 9 | ret_2 := boolOr(ret_0, ret_1); | |
| 387 | 9 | txt := fun_56(txt, ret_2, i_fileNamePrefix); | |
| 388 | 9 | txt := Tpl.softNewLine(txt); | |
| 389 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include \"OMCpp")); | |
| 390 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 391 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 392 | "Initialize.cpp\"\n", | ||
| 393 | "#include \"OMCpp" | ||
| 394 | }, false)); | ||
| 395 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 396 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 397 | "Jacobian.cpp\"\n", | ||
| 398 | "#include \"OMCpp" | ||
| 399 | }, false)); | ||
| 400 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 401 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 402 | "StateSelection.cpp\"\n", | ||
| 403 | "#include \"OMCpp" | ||
| 404 | }, false)); | ||
| 405 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 406 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 407 | ".cpp\"\n", | ||
| 408 | "#include \"OMCpp" | ||
| 409 | }, false)); | ||
| 410 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 411 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("FMU.cpp\"")); | |
| 412 | then txt; | ||
| 413 | |||
| 414 | case ( txt, | ||
| 415 | _ ) | ||
| 416 | then txt; | ||
| 417 | end match; | ||
| 418 | end fmuCalcHelperMainfile; | ||
| 419 | |||
| 420 | protected function fun_58 | ||
| 421 | input Tpl.Text in_txt; | ||
| 422 | input SimCode.SimCode in_a_simCode; | ||
| 423 | |||
| 424 | output Tpl.Text out_txt; | ||
| 425 | algorithm | ||
| 426 | out_txt := | ||
| 427 | match(in_txt, in_a_simCode) | ||
| 428 | local | ||
| 429 | Tpl.Text txt; | ||
| 430 | Absyn.Path i_modelInfo_name; | ||
| 431 | |||
| 432 | case ( txt, | ||
| 433 | SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(name = i_modelInfo_name), simulationSettingsOpt = SOME(SimCode.SIMULATION_SETTINGS(startTime = _))) ) | ||
| 434 | algorithm | ||
| 435 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 436 | "#pragma once\n", | ||
| 437 | "\n", | ||
| 438 | "// Dummy code for FMU that writes no output file\n", | ||
| 439 | "class " | ||
| 440 | }, false)); | ||
| 441 | 9 | txt := CodegenCpp.lastIdentOfPath(txt, i_modelInfo_name); | |
| 442 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("WriteOutput : public IWriteOutput,public ")); | |
| 443 | 9 | txt := CodegenCpp.lastIdentOfPath(txt, i_modelInfo_name); | |
| 444 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 445 | "StateSelection\n", | ||
| 446 | "{\n", | ||
| 447 | " public:\n" | ||
| 448 | }, true)); | ||
| 449 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 450 | 9 | txt := CodegenCpp.lastIdentOfPath(txt, i_modelInfo_name); | |
| 451 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("WriteOutput(IGlobalSettings* globalSettings, shared_ptr<ISimObjects> simObjects): ")); | |
| 452 | 9 | txt := CodegenCpp.lastIdentOfPath(txt, i_modelInfo_name); | |
| 453 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 454 | "StateSelection(globalSettings, simObjects) {}\n", | ||
| 455 | "virtual ~" | ||
| 456 | }, false)); | ||
| 457 | 9 | txt := CodegenCpp.lastIdentOfPath(txt, i_modelInfo_name); | |
| 458 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 459 | "WriteOutput() {}\n", | ||
| 460 | "\n", | ||
| 461 | "virtual void writeOutput(const IWriteOutput::OUTPUT command = IWriteOutput::UNDEF_OUTPUT) {}\n", | ||
| 462 | "virtual IHistory* getHistory() {return NULL;}\n", | ||
| 463 | "\n" | ||
| 464 | }, true)); | ||
| 465 | 9 | txt := Tpl.popBlock(txt); | |
| 466 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 467 | " protected:\n", | ||
| 468 | " void initialize() {}\n", | ||
| 469 | "};" | ||
| 470 | }, false)); | ||
| 471 | then txt; | ||
| 472 | |||
| 473 | case ( txt, | ||
| 474 | _ ) | ||
| 475 | then txt; | ||
| 476 | end match; | ||
| 477 | end fun_58; | ||
| 478 | |||
| 479 | public function fmuWriteOutputHeaderFile | ||
| 480 | input Tpl.Text txt; | ||
| 481 | input SimCode.SimCode a_simCode; | ||
| 482 | input Tpl.Text a_extraFuncs; | ||
| 483 | input Tpl.Text a_extraFuncsDecl; | ||
| 484 | input Tpl.Text a_extraFuncsNamespace; | ||
| 485 | |||
| 486 | output Tpl.Text out_txt; | ||
| 487 | output Tpl.Text out_a_extraFuncs; | ||
| 488 | output Tpl.Text out_a_extraFuncsDecl; | ||
| 489 | output Tpl.Text out_a_extraFuncsNamespace; | ||
| 490 | algorithm | ||
| 491 | 9 | out_txt := fun_58(txt, a_simCode); | |
| 492 | out_a_extraFuncs := a_extraFuncs; | ||
| 493 | out_a_extraFuncsDecl := a_extraFuncsDecl; | ||
| 494 | out_a_extraFuncsNamespace := a_extraFuncsNamespace; | ||
| 495 | end fmuWriteOutputHeaderFile; | ||
| 496 | |||
| 497 | protected function fun_60 | ||
| 498 | input Tpl.Text in_txt; | ||
| 499 | input SimCode.SimCode in_a_simCode; | ||
| 500 | |||
| 501 | output Tpl.Text out_txt; | ||
| 502 | algorithm | ||
| 503 | out_txt := | ||
| 504 | match(in_txt, in_a_simCode) | ||
| 505 | local | ||
| 506 | Tpl.Text txt; | ||
| 507 | Absyn.Path i_modelInfo_name; | ||
| 508 | Tpl.Text l_modelShortName; | ||
| 509 | |||
| 510 | case ( txt, | ||
| 511 | SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(name = i_modelInfo_name)) ) | ||
| 512 | algorithm | ||
| 513 | 9 | l_modelShortName := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, i_modelInfo_name); | |
| 514 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 515 | "// declaration for Cpp FMU target\n", | ||
| 516 | "\n", | ||
| 517 | "class " | ||
| 518 | }, false)); | ||
| 519 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 520 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("FMU: public ")); | |
| 521 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 522 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 523 | "Initialize {\n", | ||
| 524 | " public:\n", | ||
| 525 | " // constructor\n" | ||
| 526 | }, true)); | ||
| 527 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 528 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 529 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 530 | "FMU(IGlobalSettings* globalSettings, shared_ptr<ISimObjects> simObjects);\n", | ||
| 531 | "\n", | ||
| 532 | "// initialization\n", | ||
| 533 | "virtual void initialize();\n", | ||
| 534 | "\n", | ||
| 535 | "// getters for given value references\n", | ||
| 536 | "virtual void getReal(const unsigned int vr[], size_t nvr, double value[]);\n", | ||
| 537 | "virtual void getInteger(const unsigned int vr[], size_t nvr, int value[]);\n", | ||
| 538 | "virtual void getBoolean(const unsigned int vr[], size_t nvr, int value[]);\n", | ||
| 539 | "virtual void getString(const unsigned int vr[], size_t nvr, string value[]);\n", | ||
| 540 | "\n", | ||
| 541 | "// setters for given value references\n", | ||
| 542 | "virtual void setReal(const unsigned int vr[], size_t nvr, const double value[]);\n", | ||
| 543 | "virtual void setInteger(const unsigned int vr[], size_t nvr, const int value[]);\n", | ||
| 544 | "virtual void setBoolean(const unsigned int vr[], size_t nvr, const int value[]);\n", | ||
| 545 | "virtual void setString(const unsigned int vr[], size_t nvr, const string value[]);\n", | ||
| 546 | "\n", | ||
| 547 | "// Jacobian\n", | ||
| 548 | "void getDirectionalDerivative(const unsigned int vrUnknown[], size_t nUnknown,\n", | ||
| 549 | " const unsigned int vrKnown[], size_t nKnown,\n", | ||
| 550 | " const double dvKnown[], double dvUnknown[]);\n", | ||
| 551 | "\n" | ||
| 552 | }, true)); | ||
| 553 | 9 | txt := Tpl.popBlock(txt); | |
| 554 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 555 | " protected:\n", | ||
| 556 | " static unsigned int _inputRefs[]; ///< Value references of input variables\n", | ||
| 557 | " static unsigned int _outputRefs[]; ///< Value references of discrete states and outputs\n", | ||
| 558 | "};\n", | ||
| 559 | "\n", | ||
| 560 | "/// create instance of " | ||
| 561 | }, false)); | ||
| 562 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 563 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 564 | "FMU\n", | ||
| 565 | "static " | ||
| 566 | }, false)); | ||
| 567 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 568 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("FMU *createSystemFMU(IGlobalSettings *globalSettings);")); | |
| 569 | then txt; | ||
| 570 | |||
| 571 | case ( txt, | ||
| 572 | _ ) | ||
| 573 | then txt; | ||
| 574 | end match; | ||
| 575 | end fun_60; | ||
| 576 | |||
| 577 | public function fmuModelHeaderFile | ||
| 578 | input Tpl.Text txt; | ||
| 579 | input SimCode.SimCode a_simCode; | ||
| 580 | input Tpl.Text a_extraFuncs; | ||
| 581 | input Tpl.Text a_extraFuncsDecl; | ||
| 582 | input Tpl.Text a_extraFuncsNamespace; | ||
| 583 | input String a_guid; | ||
| 584 | input String a_FMUVersion; | ||
| 585 | |||
| 586 | output Tpl.Text out_txt; | ||
| 587 | output Tpl.Text out_a_extraFuncs; | ||
| 588 | output Tpl.Text out_a_extraFuncsDecl; | ||
| 589 | output Tpl.Text out_a_extraFuncsNamespace; | ||
| 590 | algorithm | ||
| 591 | 9 | out_txt := fun_60(txt, a_simCode); | |
| 592 | out_a_extraFuncs := a_extraFuncs; | ||
| 593 | out_a_extraFuncsDecl := a_extraFuncsDecl; | ||
| 594 | out_a_extraFuncsNamespace := a_extraFuncsNamespace; | ||
| 595 | end fmuModelHeaderFile; | ||
| 596 | |||
| 597 | protected function lm_62 | ||
| 598 | input output Tpl.Text txt; | ||
| 599 | input list<SimCode.SimEqSystem> items; | ||
| 600 | input Tpl.Text a_modelShortName; | ||
| 601 | input output Tpl.Text a_extraFuncsNamespace; | ||
| 602 | input output Tpl.Text a_extraFuncsDecl; | ||
| 603 | input output Tpl.Text a_extraFuncs; | ||
| 604 | input SimCode.SimCode a_simCode; | ||
| 605 | algorithm | ||
| 606 |
2/2✓ Branch 0 taken 222 times.
✓ Branch 1 taken 9 times.
|
231 | for lstElt_62 in items loop |
| 607 | (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs) := match lstElt_62 | ||
| 608 | local | ||
| 609 | SimCode.SimEqSystem i_eqs; | ||
| 610 | |||
| 611 | case i_eqs | ||
| 612 | algorithm | ||
| 613 | 222 | (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := CodegenCpp.algloopMainfile2(txt, i_eqs, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, Tpl.textString(a_modelShortName)); | |
| 614 | 222 | txt := Tpl.nextIter(txt); | |
| 615 | then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs); | ||
| 616 | end match; | ||
| 617 | end for; | ||
| 618 | end lm_62; | ||
| 619 | |||
| 620 | protected function fun_63 | ||
| 621 | input Tpl.Text in_txt; | ||
| 622 | input String in_mArg; | ||
| 623 | |||
| 624 | output Tpl.Text out_txt; | ||
| 625 | algorithm | ||
| 626 | out_txt := | ||
| 627 | match(in_txt, in_mArg) | ||
| 628 | local | ||
| 629 | Tpl.Text txt; | ||
| 630 | |||
| 631 | case ( txt, | ||
| 632 | "" ) | ||
| 633 | then txt; | ||
| 634 | |||
| 635 | case ( txt, | ||
| 636 | _ ) | ||
| 637 | algorithm | ||
| 638 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("createStaticAlgLoopSolverFactory(globalSettings, PATH(\"\"), PATH(\"\"))")); | |
| 639 | then txt; | ||
| 640 | end match; | ||
| 641 | end fun_63; | ||
| 642 | |||
| 643 | protected function fun_64 | ||
| 644 | input Tpl.Text in_txt; | ||
| 645 | input Boolean in_mArg; | ||
| 646 | |||
| 647 | output Tpl.Text out_txt; | ||
| 648 | algorithm | ||
| 649 | out_txt := | ||
| 650 | match(in_txt, in_mArg) | ||
| 651 | local | ||
| 652 | Tpl.Text txt; | ||
| 653 | |||
| 654 | case ( txt, | ||
| 655 | false ) | ||
| 656 | algorithm | ||
| 657 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include \"FMU2/FMU2Wrapper.cpp\"")); | |
| 658 | then txt; | ||
| 659 | |||
| 660 | case ( txt, | ||
| 661 | _ ) | ||
| 662 | algorithm | ||
| 663 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include \"FMU3/FMU3Wrapper.cpp\"")); | |
| 664 | then txt; | ||
| 665 | end match; | ||
| 666 | end fun_64; | ||
| 667 | |||
| 668 | protected function fun_65 | ||
| 669 | input Tpl.Text in_txt; | ||
| 670 | input Boolean in_mArg; | ||
| 671 | input String in_a_FMUVersion; | ||
| 672 | |||
| 673 | output Tpl.Text out_txt; | ||
| 674 | algorithm | ||
| 675 | out_txt := | ||
| 676 | match(in_txt, in_mArg, in_a_FMUVersion) | ||
| 677 | local | ||
| 678 | Tpl.Text txt; | ||
| 679 | String a_FMUVersion; | ||
| 680 | Boolean ret_0; | ||
| 681 | |||
| 682 | case ( txt, | ||
| 683 | false, | ||
| 684 | a_FMUVersion ) | ||
| 685 | algorithm | ||
| 686 | 8 | ret_0 := FMI.isFMIVersion30(a_FMUVersion); | |
| 687 | 8 | txt := fun_64(txt, ret_0); | |
| 688 | then txt; | ||
| 689 | |||
| 690 | case ( txt, | ||
| 691 | _, | ||
| 692 | _ ) | ||
| 693 | algorithm | ||
| 694 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include <FMU/FMUWrapper.h>")); | |
| 695 | then txt; | ||
| 696 | end match; | ||
| 697 | end fun_65; | ||
| 698 | |||
| 699 | protected function fun_66 | ||
| 700 | input Tpl.Text in_txt; | ||
| 701 | input Boolean in_mArg; | ||
| 702 | |||
| 703 | output Tpl.Text out_txt; | ||
| 704 | algorithm | ||
| 705 | out_txt := | ||
| 706 | match(in_txt, in_mArg) | ||
| 707 | local | ||
| 708 | Tpl.Text txt; | ||
| 709 | |||
| 710 | case ( txt, | ||
| 711 | false ) | ||
| 712 | algorithm | ||
| 713 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include \"FMU2/FMU2Interface.cpp\"")); | |
| 714 | then txt; | ||
| 715 | |||
| 716 | case ( txt, | ||
| 717 | _ ) | ||
| 718 | algorithm | ||
| 719 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include <FMU/FMULibInterface.h>")); | |
| 720 | then txt; | ||
| 721 | end match; | ||
| 722 | end fun_66; | ||
| 723 | |||
| 724 | protected function fun_67 | ||
| 725 | input Tpl.Text in_txt; | ||
| 726 | input Boolean in_mArg; | ||
| 727 | input SimCode.SimCode in_a_simCode; | ||
| 728 | input String in_a_FMUVersion; | ||
| 729 | |||
| 730 | output Tpl.Text out_txt; | ||
| 731 | algorithm | ||
| 732 | out_txt := | ||
| 733 | match(in_txt, in_mArg, in_a_simCode, in_a_FMUVersion) | ||
| 734 | local | ||
| 735 | Tpl.Text txt; | ||
| 736 | SimCode.SimCode a_simCode; | ||
| 737 | String a_FMUVersion; | ||
| 738 | Boolean ret_0; | ||
| 739 | |||
| 740 | case ( txt, | ||
| 741 | false, | ||
| 742 | _, | ||
| 743 | a_FMUVersion ) | ||
| 744 | algorithm | ||
| 745 | 8 | ret_0 := FMI.isFMIVersion10(a_FMUVersion); | |
| 746 | 8 | txt := fun_66(txt, ret_0); | |
| 747 | then txt; | ||
| 748 | |||
| 749 | case ( txt, | ||
| 750 | _, | ||
| 751 | a_simCode, | ||
| 752 | _ ) | ||
| 753 | algorithm | ||
| 754 | 1 | txt := fmi3CppOffsetDefines(txt, a_simCode); | |
| 755 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 756 | "\n", | ||
| 757 | " #include \"FMU3/FMU3Interface.cpp\"" | ||
| 758 | }, false)); | ||
| 759 | then txt; | ||
| 760 | end match; | ||
| 761 | end fun_67; | ||
| 762 | |||
| 763 | protected function fun_68 | ||
| 764 | input Tpl.Text in_txt; | ||
| 765 | input SimCodeVar.SimVar in_a_var; | ||
| 766 | input SimCode.SimCode in_a_simCode; | ||
| 767 | |||
| 768 | output Tpl.Text out_txt; | ||
| 769 | algorithm | ||
| 770 | out_txt := | ||
| 771 | match(in_txt, in_a_var, in_a_simCode) | ||
| 772 | local | ||
| 773 | Tpl.Text txt; | ||
| 774 | SimCode.SimCode a_simCode; | ||
| 775 | DAE.ComponentRef i_name; | ||
| 776 | Integer ret_2; | ||
| 777 | Integer ret_1; | ||
| 778 | SimCodeVar.SimVar ret_0; | ||
| 779 | |||
| 780 | case ( txt, | ||
| 781 | SimCodeVar.SIMVAR(name = i_name, type_ = DAE.T_REAL(varLst = _)), | ||
| 782 | a_simCode ) | ||
| 783 | algorithm | ||
| 784 | 10 | ret_0 := SimCodeCodegenUtil.cref2simvar(i_name, a_simCode); | |
| 785 | 10 | ret_1 := SimCodeCodegenUtil.getVariableIndex(ret_0); | |
| 786 | 10 | ret_2 := intSub(ret_1, 1); | |
| 787 | 10 | txt := Tpl.writeStr(txt, intString(ret_2)); | |
| 788 | then txt; | ||
| 789 | |||
| 790 | case ( txt, | ||
| 791 | _, | ||
| 792 | _ ) | ||
| 793 | then txt; | ||
| 794 | end match; | ||
| 795 | end fun_68; | ||
| 796 | |||
| 797 | protected function lm_69 | ||
| 798 | input output Tpl.Text txt; | ||
| 799 | input list<SimCodeVar.SimVar> items; | ||
| 800 | input SimCode.SimCode a_simCode; | ||
| 801 | algorithm | ||
| 802 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 9 times.
|
21 | for lstElt_69 in items loop |
| 803 | txt := match lstElt_69 | ||
| 804 | local | ||
| 805 | SimCodeVar.SimVar i_var; | ||
| 806 | |||
| 807 | case i_var | ||
| 808 | algorithm | ||
| 809 | 12 | txt := fun_68(txt, i_var, a_simCode); | |
| 810 | 12 | txt := Tpl.nextIter(txt); | |
| 811 | then txt; | ||
| 812 | end match; | ||
| 813 | end for; | ||
| 814 | end lm_69; | ||
| 815 | |||
| 816 | protected function fun_70 | ||
| 817 | input Tpl.Text in_txt; | ||
| 818 | input SimCodeVar.SimVar in_a_var; | ||
| 819 | input SimCode.SimCode in_a_simCode; | ||
| 820 | |||
| 821 | output Tpl.Text out_txt; | ||
| 822 | algorithm | ||
| 823 | out_txt := | ||
| 824 | match(in_txt, in_a_var, in_a_simCode) | ||
| 825 | local | ||
| 826 | Tpl.Text txt; | ||
| 827 | SimCode.SimCode a_simCode; | ||
| 828 | DAE.ComponentRef i_name; | ||
| 829 | Integer ret_5; | ||
| 830 | Integer ret_4; | ||
| 831 | SimCodeVar.SimVar ret_3; | ||
| 832 | Integer ret_2; | ||
| 833 | Integer ret_1; | ||
| 834 | SimCodeVar.SimVar ret_0; | ||
| 835 | |||
| 836 | case ( txt, | ||
| 837 | SimCodeVar.SIMVAR(name = i_name, type_ = DAE.T_REAL(varLst = _), varKind = BackendDAE.CLOCKED_STATE(previousName = _)), | ||
| 838 | a_simCode ) | ||
| 839 | algorithm | ||
| 840 | ✗ | ret_0 := SimCodeCodegenUtil.cref2simvar(i_name, a_simCode); | |
| 841 | ✗ | ret_1 := SimCodeCodegenUtil.getVariableIndex(ret_0); | |
| 842 | ✗ | ret_2 := intSub(ret_1, 1); | |
| 843 | ✗ | txt := Tpl.writeStr(txt, intString(ret_2)); | |
| 844 | then txt; | ||
| 845 | |||
| 846 | case ( txt, | ||
| 847 | SimCodeVar.SIMVAR(name = i_name, type_ = DAE.T_REAL(varLst = _), causality = SOME(SimCodeVar.OUTPUT())), | ||
| 848 | a_simCode ) | ||
| 849 | algorithm | ||
| 850 | 25 | ret_3 := SimCodeCodegenUtil.cref2simvar(i_name, a_simCode); | |
| 851 | 25 | ret_4 := SimCodeCodegenUtil.getVariableIndex(ret_3); | |
| 852 | 25 | ret_5 := intSub(ret_4, 1); | |
| 853 | 25 | txt := Tpl.writeStr(txt, intString(ret_5)); | |
| 854 | then txt; | ||
| 855 | |||
| 856 | case ( txt, | ||
| 857 | _, | ||
| 858 | _ ) | ||
| 859 | then txt; | ||
| 860 | end match; | ||
| 861 | end fun_70; | ||
| 862 | |||
| 863 | protected function lm_71 | ||
| 864 | input output Tpl.Text txt; | ||
| 865 | input list<SimCodeVar.SimVar> items; | ||
| 866 | input SimCode.SimCode a_simCode; | ||
| 867 | algorithm | ||
| 868 |
2/2✓ Branch 0 taken 234 times.
✓ Branch 1 taken 9 times.
|
243 | for lstElt_71 in items loop |
| 869 | txt := match lstElt_71 | ||
| 870 | local | ||
| 871 | SimCodeVar.SimVar i_var; | ||
| 872 | |||
| 873 | case i_var | ||
| 874 | algorithm | ||
| 875 | 234 | txt := fun_70(txt, i_var, a_simCode); | |
| 876 | 234 | txt := Tpl.nextIter(txt); | |
| 877 | then txt; | ||
| 878 | end match; | ||
| 879 | end for; | ||
| 880 | end lm_71; | ||
| 881 | |||
| 882 | public function fmuModelCppFile | ||
| 883 | input Tpl.Text in_txt; | ||
| 884 | input SimCode.SimCode in_a_simCode; | ||
| 885 | input Tpl.Text in_a_extraFuncs; | ||
| 886 | input Tpl.Text in_a_extraFuncsDecl; | ||
| 887 | input Tpl.Text in_a_extraFuncsNamespace; | ||
| 888 | input String in_a_guid; | ||
| 889 | input String in_a_FMUVersion; | ||
| 890 | |||
| 891 | output Tpl.Text out_txt; | ||
| 892 | output Tpl.Text out_a_extraFuncs; | ||
| 893 | output Tpl.Text out_a_extraFuncsDecl; | ||
| 894 | output Tpl.Text out_a_extraFuncsNamespace; | ||
| 895 | algorithm | ||
| 896 | (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := | ||
| 897 | match(in_txt, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_guid, in_a_FMUVersion) | ||
| 898 | local | ||
| 899 | Tpl.Text txt; | ||
| 900 | Tpl.Text a_extraFuncs; | ||
| 901 | Tpl.Text a_extraFuncsDecl; | ||
| 902 | Tpl.Text a_extraFuncsNamespace; | ||
| 903 | String a_guid; | ||
| 904 | String a_FMUVersion; | ||
| 905 | list<SimCodeVar.SimVar> i_algVars; | ||
| 906 | list<SimCodeVar.SimVar> i_inputVars; | ||
| 907 | SimCode.ModelInfo i_modelInfo; | ||
| 908 | SimCode.SimCode i_simCode; | ||
| 909 | list<SimCode.ClockedPartition> i_clockedPartitions; | ||
| 910 | list<SimCode.SimEqSystem> i_initialEquations; | ||
| 911 | list<SimCode.SimEqSystem> i_allEquations; | ||
| 912 | Absyn.Path i_modelInfo_name; | ||
| 913 | Boolean ret_12; | ||
| 914 | Boolean ret_11; | ||
| 915 | String str_10; | ||
| 916 | Tpl.Text l_solverFactory; | ||
| 917 | list<SimCode.SimEqSystem> ret_8; | ||
| 918 | list<SimCode.SimEqSystem> ret_7; | ||
| 919 | list<SimCode.SubPartition> ret_6; | ||
| 920 | list<SimCode.SimEqSystem> ret_5; | ||
| 921 | Tpl.Text l_algloopfiles; | ||
| 922 | String ret_3; | ||
| 923 | Tpl.Text l_modelLongName; | ||
| 924 | Tpl.Text l_modelShortName; | ||
| 925 | Tpl.Text l_modelName; | ||
| 926 | |||
| 927 | case ( txt, | ||
| 928 | (i_simCode as SimCode.SIMCODE(modelInfo = (i_modelInfo as SimCode.MODELINFO(vars = SimCodeVar.SIMVARS(inputVars = i_inputVars, algVars = i_algVars), name = i_modelInfo_name)), modelStructure = _, allEquations = i_allEquations, initialEquations = i_initialEquations, clockedPartitions = i_clockedPartitions)), | ||
| 929 | a_extraFuncs, | ||
| 930 | a_extraFuncsDecl, | ||
| 931 | a_extraFuncsNamespace, | ||
| 932 | a_guid, | ||
| 933 | a_FMUVersion ) | ||
| 934 | algorithm | ||
| 935 | 9 | l_modelName := CodegenUtil.dotPath(Tpl.emptyTxt, i_modelInfo_name); | |
| 936 | 9 | l_modelShortName := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, i_modelInfo_name); | |
| 937 | 9 | ret_3 := System.stringReplace(Tpl.textString(l_modelName), ".", "_"); | |
| 938 | 9 | l_modelLongName := Tpl.writeStr(Tpl.emptyTxt, ret_3); | |
| 939 | 9 | ret_5 := listAppend(i_allEquations, i_initialEquations); | |
| 940 | 9 | ret_6 := SimCodeCodegenUtil.getSubPartitions(i_clockedPartitions); | |
| 941 | 9 | ret_7 := SimCodeCodegenUtil.getClockedEquations(ret_6); | |
| 942 | 9 | ret_8 := listAppend(ret_5, ret_7); | |
| 943 | 9 | l_algloopfiles := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 944 | 9 | (l_algloopfiles, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs) := lm_62(l_algloopfiles, ret_8, l_modelShortName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, i_simCode); | |
| 945 | 9 | l_algloopfiles := Tpl.popIter(l_algloopfiles); | |
| 946 | 9 | str_10 := Tpl.textString(l_algloopfiles); | |
| 947 | 9 | l_solverFactory := fun_63(Tpl.emptyTxt, str_10); | |
| 948 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 949 | "// define model identifier and unique id\n", | ||
| 950 | "#define MODEL_IDENTIFIER " | ||
| 951 | }, false)); | ||
| 952 | 9 | txt := Tpl.writeText(txt, l_modelLongName); | |
| 953 | 9 | txt := Tpl.softNewLine(txt); | |
| 954 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#define MODEL_IDENTIFIER_SHORT ")); | |
| 955 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 956 | 9 | txt := Tpl.softNewLine(txt); | |
| 957 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#define MODEL_CLASS ")); | |
| 958 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 959 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 960 | "FMU\n", | ||
| 961 | "#define MODEL_GUID \"{" | ||
| 962 | }, false)); | ||
| 963 | 9 | txt := Tpl.writeStr(txt, a_guid); | |
| 964 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 965 | "}\"\n", | ||
| 966 | "\n" | ||
| 967 | }, true)); | ||
| 968 | 9 | txt := ModelDefineData(txt, i_modelInfo); | |
| 969 | 9 | txt := Tpl.softNewLine(txt); | |
| 970 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#define NUMBER_OF_EVENT_INDICATORS ")); | |
| 971 | 9 | txt := CodegenFMUCommon.getNumberOfEventIndicators(txt, i_simCode); | |
| 972 | 9 | txt := Tpl.softNewLine(txt); | |
| 973 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); | |
| 974 | 9 | ret_11 := FMI.isFMIVersion10(a_FMUVersion); | |
| 975 | 9 | txt := fun_65(txt, ret_11, a_FMUVersion); | |
| 976 | 9 | txt := Tpl.softNewLine(txt); | |
| 977 | 9 | ret_12 := FMI.isFMIVersion30(a_FMUVersion); | |
| 978 | 9 | txt := fun_67(txt, ret_12, i_simCode, a_FMUVersion); | |
| 979 | 9 | txt := Tpl.softNewLine(txt); | |
| 980 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 981 | "\n", | ||
| 982 | "// SimObjects for " | ||
| 983 | }, false)); | ||
| 984 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 985 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 986 | "FMU\n", | ||
| 987 | "shared_ptr<IAlgLoopSolverFactory> createStaticAlgLoopSolverFactory(IGlobalSettings*, PATH, PATH);\n", | ||
| 988 | "\n", | ||
| 989 | "class " | ||
| 990 | }, false)); | ||
| 991 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 992 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 993 | "SimObjects : public ISimObjects {\n", | ||
| 994 | " public:\n" | ||
| 995 | }, true)); | ||
| 996 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 997 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 998 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("SimObjects(IGlobalSettings *globalSettings) {\n")); | |
| 999 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 1000 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_algLoopSolverFactory = shared_ptr<IAlgLoopSolverFactory>(")); | |
| 1001 | 9 | txt := Tpl.writeText(txt, l_solverFactory); | |
| 1002 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n")); | |
| 1003 | 9 | txt := Tpl.popBlock(txt); | |
| 1004 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n")); | |
| 1005 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1006 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("SimObjects(")); | |
| 1007 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1008 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1009 | "SimObjects& instance) {\n", | ||
| 1010 | " _algLoopSolverFactory = instance._algLoopSolverFactory;\n", | ||
| 1011 | "}\n", | ||
| 1012 | "weak_ptr<ISimData> LoadSimData(string modelKey) {\n", | ||
| 1013 | " return shared_ptr<ISimData>();\n", | ||
| 1014 | "}\n", | ||
| 1015 | "weak_ptr<ISimVars> LoadSimVars(string modelKey, size_t dim_real, size_t dim_int, size_t dim_bool, size_t dim_string, size_t dim_pre_vars, size_t dim_z, size_t z_i) {\n", | ||
| 1016 | " _simVars = shared_ptr<ISimVars>(new SimVars(dim_real, dim_int, dim_bool, dim_string, dim_pre_vars, dim_z, z_i));\n", | ||
| 1017 | " return _simVars;\n", | ||
| 1018 | "}\n", | ||
| 1019 | "weak_ptr<IHistory> LoadWriter(size_t) {\n", | ||
| 1020 | " return shared_ptr<IHistory>();\n", | ||
| 1021 | "}\n", | ||
| 1022 | "shared_ptr<ISimData> getSimData(string modelKey) {\n", | ||
| 1023 | " return shared_ptr<ISimData>();\n", | ||
| 1024 | "}\n", | ||
| 1025 | "shared_ptr<ISimVars> getSimVars(string modelKey) {\n", | ||
| 1026 | " return _simVars;\n", | ||
| 1027 | "}\n", | ||
| 1028 | "void eraseSimData(string modelKey) {}\n", | ||
| 1029 | "void eraseSimVars(string modelKey) {}\n", | ||
| 1030 | "shared_ptr<IAlgLoopSolverFactory> getAlgLoopSolverFactory() {\n", | ||
| 1031 | " return _algLoopSolverFactory;\n", | ||
| 1032 | "}\n", | ||
| 1033 | "\n", | ||
| 1034 | "ISimObjects* clone() {\n" | ||
| 1035 | }, true)); | ||
| 1036 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 1037 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("return new ")); | |
| 1038 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1039 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("SimObjects(*this);\n")); | |
| 1040 | 9 | txt := Tpl.popBlock(txt); | |
| 1041 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n")); | |
| 1042 | 9 | txt := Tpl.popBlock(txt); | |
| 1043 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1044 | " protected:\n", | ||
| 1045 | " shared_ptr<ISimVars> _simVars;\n", | ||
| 1046 | " shared_ptr<IAlgLoopSolverFactory> _algLoopSolverFactory;\n", | ||
| 1047 | "};\n", | ||
| 1048 | "\n", | ||
| 1049 | "// create instance of " | ||
| 1050 | }, false)); | ||
| 1051 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1052 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("FMU\n")); | |
| 1053 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1054 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("FMU *createSystemFMU(IGlobalSettings *globalSettings) {\n")); | |
| 1055 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 1056 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("shared_ptr<ISimObjects> simObjects(new ")); | |
| 1057 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1058 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1059 | "SimObjects(globalSettings));\n", | ||
| 1060 | "simObjects->LoadSimVars(\"" | ||
| 1061 | }, false)); | ||
| 1062 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1063 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\", ")); | |
| 1064 | 9 | txt := CodegenCpp.numRealvars(txt, i_modelInfo); | |
| 1065 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 1066 | 9 | txt := CodegenCpp.numIntvars(txt, i_modelInfo); | |
| 1067 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 1068 | 9 | txt := CodegenCpp.numBoolvars(txt, i_modelInfo); | |
| 1069 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 1070 | 9 | txt := CodegenCpp.numStringvars(txt, i_modelInfo); | |
| 1071 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 1072 | 9 | txt := CodegenCpp.getPreVarsCount(txt, i_modelInfo); | |
| 1073 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 1074 | 9 | txt := CodegenCpp.numStatevars(txt, i_modelInfo); | |
| 1075 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 1076 | 9 | txt := CodegenCpp.numStateVarIndex(txt, i_modelInfo); | |
| 1077 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1078 | ");\n", | ||
| 1079 | "simObjects->LoadSimData(\"" | ||
| 1080 | }, false)); | ||
| 1081 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1082 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1083 | "\");\n", | ||
| 1084 | "globalSettings->setOutputFormat(EMPTY);\n", | ||
| 1085 | "return new " | ||
| 1086 | }, false)); | ||
| 1087 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1088 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("FMU(globalSettings, simObjects);\n")); | |
| 1089 | 9 | txt := Tpl.popBlock(txt); | |
| 1090 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1091 | "}\n", | ||
| 1092 | "\n", | ||
| 1093 | "// value references of real inputs\n", | ||
| 1094 | "unsigned int " | ||
| 1095 | }, false)); | ||
| 1096 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1097 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("FMU::_inputRefs[] = {")); | |
| 1098 | 9 | txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1099 | 9 | txt := lm_69(txt, i_inputVars, i_simCode); | |
| 1100 | 9 | txt := Tpl.popIter(txt); | |
| 1101 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1102 | "};\n", | ||
| 1103 | "// value references of real discrete states and outputs\n", | ||
| 1104 | "unsigned int " | ||
| 1105 | }, false)); | ||
| 1106 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1107 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("FMU::_outputRefs[] = {")); | |
| 1108 | 9 | txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1109 | 9 | txt := lm_71(txt, i_algVars, i_simCode); | |
| 1110 | 9 | txt := Tpl.popIter(txt); | |
| 1111 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1112 | "};\n", | ||
| 1113 | "\n", | ||
| 1114 | "// constructor\n" | ||
| 1115 | }, true)); | ||
| 1116 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1117 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("FMU::")); | |
| 1118 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1119 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("FMU(IGlobalSettings* globalSettings, shared_ptr<ISimObjects> simObjects)\n")); | |
| 1120 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 1121 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(": ")); | |
| 1122 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1123 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("Initialize(globalSettings, simObjects) {\n")); | |
| 1124 | 9 | txt := Tpl.popBlock(txt); | |
| 1125 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1126 | "}\n", | ||
| 1127 | "\n", | ||
| 1128 | "// initialization\n", | ||
| 1129 | "void " | ||
| 1130 | }, false)); | ||
| 1131 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1132 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("FMU::initialize() {\n")); | |
| 1133 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 1134 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1135 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("WriteOutput::initialize();\n")); | |
| 1136 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1137 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("Initialize::initializeMemory();\n")); | |
| 1138 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1139 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("Initialize::initializeFreeVariables();\n")); | |
| 1140 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 1141 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("Jacobian::initialize();\n")); | |
| 1142 | 9 | txt := Tpl.popBlock(txt); | |
| 1143 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1144 | "}\n", | ||
| 1145 | "\n", | ||
| 1146 | "// getters\n" | ||
| 1147 | }, true)); | ||
| 1148 | 9 | txt := accessFunctions(txt, i_simCode, "get", Tpl.textString(l_modelShortName), i_modelInfo); | |
| 1149 | 9 | txt := Tpl.softNewLine(txt); | |
| 1150 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1151 | "\n", | ||
| 1152 | "// setters\n" | ||
| 1153 | }, true)); | ||
| 1154 | 9 | txt := accessFunctions(txt, i_simCode, "set", Tpl.textString(l_modelShortName), i_modelInfo); | |
| 1155 | 9 | txt := Tpl.softNewLine(txt); | |
| 1156 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1157 | "\n", | ||
| 1158 | "// Jacobian\n" | ||
| 1159 | }, true)); | ||
| 1160 | 9 | txt := directionalDerivativeFunction(txt, i_simCode); | |
| 1161 | 9 | txt := Tpl.softNewLine(txt); | |
| 1162 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); | |
| 1163 | 9 | then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace); | |
| 1164 | |||
| 1165 | case ( txt, | ||
| 1166 | _, | ||
| 1167 | a_extraFuncs, | ||
| 1168 | a_extraFuncsDecl, | ||
| 1169 | a_extraFuncsNamespace, | ||
| 1170 | _, | ||
| 1171 | _ ) | ||
| 1172 | then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace); | ||
| 1173 | end match; | ||
| 1174 | end fmuModelCppFile; | ||
| 1175 | |||
| 1176 | public function fmi3CppOffsetDefines | ||
| 1177 | input Tpl.Text in_txt; | ||
| 1178 | input SimCode.SimCode in_a_simCode; | ||
| 1179 | |||
| 1180 | output Tpl.Text out_txt; | ||
| 1181 | algorithm | ||
| 1182 | out_txt := | ||
| 1183 | match(in_txt, in_a_simCode) | ||
| 1184 | local | ||
| 1185 | Tpl.Text txt; | ||
| 1186 | Integer i_numberOfClocks; | ||
| 1187 | Integer i_varInfo_numExternalObjects; | ||
| 1188 | Integer i_varInfo_numStringAliasVars; | ||
| 1189 | Integer i_varInfo_numStringParamVars; | ||
| 1190 | Integer i_varInfo_numStringAlgVars; | ||
| 1191 | Integer i_varInfo_numBoolAliasVars; | ||
| 1192 | Integer i_varInfo_numBoolParams; | ||
| 1193 | Integer i_varInfo_numBoolAlgVars; | ||
| 1194 | Integer i_varInfo_numIntAliasVars; | ||
| 1195 | Integer i_varInfo_numIntParams; | ||
| 1196 | Integer i_varInfo_numIntAlgVars; | ||
| 1197 | Integer i_varInfo_numAlgAliasVars; | ||
| 1198 | Integer i_varInfo_numParams; | ||
| 1199 | Integer i_varInfo_numAlgVars; | ||
| 1200 | Integer i_varInfo_numDiscreteReal; | ||
| 1201 | Integer i_varInfo_numStateVars; | ||
| 1202 | |||
| 1203 | case ( txt, | ||
| 1204 | SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(varInfo = SimCode.VARINFO(numStateVars = i_varInfo_numStateVars, numDiscreteReal = i_varInfo_numDiscreteReal, numAlgVars = i_varInfo_numAlgVars, numParams = i_varInfo_numParams, numAlgAliasVars = i_varInfo_numAlgAliasVars, numIntAlgVars = i_varInfo_numIntAlgVars, numIntParams = i_varInfo_numIntParams, numIntAliasVars = i_varInfo_numIntAliasVars, numBoolAlgVars = i_varInfo_numBoolAlgVars, numBoolParams = i_varInfo_numBoolParams, numBoolAliasVars = i_varInfo_numBoolAliasVars, numStringAlgVars = i_varInfo_numStringAlgVars, numStringParamVars = i_varInfo_numStringParamVars, numStringAliasVars = i_varInfo_numStringAliasVars, numExternalObjects = i_varInfo_numExternalObjects), nClocks = i_numberOfClocks)) ) | ||
| 1205 | algorithm | ||
| 1206 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#define FMI3_NUMBER_OF_REALS (2*")); | |
| 1207 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numStateVars)); | |
| 1208 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1209 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numDiscreteReal)); | |
| 1210 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1211 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numAlgVars)); | |
| 1212 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1213 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numParams)); | |
| 1214 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1215 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numAlgAliasVars)); | |
| 1216 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1217 | ")\n", | ||
| 1218 | "#define FMI3_NUMBER_OF_INTEGERS (" | ||
| 1219 | }, false)); | ||
| 1220 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numIntAlgVars)); | |
| 1221 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1222 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numIntParams)); | |
| 1223 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1224 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numIntAliasVars)); | |
| 1225 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1226 | ")\n", | ||
| 1227 | "#define FMI3_NUMBER_OF_BOOLEANS (" | ||
| 1228 | }, false)); | ||
| 1229 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numBoolAlgVars)); | |
| 1230 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1231 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numBoolParams)); | |
| 1232 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1233 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numBoolAliasVars)); | |
| 1234 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1235 | ")\n", | ||
| 1236 | "#define FMI3_NUMBER_OF_STRINGS (" | ||
| 1237 | }, false)); | ||
| 1238 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numStringAlgVars)); | |
| 1239 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1240 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numStringParamVars)); | |
| 1241 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + ")); | |
| 1242 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numStringAliasVars)); | |
| 1243 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1244 | ")\n", | ||
| 1245 | "#define FMI3_NUMBER_OF_EXTERNALOBJECTS (" | ||
| 1246 | }, false)); | ||
| 1247 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numExternalObjects)); | |
| 1248 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1249 | ")\n", | ||
| 1250 | "#define FMI3_NUMBER_OF_CLOCKS (" | ||
| 1251 | }, false)); | ||
| 1252 | 1 | txt := Tpl.writeStr(txt, intString(i_numberOfClocks)); | |
| 1253 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1254 | ")\n", | ||
| 1255 | "#define FMI3_REAL_VR_OFFSET 0\n", | ||
| 1256 | "#define FMI3_INTEGER_VR_OFFSET (FMI3_NUMBER_OF_REALS)\n", | ||
| 1257 | "#define FMI3_BOOLEAN_VR_OFFSET (FMI3_NUMBER_OF_REALS + FMI3_NUMBER_OF_INTEGERS)\n", | ||
| 1258 | "#define FMI3_STRING_VR_OFFSET (FMI3_NUMBER_OF_REALS + FMI3_NUMBER_OF_INTEGERS + FMI3_NUMBER_OF_BOOLEANS)\n", | ||
| 1259 | "// external objects are exported as FMI 3.0 Binary, then the model clocks, after the string block\n", | ||
| 1260 | "#define FMI3_BINARY_VR_OFFSET (FMI3_NUMBER_OF_REALS + FMI3_NUMBER_OF_INTEGERS + FMI3_NUMBER_OF_BOOLEANS + FMI3_NUMBER_OF_STRINGS)\n", | ||
| 1261 | "#define FMI3_CLOCK_VR_OFFSET (FMI3_NUMBER_OF_REALS + FMI3_NUMBER_OF_INTEGERS + FMI3_NUMBER_OF_BOOLEANS + FMI3_NUMBER_OF_STRINGS + FMI3_NUMBER_OF_EXTERNALOBJECTS)\n", | ||
| 1262 | "#define FMI3_TIME_VR (FMI3_NUMBER_OF_REALS + FMI3_NUMBER_OF_INTEGERS + FMI3_NUMBER_OF_BOOLEANS + FMI3_NUMBER_OF_STRINGS + FMI3_NUMBER_OF_EXTERNALOBJECTS + FMI3_NUMBER_OF_CLOCKS)\n", | ||
| 1263 | "#define FMI3_EVENT_INDICATOR_VR_START (FMI3_TIME_VR + 1)\n", | ||
| 1264 | "#define FMI3_NUMBER_OF_STATES " | ||
| 1265 | }, false)); | ||
| 1266 | 1 | txt := Tpl.writeStr(txt, intString(i_varInfo_numStateVars)); | |
| 1267 | then txt; | ||
| 1268 | |||
| 1269 | case ( txt, | ||
| 1270 | _ ) | ||
| 1271 | then txt; | ||
| 1272 | end match; | ||
| 1273 | end fmi3CppOffsetDefines; | ||
| 1274 | |||
| 1275 | protected function lm_74 | ||
| 1276 | input output Tpl.Text txt; | ||
| 1277 | input list<SimCodeFunction.Function> items; | ||
| 1278 | algorithm | ||
| 1279 |
2/2✓ Branch 0 taken 141 times.
✓ Branch 1 taken 9 times.
|
150 | for lstElt_74 in items loop |
| 1280 | txt := match lstElt_74 | ||
| 1281 | local | ||
| 1282 | SimCodeFunction.Function i_fn; | ||
| 1283 | |||
| 1284 | case i_fn | ||
| 1285 | algorithm | ||
| 1286 | 141 | txt := defineExternalFunction(txt, i_fn); | |
| 1287 | 141 | txt := Tpl.nextIter(txt); | |
| 1288 | then txt; | ||
| 1289 | end match; | ||
| 1290 | end for; | ||
| 1291 | end lm_74; | ||
| 1292 | |||
| 1293 | public function ModelDefineData | ||
| 1294 | input Tpl.Text in_txt; | ||
| 1295 | input SimCode.ModelInfo in_a_modelInfo; | ||
| 1296 | |||
| 1297 | output Tpl.Text out_txt; | ||
| 1298 | algorithm | ||
| 1299 | out_txt := | ||
| 1300 | match(in_txt, in_a_modelInfo) | ||
| 1301 | local | ||
| 1302 | Tpl.Text txt; | ||
| 1303 | list<SimCodeFunction.Function> i_functions; | ||
| 1304 | |||
| 1305 | case ( txt, | ||
| 1306 | SimCode.MODELINFO(varInfo = SimCode.VARINFO(numZeroCrossings = _), vars = SimCodeVar.SIMVARS(stateVars = _), functions = i_functions) ) | ||
| 1307 | algorithm | ||
| 1308 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("/* TODO: implement external functions in FMU wrapper for c++ target\n")); | |
| 1309 | 9 | System.tmpTickReset(0); | |
| 1310 | 9 | txt := Tpl.softNewLine(txt); | |
| 1311 | 9 | 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())); | |
| 1312 | 9 | txt := lm_74(txt, i_functions); | |
| 1313 | 9 | txt := Tpl.popIter(txt); | |
| 1314 | 9 | txt := Tpl.softNewLine(txt); | |
| 1315 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*/")); | |
| 1316 | then txt; | ||
| 1317 | |||
| 1318 | case ( txt, | ||
| 1319 | _ ) | ||
| 1320 | then txt; | ||
| 1321 | end match; | ||
| 1322 | end ModelDefineData; | ||
| 1323 | |||
| 1324 | protected function fun_76 | ||
| 1325 | input Tpl.Text in_txt; | ||
| 1326 | input String in_a_comment; | ||
| 1327 | |||
| 1328 | output Tpl.Text out_txt; | ||
| 1329 | algorithm | ||
| 1330 | out_txt := | ||
| 1331 | match(in_txt, in_a_comment) | ||
| 1332 | local | ||
| 1333 | Tpl.Text txt; | ||
| 1334 | String i_comment; | ||
| 1335 | |||
| 1336 | case ( txt, | ||
| 1337 | "" ) | ||
| 1338 | then txt; | ||
| 1339 | |||
| 1340 | case ( txt, | ||
| 1341 | i_comment ) | ||
| 1342 | algorithm | ||
| 1343 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("// \"")); | |
| 1344 | ✗ | txt := Tpl.writeStr(txt, i_comment); | |
| 1345 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 1346 | then txt; | ||
| 1347 | end match; | ||
| 1348 | end fun_76; | ||
| 1349 | |||
| 1350 | protected function fun_77 | ||
| 1351 | input Tpl.Text in_txt; | ||
| 1352 | input Boolean in_mArg; | ||
| 1353 | input Tpl.Text in_a_description; | ||
| 1354 | input Boolean in_a_useFlatArrayNotation; | ||
| 1355 | input DAE.ComponentRef in_a_name; | ||
| 1356 | |||
| 1357 | output Tpl.Text out_txt; | ||
| 1358 | algorithm | ||
| 1359 | out_txt := | ||
| 1360 | match(in_txt, in_mArg, in_a_description, in_a_useFlatArrayNotation, in_a_name) | ||
| 1361 | local | ||
| 1362 | Tpl.Text txt; | ||
| 1363 | Tpl.Text a_description; | ||
| 1364 | Boolean a_useFlatArrayNotation; | ||
| 1365 | DAE.ComponentRef a_name; | ||
| 1366 | Integer ret_0; | ||
| 1367 | |||
| 1368 | case ( txt, | ||
| 1369 | false, | ||
| 1370 | a_description, | ||
| 1371 | a_useFlatArrayNotation, | ||
| 1372 | a_name ) | ||
| 1373 | algorithm | ||
| 1374 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#define ")); | |
| 1375 | ✗ | txt := CodegenCppCommon.cref(txt, a_name, a_useFlatArrayNotation); | |
| 1376 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_ ")); | |
| 1377 | ✗ | ret_0 := System.tmpTick(); | |
| 1378 | ✗ | txt := Tpl.writeStr(txt, intString(ret_0)); | |
| 1379 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 1380 | ✗ | txt := Tpl.writeText(txt, a_description); | |
| 1381 | then txt; | ||
| 1382 | |||
| 1383 | case ( txt, | ||
| 1384 | _, | ||
| 1385 | _, | ||
| 1386 | _, | ||
| 1387 | _ ) | ||
| 1388 | then txt; | ||
| 1389 | end match; | ||
| 1390 | end fun_77; | ||
| 1391 | |||
| 1392 | protected function fun_78 | ||
| 1393 | input Tpl.Text in_txt; | ||
| 1394 | input Boolean in_mArg; | ||
| 1395 | input Tpl.Text in_a_description; | ||
| 1396 | input Boolean in_a_useFlatArrayNotation; | ||
| 1397 | input DAE.ComponentRef in_a_name; | ||
| 1398 | |||
| 1399 | output Tpl.Text out_txt; | ||
| 1400 | algorithm | ||
| 1401 | out_txt := | ||
| 1402 | match(in_txt, in_mArg, in_a_description, in_a_useFlatArrayNotation, in_a_name) | ||
| 1403 | local | ||
| 1404 | Tpl.Text txt; | ||
| 1405 | Tpl.Text a_description; | ||
| 1406 | Boolean a_useFlatArrayNotation; | ||
| 1407 | DAE.ComponentRef a_name; | ||
| 1408 | Boolean ret_1; | ||
| 1409 | Tpl.Text txt_0; | ||
| 1410 | |||
| 1411 | case ( txt, | ||
| 1412 | false, | ||
| 1413 | a_description, | ||
| 1414 | a_useFlatArrayNotation, | ||
| 1415 | a_name ) | ||
| 1416 | algorithm | ||
| 1417 | ✗ | txt_0 := CodegenUtil.crefStr(Tpl.emptyTxt, a_name); | |
| 1418 | ✗ | ret_1 := stringEq(Tpl.textString(txt_0), "der($dummy)"); | |
| 1419 | ✗ | txt := fun_77(txt, ret_1, a_description, a_useFlatArrayNotation, a_name); | |
| 1420 | then txt; | ||
| 1421 | |||
| 1422 | case ( txt, | ||
| 1423 | _, | ||
| 1424 | _, | ||
| 1425 | _, | ||
| 1426 | _ ) | ||
| 1427 | then txt; | ||
| 1428 | end match; | ||
| 1429 | end fun_78; | ||
| 1430 | |||
| 1431 | public function DefineVariables | ||
| 1432 | input Tpl.Text in_txt; | ||
| 1433 | input SimCodeVar.SimVar in_a_simVar; | ||
| 1434 | input Boolean in_a_useFlatArrayNotation; | ||
| 1435 | |||
| 1436 | output Tpl.Text out_txt; | ||
| 1437 | algorithm | ||
| 1438 | out_txt := | ||
| 1439 | match(in_txt, in_a_simVar, in_a_useFlatArrayNotation) | ||
| 1440 | local | ||
| 1441 | Tpl.Text txt; | ||
| 1442 | Boolean a_useFlatArrayNotation; | ||
| 1443 | DAE.ComponentRef i_name; | ||
| 1444 | String i_comment; | ||
| 1445 | Boolean ret_2; | ||
| 1446 | Tpl.Text txt_1; | ||
| 1447 | Tpl.Text l_description; | ||
| 1448 | |||
| 1449 | case ( txt, | ||
| 1450 | SimCodeVar.SIMVAR(comment = i_comment, name = i_name), | ||
| 1451 | a_useFlatArrayNotation ) | ||
| 1452 | algorithm | ||
| 1453 | ✗ | l_description := fun_76(Tpl.emptyTxt, i_comment); | |
| 1454 | ✗ | txt_1 := CodegenUtil.crefStr(Tpl.emptyTxt, i_name); | |
| 1455 | ✗ | ret_2 := stringEq(Tpl.textString(txt_1), "$dummy"); | |
| 1456 | ✗ | txt := fun_78(txt, ret_2, l_description, a_useFlatArrayNotation, i_name); | |
| 1457 | then txt; | ||
| 1458 | |||
| 1459 | case ( txt, | ||
| 1460 | _, | ||
| 1461 | _ ) | ||
| 1462 | then txt; | ||
| 1463 | end match; | ||
| 1464 | end DefineVariables; | ||
| 1465 | |||
| 1466 | public function defineExternalFunction | ||
| 1467 | input Tpl.Text in_txt; | ||
| 1468 | input SimCodeFunction.Function in_a_fn; | ||
| 1469 | |||
| 1470 | output Tpl.Text out_txt; | ||
| 1471 | algorithm | ||
| 1472 | out_txt := | ||
| 1473 | match(in_txt, in_a_fn) | ||
| 1474 | local | ||
| 1475 | Tpl.Text txt; | ||
| 1476 | String i_language; | ||
| 1477 | String i_extName; | ||
| 1478 | Integer ret_1; | ||
| 1479 | Tpl.Text l_fname; | ||
| 1480 | |||
| 1481 | case ( txt, | ||
| 1482 | SimCodeFunction.EXTERNAL_FUNCTION(dynamicLoad = true, extName = i_extName, language = i_language) ) | ||
| 1483 | algorithm | ||
| 1484 | ✗ | l_fname := CodegenUtil.extFunctionName(Tpl.emptyTxt, i_extName, i_language); | |
| 1485 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#define $P")); | |
| 1486 | ✗ | txt := Tpl.writeText(txt, l_fname); | |
| 1487 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 1488 | ✗ | ret_1 := System.tmpTick(); | |
| 1489 | ✗ | txt := Tpl.writeStr(txt, intString(ret_1)); | |
| 1490 | then txt; | ||
| 1491 | |||
| 1492 | case ( txt, | ||
| 1493 | _ ) | ||
| 1494 | then txt; | ||
| 1495 | end match; | ||
| 1496 | end defineExternalFunction; | ||
| 1497 | |||
| 1498 | protected function lm_81 | ||
| 1499 | input output Tpl.Text txt; | ||
| 1500 | input list<SimCodeVar.SimVar> items; | ||
| 1501 | algorithm | ||
| 1502 | ✗ | for lstElt_81 in items loop | |
| 1503 | txt := match lstElt_81 | ||
| 1504 | local | ||
| 1505 | SimCodeVar.SimVar i_var; | ||
| 1506 | |||
| 1507 | case i_var | ||
| 1508 | algorithm | ||
| 1509 | ✗ | txt := initValsDefault(txt, i_var, "realVars", 0); | |
| 1510 | ✗ | txt := Tpl.nextIter(txt); | |
| 1511 | then txt; | ||
| 1512 | end match; | ||
| 1513 | end for; | ||
| 1514 | end lm_81; | ||
| 1515 | |||
| 1516 | protected function lm_82 | ||
| 1517 | input output Tpl.Text txt; | ||
| 1518 | input list<SimCodeVar.SimVar> items; | ||
| 1519 | input Integer a_numStateVars; | ||
| 1520 | algorithm | ||
| 1521 | ✗ | for lstElt_82 in items loop | |
| 1522 | txt := match lstElt_82 | ||
| 1523 | local | ||
| 1524 | SimCodeVar.SimVar i_var; | ||
| 1525 | |||
| 1526 | case i_var | ||
| 1527 | algorithm | ||
| 1528 | ✗ | txt := initValsDefault(txt, i_var, "realVars", a_numStateVars); | |
| 1529 | ✗ | txt := Tpl.nextIter(txt); | |
| 1530 | then txt; | ||
| 1531 | end match; | ||
| 1532 | end for; | ||
| 1533 | end lm_82; | ||
| 1534 | |||
| 1535 | protected function lm_83 | ||
| 1536 | input output Tpl.Text txt; | ||
| 1537 | input list<SimCodeVar.SimVar> items; | ||
| 1538 | input Integer a_numStateVars; | ||
| 1539 | algorithm | ||
| 1540 | ✗ | for lstElt_83 in items loop | |
| 1541 | txt := match lstElt_83 | ||
| 1542 | local | ||
| 1543 | SimCodeVar.SimVar i_var; | ||
| 1544 | Integer ret_0; | ||
| 1545 | |||
| 1546 | case i_var | ||
| 1547 | algorithm | ||
| 1548 | ✗ | ret_0 := intMul(2, a_numStateVars); | |
| 1549 | ✗ | txt := initValsDefault(txt, i_var, "realVars", ret_0); | |
| 1550 | ✗ | txt := Tpl.nextIter(txt); | |
| 1551 | then txt; | ||
| 1552 | end match; | ||
| 1553 | end for; | ||
| 1554 | end lm_83; | ||
| 1555 | |||
| 1556 | protected function lm_84 | ||
| 1557 | input output Tpl.Text txt; | ||
| 1558 | input list<SimCodeVar.SimVar> items; | ||
| 1559 | input Integer a_numAlgVars; | ||
| 1560 | input Integer a_numStateVars; | ||
| 1561 | algorithm | ||
| 1562 | ✗ | for lstElt_84 in items loop | |
| 1563 | txt := match lstElt_84 | ||
| 1564 | local | ||
| 1565 | SimCodeVar.SimVar i_var; | ||
| 1566 | Integer ret_1; | ||
| 1567 | Integer ret_0; | ||
| 1568 | |||
| 1569 | case i_var | ||
| 1570 | algorithm | ||
| 1571 | ✗ | ret_0 := intMul(2, a_numStateVars); | |
| 1572 | ✗ | ret_1 := intAdd(ret_0, a_numAlgVars); | |
| 1573 | ✗ | txt := initValsDefault(txt, i_var, "realVars", ret_1); | |
| 1574 | ✗ | txt := Tpl.nextIter(txt); | |
| 1575 | then txt; | ||
| 1576 | end match; | ||
| 1577 | end for; | ||
| 1578 | end lm_84; | ||
| 1579 | |||
| 1580 | protected function lm_85 | ||
| 1581 | input output Tpl.Text txt; | ||
| 1582 | input list<SimCodeVar.SimVar> items; | ||
| 1583 | algorithm | ||
| 1584 | ✗ | for lstElt_85 in items loop | |
| 1585 | txt := match lstElt_85 | ||
| 1586 | local | ||
| 1587 | SimCodeVar.SimVar i_var; | ||
| 1588 | |||
| 1589 | case i_var | ||
| 1590 | algorithm | ||
| 1591 | ✗ | txt := initValsDefault(txt, i_var, "integerVars", 0); | |
| 1592 | ✗ | txt := Tpl.nextIter(txt); | |
| 1593 | then txt; | ||
| 1594 | end match; | ||
| 1595 | end for; | ||
| 1596 | end lm_85; | ||
| 1597 | |||
| 1598 | protected function lm_86 | ||
| 1599 | input output Tpl.Text txt; | ||
| 1600 | input list<SimCodeVar.SimVar> items; | ||
| 1601 | algorithm | ||
| 1602 | ✗ | for lstElt_86 in items loop | |
| 1603 | txt := match lstElt_86 | ||
| 1604 | local | ||
| 1605 | SimCodeVar.SimVar i_var; | ||
| 1606 | |||
| 1607 | case i_var | ||
| 1608 | algorithm | ||
| 1609 | ✗ | txt := initValsDefault(txt, i_var, "booleanVars", 0); | |
| 1610 | ✗ | txt := Tpl.nextIter(txt); | |
| 1611 | then txt; | ||
| 1612 | end match; | ||
| 1613 | end for; | ||
| 1614 | end lm_86; | ||
| 1615 | |||
| 1616 | protected function lm_87 | ||
| 1617 | input output Tpl.Text txt; | ||
| 1618 | input list<SimCodeVar.SimVar> items; | ||
| 1619 | algorithm | ||
| 1620 | ✗ | for lstElt_87 in items loop | |
| 1621 | txt := match lstElt_87 | ||
| 1622 | local | ||
| 1623 | SimCodeVar.SimVar i_var; | ||
| 1624 | |||
| 1625 | case i_var | ||
| 1626 | algorithm | ||
| 1627 | ✗ | txt := initValsDefault(txt, i_var, "stringVars", 0); | |
| 1628 | ✗ | txt := Tpl.nextIter(txt); | |
| 1629 | then txt; | ||
| 1630 | end match; | ||
| 1631 | end for; | ||
| 1632 | end lm_87; | ||
| 1633 | |||
| 1634 | protected function lm_88 | ||
| 1635 | input output Tpl.Text txt; | ||
| 1636 | input list<SimCodeVar.SimVar> items; | ||
| 1637 | algorithm | ||
| 1638 | ✗ | for lstElt_88 in items loop | |
| 1639 | txt := match lstElt_88 | ||
| 1640 | local | ||
| 1641 | SimCodeVar.SimVar i_var; | ||
| 1642 | |||
| 1643 | case i_var | ||
| 1644 | algorithm | ||
| 1645 | ✗ | txt := initParamsDefault(txt, i_var, "realParameter"); | |
| 1646 | ✗ | txt := Tpl.nextIter(txt); | |
| 1647 | then txt; | ||
| 1648 | end match; | ||
| 1649 | end for; | ||
| 1650 | end lm_88; | ||
| 1651 | |||
| 1652 | protected function lm_89 | ||
| 1653 | input output Tpl.Text txt; | ||
| 1654 | input list<SimCodeVar.SimVar> items; | ||
| 1655 | algorithm | ||
| 1656 | ✗ | for lstElt_89 in items loop | |
| 1657 | txt := match lstElt_89 | ||
| 1658 | local | ||
| 1659 | SimCodeVar.SimVar i_var; | ||
| 1660 | |||
| 1661 | case i_var | ||
| 1662 | algorithm | ||
| 1663 | ✗ | txt := initParamsDefault(txt, i_var, "integerParameter"); | |
| 1664 | ✗ | txt := Tpl.nextIter(txt); | |
| 1665 | then txt; | ||
| 1666 | end match; | ||
| 1667 | end for; | ||
| 1668 | end lm_89; | ||
| 1669 | |||
| 1670 | protected function lm_90 | ||
| 1671 | input output Tpl.Text txt; | ||
| 1672 | input list<SimCodeVar.SimVar> items; | ||
| 1673 | algorithm | ||
| 1674 | ✗ | for lstElt_90 in items loop | |
| 1675 | txt := match lstElt_90 | ||
| 1676 | local | ||
| 1677 | SimCodeVar.SimVar i_var; | ||
| 1678 | |||
| 1679 | case i_var | ||
| 1680 | algorithm | ||
| 1681 | ✗ | txt := initParamsDefault(txt, i_var, "booleanParameter"); | |
| 1682 | ✗ | txt := Tpl.nextIter(txt); | |
| 1683 | then txt; | ||
| 1684 | end match; | ||
| 1685 | end for; | ||
| 1686 | end lm_90; | ||
| 1687 | |||
| 1688 | protected function lm_91 | ||
| 1689 | input output Tpl.Text txt; | ||
| 1690 | input list<SimCodeVar.SimVar> items; | ||
| 1691 | algorithm | ||
| 1692 | ✗ | for lstElt_91 in items loop | |
| 1693 | txt := match lstElt_91 | ||
| 1694 | local | ||
| 1695 | SimCodeVar.SimVar i_var; | ||
| 1696 | |||
| 1697 | case i_var | ||
| 1698 | algorithm | ||
| 1699 | ✗ | txt := initParamsDefault(txt, i_var, "stringParameter"); | |
| 1700 | ✗ | txt := Tpl.nextIter(txt); | |
| 1701 | then txt; | ||
| 1702 | end match; | ||
| 1703 | end for; | ||
| 1704 | end lm_91; | ||
| 1705 | |||
| 1706 | public function setDefaultStartValues | ||
| 1707 | input Tpl.Text in_txt; | ||
| 1708 | input SimCode.ModelInfo in_a_modelInfo; | ||
| 1709 | |||
| 1710 | output Tpl.Text out_txt; | ||
| 1711 | algorithm | ||
| 1712 | out_txt := | ||
| 1713 | match(in_txt, in_a_modelInfo) | ||
| 1714 | local | ||
| 1715 | Tpl.Text txt; | ||
| 1716 | list<SimCodeVar.SimVar> i_vars_stringParamVars; | ||
| 1717 | list<SimCodeVar.SimVar> i_vars_boolParamVars; | ||
| 1718 | list<SimCodeVar.SimVar> i_vars_intParamVars; | ||
| 1719 | list<SimCodeVar.SimVar> i_vars_paramVars; | ||
| 1720 | list<SimCodeVar.SimVar> i_vars_stringAlgVars; | ||
| 1721 | list<SimCodeVar.SimVar> i_vars_boolAlgVars; | ||
| 1722 | list<SimCodeVar.SimVar> i_vars_intAlgVars; | ||
| 1723 | Integer i_numAlgVars; | ||
| 1724 | list<SimCodeVar.SimVar> i_vars_discreteAlgVars; | ||
| 1725 | list<SimCodeVar.SimVar> i_vars_algVars; | ||
| 1726 | Integer i_numStateVars; | ||
| 1727 | list<SimCodeVar.SimVar> i_vars_derivativeVars; | ||
| 1728 | list<SimCodeVar.SimVar> i_vars_stateVars; | ||
| 1729 | |||
| 1730 | case ( txt, | ||
| 1731 | SimCode.MODELINFO(varInfo = SimCode.VARINFO(numStateVars = i_numStateVars, numAlgVars = i_numAlgVars), vars = SimCodeVar.SIMVARS(stateVars = i_vars_stateVars, derivativeVars = i_vars_derivativeVars, algVars = i_vars_algVars, discreteAlgVars = i_vars_discreteAlgVars, intAlgVars = i_vars_intAlgVars, boolAlgVars = i_vars_boolAlgVars, stringAlgVars = i_vars_stringAlgVars, paramVars = i_vars_paramVars, intParamVars = i_vars_intParamVars, boolParamVars = i_vars_boolParamVars, stringParamVars = i_vars_stringParamVars)) ) | ||
| 1732 | algorithm | ||
| 1733 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1734 | "// Set values for all variables that define a start value\n", | ||
| 1735 | "void setDefaultStartValues(ModelInstance *comp) {\n", | ||
| 1736 | "/*\n" | ||
| 1737 | }, true)); | ||
| 1738 | ✗ | 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())); | |
| 1739 | ✗ | txt := lm_81(txt, i_vars_stateVars); | |
| 1740 | ✗ | txt := Tpl.popIter(txt); | |
| 1741 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1742 | ✗ | 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())); | |
| 1743 | ✗ | txt := lm_82(txt, i_vars_derivativeVars, i_numStateVars); | |
| 1744 | ✗ | txt := Tpl.popIter(txt); | |
| 1745 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1746 | ✗ | 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())); | |
| 1747 | ✗ | txt := lm_83(txt, i_vars_algVars, i_numStateVars); | |
| 1748 | ✗ | txt := Tpl.popIter(txt); | |
| 1749 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1750 | ✗ | 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())); | |
| 1751 | ✗ | txt := lm_84(txt, i_vars_discreteAlgVars, i_numAlgVars, i_numStateVars); | |
| 1752 | ✗ | txt := Tpl.popIter(txt); | |
| 1753 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1754 | ✗ | 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())); | |
| 1755 | ✗ | txt := lm_85(txt, i_vars_intAlgVars); | |
| 1756 | ✗ | txt := Tpl.popIter(txt); | |
| 1757 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1758 | ✗ | 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())); | |
| 1759 | ✗ | txt := lm_86(txt, i_vars_boolAlgVars); | |
| 1760 | ✗ | txt := Tpl.popIter(txt); | |
| 1761 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1762 | ✗ | 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())); | |
| 1763 | ✗ | txt := lm_87(txt, i_vars_stringAlgVars); | |
| 1764 | ✗ | txt := Tpl.popIter(txt); | |
| 1765 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1766 | ✗ | 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())); | |
| 1767 | ✗ | txt := lm_88(txt, i_vars_paramVars); | |
| 1768 | ✗ | txt := Tpl.popIter(txt); | |
| 1769 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1770 | ✗ | 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())); | |
| 1771 | ✗ | txt := lm_89(txt, i_vars_intParamVars); | |
| 1772 | ✗ | txt := Tpl.popIter(txt); | |
| 1773 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1774 | ✗ | 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())); | |
| 1775 | ✗ | txt := lm_90(txt, i_vars_boolParamVars); | |
| 1776 | ✗ | txt := Tpl.popIter(txt); | |
| 1777 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1778 | ✗ | 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())); | |
| 1779 | ✗ | txt := lm_91(txt, i_vars_stringParamVars); | |
| 1780 | ✗ | txt := Tpl.popIter(txt); | |
| 1781 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1782 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1783 | "*/\n", | ||
| 1784 | "}" | ||
| 1785 | }, false)); | ||
| 1786 | then txt; | ||
| 1787 | |||
| 1788 | case ( txt, | ||
| 1789 | _ ) | ||
| 1790 | then txt; | ||
| 1791 | end match; | ||
| 1792 | end setDefaultStartValues; | ||
| 1793 | |||
| 1794 | protected function lm_93 | ||
| 1795 | input output Tpl.Text txt; | ||
| 1796 | input list<SimCodeVar.SimVar> items; | ||
| 1797 | algorithm | ||
| 1798 | ✗ | for lstElt_93 in items loop | |
| 1799 | txt := match lstElt_93 | ||
| 1800 | local | ||
| 1801 | SimCodeVar.SimVar i_var; | ||
| 1802 | |||
| 1803 | case i_var | ||
| 1804 | algorithm | ||
| 1805 | ✗ | txt := initVals(txt, i_var, "realVars", 0); | |
| 1806 | ✗ | txt := Tpl.nextIter(txt); | |
| 1807 | then txt; | ||
| 1808 | end match; | ||
| 1809 | end for; | ||
| 1810 | end lm_93; | ||
| 1811 | |||
| 1812 | protected function lm_94 | ||
| 1813 | input output Tpl.Text txt; | ||
| 1814 | input list<SimCodeVar.SimVar> items; | ||
| 1815 | input Integer a_numStateVars; | ||
| 1816 | algorithm | ||
| 1817 | ✗ | for lstElt_94 in items loop | |
| 1818 | txt := match lstElt_94 | ||
| 1819 | local | ||
| 1820 | SimCodeVar.SimVar i_var; | ||
| 1821 | |||
| 1822 | case i_var | ||
| 1823 | algorithm | ||
| 1824 | ✗ | txt := initVals(txt, i_var, "realVars", a_numStateVars); | |
| 1825 | ✗ | txt := Tpl.nextIter(txt); | |
| 1826 | then txt; | ||
| 1827 | end match; | ||
| 1828 | end for; | ||
| 1829 | end lm_94; | ||
| 1830 | |||
| 1831 | protected function lm_95 | ||
| 1832 | input output Tpl.Text txt; | ||
| 1833 | input list<SimCodeVar.SimVar> items; | ||
| 1834 | input Integer a_numStateVars; | ||
| 1835 | algorithm | ||
| 1836 | ✗ | for lstElt_95 in items loop | |
| 1837 | txt := match lstElt_95 | ||
| 1838 | local | ||
| 1839 | SimCodeVar.SimVar i_var; | ||
| 1840 | Integer ret_0; | ||
| 1841 | |||
| 1842 | case i_var | ||
| 1843 | algorithm | ||
| 1844 | ✗ | ret_0 := intMul(2, a_numStateVars); | |
| 1845 | ✗ | txt := initVals(txt, i_var, "realVars", ret_0); | |
| 1846 | ✗ | txt := Tpl.nextIter(txt); | |
| 1847 | then txt; | ||
| 1848 | end match; | ||
| 1849 | end for; | ||
| 1850 | end lm_95; | ||
| 1851 | |||
| 1852 | protected function lm_96 | ||
| 1853 | input output Tpl.Text txt; | ||
| 1854 | input list<SimCodeVar.SimVar> items; | ||
| 1855 | input Integer a_numAlgVars; | ||
| 1856 | input Integer a_numStateVars; | ||
| 1857 | algorithm | ||
| 1858 | ✗ | for lstElt_96 in items loop | |
| 1859 | txt := match lstElt_96 | ||
| 1860 | local | ||
| 1861 | SimCodeVar.SimVar i_var; | ||
| 1862 | Integer ret_1; | ||
| 1863 | Integer ret_0; | ||
| 1864 | |||
| 1865 | case i_var | ||
| 1866 | algorithm | ||
| 1867 | ✗ | ret_0 := intMul(2, a_numStateVars); | |
| 1868 | ✗ | ret_1 := intAdd(ret_0, a_numAlgVars); | |
| 1869 | ✗ | txt := initVals(txt, i_var, "realVars", ret_1); | |
| 1870 | ✗ | txt := Tpl.nextIter(txt); | |
| 1871 | then txt; | ||
| 1872 | end match; | ||
| 1873 | end for; | ||
| 1874 | end lm_96; | ||
| 1875 | |||
| 1876 | protected function lm_97 | ||
| 1877 | input output Tpl.Text txt; | ||
| 1878 | input list<SimCodeVar.SimVar> items; | ||
| 1879 | algorithm | ||
| 1880 | ✗ | for lstElt_97 in items loop | |
| 1881 | txt := match lstElt_97 | ||
| 1882 | local | ||
| 1883 | SimCodeVar.SimVar i_var; | ||
| 1884 | |||
| 1885 | case i_var | ||
| 1886 | algorithm | ||
| 1887 | ✗ | txt := initVals(txt, i_var, "integerVars", 0); | |
| 1888 | ✗ | txt := Tpl.nextIter(txt); | |
| 1889 | then txt; | ||
| 1890 | end match; | ||
| 1891 | end for; | ||
| 1892 | end lm_97; | ||
| 1893 | |||
| 1894 | protected function lm_98 | ||
| 1895 | input output Tpl.Text txt; | ||
| 1896 | input list<SimCodeVar.SimVar> items; | ||
| 1897 | algorithm | ||
| 1898 | ✗ | for lstElt_98 in items loop | |
| 1899 | txt := match lstElt_98 | ||
| 1900 | local | ||
| 1901 | SimCodeVar.SimVar i_var; | ||
| 1902 | |||
| 1903 | case i_var | ||
| 1904 | algorithm | ||
| 1905 | ✗ | txt := initVals(txt, i_var, "booleanVars", 0); | |
| 1906 | ✗ | txt := Tpl.nextIter(txt); | |
| 1907 | then txt; | ||
| 1908 | end match; | ||
| 1909 | end for; | ||
| 1910 | end lm_98; | ||
| 1911 | |||
| 1912 | protected function lm_99 | ||
| 1913 | input output Tpl.Text txt; | ||
| 1914 | input list<SimCodeVar.SimVar> items; | ||
| 1915 | algorithm | ||
| 1916 | ✗ | for lstElt_99 in items loop | |
| 1917 | txt := match lstElt_99 | ||
| 1918 | local | ||
| 1919 | SimCodeVar.SimVar i_var; | ||
| 1920 | |||
| 1921 | case i_var | ||
| 1922 | algorithm | ||
| 1923 | ✗ | txt := initVals(txt, i_var, "stringVars", 0); | |
| 1924 | ✗ | txt := Tpl.nextIter(txt); | |
| 1925 | then txt; | ||
| 1926 | end match; | ||
| 1927 | end for; | ||
| 1928 | end lm_99; | ||
| 1929 | |||
| 1930 | protected function lm_100 | ||
| 1931 | input output Tpl.Text txt; | ||
| 1932 | input list<SimCodeVar.SimVar> items; | ||
| 1933 | algorithm | ||
| 1934 | ✗ | for lstElt_100 in items loop | |
| 1935 | txt := match lstElt_100 | ||
| 1936 | local | ||
| 1937 | SimCodeVar.SimVar i_var; | ||
| 1938 | |||
| 1939 | case i_var | ||
| 1940 | algorithm | ||
| 1941 | ✗ | txt := initParams(txt, i_var, "realParameter"); | |
| 1942 | ✗ | txt := Tpl.nextIter(txt); | |
| 1943 | then txt; | ||
| 1944 | end match; | ||
| 1945 | end for; | ||
| 1946 | end lm_100; | ||
| 1947 | |||
| 1948 | protected function lm_101 | ||
| 1949 | input output Tpl.Text txt; | ||
| 1950 | input list<SimCodeVar.SimVar> items; | ||
| 1951 | algorithm | ||
| 1952 | ✗ | for lstElt_101 in items loop | |
| 1953 | txt := match lstElt_101 | ||
| 1954 | local | ||
| 1955 | SimCodeVar.SimVar i_var; | ||
| 1956 | |||
| 1957 | case i_var | ||
| 1958 | algorithm | ||
| 1959 | ✗ | txt := initParams(txt, i_var, "integerParameter"); | |
| 1960 | ✗ | txt := Tpl.nextIter(txt); | |
| 1961 | then txt; | ||
| 1962 | end match; | ||
| 1963 | end for; | ||
| 1964 | end lm_101; | ||
| 1965 | |||
| 1966 | protected function lm_102 | ||
| 1967 | input output Tpl.Text txt; | ||
| 1968 | input list<SimCodeVar.SimVar> items; | ||
| 1969 | algorithm | ||
| 1970 | ✗ | for lstElt_102 in items loop | |
| 1971 | txt := match lstElt_102 | ||
| 1972 | local | ||
| 1973 | SimCodeVar.SimVar i_var; | ||
| 1974 | |||
| 1975 | case i_var | ||
| 1976 | algorithm | ||
| 1977 | ✗ | txt := initParams(txt, i_var, "booleanParameter"); | |
| 1978 | ✗ | txt := Tpl.nextIter(txt); | |
| 1979 | then txt; | ||
| 1980 | end match; | ||
| 1981 | end for; | ||
| 1982 | end lm_102; | ||
| 1983 | |||
| 1984 | protected function lm_103 | ||
| 1985 | input output Tpl.Text txt; | ||
| 1986 | input list<SimCodeVar.SimVar> items; | ||
| 1987 | algorithm | ||
| 1988 | ✗ | for lstElt_103 in items loop | |
| 1989 | txt := match lstElt_103 | ||
| 1990 | local | ||
| 1991 | SimCodeVar.SimVar i_var; | ||
| 1992 | |||
| 1993 | case i_var | ||
| 1994 | algorithm | ||
| 1995 | ✗ | txt := initParams(txt, i_var, "stringParameter"); | |
| 1996 | ✗ | txt := Tpl.nextIter(txt); | |
| 1997 | then txt; | ||
| 1998 | end match; | ||
| 1999 | end for; | ||
| 2000 | end lm_103; | ||
| 2001 | |||
| 2002 | public function setStartValues | ||
| 2003 | input Tpl.Text in_txt; | ||
| 2004 | input SimCode.ModelInfo in_a_modelInfo; | ||
| 2005 | |||
| 2006 | output Tpl.Text out_txt; | ||
| 2007 | algorithm | ||
| 2008 | out_txt := | ||
| 2009 | match(in_txt, in_a_modelInfo) | ||
| 2010 | local | ||
| 2011 | Tpl.Text txt; | ||
| 2012 | list<SimCodeVar.SimVar> i_vars_stringParamVars; | ||
| 2013 | list<SimCodeVar.SimVar> i_vars_boolParamVars; | ||
| 2014 | list<SimCodeVar.SimVar> i_vars_intParamVars; | ||
| 2015 | list<SimCodeVar.SimVar> i_vars_paramVars; | ||
| 2016 | list<SimCodeVar.SimVar> i_vars_stringAlgVars; | ||
| 2017 | list<SimCodeVar.SimVar> i_vars_boolAlgVars; | ||
| 2018 | list<SimCodeVar.SimVar> i_vars_intAlgVars; | ||
| 2019 | Integer i_numAlgVars; | ||
| 2020 | list<SimCodeVar.SimVar> i_vars_discreteAlgVars; | ||
| 2021 | list<SimCodeVar.SimVar> i_vars_algVars; | ||
| 2022 | Integer i_numStateVars; | ||
| 2023 | list<SimCodeVar.SimVar> i_vars_derivativeVars; | ||
| 2024 | list<SimCodeVar.SimVar> i_vars_stateVars; | ||
| 2025 | |||
| 2026 | case ( txt, | ||
| 2027 | SimCode.MODELINFO(varInfo = SimCode.VARINFO(numStateVars = i_numStateVars, numAlgVars = i_numAlgVars), vars = SimCodeVar.SIMVARS(stateVars = i_vars_stateVars, derivativeVars = i_vars_derivativeVars, algVars = i_vars_algVars, discreteAlgVars = i_vars_discreteAlgVars, intAlgVars = i_vars_intAlgVars, boolAlgVars = i_vars_boolAlgVars, stringAlgVars = i_vars_stringAlgVars, paramVars = i_vars_paramVars, intParamVars = i_vars_intParamVars, boolParamVars = i_vars_boolParamVars, stringParamVars = i_vars_stringParamVars)) ) | ||
| 2028 | algorithm | ||
| 2029 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2030 | "// Set values for all variables that define a start value\n", | ||
| 2031 | "void setStartValues(ModelInstance *comp) {\n", | ||
| 2032 | "/*\n" | ||
| 2033 | }, true)); | ||
| 2034 | ✗ | 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())); | |
| 2035 | ✗ | txt := lm_93(txt, i_vars_stateVars); | |
| 2036 | ✗ | txt := Tpl.popIter(txt); | |
| 2037 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2038 | ✗ | 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())); | |
| 2039 | ✗ | txt := lm_94(txt, i_vars_derivativeVars, i_numStateVars); | |
| 2040 | ✗ | txt := Tpl.popIter(txt); | |
| 2041 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2042 | ✗ | 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())); | |
| 2043 | ✗ | txt := lm_95(txt, i_vars_algVars, i_numStateVars); | |
| 2044 | ✗ | txt := Tpl.popIter(txt); | |
| 2045 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2046 | ✗ | 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())); | |
| 2047 | ✗ | txt := lm_96(txt, i_vars_discreteAlgVars, i_numAlgVars, i_numStateVars); | |
| 2048 | ✗ | txt := Tpl.popIter(txt); | |
| 2049 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2050 | ✗ | 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())); | |
| 2051 | ✗ | txt := lm_97(txt, i_vars_intAlgVars); | |
| 2052 | ✗ | txt := Tpl.popIter(txt); | |
| 2053 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2054 | ✗ | 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())); | |
| 2055 | ✗ | txt := lm_98(txt, i_vars_boolAlgVars); | |
| 2056 | ✗ | txt := Tpl.popIter(txt); | |
| 2057 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2058 | ✗ | 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())); | |
| 2059 | ✗ | txt := lm_99(txt, i_vars_stringAlgVars); | |
| 2060 | ✗ | txt := Tpl.popIter(txt); | |
| 2061 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2062 | ✗ | 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())); | |
| 2063 | ✗ | txt := lm_100(txt, i_vars_paramVars); | |
| 2064 | ✗ | txt := Tpl.popIter(txt); | |
| 2065 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2066 | ✗ | 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())); | |
| 2067 | ✗ | txt := lm_101(txt, i_vars_intParamVars); | |
| 2068 | ✗ | txt := Tpl.popIter(txt); | |
| 2069 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2070 | ✗ | 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())); | |
| 2071 | ✗ | txt := lm_102(txt, i_vars_boolParamVars); | |
| 2072 | ✗ | txt := Tpl.popIter(txt); | |
| 2073 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2074 | ✗ | 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())); | |
| 2075 | ✗ | txt := lm_103(txt, i_vars_stringParamVars); | |
| 2076 | ✗ | txt := Tpl.popIter(txt); | |
| 2077 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2078 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2079 | "*/\n", | ||
| 2080 | "}" | ||
| 2081 | }, false)); | ||
| 2082 | then txt; | ||
| 2083 | |||
| 2084 | case ( txt, | ||
| 2085 | _ ) | ||
| 2086 | then txt; | ||
| 2087 | end match; | ||
| 2088 | end setStartValues; | ||
| 2089 | |||
| 2090 | protected function fun_105 | ||
| 2091 | input Tpl.Text in_txt; | ||
| 2092 | input Boolean in_mArg; | ||
| 2093 | input Integer in_a_offset; | ||
| 2094 | input Integer in_a_index; | ||
| 2095 | input String in_a_arrayName; | ||
| 2096 | |||
| 2097 | output Tpl.Text out_txt; | ||
| 2098 | algorithm | ||
| 2099 | out_txt := | ||
| 2100 | match(in_txt, in_mArg, in_a_offset, in_a_index, in_a_arrayName) | ||
| 2101 | local | ||
| 2102 | Tpl.Text txt; | ||
| 2103 | Integer a_offset; | ||
| 2104 | Integer a_index; | ||
| 2105 | String a_arrayName; | ||
| 2106 | Integer ret_2; | ||
| 2107 | Integer ret_1; | ||
| 2108 | Tpl.Text l_str; | ||
| 2109 | |||
| 2110 | case ( txt, | ||
| 2111 | false, | ||
| 2112 | a_offset, | ||
| 2113 | a_index, | ||
| 2114 | a_arrayName ) | ||
| 2115 | algorithm | ||
| 2116 | ✗ | l_str := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("comp->fmuData->modelData.")); | |
| 2117 | ✗ | l_str := Tpl.writeStr(l_str, a_arrayName); | |
| 2118 | ✗ | l_str := Tpl.writeTok(l_str, Tpl.ST_STRING("Data[")); | |
| 2119 | ✗ | ret_1 := intAdd(a_index, a_offset); | |
| 2120 | ✗ | l_str := Tpl.writeStr(l_str, intString(ret_1)); | |
| 2121 | ✗ | l_str := Tpl.writeTok(l_str, Tpl.ST_STRING("].attribute.start")); | |
| 2122 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 2123 | ✗ | txt := Tpl.writeText(txt, l_str); | |
| 2124 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = comp->fmuData->localData[0]->")); | |
| 2125 | ✗ | txt := Tpl.writeStr(txt, a_arrayName); | |
| 2126 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("[")); | |
| 2127 | ret_2 := intAdd(a_index, a_offset); | ||
| 2128 | ✗ | txt := Tpl.writeStr(txt, intString(ret_2)); | |
| 2129 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("];")); | |
| 2130 | ✗ | txt := Tpl.popBlock(txt); | |
| 2131 | then txt; | ||
| 2132 | |||
| 2133 | case ( txt, | ||
| 2134 | _, | ||
| 2135 | _, | ||
| 2136 | _, | ||
| 2137 | _ ) | ||
| 2138 | then txt; | ||
| 2139 | end match; | ||
| 2140 | end fun_105; | ||
| 2141 | |||
| 2142 | protected function fun_106 | ||
| 2143 | input Tpl.Text in_txt; | ||
| 2144 | input Boolean in_mArg; | ||
| 2145 | input Integer in_a_offset; | ||
| 2146 | input Integer in_a_index; | ||
| 2147 | input String in_a_arrayName; | ||
| 2148 | input DAE.ComponentRef in_a_name; | ||
| 2149 | |||
| 2150 | output Tpl.Text out_txt; | ||
| 2151 | algorithm | ||
| 2152 | out_txt := | ||
| 2153 | match(in_txt, in_mArg, in_a_offset, in_a_index, in_a_arrayName, in_a_name) | ||
| 2154 | local | ||
| 2155 | Tpl.Text txt; | ||
| 2156 | Integer a_offset; | ||
| 2157 | Integer a_index; | ||
| 2158 | String a_arrayName; | ||
| 2159 | DAE.ComponentRef a_name; | ||
| 2160 | Boolean ret_1; | ||
| 2161 | Tpl.Text txt_0; | ||
| 2162 | |||
| 2163 | case ( txt, | ||
| 2164 | false, | ||
| 2165 | a_offset, | ||
| 2166 | a_index, | ||
| 2167 | a_arrayName, | ||
| 2168 | a_name ) | ||
| 2169 | algorithm | ||
| 2170 | ✗ | txt_0 := CodegenUtil.crefStr(Tpl.emptyTxt, a_name); | |
| 2171 | ✗ | ret_1 := stringEq(Tpl.textString(txt_0), "der($dummy)"); | |
| 2172 | ✗ | txt := fun_105(txt, ret_1, a_offset, a_index, a_arrayName); | |
| 2173 | then txt; | ||
| 2174 | |||
| 2175 | case ( txt, | ||
| 2176 | _, | ||
| 2177 | _, | ||
| 2178 | _, | ||
| 2179 | _, | ||
| 2180 | _ ) | ||
| 2181 | then txt; | ||
| 2182 | end match; | ||
| 2183 | end fun_106; | ||
| 2184 | |||
| 2185 | public function initVals | ||
| 2186 | input Tpl.Text in_txt; | ||
| 2187 | input SimCodeVar.SimVar in_a_var; | ||
| 2188 | input String in_a_arrayName; | ||
| 2189 | input Integer in_a_offset; | ||
| 2190 | |||
| 2191 | output Tpl.Text out_txt; | ||
| 2192 | algorithm | ||
| 2193 | out_txt := | ||
| 2194 | match(in_txt, in_a_var, in_a_arrayName, in_a_offset) | ||
| 2195 | local | ||
| 2196 | Tpl.Text txt; | ||
| 2197 | String a_arrayName; | ||
| 2198 | Integer a_offset; | ||
| 2199 | Integer i_index; | ||
| 2200 | DAE.ComponentRef i_name; | ||
| 2201 | Boolean ret_1; | ||
| 2202 | Tpl.Text txt_0; | ||
| 2203 | |||
| 2204 | case ( txt, | ||
| 2205 | SimCodeVar.SIMVAR(name = i_name, index = i_index), | ||
| 2206 | a_arrayName, | ||
| 2207 | a_offset ) | ||
| 2208 | algorithm | ||
| 2209 | ✗ | txt_0 := CodegenUtil.crefStr(Tpl.emptyTxt, i_name); | |
| 2210 | ✗ | ret_1 := stringEq(Tpl.textString(txt_0), "$dummy"); | |
| 2211 | ✗ | txt := fun_106(txt, ret_1, a_offset, i_index, a_arrayName, i_name); | |
| 2212 | then txt; | ||
| 2213 | |||
| 2214 | case ( txt, | ||
| 2215 | _, | ||
| 2216 | _, | ||
| 2217 | _ ) | ||
| 2218 | then txt; | ||
| 2219 | end match; | ||
| 2220 | end initVals; | ||
| 2221 | |||
| 2222 | public function initParams | ||
| 2223 | input Tpl.Text in_txt; | ||
| 2224 | input SimCodeVar.SimVar in_a_var; | ||
| 2225 | input String in_a_arrayName; | ||
| 2226 | |||
| 2227 | output Tpl.Text out_txt; | ||
| 2228 | algorithm | ||
| 2229 | out_txt := | ||
| 2230 | match(in_txt, in_a_var, in_a_arrayName) | ||
| 2231 | local | ||
| 2232 | Tpl.Text txt; | ||
| 2233 | String a_arrayName; | ||
| 2234 | Integer i_index; | ||
| 2235 | Tpl.Text l_str; | ||
| 2236 | |||
| 2237 | case ( txt, | ||
| 2238 | SimCodeVar.SIMVAR(index = i_index), | ||
| 2239 | a_arrayName ) | ||
| 2240 | algorithm | ||
| 2241 | ✗ | l_str := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("comp->fmuData->modelData.")); | |
| 2242 | ✗ | l_str := Tpl.writeStr(l_str, a_arrayName); | |
| 2243 | ✗ | l_str := Tpl.writeTok(l_str, Tpl.ST_STRING("Data[")); | |
| 2244 | ✗ | l_str := Tpl.writeStr(l_str, intString(i_index)); | |
| 2245 | ✗ | l_str := Tpl.writeTok(l_str, Tpl.ST_STRING("].attribute.start")); | |
| 2246 | ✗ | txt := Tpl.writeText(txt, l_str); | |
| 2247 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = comp->fmuData->simulationInfo.")); | |
| 2248 | ✗ | txt := Tpl.writeStr(txt, a_arrayName); | |
| 2249 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("[")); | |
| 2250 | ✗ | txt := Tpl.writeStr(txt, intString(i_index)); | |
| 2251 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("];")); | |
| 2252 | then txt; | ||
| 2253 | |||
| 2254 | case ( txt, | ||
| 2255 | _, | ||
| 2256 | _ ) | ||
| 2257 | then txt; | ||
| 2258 | end match; | ||
| 2259 | end initParams; | ||
| 2260 | |||
| 2261 | protected function fun_109 | ||
| 2262 | input Tpl.Text in_txt; | ||
| 2263 | input DAE.Type in_a_type__; | ||
| 2264 | input Tpl.Text in_a_str; | ||
| 2265 | |||
| 2266 | output Tpl.Text out_txt; | ||
| 2267 | algorithm | ||
| 2268 | out_txt := | ||
| 2269 | match(in_txt, in_a_type__, in_a_str) | ||
| 2270 | local | ||
| 2271 | Tpl.Text txt; | ||
| 2272 | Tpl.Text a_str; | ||
| 2273 | |||
| 2274 | case ( txt, | ||
| 2275 | DAE.T_INTEGER(varLst = _), | ||
| 2276 | a_str ) | ||
| 2277 | algorithm | ||
| 2278 | ✗ | txt := Tpl.writeText(txt, a_str); | |
| 2279 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = 0;")); | |
| 2280 | then txt; | ||
| 2281 | |||
| 2282 | case ( txt, | ||
| 2283 | DAE.T_REAL(varLst = _), | ||
| 2284 | a_str ) | ||
| 2285 | algorithm | ||
| 2286 | ✗ | txt := Tpl.writeText(txt, a_str); | |
| 2287 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = 0;")); | |
| 2288 | then txt; | ||
| 2289 | |||
| 2290 | case ( txt, | ||
| 2291 | DAE.T_ENUMERATION(index = _), | ||
| 2292 | a_str ) | ||
| 2293 | algorithm | ||
| 2294 | ✗ | txt := Tpl.writeText(txt, a_str); | |
| 2295 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = 0;")); | |
| 2296 | then txt; | ||
| 2297 | |||
| 2298 | case ( txt, | ||
| 2299 | DAE.T_BOOL(varLst = _), | ||
| 2300 | a_str ) | ||
| 2301 | algorithm | ||
| 2302 | ✗ | txt := Tpl.writeText(txt, a_str); | |
| 2303 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = 0;")); | |
| 2304 | then txt; | ||
| 2305 | |||
| 2306 | case ( txt, | ||
| 2307 | DAE.T_STRING(varLst = _), | ||
| 2308 | a_str ) | ||
| 2309 | algorithm | ||
| 2310 | ✗ | txt := Tpl.writeText(txt, a_str); | |
| 2311 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = \"\";")); | |
| 2312 | then txt; | ||
| 2313 | |||
| 2314 | case ( txt, | ||
| 2315 | _, | ||
| 2316 | _ ) | ||
| 2317 | algorithm | ||
| 2318 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("UNKOWN_TYPE")); | |
| 2319 | then txt; | ||
| 2320 | end match; | ||
| 2321 | end fun_109; | ||
| 2322 | |||
| 2323 | protected function fun_110 | ||
| 2324 | input Tpl.Text in_txt; | ||
| 2325 | input Option<DAE.Exp> in_a_initialValue; | ||
| 2326 | input DAE.Type in_a_type__; | ||
| 2327 | input Tpl.Text in_a_str; | ||
| 2328 | |||
| 2329 | output Tpl.Text out_txt; | ||
| 2330 | algorithm | ||
| 2331 | out_txt := | ||
| 2332 | match(in_txt, in_a_initialValue, in_a_type__, in_a_str) | ||
| 2333 | local | ||
| 2334 | Tpl.Text txt; | ||
| 2335 | DAE.Type a_type__; | ||
| 2336 | Tpl.Text a_str; | ||
| 2337 | DAE.Exp i_v; | ||
| 2338 | |||
| 2339 | case ( txt, | ||
| 2340 | SOME(i_v), | ||
| 2341 | _, | ||
| 2342 | a_str ) | ||
| 2343 | algorithm | ||
| 2344 | ✗ | txt := Tpl.writeText(txt, a_str); | |
| 2345 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 2346 | ✗ | txt := initVal(txt, i_v); | |
| 2347 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2348 | then txt; | ||
| 2349 | |||
| 2350 | case ( txt, | ||
| 2351 | NONE(), | ||
| 2352 | a_type__, | ||
| 2353 | a_str ) | ||
| 2354 | algorithm | ||
| 2355 | ✗ | txt := fun_109(txt, a_type__, a_str); | |
| 2356 | then txt; | ||
| 2357 | |||
| 2358 | case ( txt, | ||
| 2359 | _, | ||
| 2360 | _, | ||
| 2361 | _ ) | ||
| 2362 | then txt; | ||
| 2363 | end match; | ||
| 2364 | end fun_110; | ||
| 2365 | |||
| 2366 | public function initValsDefault | ||
| 2367 | input Tpl.Text in_txt; | ||
| 2368 | input SimCodeVar.SimVar in_a_var; | ||
| 2369 | input String in_a_arrayName; | ||
| 2370 | input Integer in_a_offset; | ||
| 2371 | |||
| 2372 | output Tpl.Text out_txt; | ||
| 2373 | algorithm | ||
| 2374 | out_txt := | ||
| 2375 | match(in_txt, in_a_var, in_a_arrayName, in_a_offset) | ||
| 2376 | local | ||
| 2377 | Tpl.Text txt; | ||
| 2378 | String a_arrayName; | ||
| 2379 | Integer a_offset; | ||
| 2380 | DAE.Type i_type__; | ||
| 2381 | Option<DAE.Exp> i_initialValue; | ||
| 2382 | Integer i_index; | ||
| 2383 | Integer ret_1; | ||
| 2384 | Tpl.Text l_str; | ||
| 2385 | |||
| 2386 | case ( txt, | ||
| 2387 | SimCodeVar.SIMVAR(index = i_index, type_ = i_type__, initialValue = i_initialValue), | ||
| 2388 | a_arrayName, | ||
| 2389 | a_offset ) | ||
| 2390 | algorithm | ||
| 2391 | ✗ | l_str := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("comp->fmuData->modelData.")); | |
| 2392 | ✗ | l_str := Tpl.writeStr(l_str, a_arrayName); | |
| 2393 | ✗ | l_str := Tpl.writeTok(l_str, Tpl.ST_STRING("Data[")); | |
| 2394 | ✗ | ret_1 := intAdd(i_index, a_offset); | |
| 2395 | ✗ | l_str := Tpl.writeStr(l_str, intString(ret_1)); | |
| 2396 | ✗ | l_str := Tpl.writeTok(l_str, Tpl.ST_STRING("].attribute.start")); | |
| 2397 | ✗ | txt := fun_110(txt, i_initialValue, i_type__, l_str); | |
| 2398 | then txt; | ||
| 2399 | |||
| 2400 | case ( txt, | ||
| 2401 | _, | ||
| 2402 | _, | ||
| 2403 | _ ) | ||
| 2404 | then txt; | ||
| 2405 | end match; | ||
| 2406 | end initValsDefault; | ||
| 2407 | |||
| 2408 | protected function fun_112 | ||
| 2409 | input Tpl.Text in_txt; | ||
| 2410 | input Option<DAE.Exp> in_a_initialValue; | ||
| 2411 | input Tpl.Text in_a_str; | ||
| 2412 | |||
| 2413 | output Tpl.Text out_txt; | ||
| 2414 | algorithm | ||
| 2415 | out_txt := | ||
| 2416 | match(in_txt, in_a_initialValue, in_a_str) | ||
| 2417 | local | ||
| 2418 | Tpl.Text txt; | ||
| 2419 | Tpl.Text a_str; | ||
| 2420 | DAE.Exp i_v; | ||
| 2421 | |||
| 2422 | case ( txt, | ||
| 2423 | SOME(i_v), | ||
| 2424 | a_str ) | ||
| 2425 | algorithm | ||
| 2426 | ✗ | txt := Tpl.writeText(txt, a_str); | |
| 2427 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 2428 | ✗ | txt := initVal(txt, i_v); | |
| 2429 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2430 | then txt; | ||
| 2431 | |||
| 2432 | case ( txt, | ||
| 2433 | _, | ||
| 2434 | _ ) | ||
| 2435 | then txt; | ||
| 2436 | end match; | ||
| 2437 | end fun_112; | ||
| 2438 | |||
| 2439 | public function initParamsDefault | ||
| 2440 | input Tpl.Text in_txt; | ||
| 2441 | input SimCodeVar.SimVar in_a_var; | ||
| 2442 | input String in_a_arrayName; | ||
| 2443 | |||
| 2444 | output Tpl.Text out_txt; | ||
| 2445 | algorithm | ||
| 2446 | out_txt := | ||
| 2447 | match(in_txt, in_a_var, in_a_arrayName) | ||
| 2448 | local | ||
| 2449 | Tpl.Text txt; | ||
| 2450 | String a_arrayName; | ||
| 2451 | Option<DAE.Exp> i_initialValue; | ||
| 2452 | Integer i_index; | ||
| 2453 | Tpl.Text l_str; | ||
| 2454 | |||
| 2455 | case ( txt, | ||
| 2456 | SimCodeVar.SIMVAR(index = i_index, initialValue = i_initialValue), | ||
| 2457 | a_arrayName ) | ||
| 2458 | algorithm | ||
| 2459 | ✗ | l_str := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("comp->fmuData->modelData.")); | |
| 2460 | ✗ | l_str := Tpl.writeStr(l_str, a_arrayName); | |
| 2461 | ✗ | l_str := Tpl.writeTok(l_str, Tpl.ST_STRING("Data[")); | |
| 2462 | ✗ | l_str := Tpl.writeStr(l_str, intString(i_index)); | |
| 2463 | ✗ | l_str := Tpl.writeTok(l_str, Tpl.ST_STRING("].attribute.start")); | |
| 2464 | ✗ | txt := fun_112(txt, i_initialValue, l_str); | |
| 2465 | then txt; | ||
| 2466 | |||
| 2467 | case ( txt, | ||
| 2468 | _, | ||
| 2469 | _ ) | ||
| 2470 | then txt; | ||
| 2471 | end match; | ||
| 2472 | end initParamsDefault; | ||
| 2473 | |||
| 2474 | protected function fun_114 | ||
| 2475 | input Tpl.Text in_txt; | ||
| 2476 | input Boolean in_a_bool; | ||
| 2477 | |||
| 2478 | output Tpl.Text out_txt; | ||
| 2479 | algorithm | ||
| 2480 | out_txt := | ||
| 2481 | match(in_txt, in_a_bool) | ||
| 2482 | local | ||
| 2483 | Tpl.Text txt; | ||
| 2484 | |||
| 2485 | case ( txt, | ||
| 2486 | false ) | ||
| 2487 | algorithm | ||
| 2488 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 2489 | then txt; | ||
| 2490 | |||
| 2491 | case ( txt, | ||
| 2492 | _ ) | ||
| 2493 | algorithm | ||
| 2494 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("1")); | |
| 2495 | then txt; | ||
| 2496 | end match; | ||
| 2497 | end fun_114; | ||
| 2498 | |||
| 2499 | public function initVal | ||
| 2500 | input Tpl.Text in_txt; | ||
| 2501 | input DAE.Exp in_a_initialValue; | ||
| 2502 | |||
| 2503 | output Tpl.Text out_txt; | ||
| 2504 | algorithm | ||
| 2505 | out_txt := | ||
| 2506 | match(in_txt, in_a_initialValue) | ||
| 2507 | local | ||
| 2508 | Tpl.Text txt; | ||
| 2509 | Absyn.Path i_name; | ||
| 2510 | Integer i_index; | ||
| 2511 | Boolean i_bool; | ||
| 2512 | String i_string; | ||
| 2513 | Real i_real; | ||
| 2514 | Integer i_integer; | ||
| 2515 | String ret_0; | ||
| 2516 | |||
| 2517 | case ( txt, | ||
| 2518 | DAE.ICONST(integer = i_integer) ) | ||
| 2519 | algorithm | ||
| 2520 | ✗ | txt := Tpl.writeStr(txt, intString(i_integer)); | |
| 2521 | then txt; | ||
| 2522 | |||
| 2523 | case ( txt, | ||
| 2524 | DAE.RCONST(real = i_real) ) | ||
| 2525 | algorithm | ||
| 2526 | ✗ | txt := Tpl.writeStr(txt, realString(i_real)); | |
| 2527 | then txt; | ||
| 2528 | |||
| 2529 | case ( txt, | ||
| 2530 | DAE.SCONST(string = i_string) ) | ||
| 2531 | algorithm | ||
| 2532 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 2533 | ✗ | ret_0 := Util.escapeModelicaStringToXmlString(i_string); | |
| 2534 | ✗ | txt := Tpl.writeStr(txt, ret_0); | |
| 2535 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 2536 | then txt; | ||
| 2537 | |||
| 2538 | case ( txt, | ||
| 2539 | DAE.BCONST(bool = i_bool) ) | ||
| 2540 | algorithm | ||
| 2541 | ✗ | txt := fun_114(txt, i_bool); | |
| 2542 | then txt; | ||
| 2543 | |||
| 2544 | case ( txt, | ||
| 2545 | DAE.ENUM_LITERAL(index = i_index, name = i_name) ) | ||
| 2546 | algorithm | ||
| 2547 | ✗ | txt := Tpl.writeStr(txt, intString(i_index)); | |
| 2548 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/*ENUM:")); | |
| 2549 | ✗ | txt := CodegenUtil.dotPath(txt, i_name); | |
| 2550 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*/")); | |
| 2551 | then txt; | ||
| 2552 | |||
| 2553 | case ( txt, | ||
| 2554 | _ ) | ||
| 2555 | algorithm | ||
| 2556 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*ERROR* initial value of unknown type")); | |
| 2557 | then txt; | ||
| 2558 | end match; | ||
| 2559 | end initVal; | ||
| 2560 | |||
| 2561 | public function setExternalFunction | ||
| 2562 | input Tpl.Text in_txt; | ||
| 2563 | input SimCode.ModelInfo in_a_modelInfo; | ||
| 2564 | |||
| 2565 | output Tpl.Text out_txt; | ||
| 2566 | algorithm | ||
| 2567 | out_txt := | ||
| 2568 | match(in_txt, in_a_modelInfo) | ||
| 2569 | local | ||
| 2570 | Tpl.Text txt; | ||
| 2571 | list<SimCodeFunction.Function> i_functions; | ||
| 2572 | Tpl.Text l_externalFuncs; | ||
| 2573 | |||
| 2574 | case ( txt, | ||
| 2575 | SimCode.MODELINFO(vars = SimCodeVar.SIMVARS(stateVars = _), functions = i_functions) ) | ||
| 2576 | algorithm | ||
| 2577 | ✗ | l_externalFuncs := setExternalFunctionsSwitch(Tpl.emptyTxt, i_functions); | |
| 2578 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2579 | "fmiStatus setExternalFunction(ModelInstance* c, const fmiValueReference vr, const void* value){\n", | ||
| 2580 | " switch (vr) {\n", | ||
| 2581 | " /*\n" | ||
| 2582 | }, true)); | ||
| 2583 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(6)); | |
| 2584 | ✗ | txt := Tpl.writeText(txt, l_externalFuncs); | |
| 2585 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2586 | ✗ | txt := Tpl.popBlock(txt); | |
| 2587 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2588 | " */\n", | ||
| 2589 | " default:\n", | ||
| 2590 | " return fmiError;\n", | ||
| 2591 | " }\n", | ||
| 2592 | " return fmiOK;\n", | ||
| 2593 | "}\n", | ||
| 2594 | "\n" | ||
| 2595 | }, true)); | ||
| 2596 | then txt; | ||
| 2597 | |||
| 2598 | case ( txt, | ||
| 2599 | _ ) | ||
| 2600 | then txt; | ||
| 2601 | end match; | ||
| 2602 | end setExternalFunction; | ||
| 2603 | |||
| 2604 | protected function lm_117 | ||
| 2605 | input output Tpl.Text txt; | ||
| 2606 | input list<SimCodeFunction.Function> items; | ||
| 2607 | algorithm | ||
| 2608 | ✗ | for lstElt_117 in items loop | |
| 2609 | txt := match lstElt_117 | ||
| 2610 | local | ||
| 2611 | SimCodeFunction.Function i_fn; | ||
| 2612 | |||
| 2613 | case i_fn | ||
| 2614 | algorithm | ||
| 2615 | ✗ | txt := setExternalFunctionSwitch(txt, i_fn); | |
| 2616 | ✗ | txt := Tpl.nextIter(txt); | |
| 2617 | then txt; | ||
| 2618 | end match; | ||
| 2619 | end for; | ||
| 2620 | end lm_117; | ||
| 2621 | |||
| 2622 | public function setExternalFunctionsSwitch | ||
| 2623 | input Tpl.Text txt; | ||
| 2624 | input list<SimCodeFunction.Function> a_functions; | ||
| 2625 | |||
| 2626 | output Tpl.Text out_txt; | ||
| 2627 | algorithm | ||
| 2628 | ✗ | 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())); | |
| 2629 | ✗ | out_txt := lm_117(out_txt, a_functions); | |
| 2630 | ✗ | out_txt := Tpl.popIter(out_txt); | |
| 2631 | end setExternalFunctionsSwitch; | ||
| 2632 | |||
| 2633 | public function setExternalFunctionSwitch | ||
| 2634 | input Tpl.Text in_txt; | ||
| 2635 | input SimCodeFunction.Function in_a_fn; | ||
| 2636 | |||
| 2637 | output Tpl.Text out_txt; | ||
| 2638 | algorithm | ||
| 2639 | out_txt := | ||
| 2640 | match(in_txt, in_a_fn) | ||
| 2641 | local | ||
| 2642 | Tpl.Text txt; | ||
| 2643 | String i_language; | ||
| 2644 | String i_extName; | ||
| 2645 | Tpl.Text l_fname; | ||
| 2646 | |||
| 2647 | case ( txt, | ||
| 2648 | SimCodeFunction.EXTERNAL_FUNCTION(dynamicLoad = true, extName = i_extName, language = i_language) ) | ||
| 2649 | algorithm | ||
| 2650 | ✗ | l_fname := CodegenUtil.extFunctionName(Tpl.emptyTxt, i_extName, i_language); | |
| 2651 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("case $P")); | |
| 2652 | ✗ | txt := Tpl.writeText(txt, l_fname); | |
| 2653 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" : ptr_")); | |
| 2654 | ✗ | txt := Tpl.writeText(txt, l_fname); | |
| 2655 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("=(ptrT_")); | |
| 2656 | ✗ | txt := Tpl.writeText(txt, l_fname); | |
| 2657 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")value; break;")); | |
| 2658 | then txt; | ||
| 2659 | |||
| 2660 | case ( txt, | ||
| 2661 | _ ) | ||
| 2662 | then txt; | ||
| 2663 | end match; | ||
| 2664 | end setExternalFunctionSwitch; | ||
| 2665 | |||
| 2666 | protected function fun_120 | ||
| 2667 | input Tpl.Text in_txt; | ||
| 2668 | input SimCode.ModelInfo in_a_modelInfo; | ||
| 2669 | input SimCode.SimCode in_a_simCode; | ||
| 2670 | input String in_a_direction; | ||
| 2671 | input String in_a_modelShortName; | ||
| 2672 | |||
| 2673 | output Tpl.Text out_txt; | ||
| 2674 | algorithm | ||
| 2675 | out_txt := | ||
| 2676 | match(in_txt, in_a_modelInfo, in_a_simCode, in_a_direction, in_a_modelShortName) | ||
| 2677 | local | ||
| 2678 | Tpl.Text txt; | ||
| 2679 | SimCode.SimCode a_simCode; | ||
| 2680 | String a_direction; | ||
| 2681 | String a_modelShortName; | ||
| 2682 | list<SimCodeVar.SimVar> i_vars_stringAliasVars; | ||
| 2683 | list<SimCodeVar.SimVar> i_vars_stringParamVars; | ||
| 2684 | list<SimCodeVar.SimVar> i_vars_stringAlgVars; | ||
| 2685 | list<SimCodeVar.SimVar> i_vars_boolAliasVars; | ||
| 2686 | list<SimCodeVar.SimVar> i_vars_boolParamVars; | ||
| 2687 | list<SimCodeVar.SimVar> i_vars_boolAlgVars; | ||
| 2688 | list<SimCodeVar.SimVar> i_vars_intAliasVars; | ||
| 2689 | list<SimCodeVar.SimVar> i_vars_intParamVars; | ||
| 2690 | list<SimCodeVar.SimVar> i_vars_intAlgVars; | ||
| 2691 | list<SimCodeVar.SimVar> i_vars_aliasVars; | ||
| 2692 | Integer i_numParams; | ||
| 2693 | Integer i_numDiscreteReal; | ||
| 2694 | Integer i_numAlgVars; | ||
| 2695 | Integer i_numStateVars; | ||
| 2696 | Integer ret_12; | ||
| 2697 | Integer ret_11; | ||
| 2698 | Integer ret_10; | ||
| 2699 | Integer ret_9; | ||
| 2700 | Integer ret_8; | ||
| 2701 | Integer ret_7; | ||
| 2702 | Integer ret_6; | ||
| 2703 | Integer ret_5; | ||
| 2704 | Integer ret_4; | ||
| 2705 | Integer ret_3; | ||
| 2706 | Integer ret_2; | ||
| 2707 | Integer ret_1; | ||
| 2708 | Integer ret_0; | ||
| 2709 | |||
| 2710 | case ( txt, | ||
| 2711 | SimCode.MODELINFO(vars = SimCodeVar.SIMVARS(aliasVars = i_vars_aliasVars, intAlgVars = i_vars_intAlgVars, intParamVars = i_vars_intParamVars, intAliasVars = i_vars_intAliasVars, boolAlgVars = i_vars_boolAlgVars, boolParamVars = i_vars_boolParamVars, boolAliasVars = i_vars_boolAliasVars, stringAlgVars = i_vars_stringAlgVars, stringParamVars = i_vars_stringParamVars, stringAliasVars = i_vars_stringAliasVars), varInfo = SimCode.VARINFO(numStateVars = i_numStateVars, numAlgVars = i_numAlgVars, numDiscreteReal = i_numDiscreteReal, numParams = i_numParams)), | ||
| 2712 | a_simCode, | ||
| 2713 | a_direction, | ||
| 2714 | a_modelShortName ) | ||
| 2715 | algorithm | ||
| 2716 | 18 | ret_0 := intMul(2, i_numStateVars); | |
| 2717 | 18 | ret_1 := intAdd(ret_0, i_numAlgVars); | |
| 2718 | 18 | ret_2 := intAdd(ret_1, i_numDiscreteReal); | |
| 2719 | 18 | ret_3 := intAdd(ret_2, i_numParams); | |
| 2720 | 18 | txt := accessVarsFunction(txt, a_simCode, a_direction, a_modelShortName, "Real", "Real", "double", ret_3, i_vars_aliasVars); | |
| 2721 | 18 | txt := Tpl.softNewLine(txt); | |
| 2722 | 18 | ret_4 := listLength(i_vars_intAlgVars); | |
| 2723 | 18 | ret_5 := listLength(i_vars_intParamVars); | |
| 2724 | 18 | ret_6 := intAdd(ret_4, ret_5); | |
| 2725 | 18 | txt := accessVarsFunction(txt, a_simCode, a_direction, a_modelShortName, "Integer", "Int", "int", ret_6, i_vars_intAliasVars); | |
| 2726 | 18 | txt := Tpl.softNewLine(txt); | |
| 2727 | 18 | ret_7 := listLength(i_vars_boolAlgVars); | |
| 2728 | 18 | ret_8 := listLength(i_vars_boolParamVars); | |
| 2729 | 18 | ret_9 := intAdd(ret_7, ret_8); | |
| 2730 | 18 | txt := accessVarsFunction(txt, a_simCode, a_direction, a_modelShortName, "Boolean", "Bool", "int", ret_9, i_vars_boolAliasVars); | |
| 2731 | 18 | txt := Tpl.softNewLine(txt); | |
| 2732 | 18 | ret_10 := listLength(i_vars_stringAlgVars); | |
| 2733 | 18 | ret_11 := listLength(i_vars_stringParamVars); | |
| 2734 | 18 | ret_12 := intAdd(ret_10, ret_11); | |
| 2735 | 18 | txt := accessVarsFunction(txt, a_simCode, a_direction, a_modelShortName, "String", "String", "string", ret_12, i_vars_stringAliasVars); | |
| 2736 | then txt; | ||
| 2737 | |||
| 2738 | case ( txt, | ||
| 2739 | _, | ||
| 2740 | _, | ||
| 2741 | _, | ||
| 2742 | _ ) | ||
| 2743 | then txt; | ||
| 2744 | end match; | ||
| 2745 | end fun_120; | ||
| 2746 | |||
| 2747 | public function accessFunctions | ||
| 2748 | input Tpl.Text txt; | ||
| 2749 | input SimCode.SimCode a_simCode; | ||
| 2750 | input String a_direction; | ||
| 2751 | input String a_modelShortName; | ||
| 2752 | input SimCode.ModelInfo a_modelInfo; | ||
| 2753 | |||
| 2754 | output Tpl.Text out_txt; | ||
| 2755 | algorithm | ||
| 2756 | 18 | out_txt := fun_120(txt, a_modelInfo, a_simCode, a_direction, a_modelShortName); | |
| 2757 | end accessFunctions; | ||
| 2758 | |||
| 2759 | protected function fun_122 | ||
| 2760 | input Tpl.Text in_txt; | ||
| 2761 | input Boolean in_mArg; | ||
| 2762 | |||
| 2763 | output Tpl.Text out_txt; | ||
| 2764 | algorithm | ||
| 2765 | out_txt := | ||
| 2766 | match(in_txt, in_mArg) | ||
| 2767 | local | ||
| 2768 | Tpl.Text txt; | ||
| 2769 | |||
| 2770 | case ( txt, | ||
| 2771 | false ) | ||
| 2772 | then txt; | ||
| 2773 | |||
| 2774 | case ( txt, | ||
| 2775 | _ ) | ||
| 2776 | algorithm | ||
| 2777 | 36 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("const")); | |
| 2778 | then txt; | ||
| 2779 | end match; | ||
| 2780 | end fun_122; | ||
| 2781 | |||
| 2782 | protected function fun_123 | ||
| 2783 | input Tpl.Text in_txt; | ||
| 2784 | input Boolean in_mArg; | ||
| 2785 | input String in_a_pointerName; | ||
| 2786 | |||
| 2787 | output Tpl.Text out_txt; | ||
| 2788 | algorithm | ||
| 2789 | out_txt := | ||
| 2790 | match(in_txt, in_mArg, in_a_pointerName) | ||
| 2791 | local | ||
| 2792 | Tpl.Text txt; | ||
| 2793 | String a_pointerName; | ||
| 2794 | |||
| 2795 | case ( txt, | ||
| 2796 | false, | ||
| 2797 | a_pointerName ) | ||
| 2798 | algorithm | ||
| 2799 | 36 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_pointerTo")); | |
| 2800 | 36 | txt := Tpl.writeStr(txt, a_pointerName); | |
| 2801 | 36 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("Vars[*vr] = *value;")); | |
| 2802 | then txt; | ||
| 2803 | |||
| 2804 | case ( txt, | ||
| 2805 | _, | ||
| 2806 | a_pointerName ) | ||
| 2807 | algorithm | ||
| 2808 | 36 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*value = _pointerTo")); | |
| 2809 | 36 | txt := Tpl.writeStr(txt, a_pointerName); | |
| 2810 | 36 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("Vars[*vr];")); | |
| 2811 | then txt; | ||
| 2812 | end match; | ||
| 2813 | end fun_123; | ||
| 2814 | |||
| 2815 | protected function fun_124 | ||
| 2816 | input Tpl.Text in_txt; | ||
| 2817 | input SimCodeVar.SimVar in_a_var; | ||
| 2818 | input Integer in_a_offset; | ||
| 2819 | input String in_a_direction; | ||
| 2820 | input SimCode.SimCode in_a_simCode; | ||
| 2821 | |||
| 2822 | output Tpl.Text out_txt; | ||
| 2823 | algorithm | ||
| 2824 | out_txt := | ||
| 2825 | match(in_txt, in_a_var, in_a_offset, in_a_direction, in_a_simCode) | ||
| 2826 | local | ||
| 2827 | Tpl.Text txt; | ||
| 2828 | Integer a_offset; | ||
| 2829 | String a_direction; | ||
| 2830 | SimCode.SimCode a_simCode; | ||
| 2831 | SimCodeVar.SimVar i_var; | ||
| 2832 | |||
| 2833 | case ( txt, | ||
| 2834 | (i_var as SimCodeVar.SIMVAR(aliasvar = SimCodeVar.NEGATEDALIAS(varName = _))), | ||
| 2835 | a_offset, | ||
| 2836 | a_direction, | ||
| 2837 | a_simCode ) | ||
| 2838 | algorithm | ||
| 2839 | 14 | txt := accessVar(txt, a_simCode, a_direction, i_var, a_offset); | |
| 2840 | then txt; | ||
| 2841 | |||
| 2842 | case ( txt, | ||
| 2843 | _, | ||
| 2844 | _, | ||
| 2845 | _, | ||
| 2846 | _ ) | ||
| 2847 | then txt; | ||
| 2848 | end match; | ||
| 2849 | end fun_124; | ||
| 2850 | |||
| 2851 | protected function lm_125 | ||
| 2852 | input output Tpl.Text txt; | ||
| 2853 | input list<SimCodeVar.SimVar> items; | ||
| 2854 | input Integer a_offset; | ||
| 2855 | input String a_direction; | ||
| 2856 | input SimCode.SimCode a_simCode; | ||
| 2857 | algorithm | ||
| 2858 |
2/2✓ Branch 0 taken 188 times.
✓ Branch 1 taken 72 times.
|
260 | for lstElt_125 in items loop |
| 2859 | txt := match lstElt_125 | ||
| 2860 | local | ||
| 2861 | SimCodeVar.SimVar i_var; | ||
| 2862 | |||
| 2863 | case i_var | ||
| 2864 | algorithm | ||
| 2865 | 188 | txt := fun_124(txt, i_var, a_offset, a_direction, a_simCode); | |
| 2866 | 188 | txt := Tpl.nextIter(txt); | |
| 2867 | then txt; | ||
| 2868 | end match; | ||
| 2869 | end for; | ||
| 2870 | end lm_125; | ||
| 2871 | |||
| 2872 | public function accessVarsFunction | ||
| 2873 | input Tpl.Text txt; | ||
| 2874 | input SimCode.SimCode a_simCode; | ||
| 2875 | input String a_direction; | ||
| 2876 | input String a_modelShortName; | ||
| 2877 | input String a_typeName; | ||
| 2878 | input String a_pointerName; | ||
| 2879 | input String a_typeImpl; | ||
| 2880 | input Integer a_offset; | ||
| 2881 | input list<SimCodeVar.SimVar> a_aliasVars; | ||
| 2882 | |||
| 2883 | output Tpl.Text out_txt; | ||
| 2884 | protected | ||
| 2885 | Boolean ret_2; | ||
| 2886 | Boolean ret_1; | ||
| 2887 | Tpl.Text l_qualifier; | ||
| 2888 | algorithm | ||
| 2889 |
3/4✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
|
72 | ret_1 := stringEq(a_direction, "set"); |
| 2890 | 72 | l_qualifier := fun_122(Tpl.emptyTxt, ret_1); | |
| 2891 | 72 | out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("void ")); | |
| 2892 | 72 | out_txt := Tpl.writeStr(out_txt, a_modelShortName); | |
| 2893 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("FMU::")); | |
| 2894 | 72 | out_txt := Tpl.writeStr(out_txt, a_direction); | |
| 2895 | 72 | out_txt := Tpl.writeStr(out_txt, a_typeName); | |
| 2896 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("(const unsigned int vr[], size_t nvr, ")); | |
| 2897 | 72 | out_txt := Tpl.writeText(out_txt, l_qualifier); | |
| 2898 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" ")); | |
| 2899 | 72 | out_txt := Tpl.writeStr(out_txt, a_typeImpl); | |
| 2900 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({ | |
| 2901 | " value[]) {\n", | ||
| 2902 | " for (size_t i = 0; i < nvr; i++, vr++, value++) {\n", | ||
| 2903 | " // access variables and aliases in SimVars memory\n" | ||
| 2904 | }, true)); | ||
| 2905 | 72 | out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(4)); | |
| 2906 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("if (*vr < _dim")); | |
| 2907 | 72 | out_txt := Tpl.writeStr(out_txt, a_typeName); | |
| 2908 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE(")\n")); | |
| 2909 | 72 | out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2)); | |
| 2910 |
3/4✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
|
72 | ret_2 := stringEq(a_direction, "get"); |
| 2911 | 72 | out_txt := fun_123(out_txt, ret_2, a_pointerName); | |
| 2912 | 72 | out_txt := Tpl.softNewLine(out_txt); | |
| 2913 | 72 | out_txt := Tpl.popBlock(out_txt); | |
| 2914 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({ | |
| 2915 | "// convert negated aliases\n", | ||
| 2916 | "else switch (*vr) {\n" | ||
| 2917 | }, true)); | ||
| 2918 | 72 | out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2)); | |
| 2919 | 72 | out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 2920 | 72 | out_txt := lm_125(out_txt, a_aliasVars, a_offset, a_direction, a_simCode); | |
| 2921 | 72 | out_txt := Tpl.popIter(out_txt); | |
| 2922 | 72 | out_txt := Tpl.softNewLine(out_txt); | |
| 2923 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("default:\n")); | |
| 2924 | 72 | out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2)); | |
| 2925 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("throw std::invalid_argument(\"")); | |
| 2926 | 72 | out_txt := Tpl.writeStr(out_txt, a_direction); | |
| 2927 | 72 | out_txt := Tpl.writeStr(out_txt, a_typeName); | |
| 2928 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE(" with wrong value reference \" + omcpp::to_string(*vr));\n")); | |
| 2929 | 72 | out_txt := Tpl.popBlock(out_txt); | |
| 2930 | 72 | out_txt := Tpl.popBlock(out_txt); | |
| 2931 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("}\n")); | |
| 2932 | 72 | out_txt := Tpl.popBlock(out_txt); | |
| 2933 | 72 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({ | |
| 2934 | " }\n", | ||
| 2935 | "}" | ||
| 2936 | }, false)); | ||
| 2937 | end accessVarsFunction; | ||
| 2938 | |||
| 2939 | protected function fun_127 | ||
| 2940 | input Tpl.Text in_txt; | ||
| 2941 | input String in_a_comment; | ||
| 2942 | input Tpl.Text in_a_descName; | ||
| 2943 | |||
| 2944 | output Tpl.Text out_txt; | ||
| 2945 | algorithm | ||
| 2946 | out_txt := | ||
| 2947 | match(in_txt, in_a_comment, in_a_descName) | ||
| 2948 | local | ||
| 2949 | Tpl.Text txt; | ||
| 2950 | Tpl.Text a_descName; | ||
| 2951 | String i_comment; | ||
| 2952 | |||
| 2953 | case ( txt, | ||
| 2954 | "", | ||
| 2955 | a_descName ) | ||
| 2956 | algorithm | ||
| 2957 | 2 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/* ")); | |
| 2958 | 2 | txt := Tpl.writeText(txt, a_descName); | |
| 2959 | 2 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" */")); | |
| 2960 | then txt; | ||
| 2961 | |||
| 2962 | case ( txt, | ||
| 2963 | i_comment, | ||
| 2964 | a_descName ) | ||
| 2965 | algorithm | ||
| 2966 | 12 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/* ")); | |
| 2967 | 12 | txt := Tpl.writeText(txt, a_descName); | |
| 2968 | 12 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" \"")); | |
| 2969 | 12 | txt := Tpl.writeStr(txt, i_comment); | |
| 2970 | 12 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" */")); | |
| 2971 | then txt; | ||
| 2972 | end match; | ||
| 2973 | end fun_127; | ||
| 2974 | |||
| 2975 | protected function fun_128 | ||
| 2976 | input Tpl.Text in_txt; | ||
| 2977 | input Boolean in_mArg; | ||
| 2978 | input Tpl.Text in_a_cppSign; | ||
| 2979 | input Tpl.Text in_a_cppName; | ||
| 2980 | input Tpl.Text in_a_description; | ||
| 2981 | input Integer in_a_index; | ||
| 2982 | input Integer in_a_offset; | ||
| 2983 | |||
| 2984 | output Tpl.Text out_txt; | ||
| 2985 | algorithm | ||
| 2986 | out_txt := | ||
| 2987 | match(in_txt, in_mArg, in_a_cppSign, in_a_cppName, in_a_description, in_a_index, in_a_offset) | ||
| 2988 | local | ||
| 2989 | Tpl.Text txt; | ||
| 2990 | Tpl.Text a_cppSign; | ||
| 2991 | Tpl.Text a_cppName; | ||
| 2992 | Tpl.Text a_description; | ||
| 2993 | Integer a_index; | ||
| 2994 | Integer a_offset; | ||
| 2995 | Integer ret_1; | ||
| 2996 | Integer ret_0; | ||
| 2997 | |||
| 2998 | case ( txt, | ||
| 2999 | false, | ||
| 3000 | a_cppSign, | ||
| 3001 | a_cppName, | ||
| 3002 | a_description, | ||
| 3003 | a_index, | ||
| 3004 | a_offset ) | ||
| 3005 | algorithm | ||
| 3006 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("case ")); | |
| 3007 | 7 | ret_0 := intAdd(a_offset, a_index); | |
| 3008 | 7 | txt := Tpl.writeStr(txt, intString(ret_0)); | |
| 3009 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(": ")); | |
| 3010 | 7 | txt := Tpl.writeText(txt, a_description); | |
| 3011 | 7 | txt := Tpl.softNewLine(txt); | |
| 3012 | 7 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 3013 | 7 | txt := Tpl.writeText(txt, a_cppName); | |
| 3014 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 3015 | 7 | txt := Tpl.writeText(txt, a_cppSign); | |
| 3016 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*value; break;")); | |
| 3017 | 7 | txt := Tpl.popBlock(txt); | |
| 3018 | then txt; | ||
| 3019 | |||
| 3020 | case ( txt, | ||
| 3021 | _, | ||
| 3022 | a_cppSign, | ||
| 3023 | a_cppName, | ||
| 3024 | a_description, | ||
| 3025 | a_index, | ||
| 3026 | a_offset ) | ||
| 3027 | algorithm | ||
| 3028 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("case ")); | |
| 3029 | 7 | ret_1 := intAdd(a_offset, a_index); | |
| 3030 | 7 | txt := Tpl.writeStr(txt, intString(ret_1)); | |
| 3031 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(": ")); | |
| 3032 | 7 | txt := Tpl.writeText(txt, a_description); | |
| 3033 | 7 | txt := Tpl.softNewLine(txt); | |
| 3034 | 7 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 3035 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*value = ")); | |
| 3036 | 7 | txt := Tpl.writeText(txt, a_cppSign); | |
| 3037 | 7 | txt := Tpl.writeText(txt, a_cppName); | |
| 3038 | 7 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("; break;")); | |
| 3039 | 7 | txt := Tpl.popBlock(txt); | |
| 3040 | then txt; | ||
| 3041 | end match; | ||
| 3042 | end fun_128; | ||
| 3043 | |||
| 3044 | protected function fun_129 | ||
| 3045 | input Tpl.Text in_txt; | ||
| 3046 | input SimCodeVar.SimVar in_a_simVar; | ||
| 3047 | input SimCode.SimCode in_a_simCode; | ||
| 3048 | input String in_a_direction; | ||
| 3049 | input Integer in_a_offset; | ||
| 3050 | |||
| 3051 | output Tpl.Text out_txt; | ||
| 3052 | algorithm | ||
| 3053 | out_txt := | ||
| 3054 | match(in_txt, in_a_simVar, in_a_simCode, in_a_direction, in_a_offset) | ||
| 3055 | local | ||
| 3056 | Tpl.Text txt; | ||
| 3057 | SimCode.SimCode a_simCode; | ||
| 3058 | String a_direction; | ||
| 3059 | Integer a_offset; | ||
| 3060 | Integer i_index; | ||
| 3061 | SimCodeVar.SimVar i_simVar; | ||
| 3062 | String i_comment; | ||
| 3063 | DAE.ComponentRef i_name; | ||
| 3064 | Boolean ret_6; | ||
| 3065 | Tpl.Text l_cppSign; | ||
| 3066 | Tpl.Text l_cppName; | ||
| 3067 | Tpl.Text l_description; | ||
| 3068 | String ret_2; | ||
| 3069 | Tpl.Text txt_1; | ||
| 3070 | Tpl.Text l_descName; | ||
| 3071 | |||
| 3072 | case ( txt, | ||
| 3073 | (i_simVar as SimCodeVar.SIMVAR(name = i_name, comment = i_comment, index = i_index)), | ||
| 3074 | a_simCode, | ||
| 3075 | a_direction, | ||
| 3076 | a_offset ) | ||
| 3077 | algorithm | ||
| 3078 | 14 | txt_1 := CodegenUtil.crefStrNoUnderscore(Tpl.emptyTxt, i_name); | |
| 3079 | 14 | ret_2 := System.stringReplace(Tpl.textString(txt_1), "$", "_D_"); | |
| 3080 | 14 | l_descName := Tpl.writeStr(Tpl.emptyTxt, ret_2); | |
| 3081 | 14 | l_description := fun_127(Tpl.emptyTxt, i_comment, l_descName); | |
| 3082 | 14 | l_cppName := getCppName(Tpl.emptyTxt, a_simCode, i_simVar); | |
| 3083 | 14 | l_cppSign := getCppSign(Tpl.emptyTxt, a_simCode, i_simVar); | |
| 3084 |
3/4✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
|
14 | ret_6 := stringEq(a_direction, "get"); |
| 3085 | 14 | txt := fun_128(txt, ret_6, l_cppSign, l_cppName, l_description, i_index, a_offset); | |
| 3086 | then txt; | ||
| 3087 | |||
| 3088 | case ( txt, | ||
| 3089 | _, | ||
| 3090 | _, | ||
| 3091 | _, | ||
| 3092 | _ ) | ||
| 3093 | then txt; | ||
| 3094 | end match; | ||
| 3095 | end fun_129; | ||
| 3096 | |||
| 3097 | public function accessVar | ||
| 3098 | input Tpl.Text txt; | ||
| 3099 | input SimCode.SimCode a_simCode; | ||
| 3100 | input String a_direction; | ||
| 3101 | input SimCodeVar.SimVar a_simVar; | ||
| 3102 | input Integer a_offset; | ||
| 3103 | |||
| 3104 | output Tpl.Text out_txt; | ||
| 3105 | algorithm | ||
| 3106 | 14 | out_txt := fun_129(txt, a_simVar, a_simCode, a_direction, a_offset); | |
| 3107 | end accessVar; | ||
| 3108 | |||
| 3109 | protected function fun_131 | ||
| 3110 | input Tpl.Text in_txt; | ||
| 3111 | input SimCodeVar.AliasVariable in_a_aliasvar; | ||
| 3112 | input Tpl.Text in_a_actualName; | ||
| 3113 | input SimCode.SimCode in_a_simCode; | ||
| 3114 | |||
| 3115 | output Tpl.Text out_txt; | ||
| 3116 | algorithm | ||
| 3117 | out_txt := | ||
| 3118 | match(in_txt, in_a_aliasvar, in_a_actualName, in_a_simCode) | ||
| 3119 | local | ||
| 3120 | Tpl.Text txt; | ||
| 3121 | Tpl.Text a_actualName; | ||
| 3122 | SimCode.SimCode a_simCode; | ||
| 3123 | DAE.ComponentRef i_varName; | ||
| 3124 | |||
| 3125 | case ( txt, | ||
| 3126 | SimCodeVar.ALIAS(varName = i_varName), | ||
| 3127 | _, | ||
| 3128 | a_simCode ) | ||
| 3129 | algorithm | ||
| 3130 | ✗ | (txt, _, _, _, _, _) := CodegenCppCommon.cref1(txt, i_varName, a_simCode, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextOther, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), false); | |
| 3131 | then txt; | ||
| 3132 | |||
| 3133 | case ( txt, | ||
| 3134 | SimCodeVar.NEGATEDALIAS(varName = i_varName), | ||
| 3135 | _, | ||
| 3136 | a_simCode ) | ||
| 3137 | algorithm | ||
| 3138 | 14 | (txt, _, _, _, _, _) := CodegenCppCommon.cref1(txt, i_varName, a_simCode, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextOther, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), false); | |
| 3139 | then txt; | ||
| 3140 | |||
| 3141 | case ( txt, | ||
| 3142 | _, | ||
| 3143 | a_actualName, | ||
| 3144 | _ ) | ||
| 3145 | algorithm | ||
| 3146 | ✗ | txt := Tpl.writeText(txt, a_actualName); | |
| 3147 | then txt; | ||
| 3148 | end match; | ||
| 3149 | end fun_131; | ||
| 3150 | |||
| 3151 | protected function fun_132 | ||
| 3152 | input Tpl.Text in_txt; | ||
| 3153 | input SimCodeVar.SimVar in_a_simVar; | ||
| 3154 | input SimCode.SimCode in_a_simCode; | ||
| 3155 | |||
| 3156 | output Tpl.Text out_txt; | ||
| 3157 | algorithm | ||
| 3158 | out_txt := | ||
| 3159 | match(in_txt, in_a_simVar, in_a_simCode) | ||
| 3160 | local | ||
| 3161 | Tpl.Text txt; | ||
| 3162 | SimCode.SimCode a_simCode; | ||
| 3163 | SimCodeVar.AliasVariable i_aliasvar; | ||
| 3164 | DAE.ComponentRef i_name; | ||
| 3165 | Tpl.Text l_actualName; | ||
| 3166 | |||
| 3167 | case ( txt, | ||
| 3168 | SimCodeVar.SIMVAR(name = i_name, aliasvar = i_aliasvar), | ||
| 3169 | a_simCode ) | ||
| 3170 | algorithm | ||
| 3171 | 14 | (l_actualName, _, _, _, _, _) := CodegenCppCommon.cref1(Tpl.emptyTxt, i_name, a_simCode, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextOther, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.strTokText(Tpl.ST_STRING("")), false); | |
| 3172 | 14 | txt := fun_131(txt, i_aliasvar, l_actualName, a_simCode); | |
| 3173 | then txt; | ||
| 3174 | |||
| 3175 | case ( txt, | ||
| 3176 | _, | ||
| 3177 | _ ) | ||
| 3178 | then txt; | ||
| 3179 | end match; | ||
| 3180 | end fun_132; | ||
| 3181 | |||
| 3182 | public function getCppName | ||
| 3183 | input Tpl.Text txt; | ||
| 3184 | input SimCode.SimCode a_simCode; | ||
| 3185 | input SimCodeVar.SimVar a_simVar; | ||
| 3186 | |||
| 3187 | output Tpl.Text out_txt; | ||
| 3188 | algorithm | ||
| 3189 | 14 | out_txt := fun_132(txt, a_simVar, a_simCode); | |
| 3190 | end getCppName; | ||
| 3191 | |||
| 3192 | protected function fun_134 | ||
| 3193 | input Tpl.Text in_txt; | ||
| 3194 | input DAE.Type in_a_type__; | ||
| 3195 | |||
| 3196 | output Tpl.Text out_txt; | ||
| 3197 | algorithm | ||
| 3198 | out_txt := | ||
| 3199 | match(in_txt, in_a_type__) | ||
| 3200 | local | ||
| 3201 | Tpl.Text txt; | ||
| 3202 | |||
| 3203 | case ( txt, | ||
| 3204 | DAE.T_BOOL(varLst = _) ) | ||
| 3205 | algorithm | ||
| 3206 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("!")); | |
| 3207 | then txt; | ||
| 3208 | |||
| 3209 | case ( txt, | ||
| 3210 | _ ) | ||
| 3211 | algorithm | ||
| 3212 | 14 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("-")); | |
| 3213 | then txt; | ||
| 3214 | end match; | ||
| 3215 | end fun_134; | ||
| 3216 | |||
| 3217 | protected function fun_135 | ||
| 3218 | input Tpl.Text in_txt; | ||
| 3219 | input SimCodeVar.AliasVariable in_a_aliasvar; | ||
| 3220 | input DAE.Type in_a_type__; | ||
| 3221 | |||
| 3222 | output Tpl.Text out_txt; | ||
| 3223 | algorithm | ||
| 3224 | out_txt := | ||
| 3225 | match(in_txt, in_a_aliasvar, in_a_type__) | ||
| 3226 | local | ||
| 3227 | Tpl.Text txt; | ||
| 3228 | DAE.Type a_type__; | ||
| 3229 | |||
| 3230 | case ( txt, | ||
| 3231 | SimCodeVar.NEGATEDALIAS(varName = _), | ||
| 3232 | a_type__ ) | ||
| 3233 | algorithm | ||
| 3234 | 14 | txt := fun_134(txt, a_type__); | |
| 3235 | then txt; | ||
| 3236 | |||
| 3237 | case ( txt, | ||
| 3238 | _, | ||
| 3239 | _ ) | ||
| 3240 | then txt; | ||
| 3241 | end match; | ||
| 3242 | end fun_135; | ||
| 3243 | |||
| 3244 | protected function fun_136 | ||
| 3245 | input Tpl.Text in_txt; | ||
| 3246 | input SimCodeVar.SimVar in_a_simVar; | ||
| 3247 | |||
| 3248 | output Tpl.Text out_txt; | ||
| 3249 | algorithm | ||
| 3250 | out_txt := | ||
| 3251 | match(in_txt, in_a_simVar) | ||
| 3252 | local | ||
| 3253 | Tpl.Text txt; | ||
| 3254 | DAE.Type i_type__; | ||
| 3255 | SimCodeVar.AliasVariable i_aliasvar; | ||
| 3256 | |||
| 3257 | case ( txt, | ||
| 3258 | SimCodeVar.SIMVAR(type_ = i_type__, aliasvar = i_aliasvar) ) | ||
| 3259 | algorithm | ||
| 3260 | 14 | txt := fun_135(txt, i_aliasvar, i_type__); | |
| 3261 | then txt; | ||
| 3262 | |||
| 3263 | case ( txt, | ||
| 3264 | _ ) | ||
| 3265 | then txt; | ||
| 3266 | end match; | ||
| 3267 | end fun_136; | ||
| 3268 | |||
| 3269 | public function getCppSign | ||
| 3270 | input Tpl.Text txt; | ||
| 3271 | input SimCode.SimCode a_simCode; | ||
| 3272 | input SimCodeVar.SimVar a_simVar; | ||
| 3273 | |||
| 3274 | output Tpl.Text out_txt; | ||
| 3275 | algorithm | ||
| 3276 | 14 | out_txt := fun_136(txt, a_simVar); | |
| 3277 | end getCppSign; | ||
| 3278 | |||
| 3279 | protected function fun_138 | ||
| 3280 | input Tpl.Text in_txt; | ||
| 3281 | input SimCode.FmiDiscreteStates in_a_modelStructure_fmiDiscreteStates; | ||
| 3282 | |||
| 3283 | output Tpl.Text out_txt; | ||
| 3284 | algorithm | ||
| 3285 | out_txt := | ||
| 3286 | match(in_txt, in_a_modelStructure_fmiDiscreteStates) | ||
| 3287 | local | ||
| 3288 | Tpl.Text txt; | ||
| 3289 | list<SimCode.FmiUnknown> i_fmiUnknownsList; | ||
| 3290 | Integer ret_0; | ||
| 3291 | |||
| 3292 | case ( txt, | ||
| 3293 | SimCode.FMIDISCRETESTATES(fmiUnknownsList = i_fmiUnknownsList) ) | ||
| 3294 | algorithm | ||
| 3295 | 8 | ret_0 := listLength(i_fmiUnknownsList); | |
| 3296 | 8 | txt := Tpl.writeStr(txt, intString(ret_0)); | |
| 3297 | then txt; | ||
| 3298 | |||
| 3299 | case ( txt, | ||
| 3300 | _ ) | ||
| 3301 | algorithm | ||
| 3302 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 3303 | then txt; | ||
| 3304 | end match; | ||
| 3305 | end fun_138; | ||
| 3306 | |||
| 3307 | protected function fun_139 | ||
| 3308 | input Tpl.Text in_txt; | ||
| 3309 | input Option<SimCode.FmiModelStructure> in_a_fmiModelStructure; | ||
| 3310 | |||
| 3311 | output Tpl.Text out_txt; | ||
| 3312 | algorithm | ||
| 3313 | out_txt := | ||
| 3314 | match(in_txt, in_a_fmiModelStructure) | ||
| 3315 | local | ||
| 3316 | Tpl.Text txt; | ||
| 3317 | SimCode.FmiDiscreteStates i_modelStructure_fmiDiscreteStates; | ||
| 3318 | |||
| 3319 | case ( txt, | ||
| 3320 | SOME(SimCode.FMIMODELSTRUCTURE(fmiDiscreteStates = i_modelStructure_fmiDiscreteStates)) ) | ||
| 3321 | algorithm | ||
| 3322 | 8 | txt := fun_138(txt, i_modelStructure_fmiDiscreteStates); | |
| 3323 | then txt; | ||
| 3324 | |||
| 3325 | case ( txt, | ||
| 3326 | _ ) | ||
| 3327 | algorithm | ||
| 3328 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 3329 | then txt; | ||
| 3330 | end match; | ||
| 3331 | end fun_139; | ||
| 3332 | |||
| 3333 | protected function fun_140 | ||
| 3334 | input Tpl.Text in_txt; | ||
| 3335 | input Boolean in_mArg; | ||
| 3336 | input Tpl.Text in_a_dimDiscreteStates; | ||
| 3337 | |||
| 3338 | output Tpl.Text out_txt; | ||
| 3339 | algorithm | ||
| 3340 | out_txt := | ||
| 3341 | match(in_txt, in_mArg, in_a_dimDiscreteStates) | ||
| 3342 | local | ||
| 3343 | Tpl.Text txt; | ||
| 3344 | Tpl.Text a_dimDiscreteStates; | ||
| 3345 | |||
| 3346 | case ( txt, | ||
| 3347 | false, | ||
| 3348 | _ ) | ||
| 3349 | algorithm | ||
| 3350 | 8 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" throw ModelicaSimulationError(MATH_FUNCTION, \"No derivative code, see flag disableDirectionalDerivatives\");")); | |
| 3351 | then txt; | ||
| 3352 | |||
| 3353 | case ( txt, | ||
| 3354 | _, | ||
| 3355 | a_dimDiscreteStates ) | ||
| 3356 | algorithm | ||
| 3357 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_LINE(" unsigned int idx, *ref_p, ref_1;\n")); | |
| 3358 | 1 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 3359 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("int dimStates = _dimContinuousStates + ")); | |
| 3360 | 1 | txt := Tpl.writeText(txt, a_dimDiscreteStates); | |
| 3361 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3362 | ";\n", | ||
| 3363 | "\n", | ||
| 3364 | "_FMIDERjac_x.clear();\n", | ||
| 3365 | "ref_p = NULL;\n", | ||
| 3366 | "for (size_t j = 0; j < nKnown; j++) {\n", | ||
| 3367 | " idx = vrKnown[j];\n", | ||
| 3368 | " if (idx >= dimStates) {\n", | ||
| 3369 | " // find input reference\n", | ||
| 3370 | " if (ref_p == NULL || idx < ref_1)\n", | ||
| 3371 | " ref_p = _inputRefs; // reset ref_p if vrKnown decreases\n", | ||
| 3372 | " ref_p = std::find(ref_p, _inputRefs + sizeof(_inputRefs)/sizeof(unsigned int), vrKnown[j]);\n", | ||
| 3373 | " ref_1 = idx;\n", | ||
| 3374 | " idx = dimStates + (ref_p - _inputRefs);\n", | ||
| 3375 | " }\n", | ||
| 3376 | " if (idx >= _FMIDERjac_x.size())\n", | ||
| 3377 | " throw std::invalid_argument(\"getDirectionalDerivative with wrong value reference of known \" + omcpp::to_string(vrKnown[j]));\n", | ||
| 3378 | " _FMIDERjac_x(idx) = dvKnown[j];\n", | ||
| 3379 | "}\n", | ||
| 3380 | "calcFMIDERJacobianColumn();\n", | ||
| 3381 | "ref_p = NULL;\n", | ||
| 3382 | "for (size_t i = 0; i < nUnknown; i++) {\n", | ||
| 3383 | " idx = vrUnknown[i] - _dimContinuousStates; // derivatives behind states\n", | ||
| 3384 | " if (idx >= _dimContinuousStates) {\n", | ||
| 3385 | " // find output reference\n", | ||
| 3386 | " if (ref_p == NULL || idx < ref_1)\n", | ||
| 3387 | " ref_p = _outputRefs; // reset ref_p if vrUnknown decreases\n", | ||
| 3388 | " ref_p = std::find(ref_p, _outputRefs + sizeof(_outputRefs)/sizeof(unsigned int), vrUnknown[i]);\n", | ||
| 3389 | " ref_1 = idx;\n", | ||
| 3390 | " idx = _dimContinuousStates + (ref_p - _outputRefs);\n", | ||
| 3391 | " }\n", | ||
| 3392 | " if (idx >= _FMIDERjac_y.size())\n", | ||
| 3393 | " throw std::invalid_argument(\"getDirectionalDerivative with wrong value reference of unknown \" + omcpp::to_string(vrUnknown[i]));\n", | ||
| 3394 | " dvUnknown[i] = _FMIDERjac_y(idx);\n", | ||
| 3395 | "}" | ||
| 3396 | }, false)); | ||
| 3397 | 1 | txt := Tpl.popBlock(txt); | |
| 3398 | then txt; | ||
| 3399 | end match; | ||
| 3400 | end fun_140; | ||
| 3401 | |||
| 3402 | public function directionalDerivativeFunction | ||
| 3403 | input Tpl.Text in_txt; | ||
| 3404 | input SimCode.SimCode in_a_simCode; | ||
| 3405 | |||
| 3406 | output Tpl.Text out_txt; | ||
| 3407 | algorithm | ||
| 3408 | out_txt := | ||
| 3409 | match(in_txt, in_a_simCode) | ||
| 3410 | local | ||
| 3411 | Tpl.Text txt; | ||
| 3412 | SimCode.SimCode i_simCode; | ||
| 3413 | Option<SimCode.FmiModelStructure> i_fmiModelStructure; | ||
| 3414 | Absyn.Path i_modelInfo_name; | ||
| 3415 | Boolean ret_2; | ||
| 3416 | Tpl.Text l_dimDiscreteStates; | ||
| 3417 | Tpl.Text l_modelShortName; | ||
| 3418 | |||
| 3419 | case ( txt, | ||
| 3420 | (i_simCode as SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(name = i_modelInfo_name), modelStructure = i_fmiModelStructure)) ) | ||
| 3421 | algorithm | ||
| 3422 | 9 | l_modelShortName := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, i_modelInfo_name); | |
| 3423 | 9 | l_dimDiscreteStates := fun_139(Tpl.emptyTxt, i_fmiModelStructure); | |
| 3424 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("void ")); | |
| 3425 | 9 | txt := Tpl.writeText(txt, l_modelShortName); | |
| 3426 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3427 | "FMU::getDirectionalDerivative(\n", | ||
| 3428 | " const unsigned int vrUnknown[], size_t nUnknown,\n", | ||
| 3429 | " const unsigned int vrKnown[], size_t nKnown,\n", | ||
| 3430 | " const double dvKnown[], double dvUnknown[])\n", | ||
| 3431 | "{\n" | ||
| 3432 | }, true)); | ||
| 3433 | 9 | ret_2 := SimCodeCodegenUtil.providesDirectionalDerivative(i_simCode); | |
| 3434 | 9 | txt := fun_140(txt, ret_2, l_dimDiscreteStates); | |
| 3435 | 9 | txt := Tpl.softNewLine(txt); | |
| 3436 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("}")); | |
| 3437 | then txt; | ||
| 3438 | |||
| 3439 | case ( txt, | ||
| 3440 | _ ) | ||
| 3441 | then txt; | ||
| 3442 | end match; | ||
| 3443 | end directionalDerivativeFunction; | ||
| 3444 | |||
| 3445 | protected function fun_142 | ||
| 3446 | input Tpl.Text in_txt; | ||
| 3447 | input String in_a_modelInfo_directory; | ||
| 3448 | |||
| 3449 | output Tpl.Text out_txt; | ||
| 3450 | algorithm | ||
| 3451 | out_txt := | ||
| 3452 | match(in_txt, in_a_modelInfo_directory) | ||
| 3453 | local | ||
| 3454 | Tpl.Text txt; | ||
| 3455 | String i_modelInfo_directory; | ||
| 3456 | |||
| 3457 | case ( txt, | ||
| 3458 | "" ) | ||
| 3459 | then txt; | ||
| 3460 | |||
| 3461 | case ( txt, | ||
| 3462 | i_modelInfo_directory ) | ||
| 3463 | algorithm | ||
| 3464 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("-L\"")); | |
| 3465 | ✗ | txt := Tpl.writeStr(txt, i_modelInfo_directory); | |
| 3466 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 3467 | then txt; | ||
| 3468 | end match; | ||
| 3469 | end fun_142; | ||
| 3470 | |||
| 3471 | protected function lm_143 | ||
| 3472 | input output Tpl.Text txt; | ||
| 3473 | input list<String> items; | ||
| 3474 | algorithm | ||
| 3475 | ✗ | for lstElt_143 in items loop | |
| 3476 | txt := match lstElt_143 | ||
| 3477 | local | ||
| 3478 | String i_lib; | ||
| 3479 | |||
| 3480 | case i_lib | ||
| 3481 | algorithm | ||
| 3482 | ✗ | txt := Tpl.writeStr(txt, i_lib); | |
| 3483 | ✗ | txt := Tpl.nextIter(txt); | |
| 3484 | then txt; | ||
| 3485 | end match; | ||
| 3486 | end for; | ||
| 3487 | end lm_143; | ||
| 3488 | |||
| 3489 | protected function fun_144 | ||
| 3490 | input Tpl.Text in_txt; | ||
| 3491 | input Boolean in_mArg; | ||
| 3492 | |||
| 3493 | output Tpl.Text out_txt; | ||
| 3494 | algorithm | ||
| 3495 | out_txt := | ||
| 3496 | match(in_txt, in_mArg) | ||
| 3497 | local | ||
| 3498 | Tpl.Text txt; | ||
| 3499 | |||
| 3500 | case ( txt, | ||
| 3501 | false ) | ||
| 3502 | then txt; | ||
| 3503 | |||
| 3504 | case ( txt, | ||
| 3505 | _ ) | ||
| 3506 | algorithm | ||
| 3507 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("-lOMOCLRuntime -lOpenCL")); | |
| 3508 | then txt; | ||
| 3509 | end match; | ||
| 3510 | end fun_144; | ||
| 3511 | |||
| 3512 | protected function fun_145 | ||
| 3513 | input Tpl.Text in_txt; | ||
| 3514 | input String in_a_s_method; | ||
| 3515 | |||
| 3516 | output Tpl.Text out_txt; | ||
| 3517 | algorithm | ||
| 3518 | out_txt := | ||
| 3519 | match(in_txt, in_a_s_method) | ||
| 3520 | local | ||
| 3521 | Tpl.Text txt; | ||
| 3522 | |||
| 3523 | case ( txt, | ||
| 3524 | "dassljac" ) | ||
| 3525 | algorithm | ||
| 3526 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("-D_OMC_JACOBIAN ")); | |
| 3527 | then txt; | ||
| 3528 | |||
| 3529 | case ( txt, | ||
| 3530 | _ ) | ||
| 3531 | then txt; | ||
| 3532 | end match; | ||
| 3533 | end fun_145; | ||
| 3534 | |||
| 3535 | protected function fun_146 | ||
| 3536 | input Tpl.Text in_txt; | ||
| 3537 | input Option<SimCode.SimulationSettings> in_a_sopt; | ||
| 3538 | |||
| 3539 | output Tpl.Text out_txt; | ||
| 3540 | algorithm | ||
| 3541 | out_txt := | ||
| 3542 | match(in_txt, in_a_sopt) | ||
| 3543 | local | ||
| 3544 | Tpl.Text txt; | ||
| 3545 | String i_s_method; | ||
| 3546 | |||
| 3547 | case ( txt, | ||
| 3548 | SOME(SimCode.SIMULATION_SETTINGS(method = i_s_method)) ) | ||
| 3549 | algorithm | ||
| 3550 | ✗ | txt := fun_145(txt, i_s_method); | |
| 3551 | then txt; | ||
| 3552 | |||
| 3553 | case ( txt, | ||
| 3554 | _ ) | ||
| 3555 | then txt; | ||
| 3556 | end match; | ||
| 3557 | end fun_146; | ||
| 3558 | |||
| 3559 | protected function fun_147 | ||
| 3560 | input Tpl.Text in_txt; | ||
| 3561 | input Boolean in_mArg; | ||
| 3562 | input String in_a_makefileParams_omhome; | ||
| 3563 | |||
| 3564 | output Tpl.Text out_txt; | ||
| 3565 | algorithm | ||
| 3566 | out_txt := | ||
| 3567 | match(in_txt, in_mArg, in_a_makefileParams_omhome) | ||
| 3568 | local | ||
| 3569 | Tpl.Text txt; | ||
| 3570 | String a_makefileParams_omhome; | ||
| 3571 | |||
| 3572 | case ( txt, | ||
| 3573 | false, | ||
| 3574 | a_makefileParams_omhome ) | ||
| 3575 | algorithm | ||
| 3576 | ✗ | txt := Tpl.writeStr(txt, a_makefileParams_omhome); | |
| 3577 | then txt; | ||
| 3578 | |||
| 3579 | case ( txt, | ||
| 3580 | _, | ||
| 3581 | _ ) | ||
| 3582 | algorithm | ||
| 3583 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("$(OPENMODELICAHOME)")); | |
| 3584 | then txt; | ||
| 3585 | end match; | ||
| 3586 | end fun_147; | ||
| 3587 | |||
| 3588 | protected function fun_148 | ||
| 3589 | input Tpl.Text in_txt; | ||
| 3590 | input SimCode.SimCode in_a_simCode; | ||
| 3591 | |||
| 3592 | output Tpl.Text out_txt; | ||
| 3593 | algorithm | ||
| 3594 | out_txt := | ||
| 3595 | match(in_txt, in_a_simCode) | ||
| 3596 | local | ||
| 3597 | Tpl.Text txt; | ||
| 3598 | String i_fmuTargetName; | ||
| 3599 | String i_fileNamePrefix; | ||
| 3600 | String i_makefileParams_platform; | ||
| 3601 | String i_makefileParams_omhome; | ||
| 3602 | Option<SimCode.SimulationSettings> i_sopt; | ||
| 3603 | list<String> i_makefileParams_libs; | ||
| 3604 | String i_modelInfo_directory; | ||
| 3605 | String ret_8; | ||
| 3606 | Boolean ret_7; | ||
| 3607 | Boolean ret_6; | ||
| 3608 | Boolean ret_5; | ||
| 3609 | Tpl.Text l_extraCflags; | ||
| 3610 | Boolean ret_3; | ||
| 3611 | Tpl.Text l_ParModelicaLibs; | ||
| 3612 | Tpl.Text l_libsExtra; | ||
| 3613 | Tpl.Text l_dirExtra; | ||
| 3614 | |||
| 3615 | case ( txt, | ||
| 3616 | SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(directory = i_modelInfo_directory), makefileParams = SimCodeFunction.MAKEFILE_PARAMS(libs = i_makefileParams_libs, omhome = i_makefileParams_omhome, platform = i_makefileParams_platform), simulationSettingsOpt = i_sopt, fileNamePrefix = i_fileNamePrefix, fmuTargetName = i_fmuTargetName) ) | ||
| 3617 | algorithm | ||
| 3618 | ✗ | l_dirExtra := fun_142(Tpl.emptyTxt, i_modelInfo_directory); | |
| 3619 | ✗ | l_libsExtra := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(" ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 3620 | ✗ | l_libsExtra := lm_143(l_libsExtra, i_makefileParams_libs); | |
| 3621 | ✗ | l_libsExtra := Tpl.popIter(l_libsExtra); | |
| 3622 | ✗ | ret_3 := Config.acceptParModelicaGrammar(); | |
| 3623 | ✗ | l_ParModelicaLibs := fun_144(Tpl.emptyTxt, ret_3); | |
| 3624 | ✗ | l_extraCflags := fun_146(Tpl.emptyTxt, i_sopt); | |
| 3625 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3626 | "# Makefile generated by OpenModelica\n", | ||
| 3627 | "# run with nmake from Visual Studio Command Prompt\n", | ||
| 3628 | "# FMU packaging requires PATH to " | ||
| 3629 | }, false)); | ||
| 3630 | ✗ | txt := Tpl.writeStr(txt, i_makefileParams_omhome); | |
| 3631 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3632 | "/mingw/bin\n", | ||
| 3633 | "OMHOME=" | ||
| 3634 | }, false)); | ||
| 3635 | ✗ | ret_5 := stringEq(i_makefileParams_platform, "win32"); | |
| 3636 | ✗ | ret_6 := stringEq(i_makefileParams_platform, "win64"); | |
| 3637 | ✗ | ret_7 := boolOr(ret_5, ret_6); | |
| 3638 | ✗ | txt := fun_147(txt, ret_7, i_makefileParams_omhome); | |
| 3639 | ✗ | txt := Tpl.softNewLine(txt); | |
| 3640 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("include ")); | |
| 3641 | ✗ | txt := Tpl.writeStr(txt, i_makefileParams_omhome); | |
| 3642 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3643 | "/include/omc/cpp/ModelicaConfig_msvc.inc\n", | ||
| 3644 | "include " | ||
| 3645 | }, false)); | ||
| 3646 | ✗ | txt := Tpl.writeStr(txt, i_makefileParams_omhome); | |
| 3647 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3648 | "/include/omc/cpp/ModelicaLibraryConfig_msvc.inc\n", | ||
| 3649 | "# Simulations use /Od by default\n", | ||
| 3650 | "SIM_OR_DYNLOAD_OPT_LEVEL=\n", | ||
| 3651 | "MODELICAUSERCFLAGS=\n", | ||
| 3652 | "CXX=cl\n", | ||
| 3653 | "EXEEXT=.exe\n", | ||
| 3654 | "DLLEXT=.dll\n", | ||
| 3655 | "\n", | ||
| 3656 | "# /Od - Optimization disabled\n", | ||
| 3657 | "# /EHa enable C++ EH (w/ SEH exceptions)\n", | ||
| 3658 | "# /fp:except - consider floating-point exceptions when generating code\n", | ||
| 3659 | "# /arch:SSE2 - enable use of instructions available with SSE2 enabled CPUs\n", | ||
| 3660 | "# /I - Include Directories\n", | ||
| 3661 | "# /DNOMINMAX - Define NOMINMAX (does what it says)\n", | ||
| 3662 | "# /TP - Use C++ Compiler\n", | ||
| 3663 | "\n", | ||
| 3664 | "CFLAGS=$(SYSTEM_CFLAGS) /w /I\"" | ||
| 3665 | }, false)); | ||
| 3666 | ✗ | txt := Tpl.writeStr(txt, i_makefileParams_omhome); | |
| 3667 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3668 | "/include/omc/cpp/\" /I\"$(SUITESPARSE_INCLUDE)\" /I. /TP /DNOMINMAX /DNO_INTERACTIVE_DEPENDENCY /DFMU_BUILD /DRUNTIME_STATIC_LINKING\n", | ||
| 3669 | "\n", | ||
| 3670 | "\n", | ||
| 3671 | "# /MD - link with MSVCRT.LIB\n", | ||
| 3672 | "# /link - [linker options and libraries]\n", | ||
| 3673 | "# /LIBPATH: - Directories where libs can be found\n", | ||
| 3674 | "OMCPP_SOLVER_LIBS=OMCppNewton_static.lib OMCppDgesv_static.lib OMCppDgesvSolver_static.lib -lOMCppSolver_static\n", | ||
| 3675 | "MODELICA_UTILITIES_LIB=OMCppModelicaUtilities_static.lib\n", | ||
| 3676 | "EXTRA_LIBS=" | ||
| 3677 | }, false)); | ||
| 3678 | ✗ | txt := Tpl.writeText(txt, l_dirExtra); | |
| 3679 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 3680 | ✗ | txt := Tpl.writeText(txt, l_libsExtra); | |
| 3681 | ✗ | txt := Tpl.softNewLine(txt); | |
| 3682 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3683 | "\n", | ||
| 3684 | "LDFLAGS=/link /DLL /NOENTRY /LIBPATH:\"" | ||
| 3685 | }, false)); | ||
| 3686 | ✗ | txt := Tpl.writeStr(txt, i_makefileParams_omhome); | |
| 3687 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/lib/")); | |
| 3688 | ✗ | ret_8 := Config.targetTriple(); | |
| 3689 | ✗ | txt := Tpl.writeStr(txt, ret_8); | |
| 3690 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/omc/cpp\" /LIBPATH:\"")); | |
| 3691 | ✗ | txt := Tpl.writeStr(txt, i_makefileParams_omhome); | |
| 3692 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3693 | "/bin\" OMCppSystem_static.lib OMCppMath_static.lib OMCppExtensionUtilities_static.lib OMCppFMU_static.lib $(OMCPP_SOLVER_LIBS) $(EXTRA_LIBS) $(MODELICA_UTILITIES_LIB)\n", | ||
| 3694 | "\n", | ||
| 3695 | "PLATFORM=\"" | ||
| 3696 | }, false)); | ||
| 3697 | ✗ | txt := Tpl.writeStr(txt, i_makefileParams_platform); | |
| 3698 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3699 | "\"\n", | ||
| 3700 | "\n", | ||
| 3701 | "MODELICA_SYSTEM_LIB=" | ||
| 3702 | }, false)); | ||
| 3703 | ✗ | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 3704 | ✗ | txt := Tpl.softNewLine(txt); | |
| 3705 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3706 | "CALCHELPERMAINFILE=OMCpp$(MODELICA_SYSTEM_LIB)CalcHelperMain.cpp\n", | ||
| 3707 | "\n" | ||
| 3708 | }, true)); | ||
| 3709 | ✗ | txt := Tpl.writeStr(txt, i_fmuTargetName); | |
| 3710 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE(".fmu: $(MODELICA_SYSTEM_LIB)$(DLLEXT)\n")); | |
| 3711 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 3712 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE("rm -rf binaries\n")); | |
| 3713 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 3714 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE("mkdir -p \"binaries/$(PLATFORM)\"\n")); | |
| 3715 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 3716 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE("mv $(MODELICA_SYSTEM_LIB)$(DLLEXT) \"binaries/$(PLATFORM)/\"\n")); | |
| 3717 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 3718 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE("rm -f $(MODELICA_SYSTEM_LIB).fmu\n")); | |
| 3719 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 3720 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("zip -r \"")); | |
| 3721 | ✗ | txt := Tpl.writeStr(txt, i_fmuTargetName); | |
| 3722 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE(".fmu\" modelDescription.xml binaries\n")); | |
| 3723 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 3724 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 3725 | "rm -rf binaries\n", | ||
| 3726 | "\n", | ||
| 3727 | "$(MODELICA_SYSTEM_LIB)$(DLLEXT):\n" | ||
| 3728 | }, true)); | ||
| 3729 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 3730 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("$(CXX) /Fe$(MODELICA_SYSTEM_LIB)$(DLLEXT) $(CALCHELPERMAINFILE) $(CFLAGS) $(LDFLAGS)")); | |
| 3731 | then txt; | ||
| 3732 | |||
| 3733 | case ( txt, | ||
| 3734 | _ ) | ||
| 3735 | then txt; | ||
| 3736 | end match; | ||
| 3737 | end fun_148; | ||
| 3738 | |||
| 3739 | protected function fun_149 | ||
| 3740 | input Tpl.Text in_txt; | ||
| 3741 | input String in_a_modelInfo_directory; | ||
| 3742 | |||
| 3743 | output Tpl.Text out_txt; | ||
| 3744 | algorithm | ||
| 3745 | out_txt := | ||
| 3746 | match(in_txt, in_a_modelInfo_directory) | ||
| 3747 | local | ||
| 3748 | Tpl.Text txt; | ||
| 3749 | String i_modelInfo_directory; | ||
| 3750 | |||
| 3751 | case ( txt, | ||
| 3752 | "" ) | ||
| 3753 | then txt; | ||
| 3754 | |||
| 3755 | case ( txt, | ||
| 3756 | i_modelInfo_directory ) | ||
| 3757 | algorithm | ||
| 3758 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("-L\"")); | |
| 3759 | ✗ | txt := Tpl.writeStr(txt, i_modelInfo_directory); | |
| 3760 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 3761 | then txt; | ||
| 3762 | end match; | ||
| 3763 | end fun_149; | ||
| 3764 | |||
| 3765 | protected function lm_150 | ||
| 3766 | input output Tpl.Text txt; | ||
| 3767 | input list<String> items; | ||
| 3768 | algorithm | ||
| 3769 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | for lstElt_150 in items loop |
| 3770 | txt := match lstElt_150 | ||
| 3771 | local | ||
| 3772 | String i_lib; | ||
| 3773 | |||
| 3774 | case i_lib | ||
| 3775 | algorithm | ||
| 3776 | ✗ | txt := Tpl.writeStr(txt, i_lib); | |
| 3777 | ✗ | txt := Tpl.nextIter(txt); | |
| 3778 | then txt; | ||
| 3779 | end match; | ||
| 3780 | end for; | ||
| 3781 | end lm_150; | ||
| 3782 | |||
| 3783 | protected function fun_151 | ||
| 3784 | input Tpl.Text in_txt; | ||
| 3785 | input Option<SimCode.SimulationSettings> in_a_sopt; | ||
| 3786 | |||
| 3787 | output Tpl.Text out_txt; | ||
| 3788 | algorithm | ||
| 3789 | out_txt := | ||
| 3790 | match(in_txt, in_a_sopt) | ||
| 3791 | local | ||
| 3792 | Tpl.Text txt; | ||
| 3793 | |||
| 3794 | case ( txt, | ||
| 3795 | SOME(SimCode.SIMULATION_SETTINGS(startTime = _)) ) | ||
| 3796 | then txt; | ||
| 3797 | |||
| 3798 | case ( txt, | ||
| 3799 | _ ) | ||
| 3800 | then txt; | ||
| 3801 | end match; | ||
| 3802 | end fun_151; | ||
| 3803 | |||
| 3804 | protected function fun_152 | ||
| 3805 | input Tpl.Text in_txt; | ||
| 3806 | input String in_a_makefileParams_platform; | ||
| 3807 | |||
| 3808 | output Tpl.Text out_txt; | ||
| 3809 | algorithm | ||
| 3810 | out_txt := | ||
| 3811 | match(in_txt, in_a_makefileParams_platform) | ||
| 3812 | local | ||
| 3813 | Tpl.Text txt; | ||
| 3814 | String i_makefileParams_platform; | ||
| 3815 | |||
| 3816 | case ( txt, | ||
| 3817 | "i386-pc-linux" ) | ||
| 3818 | algorithm | ||
| 3819 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("linux32")); | |
| 3820 | then txt; | ||
| 3821 | |||
| 3822 | case ( txt, | ||
| 3823 | "x86_64-linux" ) | ||
| 3824 | algorithm | ||
| 3825 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("linux64")); | |
| 3826 | then txt; | ||
| 3827 | |||
| 3828 | case ( txt, | ||
| 3829 | i_makefileParams_platform ) | ||
| 3830 | algorithm | ||
| 3831 | 8 | txt := Tpl.writeStr(txt, i_makefileParams_platform); | |
| 3832 | then txt; | ||
| 3833 | end match; | ||
| 3834 | end fun_152; | ||
| 3835 | |||
| 3836 | protected function fun_153 | ||
| 3837 | input Tpl.Text in_txt; | ||
| 3838 | input String in_a_makefileParams_platform; | ||
| 3839 | |||
| 3840 | output Tpl.Text out_txt; | ||
| 3841 | algorithm | ||
| 3842 | out_txt := | ||
| 3843 | match(in_txt, in_a_makefileParams_platform) | ||
| 3844 | local | ||
| 3845 | Tpl.Text txt; | ||
| 3846 | String i_makefileParams_platform; | ||
| 3847 | |||
| 3848 | case ( txt, | ||
| 3849 | "i386-pc-linux" ) | ||
| 3850 | algorithm | ||
| 3851 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("i686-linux")); | |
| 3852 | then txt; | ||
| 3853 | |||
| 3854 | case ( txt, | ||
| 3855 | "linux32" ) | ||
| 3856 | algorithm | ||
| 3857 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("i686-linux")); | |
| 3858 | then txt; | ||
| 3859 | |||
| 3860 | case ( txt, | ||
| 3861 | "i686-linux" ) | ||
| 3862 | algorithm | ||
| 3863 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("i686-linux")); | |
| 3864 | then txt; | ||
| 3865 | |||
| 3866 | case ( txt, | ||
| 3867 | "x86_64-linux" ) | ||
| 3868 | algorithm | ||
| 3869 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("x86_64-linux")); | |
| 3870 | then txt; | ||
| 3871 | |||
| 3872 | case ( txt, | ||
| 3873 | "linux64" ) | ||
| 3874 | algorithm | ||
| 3875 | 1 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("x86_64-linux")); | |
| 3876 | then txt; | ||
| 3877 | |||
| 3878 | case ( txt, | ||
| 3879 | "win64" ) | ||
| 3880 | algorithm | ||
| 3881 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("x86_64-windows")); | |
| 3882 | then txt; | ||
| 3883 | |||
| 3884 | case ( txt, | ||
| 3885 | "win32" ) | ||
| 3886 | algorithm | ||
| 3887 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("i686-windows")); | |
| 3888 | then txt; | ||
| 3889 | |||
| 3890 | case ( txt, | ||
| 3891 | "darwin64" ) | ||
| 3892 | algorithm | ||
| 3893 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("x86_64-darwin")); | |
| 3894 | then txt; | ||
| 3895 | |||
| 3896 | case ( txt, | ||
| 3897 | i_makefileParams_platform ) | ||
| 3898 | algorithm | ||
| 3899 | ✗ | txt := Tpl.writeStr(txt, i_makefileParams_platform); | |
| 3900 | then txt; | ||
| 3901 | end match; | ||
| 3902 | end fun_153; | ||
| 3903 | |||
| 3904 | protected function fun_154 | ||
| 3905 | input Tpl.Text in_txt; | ||
| 3906 | input Boolean in_mArg; | ||
| 3907 | input String in_a_makefileParams_platform; | ||
| 3908 | |||
| 3909 | output Tpl.Text out_txt; | ||
| 3910 | algorithm | ||
| 3911 | out_txt := | ||
| 3912 | match(in_txt, in_mArg, in_a_makefileParams_platform) | ||
| 3913 | local | ||
| 3914 | Tpl.Text txt; | ||
| 3915 | String a_makefileParams_platform; | ||
| 3916 | |||
| 3917 | case ( txt, | ||
| 3918 | false, | ||
| 3919 | a_makefileParams_platform ) | ||
| 3920 | algorithm | ||
| 3921 | 8 | txt := fun_152(txt, a_makefileParams_platform); | |
| 3922 | then txt; | ||
| 3923 | |||
| 3924 | case ( txt, | ||
| 3925 | _, | ||
| 3926 | a_makefileParams_platform ) | ||
| 3927 | algorithm | ||
| 3928 | 1 | txt := fun_153(txt, a_makefileParams_platform); | |
| 3929 | then txt; | ||
| 3930 | end match; | ||
| 3931 | end fun_154; | ||
| 3932 | |||
| 3933 | protected function fun_155 | ||
| 3934 | input Tpl.Text in_txt; | ||
| 3935 | input String in_mArg; | ||
| 3936 | input Tpl.Text in_a_omhome; | ||
| 3937 | |||
| 3938 | output Tpl.Text out_txt; | ||
| 3939 | algorithm | ||
| 3940 | out_txt := | ||
| 3941 | match(in_txt, in_mArg, in_a_omhome) | ||
| 3942 | local | ||
| 3943 | Tpl.Text txt; | ||
| 3944 | Tpl.Text a_omhome; | ||
| 3945 | |||
| 3946 | case ( txt, | ||
| 3947 | "win32", | ||
| 3948 | a_omhome ) | ||
| 3949 | algorithm | ||
| 3950 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 3951 | ✗ | txt := Tpl.writeText(txt, a_omhome); | |
| 3952 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/bin/libopenblas.dll\"")); | |
| 3953 | then txt; | ||
| 3954 | |||
| 3955 | case ( txt, | ||
| 3956 | "win64", | ||
| 3957 | a_omhome ) | ||
| 3958 | algorithm | ||
| 3959 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 3960 | ✗ | txt := Tpl.writeText(txt, a_omhome); | |
| 3961 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/bin/libopenblas.dll\"")); | |
| 3962 | then txt; | ||
| 3963 | |||
| 3964 | case ( txt, | ||
| 3965 | "i686-windows", | ||
| 3966 | a_omhome ) | ||
| 3967 | algorithm | ||
| 3968 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 3969 | ✗ | txt := Tpl.writeText(txt, a_omhome); | |
| 3970 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/bin/libopenblas.dll\"")); | |
| 3971 | then txt; | ||
| 3972 | |||
| 3973 | case ( txt, | ||
| 3974 | "x86_64-windows", | ||
| 3975 | a_omhome ) | ||
| 3976 | algorithm | ||
| 3977 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 3978 | ✗ | txt := Tpl.writeText(txt, a_omhome); | |
| 3979 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/bin/libopenblas.dll\"")); | |
| 3980 | then txt; | ||
| 3981 | |||
| 3982 | case ( txt, | ||
| 3983 | _, | ||
| 3984 | _ ) | ||
| 3985 | then txt; | ||
| 3986 | end match; | ||
| 3987 | end fun_155; | ||
| 3988 | |||
| 3989 | protected function fun_156 | ||
| 3990 | input Tpl.Text in_txt; | ||
| 3991 | input String in_a_makefileParams_platform; | ||
| 3992 | |||
| 3993 | output Tpl.Text out_txt; | ||
| 3994 | algorithm | ||
| 3995 | out_txt := | ||
| 3996 | match(in_txt, in_a_makefileParams_platform) | ||
| 3997 | local | ||
| 3998 | Tpl.Text txt; | ||
| 3999 | |||
| 4000 | case ( txt, | ||
| 4001 | "win32" ) | ||
| 4002 | algorithm | ||
| 4003 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"mkdir.exe\"")); | |
| 4004 | then txt; | ||
| 4005 | |||
| 4006 | case ( txt, | ||
| 4007 | "win64" ) | ||
| 4008 | algorithm | ||
| 4009 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"mkdir.exe\"")); | |
| 4010 | then txt; | ||
| 4011 | |||
| 4012 | case ( txt, | ||
| 4013 | _ ) | ||
| 4014 | algorithm | ||
| 4015 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("mkdir")); | |
| 4016 | then txt; | ||
| 4017 | end match; | ||
| 4018 | end fun_156; | ||
| 4019 | |||
| 4020 | protected function fun_157 | ||
| 4021 | input Tpl.Text in_txt; | ||
| 4022 | input Boolean in_mArg; | ||
| 4023 | input String in_a_makefileParams_omhome; | ||
| 4024 | |||
| 4025 | output Tpl.Text out_txt; | ||
| 4026 | algorithm | ||
| 4027 | out_txt := | ||
| 4028 | match(in_txt, in_mArg, in_a_makefileParams_omhome) | ||
| 4029 | local | ||
| 4030 | Tpl.Text txt; | ||
| 4031 | String a_makefileParams_omhome; | ||
| 4032 | |||
| 4033 | case ( txt, | ||
| 4034 | false, | ||
| 4035 | a_makefileParams_omhome ) | ||
| 4036 | algorithm | ||
| 4037 | 9 | txt := Tpl.writeStr(txt, a_makefileParams_omhome); | |
| 4038 | then txt; | ||
| 4039 | |||
| 4040 | case ( txt, | ||
| 4041 | _, | ||
| 4042 | _ ) | ||
| 4043 | algorithm | ||
| 4044 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("$(OPENMODELICAHOME)")); | |
| 4045 | then txt; | ||
| 4046 | end match; | ||
| 4047 | end fun_157; | ||
| 4048 | |||
| 4049 | protected function lm_158 | ||
| 4050 | input output Tpl.Text txt; | ||
| 4051 | input list<String> items; | ||
| 4052 | algorithm | ||
| 4053 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | for lstElt_158 in items loop |
| 4054 | txt := match lstElt_158 | ||
| 4055 | local | ||
| 4056 | String i_it; | ||
| 4057 | |||
| 4058 | case i_it | ||
| 4059 | algorithm | ||
| 4060 | ✗ | txt := Tpl.writeStr(txt, i_it); | |
| 4061 | ✗ | txt := Tpl.nextIter(txt); | |
| 4062 | then txt; | ||
| 4063 | end match; | ||
| 4064 | end for; | ||
| 4065 | end lm_158; | ||
| 4066 | |||
| 4067 | protected function fun_159 | ||
| 4068 | input Tpl.Text in_txt; | ||
| 4069 | input SimCode.SimCode in_a_simCode; | ||
| 4070 | input String in_a_extraAnnotations; | ||
| 4071 | input String in_a_additionalLinkerFlags__GCC; | ||
| 4072 | input String in_a_additionalCFlags__GCC; | ||
| 4073 | input String in_a_FMUVersion; | ||
| 4074 | |||
| 4075 | output Tpl.Text out_txt; | ||
| 4076 | algorithm | ||
| 4077 | out_txt := | ||
| 4078 | match(in_txt, in_a_simCode, in_a_extraAnnotations, in_a_additionalLinkerFlags__GCC, in_a_additionalCFlags__GCC, in_a_FMUVersion) | ||
| 4079 | local | ||
| 4080 | Tpl.Text txt; | ||
| 4081 | String a_extraAnnotations; | ||
| 4082 | String a_additionalLinkerFlags__GCC; | ||
| 4083 | String a_additionalCFlags__GCC; | ||
| 4084 | String a_FMUVersion; | ||
| 4085 | String i_fmuTargetName; | ||
| 4086 | list<String> i_makefileParams_includes; | ||
| 4087 | String i_makefileParams_dllext; | ||
| 4088 | String i_makefileParams_cxxcompiler; | ||
| 4089 | String i_makefileParams_ccompiler; | ||
| 4090 | String i_fileNamePrefix; | ||
| 4091 | String i_makefileParams_omhome; | ||
| 4092 | String i_makefileParams_platform; | ||
| 4093 | Option<SimCode.SimulationSettings> i_sopt; | ||
| 4094 | list<String> i_makefileParams_libs; | ||
| 4095 | String i_modelInfo_directory; | ||
| 4096 | String ret_12; | ||
| 4097 | Boolean ret_11; | ||
| 4098 | Boolean ret_10; | ||
| 4099 | Boolean ret_9; | ||
| 4100 | Tpl.Text l_mkdir; | ||
| 4101 | String str_7; | ||
| 4102 | Tpl.Text l_lapackbins; | ||
| 4103 | Tpl.Text l_omhome; | ||
| 4104 | Boolean ret_4; | ||
| 4105 | Tpl.Text l_platformstr; | ||
| 4106 | Tpl.Text l_extraCflags; | ||
| 4107 | Tpl.Text l_libsExtra; | ||
| 4108 | Tpl.Text l_dirExtra; | ||
| 4109 | |||
| 4110 | case ( txt, | ||
| 4111 | SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(directory = i_modelInfo_directory), makefileParams = SimCodeFunction.MAKEFILE_PARAMS(libs = i_makefileParams_libs, platform = i_makefileParams_platform, omhome = i_makefileParams_omhome, ccompiler = i_makefileParams_ccompiler, cxxcompiler = i_makefileParams_cxxcompiler, dllext = i_makefileParams_dllext, includes = i_makefileParams_includes), simulationSettingsOpt = i_sopt, fileNamePrefix = i_fileNamePrefix, fmuTargetName = i_fmuTargetName), | ||
| 4112 | a_extraAnnotations, | ||
| 4113 | a_additionalLinkerFlags__GCC, | ||
| 4114 | a_additionalCFlags__GCC, | ||
| 4115 | a_FMUVersion ) | ||
| 4116 | algorithm | ||
| 4117 | 9 | l_dirExtra := fun_149(Tpl.emptyTxt, i_modelInfo_directory); | |
| 4118 | 9 | l_libsExtra := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(" ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 4119 | 9 | l_libsExtra := lm_150(l_libsExtra, i_makefileParams_libs); | |
| 4120 | 9 | l_libsExtra := Tpl.popIter(l_libsExtra); | |
| 4121 | 9 | l_extraCflags := fun_151(Tpl.emptyTxt, i_sopt); | |
| 4122 | 9 | ret_4 := FMI.isFMIVersion30(a_FMUVersion); | |
| 4123 | 9 | l_platformstr := fun_154(Tpl.emptyTxt, ret_4, i_makefileParams_platform); | |
| 4124 | 9 | l_omhome := Tpl.writeStr(Tpl.emptyTxt, i_makefileParams_omhome); | |
| 4125 | 9 | str_7 := Tpl.textString(l_platformstr); | |
| 4126 | 9 | l_lapackbins := fun_155(Tpl.emptyTxt, str_7, l_omhome); | |
| 4127 | 9 | l_mkdir := fun_156(Tpl.emptyTxt, i_makefileParams_platform); | |
| 4128 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4129 | "# Makefile generated by OpenModelica for native and cross compilation\n", | ||
| 4130 | "# How to cross compile:\n", | ||
| 4131 | "# - build OpenModelica (omc) from source code (see github.com/OpenModelica)\n", | ||
| 4132 | "# - install a cross compiler, e.g. apt-get install g++-mingw-w64-i686\n", | ||
| 4133 | "# - fix or work around capitalization of windows.h in MSL, see\n", | ||
| 4134 | "# https://trac.modelica.org/Modelica/ticket/1962\n", | ||
| 4135 | "# - add the target triplet, e.g. i686-w64-mingw32, to\n", | ||
| 4136 | "# OMCompiler/SimulationRuntime/cpp/Makefile\n", | ||
| 4137 | "# - rebuild omc to add the new platform\n", | ||
| 4138 | "# - invoke the omc commands\n", | ||
| 4139 | "# setCommandLineOptions(\"--simCodeTarget=Cpp\");\n", | ||
| 4140 | "# buildModelFMU(MyModel, platforms={\"i686-w64-mingw32\"});\n", | ||
| 4141 | "# - alternatively call this Makefile with\n", | ||
| 4142 | "# make TARGET_TRIPLET=i686-w64-mingw32 -f " | ||
| 4143 | }, false)); | ||
| 4144 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4145 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4146 | "_FMU.makefile\n", | ||
| 4147 | "\n", | ||
| 4148 | "#TARGET_TRIPLET=\n", | ||
| 4149 | "# escape spaces for make\n", | ||
| 4150 | "empty :=\n", | ||
| 4151 | "space := $(empty) $(empty)\n", | ||
| 4152 | "escape_path = $(subst $(space),\\$(space),$1)\n", | ||
| 4153 | "\n", | ||
| 4154 | "OMHOME:=" | ||
| 4155 | }, false)); | ||
| 4156 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
9 | ret_9 := stringEq(i_makefileParams_platform, "win32"); |
| 4157 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
9 | ret_10 := stringEq(i_makefileParams_platform, "win64"); |
| 4158 | 9 | ret_11 := boolOr(ret_9, ret_10); | |
| 4159 | 9 | txt := fun_157(txt, ret_11, i_makefileParams_omhome); | |
| 4160 | 9 | txt := Tpl.softNewLine(txt); | |
| 4161 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4162 | "OMHOME_ESCAPED:=$(call escape_path,$(OMHOME))\n", | ||
| 4163 | "include $(OMHOME_ESCAPED)/include/omc/cpp/ModelicaConfig_gcc.inc\n", | ||
| 4164 | "include $(OMHOME_ESCAPED)/include/omc/cpp/ModelicaLibraryConfig_gcc.inc\n", | ||
| 4165 | "\n", | ||
| 4166 | "# simulations use -O0 by default; can be changed to e.g. -O2 or -Ofast\n", | ||
| 4167 | "SIM_OPT_LEVEL=-O0\n", | ||
| 4168 | "# the default is ON by default, override the var from commandLine to skip the zipping of fmu e.g. make -f ZIP_FMU=OFF\n", | ||
| 4169 | "ZIP_FMU = ON\n", | ||
| 4170 | "# native build or cross compilation\n", | ||
| 4171 | "ifeq ($(TARGET_TRIPLET),)\n" | ||
| 4172 | }, true)); | ||
| 4173 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 4174 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("TRIPLET=")); | |
| 4175 | 9 | ret_12 := Config.targetTriple(); | |
| 4176 | 9 | txt := Tpl.writeStr(txt, ret_12); | |
| 4177 | 9 | txt := Tpl.softNewLine(txt); | |
| 4178 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("CC=")); | |
| 4179 | 9 | txt := Tpl.writeStr(txt, i_makefileParams_ccompiler); | |
| 4180 | 9 | txt := Tpl.softNewLine(txt); | |
| 4181 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("CXX=")); | |
| 4182 | 9 | txt := Tpl.writeStr(txt, i_makefileParams_cxxcompiler); | |
| 4183 | 9 | txt := Tpl.softNewLine(txt); | |
| 4184 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4185 | "ABI_CFLAG=\n", | ||
| 4186 | "DLLEXT=" | ||
| 4187 | }, false)); | ||
| 4188 | 9 | txt := Tpl.writeStr(txt, i_makefileParams_dllext); | |
| 4189 | 9 | txt := Tpl.softNewLine(txt); | |
| 4190 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("PLATFORM=")); | |
| 4191 | 9 | txt := Tpl.writeText(txt, l_platformstr); | |
| 4192 | 9 | txt := Tpl.softNewLine(txt); | |
| 4193 | 9 | txt := Tpl.popBlock(txt); | |
| 4194 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4195 | "else\n", | ||
| 4196 | " TRIPLET=$(TARGET_TRIPLET)\n", | ||
| 4197 | " CC=$(TRIPLET)-gcc\n", | ||
| 4198 | " CXX=$(TRIPLET)-g++\n", | ||
| 4199 | " ABI_CFLAG=-D_GLIBCXX_USE_CXX11_ABI=0\n", | ||
| 4200 | " DLLEXT=$(if $(findstring mingw,$(TRIPLET)),.dll,.so)\n", | ||
| 4201 | " WORDSIZE=$(if $(findstring x86_64,$(TRIPLET)),64,32)\n", | ||
| 4202 | " PLATFORM=$(if $(findstring darwin,$(TRIPLET)),darwin,$(if $(findstring mingw,$(TRIPLET)),win,linux))$(WORDSIZE)\n", | ||
| 4203 | "endif\n", | ||
| 4204 | "\n", | ||
| 4205 | "CFLAGS_BASED_ON_INIT_FILE=" | ||
| 4206 | }, false)); | ||
| 4207 | 9 | txt := Tpl.writeText(txt, l_extraCflags); | |
| 4208 | 9 | txt := Tpl.softNewLine(txt); | |
| 4209 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4210 | "FMU_CFLAGS=$(subst -DUSE_THREAD,,$(subst -O0,$(SIM_OPT_LEVEL),$(SYSTEM_CFLAGS))) $(ABI_CFLAG)\n", | ||
| 4211 | "CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) -Winvalid-pch $(FMU_CFLAGS) -DFMU_BUILD -DRUNTIME_STATIC_LINKING -I\"$(OMHOME)/include/omc/cpp\" -I\"$(UMFPACK_INCLUDE)\" -I\"$(SUNDIALS_INCLUDE)\" " | ||
| 4212 | }, false)); | ||
| 4213 | 9 | txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(" ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 4214 | 9 | txt := lm_158(txt, i_makefileParams_includes); | |
| 4215 | 9 | txt := Tpl.popIter(txt); | |
| 4216 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 4217 | 9 | txt := Tpl.writeStr(txt, a_additionalCFlags__GCC); | |
| 4218 | 9 | txt := Tpl.softNewLine(txt); | |
| 4219 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4220 | "\n", | ||
| 4221 | "ifeq ($(USE_LOGGER),ON)\n", | ||
| 4222 | " $(eval CFLAGS=$(CFLAGS) -DUSE_LOGGER)\n", | ||
| 4223 | "endif\n", | ||
| 4224 | "\n", | ||
| 4225 | "LDFLAGS=-L\"$(OMHOME)/lib/$(TRIPLET)/omc/cpp\" " | ||
| 4226 | }, false)); | ||
| 4227 | 9 | txt := Tpl.writeStr(txt, a_additionalLinkerFlags__GCC); | |
| 4228 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4229 | " $(SYSTEM_LDFLAGS)\n", | ||
| 4230 | "ifeq ($(findstring linux,$(PLATFORM)),linux)\n", | ||
| 4231 | " LDFLAGS+=-Wl,--no-undefined\n", | ||
| 4232 | "endif\n", | ||
| 4233 | "\n", | ||
| 4234 | "CALCHELPERMAINFILE=OMCpp" | ||
| 4235 | }, false)); | ||
| 4236 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4237 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4238 | "CalcHelperMain.cpp\n", | ||
| 4239 | "\n", | ||
| 4240 | "# CVode can be used for Co-Simulation FMUs, Kinsol is available to handle non linear equation systems\n", | ||
| 4241 | "OMCPP_SOLVER_LIBS=-lOMCppNewton_static -lOMCppDgesvSolver_static -lOMCppSolver_static\n", | ||
| 4242 | "ifeq ($(USE_FMU_SUNDIALS),ON)\n", | ||
| 4243 | "$(eval OMCPP_SOLVER_LIBS=$(OMCPP_SOLVER_LIBS) -lOMCppKinsol_static $(SUNDIALS_LIBRARIES))\n", | ||
| 4244 | "$(eval CFLAGS=-DENABLE_SUNDIALS_STATIC $(CFLAGS))\n", | ||
| 4245 | "endif\n", | ||
| 4246 | "\n", | ||
| 4247 | "CPPFLAGS=$(CFLAGS)\n", | ||
| 4248 | "\n", | ||
| 4249 | "BINARIES=" | ||
| 4250 | }, false)); | ||
| 4251 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4252 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4253 | "$(DLLEXT)\n", | ||
| 4254 | "\n", | ||
| 4255 | "OMCPP_LIBS=-lOMCppSystem_static -lOMCppMath_static -lOMCppFMU_static $(OMCPP_SOLVER_LIBS) -lOMCppExtensionUtilities_static\n", | ||
| 4256 | "MODELICA_UTILITIES_LIB=-lOMCppModelicaUtilities_static\n", | ||
| 4257 | "EXTRA_LIBS=" | ||
| 4258 | }, false)); | ||
| 4259 | 9 | txt := Tpl.writeText(txt, l_dirExtra); | |
| 4260 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 4261 | 9 | txt := Tpl.writeText(txt, l_libsExtra); | |
| 4262 | 9 | txt := Tpl.softNewLine(txt); | |
| 4263 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4264 | "LIBS=$(EXTRA_LIBS) $(OMCPP_LIBS) $(MODELICA_UTILITIES_LIB) $(BASE_LIB)\n", | ||
| 4265 | "\n", | ||
| 4266 | "# link with simple dgesv or full lapack\n", | ||
| 4267 | "ifeq ($(USE_DGESV),ON)\n", | ||
| 4268 | " $(eval LIBS=$(LIBS) -lOMCppDgesv_static)\n", | ||
| 4269 | "else\n", | ||
| 4270 | " $(eval LIBS=$(LIBS) -L$(LAPACK_LIBS) $(LAPACK_LIBRARIES))\n" | ||
| 4271 | }, true)); | ||
| 4272 | 9 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 4273 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("$(eval BINARIES=$(BINARIES) ")); | |
| 4274 | 9 | txt := Tpl.writeText(txt, l_lapackbins); | |
| 4275 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE(")\n")); | |
| 4276 | 9 | txt := Tpl.popBlock(txt); | |
| 4277 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4278 | "endif\n", | ||
| 4279 | "\n", | ||
| 4280 | "# link static libs to avoid dependencies; can\'t link all static under Linux\n", | ||
| 4281 | "ifeq ($(findstring gcc,$(CC)),gcc)\n", | ||
| 4282 | " $(eval LIBS=$(LIBS) $(if $(findstring linux,$(PLATFORM)),-static-libstdc++ -static-libgcc))\n", | ||
| 4283 | "else ifeq ($(findstring clang,$(CC)),clang)\n", | ||
| 4284 | " $(eval LIBS=$(LIBS) $(if $(findstring linux,$(PLATFORM)),-static-libstdc++ -static-libgcc))\n", | ||
| 4285 | "endif\n", | ||
| 4286 | "ifeq ($(findstring linux,$(PLATFORM))$(findstring darwin,$(PLATFORM)),)\n", | ||
| 4287 | " $(eval LIBS=$(LIBS) -static)\n", | ||
| 4288 | "endif\n", | ||
| 4289 | "\n", | ||
| 4290 | "CPPFILES=$(CALCHELPERMAINFILE)\n", | ||
| 4291 | "OFILES=$(CPPFILES:.cpp=.o)\n", | ||
| 4292 | "\n", | ||
| 4293 | ".PHONY: " | ||
| 4294 | }, false)); | ||
| 4295 | 9 | txt := Tpl.writeStr(txt, i_fmuTargetName); | |
| 4296 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4297 | ".fmu $(CPPFILES) clean\n", | ||
| 4298 | "\n" | ||
| 4299 | }, true)); | ||
| 4300 | 9 | txt := Tpl.writeStr(txt, i_fmuTargetName); | |
| 4301 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE(".fmu: $(OFILES)\n")); | |
| 4302 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4303 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("$(CXX) -shared -o ")); | |
| 4304 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4305 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("$(DLLEXT) $(OFILES) $(LDFLAGS) $(LIBS)\n")); | |
| 4306 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4307 | 9 | txt := Tpl.writeText(txt, l_mkdir); | |
| 4308 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4309 | " -p \"binaries/$(PLATFORM)\"\n", | ||
| 4310 | "# copy (do not move): $(BINARIES) includes shared dependency DLLs such as\n", | ||
| 4311 | "# libopenblas.dll taken from <omhome>/bin; moving them out would break a\n", | ||
| 4312 | "# second FMU export in the same session (the C target copies here too).\n" | ||
| 4313 | }, true)); | ||
| 4314 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4315 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("cp $(BINARIES) \"binaries/$(PLATFORM)/\"\n")); | |
| 4316 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4317 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("rm -rf sources\n")); | |
| 4318 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4319 | 9 | txt := Tpl.writeText(txt, l_mkdir); | |
| 4320 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE(" -p sources\n")); | |
| 4321 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4322 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("install -p OMCpp")); | |
| 4323 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4324 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*.h OMCpp")); | |
| 4325 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4326 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*.cpp ")); | |
| 4327 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4328 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_init.xml ")); | |
| 4329 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4330 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4331 | "_FMU.makefile sources/\n", | ||
| 4332 | "ifeq ($(USE_FMU_SUNDIALS),ON)\n" | ||
| 4333 | }, true)); | ||
| 4334 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4335 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("rm -rf documentation\n")); | |
| 4336 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4337 | 9 | txt := Tpl.writeText(txt, l_mkdir); | |
| 4338 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE(" -p \"documentation\"\n")); | |
| 4339 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4340 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("cp $(SUNDIALS_LIBRARIES_KINSOL) \"binaries/$(PLATFORM)/\"\n")); | |
| 4341 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4342 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4343 | "cp \"$(OMHOME)/share/omc/runtime/cpp/licenses/sundials.license\" \"documentation/\"\n", | ||
| 4344 | "endif\n" | ||
| 4345 | }, true)); | ||
| 4346 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4347 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("rm -f ")); | |
| 4348 | 9 | txt := Tpl.writeStr(txt, i_fmuTargetName); | |
| 4349 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4350 | ".fmu\n", | ||
| 4351 | "ifeq ($(ZIP_FMU),ON)\n", | ||
| 4352 | "ifeq ($(USE_FMU_SUNDIALS),ON)\n" | ||
| 4353 | }, true)); | ||
| 4354 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4355 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("zip -r \"")); | |
| 4356 | 9 | txt := Tpl.writeStr(txt, i_fmuTargetName); | |
| 4357 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE(".fmu\" modelDescription.xml binaries sources documentation\n")); | |
| 4358 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4359 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4360 | "rm -rf documentation\n", | ||
| 4361 | "else\n" | ||
| 4362 | }, true)); | ||
| 4363 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4364 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("zip -r \"")); | |
| 4365 | 9 | txt := Tpl.writeStr(txt, i_fmuTargetName); | |
| 4366 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4367 | ".fmu\" modelDescription.xml binaries sources\n", | ||
| 4368 | "endif\n", | ||
| 4369 | "endif\n", | ||
| 4370 | "ifneq (\"" | ||
| 4371 | }, false)); | ||
| 4372 | 9 | txt := Tpl.writeStr(txt, a_extraAnnotations); | |
| 4373 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("\",\"\")\n")); | |
| 4374 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4375 | 9 | txt := Tpl.writeText(txt, l_mkdir); | |
| 4376 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4377 | " -p extra/org.openmodelica\n", | ||
| 4378 | "ifneq (\"$(wildcard " | ||
| 4379 | }, false)); | ||
| 4380 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4381 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("_modelInstance.json)\",\"\")\n")); | |
| 4382 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4383 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("jq --arg regex \"")); | |
| 4384 | 9 | txt := Tpl.writeStr(txt, a_extraAnnotations); | |
| 4385 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" -f \"$(OMHOME)/share/omc/scripts/filter-annotations.jq\" ")); | |
| 4386 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4387 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4388 | "_modelInstance.json > extra/org.openmodelica/modelAnnotations.json\n", | ||
| 4389 | "endif\n", | ||
| 4390 | "ifeq ($(ZIP_FMU),ON)\n" | ||
| 4391 | }, true)); | ||
| 4392 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4393 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("zip -ur \"")); | |
| 4394 | 9 | txt := Tpl.writeStr(txt, i_fmuTargetName); | |
| 4395 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4396 | ".fmu\" extra\n", | ||
| 4397 | "endif\n", | ||
| 4398 | "endif\n", | ||
| 4399 | "\n", | ||
| 4400 | "ifeq ($(ZIP_FMU),OFF)\n" | ||
| 4401 | }, true)); | ||
| 4402 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4403 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("rm -f OMCpp")); | |
| 4404 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4405 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("* ")); | |
| 4406 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4407 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_FMU.* ")); | |
| 4408 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4409 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".def ")); | |
| 4410 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4411 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".sh ")); | |
| 4412 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4413 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".bat ")); | |
| 4414 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4415 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".makefile ")); | |
| 4416 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4417 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("_init.xml\n")); | |
| 4418 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4419 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("rm -f ")); | |
| 4420 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4421 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4422 | "_modelInstance.json\n", | ||
| 4423 | "endif\n", | ||
| 4424 | "\n", | ||
| 4425 | "clean:\n" | ||
| 4426 | }, true)); | ||
| 4427 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4428 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("rm -f OMCpp")); | |
| 4429 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4430 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("* ")); | |
| 4431 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4432 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_FMU.* ")); | |
| 4433 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4434 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".def ")); | |
| 4435 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4436 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".sh ")); | |
| 4437 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4438 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".bat ")); | |
| 4439 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4440 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".makefile ")); | |
| 4441 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4442 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_LINE("_init.xml\n")); | |
| 4443 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\t")); | |
| 4444 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("rm -rf modelDescription.xml binaries sources documentation extra ")); | |
| 4445 | 9 | txt := Tpl.writeStr(txt, i_fileNamePrefix); | |
| 4446 | 9 | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 4447 | "_modelInstance.json\n", | ||
| 4448 | "\n" | ||
| 4449 | }, true)); | ||
| 4450 | then txt; | ||
| 4451 | |||
| 4452 | case ( txt, | ||
| 4453 | _, | ||
| 4454 | _, | ||
| 4455 | _, | ||
| 4456 | _, | ||
| 4457 | _ ) | ||
| 4458 | then txt; | ||
| 4459 | end match; | ||
| 4460 | end fun_159; | ||
| 4461 | |||
| 4462 | protected function fun_160 | ||
| 4463 | input Tpl.Text in_txt; | ||
| 4464 | input String in_mArg; | ||
| 4465 | input SimCode.SimCode in_a_simCode; | ||
| 4466 | input String in_a_FMUVersion; | ||
| 4467 | input String in_a_additionalLinkerFlags__GCC; | ||
| 4468 | input String in_a_additionalCFlags__GCC; | ||
| 4469 | input String in_a_extraAnnotations; | ||
| 4470 | |||
| 4471 | output Tpl.Text out_txt; | ||
| 4472 | algorithm | ||
| 4473 | out_txt := | ||
| 4474 | match(in_txt, in_mArg, in_a_simCode, in_a_FMUVersion, in_a_additionalLinkerFlags__GCC, in_a_additionalCFlags__GCC, in_a_extraAnnotations) | ||
| 4475 | local | ||
| 4476 | Tpl.Text txt; | ||
| 4477 | SimCode.SimCode a_simCode; | ||
| 4478 | String a_FMUVersion; | ||
| 4479 | String a_additionalLinkerFlags__GCC; | ||
| 4480 | String a_additionalCFlags__GCC; | ||
| 4481 | String a_extraAnnotations; | ||
| 4482 | |||
| 4483 | case ( txt, | ||
| 4484 | "msvc", | ||
| 4485 | a_simCode, | ||
| 4486 | _, | ||
| 4487 | _, | ||
| 4488 | _, | ||
| 4489 | _ ) | ||
| 4490 | algorithm | ||
| 4491 | ✗ | txt := fun_148(txt, a_simCode); | |
| 4492 | then txt; | ||
| 4493 | |||
| 4494 | case ( txt, | ||
| 4495 | "gcc", | ||
| 4496 | a_simCode, | ||
| 4497 | a_FMUVersion, | ||
| 4498 | a_additionalLinkerFlags__GCC, | ||
| 4499 | a_additionalCFlags__GCC, | ||
| 4500 | a_extraAnnotations ) | ||
| 4501 | algorithm | ||
| 4502 | 9 | txt := fun_159(txt, a_simCode, a_extraAnnotations, a_additionalLinkerFlags__GCC, a_additionalCFlags__GCC, a_FMUVersion); | |
| 4503 | then txt; | ||
| 4504 | |||
| 4505 | case ( txt, | ||
| 4506 | _, | ||
| 4507 | _, | ||
| 4508 | _, | ||
| 4509 | _, | ||
| 4510 | _, | ||
| 4511 | _ ) | ||
| 4512 | then txt; | ||
| 4513 | end match; | ||
| 4514 | end fun_160; | ||
| 4515 | |||
| 4516 | public function fmuMakefile | ||
| 4517 | input Tpl.Text txt; | ||
| 4518 | input String a_target; | ||
| 4519 | input SimCode.SimCode a_simCode; | ||
| 4520 | input Tpl.Text a_extraFuncs; | ||
| 4521 | input Tpl.Text a_extraFuncsDecl; | ||
| 4522 | input Tpl.Text a_extraFuncsNamespace; | ||
| 4523 | input String a_FMUVersion; | ||
| 4524 | input String a_additionalLinkerFlags__GCC; | ||
| 4525 | input String a_additionalLinkerFlags__MSVC; | ||
| 4526 | input String a_additionalCFlags__GCC; | ||
| 4527 | input String a_additionalCFlags__MSVC; | ||
| 4528 | input String a_extraAnnotations; | ||
| 4529 | |||
| 4530 | output Tpl.Text out_txt; | ||
| 4531 | output Tpl.Text out_a_extraFuncs; | ||
| 4532 | output Tpl.Text out_a_extraFuncsDecl; | ||
| 4533 | output Tpl.Text out_a_extraFuncsNamespace; | ||
| 4534 | protected | ||
| 4535 | String str_1; | ||
| 4536 | Tpl.Text txt_0; | ||
| 4537 | algorithm | ||
| 4538 | 9 | txt_0 := CodegenUtil.getGeneralTarget(Tpl.emptyTxt, a_target); | |
| 4539 | 9 | str_1 := Tpl.textString(txt_0); | |
| 4540 | 9 | out_txt := fun_160(txt, str_1, a_simCode, a_FMUVersion, a_additionalLinkerFlags__GCC, a_additionalCFlags__GCC, a_extraAnnotations); | |
| 4541 | out_a_extraFuncs := a_extraFuncs; | ||
| 4542 | out_a_extraFuncsDecl := a_extraFuncsDecl; | ||
| 4543 | out_a_extraFuncsNamespace := a_extraFuncsNamespace; | ||
| 4544 | end fmuMakefile; | ||
| 4545 | |||
| 4546 | annotation(__OpenModelica_Interface="codegen_cpp_ext"); | ||
| 4547 | end CodegenFMUCpp; | ||
| 4548 |