Skip to content
Merged
Changes from all commits
Commits
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
21 changes: 8 additions & 13 deletions OMPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ class ModelicaSystem(object):
def __init__(self, fileName=None, modelName=None, lmodel=None,
useCorba=False, commandLineOptions=None,
variableFilter=None, customBuildDirectory=None, verbose=True, raiseerrors=False,
omhome: str = None): # 1
omhome: str = None, session: OMCSessionBase = None): # 1
"""
"constructor"
It initializes to load file and build a model, generating object, exe, xml, mat, and json files. etc. It can be called :
Expand All @@ -831,11 +831,14 @@ def __init__(self, fileName=None, modelName=None, lmodel=None,
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.
ex: myModel = ModelicaSystem("ModelicaModel.mo", "modelName")
"""
if session is not None:
self.getconn = session
elif useCorba:
self.getconn = OMCSession(omhome=omhome)
else:
self.getconn = OMCSessionZMQ(omhome=omhome)

if fileName is None and modelName is None and not lmodel: # all None
if useCorba:
self.getconn = OMCSession(omhome=omhome)
else:
self.getconn = OMCSessionZMQ(omhome=omhome)
return

self.tree = None
Expand All @@ -857,11 +860,6 @@ def __init__(self, fileName=None, modelName=None, lmodel=None,

self._verbose = verbose

if useCorba:
self.getconn = OMCSession(omhome=omhome)
else:
self.getconn = OMCSessionZMQ(omhome=omhome)

## needed for properly deleting the OMCSessionZMQ
self._omc_log_file = self.getconn._omc_log_file
self._omc_process = self.getconn._omc_process
Expand Down Expand Up @@ -906,9 +904,6 @@ def __init__(self, fileName=None, modelName=None, lmodel=None,

self.buildModel(variableFilter)

def __del__(self):
OMCSessionBase.__del__(self)

def setCommandLineOptions(self, commandLineOptions: str):
## set commandLineOptions if provided by users
if commandLineOptions is not None:
Expand Down