Skip to content

Commit

Permalink
Cleaning up unused arguments from fmi3_import_x calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Meisrimel authored and Peter Meisrimel committed Sep 4, 2024
1 parent efdff72 commit 705875f
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 89 deletions.
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ The release notes are typically a highlighting subset of all changes made. For f

Note that version 2.1 is the first version with release notes. Please see the commit history for older versions.

## Future

### Changes

- [BREAKING] Removed unused `instanceEnvironment` and `logMessage` inputs from `fmi3_import_instantiate_*` functions.
- The corresponding CAPI calls use `instanceEnvironment` and `logMessage` from `fmi3_import_create_dllfmu`.

## 3.0a4

### Improvements
Expand Down
15 changes: 1 addition & 14 deletions Test/FMI3/fmi3_capi_basic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@

#include "catch.hpp"

void dummy_log_message_callback(
fmi3_instance_environment_t* env,
fmi3_status_t status,
fmi3_string_t category,
fmi3_string_t message) {
/* Empty by design */
}
void dummy_clock_update_callback(fmi3_instance_environment_t* env) { /* Empty by design */}
void dummy_lock_preemption_callback() { /* Empty by design */}
void dummy_unlock_preemption_callback() { /* Empty by design */}
Expand Down Expand Up @@ -123,9 +116,7 @@ TEST_CASE("Test CAPI methods using a Model Exchange FMU", test_file_name)
instanceName,
resourcePath,
visible,
loggingOn,
((fmi3_instance_environment_t)&instance_env),
(fmi3_log_message_callback_ft)dummy_log_message_callback
loggingOn
);

test_int_get_set(fmu, instantiate_status);
Expand Down Expand Up @@ -183,8 +174,6 @@ TEST_CASE("Test CAPI methods using a Co-Simulation FMU", test_file_name)
earlyReturnAllowed,
requiredIntermediateVariables,
nRequiredIntermediateVariables,
NULL,
NULL,
NULL
);

Expand Down Expand Up @@ -236,8 +225,6 @@ TEST_CASE("Test CAPI methods using a Scheduled-Execution FMU", test_file_name)
resourcePath,
visible,
loggingOn,
((fmi3_instance_environment_t)&instance_env),
(fmi3_log_message_callback_ft)dummy_log_message_callback,
(fmi3_clock_update_callback_ft)dummy_clock_update_callback,
(fmi3_lock_preemption_callback_ft)dummy_lock_preemption_callback,
(fmi3_unlock_preemption_callback_ft)dummy_unlock_preemption_callback
Expand Down
2 changes: 0 additions & 2 deletions Test/FMI3/fmi3_import_sim_cs_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ void test_simulate_cs(fmi3_import_t* fmu) {
earlyReturnAllowed,
requiredIntermediateVariables,
nRequiredIntermediateVariables,
NULL,
NULL,
NULL);

REQUIRE(jmstatus == jm_status_success);
Expand Down
8 changes: 2 additions & 6 deletions Test/FMI3/fmi3_import_sim_me_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ void test_capi_wrappers_me(fmi3_import_t* fmu) {
"Test ME model instance",
NULL,
fmi3_false,
fmi3_false,
NULL,
NULL
fmi3_false
);
REQUIRE(jmstatus == jm_status_success);

Expand Down Expand Up @@ -128,9 +126,7 @@ void test_simulate_me(fmi3_import_t* fmu) {
"Test ME model instance",
NULL,
fmi3_false,
fmi3_false,
NULL,
NULL
fmi3_false
);
REQUIRE(jmstatus == jm_status_success);

Expand Down
15 changes: 0 additions & 15 deletions Test/FMI3/fmi3_import_sim_se_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,13 @@ static int g_dummy_clock_callbacks;

typedef struct {
fmi3_boolean_t clock_update_callback_called; /* Boolean used to test the call to fmi3ClockUpdateCallback */
fmi3_boolean_t log_message_callback_called; /* Boolean used to test the call to fmi3LogMessageCallback */
} dummy_fmi3_instance_environment_t;

void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
{
printf("module = %s, log level = %s: %s\n", module, jm_log_level_to_string(log_level), message);
}

void dummy_log_message_callback(
fmi3_instance_environment_t env,
fmi3_status_t status,
fmi3_string_t category,
fmi3_string_t message)
{
((dummy_fmi3_instance_environment_t*)env)->log_message_callback_called = fmi3_true;
}

