Skip to content

Commit

Permalink
adapt FMI2 to new SimVars
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25500 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
rfranke committed Apr 10, 2015
1 parent d9e3df5 commit 9fdfa27
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
24 changes: 18 additions & 6 deletions Compiler/Template/CodegenFMUCpp.tpl
Expand Up @@ -86,7 +86,7 @@ case SIMCODE(modelInfo=MODELINFO(__),simulationSettingsOpt = SOME(settings as SI
// Dummy code for FMU that writes no output file
class <%lastIdentOfPath(modelInfo.name)%>WriteOutput {
public:
<%lastIdentOfPath(modelInfo.name)%>WriteOutput(IGlobalSettings* globalSettings, boost::shared_ptr<IAlgLoopSolverFactory> nonLinSolverFactory, boost::shared_ptr<ISimData> simData) {}
<%lastIdentOfPath(modelInfo.name)%>WriteOutput(IGlobalSettings* globalSettings, boost::shared_ptr<IAlgLoopSolverFactory> nonLinSolverFactory, boost::shared_ptr<ISimData> simData, boost::shared_ptr<ISimVars> simVars) {}
virtual ~<%lastIdentOfPath(modelInfo.name)%>WriteOutput() {}

virtual void writeOutput(const IWriteOutput::OUTPUT command = IWriteOutput::UNDEF_OUTPUT) {}
Expand Down Expand Up @@ -174,10 +174,14 @@ case SIMCODE(modelInfo=MODELINFO(__)) then

class <%modelIdentifier%>FMU: public <%modelIdentifier%>Extension {
public:
// create simulation variables
static ISimVars *createSimVars();
// constructor
<%modelIdentifier%>FMU(IGlobalSettings* globalSettings,
boost::shared_ptr<IAlgLoopSolverFactory> nonLinSolverFactory,
boost::shared_ptr<ISimData> simData);
boost::shared_ptr<ISimData> simData,
boost::shared_ptr<ISimVars> simVars);
// initialization
virtual void initialize();
Expand Down Expand Up @@ -235,13 +239,21 @@ case SIMCODE(modelInfo=MODELINFO(__)) then
else
'#include "FMU/FMULibInterface.cpp"'%>

// create simulation variables
#include <System/FactoryExport.h>
#include <System/SimVars.h>

ISimVars *<%modelIdentifier%>FMU::createSimVars() {
return new SimVars(<%numRealvars(modelInfo)%>, <%numIntvars(modelInfo)%>, <%numBoolvars(modelInfo)%>, <%getPreVarsCount(simCode)%>, <%numStatevars(modelInfo)%>, <%numStateVarIndex(modelInfo)%>);
}

// constructor
<%modelIdentifier%>FMU::<%modelIdentifier%>FMU(IGlobalSettings* globalSettings,
boost::shared_ptr<IAlgLoopSolverFactory> nonLinSolverFactory,
boost::shared_ptr<ISimData> simData):
PreVariables(<%getPreVarsCount(simCode)%>),
<%modelIdentifier%>(globalSettings, nonLinSolverFactory, simData),
<%modelIdentifier%>Extension(globalSettings, nonLinSolverFactory, simData) {
boost::shared_ptr<ISimData> simData,
boost::shared_ptr<ISimVars> simVars):
<%modelIdentifier%>(globalSettings, nonLinSolverFactory, simData, simVars),
<%modelIdentifier%>Extension(globalSettings, nonLinSolverFactory, simData, simVars) {
}

// initialization
Expand Down
2 changes: 2 additions & 0 deletions SimulationRuntime/cpp/Core/System/CMakeLists.txt
Expand Up @@ -45,6 +45,8 @@ install (FILES
${CMAKE_SOURCE_DIR}/Include/Core/System/PreVariables.h
${CMAKE_SOURCE_DIR}/Include/Core/System/DiscreteEvents.h
${CMAKE_SOURCE_DIR}/Include/Core/System/ContinuousEvents.h
${CMAKE_SOURCE_DIR}/Include/Core/System/SimVars.h
${CMAKE_SOURCE_DIR}/Core/System/FactoryExport.h
DESTINATION include/omc/cpp/Core/System)
install (FILES
${CMAKE_SOURCE_DIR}/Include/Core/System/IAlgLoop.h
Expand Down
3 changes: 2 additions & 1 deletion SimulationRuntime/cpp/Include/FMU2/FMU2Wrapper.cpp
Expand Up @@ -75,7 +75,8 @@ FMU2Wrapper::FMU2Wrapper(fmi2String instanceName, fmi2String GUID,
PATH(""), PATH("")));
_model = boost::shared_ptr<MODEL_CLASS>
(new MODEL_CLASS(&_global_settings, solver_factory,
boost::shared_ptr<ISimData>(new SimData())));
boost::shared_ptr<ISimData>(new SimData()),
boost::shared_ptr<ISimVars>(MODEL_CLASS::createSimVars())));
_model->initialize();
_string_buffer.resize(_model->getDimString());
}
Expand Down

0 comments on commit 9fdfa27

Please sign in to comment.