Skip to content

Commit

Permalink
Merge pull request #87 from eidekrist/bugfix/86-incorrect-initializat…
Browse files Browse the repository at this point in the history
…ion-for-fmi1-slaves

Fixing initialization sequence for FMI 1.0 slaves
  • Loading branch information
markaren authored Jul 18, 2019
2 parents cd86278 + 76e28c8 commit 42fd228
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ abstract class AbstractModelInstance<out E : CommonModelDescription, out T : Fmi
}
}

override fun exitInitializationMode(): Boolean {
return true.also {
wrapper.lastStatus = FmiStatus.OK
}
}

override fun terminate(): Boolean {
return terminate(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ class CoSimulationSlave internal constructor(
stopTime = stop
}

simulationTime = start

return true
}

override fun exitInitializationMode(): Boolean {
return (wrapper.initializeSlave(startTime, stopTime).isOK()).also {
simulationTime = start
wrapper.lastStatus = FmiStatus.OK
}

}

override fun doStep(stepSize: Double): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ open class ModelExchangeInstance internal constructor(


internal val eventInfo = EventInfo()
private var relativeTolerance: Double = 0.0

override fun setup(start: Double, stop: Double, tolerance: Double): Boolean {

Expand All @@ -60,13 +61,19 @@ open class ModelExchangeInstance internal constructor(

setTime(start)

val toleranceControlled = tolerance > 0
return (wrapper.initialize(toleranceControlled, tolerance).isOK()).also {
simulationTime = start
}
relativeTolerance = tolerance

return true

}

override fun exitInitializationMode(): Boolean {
val toleranceControlled = relativeTolerance > 0
return (wrapper.initialize(toleranceControlled, relativeTolerance).isOK()).also {
wrapper.lastStatus = FmiStatus.OK
}
}

override fun reset(): Boolean {
throw IllegalStateException("Reset not supported by FMI 1.0 for Model Exchange")
}
Expand Down

0 comments on commit 42fd228

Please sign in to comment.