void dummy_clock_update_callback() {
g_dummy_clock_callbacks++;
}
Expand All @@ -75,7 +65,6 @@ void test_capi_wrappers_se(fmi3_import_t* fmu) {
fmi3_boolean_t loggingOn = fmi3_false;
dummy_fmi3_instance_environment_t instance_env;
instance_env.clock_update_callback_called = fmi3_false;
instance_env.log_message_callback_called = fmi3_false;

g_dummy_clock_callbacks = 0;

Expand All @@ -93,17 +82,13 @@ void test_capi_wrappers_se(fmi3_import_t* fmu) {
resourcePath,
visible,
loggingOn,
((fmi3_instance_environment_t)&instance_env),
&dummy_log_message_callback,
&dummy_clock_update_callback,
&dummy_lock_preemption_callback,
&dummy_unlock_preemption_callback
);
REQUIRE(jmstatus == jm_status_success);

INFO("Verify callbacks");
REQUIRE(instance_env.log_message_callback_called == fmi3_true);

REQUIRE(g_dummy_clock_callbacks > 0);
REQUIRE(G_dummy_lock_preemption_callback_called == fmi3_true);
REQUIRE(G_dummy_unlock_preemption_callback_called == fmi3_true);
Expand Down
14 changes: 1 addition & 13 deletions src/CAPI/include/FMI3/fmi3_capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,14 @@ fmi3_status_t fmi3_capi_set_debug_logging(fmi3_capi_t* fmu, fmi3_boolean_t loggi
* @param resourcePath Absolute path to the FMU archive resources.
* @param visible Indicates whether or not the simulator application window shoule be visible.
* @param loggingOn Enable or disable the debug logger.
* @param instanceEnvironment The instance environment that is used during callbacks.
* @param logMessage The logging function the FMU will use.
* @return An instance of a model, or NULL if call failed.
*/
fmi3_instance_t fmi3_capi_instantiate_model_exchange(fmi3_capi_t* fmu,
fmi3_string_t instanceName,
fmi3_string_t instantiationToken,
fmi3_string_t resourcePath,
fmi3_boolean_t visible,
fmi3_boolean_t loggingOn,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage);
fmi3_boolean_t loggingOn);


/**
Expand All @@ -193,8 +189,6 @@ fmi3_instance_t fmi3_capi_instantiate_model_exchange(fmi3_capi_t* fmu,
* that the simulation algorithm intends to set/get during intermediate updates.
* @param nRequiredIntermediateVariables Specifies the number of entries in array
* 'requiredIntermediateVariables'.
* @param instanceEnvironment The instance environment that is used during callbacks.
* @param logMessage The logging function the FMU will use.
* @param intermediateUpdate Callback for performing intermediate updates.
* @return An instance of a model, or NULL if call failed.
*/
Expand All @@ -209,8 +203,6 @@ fmi3_instance_t fmi3_capi_instantiate_co_simulation(
fmi3_boolean_t earlyReturnAllowed,
const fmi3_value_reference_t requiredIntermediateVariables[],
size_t nRequiredIntermediateVariables,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage,
fmi3_intermediate_update_callback_ft intermediateUpdate);

/**
Expand All @@ -224,8 +216,6 @@ fmi3_instance_t fmi3_capi_instantiate_co_simulation(
* @param resourcePath Absolute path to the FMU archive resources.
* @param visible Indicates whether or not the simulator application window shoule be visible.
* @param loggingOn Enable or disable the debug logger.
* @param instanceEnvironment The instance environment that is used during callbacks.
* @param logMessage The logging function the FMU will use.
* @param clockUpdate Callback for clock update.
* @param lockPreemption Callback for locking preemption.
* @param unlockPreemption Callback for unlocking preemption.
Expand All @@ -238,8 +228,6 @@ fmi3_instance_t fmi3_capi_instantiate_scheduled_execution(
fmi3_string_t resourcePath,
fmi3_boolean_t visible,
fmi3_boolean_t loggingOn,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage,
fmi3_clock_update_callback_ft clockUpdate,
fmi3_lock_preemption_callback_ft lockPreemption,
fmi3_unlock_preemption_callback_ft unlockPreemption);
Expand Down
12 changes: 3 additions & 9 deletions src/CAPI/src/FMI3/fmi3_capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,7 @@ fmi3_instance_t fmi3_capi_instantiate_model_exchange(fmi3_capi_t* fmu,
fmi3_string_t instantiationToken,
fmi3_string_t resourcePath,
fmi3_boolean_t visible,
fmi3_boolean_t loggingOn,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage)
fmi3_boolean_t loggingOn)
{
return fmu->inst = fmu->fmi3InstantiateModelExchange(instanceName,
instantiationToken,
Expand All @@ -399,8 +397,6 @@ fmi3_instance_t fmi3_capi_instantiate_co_simulation(
fmi3_boolean_t earlyReturnAllowed,
const fmi3_value_reference_t requiredIntermediateVariables[],
size_t nRequiredIntermediateVariables,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage,
fmi3_intermediate_update_callback_ft intermediateUpdate)
{
return fmu->inst = fmu->fmi3InstantiateCoSimulation(
Expand All @@ -425,8 +421,6 @@ fmi3_instance_t fmi3_capi_instantiate_scheduled_execution(
fmi3_string_t resourcePath,
fmi3_boolean_t visible,
fmi3_boolean_t loggingOn,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage,
fmi3_clock_update_callback_ft clockUpdate,
fmi3_lock_preemption_callback_ft lockPreemption,
fmi3_unlock_preemption_callback_ft unlockPreemption)
Expand All @@ -437,8 +431,8 @@ fmi3_instance_t fmi3_capi_instantiate_scheduled_execution(
resourcePath,
visible,
loggingOn,
instanceEnvironment,
logMessage,
fmu->instanceEnvironment,
fmu->logMessage,
clockUpdate,
lockPreemption,
unlockPreemption);
Expand Down
17 changes: 1 addition & 16 deletions src/Import/include/FMI3/fmi3_import_capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ FMILIB_EXPORT fmi3_status_t fmi3_import_set_debug_logging(fmi3_import_t* fmu, fm
* \brief Wrapper for the FMI function fmi3InstantiateModelExchange(...)
*
* Arguments 'instanceEnvironment' and 'logMessage' are reused from #fmi3_import_create_dllfmu.
* Argument 'loggingOn' is reused from #fmi3_import_parse_xml().
*
* @param fmu A model description object returned by fmi3_import_parse_xml() that has loaded the FMI functions, see
* fmi3_import_create_dllfmu().
Expand All @@ -128,24 +127,19 @@ FMILIB_EXPORT fmi3_status_t fmi3_import_set_debug_logging(fmi3_import_t* fmu, fm
* path to the unzipped location.
* @param visible Indicates whether or not the simulator application window shoule be visible.
* @param loggingOn Enable or disable the debug logger.
* @param instanceEnvironment The instance environment that is used during callbacks.
* @param logMessage The logging function the FMU will use.
* @return Error status. Returnes jm_status_error if FMI function returned NULL, otherwise jm_status_success.
*/
FMILIB_EXPORT jm_status_enu_t fmi3_import_instantiate_model_exchange(
fmi3_import_t* fmu,
fmi3_string_t instanceName,
fmi3_string_t resourcePath,
fmi3_boolean_t visible,
fmi3_boolean_t loggingOn,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage);
fmi3_boolean_t loggingOn);

