Skip to content

Commit b1b2d50

Browse files
committed
[ModelicaSystem*] remove dependency on depreciated OMCSessionZMQ
1 parent 0ad6c85 commit b1b2d50

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
timeout: Optional[float] = None,
@@ -328,7 +327,7 @@ def parse_simflags(simflags: str) -> dict[str, Optional[str | dict[str, Any] | n
328327

329328
class ModelicaSystem:
330329
"""
331-
Class to simulate a Modelica model using OpenModelica via OMCSessionZMQ.
330+
Class to simulate a Modelica model using OpenModelica via OMCSession.
332331
"""
333332

334333
def __init__(
@@ -347,7 +346,7 @@ def __init__(
347346
work_directory: Path to a directory to be used for temporary
348347
files like the model executable. If left unspecified, a tmp
349348
directory will be created.
350-
omhome: path to OMC to be used when creating the OMC session (see OMCSessionZMQ).
349+
omhome: path to OMC to be used when creating the OMC session (see OMCSession).
351350
session: definition of a (local) OMC session to be used. If
352351
unspecified, a new local session will be created.
353352
"""
@@ -377,9 +376,9 @@ def __init__(
377376
self._linearized_states: list[str] = [] # linearization states list
378377

379378
if session is not None:
380-
self._session = OMCSessionZMQ(omc_process=session)
379+
self._session = session
381380
else:
382-
self._session = OMCSessionZMQ(omhome=omhome)
381+
self._session = OMCSession(omhome=omhome)
383382

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

472471
self._file_name = self.getWorkDirectory() / file_path.name
473-
if (isinstance(self._session.omc_process, OMCSessionLocal)
472+
if (isinstance(self._session, OMCSessionLocal)
474473
and file_path.as_posix() == self._file_name.as_posix()):
475474
pass
476475
elif self._file_name.is_file():
@@ -485,7 +484,7 @@ def model(
485484
if build:
486485
self.buildModel(variable_filter)
487486

488-
def get_session(self) -> OMCSessionZMQ:
487+
def get_session(self) -> OMCSession:
489488
"""
490489
Return the OMC session used for this class.
491490
"""
@@ -1207,7 +1206,7 @@ def plot(
12071206
plot is created by OMC which needs access to the local display. This is not the case for docker and WSL.
12081207
"""
12091208

1210-
if not isinstance(self._session.omc_process, OMCSessionLocal):
1209+
if not isinstance(self._session, OMCSessionLocal):
12111210
raise ModelicaSystemError("Plot is using the OMC plot functionality; "
12121211
"thus, it is only working if OMC is running locally!")
12131212

@@ -2018,7 +2017,7 @@ def __init__(
20182017
self._doe_def: Optional[dict[str, dict[str, Any]]] = None
20192018
self._doe_cmd: Optional[dict[str, OMCSessionRunData]] = None
20202019

2021-
def get_session(self) -> OMCSessionZMQ:
2020+
def get_session(self) -> OMCSession:
20222021
"""
20232022
Return the OMC session used for this class.
20242023
"""

0 commit comments

Comments
 (0)