Skip to content

Commit

Permalink
refs #2: Legalize fmiTerminate calls in error state
Browse files Browse the repository at this point in the history
  • Loading branch information
beutlich committed Mar 22, 2021
1 parent ac2587a commit d580f0b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 3 deletions.
Binary file modified LastLib/Resources/Last.fmu
Binary file not shown.
Binary file modified LastLib/Resources/binaries/linux64/Last.so
Binary file not shown.
Binary file modified LastLib/Resources/binaries/win32/Last.dll
Binary file not shown.
Binary file modified LastLib/Resources/binaries/win64/Last.dll
Binary file not shown.
6 changes: 3 additions & 3 deletions LastLib/Resources/sources/fmuTemplate.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ static fmiBoolean invalidState(ModelInstance* comp, const char* f, int statesExp
comp->state = modelError;
comp->functions.logger(comp, comp->instanceName, fmiError, "error",
"%s: Illegal call sequence.", f);
if (comp->state < 1<<4) {
comp->functions.logger(comp, comp->instanceName, fmiError, "error",
if (comp->loggingOn && comp->state < 1<<4) {
comp->functions.logger(comp, comp->instanceName, fmiOK, "log",
"%s must not be called in FMU state %s. "
"Expected FMU state(s): %s.", f, stateNames[state], stateNames[statesExpected]);
}
Expand Down Expand Up @@ -187,7 +187,7 @@ static fmiStatus init(char* fname, fmiComponent c, fmiBoolean toleranceControlle
// fname is fmiTerminate or fmiTerminateSlave
static fmiStatus terminate(char* fname, fmiComponent c){
ModelInstance* comp = (ModelInstance *)c;
if (invalidState(comp, fname, modelInitialized))
if (invalidState(comp, fname, modelInitialized|modelError))
return fmiError;
if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", fname);
comp->state = modelTerminated;
Expand Down

0 comments on commit d580f0b

Please sign in to comment.