How weiche/reference-fmus-min works
Main Components
• FMU Models: Represented by directories like BouncingBall, Clocks, Dahlquist, Feedthrough, Resource, Stair, StateSpace, and VanDerPol. Each of these folders includes model-specific code and XML model descriptions (e.g., FMI1CS.xml, FMI2.xml, FMI3.xml) along with a model implementation file (model.c) and associated configuration files.
• Core Simulation Engine (fmusim): Found in the “fmusim” directory, this executable integrates the FMI simulation infrastructure and uses the functions defined in the common modules.
• Graphical User Interface (fmusim-gui): A separate component offering a GUI (with MainWindow, Models, various dialogs, and resource management) that wraps around the simulation engine.
• Common FMI Library: Located in “include” and “src” directories. These files define the generic interface (e.g., model.h, cosimulation.h) and provide FMI-related function implementations (e.g., fmi1Functions.c, fmi2Functions.c, fmi3Functions.c).
• Build and Integration Infrastructure: This encompasses CMakeLists.txt at the root and in subdirectories, the “build” directory with various Python build scripts, and GitHub actions in “.github/workflows.” These scripts coordinate the building of both FMU models and the simulation executables.
• Examples and Tests: “examples” and “tests” directories provide sample client codes and automated tests that show integration and proper functionality of the simulation tools.
Relationships and Interactions
• FMU Models <→ Core FMI Library: Each FMU model folder supplies model-specific data (XML, model.c, config.h) that is integrated via the common FMI functions defined in “include” and “src.”
• Core FMI Library <→ Simulation Engine (fmusim): The simulation executable calls upon the common standards implementations (solvers, model description parsers, CSV handling, etc.) to run simulations.
• Simulation Engine (fmusim) <→ fmusim-gui: The GUI component wraps around or interacts with the simulation engine. This might be shown as the GUI initiating simulation commands (e.g., via command-line calls or API invocations) and receiving outputs (like CSV results).
Architectural Patterns and Technologies
• Separation of Concerns: The system is organized by dividing model specific code, core FMI function implementations, simulation executables, and the GUI.
• Modularization: Independent FMU directories make the system extensible. Additionally, the separation between command-line simulation (fmusim) and the GUI (fmusim-gui) is clearly evident.
• Build and Integration: Use of CMake, Python build scripts, and GitHub workflows shows a robust automated build and integration process.