Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for initializing and terminating ME FMUs #295

Merged
merged 20 commits into from
Feb 25, 2025
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
afceb10
Added work in progress
modelonrobinandersson Feb 14, 2025
da8d9fb
More work in progress
modelonrobinandersson Feb 17, 2025
bc75c62
Added work in progress, DLL is connected and seems to work
modelonrobinandersson Feb 17, 2025
ba62c2e
M Fixed blank spaces
modelonrobinandersson Feb 17, 2025
9e20406
Removed print-statement, added simple test
modelonrobinandersson Feb 17, 2025
0bf19b6
Fixed some issues with callbacks and added another test
modelonrobinandersson Feb 18, 2025
8a46013
Added instantiation and test for instantiation
modelonrobinandersson Feb 18, 2025
732ba1f
Added support for initializing FMI3 ME FMUs
modelonrobinandersson Feb 19, 2025
3f1939e
Fixed readability and docstrings
modelonrobinandersson Feb 19, 2025
a0ef9a7
Fixed issue with redeclared variable
modelonrobinandersson Feb 19, 2025
a4ac66b
Added some blank spaces
modelonrobinandersson Feb 19, 2025
2b3b66e
Fixed review comments
modelonrobinandersson Feb 20, 2025
90e950a
Implemented reset fully, added terminate, free and destroy dll
modelonrobinandersson Feb 20, 2025
eed36b2
Updated init test to also use reset and terminate
modelonrobinandersson Feb 20, 2025
79f032b
Added tests for enter continuous time mode and enter event mode
modelonrobinandersson Feb 21, 2025
b5887de
Improved handling of model identifier
modelonrobinandersson Feb 24, 2025
d9ae5a4
Added test for illegal call sequence
modelonrobinandersson Feb 24, 2025
6e58cb5
Added more tests
modelonrobinandersson Feb 24, 2025
bd8d8ad
Updated build.yml to use latest FMIL
modelonrobinandersson Feb 24, 2025
fdfca59
Removed some unnecessary newlines
modelonrobinandersson Feb 24, 2025
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
12 changes: 7 additions & 5 deletions src/pyfmi/fmi3.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ cdef class FMUModelBase3(FMI_BASE.ModelBase):
self._allocated_dll = 1

# Note that below, values are retrieved from XML (via FMIL) if .dll/.so is not connected
if self._fmu_kind & FMIL3.fmi3_fmu_kind_me:
self._modelId= pyfmi_util.decode(FMIL3.fmi3_import_get_model_identifier_ME(self._fmu))
else:
raise NotImplementedError(f"FMUModelBase3 only supports FMU type 'Model Exchange'")
self._modelId = self.get_identifier()

self._modelName = pyfmi_util.decode(FMIL3.fmi3_import_get_model_name(self._fmu))

Expand Down Expand Up @@ -348,7 +345,7 @@ cdef class FMUModelBase3(FMI_BASE.ModelBase):
""" Return the model identifier, name of binary model file and prefix in
the C-function names of the model.
"""
return self._modelId
return NotImplementedError

def get_default_experiment_start_time(self):
""" Returns the default experiment start time as defined the XML description. """
Expand Down Expand Up @@ -425,6 +422,11 @@ cdef class FMUModelME3(FMUModelBase3):
else:
raise InvalidVersionException('The FMU could not be loaded. This class only supports FMI 3.0 for Model Exchange.')

def get_identifier(self):
if not self._modelId:
self._modelId = pyfmi_util.decode(FMIL3.fmi3_import_get_model_identifier_ME(self._fmu))

return self._modelId

def instantiate(self, name: str = 'Model', visible: bool = False) -> None:
"""
Expand Down
Loading