Skip to content

Commit 86e87dd

Browse files
committed
Add initial version of FMI library
1 parent 19a6258 commit 86e87dd

File tree

221 files changed

+10702
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+10702
-1
lines changed

.github/workflows/build.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
on:
2+
push:
3+
branches: [ main ]
4+
tags: [ 'v*' ]
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
build-win32-binaries:
10+
runs-on: windows-2022
11+
steps:
12+
- uses: actions/checkout@v4
13+
- run: cmake -S ./runtime -B ./runtime/win32 -G "Visual Studio 17 2022" -A Win32
14+
- run: cmake --build ./runtime/win32 --config release --target install
15+
- uses: actions/upload-artifact@v4
16+
with:
17+
name: win32
18+
path: ./FMI/Resources/Library/win32/ModelicaFMI.dll
19+
if-no-files-found: error
20+
build-win64-binaries:
21+
runs-on: windows-2022
22+
steps:
23+
- uses: actions/checkout@v4
24+
- run: cmake -S ./runtime -B ./runtime/win64 -G "Visual Studio 17 2022" -A x64
25+
- run: cmake --build ./runtime/win64 --config release --target install
26+
- uses: actions/upload-artifact@v4
27+
with:
28+
name: win64
29+
path: ./FMI/Resources/Library/win64/ModelicaFMI.dll
30+
if-no-files-found: error
31+
build-linux64-binaries:
32+
runs-on: ubuntu-22.04
33+
steps:
34+
- uses: actions/checkout@v4
35+
- run: cmake -S ./runtime -B ./runtime/linux64
36+
- run: cmake --build ./runtime/linux64 --target install
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: linux64
40+
path: ./FMI/Resources/Library/linux64/libModelicaFMI.so
41+
if-no-files-found: error
42+
build-darwin64-binaries:
43+
runs-on: macos-13
44+
steps:
45+
- uses: actions/checkout@v4
46+
- run: cmake -S ./runtime -B ./runtime/darwin64 -D "CMAKE_OSX_ARCHITECTURES=arm64;x86_64"
47+
- run: cmake --build ./runtime/darwin64 --target install
48+
- uses: actions/upload-artifact@v4
49+
with:
50+
name: darwin64
51+
path: ./FMI/Resources/Library/darwin64/libModelicaFMI.dylib
52+
if-no-files-found: error
53+
build-modelica-library:
54+
runs-on: ubuntu-22.04
55+
needs: [build-win32-binaries, build-win64-binaries, build-linux64-binaries, build-darwin64-binaries]
56+
steps:
57+
- uses: actions/checkout@v4
58+
- uses: actions/download-artifact@v4
59+
with:
60+
name: win32
61+
path: ./FMI/Resources/Library/win32/
62+
- uses: actions/download-artifact@v4
63+
with:
64+
name: win64
65+
path: ./FMI/Resources/Library/win64/
66+
- uses: actions/download-artifact@v4
67+
with:
68+
name: linux64
69+
path: ./FMI/Resources/Library/linux64/
70+
- uses: actions/download-artifact@v4
71+
with:
72+
name: darwin64
73+
path: ./FMI/Resources/Library/darwin64/
74+
- run: tree
75+
- uses: actions/upload-artifact@v4
76+
with:
77+
name: Modelica-FMI
78+
path: |
79+
FMI/
80+
LICENSE
81+
README.md
82+
if-no-files-found: error
83+
build-python-wheel:
84+
runs-on: ubuntu-22.04
85+
steps:
86+
- uses: actions/checkout@v4
87+
- uses: astral-sh/setup-uv@v4
88+
- run: uv build modelica_fmi
89+
- uses: actions/upload-artifact@v4
90+
with:
91+
name: dist
92+
path: modelica_fmi/dist/*.whl
93+
if-no-files-found: error

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.idea
2+
*.bak-mo
3+
__pycache__
4+
*.zip
5+
build/
6+
dist/
7+
*.egg-info/
8+
tests/work/

FMI/FMI2/Functions/FMI2DoStep.mo

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
within FMI.FMI2.Functions;
2+
impure function FMI2DoStep
3+
extends Modelica.Icons.Function;
4+
input Internal.ExternalFMU instance;
5+
input Real currentCommunicationPoint;
6+
input Real communicationStepSize;
7+
input Boolean noSetFMUStatePriorToCurrentPoint;
8+
algorithm
9+
FMI.Internal.FMI2.FMI2DoStep(
10+
instance,
11+
currentCommunicationPoint,
12+
communicationStepSize,
13+
noSetFMUStatePriorToCurrentPoint);
14+
FMI.Internal.Logging.logMessages(instance);
15+
end FMI2DoStep;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
within FMI.FMI2.Functions;
2+
impure function FMI2EnterInitializationMode
3+
extends Modelica.Icons.Function;
4+
input Internal.ExternalFMU externalFMU;
5+
algorithm
6+
FMI.Internal.FMI2.FMI2EnterInitializationMode(externalFMU);
7+
FMI.Internal.Logging.logMessages(externalFMU);
8+
end FMI2EnterInitializationMode;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
within FMI.FMI2.Functions;
2+
impure function FMI2ExitInitializationMode
3+
extends Modelica.Icons.Function;
4+
input Internal.ExternalFMU externalFMU;
5+
algorithm
6+
FMI.Internal.FMI2.FMI2ExitInitializationMode(externalFMU);
7+
FMI.Internal.Logging.logMessages(externalFMU);
8+
end FMI2ExitInitializationMode;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
within FMI.FMI2.Functions;
2+
impure function FMI2GetBoolean
3+
extends Modelica.Icons.Function;
4+
5+
input Internal.ExternalFMU instance;
6+
input FMI.FMI2.Types.FMI2ValueReference valueReference;
7+
8+
output FMI.FMI2.Types.FMI2Boolean value;
9+
10+
algorithm
11+
12+
value := FMI.Internal.FMI2.FMI2GetBoolean(instance, valueReference);
13+
14+
FMI.Internal.Logging.logMessages(instance);
15+
16+
end FMI2GetBoolean;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
within FMI.FMI2.Functions;
2+
impure function FMI2GetInitialReal
3+
extends Modelica.Icons.Function;
4+
input Internal.ExternalFMU instance;
5+
input Real _time;
6+
input Integer realInputValueReferences[:] = fill(0, 0);
7+
input Real realInputValues[:] = fill(0.0, 0);
8+
input Integer integerInputValueReferences[:] = fill(0, 0);
9+
input Integer integerInputValues[:] = fill(0, 0);
10+
input Integer booleanInputValueReferences[:] = fill(0, 0);
11+
input Boolean booleanInputValues[:] = fill(false, 0);
12+
input Integer valueReference;
13+
output Real value;
14+
algorithm
15+
FMI2SetReal(instance, realInputValueReferences, size(realInputValueReferences, 1), realInputValues);
16+
FMI.Internal.Logging.logMessages(instance);
17+
FMI2SetInteger(instance, integerInputValueReferences, size(integerInputValueReferences, 1), integerInputValues);
18+
FMI.Internal.Logging.logMessages(instance);
19+
FMI2SetBoolean(instance, booleanInputValueReferences, size(booleanInputValueReferences, 1), booleanInputValues);
20+
FMI.Internal.Logging.logMessages(instance);
21+
value := FMI2GetReal(instance, valueReference);
22+
FMI.Internal.Logging.logMessages(instance);
23+
end FMI2GetInitialReal;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
within FMI.FMI2.Functions;
2+
impure function FMI2GetInteger
3+
extends Modelica.Icons.Function;
4+
5+
input Internal.ExternalFMU instance;
6+
input FMI.FMI2.Types.FMI2ValueReference valueReference;
7+
8+
output FMI.FMI2.Types.FMI2Integer value;
9+
10+
algorithm
11+
12+
value := FMI.Internal.FMI2.FMI2GetInteger(instance, valueReference);
13+
14+
FMI.Internal.Logging.logMessages(instance);
15+
16+
end FMI2GetInteger;

FMI/FMI2/Functions/FMI2GetReal.mo

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
within FMI.FMI2.Functions;
2+
impure function FMI2GetReal
3+
extends Modelica.Icons.Function;
4+
5+
input Internal.ExternalFMU instance;
6+
input FMI.FMI2.Types.FMI2ValueReference valueReference;
7+
8+
output FMI.FMI2.Types.FMI2Real value;
9+
10+
algorithm
11+
12+
value := FMI.Internal.FMI2.FMI2GetReal(instance, valueReference);
13+
14+
FMI.Internal.Logging.logMessages(instance);
15+
16+
end FMI2GetReal;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
within FMI.FMI2.Functions;
2+
impure function FMI2GetString
3+
extends Modelica.Icons.Function;
4+
5+
input Internal.ExternalFMU instance;
6+
input FMI.FMI2.Types.FMI2ValueReference valueReference;
7+
8+
output FMI.FMI2.Types.FMI2String value;
9+
10+
algorithm
11+
12+
value := FMI.Internal.FMI2.FMI2GetString(instance, valueReference);
13+
14+
FMI.Internal.Logging.logMessages(instance);
15+
16+
end FMI2GetString;

0 commit comments

Comments
 (0)