Skip to content

Commit fdd63e8

Browse files
committed
[ModelicaSystem] limit to local OMC process
1 parent d585207 commit fdd63e8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

OMPython/ModelicaSystem.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import warnings
5050
import xml.etree.ElementTree as ET
5151

52-
from OMPython.OMCSession import OMCSessionException, OMCSessionZMQ
52+
from OMPython.OMCSession import OMCSessionException, OMCSessionZMQ, OMCProcessLocal
5353

5454
# define logger using the current module name as ID
5555
logger = logging.getLogger(__name__)
@@ -332,7 +332,7 @@ def __init__(
332332
variableFilter: Optional[str] = None,
333333
customBuildDirectory: Optional[str | os.PathLike | pathlib.Path] = None,
334334
omhome: Optional[str] = None,
335-
session: Optional[OMCSessionZMQ] = None,
335+
omc_process: Optional[OMCProcessLocal] = None,
336336
build: bool = True,
337337
) -> None:
338338
"""Initialize, load and build a model.
@@ -360,8 +360,8 @@ def __init__(
360360
directory will be created.
361361
omhome: OPENMODELICAHOME value to be used when creating the OMC
362362
session.
363-
session: OMC session to be used. If unspecified, a new session
364-
will be created.
363+
omc_process: definition of a (local) OMC process to be used. If
364+
unspecified, a new local session will be created.
365365
build: Boolean controlling whether or not the model should be
366366
built when constructor is called. If False, the constructor
367367
simply loads the model without compiling.
@@ -396,10 +396,10 @@ def __init__(
396396
self.linearoutputs: list[str] = [] # linearization output list
397397
self.linearstates: list[str] = [] # linearization states list
398398

399-
if session is not None:
400-
if not isinstance(session, OMCSessionZMQ):
401-
raise ModelicaSystemError("Invalid session data provided!")
402-
self.getconn = session
399+
if omc_process is not None:
400+
if not isinstance(omc_process, OMCProcessLocal):
401+
raise ModelicaSystemError("Invalid (local) omc process definition provided!")
402+
self.getconn = OMCSessionZMQ(omc_process=omc_process)
403403
else:
404404
self.getconn = OMCSessionZMQ(omhome=omhome)
405405

0 commit comments

Comments
 (0)