Skip to content

Commit 31ce3d2

Browse files
committed
[ModelicaSystem] define convertFmu2Mo() as entry point like definition()
* rename fmuName => fmu
1 parent ae4f19d commit 31ce3d2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

OMPython/ModelicaSystem.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,16 +1579,17 @@ def convertMo2Fmu(
15791579
# to convert FMU to Modelica model
15801580
def convertFmu2Mo(
15811581
self,
1582-
fmuName: os.PathLike,
1582+
fmu: os.PathLike,
15831583
) -> pathlib.Path:
15841584
"""
1585-
In order to load FMU, at first it needs to be translated into Modelica model. This method is used to generate Modelica model from the given FMU. It generates "fmuName_me_FMU.mo".
1585+
In order to load FMU, at first it needs to be translated into Modelica model. This method is used to generate
1586+
Modelica model from the given FMU. It generates "fmuName_me_FMU.mo".
15861587
Currently, it only supports Model Exchange conversion.
15871588
usage
15881589
>>> convertFmu2Mo("c:/BouncingBall.Fmu")
15891590
"""
15901591

1591-
fmu_path = pathlib.Path(fmuName)
1592+
fmu_path = pathlib.Path(fmu)
15921593

15931594
filename = self._requestApi(apiName='importFMU', entity=fmu_path.as_posix())
15941595
filepath = pathlib.Path(filename)
@@ -1597,6 +1598,11 @@ def convertFmu2Mo(
15971598
if not filepath.is_file():
15981599
raise ModelicaSystemError(f"Missing file {filepath.as_posix()}")
15991600

1601+
self.model(
1602+
name=f"{fmu_path.stem}_me_FMU",
1603+
file=filepath,
1604+
)
1605+
16001606
return filepath
16011607

16021608
def optimize(self) -> dict[str, Any]:

0 commit comments

Comments
 (0)