|
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 |
@@ -271,6 +272,48 @@ def getClassNames(self, className=None, recursive=False, qualified=False, sort=F |
271 | 272 | return self._ask(question='getClassNames', opt=opt) |
272 | 273 |
|
273 | 274 |
|
| 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 | + |
274 | 317 | class OMCSessionZMQ: |
275 | 318 |
|
276 | 319 | def __init__( |
|
0 commit comments