Skip to content

[ModelicaSystem] only local omc process allowed #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import warnings
import xml.etree.ElementTree as ET

from OMPython.OMCSession import OMCSessionException, OMCSessionZMQ
from OMPython.OMCSession import OMCSessionException, OMCSessionZMQ, OMCProcessLocal

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

if session is not None:
if not isinstance(session, OMCSessionZMQ):
raise ModelicaSystemError("Invalid session data provided!")
self.getconn = session
if omc_process is not None:
if not isinstance(omc_process, OMCProcessLocal):
raise ModelicaSystemError("Invalid (local) omc process definition provided!")
self.getconn = OMCSessionZMQ(omc_process=omc_process)
else:
self.getconn = OMCSessionZMQ(omhome=omhome)

Expand Down
Loading