2323 OMCSessionException ,
2424 OMCSessionRunData ,
2525 OMCSessionZMQ ,
26- OMCProcess ,
27- OMCProcessLocal ,
26+ OMCSession ,
27+ OMCSessionLocal ,
2828 OMCPath ,
2929)
3030
@@ -304,7 +304,7 @@ def __init__(
304304 command_line_options : Optional [list [str ]] = None ,
305305 work_directory : Optional [str | os .PathLike ] = None ,
306306 omhome : Optional [str ] = None ,
307- omc_process : Optional [OMCProcess ] = None ,
307+ session : Optional [OMCSession ] = None ,
308308 ) -> None :
309309 """Create a ModelicaSystem instance. To define the model use model() or convertFmu2Mo().
310310
@@ -316,7 +316,7 @@ def __init__(
316316 files like the model executable. If left unspecified, a tmp
317317 directory will be created.
318318 omhome: path to OMC to be used when creating the OMC session (see OMCSessionZMQ).
319- omc_process : definition of a (local) OMC process to be used. If
319+ session : definition of a (local) OMC session to be used. If
320320 unspecified, a new local session will be created.
321321 """
322322
@@ -344,8 +344,8 @@ def __init__(
344344 self ._linearized_outputs : list [str ] = [] # linearization output list
345345 self ._linearized_states : list [str ] = [] # linearization states list
346346
347- if omc_process is not None :
348- self ._session = OMCSessionZMQ (omc_process = omc_process )
347+ if session is not None :
348+ self ._session = OMCSessionZMQ (omc_process = session )
349349 else :
350350 self ._session = OMCSessionZMQ (omhome = omhome )
351351
@@ -432,13 +432,13 @@ def model(
432432 if model_file is not None :
433433 file_path = pathlib .Path (model_file )
434434 # special handling for OMCProcessLocal - consider a relative path
435- if isinstance (self ._session .omc_process , OMCProcessLocal ) and not file_path .is_absolute ():
435+ if isinstance (self ._session .omc_process , OMCSessionLocal ) and not file_path .is_absolute ():
436436 file_path = pathlib .Path .cwd () / file_path
437437 if not file_path .is_file ():
438438 raise IOError (f"Model file { file_path } does not exist!" )
439439
440440 self ._file_name = self .getWorkDirectory () / file_path .name
441- if (isinstance (self ._session .omc_process , OMCProcessLocal )
441+ if (isinstance (self ._session .omc_process , OMCSessionLocal )
442442 and file_path .as_posix () == self ._file_name .as_posix ()):
443443 pass
444444 elif self ._file_name .is_file ():
@@ -453,7 +453,7 @@ def model(
453453 if build :
454454 self .buildModel (variable_filter )
455455
456- def session (self ) -> OMCSessionZMQ :
456+ def get_session (self ) -> OMCSessionZMQ :
457457 """
458458 Return the OMC session used for this class.
459459 """
@@ -1168,7 +1168,7 @@ def plot(
11681168 plot is created by OMC which needs access to the local display. This is not the case for docker and WSL.
11691169 """
11701170
1171- if not isinstance (self ._session .omc_process , OMCProcessLocal ):
1171+ if not isinstance (self ._session .omc_process , OMCSessionLocal ):
11721172 raise ModelicaSystemError ("Plot is using the OMC plot functionality; "
11731173 "thus, it is only working if OMC is running locally!" )
11741174
@@ -1925,7 +1925,7 @@ def __init__(
19251925 variable_filter : Optional [str ] = None ,
19261926 work_directory : Optional [str | os .PathLike ] = None ,
19271927 omhome : Optional [str ] = None ,
1928- omc_process : Optional [OMCProcess ] = None ,
1928+ session : Optional [OMCSession ] = None ,
19291929 # simulation specific input
19301930 # TODO: add more settings (simulation options, input options, ...)
19311931 simargs : Optional [dict [str , Optional [str | dict [str , str ] | numbers .Number ]]] = None ,
@@ -1945,7 +1945,7 @@ def __init__(
19451945 command_line_options = command_line_options ,
19461946 work_directory = work_directory ,
19471947 omhome = omhome ,
1948- omc_process = omc_process ,
1948+ session = session ,
19491949 )
19501950 self ._mod .model (
19511951 model_file = model_file ,
@@ -1959,9 +1959,9 @@ def __init__(
19591959 self ._simargs = simargs
19601960
19611961 if resultpath is None :
1962- self ._resultpath = self .session ().omcpath_tempdir ()
1962+ self ._resultpath = self .get_session ().omcpath_tempdir ()
19631963 else :
1964- self ._resultpath = self .session ().omcpath (resultpath )
1964+ self ._resultpath = self .get_session ().omcpath (resultpath )
19651965 if not self ._resultpath .is_dir ():
19661966 raise ModelicaSystemError ("Argument resultpath must be set to a valid path within the environment used "
19671967 f"for the OpenModelica session: { resultpath } !" )
@@ -1974,11 +1974,11 @@ def __init__(
19741974 self ._doe_def : Optional [dict [str , dict [str , Any ]]] = None
19751975 self ._doe_cmd : Optional [dict [str , OMCSessionRunData ]] = None
19761976
1977- def session (self ) -> OMCSessionZMQ :
1977+ def get_session (self ) -> OMCSessionZMQ :
19781978 """
19791979 Return the OMC session used for this class.
19801980 """
1981- return self ._mod .session ()
1981+ return self ._mod .get_session ()
19821982
19831983 def prepare (self ) -> int :
19841984 """
@@ -2017,7 +2017,7 @@ def prepare(self) -> int:
20172017
20182018 pk_value = pc_structure [idx_structure ]
20192019 if isinstance (pk_value , str ):
2020- pk_value_str = self .session ().escape_str (pk_value )
2020+ pk_value_str = self .get_session ().escape_str (pk_value )
20212021 expression = f"setParameterValue({ self ._model_name } , { pk_structure } , \" { pk_value_str } \" )"
20222022 elif isinstance (pk_value , bool ):
20232023 pk_value_bool_str = "true" if pk_value else "false"
@@ -2138,12 +2138,12 @@ def worker(worker_id, task_queue):
21382138 raise ModelicaSystemError ("Missing simulation definition!" )
21392139
21402140 resultfile = cmd_definition .cmd_result_path
2141- resultpath = self .session ().omcpath (resultfile )
2141+ resultpath = self .get_session ().omcpath (resultfile )
21422142
21432143 logger .info (f"[Worker { worker_id } ] Performing task: { resultpath .name } " )
21442144
21452145 try :
2146- returncode = self .session ().run_model_executable (cmd_run_data = cmd_definition )
2146+ returncode = self .get_session ().run_model_executable (cmd_run_data = cmd_definition )
21472147 logger .info (f"[Worker { worker_id } ] Simulation { resultpath .name } "
21482148 f"finished with return code: { returncode } " )
21492149 except ModelicaSystemError as ex :
0 commit comments