示例#1
0
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)
示例#2
0
 def exportSnapshot(self, ident: str = None) -> str:
     contents, status = Scope._capi.exportSnapshot(self.cref +
                                                   ('.' +
                                                    ident if ident else ''))
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return contents
示例#3
0
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)
示例#4
0
    def resultFile(self, file: str):
        _, bufferSize, status = Scope._capi.getResultFile(self.cref)
        if Types.Status(status) != Types.Status.OK:
            raise Exception('error {}'.format(Types.Status(status)))

        status = Scope._capi.setResultFile(self.cref, file, bufferSize)
        if Types.Status(status) != Types.Status.OK:
            raise Exception('error {}'.format(Types.Status(status)))
示例#5
0
 def addSystem(self, cref: str, type_: Types.System):
     new_cref = self.cref + '.' + cref
     status = Scope._capi.addSystem(new_cref, type_.value)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return System.System(new_cref)
示例#6
0
 def resultFile(self):
     file, _, status = Scope._capi.getResultFile(self.cref)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return file
示例#7
0
 def stopTime(self):
     value, status = Scope._capi.getStopTime(self.cref)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return value
示例#8
0
 def stopTime(self, value: float):
     status = Scope._capi.setStopTime(self.cref, value)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
示例#9
0
 def modelState(self):
     modelState, status = Scope._capi.getModelState(self.cref)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return Types.ModelState(modelState)
示例#10
0
def setLoggingLevel(level: int) -> None:
    if not isinstance(level, int):
        raise Exception('bad argument: {}'.format(level))
    status = Scope._capi.setLoggingLevel(level)
    if Types.Status(status) != Types.Status.OK:
        raise Exception('error {}'.format(Types.Status(status)))
示例#11
0
 def delete(self):
     status = Scope._capi.delete(self.cref)
     if Types.Status(status) == Types.Status.OK:
         Scope._Scope = [cref for cref in Scope._Scope if cref != self.cref]
     else:
         raise Exception('error {}'.format(Types.Status(status)))
示例#12
0
 def initialize(self):
     status = Scope._capi.initialize(self.cref)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
示例#13
0
 def addConnection(self, conA: str, conB: str):
     new_conA = self.cref + '.' + conA
     new_conB = self.cref + '.' + conB
     status = Scope._capi.addConnection(new_conA, new_conB)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
示例#14
0
 def setString(self, cref: str, value: str) -> None:
     status = Scope._capi.setString(self.cref + '.' + cref, value)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
示例#15
0
 def addSubModel(self, cref: str, path: str):
     new_cref = self.cref + '.' + cref
     status = Scope._capi.addSubModel(new_cref, path)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return SubModel(new_cref)
示例#16
0
 def type(self):
     type_, status = Scope._capi.getSystemType(self.cref)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return Types.System(type_)
示例#17
0
def setLogFile(path: str, size=None) -> None:
    status = Scope._capi.setLogFile(path)
    if Types.Status(status) != Types.Status.OK:
        raise Exception('error {}'.format(Types.Status(status)))
    if size:
        setMaxLogFileSize(size)
示例#18
0
 def fixedStepSize(self):
     stepSize, status = Scope._capi.getFixedStepSize(self.cref)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return stepSize
示例#19
0
 def reset(self):
     status = Scope._capi.reset(self.cref)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
示例#20
0
 def fixedStepSize(self, stepSize: float):
     status = Scope._capi.setFixedStepSize(self.cref, stepSize)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
示例#21
0
def setWorkingDirectory(dir: str) -> None:
    status = Scope._capi.setWorkingDirectory(dir)
    if Types.Status(status) != Types.Status.OK:
        raise Exception('error {}'.format(Types.Status(status)))
示例#22
0
 def exportDependencyGraphs(self, initialization: str, event: str,
                            simulation: str) -> None:
     status = Scope._capi.exportDependencyGraphs(self.cref, initialization,
                                                 event, simulation)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
示例#23
0
def setCommandLineOption(cmd: str) -> None:
    status = Scope._capi.setCommandLineOption(cmd)
    if Types.Status(status) != Types.Status.OK:
        raise Exception('error {}'.format(Types.Status(status)))
示例#24
0
 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)))
示例#25
0
 def exportSSVTemplate(self, ident: str, filename: str) -> None:
     status = Scope._capi.exportSSVTemplate(
         self.cref + ('.' + ident if ident else ''), filename)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
示例#26
0
 def getString(self, cref: str):
     value, status = Scope._capi.getString(self.cref + '.' + cref)
     if Types.Status(status) != Types.Status.OK:
         raise Exception('error {}'.format(Types.Status(status)))
     return value
示例#27
0
 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)))