Skip to content

Commit

Permalink
Remove modelError and modelFatal states (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer authored Nov 26, 2023
1 parent 6e6e05a commit df926b8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
4 changes: 0 additions & 4 deletions include/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ typedef enum {
StepCanceled = 1<<8,

Terminated = 1<<9,
modelError = 1<<10,
modelFatal = 1<<11,
} ModelState;

#else
Expand All @@ -60,8 +58,6 @@ typedef enum {
ReconfigurationMode = 1 << 9,
IntermediateUpdateMode = 1 << 10,
Terminated = 1 << 11,
modelError = 1 << 12,
modelFatal = 1 << 13,
} ModelState;

#endif
Expand Down
4 changes: 2 additions & 2 deletions src/cosimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Status reset(ModelInstance* comp) {
bool invalidNumber(ModelInstance *comp, const char *f, const char *arg, size_t actual, size_t expected) {

if (actual != expected) {
comp->state = modelError;
comp->state = Terminated;
logError(comp, "%s: Invalid argument %s = %d. Expected %d.", f, arg, actual, expected);
return true;
}
Expand Down Expand Up @@ -221,7 +221,7 @@ bool invalidState(ModelInstance *comp, const char *f, int statesExpected) {
bool nullPointer(ModelInstance* comp, const char *f, const char *arg, const void *p) {

if (!p) {
comp->state = modelError;
comp->state = Terminated;
logError(comp, "%s: Invalid argument %s = NULL.", f, arg);
return true;
}
Expand Down
22 changes: 11 additions & 11 deletions src/fmi2Functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
do { \
if (!p) { \
logError(S, "Argument %s must not be NULL.", xstr(p)); \
S->state = modelError; \
S->state = Terminated; \
return (fmi2Status)Error; \
} \
} while (0)
Expand Down Expand Up @@ -109,17 +109,17 @@ do { \
#define MASK_fmi2GetTypesPlatform (StartAndEnd | Instantiated | InitializationMode \
| EventMode | ContinuousTimeMode \
| StepComplete | StepInProgress | StepFailed | StepCanceled \
| Terminated | modelError)
| Terminated)
#define MASK_fmi2GetVersion MASK_fmi2GetTypesPlatform
#define MASK_fmi2SetDebugLogging (Instantiated | InitializationMode \
| EventMode | ContinuousTimeMode \
| StepComplete | StepInProgress | StepFailed | StepCanceled \
| Terminated | modelError)
| Terminated)
#define MASK_fmi2Instantiate (StartAndEnd)
#define MASK_fmi2FreeInstance (Instantiated | InitializationMode \
| EventMode | ContinuousTimeMode \
| StepComplete | StepFailed | StepCanceled \
| Terminated | modelError)
| Terminated)
#define MASK_fmi2SetupExperiment Instantiated
#define MASK_fmi2EnterInitializationMode Instantiated
#define MASK_fmi2ExitInitializationMode InitializationMode
Expand All @@ -129,7 +129,7 @@ do { \
#define MASK_fmi2GetReal (InitializationMode \
| EventMode | ContinuousTimeMode \
| StepComplete | StepFailed | StepCanceled \
| Terminated | modelError)
| Terminated)
#define MASK_fmi2GetInteger MASK_fmi2GetReal
#define MASK_fmi2GetBoolean MASK_fmi2GetReal
#define MASK_fmi2GetString MASK_fmi2GetReal
Expand All @@ -150,7 +150,7 @@ do { \
#define MASK_fmi2GetDirectionalDerivative (InitializationMode \
| EventMode | ContinuousTimeMode \
| StepComplete | StepFailed | StepCanceled \
| Terminated | modelError)
| Terminated)

// ---------------------------------------------------------------------------
// Function calls allowed state masks for Model-exchange
Expand All @@ -163,13 +163,13 @@ do { \
#define MASK_fmi2SetContinuousStates ContinuousTimeMode
#define MASK_fmi2GetEventIndicators (InitializationMode \
| EventMode | ContinuousTimeMode \
| Terminated | modelError)
| Terminated)
#define MASK_fmi2GetContinuousStates MASK_fmi2GetEventIndicators
#define MASK_fmi2GetDerivatives (EventMode | ContinuousTimeMode \
| Terminated | modelError)
| Terminated)
#define MASK_fmi2GetNominalsOfContinuousStates ( Instantiated \
| EventMode | ContinuousTimeMode \
| Terminated | modelError)
| Terminated)

// ---------------------------------------------------------------------------
// Function calls allowed state masks for Co-simulation
Expand Down Expand Up @@ -626,14 +626,14 @@ fmi2Status fmi2DoStep(fmi2Component c, fmi2Real currentCommunicationPoint,

if (communicationStepSize <= 0) {
logError(S, "Communication step size must be > 0 but was %g.", communicationStepSize);
S->state = modelError;
S->state = Terminated;
return fmi2Error;
}

if (currentCommunicationPoint + communicationStepSize > S->stopTime + EPSILON) {
logError(S, "At communication point %.16g a step size of %.16g was requested but stop time is %.16g.",
currentCommunicationPoint, communicationStepSize, S->stopTime);
S->state = modelError;
S->state = Terminated;
return fmi2Error;
}

Expand Down
4 changes: 2 additions & 2 deletions src/fmi3Functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
do { \
if (!p) { \
logError(S, "Argument %s must not be NULL.", xstr(p)); \
S->state = modelError; \
S->state = Terminated; \
return (fmi3Status)Error; \
} \
} while (0)
Expand Down Expand Up @@ -204,7 +204,7 @@ TERMINATE: \

#define MASK_fmi3EnterStepMode (InitializationMode | EventMode)
#define MASK_fmi3SetInputDerivatives (Instantiated | InitializationMode | StepMode)
#define MASK_fmi3GetOutputDerivatives (StepMode | StepDiscarded | Terminated | modelError)
#define MASK_fmi3GetOutputDerivatives (StepMode | StepDiscarded | Terminated)
#define MASK_fmi3DoStep StepMode
#define MASK_fmi3ActivateModelPartition ClockActivationMode
#define MASK_fmi3DoEarlyReturn IntermediateUpdateMode
Expand Down

0 comments on commit df926b8

Please sign in to comment.