Changeset 7755d79 in OpenModelica
- Timestamp:
- 2023-03-25T10:50:00+01:00 (13 months ago)
- Children:
- 194557d
- Parents:
- 5aba6e5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/Template/CodegenC.tpl
r80e3f4b0 r7755d79 3446 3446 let &sub = buffer "" 3447 3447 << 3448 <%(startValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_impl _options(-1, -1, eq, contextOther, modelNamePrefix, /* Static? */ true, /* No optimization */ true, /* Initial? */ true) ; separator="\n")3449 %><%(nominalValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_impl_options(-1, -1, eq, contextOther, modelNamePrefix, /* Static? */ true, /* No optimization */ true, /* Initial? */ true) ; separator="\n")3450 %><%(minValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_impl_options(-1, -1, eq, contextOther, modelNamePrefix, /* Static? */ true, /* No optimization */ true, /* Initial? */ true) ; separator="\n")3451 %><%(maxValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_impl_options(-1, -1, eq, contextOther, modelNamePrefix, /* Static? */ true, /* No optimization */ true, /* Initial?*/ true) ; separator="\n") %>3448 <%(startValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_impl2(-1, -1, eq, contextOther, modelNamePrefix, /* Static? */ true, /* No optimization */ true, /* Initial? */ true) ; separator="\n")%> 3449 <%(nominalValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => functionUpdateBoundVariableAttributesFunctions(eq, "nominal", contextOther, modelNamePrefix, /* Static? */ true, /* No optimization */ true) ; separator="\n") %> 3450 <%(minValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => functionUpdateBoundVariableAttributesFunctions(eq, "min", contextOther, modelNamePrefix, /* Static? */ true, /* No optimization */ true) ; separator="\n") %> 3451 <%(maxValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => functionUpdateBoundVariableAttributesFunctions(eq, "max", contextOther, modelNamePrefix, /* Static? */ true, /* No optimization */ true) ; separator="\n") %> 3452 3452 OMC_DISABLE_OPT 3453 3453 int <%symbolName(modelNamePrefix,"updateBoundVariableAttributes")%>(DATA *data, threadData_t *threadData) … … 3455 3455 TRACE_PUSH 3456 3456 /* min ******************************************************** */ 3457 <%(minValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix) ; separator="\n")%>3458 3459 3457 infoStreamPrint(LOG_INIT, 1, "updating min-values"); 3460 <%minValueEquations |> SES_SIMPLE_ASSIGN(__) => 3461 << 3462 <%crefAttributes(cref)%>.min = <%cref(cref, &sub)%>; 3463 infoStreamPrint(LOG_INIT_V, 0, "%s(min=<%crefToPrintfArg(cref)%>)", <%crefVarInfo(cref)%>.name, (<%crefType(cref)%>) <%crefAttributes(cref)%>.min); 3464 <%cref(cref, &sub)%> = <%crefAttributes(cref)%>.start; 3465 >> 3466 ;separator="\n" 3467 %> 3458 <%minValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix)%> 3468 3459 if (ACTIVE_STREAM(LOG_INIT)) messageClose(LOG_INIT); 3469 3460 3470 3461 /* max ******************************************************** */ 3471 <%(maxValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix) ; separator="\n")%>3472 3473 3462 infoStreamPrint(LOG_INIT, 1, "updating max-values"); 3474 <%maxValueEquations |> SES_SIMPLE_ASSIGN(__) => 3475 << 3476 <%crefAttributes(cref)%>.max = <%cref(cref, &sub)%>; 3477 infoStreamPrint(LOG_INIT_V, 0, "%s(max=<%crefToPrintfArg(cref)%>)", <%crefVarInfo(cref)%>.name, (<%crefType(cref)%>) <%crefAttributes(cref)%>.max); 3478 <%cref(cref, &sub)%> = <%crefAttributes(cref)%>.start; 3479 >> 3480 ;separator="\n" 3481 %> 3463 <%maxValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix)%> 3482 3464 if (ACTIVE_STREAM(LOG_INIT)) messageClose(LOG_INIT); 3483 3465 3484 3466 /* nominal **************************************************** */ 3485 <%(nominalValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix) ; separator="\n")%>3486 3487 3467 infoStreamPrint(LOG_INIT, 1, "updating nominal-values"); 3488 <%nominalValueEquations |> SES_SIMPLE_ASSIGN(__) => 3489 << 3490 <%crefAttributes(cref)%>.nominal = <%cref(cref, &sub)%>; 3491 infoStreamPrint(LOG_INIT_V, 0, "%s(nominal=<%crefToPrintfArg(cref)%>)", <%crefVarInfo(cref)%>.name, (<%crefType(cref)%>) <%crefAttributes(cref)%>.nominal); 3492 <%cref(cref, &sub)%> = <%crefAttributes(cref)%>.start; 3493 >> 3494 ;separator="\n" 3495 %> 3468 <%nominalValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix)%> 3496 3469 if (ACTIVE_STREAM(LOG_INIT)) messageClose(LOG_INIT); 3497 3470 … … 3506 3479 >> 3507 3480 end functionUpdateBoundVariableAttributes; 3481 3482 template functionUpdateBoundVariableAttributesFunctions(SimEqSystem eq, String attribute, Context context, String modelNamePrefix, Boolean static, Boolean noOpt) 3483 "Generates an a function representing an equation for an attribute binding (e.g min, max ...)" 3484 ::= 3485 let OMC_NO_OPT = if noOpt then 'OMC_DISABLE_OPT<%\n%>' else (match eq case SES_LINEAR(__) then 'OMC_DISABLE_OPT<%\n%>') 3486 match eq 3487 case SES_SIMPLE_ASSIGN(exp=CALL(path=IDENT(name="fail"))) 3488 case SES_SIMPLE_ASSIGN_CONSTRAINTS(exp=CALL(path=IDENT(name="fail"))) then 3489 '<%generateThrow()%><%\n%>' 3490 3491 case SES_SIMPLE_ASSIGN(__) 3492 case SES_SIMPLE_ASSIGN_CONSTRAINTS(__) then 3493 3494 let ix = equationIndex(eq) /*System.tmpTickIndex(10)*/ 3495 let &varDecls = buffer "" 3496 let &auxFunction = buffer "" 3497 let body = functionUpdateBoundVariableAttributesFunctionsSimpleAssign(eq, attribute, context, &varDecls, &auxFunction) 3498 3499 << 3500 /* 3501 <%dumpEqs(fill(eq,1))%> 3502 */ 3503 <%OMC_NO_OPT%><% if static then "static "%>void <%symbolName(modelNamePrefix,"eqFunction")%>_<%ix%>(DATA *data, threadData_t *threadData) 3504 { 3505 TRACE_PUSH 3506 const int equationIndexes[2] = {1,<%ix%>}; 3507 <%&varDecls%> 3508 <%body%> 3509 TRACE_POP 3510 } 3511 3512 >> 3513 3514 else "NOT IMPLEMENTED EQUATION equation_" 3515 end functionUpdateBoundVariableAttributesFunctions; 3516 3517 template functionUpdateBoundVariableAttributesFunctionsSimpleAssign(SimEqSystem eq, String attribute, Context context, 3518 Text &varDecls, Text &auxFunction) 3519 "Generates an equation that is just a simple assignment for an arribute binding. The attribute type is given by the 3520 function argument 'attibute' (e.g min, max ...)" 3521 ::= 3522 match eq 3523 case SES_SIMPLE_ASSIGN(__) 3524 case SES_SIMPLE_ASSIGN_CONSTRAINTS(__) then 3525 let &sub = buffer "" 3526 let &preExp = buffer "" 3527 let expPart = daeExp(exp, context, &preExp, &varDecls, &auxFunction) 3528 let postExp = if isStartCref(cref) then 3529 << 3530 <%cref(popCref(cref), &sub)%> = <%cref(cref, &sub)%>; 3531 infoStreamPrint(LOG_INIT_V, 0, "updated start value: %s(start=<%crefToPrintfArg(popCref(cref))%>)", <%crefVarInfo(popCref(cref))%>.name, (<%crefType(popCref(cref))%>) <%cref(popCref(cref), &sub)%>); 3532 >> 3533 << 3534 <%modelicaLine(eqInfo(eq))%> 3535 <%preExp%> 3536 <%crefAttributes(cref)%>.<%attribute%> = <%expPart%>; 3537 infoStreamPrint(LOG_INIT_V, 0, "%s(<%attribute%>=<%crefToPrintfArg(cref)%>)", <%crefVarInfo(cref)%>.name, 3538 (<%crefType(cref)%>) <%crefAttributes(cref)%>.<%attribute%>); 3539 <%postExp%> 3540 <%endModelicaLine()%> 3541 >> 3542 end functionUpdateBoundVariableAttributesFunctionsSimpleAssign; 3543 3508 3544 3509 3545 template functionUpdateBoundParameters(list<SimEqSystem> simpleParameterEquations, list<SimEqSystem> parameterEquations, String fileNamePrefix, String fullPathPrefix, String modelNamePrefix, SimCode simCode)
Note: See TracChangeset
for help on using the changeset viewer.