Skip to content

Commit

Permalink
fix for save pre varibales in cpp runtime
Browse files Browse the repository at this point in the history
fix for typo

extended save operation for extra save value

Belonging to [master]:
  - OpenModelica/OMCompiler#2112
  • Loading branch information
niklwors authored and OpenModelica-Hudson committed Jan 17, 2018
1 parent 96f7d96 commit b1a437a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
12 changes: 6 additions & 6 deletions Compiler/Template/CodegenCpp.tpl
Expand Up @@ -6472,7 +6472,7 @@ case SES_NONLINEAR(nlSystem = nls as NONLINEARSYSTEM(__)) then
let varname = '_system-><%cref(componentRef, useFlatArrayNotation)%>'
<<
<%varname%> = vars[<%i0%>];
_discrete_events->save(<%varname%>);
_discrete_events->save(<%varname%>,<%varname%>);
>>
else
<<
Expand Down Expand Up @@ -11275,10 +11275,10 @@ case SES_SIMPLE_ASSIGN(__) then

match cref
case CREF_QUAL(ident = "$PRE") then
let sysderef = match context case ALGLOOP_CONTEXT(__) then '_system->'
<<
//<%cref(componentRef, useFlatArrayNotation)%> = <%expPart%>;
//_discrete_events->save( <%cref(componentRef, useFlatArrayNotation)%>);
_discrete_events->pre(<%cref(componentRef, useFlatArrayNotation)%>)=<%expPart%>;
_discrete_events->save(<%sysderef%><%cref(componentRef, useFlatArrayNotation)%>,<%expPart%>);
//_discrete_events->pre(<%cref(componentRef, useFlatArrayNotation)%>)=<%expPart%>;
>>
else
match exp
Expand Down Expand Up @@ -12343,7 +12343,7 @@ template saveconditionvar1(Integer index1, Exp relation,SimCode simCode ,Text& e
match relation
case RELATION(index=zerocrossingIndex) then
<<
_discrete_events->save(_condition<%zerocrossingIndex%>);
_discrete_events->save(_condition<%zerocrossingIndex%>,_condition<%zerocrossingIndex%>);
>>
end saveconditionvar1;

Expand Down Expand Up @@ -13390,7 +13390,7 @@ template algStmtReinit(DAE.Statement stmt, Context context, Text &varDecls /*BUF
>>
*/
<<
_discrete_events->save(<%expPart1%>);
_discrete_events->save(<%expPart1%>,<%expPart1%>);
<%preExp%>
<%expPart1%> = <%expPart2%>;
>>
Expand Down
3 changes: 3 additions & 0 deletions SimulationRuntime/cpp/.vs/ProjectSettings.json
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
9 changes: 9 additions & 0 deletions SimulationRuntime/cpp/.vs/VSWorkspaceState.json
@@ -0,0 +1,9 @@
{
"ExpandedNodes": [
"",
"\\Core",
"\\Core\\SimController"
],
"SelectedNode": "\\Core\\SimController\\Configuration.cpp",
"PreviewInSolutionExplorer": false
}
Binary file added SimulationRuntime/cpp/.vs/cpp/v15/.suo
Binary file not shown.
Binary file added SimulationRuntime/cpp/.vs/slnx.sqlite
Binary file not shown.
12 changes: 6 additions & 6 deletions SimulationRuntime/cpp/Core/System/DiscreteEvents.cpp
Expand Up @@ -40,25 +40,25 @@ void DiscreteEvents::savePreVars(double vars[], unsigned int n)
/**
Saves a variable in _sim_vars->_pre_real_vars vector
*/
void DiscreteEvents::save(double& var)
void DiscreteEvents::save(double& var,double value)
{
_sim_vars->getPreVar(var) = var;
_sim_vars->getPreVar(var) = value;
}

/**
Saves a variable in _sim_vars->_pre_int_vars vector
*/
void DiscreteEvents::save(int& var)
void DiscreteEvents::save(int& var,double value)
{
_sim_vars->getPreVar(var) = var;
_sim_vars->getPreVar(var) = value;
}

/**
Saves a variable in _sim_vars->_pre_bool_vars vector
*/
void DiscreteEvents::save(bool& var)
void DiscreteEvents::save(bool& var,double value)
{
_sim_vars->getPreVar(var) = var;
_sim_vars->getPreVar(var) = value;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions SimulationRuntime/cpp/Include/Core/System/DiscreteEvents.h
Expand Up @@ -18,9 +18,9 @@ class BOOST_EXTENSION_EVENTHANDLING_DECL DiscreteEvents


//saves a variable in _pre_vars vector
void save(double& var);
void save(int& var);
void save(bool& var);
void save(double& var,double value);
void save(int& var,double value);
void save(bool& var,double value);
//void savePreVars(double vars [], unsigned int n);


Expand Down

0 comments on commit b1a437a

Please sign in to comment.