Skip to content

boschglobal/dse.fmi

Repository files navigation

Dynamic Simulation Environment - FMI Library

CI Super Linter GitHub

Introduction

FMI Libraries of the Dynamic Simulation Environment (DSE) Core Platform provide various solutions for working with FMUs and FMI based simulation environments. Included are:

The DSE FMI libraries operate in Co-simulation environments and support both scalar and binary variables. Virtual networks (e.g. CAN) are implemented using Network Codecs and supported via FMI Binary variables, or in the case of FMI 2, by using encoded FMI String variables.

[FMI MCL]

fmimcl.png

  • Multi platform (Linux, Windows) and multi architecture (x64, x86, i386) simulation environment.
  • Native FMU support for Co-simulation.
  • Virtual Networks (CAN etc.) using Network Codecs and Binary Streams. Includes support for FMI 2 (via String variables).

[ModelC FMU]

ki_fmimodelc.png

  • FMU with embedded Model Runtime and SimBus from the ModelC project.
  • Packages DSE Simer simulation as an FMU.
  • FMU interface supports Codec based Binary Streams (e.g. CAN Virtual Bus). Includes support for FMI 2 (via String variables).

[Gateway FMU]

ki_fmigateway.png

  • Bridge simulaiton environments using a Gateway FMU.
  • Gateway FMU interface supports Codec based Binary Streams, including FMI 2 support.
  • Manages the Co-simulation time-domain between the bridged simulation environments.
  • Simple lifecycle which can be customised to support automation of simulation environments (e.g. session management).

[FMU API]

  • Minimal API for implementing Co-simulation FMUs with methods:
    • fmu_create()
    • fmu_init()
    • fmu_step()
    • fmu_destroy()
  • Automatic FMI Variable indexing and storage, including FMI 2 support for Binary Variables
  • Build targets for FMI 2 and FMI 3.
  • Virtual Networks (CAN etc.) using Network Codecs and Binary Streams. Includes support for FMI 2 (via String variables).

Project Structure

└── dse
    └── examples            <-- Examples
    └── fmigateway          <-- Gateway FMU source code
    └── fmimcl              <-- FMI MCL source code
    └── fmimodelc           <-- ModelC FMU source code
    └── fmu                 <-- FMI API source code
    └── importer            <-- Simple FMU Importer
└── extra                   <-- Build infrastructure
    └── tools/fmi           <-- Containerised tools
└── licenses                <-- Third Party Licenses
└── tests                   <-- Unit and E2E tests
└── Taskfile.yml            <-- Workflow automation via Task

Usage

ModelC FMU with DSE Script and Simulation Builder

Info: This usage example is derived from E2E Test Direct Index.

simulation.dse (DSE Script)

simulation
channel in
channel out

uses
dse.fmi file:///repo

model direct dse.fmi.example.direct
    channel in in_vector
    channel out out_vector
    envar OFFSET 100
    envar FACTOR 4

workflow generate-modelcfmu
    var FMU_NAME direct
    var FMI_VERSION 2
    var INDEX direct

Simulation Builder and Operation

# Setup environment.
$ export BUILDER_IMAGE=ghcr.io/boschglobal/dse-builder:latest
$ export FMI_IMAGE=ghcr.io/boschglobal/dse-fmi:latest
$ export TASK_X_REMOTE_TASKFILES=1

# Set command aliases.
function dse-builder() {
    ( if test -f "$1"; then cd $(dirname "$1"); fi && docker run -it --user $(id -u):$(id -g) --rm -e AR_USER -e AR_TOKEN -e GHE_USER -e GHE_TOKEN -e GHE_PAT -v $(pwd):/workdir $BUILDER_IMAGE "$@"; )
}

# Install Task (from DSE fork).
$ go install github.com/boschglobal/task/v3/cmd/task@latest

# Build the simulation.
$ dse-builder simulation.dse
$ task -y -v

# Operate the simulation with the Importer.
$ dse/build/_out/importer/fmuImporter --verbose out/fmu/direct

Examples

Build

# Clone the repo.
$ git clone https://github.com/boschglobal/dse.fmi.git
$ cd dse.fmi

# Optionally set builder images.
$ export GCC_BUILDER_IMAGE=ghcr.io/boschglobal/dse-gcc-builder:latest

# Build.
$ make
$ make package

# Build containerised tools (more details in the extra/tools/fmi directory).
$ make build fmi tools

# Optionally use local container images.
$ export FMI_IMAGE=fmi:test
$ export SIMER_IMAGE=simer:test

# Run tests.
$ make test

# Generate documentation.
$ make generate

# Remove (clean) temporary build artifacts.
$ make clean
$ make cleanall

Toolchains

The FMI Library is built using containerised toolchains. Those are available from the DSE C Library and can be built as follows:

$ git clone https://github.com/boschglobal/dse.clib.git
$ cd dse.clib
$ make docker

Alternatively, the latest Docker Images are available on ghcr.io and can be used as follows:

$ export GCC_BUILDER_IMAGE=ghcr.io/boschglobal/dse-gcc-builder:latest

Additional Resources

The FMI Library is implemented using the following related repositories:

Contribute

Please refer to the CONTRIBUTING.md file.

License

Dynamic Simulation Environment FMI Library is open-sourced under the Apache-2.0 license. See the LICENSE and NOTICE files for details.

Third Party Licenses

Third Party Licenses

About

FMI Libraries of the Dynamic Simulation Environment Core Platform.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •