|
34 | 34 | CONDITIONS OF OSMC-PL. |
35 | 35 | """ |
36 | 36 |
|
| 37 | +import dataclasses |
37 | 38 | import io |
38 | 39 | import json |
39 | 40 | import logging |
@@ -456,6 +457,48 @@ class OMCPathCompatibilityWindows(pathlib.WindowsPath, OMCPathCompatibility): |
456 | 457 | OMCPath = OMCPathReal |
457 | 458 |
|
458 | 459 |
|
| 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 | + |
459 | 502 | class OMCSessionZMQ: |
460 | 503 |
|
461 | 504 | def __init__( |
|
0 commit comments