Skip to content

Commit

Permalink
- Fixed fmiNewDiscreteStates function.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21071 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Jun 12, 2014
1 parent c571ce2 commit 510ae97
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions SimulationRuntime/fmi/export/fmi2/fmu2_model_interface.c
Expand Up @@ -120,8 +120,7 @@ fmiStatus fmiEventUpdate(fmiComponent c, fmiEventInfo* eventInfo)
{
int i;
ModelInstance* comp = (ModelInstance *)c;
if (invalidState(comp, "fmiEventUpdate", modelInitializationMode))
return fmiError;

if (nullPointer(comp, "fmiEventUpdate", "eventInfo", eventInfo))
return fmiError;
eventInfo->valuesOfContinuousStatesChanged = fmiFalse;
Expand Down Expand Up @@ -397,9 +396,9 @@ fmiStatus fmiEnterInitializationMode(fmiComponent c) {
/* Get next event time (sample calls)*/
double nextSampleEvent = 0;
nextSampleEvent = getNextSampleTimeFMU(comp->fmuData);
if (nextSampleEvent == -1){
if (nextSampleEvent == -1) {
comp->eventInfo.nextEventTimeDefined = fmiFalse;
}else{
} else {
comp->eventInfo.nextEventTimeDefined = fmiTrue;
comp->eventInfo.nextEventTime = nextSampleEvent;
fmiEventUpdate(comp, &(comp->eventInfo));
Expand Down Expand Up @@ -678,16 +677,29 @@ fmiStatus fmiNewDiscreteStates(fmiComponent c, fmiEventInfo* eventInfo) {
return fmiError;
FILTERED_LOG(comp, fmiOK, LOG_FMI_CALL, "fmiNewDiscreteStates")

eventInfo->newDiscreteStatesNeeded = fmiFalse;
eventInfo->terminateSimulation = fmiFalse;
eventInfo->nominalsOfContinuousStatesChanged = fmiFalse;
eventInfo->valuesOfContinuousStatesChanged = fmiFalse;
eventInfo->nextEventTimeDefined = fmiFalse;
eventInfo->nextEventTime = 0;

/* Get next event time (sample calls)*/
double nextSampleEvent = 0;
nextSampleEvent = getNextSampleTimeFMU(comp->fmuData);
if (nextSampleEvent == -1){
comp->eventInfo.nextEventTimeDefined = fmiFalse;
}else{
comp->eventInfo.nextEventTimeDefined = fmiTrue;
comp->eventInfo.nextEventTime = nextSampleEvent;
if (nextSampleEvent == -1) {
eventInfo->nextEventTimeDefined = fmiFalse;
} else {
eventInfo->nextEventTimeDefined = fmiTrue;
eventInfo->nextEventTime = nextSampleEvent;
fmiEventUpdate(comp, eventInfo);
}

// set the state
if (eventInfo->newDiscreteStatesNeeded) {
comp->state = modelContinuousTimeMode;
}

return fmiOK;
}

Expand Down

0 comments on commit 510ae97

Please sign in to comment.