Skip to content

Commit bf0262b

Browse files
committed
Merge remote-tracking branch 'origin' into remove-corba
2 parents c039c90 + 3ba72b0 commit bf0262b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.github/workflows/FMITest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
- uses: actions/checkout@v4
3232
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v4
33+
uses: actions/setup-python@v5
3434
with:
3535
python-version: ${{ matrix.python-version }}
3636
architecture: 'x64'

OMPython/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ class ModelicaSystemError(Exception):
678678
class ModelicaSystem(object):
679679
def __init__(self, fileName=None, modelName=None, lmodel=None, commandLineOptions=None,
680680
variableFilter=None, customBuildDirectory=None, verbose=True, raiseerrors=False,
681-
omhome: str = None): # 1
681+
omhome: str = None, session: OMCSessionBase = None): # 1
682682
"""
683683
"constructor"
684684
It initializes to load file and build a model, generating object, exe, xml, mat, and json files. etc. It can be called :
@@ -688,6 +688,11 @@ def __init__(self, fileName=None, modelName=None, lmodel=None, commandLineOption
688688
Note: If the model file is not in the current working directory, then the path where file is located must be included together with file name. Besides, if the Modelica model contains several different models within the same package, then in order to build the specific model, in second argument, user must put the package name with dot(.) followed by specific model name.
689689
ex: myModel = ModelicaSystem("ModelicaModel.mo", "modelName")
690690
"""
691+
if session is not None:
692+
self.getconn = session
693+
else:
694+
self.getconn = OMCSession(omhome=omhome)
695+
691696
if fileName is None and modelName is None and not lmodel: # all None
692697
self.getconn = OMCSession(omhome=omhome)
693698
return
@@ -757,9 +762,6 @@ def __init__(self, fileName=None, modelName=None, lmodel=None, commandLineOption
757762

758763
self.buildModel(variableFilter)
759764

760-
def __del__(self):
761-
OMCSessionBase.__del__(self)
762-
763765
def setCommandLineOptions(self, commandLineOptions: str):
764766
## set commandLineOptions if provided by users
765767
if commandLineOptions is not None:

0 commit comments

Comments
 (0)