Skip to content

Commit b23684e

Browse files
committed
[ModelicaSystemCmd] use OMCPath for file system interactions
1 parent 009b354 commit b23684e

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

OMPython/OMCSession.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -458,18 +458,18 @@ class OMCPathCompatibilityWindows(pathlib.WindowsPath, OMCPathCompatibility):
458458

459459
@dataclasses.dataclass
460460
class OMCSessionRunData:
461-
# TODO: rename OMCExcecutableModelData
462461
"""
463462
Data class to store the command line data for running a model executable in the OMC environment.
464463
465464
All data should be defined for the environment, where OMC is running (local, docker or WSL)
466465
"""
467-
# cmd_path is the expected working directory
466+
# cmd_path is based on the selected OMCProcess definition
468467
cmd_path: str
469468
cmd_model_name: str
470469
# command line arguments for the model executable
471470
cmd_args: list[str]
472471
# result file with the simulation output
472+
# cmd_result_path is based on the selected OMCProcess definition
473473
cmd_result_path: str
474474

475475
# command prefix data (as list of strings); needed for docker or WSL
@@ -598,13 +598,13 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMCPath:
598598

599599
return tempdir
600600

601-
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
601+
def omc_run_data_update(self, omc_run_data: OMCSessionRunData, session: OMCSessionZMQ) -> OMCSessionRunData:
602602
"""
603603
Modify data based on the selected OMCProcess implementation.
604604
605605
Needs to be implemented in the subclasses.
606606
"""
607-
return self.omc_process.omc_run_data_update(omc_run_data=omc_run_data)
607+
return self.omc_process.omc_run_data_update(omc_run_data=omc_run_data, session=self)
608608

609609
@staticmethod
610610
def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
@@ -652,8 +652,11 @@ def execute(self, command: str):
652652
return self.sendExpression(command, parsed=False)
653653

654654
def sendExpression(self, command: str, parsed: bool = True) -> Any:
655+
"""
656+
Send an expression to the OMC server and return the result.
657+
"""
655658
if self.omc_zmq is None:
656-
raise OMCSessionException("No OMC running. Create a new instance of OMCSessionZMQ!")
659+
raise OMCSessionException("No OMC running. Create a new instance of OMCProcess!")
657660

658661
logger.debug("sendExpression(%r, parsed=%r)", command, parsed)
659662

@@ -831,7 +834,7 @@ def _get_portfile_path(self) -> Optional[pathlib.Path]:
831834
return portfile_path
832835

833836
@abc.abstractmethod
834-
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
837+
def omc_run_data_update(self, omc_run_data: OMCSessionRunData, session: OMCSessionZMQ) -> OMCSessionRunData:
835838
"""
836839
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
837840
@@ -849,7 +852,7 @@ def __init__(
849852
super().__init__()
850853
self._omc_port = omc_port
851854

852-
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
855+
def omc_run_data_update(self, omc_run_data: OMCSessionRunData, session: OMCSessionZMQ) -> OMCSessionRunData:
853856
"""
854857
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
855858
"""
@@ -936,7 +939,7 @@ def _omc_port_get(self) -> str:
936939

937940
return port
938941

939-
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
942+
def omc_run_data_update(self, omc_run_data: OMCSessionRunData, session: OMCSessionZMQ) -> OMCSessionRunData:
940943
"""
941944
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
942945
"""
@@ -1084,7 +1087,7 @@ def get_docker_container_id(self) -> str:
10841087

10851088
return self._dockerCid
10861089

1087-
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
1090+
def omc_run_data_update(self, omc_run_data: OMCSessionRunData, session: OMCSessionZMQ) -> OMCSessionRunData:
10881091
"""
10891092
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
10901093
"""
@@ -1396,7 +1399,7 @@ def _omc_port_get(self) -> str:
13961399

13971400
return port
13981401

1399-
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
1402+
def omc_run_data_update(self, omc_run_data: OMCSessionRunData, session: OMCSessionZMQ) -> OMCSessionRunData:
14001403
"""
14011404
Update the OMCSessionRunData object based on the selected OMCProcess implementation.
14021405
"""

0 commit comments

Comments
 (0)