Skip to content

Commit a6bbdba

Browse files
committed
[OMCSessionRunData] add new class to store all information about a model executable
1 parent 07eb621 commit a6bbdba

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
@@ -456,6 +457,48 @@ class OMCPathCompatibilityWindows(pathlib.WindowsPath, OMCPathCompatibility):
456457
OMCPath = OMCPathReal
457458

458459

460+
@dataclasses.dataclass
461+
class OMCSessionRunData:
462+
# TODO: rename OMCExcecutableModelData
463+
"""
464+
Data class to store the command line data for running a model executable in the OMC environment.
465+
466+
All data should be defined for the environment, where OMC is running (local, docker or WSL)
467+
"""
468+
# cmd_path is the expected working directory
469+
cmd_path: str
470+
cmd_model_name: str
471+
# command line arguments for the model executable
472+
cmd_args: list[str]
473+
# result file with the simulation output
474+
cmd_result_path: str
475+
476+
# command prefix data (as list of strings); needed for docker or WSL
477+
cmd_prefix: Optional[list[str]] = None
478+
# cmd_model_executable is build out of cmd_path and cmd_model_name; this is mainly needed on Windows (add *.exe)
479+
cmd_model_executable: Optional[str] = None
480+
# additional library search path; this is mainly needed if OMCProcessLocal is run on Windows
481+
cmd_library_path: Optional[str] = None
482+
# command timeout
483+
cmd_timeout: Optional[float] = 10.0
484+
485+
# working directory to be used on the *local* system
486+
cmd_cwd_local: Optional[str] = None
487+
488+
def get_cmd(self) -> list[str]:
489+
"""
490+
Get the command line to run the model executable in the environment defined by the OMCProcess definition.
491+
"""
492+
493+
if self.cmd_model_executable is None:
494+
raise OMCSessionException("No model file defined for the model executable!")
495+
496+
cmdl = [] if self.cmd_prefix is None else self.cmd_prefix
497+
cmdl += [self.cmd_model_executable] + self.cmd_args
498+
499+
return cmdl
500+
501+
459502
class OMCSessionZMQ:
460503

461504
def __init__(

0 commit comments

Comments
 (0)