Skip to content

Commit

Permalink
Add "FMI" prefix to simulation files and functions (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer authored Jun 27, 2024
1 parent afd1d31 commit a210776
Show file tree
Hide file tree
Showing 20 changed files with 255 additions and 239 deletions.
31 changes: 16 additions & 15 deletions fmusim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,23 @@ set(sources
fmi1schema.h
fmi2schema.h
fmi3schema.h
fmusim.h
FMISimulation.h
FMISimulation.c
FMIStaticInput.h
FMIStaticInput.c
FMI1CSSimulation.h
FMI1CSSimulation.c
FMI1MESimulation.h
FMI1MESimulation.c
FMI2CSSimulation.h
FMI2CSSimulation.c
FMI2MESimulation.h
FMI2MESimulation.c
FMI3CSSimulation.h
FMI3CSSimulation.c
FMI3MESimulation.h
FMI3MESimulation.c
fmusim.c
fmusim_fmi1_cs.h
fmusim_fmi1_cs.c
fmusim_fmi1_me.h
fmusim_fmi1_me.c
fmusim_fmi2_cs.h
fmusim_fmi2_cs.c
fmusim_fmi2_me.h
fmusim_fmi2_me.c
fmusim_fmi3_cs.h
fmusim_fmi3_cs.c
fmusim_fmi3_me.h
fmusim_fmi3_me.c
fmusim_input.h
fmusim_input.c
miniunzip.c
${ZLIB_SRC_DIR}/contrib/minizip/ioapi.c
${ZLIB_SRC_DIR}/contrib/minizip/unzip.c
Expand Down
10 changes: 5 additions & 5 deletions fmusim/fmusim_fmi1_cs.c → fmusim/FMI1CSSimulation.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "fmusim_fmi1_cs.h"

#include "FMI1.h"
#include "FMI1CSSimulation.h"

#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)


FMIStatus simulateFMI1CS(
FMIStatus FMI1CSSimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* fmuLocation,
FMIRecorder* result,
const FMUStaticInput * input,
const FMIStaticInput * input,
const FMISimulationSettings * settings) {

FMIStatus status = FMIOK;
Expand All @@ -26,7 +26,7 @@ FMIStatus simulateFMI1CS(
));

// set start values
CALL(applyStartValues(S, settings));
CALL(FMIApplyStartValues(S, settings));
CALL(FMIApplyInput(S, input, settings->startTime, true, true, false));

// initialize
Expand Down
10 changes: 3 additions & 7 deletions fmusim/fmusim_fmi2_cs.h → fmusim/FMI1CSSimulation.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#pragma once

#include "FMI2.h"
#include "FMIModelDescription.h"
#include "FMIRecorder.h"
#include "fmusim_input.h"
#include "fmusim.h"
#include "FMISimulation.h"


FMIStatus simulateFMI2CS(
FMIStatus FMI1CSSimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* resourceURI,
FMIRecorder* result,
const FMUStaticInput* input,
const FMIStaticInput* input,
const FMISimulationSettings* settings);
9 changes: 5 additions & 4 deletions fmusim/fmusim_fmi1_me.c → fmusim/FMI1MESimulation.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#include <stdlib.h>
#include <math.h>

#include "fmusim_fmi1_me.h"
#include "FMI1.h"
#include "FMI1MESimulation.h"


#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)


FMIStatus simulateFMI1ME(
FMIStatus FMI1MESimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
FMIRecorder* result,
const FMUStaticInput * input,
const FMIStaticInput * input,
const FMISimulationSettings* settings) {

FMIStatus status = FMIOK;
Expand Down Expand Up @@ -48,7 +49,7 @@ FMIStatus simulateFMI1ME(
));

// set start values
CALL(applyStartValues(S, settings));
CALL(FMIApplyStartValues(S, settings));

CALL(FMIApplyInput(S, input, time,
true, // discrete
Expand Down
11 changes: 11 additions & 0 deletions fmusim/FMI1MESimulation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include "FMISimulation.h"


FMIStatus FMI1MESimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
FMIRecorder* result,
const FMIStaticInput* input,
const FMISimulationSettings* settings);
10 changes: 5 additions & 5 deletions fmusim/fmusim_fmi2_cs.c → fmusim/FMI2CSSimulation.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "FMIUtil.h"

#include "fmusim_fmi2_cs.h"
#include "FMI2.h"
#include "FMI2CSSimulation.h"


#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)


FMIStatus simulateFMI2CS(
FMIStatus FMI2CSSimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* resourceURI,
FMIRecorder* result,
const FMUStaticInput * input,
const FMIStaticInput * input,
const FMISimulationSettings * settings) {

FMIStatus status = FMIOK;
Expand All @@ -28,7 +28,7 @@ FMIStatus simulateFMI2CS(
CALL(FMIRestoreFMUStateFromFile(S, settings->initialFMUStateFile));
}

CALL(applyStartValues(S, settings));
CALL(FMIApplyStartValues(S, settings));

if (!settings->initialFMUStateFile) {
CALL(FMI2SetupExperiment(S, settings->tolerance > 0, settings->tolerance, settings->startTime, fmi2False, 0));
Expand Down
10 changes: 3 additions & 7 deletions fmusim/fmusim_fmi1_cs.h → fmusim/FMI2CSSimulation.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#pragma once

#include "FMI1.h"
#include "FMIModelDescription.h"
#include "FMIRecorder.h"
#include "fmusim_input.h"
#include "fmusim.h"
#include "FMISimulation.h"


FMIStatus simulateFMI1CS(
FMIStatus FMI2CSSimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* resourceURI,
FMIRecorder* result,
const FMUStaticInput* input,
const FMIStaticInput* input,
const FMISimulationSettings* settings);
10 changes: 5 additions & 5 deletions fmusim/fmusim_fmi2_me.c → fmusim/FMI2MESimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
#include <math.h>

#include "FMIUtil.h"

#include "fmusim_fmi2_me.h"
#include "FMI2.h"
#include "FMI2MESimulation.h"


#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)


FMIStatus simulateFMI2ME(
FMIStatus FMI2MESimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* resourceURI,
FMIRecorder* result,
const FMUStaticInput * input,
const FMIStaticInput * input,
const FMISimulationSettings* settings) {

const bool needsCompletedIntegratorStep = modelDescription->modelExchange->needsCompletedIntegratorStep;
Expand Down Expand Up @@ -60,7 +60,7 @@ FMIStatus simulateFMI2ME(
CALL(FMIRestoreFMUStateFromFile(S, settings->initialFMUStateFile));
}

CALL(applyStartValues(S, settings));
CALL(FMIApplyStartValues(S, settings));

if (!settings->initialFMUStateFile) {

Expand Down
10 changes: 3 additions & 7 deletions fmusim/fmusim_fmi2_me.h → fmusim/FMI2MESimulation.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#pragma once

#include "FMI2.h"
#include "FMIModelDescription.h"
#include "FMIRecorder.h"
#include "fmusim_input.h"
#include "fmusim.h"
#include "FMISimulation.h"


FMIStatus simulateFMI2ME(
FMIStatus FMI2MESimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* resourceURI,
FMIRecorder* result,
const FMUStaticInput* input,
const FMIStaticInput* input,
const FMISimulationSettings* settings);
10 changes: 5 additions & 5 deletions fmusim/fmusim_fmi3_cs.c → fmusim/FMI3CSSimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <math.h>

#include "FMIUtil.h"

#include "fmusim_fmi3_cs.h"
#include "FMI3.h"
#include "FMI3CSSimulation.h"


#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)
Expand All @@ -30,11 +30,11 @@ static void recordIntermediateValues(
*earlyReturnRequested = fmi3False;
}

FMIStatus simulateFMI3CS(FMIInstance* S,
FMIStatus FMI3CSSimulate(FMIInstance* S,
const FMIModelDescription * modelDescription,
const char* resourcePath,
FMIRecorder* recorder,
const FMUStaticInput * input,
const FMIStaticInput * input,
const FMISimulationSettings * settings) {

FMIStatus status = FMIOK;
Expand Down Expand Up @@ -92,7 +92,7 @@ FMIStatus simulateFMI3CS(FMIInstance* S,
CALL(FMIRestoreFMUStateFromFile(S, settings->initialFMUStateFile));
}

CALL(applyStartValues(S, settings));
CALL(FMIApplyStartValues(S, settings));

if (!settings->initialFMUStateFile) {

Expand Down
10 changes: 3 additions & 7 deletions fmusim/fmusim_fmi3_cs.h → fmusim/FMI3CSSimulation.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#pragma once

#include "FMI3.h"
#include "FMIModelDescription.h"
#include "FMIRecorder.h"
#include "fmusim_input.h"
#include "fmusim.h"
#include "FMISimulation.h"


FMIStatus simulateFMI3CS(
FMIStatus FMI3CSSimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* resourcePath,
FMIRecorder* result,
const FMUStaticInput* input,
const FMIStaticInput* input,
const FMISimulationSettings* settings);
10 changes: 5 additions & 5 deletions fmusim/fmusim_fmi3_me.c → fmusim/FMI3MESimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
#include <math.h>

#include "FMIUtil.h"

#include "fmusim_fmi3_me.h"
#include "FMI3.h"
#include "FMI3MESimulation.h"


#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)


FMIStatus simulateFMI3ME(
FMIStatus FMI3MESimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* resourcePath,
FMIRecorder* result,
const FMUStaticInput * input,
const FMIStaticInput * input,
const FMISimulationSettings * settings) {

const bool needsCompletedIntegratorStep = modelDescription->modelExchange->needsCompletedIntegratorStep;
Expand Down Expand Up @@ -58,7 +58,7 @@ FMIStatus simulateFMI3ME(
CALL(FMIRestoreFMUStateFromFile(S, settings->initialFMUStateFile));
}

CALL(applyStartValues(S, settings));
CALL(FMIApplyStartValues(S, settings));

if (!settings->initialFMUStateFile) {

Expand Down
10 changes: 3 additions & 7 deletions fmusim/fmusim_fmi3_me.h → fmusim/FMI3MESimulation.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#pragma once

#include "FMI3.h"
#include "FMIModelDescription.h"
#include "FMIRecorder.h"
#include "fmusim_input.h"
#include "fmusim.h"
#include "FMISimulation.h"


FMIStatus simulateFMI3ME(
FMIStatus FMI3MESimulate(
FMIInstance* S,
const FMIModelDescription* modelDescription,
const char* resourcePath,
FMIRecorder* result,
const FMUStaticInput* input,
const FMIStaticInput* input,
const FMISimulationSettings* settings);
2 changes: 2 additions & 0 deletions fmusim/FMIModelDescription.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,8 @@ FMIDisplayUnit* FMIDisplayUnitForName(const FMIUnit* unit, const char* name) {
return displayUnit;
}
}

return NULL;
}

FMITypeDefinition* FMITypeDefintionForName(const FMIModelDescription* modelDescription, const char* name) {
Expand Down
Loading

0 comments on commit a210776

Please sign in to comment.