Skip to content

Commit fc04903

Browse files
committed
[ModelicaSystem*] remove dependency on depreciated OMCSessionZMQ
1 parent fa448ea commit fc04903

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
from OMPython.OMCSession import (
5252
OMCSessionException,
5353
OMCSessionRunData,
54-
OMCSessionZMQ,
5554
OMCSession,
5655
OMCSessionLocal,
5756
OMCPath,
@@ -127,7 +126,7 @@ class ModelicaSystemCmd:
127126

128127
def __init__(
129128
self,
130-
session: OMCSessionZMQ,
129+
session: OMCSession,
131130
runpath: OMCPath,
132131
modelname: Optional[str] = None,
133132
) -> None:
@@ -325,7 +324,7 @@ def parse_simflags(simflags: str) -> dict[str, Optional[str | dict[str, Any] | n
325324

326325
class ModelicaSystem:
327326
"""
328-
Class to simulate a Modelica model using OpenModelica via OMCSessionZMQ.
327+
Class to simulate a Modelica model using OpenModelica via OMCSession.
329328
"""
330329

331330
def __init__(
@@ -344,7 +343,7 @@ def __init__(
344343
work_directory: Path to a directory to be used for temporary
345344
files like the model executable. If left unspecified, a tmp
346345
directory will be created.
347-
omhome: path to OMC to be used when creating the OMC session (see OMCSessionZMQ).
346+
omhome: path to OMC to be used when creating the OMC session (see OMCSession).
348347
session: definition of a (local) OMC session to be used. If
349348
unspecified, a new local session will be created.
350349
"""
@@ -374,9 +373,9 @@ def __init__(
374373
self._linearized_states: list[str] = [] # linearization states list
375374

376375
if session is not None:
377-
self._session = OMCSessionZMQ(omc_process=session)
376+
self._session = session
378377
else:
379-
self._session = OMCSessionZMQ(omhome=omhome)
378+
self._session = OMCSession(omhome=omhome)
380379

381380
# set commandLineOptions using default values or the user defined list
382381
if command_line_options is None:
@@ -461,13 +460,13 @@ def model(
461460
if model_file is not None:
462461
file_path = pathlib.Path(model_file)
463462
# special handling for OMCProcessLocal - consider a relative path
464-
if isinstance(self._session.omc_process, OMCSessionLocal) and not file_path.is_absolute():
463+
if isinstance(self._session, OMCSessionLocal) and not file_path.is_absolute():
465464
file_path = pathlib.Path.cwd() / file_path
466465
if not file_path.is_file():
467466
raise IOError(f"Model file {file_path} does not exist!")
468467

469468
self._file_name = self.getWorkDirectory() / file_path.name
470-
if (isinstance(self._session.omc_process, OMCSessionLocal)
469+
if (isinstance(self._session, OMCSessionLocal)
471470
and file_path.as_posix() == self._file_name.as_posix()):
472471
pass
473472
elif self._file_name.is_file():
@@ -482,7 +481,7 @@ def model(
482481
if build:
483482
self.buildModel(variable_filter)
484483

485-
def get_session(self) -> OMCSessionZMQ:
484+
def get_session(self) -> OMCSession:
486485
"""
487486
Return the OMC session used for this class.
488487
"""
@@ -1197,7 +1196,7 @@ def plot(
11971196
plot is created by OMC which needs access to the local display. This is not the case for docker and WSL.
11981197
"""
11991198

1200-
if not isinstance(self._session.omc_process, OMCSessionLocal):
1199+
if not isinstance(self._session, OMCSessionLocal):
12011200
raise ModelicaSystemError("Plot is using the OMC plot functionality; "
12021201
"thus, it is only working if OMC is running locally!")
12031202

@@ -2003,7 +2002,7 @@ def __init__(
20032002
self._doe_def: Optional[dict[str, dict[str, Any]]] = None
20042003
self._doe_cmd: Optional[dict[str, OMCSessionRunData]] = None
20052004

2006-
def get_session(self) -> OMCSessionZMQ:
2005+
def get_session(self) -> OMCSession:
20072006
"""
20082007
Return the OMC session used for this class.
20092008
"""

0 commit comments

Comments
 (0)