Skip to content

Commit

Permalink
Add setLoggingInterval to new python interface
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel committed May 23, 2021
1 parent df73447 commit e507bb3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 9 additions & 4 deletions src/OMSimulatorPython/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,32 @@ def getReal(self, cref: str):
raise Exception('error {}'.format(Types.Status(status)))
return value

def setBoolean(self, cref: str, value: bool):
def setBoolean(self, cref: str, value: bool) -> None:
status = Scope._capi.setBoolean(self.cref + '.' + cref, value)
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))

def setInteger(self, cref: str, value: int):
def setInteger(self, cref: str, value: int) -> None:
status = Scope._capi.setInteger(self.cref + '.' + cref, value)
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))

def setReal(self, cref: str, value: float):
def setReal(self, cref: str, value: float) -> None:
status = Scope._capi.setReal(self.cref + '.' + cref, value)
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))

def exportSnapshot(self, ident: str):
def exportSnapshot(self, ident: str) -> str:
contents, status = Scope._capi.exportSnapshot(self.cref + '.' + ident)
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))
return contents

def setLoggingInterval(self, loggingInterval: float) -> None:
status = Scope._capi.setLoggingInterval(self.cref, loggingInterval)
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))

@property
def cref(self):
return self._cref
Expand Down
10 changes: 5 additions & 5 deletions src/OMSimulatorPython/NewAPI.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
from OMSimulator import Model, Scope, Types


def newModel(cref: str):
def newModel(cref: str) -> Model:
status = Scope._capi.newModel(cref)
if Types.Status(status) == Types.Status.OK:
Scope._Scope.append(cref)
else:
raise Exception('error {}'.format(Types.Status(status)))
return Model(cref)

def importFile(file: str):
def importFile(file: str) -> Model:
cref, status = Scope._capi.importFile(file)
if Types.Status(status) == Types.Status.OK:
Scope._Scope.append(cref)
else:
raise Exception('error {}'.format(Types.Status(status)))
return Model(cref)

def setTempDirectory(dir: str):
def setTempDirectory(dir: str) -> None:
status = Scope._capi.setTempDirectory(dir)
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))

def setCommandLineOption(cmd: str):
def setCommandLineOption(cmd: str) -> None:
status = Scope._capi.setCommandLineOption(cmd)
if Types.Status(status) != Types.Status.OK:
raise Exception('error {}'.format(Types.Status(status)))

def setLoggingLevel(level: int):
def setLoggingLevel(level: int) -> None:
if not isinstance(level, int):
raise Exception('bad argument: {}'.format(level))
status = Scope._capi.setLoggingLevel(level)
Expand Down

0 comments on commit e507bb3

Please sign in to comment.