-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathtest_FMIRegression.py
More file actions
69 lines (41 loc) · 2.15 KB
/
test_FMIRegression.py
File metadata and controls
69 lines (41 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import tempfile
import pathlib
import shutil
import os
import OMPython
def buildModelFMU(modelName):
omcs = OMPython.OMCSessionLocal()
tempdir = pathlib.Path(tempfile.mkdtemp())
try:
omcs.sendExpression(f'cd("{tempdir.as_posix()}")')
omcs.sendExpression("loadModel(Modelica)")
omcs.sendExpression("getErrorString()")
fileNamePrefix = modelName.split(".")[-1]
exp = f'buildModelFMU({modelName}, fileNamePrefix="{fileNamePrefix}")'
fmu = omcs.sendExpression(exp)
assert os.path.exists(fmu)
finally:
del omcs
shutil.rmtree(tempdir, ignore_errors=True)
def test_Modelica_Blocks_Examples_Filter():
buildModelFMU("Modelica.Blocks.Examples.Filter")
def test_Modelica_Blocks_Examples_RealNetwork1():
buildModelFMU("Modelica.Blocks.Examples.RealNetwork1")
def test_Modelica_Electrical_Analog_Examples_CauerLowPassAnalog():
buildModelFMU("Modelica.Electrical.Analog.Examples.CauerLowPassAnalog")
def test_Modelica_Electrical_Digital_Examples_FlipFlop():
buildModelFMU("Modelica.Electrical.Digital.Examples.FlipFlop")
def test_Modelica_Mechanics_Rotational_Examples_FirstGrounded():
buildModelFMU("Modelica.Mechanics.Rotational.Examples.FirstGrounded")
def test_Modelica_Mechanics_Rotational_Examples_CoupledClutches():
buildModelFMU("Modelica.Mechanics.Rotational.Examples.CoupledClutches")
def test_Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum():
buildModelFMU("Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum")
def test_Modelica_Mechanics_MultiBody_Examples_Elementary_FreeBody():
buildModelFMU("Modelica.Mechanics.MultiBody.Examples.Elementary.FreeBody")
def test_Modelica_Fluid_Examples_PumpingSystem():
buildModelFMU("Modelica.Fluid.Examples.PumpingSystem")
def test_Modelica_Fluid_Examples_TraceSubstances_RoomCO2WithControls():
buildModelFMU("Modelica.Fluid.Examples.TraceSubstances.RoomCO2WithControls")
def test_Modelica_Clocked_Examples_SimpleControlledDrive_ClockedWithDiscreteTextbookController():
buildModelFMU("Modelica.Clocked.Examples.SimpleControlledDrive.ClockedWithDiscreteTextbookController")