Skip to content

Commit

Permalink
Update the code gen for the updated interface.
Browse files Browse the repository at this point in the history
  - We now use a global model variable in the C code.
  - Pass this globalb variable to the C interface functions.
    Basically acts as the 'this' argument for the C++ counterparts
    of the functions.
  • Loading branch information
mahge committed May 20, 2020
1 parent 3479645 commit 7d0a626
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions OMCompiler/Compiler/Template/CodegenC.tpl
Expand Up @@ -1036,7 +1036,14 @@ template simulationFile(SimCode simCode, String guid, String isModelExchangeFMU)
MMC_INIT(0);
omc_alloc_interface.init();
>>
let pminit = if Flags.getConfigBool(Flags.PARMODAUTO) then 'PM_Model_init("<%fileNamePrefix%>", &data, threadData, functionODE_systems);' else ''
let pminit = if Flags.getConfigBool(Flags.PARMODAUTO) then
<<

pm_model = PM_Model_create("<%fileNamePrefix%>", &data, threadData);
PM_Model_load_ODE_system(pm_model, functionODE_systems);

>>
else ''
let mainBody =
<<
<%symbolName(modelNamePrefixStr,"setupDataStruc")%>(&data, threadData);
Expand Down Expand Up @@ -1064,6 +1071,12 @@ template simulationFile(SimCode simCode, String guid, String isModelExchangeFMU)
>>
%>
<% if Flags.getConfigBool(Flags.PARMODAUTO) then
<<
void* pm_model = NULL;
>>
%>
/* dummy VARINFO and FILEINFO */
const FILE_INFO dummyFILE_INFO = omc_dummyFileInfo;
const VAR_INFO dummyVAR_INFO = omc_dummyVarInfo;
Expand Down Expand Up @@ -1191,7 +1204,7 @@ template simulationFile(SimCode simCode, String guid, String isModelExchangeFMU)
<%mainTop(mainBody,"https://trac.openmodelica.org/OpenModelica/newticket")%>
<%if Flags.isSet(HPCOM) then "terminateHpcOmThreads();" %>
<%if Flags.getConfigBool(Flags.PARMODAUTO) then "dump_times();" %>
<%if Flags.getConfigBool(Flags.PARMODAUTO) then "dump_times(pm_model);" %>
fflush(NULL);
EXIT(res);
return res;
Expand Down Expand Up @@ -4040,7 +4053,7 @@ template functionODE(list<list<SimEqSystem>> derivativEquations, Text method, Op
data->simulationInfo->callStatistics.functionODE++;
<%symbolName(modelNamePrefix,"functionLocalKnownVars")%>(data, threadData);
<%if Flags.getConfigBool(Flags.PARMODAUTO) then 'PM_functionODE(<%nrfuncs%>, data, threadData, functionODE_systems);'
<%if Flags.getConfigBool(Flags.PARMODAUTO) then 'PM_evaluate_ODE_system(pm_model);'
else fncalls %>
#if !defined(OMC_MINIMAL_RUNTIME)
Expand Down

0 comments on commit 7d0a626

Please sign in to comment.