Skip to content

Commit 6ee2c35

Browse files
author
Lars Ivar Hatledal
committed
Fix status not updated when calling setup on FMI 1.0 and cleanup
1 parent 42fd228 commit 6ee2c35

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

fmi-import/src/main/kotlin/no/ntnu/ihb/fmi4j/importer/fmi1/AbstractModelInstance.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ abstract class AbstractModelInstance<out E : CommonModelDescription, out T : Fmi
126126
return wrapper.write(vr, value)
127127
}
128128

129-
private companion object {
130-
private val LOG: Logger = LoggerFactory.getLogger(AbstractModelInstance::class.java)
131-
}
132-
133129
override fun getFMUstate(): FmuState {
134130
throw IllegalStateException("Feature not available for FMI 1.0")
135131
}
@@ -154,4 +150,8 @@ abstract class AbstractModelInstance<out E : CommonModelDescription, out T : Fmi
154150
throw IllegalStateException("Feature not available for FMI 1.0")
155151
}
156152

153+
private companion object {
154+
private val LOG: Logger = LoggerFactory.getLogger(AbstractModelInstance::class.java)
155+
}
156+
157157
}

fmi-import/src/main/kotlin/no/ntnu/ihb/fmi4j/importer/fmi1/CoSimulationSlave.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ class CoSimulationSlave internal constructor(
6363

6464
simulationTime = start
6565

66-
return true
66+
return true.also {
67+
wrapper.lastStatus = FmiStatus.OK
68+
}
6769
}
6870

6971
override fun exitInitializationMode(): Boolean {
70-
return (wrapper.initializeSlave(startTime, stopTime).isOK()).also {
71-
wrapper.lastStatus = FmiStatus.OK
72-
}
72+
return wrapper.initializeSlave(startTime, stopTime).isOK()
7373
}
7474

7575
override fun doStep(stepSize: Double): Boolean {

fmi-import/src/main/kotlin/no/ntnu/ihb/fmi4j/importer/fmi1/ModelExchangeInstance.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ open class ModelExchangeInstance internal constructor(
6363

6464
relativeTolerance = tolerance
6565

66-
return true
66+
return true.also {
67+
wrapper.lastStatus = FmiStatus.OK
68+
}
6769

6870
}
6971

7072
override fun exitInitializationMode(): Boolean {
7173
val toleranceControlled = relativeTolerance > 0
72-
return (wrapper.initialize(toleranceControlled, relativeTolerance).isOK()).also {
73-
wrapper.lastStatus = FmiStatus.OK
74-
}
74+
return wrapper.initialize(toleranceControlled, relativeTolerance).isOK()
7575
}
7676

7777
override fun reset(): Boolean {

0 commit comments

Comments
 (0)