Skip to content

Commit

Permalink
added terminate function to cpp tempalte
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22400 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Sep 22, 2014
1 parent 6795340 commit 991c2be
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 67 deletions.
142 changes: 80 additions & 62 deletions Compiler/Template/CodegenCpp.tpl

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion SimulationRuntime/cpp/Core/Modelica/ModelicaSystem.cpp
Expand Up @@ -188,8 +188,9 @@ bool Modelica::checkForDiscreteEvents()

return restart;
}
void Modelica::stepCompleted(double time)
bool Modelica::stepCompleted(double time)
{
throw std::runtime_error("stepCompleted is not yet implemented");
}
bool Modelica::checkConditions()
{
Expand Down
Expand Up @@ -48,6 +48,7 @@ SystemDefaultImplementation::SystemDefaultImplementation(IGlobalSettings *global
,_delay_max(0.0)
,_start_time(0.0)
,_terminal(false)
,_terminate(false)
,_global_settings(globalSettings)
{
}
Expand Down Expand Up @@ -153,6 +154,7 @@ void SystemDefaultImplementation::initialize()
}
_start_time =0.0;
_terminal =false;
_terminate =false;
};


Expand Down
Expand Up @@ -132,7 +132,7 @@ class Modelica: public IMixedSystem ,public IContinuous ,public IEvent ,public I
// System is able to provide the Jacobian symbolically
virtual bool provideSymbolicJacobian() ;
virtual void saveDiscreteVars();
virtual void stepCompleted(double time);
virtual bool stepCompleted(double time);
private:

//Methods:
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Include/Core/System/IContinuous.h
Expand Up @@ -106,7 +106,7 @@ class IContinuous
virtual void evaluateZeroFuncs(const UPDATETYPE command = UNDEF_UPDATE)= 0;
virtual bool evaluateConditions(const UPDATETYPE command = UNDEF_UPDATE)= 0;

virtual void stepCompleted(double time) = 0;
virtual bool stepCompleted(double time) = 0;

};

Expand Down
Expand Up @@ -167,6 +167,8 @@ class BOOST_EXTENSION_SYSTEM_DECL SystemDefaultImplementation

bool _initial;
bool _terminal;
bool _terminate;

//SValuesMap _start_values;
InitVars<double> _real_start_values;
InitVars<int> _int_start_values;
Expand Down
6 changes: 4 additions & 2 deletions SimulationRuntime/cpp/Solver/CVode/CVode.cpp
Expand Up @@ -351,8 +351,10 @@ void Cvode::CVodeCore()
// -> Write output if true
if (writeOutput)
writeCVodeOutput(_tCurrent, _h, _locStps);

_continuous_system->stepCompleted(_tCurrent);

//set completed step to system and check if terminate was called
if(_continuous_system->stepCompleted(_tCurrent))
_solverStatus = DONE;

// Perform state selection
bool state_selection = stateSelection();
Expand Down

0 comments on commit 991c2be

Please sign in to comment.