Skip to content

Commit

Permalink
Prefix fmi functions to avoid linker conflict.
Browse files Browse the repository at this point in the history
Signed-off-by: Rule Timothy (VM/EMT3) <[email protected]>
  • Loading branch information
Smidt Jannik authored and timrulebosch committed Apr 19, 2024
1 parent 641122f commit 241a27c
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion doc/content/apis/clib/examples/counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define VR_COUNT 42


int model_step(FmuModelDesc* model_desc, double model_time, double stop_time)
int fmu_model_step(FmuModelDesc* model_desc, double model_time, double stop_time)
{
UNUSED(model_time);
UNUSED(stop_time);
Expand Down
18 changes: 9 additions & 9 deletions doc/content/apis/clib/fmi/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ the following notable capabilities:

* Models are compatible with either FMI 2 or FMI 3 (selected via linker).
* Simple model lifecycle:
* `model_init()`
* `model_step()` - only function needed for a minimal FMU implementation!
* `fmu_model_init()`
* `fmu_model_step()` - only function needed for a minimal FMU implementation!
* ...
* Storage system with fast hash based index for all FMI Variable types, including binary data.
* Integration with [DSE Network Codec API](https://github.com/boschglobal/dse.standards/tree/main/dse/ncodec)
Expand Down Expand Up @@ -176,7 +176,7 @@ action (FmuStrategyAction)



### model_create
### fmu_model_create

Creates an FMU Model Descriptor object and performs any necessary
initialisation of the FMU Model.
Expand Down Expand Up @@ -205,7 +205,7 @@ FmuModelDesc*



### model_destroy
### fmu_model_destroy

Called by `fmi2FreeInstance()`.

Expand All @@ -226,9 +226,9 @@ model_desc (FmuModelDesc*)



### model_finalize
### fmu_model_finalize

Releases the resources created by `model_create()`.
Releases the resources created by `fmu_model_create()`.

Called by `fmi2FreeInstance()`.

Expand All @@ -241,7 +241,7 @@ model_desc (FmuModelDesc*)



### model_init
### fmu_model_init

Called by `fmi2ExitInitializationMode()` as the FMU exits initialisation mode.

Expand All @@ -262,7 +262,7 @@ model_desc (FmuModelDesc*)



### model_step
### fmu_model_step

Called by `fmi2DoStep()`.

Expand All @@ -283,7 +283,7 @@ model_desc (FmuModelDesc*)



### model_terminate
### fmu_model_terminate

Called by `fmi2Terminate()`.

Expand Down
2 changes: 1 addition & 1 deletion dse/clib/fmi/examples/fmu/counter/counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define VR_COUNT 42


int model_step(FmuModelDesc* model_desc, double model_time, double stop_time)
int fmu_model_step(FmuModelDesc* model_desc, double model_time, double stop_time)
{
UNUSED(model_time);
UNUSED(stop_time);
Expand Down
16 changes: 8 additions & 8 deletions dse/clib/fmi/examples/fmu/nop/nop_weak.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


/**
* model_init
* fmu_model_init
*
* Parameters
* ----------
Expand All @@ -20,7 +20,7 @@
* -------
* 0 : success.
*/
__attribute__((weak)) int model_init(FmuModelDesc* model_desc)
__attribute__((weak)) int fmu_model_init(FmuModelDesc* model_desc)
{
UNUSED(model_desc);

Expand All @@ -29,7 +29,7 @@ __attribute__((weak)) int model_init(FmuModelDesc* model_desc)


/**
* model_step
* fmu_model_step
*
* Parameters
* ----------
Expand All @@ -40,7 +40,7 @@ __attribute__((weak)) int model_init(FmuModelDesc* model_desc)
* -------
* 0 : success.
*/
__attribute__((weak)) int model_step(
__attribute__((weak)) int fmu_model_step(
FmuModelDesc* model_desc, double model_time, double stop_time)
{
UNUSED(model_desc);
Expand All @@ -52,7 +52,7 @@ __attribute__((weak)) int model_step(


/**
* model_terminate
* fmu_model_terminate
*
* Parameters
* ----------
Expand All @@ -63,7 +63,7 @@ __attribute__((weak)) int model_step(
* -------
* 0 : success.
*/
__attribute__((weak)) int model_terminate(FmuModelDesc* model_desc)
__attribute__((weak)) int fmu_model_terminate(FmuModelDesc* model_desc)
{
UNUSED(model_desc);

Expand All @@ -72,7 +72,7 @@ __attribute__((weak)) int model_terminate(FmuModelDesc* model_desc)


/**
* model_destroy
* fmu_model_destroy
*
* Free the loaded process list.
*
Expand All @@ -81,7 +81,7 @@ __attribute__((weak)) int model_terminate(FmuModelDesc* model_desc)
* model_desc : FmuModelDesc
* Model Descriptor, references various runtime functions and data.
*/
__attribute__((weak)) void model_destroy(FmuModelDesc* model_desc)
__attribute__((weak)) void fmu_model_destroy(FmuModelDesc* model_desc)
{
UNUSED(model_desc);
}
16 changes: 8 additions & 8 deletions dse/clib/fmi/examples/fmu/nop/process-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void _set_envvar(


/**
* model_init
* fmu_model_init
*
* Load the process list and start all configured processes.
*
Expand All @@ -55,7 +55,7 @@ static void _set_envvar(
* 0 : success.
* +ve : failure, inspect errno for the failing condition.
*/
int model_init(FmuModelDesc* model_desc)
int fmu_model_init(FmuModelDesc* model_desc)
{
process_list = dse_process_load_process_list(PROCESS_LIST_FILENAME);

Expand Down Expand Up @@ -89,7 +89,7 @@ int model_init(FmuModelDesc* model_desc)


/**
* model_step
* fmu_model_step
*
* (Not used - required to complete the FMU Model API)
*
Expand All @@ -102,7 +102,7 @@ int model_init(FmuModelDesc* model_desc)
* -------
* 0 : success.
*/
int model_step(FmuModelDesc* model_desc, double model_time, double stop_time)
int fmu_model_step(FmuModelDesc* model_desc, double model_time, double stop_time)
{
UNUSED(model_desc);
UNUSED(model_time);
Expand All @@ -113,7 +113,7 @@ int model_step(FmuModelDesc* model_desc, double model_time, double stop_time)


/**
* model_terminate
* fmu_model_terminate
*
* Stop all running processes in the process list.
*
Expand All @@ -127,7 +127,7 @@ int model_step(FmuModelDesc* model_desc, double model_time, double stop_time)
* 0 : success.
* +ve : failure, inspect errno for the failing condition.
*/
int model_terminate(FmuModelDesc* model_desc)
int fmu_model_terminate(FmuModelDesc* model_desc)
{
UNUSED(model_desc);

Expand All @@ -139,7 +139,7 @@ int model_terminate(FmuModelDesc* model_desc)


/**
* model_destroy
* fmu_model_destroy
*
* Free the loaded process list.
*
Expand All @@ -148,7 +148,7 @@ int model_terminate(FmuModelDesc* model_desc)
* model_desc : FmuModelDesc
* Model Descriptor, references various runtime functions and data.
*/
void model_destroy(FmuModelDesc* model_desc)
void fmu_model_destroy(FmuModelDesc* model_desc)
{
UNUSED(model_desc);

Expand Down
12 changes: 6 additions & 6 deletions dse/clib/fmi/fmi2/fmi2fmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fmi2Component fmi2Instantiate(fmi2String instance_name, fmi2Type fmu_type,
}

/* Create the Model. */
FmuModelDesc* model_desc = model_create(
FmuModelDesc* model_desc = fmu_model_create(
fmu_inst, functions->allocateMemory, functions->freeMemory,
fmu_resource_location + resource_path_offset);

Expand Down Expand Up @@ -125,7 +125,7 @@ fmi2Status fmi2EnterInitializationMode(fmi2Component c)

fmi2Status fmi2ExitInitializationMode(fmi2Component c)
{
int rc = model_init(c);
int rc = fmu_model_init(c);
return (rc == 0 ? fmi2OK : fmi2Error);
}

Expand Down Expand Up @@ -368,7 +368,7 @@ fmi2Status fmi2DoStep(fmi2Component c, fmi2Real currentCommunicationPoint,
{
UNUSED(noSetFMUStatePriorToCurrentPoint);

int rc = model_step(c, currentCommunicationPoint, communicationStepSize);
int rc = fmu_model_step(c, currentCommunicationPoint, communicationStepSize);
return (rc == 0 ? fmi2OK : fmi2Error);
}

Expand Down Expand Up @@ -457,12 +457,12 @@ fmi2Status fmi2Reset(fmi2Component c)

fmi2Status fmi2Terminate(fmi2Component c)
{
int rc = model_terminate(c);
int rc = fmu_model_terminate(c);
return (rc == 0 ? fmi2OK : fmi2Error);
}

void fmi2FreeInstance(fmi2Component c)
{
model_destroy(c);
model_finalize(c);
fmu_model_destroy(c);
fmu_model_finalize(c);
}
12 changes: 6 additions & 6 deletions dse/clib/fmi/fmi3/fmi3fmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fmi3Instance fmi3InstantiateCoSimulation(fmi3String instanceName,
}

/* Create the Model. */
FmuModelDesc* model_desc = model_create(fmu_inst, calloc, free,
FmuModelDesc* model_desc = fmu_model_create(fmu_inst, calloc, free,
resourcePath + resource_path_offset);

return (fmi3Instance)model_desc;
Expand Down Expand Up @@ -138,8 +138,8 @@ fmi3Instance fmi3InstantiateScheduledExecution(fmi3String instanceName,
void fmi3FreeInstance(fmi3Instance instance)
{
assert(instance);
model_destroy(instance);
model_finalize(instance);
fmu_model_destroy(instance);
fmu_model_finalize(instance);
}

/* Enter and exit initialization mode, enter event mode, terminate and reset */
Expand All @@ -161,7 +161,7 @@ fmi3Status fmi3EnterInitializationMode(fmi3Instance instance,
fmi3Status fmi3ExitInitializationMode(fmi3Instance instance)
{
assert(instance);
int rc = model_init(instance);
int rc = fmu_model_init(instance);
return (rc == 0 ? fmi3OK : fmi3Error);
}

Expand All @@ -184,7 +184,7 @@ fmi3Status fmi3Terminate(fmi3Instance instance)
{
assert(instance);

int rc = model_terminate(instance);
int rc = fmu_model_terminate(instance);
return (rc == 0 ? fmi3OK : fmi3Error);
}

Expand Down Expand Up @@ -999,7 +999,7 @@ fmi3Status fmi3DoStep(fmi3Instance instance,
UNUSED(lastSuccessfulTime);

int rc =
model_step(instance, currentCommunicationPoint, communicationStepSize);
fmu_model_step(instance, currentCommunicationPoint, communicationStepSize);
return (rc == 0 ? fmi3OK : fmi3Error);

return fmi3OK;
Expand Down
Loading

0 comments on commit 241a27c

Please sign in to comment.