Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
fix for asserts during event iteration
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - #2114
  • Loading branch information
niklwors authored and OpenModelica-Hudson committed Jan 18, 2018
1 parent b1a437a commit e43fc8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 37 deletions.
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Core/SimController/SimManager.cpp
Expand Up @@ -489,7 +489,7 @@ void SimManager::runSingleProcess()
_writeFinalState = true;
_timeevent_system->computeTimeEventConditions(_tStart);
}
_cont_system->evaluateAll(IContinuous::CONTINUOUS); // vxworksupdate
// _cont_system->evaluateAll(IContinuous::CONTINUOUS); // vxworksupdate
_event_system->getZeroFunc(zeroVal_new);

for (int i = 0; i < _dimZeroFunc; i++)
Expand Down
57 changes: 21 additions & 36 deletions SimulationRuntime/cpp/Core/System/ContinuousEvents.cpp
Expand Up @@ -91,48 +91,33 @@ bool ContinuousEvents::startEventIteration(bool& state_vars_reinitialized)
//_event_system->getClockConditions(_clockconditions0);

//Handle all events
bool assert = false;
bool drestart = false;
bool crestart = false;
try
{

state_vars_reinitialized = _countinous_system->evaluateConditions();
state_vars_reinitialized = _countinous_system->evaluateConditions();


//check if discrete variables changed
bool drestart= _event_system->checkForDiscreteEvents(); //discrete time conditions
//check if discrete variables changed
drestart = _event_system->checkForDiscreteEvents(); //discrete time conditions

_event_system->getConditions(_conditions1);
//_event_system->getClockConditions(_clockconditions1);
bool crestart =false;
if (dim > 0)
{
LOGGER_WRITE_VECTOR("conditions", _conditions1, dim, LC_EVENTS, LL_DEBUG);
crestart = !std::equal(_conditions1, _conditions1 + dim, _conditions0);
_event_system->getConditions(_conditions1);
//_event_system->getClockConditions(_clockconditions1);

if (dim > 0)
{
LOGGER_WRITE_VECTOR("conditions", _conditions1, dim, LC_EVENTS, LL_DEBUG);
crestart = !std::equal(_conditions1, _conditions1 + dim, _conditions0);
}
}
//check for event clocks
/*bool eventclocksrestart = false;
if(dimClock>0)
catch (std::exception& ex)
{
eventclocksrestart = !std::equal (_clockconditions1, _clockconditions1+dimClock,_clockconditions0);
}
*/
return((drestart||crestart)); //returns true if new events occurred
}
/** @} */ // end of coreSystem
/*
bool ContinuousEvents::checkConditions(const bool* events, bool all)
{
IEvent* event_system= dynamic_cast<IEvent*>(_system);
int dim = event_system->getDimZeroFunc();
bool* conditions0 = new bool[dim];
bool* conditions1 = new bool[dim];
event_system->getConditions(conditions0);
for(int i=0;i<dim;i++)
{
if(all||events[i])
getCondition(i);
}
event_system->getConditions(conditions1);
return !std::equal (conditions1, conditions1+dim,conditions0);

// if evaluateConditions throws and error during event iteration the event iteration will restarted
assert = true;
}
return(drestart || crestart || assert); //returns true if new events occurred
}
*/

0 comments on commit e43fc8a

Please sign in to comment.