File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -1104,6 +1104,34 @@ def simulate(
11041104
11051105 self ._simulated = True
11061106
1107+ def plot (
1108+ self ,
1109+ plotdata : str ,
1110+ resultfile : Optional [str | os .PathLike ] = None ,
1111+ ) -> None :
1112+ """
1113+ Plot a variable using OMC; this will work for local OMC usage only (OMCProcessLocal). The reason is that the
1114+ plot is created by OMC which needs access to the local display. This is not the case for docker and WSL.
1115+ """
1116+
1117+ if not isinstance (self ._getconn .omc_process , OMCProcessLocal ):
1118+ raise ModelicaSystemError ("Plot is using the OMC plot functionality; "
1119+ "thus, it is only working if OMC is running locally!" )
1120+
1121+ if resultfile is not None :
1122+ plot_result_file = self ._getconn .omcpath (resultfile )
1123+ elif self ._result_file is not None :
1124+ plot_result_file = self ._result_file
1125+ else :
1126+ raise ModelicaSystemError ("No resultfile available - either run simulate() before plotting "
1127+ "or provide a result file!" )
1128+
1129+ if not plot_result_file .is_file ():
1130+ raise ModelicaSystemError (f"Provided resultfile { repr (plot_result_file .as_posix ())} does not exists!" )
1131+
1132+ expr = f'plot({ plotdata } , fileName="{ plot_result_file .as_posix ()} ")'
1133+ self .sendExpression (expr = expr )
1134+
11071135 def getSolutions (
11081136 self ,
11091137 varList : Optional [str | list [str ]] = None ,
You can’t perform that action at this time.
0 commit comments