/**
* \brief Wrapper for the FMI function fmi3InstantiateCoSimulation(...)
*
* Arguments 'instanceEnvironment' and 'logMessage' are reused from #fmi3_import_create_dllfmu.
* Argument 'loggingOn' is reused from #fmi3_import_parse_xml().
*
* @param fmu A model description object returned by fmi3_import_parse_xml() that has loaded the FMI functions, see
* fmi3_import_create_dllfmu().
Expand All @@ -160,8 +154,6 @@ FMILIB_EXPORT jm_status_enu_t fmi3_import_instantiate_model_exchange(
* that the simulation algorithm intends to set/get during intermediate updates.
* @param nRequiredIntermediateVariables Specifies the number of entries in array
* 'requiredIntermediateVariables'.
* @param instanceEnvironment The instance environment that is used during callbacks.
* @param logMessage The logging function the FMU will use.
* @param intermediateUpdate Callback for performing intermediate updates.
* @return Error status. Returnes jm_status_error if FMI function returned NULL, otherwise jm_status_success.
*/
Expand All @@ -175,15 +167,12 @@ FMILIB_EXPORT jm_status_enu_t fmi3_import_instantiate_co_simulation(
fmi3_boolean_t earlyReturnAllowed,
const fmi3_value_reference_t requiredIntermediateVariables[],
size_t nRequiredIntermediateVariables,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage,
fmi3_intermediate_update_callback_ft intermediateUpdate);

