Skip to content

Commit 8bdb86a

Browse files
committed
[OMCSessionRunData] add new class to store all information about a model executable
1 parent ad91868 commit 8bdb86a

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

OMPython/OMCSession.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
CONDITIONS OF OSMC-PL.
3535
"""
3636

37+
import dataclasses
3738
import io
3839
import json
3940
import logging
@@ -271,6 +272,48 @@ def getClassNames(self, className=None, recursive=False, qualified=False, sort=F
271272
return self._ask(question='getClassNames', opt=opt)
272273

273274

275+
@dataclasses.dataclass
276+
class OMCSessionRunData:
277+
# TODO: rename OMCExcecutableModelData
278+
"""
279+
Data class to store the command line data for running a model executable in the OMC environment.
280+
281+
All data should be defined for the environment, where OMC is running (local, docker or WSL)
282+
"""
283+
# cmd_path is the expected working directory
284+
cmd_path: str
285+
cmd_model_name: str
286+
# command line arguments for the model executable
287+
cmd_args: list[str]
288+
# result file with the simulation output
289+
cmd_result_path: str
290+
291+
# command prefix data (as list of strings); needed for docker or WSL
292+
cmd_prefix: Optional[list[str]] = None
293+
# cmd_model_executable is build out of cmd_path and cmd_model_name; this is mainly needed on Windows (add *.exe)
294+
cmd_model_executable: Optional[str] = None
295+
# additional library search path; this is mainly needed if OMCProcessLocal is run on Windows
296+
cmd_library_path: Optional[str] = None
297+
# command timeout
298+
cmd_timeout: Optional[float] = 10.0
299+
300+
# working directory to be used on the *local* system
301+
cmd_cwd_local: Optional[str] = None
302+
303+
def get_cmd(self) -> list[str]:
304+
"""
305+
Get the command line to run the model executable in the environment defined by the OMCProcess definition.
306+
"""
307+
308+
if self.cmd_model_executable is None:
309+
raise OMCSessionException("No model file defined for the model executable!")
310+
311+
cmdl = [] if self.cmd_prefix is None else self.cmd_prefix
312+
cmdl += [self.cmd_model_executable] + self.cmd_args
313+
314+
return cmdl
315+
316+
274317
class OMCSessionZMQ:
275318

276319
def __init__(

0 commit comments

Comments
 (0)