Skip to content

Commit e94f822

Browse files
committed
[OMCSessionRunData] add new class to store all information about a model executable
1 parent 3e9c55b commit e94f822

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
@@ -268,6 +269,48 @@ def getClassNames(self, className=None, recursive=False, qualified=False, sort=F
268269
return self._ask(question='getClassNames', opt=opt)
269270

270271

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

273316
def __init__(

0 commit comments

Comments
 (0)