/**
* \brief Wrapper for the FMI function fmi3InstantiateScheduledExecution(...)
*
* Arguments 'instanceEnvironment' and 'logMessage' are reused from #fmi3_import_create_dllfmu.
* Argument 'loggingOn' is reused from #fmi3_import_parse_xml().
*
* @param fmu A model description object returned by fmi3_import_parse_xml() that has loaded the FMI functions, see
* fmi3_import_create_dllfmu().
Expand All @@ -192,8 +181,6 @@ FMILIB_EXPORT jm_status_enu_t fmi3_import_instantiate_co_simulation(
* path to the unzipped location.
* @param visible Indicates whether or not the simulator application window shoule be visible.
* @param loggingOn Enable or disable the debug logger.
* @param instanceEnvironment The instance environment that is used during callbacks.
* @param logMessage The logging function the FMU will use.
* @param clockUpdate Callback for clock update.
* @param lockPreemption Callback for locking preemption.
* @param unlockPreemption Callback for unlocking preemption.
Expand All @@ -205,8 +192,6 @@ FMILIB_EXPORT jm_status_enu_t fmi3_import_instantiate_scheduled_execution(
fmi3_string_t resourcePath,
fmi3_boolean_t visible,
fmi3_boolean_t loggingOn,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage,
fmi3_clock_update_callback_ft clockUpdate,
fmi3_lock_preemption_callback_ft lockPreemption,
fmi3_unlock_preemption_callback_ft unlockPreemption);
Expand Down
16 changes: 2 additions & 14 deletions src/Import/src/FMI3/fmi3_import_capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ jm_status_enu_t fmi3_import_instantiate_model_exchange(fmi3_import_t* fmu,
fmi3_string_t instanceName,
fmi3_string_t resourcePath,
fmi3_boolean_t visible,
fmi3_boolean_t loggingOn,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage)
fmi3_boolean_t loggingOn)
{
fmi3_string_t instantiationToken = fmi3_import_get_instantiation_token(fmu);
fmi3_instance_t c;
Expand All @@ -231,9 +229,7 @@ jm_status_enu_t fmi3_import_instantiate_model_exchange(fmi3_import_t* fmu,
instantiationToken,
resourcePath,
visible,
loggingOn,
instanceEnvironment,
logMessage);
loggingOn);
if (c == NULL) {
return jm_status_error;
} else {
Expand All @@ -251,8 +247,6 @@ jm_status_enu_t fmi3_import_instantiate_co_simulation(
fmi3_boolean_t earlyReturnAllowed,
const fmi3_value_reference_t requiredIntermediateVariables[],
size_t nRequiredIntermediateVariables,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage,
fmi3_intermediate_update_callback_ft intermediateUpdate)
{
fmi3_string_t instantiationToken = fmi3_import_get_instantiation_token(fmu);
Expand Down Expand Up @@ -282,8 +276,6 @@ jm_status_enu_t fmi3_import_instantiate_co_simulation(
earlyReturnAllowed,
requiredIntermediateVariables,
nRequiredIntermediateVariables,
instanceEnvironment,
logMessage,
intermediateUpdate);
if (c == NULL) {
return jm_status_error;
Expand All @@ -298,8 +290,6 @@ jm_status_enu_t fmi3_import_instantiate_scheduled_execution(
fmi3_string_t resourcePath,
fmi3_boolean_t visible,
fmi3_boolean_t loggingOn,
fmi3_instance_environment_t instanceEnvironment,
fmi3_log_message_callback_ft logMessage,
fmi3_clock_update_callback_ft clockUpdate,
fmi3_lock_preemption_callback_ft lockPreemption,
fmi3_unlock_preemption_callback_ft unlockPreemption)
Expand Down Expand Up @@ -327,8 +317,6 @@ jm_status_enu_t fmi3_import_instantiate_scheduled_execution(
resourcePath,
visible,
loggingOn,
instanceEnvironment,
logMessage,
clockUpdate,
lockPreemption,
unlockPreemption);
Expand Down

0 comments on commit 705875f

Please sign in to comment.