Skip to content

Commit

Permalink
Add support for MDF measurement of FMI MCL.
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Rule (VM/EMT3) <[email protected]>
  • Loading branch information
timrulebosch committed Nov 14, 2024
1 parent f956c2a commit 811a12f
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 124 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

################
## DSE Projects.
export DSE_CLIB_VERSION ?= 1.0.24
export DSE_CLIB_VERSION ?= 1.0.26
export DSE_MODELC_VERSION ?= 2.1.9


Expand Down Expand Up @@ -137,9 +137,8 @@ ifeq ($(PACKAGE_ARCH), linux-amd64)
@-docker kill simer
@set -eu; for t in $(TESTSCRIPT_E2E_FILES) ;\
do \
echo "Running E2E Test: $$t" ;\
export ENTRYWORKDIR=$$(mktemp -d) ;\
echo "ENTRYWORKDIR: $${ENTRYWORKDIR}" ;\
echo "Running E2E Test: $$t (in $${ENTRYWORKDIR})" ;\
docker run -i --rm \
-e ENTRYHOSTDIR=$(HOST_DOCKER_WORKSPACE) \
-e ENTRYWORKDIR=$${ENTRYWORKDIR} \
Expand Down
43 changes: 21 additions & 22 deletions doc/content/apis/fmi/fmimcl/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,27 +196,6 @@ center footer Dynamic Simulation Environment



## fmimcl_adapter_create


This method creates an adapter object based on the configuration in the FMU
Model object.

### Parameters

fmu_model (FmuModel*)
: FMU Model descriptor object.

### Returns

0 (int32_t)
: The related adapter was loaded by the fmimcl.

-EINVAL (-22)
: No matching adapter found.



## mcl_create


