@@ -189,6 +189,26 @@ def get_exe_file(self, tempdir, modelName) -> pathlib.Path:
189189 else :
190190 return pathlib .Path (tempdir ) / modelName
191191
192+ def parse_simflags (self , simflags : str ) -> dict :
193+ # add old style simulation arguments
194+ warnings .warn ("The argument 'simflags' is depreciated and will be removed in future versions; "
195+ "please use 'simargs' instead" , DeprecationWarning , stacklevel = 2 )
196+
197+ simargs = {}
198+
199+ args = [s for s in simflags .split (' ' ) if s ]
200+ for arg in args :
201+ if arg [0 ] != '-' :
202+ raise ModelicaSystemError (f"Invalid simulation flag: { arg } " )
203+ arg = arg [1 :]
204+ parts = arg .split ('=' )
205+ if len (parts ) == 1 :
206+ simargs [parts [0 ]] = None
207+ else :
208+ simargs [parts [0 ]] = '=' .join (parts [1 :])
209+
210+ return simargs
211+
192212
193213class ModelicaSystem :
194214 def __init__ (
@@ -714,23 +734,8 @@ def simulate(self, resultfile: Optional[str] = None, simflags: Optional[str] = N
714734 om_cmd .arg_set (key = "r" , val = self .resultfile )
715735
716736 # allow runtime simulation flags from user input
717- # TODO: merge into ModelicaSystemCmd?
718737 if simflags is not None :
719- # add old style simulation arguments
720- warnings .warn ("The argument simflags is depreciated and will be removed in future versions; "
721- "please use simargs instead" , DeprecationWarning , stacklevel = 1 )
722-
723- args = [s for s in simflags .split (' ' ) if s ]
724- for arg in args :
725- if arg [0 ] != '-' :
726- raise ModelicaSystemError (f"Invalid simulation flag: { arg } " )
727- arg = arg [1 :]
728- parts = arg .split ('=' )
729- if len (parts ) == 1 :
730- val = None
731- else :
732- val = '=' .join (parts [1 :])
733- om_cmd .arg_set (key = parts [0 ], val = val )
738+ om_cmd .args_set (args = om_cmd .parse_simflags (simflags = simflags ))
734739
735740 if simargs :
736741 om_cmd .args_set (args = simargs )
@@ -1128,22 +1133,8 @@ def linearize(self, lintime: Optional[float] = None, simflags: Optional[str] = N
11281133 om_cmd .arg_set (key = "l" , val = f"{ lintime or self .linearOptions ["stopTime" ]} " )
11291134
11301135 # allow runtime simulation flags from user input
1131- # TODO: merge into ModelicaSystemCmd?
11321136 if simflags is not None :
1133- # add old style simulation arguments
1134- warnings .warn ("The argument simflags is depreciated and will be removed in future versions; "
1135- "please use simargs instead" , DeprecationWarning , stacklevel = 1 )
1136-
1137- args = [s for s in simflags .split (' ' ) if s ]
1138- for arg in args :
1139- if arg [0 ] != '-' :
1140- raise ModelicaSystemError (f"Invalid simulation flag: { arg } " )
1141- parts = arg .split ('=' )
1142- if len (parts ) == 1 :
1143- val = None
1144- else :
1145- val = '=' .join (parts [1 :])
1146- om_cmd .arg_set (key = parts [0 ], val = val )
1137+ om_cmd .args_set (args = om_cmd .parse_simflags (simflags = simflags ))
11471138
11481139 if simargs :
11491140 om_cmd .args_set (args = simargs )
0 commit comments