Skip to content

Commit

Permalink
Added get and set method for conditions vector in IEvent interface
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11182 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Feb 23, 2012
1 parent dca4dc4 commit 3c2a60b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
29 changes: 29 additions & 0 deletions Compiler/susan_codegen/SimCode/CodegenCpp.tpl
Expand Up @@ -221,6 +221,8 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
<%DefaultImplementationCode(simCode)%>
<%checkForDiscreteEvents(discreteModelVars,simCode)%>
<%giveZeroFunc1(zeroCrossings,simCode)%>
<%giveConditions(simCode)%>
<%setConditions(simCode)%>
<%isODE(simCode)%>
<%DimZeroFunc(simCode)%>
<%DimInitEquations(simCode)%>
Expand Down Expand Up @@ -2073,6 +2075,8 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
virtual int getDimZeroFunc();
//Provides current values of root/zero functions
virtual void giveZeroFunc(double* f,const double& eps);
virtual void giveConditions(bool* c);
virtual void setConditions(bool* c);
//Called to check conditions for event-handling
virtual void checkConditions(unsigned int, bool all);
//Called to handle all events occured at same time
Expand Down Expand Up @@ -5795,6 +5799,31 @@ template giveZeroFunc1(list<ZeroCrossing> zeroCrossings,SimCode simCode)
>>
end giveZeroFunc1;


template giveConditions(SimCode simCode)
::=
match simCode
case SIMCODE(modelInfo = MODELINFO(__)) then
<<
void <%lastIdentOfPath(modelInfo.name)%>::giveConditions(bool* c)
{
memcpy(c,_conditions0,_dimZeroFunc*sizeof(bool));
}
>>
end giveConditions;

template setConditions(SimCode simCode)
::=
match simCode
case SIMCODE(modelInfo = MODELINFO(__)) then
<<
void <%lastIdentOfPath(modelInfo.name)%>::setConditions(bool* c)
{
memcpy(_conditions0,c,_dimZeroFunc*sizeof(bool));
}
>>
end setConditions;

template giveZeroFunc2(list<ZeroCrossing> zeroCrossings, Text &varDecls /*BUFP*/,SimCode simCode)
::=

Expand Down
Expand Up @@ -15,7 +15,7 @@ install (FILES ../Interfaces/IAlgLoop.h
../Interfaces/IDataExchange.h
../Interfaces/IEvent.h
../Interfaces/ISystemProperties.h
../Interfaces/ISystemIntialization.h
../Interfaces/ISystemInitialization.h
DESTINATION include/omc/cpp/System/Interfaces)


Expand Down
3 changes: 2 additions & 1 deletion SimulationRuntime/cpp/Source/System/Interfaces/IEvent.h
Expand Up @@ -29,7 +29,8 @@ class IEvent

/// Provides current values of root/zero functions
virtual void giveZeroFunc(double* f,const double& eps) = 0;

virtual void giveConditions(bool* c) = 0;
virtual void setConditions(bool* c) = 0;
//Saves all variables before an event is handled, is needed for the pre, edge and change operator
virtual void saveAll() = 0;
/// Called to handle all events occured at same time
Expand Down

0 comments on commit 3c2a60b

Please sign in to comment.