Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions FMI/Internal/FMU.mo
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ protected

parameter Real startTime(fixed=false);

parameter Boolean startValuesSet(start=false, fixed=false);

Boolean initialized(start=false, fixed=true);

FMI.Internal.ExternalFMU instance = FMI.Internal.ExternalFMU();

end FMU;
File renamed without changes
26 changes: 26 additions & 0 deletions FMI/Resources/Images/FMI_package.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 0 additions & 46 deletions FMI/importFMU.mo

This file was deleted.

25 changes: 23 additions & 2 deletions FMI/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@ within ;
package FMI "Import Functional Mock-up Units (FMUs) to Modelica"
extends Modelica.Icons.Package;

package Menu "FMU Import"

function importFMU = FMI.Menu.openImportDialog "Import FMU..." annotation(__Dymola_autoExecute = true);
function openImportDialog

algorithm

Execute("modelica-fmi-gui");

end openImportDialog;
annotation (
__Dymola_toolbar=true,
Protection(hideFromBrowser=true),
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
100}}), graphics={Bitmap(extent={{-100,-100},{100,100}}, fileName
="modelica://FMI/Resources/Images/FMI_package.svg")}));

end Menu;
annotation (version="0.0.6", uses(Modelica(version="4.0.0")), Icon(graphics={Bitmap(extent={{-80,-60},
{80,60}}, fileName="modelica://FMI/Resources/FMI_bare.svg")}),
{80,60}}, fileName="modelica://FMI/Resources/Images/FMI_bare.svg")}),
Documentation(info="<html>

<p>A Modelica package to import <a href=\"https://fmi-standard.org/\">Functional Mock-up Units</a> (FMUs).</p>
Expand All @@ -22,5 +40,8 @@ to install the <code>modelica-fmi</code> command.</p>

<p>To import an FMU into a Modelica package run <a href=\"modelica://FMI.importFMU\">FMI.importFMU()</a>.</p>

</html>"));
</html>"),
__Dymola_Commands(executeCall(description=
"Import an FMU to an existing package") = Execute(
"modelica-fmi-gui") "Import FMU..."), __Dymola_containsMenu=true);
end FMI;
2 changes: 1 addition & 1 deletion FMI/package.order
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
importFMU
FMI2
FMI3
Internal
Menu
62 changes: 57 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![](https://github.com/user-attachments/assets/dbcd7e72-cdb3-48b5-8323-a1b89c328ea2)
![](FMI/Resources/Images/FMI_package.svg)

# Modelica FMI

Expand All @@ -12,7 +12,7 @@ A Modelica library to import [Functional Mock-up Units](https://fmi-standard.org

## Installation

Install the `modelica-fmi` command with [uv](https://docs.astral.sh/uv/getting-started/installation/):
To import FMUs install the `modelica-fmi` and `modelica-fmi-gui` commands with [uv](https://docs.astral.sh/uv/getting-started/installation/):

```bash
uv tool install --reinstall https://github.com/modelica/Modelica-FMI/releases/download/v0.0.6/modelica_fmi-0.0.6-py3-none-any.whl
Expand All @@ -24,17 +24,69 @@ Or, with `pip`:
pip install https://github.com/modelica/Modelica-FMI/releases/download/v0.0.6/modelica_fmi-0.0.6-py3-none-any.whl
```

Then download the [Modelica-FMI](https://github.com/modelica/Modelica-FMI/releases/download/v0.0.6/Modelica-FMI-0.0.6.zip) package and load it in your Modelica tool.
To simulate imported FMUs download the [Modelica-FMI](https://github.com/modelica/Modelica-FMI/releases/download/v0.0.6/Modelica-FMI-0.0.6.zip) package and load it in your Modelica tool.

## Usage

To import an FMU into an existing package call [FMI.importFMU()](FMI/importFMU.mo) or run
To open the import dialog run

```bash
modelica-fmi-gui
```

or

```bash
modelica-fmi /path/to/model.fmu /path/to/package/model.mo
```

and reload the package.
to import an FMU directly.

In Dymola you can open the import dialog by selecting `Tools > FMU Import > Import FMU...`.

After the import you have to reload the package.

## Building the binaries from source

To build the binaries in `FMI/Resources/Library` from source install CMake

```
uv tool install cmake
```

clone the repository, and run

```
cmake -S runtime -B runtime/build
```

```
cmake --build runtime/build --config release --target install
```

## Building distributable import commands

To build distributable version of the `modelica-fmi` and `modelica-fmi-gui` commands

- create a new virtual environment
```
uv venv
```

- install PyInstaller and modelica_fmi
```
uv pip install pyinstaller https://github.com/modelica/Modelica-FMI/releases/download/v0.0.6/modelica_fmi-0.0.6-py3-none-any.whl
```

- build modelica-fmi-gui
```
uv run pyinstaller --windowed --name modelica-fmi-gui --collect-data modelica_fmi .venv/Lib/site-packages/modelica_fmi/gui/__main__.py
```

- ...or modelica-fmi
```
uv run pyinstaller --name modelica-fmi --collect-data modelica_fmi .venv/Lib/site-packages/modelica_fmi/__main__.py
```

## License

Expand Down
20 changes: 19 additions & 1 deletion modelica_fmi/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ description = "Import FMUs to Modelica"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"fmpy>=0.3.22",
"fmpy>=0.3.25",
"jinja2>=3.1.6",
# "pymola",
"pyside6>=6.9.1",
]

[dependency-groups]
Expand All @@ -20,6 +22,22 @@ dev = [
[project.scripts]
modelica-fmi = "modelica_fmi.cli:main"

[project.gui-scripts]
modelica-fmi-gui = "modelica_fmi.gui:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
exclude = [
"*.svg",
"*.ui",
"*.qrc",
]

[tool.ruff]
extend-exclude = ["src/modelica_fmi/gui/generated"]

#[tool.uv.sources]
#pymola = { git = "ssh://[email protected]/SCT/pymola.git" }
Loading