Skip to content

Commit e679155

Browse files
authored
Add import dialog (#41)
and add --basic and --hide-connectors options fixes #33 fixes #35
1 parent 8cf0a53 commit e679155

File tree

25 files changed

+1475
-366
lines changed

25 files changed

+1475
-366
lines changed

FMI/Internal/FMU.mo

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ protected
1919

2020
parameter Real startTime(fixed=false);
2121

22-
parameter Boolean startValuesSet(start=false, fixed=false);
23-
24-
Boolean initialized(start=false, fixed=true);
25-
2622
FMI.Internal.ExternalFMU instance = FMI.Internal.ExternalFMU();
2723

2824
end FMU;
File renamed without changes.
Lines changed: 26 additions & 0 deletions
Loading

FMI/importFMU.mo

Lines changed: 0 additions & 46 deletions
This file was deleted.

FMI/package.mo

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,26 @@ within ;
22
package FMI "Import Functional Mock-up Units (FMUs) to Modelica"
33
extends Modelica.Icons.Package;
44

5+
package Menu "FMU Import"
6+
7+
function importFMU = FMI.Menu.openImportDialog "Import FMU..." annotation(__Dymola_autoExecute = true);
8+
function openImportDialog
9+
10+
algorithm
11+
12+
Execute("modelica-fmi-gui");
13+
14+
end openImportDialog;
15+
annotation (
16+
__Dymola_toolbar=true,
17+
Protection(hideFromBrowser=true),
18+
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
19+
100}}), graphics={Bitmap(extent={{-100,-100},{100,100}}, fileName
20+
="modelica://FMI/Resources/Images/FMI_package.svg")}));
21+
22+
end Menu;
523
annotation (version="0.0.6", uses(Modelica(version="4.0.0")), Icon(graphics={Bitmap(extent={{-80,-60},
6-
{80,60}}, fileName="modelica://FMI/Resources/FMI_bare.svg")}),
24+
{80,60}}, fileName="modelica://FMI/Resources/Images/FMI_bare.svg")}),
725
Documentation(info="<html>
826
927
<p>A Modelica package to import <a href=\"https://fmi-standard.org/\">Functional Mock-up Units</a> (FMUs).</p>
@@ -22,5 +40,8 @@ to install the <code>modelica-fmi</code> command.</p>
2240
2341
<p>To import an FMU into a Modelica package run <a href=\"modelica://FMI.importFMU\">FMI.importFMU()</a>.</p>
2442
25-
</html>"));
43+
</html>"),
44+
__Dymola_Commands(executeCall(description=
45+
"Import an FMU to an existing package") = Execute(
46+
"modelica-fmi-gui") "Import FMU..."), __Dymola_containsMenu=true);
2647
end FMI;

FMI/package.order

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
importFMU
21
FMI2
32
FMI3
43
Internal
4+
Menu

README.md

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![](https://github.com/user-attachments/assets/dbcd7e72-cdb3-48b5-8323-a1b89c328ea2)
1+
![](FMI/Resources/Images/FMI_package.svg)
22

33
# Modelica FMI
44

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

1313
## Installation
1414

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

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

27-
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.
27+
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.
2828

2929
## Usage
3030

31-
To import an FMU into an existing package call [FMI.importFMU()](FMI/importFMU.mo) or run
31+
To open the import dialog run
32+
33+
```bash
34+
modelica-fmi-gui
35+
```
36+
37+
or
3238

3339
```bash
3440
modelica-fmi /path/to/model.fmu /path/to/package/model.mo
3541
```
3642

37-
and reload the package.
43+
to import an FMU directly.
44+
45+
In Dymola you can open the import dialog by selecting `Tools > FMU Import > Import FMU...`.
46+
47+
After the import you have to reload the package.
48+
49+
## Building the binaries from source
50+
51+
To build the binaries in `FMI/Resources/Library` from source install CMake
52+
53+
```
54+
uv tool install cmake
55+
```
56+
57+
clone the repository, and run
58+
59+
```
60+
cmake -S runtime -B runtime/build
61+
```
62+
63+
```
64+
cmake --build runtime/build --config release --target install
65+
```
66+
67+
## Building distributable import commands
68+
69+
To build distributable version of the `modelica-fmi` and `modelica-fmi-gui` commands
70+
71+
- create a new virtual environment
72+
```
73+
uv venv
74+
```
75+
76+
- install PyInstaller and modelica_fmi
77+
```
78+
uv pip install pyinstaller https://github.com/modelica/Modelica-FMI/releases/download/v0.0.6/modelica_fmi-0.0.6-py3-none-any.whl
79+
```
80+
81+
- build modelica-fmi-gui
82+
```
83+
uv run pyinstaller --windowed --name modelica-fmi-gui --collect-data modelica_fmi .venv/Lib/site-packages/modelica_fmi/gui/__main__.py
84+
```
85+
86+
- ...or modelica-fmi
87+
```
88+
uv run pyinstaller --name modelica-fmi --collect-data modelica_fmi .venv/Lib/site-packages/modelica_fmi/__main__.py
89+
```
3890

3991
## License
4092

modelica_fmi/pyproject.toml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ description = "Import FMUs to Modelica"
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
8-
"fmpy>=0.3.22",
8+
"fmpy>=0.3.25",
99
"jinja2>=3.1.6",
10+
# "pymola",
11+
"pyside6>=6.9.1",
1012
]
1113

1214
[dependency-groups]
@@ -20,6 +22,22 @@ dev = [
2022
[project.scripts]
2123
modelica-fmi = "modelica_fmi.cli:main"
2224

25+
[project.gui-scripts]
26+
modelica-fmi-gui = "modelica_fmi.gui:main"
27+
2328
[build-system]
2429
requires = ["hatchling"]
2530
build-backend = "hatchling.build"
31+
32+
[tool.hatch.build.targets.wheel]
33+
exclude = [
34+
"*.svg",
35+
"*.ui",
36+
"*.qrc",
37+
]
38+
39+
[tool.ruff]
40+
extend-exclude = ["src/modelica_fmi/gui/generated"]
41+
42+
#[tool.uv.sources]
43+
#pymola = { git = "ssh://[email protected]/SCT/pymola.git" }

0 commit comments

Comments
 (0)