fmu_from_struct 0.2.1

A derive macro for automatically setting up FMU models in Rust
Documentation

fmu_from_struct

A derive macro for automatically setting up FMU models in Rust

Development Status

WARNING: This crate is still in development. Bugs can be expected in the current version and breaking changes are to be expected in future versions. The reason it is released openly is mostly to allow people interested in the purpose of this crate (see below) to contribute to and comment on the development.

Only the most fundamental functionality in the FMI standard is so far implemented. However, this is often enough for simple models and use cases. The library is therefore used to implement FMUs from Rust code in separate projects related to maritime research. One example is an FMU-version of the Stormbird library. The basic functionality seems to work as intended.

Purpose

Automate the implementation of a functional mockup interface for models written in Rust. That is, automatically generate everything from initialization, setters and getters, model description files and everything else needed for an FMI-model. The only thing you have to write is the do-step function. Custom initialization functionality is also possible, but optional (only required sometimes)

Co-simulation is seen as the primary use case for this macro and is currently the only supported type of implementation. Model exchange may be added in the future if there is a need or interest from users.

Only versions 2 and 3 of the FMI standard are supported, with no plans to add support for version 1. Due to how this code is used in other projects by the developer, version 2 is tested more than version 3, and may be considered the safer choice. However, version 3 is theoretically supported in the same way, just not tested as thoroughly.

Getting Started

Check the examples folder for code examples on how to use this macro. In particular, there is a an example called "spring" which attempts to show the most important ways to use this macro with a simple spinrg model.

Another example, from an external github page, is the implementation of the stormbird lifting line FMU. This example is more complex than the basic spring example, but the same basic steps and architecture are used.

Folder Structure

  • fmu_from_struct contains the high-level rust code for the macro (mainly prelude and traits)
  • fmu_from_struct_derive contains the actual derive macro logic (must be a separate crate)
  • package_fmu_after_build contains a command line tool to package a FMU that is generated by the macro. This mainly consists of taking the generated files and packaging them into a single file zip file that follows the FMI standard.
  • examples contains simple examples of how to use the macro

Contribute

If you would like to contribute, that's great! Please contact the repository owner for an informal discussion about how and what.

If you only would like to raise an issue, feel free to create one in this repository. However, no promises on when it will be fixed...

License

This macro is licensed under the MIT License. See LICENSE or https://opensource.org/license/MIT for details.