Skip to content

Commit

Permalink
Add stepUntil to python api (#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored Mar 2, 2022
1 parent d92d4ff commit 98a7a11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/OMSimulatorLib/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,9 +915,6 @@ oms_status_enu_t oms::Model::setStartTime(double value)

oms_status_enu_t oms::Model::setStopTime(double value)
{
if (!validState(oms_modelState_virgin|oms_modelState_enterInstantiation|oms_modelState_instantiated))
return logError_ModelInWrongState(getCref());

stopTime = value;
return oms_status_ok;
}
Expand Down Expand Up @@ -1085,6 +1082,9 @@ oms_status_enu_t oms::Model::stepUntil(double stopTime)
return logError("Model doesn't contain a system");
}

if (stopTime > getStopTime())
setStopTime(stopTime);

oms_status_enu_t status = system->stepUntil(stopTime);
emit(stopTime, true);
clock.toc();
Expand Down
5 changes: 5 additions & 0 deletions src/OMSimulatorPython/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def doStep(self):
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))

def stepUntil(self, stopTime: float):
status = Scope._capi.stepUntil(self.cref, stopTime)
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))

def terminate(self):
status = Scope._capi.terminate(self.cref)
if Types.Status(status) != Types.Status.OK:
Expand Down

0 comments on commit 98a7a11

Please sign in to comment.