Expand description
§fmi-export
A Rust interface to FMUs (Functional Mockup Units) that follow the FMI Standard. This crate provides necessary interfaces and utilities to construct FMUs.
This crate is part of rust-fmi.
See http://www.fmi-standard.org
§Quick start: export an FMU
- Define a
cdylibmodel crate and deriveFmuModel:
use fmi_export::FmuModel;
#[derive(FmuModel, Default, Debug)]
struct MyModel {
#[variable(causality = Output, start = 1.0)]
y: f64,
}- Export FMI symbols:
fmi_export::export_fmu!(MyModel);- Bundle the FMU with
xtask:
cargo run --package xtask -- --package my-model bundle§Building FMUs
This repository builds FMI 3.0 FMUs from pure Rust code. The FMI API interfacing boilerplate is generated with the
FmuModel derive macro. Automated packaging is handled by an xtask module.
§Minimal FMU setup
Your FMU crate must:
- Be a
cdylib:
[lib]
crate-type = ["cdylib"]- Derive
FmuModelfor your model struct - Export FMI symbols via
export_fmu!
Example skeleton:
use fmi_export::FmuModel;
#[derive(FmuModel, Default, Debug)]
struct MyModel {
#[variable(causality = Output, start = 1.0)]
y: f64,
}
fmi_export::export_fmu!(MyModel);§Build an FMU (this repo)
From the repository root:
cargo run xtask -- --package can-triggered-output bundleThe FMU zip is written to:
target/fmu/<model_identifier>.fmu<model_identifier> is the Rust cdylib target name (for can-triggered-output, this is
can_triggered_output).
§Common options
- Build a release FMU:
cargo run --package xtask -- --package can-triggered-output bundle --release- Build for a specific target:
cargo run --package xtask -- --package can-triggered-output bundle --target x86_64-unknown-linux-gnu§License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
§Feature flags
fmi3(enabled by default) — Enable support for FMI 3.0
Modules§
- fmi3
- Architecture
Macros§
- checked_
deref_ cs - Safely dereferences an FMI instance pointer for Co-Simulation instances with wrapper context.
- checked_
deref_ me - Safely dereferences an FMI instance pointer for Model Exchange instances.
- dispatch_
by_ instance_ type - Dispatches a method call based on the runtime instance_type. This is used for Common trait methods that must work for any instance type (ME/CS/SE).
- export_
fmu - Main macro for exporting an FMI 3.0 model as a shared library.
- generate_
getset_ functions - Generates getter and setter functions for FMI3 data types.
- wrapper_
getset_ functions
Derive Macros§
- FmuModel
- FmuModel derive reference