Skip to content

Commit 64968d0

Browse files
committed
[ModelicaSystem] remove _has_inputs - is defined by _inputs empty or not
1 parent c0a7f73 commit 64968d0

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

OMPython/ModelicaSystem.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ def __init__(
388388
self._lmodel = lmodel # may be needed if model is derived from other model
389389
self._model_name = modelName # Model class name
390390
self._file_name = pathlib.Path(fileName).resolve() if fileName is not None else None # Model file/package name
391-
self._has_inputs = False # for model with input quantity
392391
self._simulated = False # True if the model has already been simulated
393392
self._csvFile: Optional[pathlib.Path] = None # for storing inputs condition
394393
self._result_file: Optional[pathlib.Path] = None # for storing result file
@@ -969,7 +968,7 @@ def simulate(self,
969968

970969
om_cmd.arg_set(key="overrideFile", val=overrideFile.as_posix())
971970

972-
if self._has_inputs: # if model has input quantities
971+
if self._inputs: # if model has input quantities
973972
for i in self._inputs:
974973
val = self._inputs[i]
975974
if val is None:
@@ -1334,8 +1333,6 @@ def setInputs(
13341333
else:
13351334
raise ModelicaSystemError(f"Data cannot be evaluated for {repr(key)}: {repr(val)}")
13361335

1337-
self._has_inputs = True
1338-
13391336
return True
13401337

13411338
def _createCSVData(self) -> pathlib.Path:
@@ -1521,13 +1518,13 @@ def load_module_from_path(module_name, file_path):
15211518

15221519
om_cmd.arg_set(key="overrideFile", val=overrideLinearFile.as_posix())
15231520

1524-
if self._has_inputs:
1525-
nameVal = self.getInputs()
1526-
for n in nameVal:
1527-
tupleList = nameVal.get(n)
1528-
if tupleList is not None:
1529-
for l in tupleList:
1530-
if l[0] < float(self._simulate_options["startTime"]):
1521+
inputs = self.getInputs()
1522+
if inputs:
1523+
for key in inputs:
1524+
data = inputs[key]
1525+
if data is not None:
1526+
for value in data:
1527+
if value[0] < float(self._simulate_options["startTime"]):
15311528
raise ModelicaSystemError('Input time value is less than simulation startTime')
15321529
self._csvFile = self._createCSVData()
15331530
om_cmd.arg_set(key="csvInput", val=self._csvFile.as_posix())

0 commit comments

Comments
 (0)