Skip to content

Commit b749545

Browse files
committed
[ModelicaSystem*] remove dependency on depreciated OMCSessionZMQ
1 parent f9e6304 commit b749545

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

OMPython/ModelicaSystem.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from OMPython.OMCSession import (
2323
OMCSessionException,
2424
OMCSessionRunData,
25-
OMCSessionZMQ,
2625
OMCSession,
2726
OMCSessionLocal,
2827
OMCPath,
@@ -98,7 +97,7 @@ class ModelicaSystemCmd:
9897

9998
def __init__(
10099
self,
101-
session: OMCSessionZMQ,
100+
session: OMCSession,
102101
runpath: OMCPath,
103102
modelname: Optional[str] = None,
104103
) -> None:
@@ -296,7 +295,7 @@ def parse_simflags(simflags: str) -> dict[str, Optional[str | dict[str, Any] | n
296295

297296
class ModelicaSystem:
298297
"""
299-
Class to simulate a Modelica model using OpenModelica via OMCSessionZMQ.
298+
Class to simulate a Modelica model using OpenModelica via OMCSession.
300299
"""
301300

302301
def __init__(
@@ -315,7 +314,7 @@ def __init__(
315314
work_directory: Path to a directory to be used for temporary
316315
files like the model executable. If left unspecified, a tmp
317316
directory will be created.
318-
omhome: path to OMC to be used when creating the OMC session (see OMCSessionZMQ).
317+
omhome: path to OMC to be used when creating the OMC session (see OMCSession).
319318
session: definition of a (local) OMC session to be used. If
320319
unspecified, a new local session will be created.
321320
"""
@@ -345,9 +344,9 @@ def __init__(
345344
self._linearized_states: list[str] = [] # linearization states list
346345

347346
if session is not None:
348-
self._session = OMCSessionZMQ(omc_process=session)
347+
self._session = session
349348
else:
350-
self._session = OMCSessionZMQ(omhome=omhome)
349+
self._session = OMCSession(omhome=omhome)
351350

352351
# set commandLineOptions using default values or the user defined list
353352
if command_line_options is None:
@@ -432,13 +431,13 @@ def model(
432431
if model_file is not None:
433432
file_path = pathlib.Path(model_file)
434433
# special handling for OMCProcessLocal - consider a relative path
435-
if isinstance(self._session.omc_process, OMCSessionLocal) and not file_path.is_absolute():
434+
if isinstance(self._session, OMCSessionLocal) and not file_path.is_absolute():
436435
file_path = pathlib.Path.cwd() / file_path
437436
if not file_path.is_file():
438437
raise IOError(f"Model file {file_path} does not exist!")
439438

440439
self._file_name = self.getWorkDirectory() / file_path.name
441-
if (isinstance(self._session.omc_process, OMCSessionLocal)
440+
if (isinstance(self._session, OMCSessionLocal)
442441
and file_path.as_posix() == self._file_name.as_posix()):
443442
pass
444443
elif self._file_name.is_file():
@@ -453,7 +452,7 @@ def model(
453452
if build:
454453
self.buildModel(variable_filter)
455454

456-
def get_session(self) -> OMCSessionZMQ:
455+
def get_session(self) -> OMCSession:
457456
"""
458457
Return the OMC session used for this class.
459458
"""
@@ -1168,7 +1167,7 @@ def plot(
11681167
plot is created by OMC which needs access to the local display. This is not the case for docker and WSL.
11691168
"""
11701169

1171-
if not isinstance(self._session.omc_process, OMCSessionLocal):
1170+
if not isinstance(self._session, OMCSessionLocal):
11721171
raise ModelicaSystemError("Plot is using the OMC plot functionality; "
11731172
"thus, it is only working if OMC is running locally!")
11741173

@@ -1974,7 +1973,7 @@ def __init__(
19741973
self._doe_def: Optional[dict[str, dict[str, Any]]] = None
19751974
self._doe_cmd: Optional[dict[str, OMCSessionRunData]] = None
19761975

1977-
def get_session(self) -> OMCSessionZMQ:
1976+
def get_session(self) -> OMCSession:
19781977
"""
19791978
Return the OMC session used for this class.
19801979
"""

0 commit comments

Comments
 (0)