@@ -460,21 +460,7 @@ template initValsDefault(SimVar var, String arrayName) ::=
460460 match var
461461 case SIMVAR(index=index, type_=type_) then
462462 let str = 'comp->fmuData->modelData-><%arrayName%>Data[<%index%>].attribute.start'
463- match initialValue
464- case SOME(v as ICONST(__))
465- case SOME(v as RCONST(__))
466- case SOME(v as SCONST(__))
467- case SOME(v as BCONST(__))
468- case SOME(v as ENUM_LITERAL(__)) then
469- '<%str%> = <%initVal(v)%>;'
470- else
471- match type_
472- case T_INTEGER(__)
473- case T_REAL(__)
474- case T_ENUMERATION(__)
475- case T_BOOL(__) then '<%str%> = 0;'
476- case T_STRING(__) then '<%str%> = "";'
477- else 'UNKOWN_TYPE'
463+ '<%str%> = <%initValDefault(var)%>;'
478464end initValsDefault;
479465
480466template initParamsDefault(SimVar var, String arrayName) ::=
@@ -484,10 +470,29 @@ template initParamsDefault(SimVar var, String arrayName) ::=
484470 match initialValue
485471 case SOME(v as SCONST(__)) then
486472 '<%str%> = mmc_mk_scon(<%initVal(v)%>);'
487- case SOME(v) then
488- '<%str%> = <%initVal(v )%>;'
473+ else
474+ '<%str%> = <%initValDefault(var )%>;'
489475end initParamsDefault;
490476
477+ template initValDefault(SimVar var) ::=
478+ match var
479+ case var as SIMVAR(__) then
480+ match var.initialValue
481+ case SOME(v as ICONST(__))
482+ case SOME(v as RCONST(__))
483+ case SOME(v as SCONST(__))
484+ case SOME(v as BCONST(__))
485+ case SOME(v as ENUM_LITERAL(__)) then initVal(v)
486+ else
487+ match var.type_
488+ case T_INTEGER(__)
489+ case T_REAL(__)
490+ case T_ENUMERATION(__)
491+ case T_BOOL(__) then '0'
492+ case T_STRING(__) then '""'
493+ else error(sourceInfo(), 'Unknown type for initValDefault: <%unparseType(var.type_)%>')
494+ end initValDefault;
495+
491496template initVal(Exp initialValue)
492497::=
493498 match initialValue
@@ -496,7 +501,7 @@ template initVal(Exp initialValue)
496501 case SCONST(__) then '"<%Util.escapeModelicaStringToXmlString(string)%>"'
497502 case BCONST(__) then if bool then "1" else "0"
498503 case ENUM_LITERAL(__) then '<%index%>'
499- else "*ERROR* initial value of unknown type"
504+ else error(sourceInfo(), ' initial value of unknown type: <%printExpStr(initialValue)%>')
500505end initVal;
501506
502507template eventUpdateFunction(SimCode simCode)
0 commit comments