Expand Down Expand Up @@ -286,7 +265,7 @@ typedef struct FmuModel {
void* m_doc;
void* adapter;
FmuData data;
struct (anonymous struct at dse/fmimcl/fmimcl.h:257:5) measurement;
struct (anonymous struct at dse/fmimcl/fmimcl.h:266:5) measurement;
}
```

Expand All @@ -306,6 +285,26 @@ typedef struct FmuSignal {

## Functions

### fmimcl_adapter_create

This method creates an adapter object based on the configuration in the FMU
Model object.

#### Parameters

fmu_model (FmuModel*)
: FMU Model descriptor object.

#### Returns

0 (int32_t)
: The related adapter was loaded by the fmimcl.

-EINVAL (-22)
: No matching adapter found.



### fmimcl_allocate_source

For each Signal parsed from the Signalgroup, this function creates an
Expand Down
156 changes: 78 additions & 78 deletions doc/content/apis/fmi/fmimodelc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@
title: FMI ModelC FMU API Reference
linkTitle: ModelC FMU
---
## FMI ModelC FMU


The FMI ModelC FMU is and FMU which is capable of loading and running a
DSE Simulation (e.g. a ModelC Simulation Stack). All capabilites of the ModelC
Runtime are supported, including the exchange of binary signals (e.g. CAN) and
realisation of bus topologies (e.g. multi-node CAN Networks).


### Component Diagram

<div hidden>

```
@startuml fmimodelc-component
title FMI ModelC FMU
center footer Dynamic Simulation Environment
@enduml
```

</div>

![](fmimodelc-component.png)




## fmi2GetReal


Expand All @@ -28,6 +58,37 @@ fmi2OK (fmi2Status)



## fmi2SetString


Set values for the provided list of value references and values. String/Binary
variables are always appended to the ModelC Binary Signal.

> Note: If several variables are indexed against the same ModelC Binary Signal,
for instance in a Bus Topology, then each variable will be appended to that
ModelC Binary Signal.

### Parameters

c (fmi2Component*)
: An Fmu2InstanceData object representing an instance of this FMU.

vr (fmi2ValueReference[])
: List of value references to set.

nvr (int)
: The number of value references to set.

value (fmi2String[])
: Storage for the values to be set.

### Returns

fmi2OK (fmi2Status)
: The requested variables have been set (where available).



## fmi2DoStep


Expand Down Expand Up @@ -62,6 +123,23 @@ fmi2Error (fmi2Status)



## fmi2Instantiate


Create an instance of this FMU, allocate/initialise a Fmu2InstanceData
object which should be used for subsequent calls to FMI methods (as parameter
`fmi2Component c`).

> Note: This implementation __does not__ use memory related callbacks provided
by the Importer (e.g. `malloc()` or `free()`).

### Returns

fmi2Component (pointer)
: An Fmu2InstanceData object which represents this FMU instance.



## fmi2ExitInitializationMode


Expand Down Expand Up @@ -135,37 +213,6 @@ fmi2OK (fmi2Status)



## fmi2SetString


Set values for the provided list of value references and values. String/Binary
variables are always appended to the ModelC Binary Signal.

> Note: If several variables are indexed against the same ModelC Binary Signal,
for instance in a Bus Topology, then each variable will be appended to that
ModelC Binary Signal.

### Parameters

c (fmi2Component*)
: An Fmu2InstanceData object representing an instance of this FMU.

vr (fmi2ValueReference[])
: List of value references to set.

nvr (int)
: The number of value references to set.

value (fmi2String[])
: Storage for the values to be set.

### Returns

fmi2OK (fmi2Status)
: The requested variables have been set (where available).



## fmi2FreeInstance


Expand All @@ -178,53 +225,6 @@ c (fmi2Component*)



## FMI ModelC FMU


The FMI ModelC FMU is and FMU which is capable of loading and running a
DSE Simulation (e.g. a ModelC Simulation Stack). All capabilites of the ModelC
Runtime are supported, including the exchange of binary signals (e.g. CAN) and
realisation of bus topologies (e.g. multi-node CAN Networks).


### Component Diagram

<div hidden>

```
@startuml fmimodelc-component
title FMI ModelC FMU
center footer Dynamic Simulation Environment
@enduml
```

</div>

![](fmimodelc-component.png)




## fmi2Instantiate


Create an instance of this FMU, allocate/initialise a Fmu2InstanceData
object which should be used for subsequent calls to FMI methods (as parameter
`fmi2Component c`).

> Note: This implementation __does not__ use memory related callbacks provided
by the Importer (e.g. `malloc()` or `free()`).

### Returns

fmi2Component (pointer)
: An Fmu2InstanceData object which represents this FMU instance.



## Typedefs

## Functions
Expand Down
2 changes: 1 addition & 1 deletion doc/content/docs/user/fmi/fmimcl/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "FMI Model Compatibility Library (MCL)"
linkTitle: "FMI MCL"
linkTitle: "MCL"
weight: 400
tags:
- FMI
Expand Down
1 change: 1 addition & 0 deletions dse/fmimcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_library(fmimcl SHARED
parser.c
adapter/fmi2mcl.c
../fmimodelc/ascii85.c
${DSE_CLIB_SOURCE_DIR}/clib/mdf/mdf.c
)
target_include_directories(fmimcl
PRIVATE
Expand Down
15 changes: 12 additions & 3 deletions dse/fmimcl/fmimcl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@
#include <stdint.h>
#include <dse/platform.h>
#include <dse/clib/data/marshal.h>
#include <dse/clib/mdf/mdf.h>
#include <dse/modelc/mcl.h>
#include <dse/modelc/model.h>


#ifndef DLL_PUBLIC
#define DLL_PUBLIC __attribute__((visibility("default")))
#endif
#ifndef DLL_PRIVATE
#define DLL_PRIVATE __attribute__((visibility("hidden")))
#endif


/**
FMI Model Compatibility Library
===============================
Expand Down Expand Up @@ -255,9 +264,9 @@ typedef struct FmuModel {
FmuData data;
/* Measurement file. */
struct {
char* file_name;
void* file;
// TODO measurement descriptor
char* file_name;
void* file;
MdfDesc mdf;
} measurement;
} FmuModel;

Expand Down
Loading

0 comments on commit 811a12f

Please sign in to comment.