Command Line Interface (CLI) Usage Guide¶
The command line offers complete and precise control over FMU Manipulation Toolbox, ideal for automation and batch processing.
Available Commands¶
FMU Manipulation Toolbox provides three main commands:
| Command | Usage |
|---|---|
fmutool | FMU analysis and manipulation |
fmucontainer | FMU container creation |
fmusplit | Extract FMUs from a container |
fmutool: Main Command¶
Basic Syntax¶
Required Options¶
The FMU to analyze or modify.
Save Options¶
⚠️ Important: Without this option, no modifications are saved!
Analysis Operations¶
Display FMU Summary¶
Output:
FMU Information:
Name: module
FMI Version: 2.0
GUID: {abc-123-def}
Number of variables: 42
Number of parameters: 5
Number of inputs: 10
Number of outputs: 15
Check FMI Compliance¶
Output:
Checking FMU: module.fmu
✓ modelDescription.xml is valid
✓ Schema validation passed
⚠ Warning: Variable 'temp' has no description
✓ All value references are unique
List All Ports in CSV¶
Generated CSV content:
name;newName;valueReference;causality;variability
Motor.Speed;Motor.Speed;0;input;continuous
Motor.Torque;Motor.Torque;1;output;continuous
Controller.Kp;Controller.Kp;2;parameter;fixed
Modification Operations¶
Remove Top-Level Hierarchy¶
Before:
Command:
After:
Merge First Level¶
Before:
Command:
After:
Remove Prefix¶
Before:
Command:
After:
Rename from CSV File¶
Step 1: Create CSV
Step 2: Edit CSV
Edit renaming.csv:
name;newName;valueReference;causality;variability
Motor.Speed;Engine.Velocity;0;input;continuous
Motor.Torque;Engine.Force;1;output;continuous
Step 3: Apply modifications
Tip: Leaving newName empty removes the port!
Filtering Operations¶
Filter by Regular Expression¶
Keep only matching ports:
Remove matching ports:
Regular Expression Examples¶
# Keep everything starting with "Motor."
-keep-only-regexp "^Motor\..*"
# Remove everything containing "debug"
-remove-regexp ".*debug.*"
# Keep ports ending with "Temperature"
-keep-only-regexp ".*Temperature$"
# Remove ports starting with underscore
-remove-regexp "^_.*"
Remove All Ports¶
⚠️ Warning: This removes ALL ports! Use with filters.
Filter by Port Type¶
Operations on Parameters Only¶
List only parameters:
Remove all parameters:
Operations on Inputs Only¶
# List inputs
fmutool -input module.fmu -only-inputs -dump-csv inputs.csv
# Rename inputs
fmutool -input module.fmu -only-inputs -rename-from-csv new_inputs.csv -output module.fmu
Operations on Outputs Only¶
# List outputs
fmutool -input module.fmu -only-outputs -dump-csv outputs.csv
# Filter outputs
fmutool -input module.fmu -only-outputs -keep-only-regexp "^Result\." -output module.fmu
Binary Operations¶
Remove Sources¶
Effect: The sources/ folder is removed from the FMU.
Add Binary Interface (Windows)¶
Add 64-bit interface to 32-bit FMU:
Add 32-bit interface to 64-bit FMU:
Combining Operations¶
Options can be combined for complex transformations:
Example 1: Clean and Simplify¶
fmutool -input module.fmu \
-remove-regexp "^_internal.*" \
-remove-toplevel \
-remove-sources \
-output module-clean.fmu
Example 2: Filter and Rename¶
fmutool -input module.fmu \
-keep-only-regexp "^Motor\." \
-rename-from-csv motor_names.csv \
-output module-motor-renamed.fmu
fmucontainer: Create Containers¶
Basic Syntax¶
Main Options¶
-container filename.csv # Configuration file
-fmu-directory path/to/fmus # Directory containing FMUs
-fmi {2|3} # FMI version (default: 2)
-output container.fmu # Container name (optional)
Configuration CSV Format¶
fmu;input;output
motor.fmu;controller.command;sensor.speed
controller.fmu;sensor.speed;motor.command
sensor.fmu;motor.torque;controller.feedback
Advanced Options¶
# Enable multi-threading
fmucontainer -container system.csv -fmu-directory ./fmus -mt
# Enable profiling
fmucontainer -container system.csv -fmu-directory ./fmus -profile
# Expose parameters
fmucontainer -container system.csv -fmu-directory ./fmus -auto-parameter
# Debug mode
fmucontainer -container system.csv -fmu-directory ./fmus -debug
Automation and Scripts¶
Simple Bash Script¶
#!/bin/bash
# Process all FMUs in a directory
for fmu in *.fmu; do
echo "Processing $fmu..."
fmutool -input "$fmu" \
-remove-toplevel \
-remove-sources \
-output "processed_$fmu"
done
echo "All FMUs processed!"
Batch Script (Windows)¶
@echo off
for %%f in (*.fmu) do (
echo Processing %%f...
fmutool -input "%%f" -remove-toplevel -output "processed_%%f"
)
echo All FMUs processed!
Quick Reference¶
# Analysis
fmutool -input X.fmu -summary # Summary
fmutool -input X.fmu -check # Verification
fmutool -input X.fmu -dump-csv list.csv # List ports
# Simple modification
fmutool -input X.fmu -remove-toplevel -output Y.fmu
fmutool -input X.fmu -merge-toplevel -output Y.fmu
# Renaming
fmutool -input X.fmu -rename-from-csv names.csv -output Y.fmu
# Filtering
fmutool -input X.fmu -keep-only-regexp "PATTERN" -output Y.fmu
fmutool -input X.fmu -remove-regexp "PATTERN" -output Y.fmu
# By type
fmutool -input X.fmu -only-parameters -dump-csv params.csv
fmutool -input X.fmu -only-inputs -dump-csv inputs.csv
fmutool -input X.fmu -only-outputs -dump-csv outputs.csv
# Binaries (Windows)
fmutool -input X.fmu -add-remoting-win64 -output Y.fmu
fmutool -input X.fmu -remove-sources -output Y.fmu
# Containers
fmucontainer -container config.csv -fmu-directory ./fmus
Next Steps¶
- 🐍 Python API - Advanced automation
- 💡 Examples - Detailed use cases
- 🆘 Troubleshooting