Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Oct 21, 2019
1 parent e69c663 commit 3383030
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
19 changes: 16 additions & 3 deletions fmi-import/src/main/kotlin/no/ntnu/ihb/fmi4j/Model.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,26 @@ import no.ntnu.ihb.fmi4j.modeldescription.ModelDescription
import no.ntnu.ihb.fmi4j.modeldescription.ModelExchangeModelDescription
import java.io.Closeable

typealias CosimulationModel = Model<CoSimulationModelDescription>
typealias ModelExchangeModel = Model<ModelExchangeModelDescription>

interface Model<E: CommonModelDescription> : Closeable {

val modelDescription: ModelDescription

fun newInstance(): ModelInstance<E>

}


interface CoSimulationModel: Model<CoSimulationModelDescription> {

override val modelDescription: CoSimulationModelDescription

override fun newInstance(): SlaveInstance

}

interface ModelExchangeModel: Model<ModelExchangeModelDescription> {

override val modelDescription: ModelExchangeModelDescription

}

Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

package no.ntnu.ihb.fmi4j.importer

import no.ntnu.ihb.fmi4j.CosimulationModel
import no.ntnu.ihb.fmi4j.Model
import no.ntnu.ihb.fmi4j.CoSimulationModel
import no.ntnu.ihb.fmi4j.ModelExchangeModel
import no.ntnu.ihb.fmi4j.modeldescription.ModelDescriptionParser
import no.ntnu.ihb.fmi4j.modeldescription.ModelDescriptionProvider
Expand Down Expand Up @@ -89,7 +88,7 @@ abstract class AbstractFmu internal constructor(
}
}

abstract fun asCoSimulationFmu(): CosimulationModel
abstract fun asCoSimulationFmu(): CoSimulationModel

abstract fun asModelExchangeFmu(): ModelExchangeModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

package no.ntnu.ihb.fmi4j.importer.fmi1

import no.ntnu.ihb.fmi4j.CosimulationModel
import no.ntnu.ihb.fmi4j.Model
import no.ntnu.ihb.fmi4j.SlaveInstance
import no.ntnu.ihb.fmi4j.CoSimulationModel
import no.ntnu.ihb.fmi4j.importer.fmi1.jni.CoSimulationLibraryWrapper
import no.ntnu.ihb.fmi4j.importer.fmi1.jni.Fmi1CoSimulationLibrary
import no.ntnu.ihb.fmi4j.modeldescription.CoSimulationModelDescription
Expand All @@ -36,7 +34,7 @@ import java.io.Closeable

class CoSimulationFmu(
private val fmu: Fmu
) : CosimulationModel, Closeable by fmu {
) : CoSimulationModel, Closeable by fmu {

override val modelDescription: CoSimulationModelDescription by lazy {
fmu.modelDescription.asCoSimulationModelDescription()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

package no.ntnu.ihb.fmi4j.importer.fmi2

import no.ntnu.ihb.fmi4j.CosimulationModel
import no.ntnu.ihb.fmi4j.Model
import no.ntnu.ihb.fmi4j.CoSimulationModel
import no.ntnu.ihb.fmi4j.SlaveInstance
import no.ntnu.ihb.fmi4j.importer.fmi2.jni.CoSimulationLibraryWrapper
import no.ntnu.ihb.fmi4j.importer.fmi2.jni.Fmi2CoSimulationLibrary
Expand All @@ -35,7 +34,7 @@ import java.io.Closeable

class CoSimulationFmu(
private val fmu: Fmu
) : CosimulationModel, Closeable by fmu {
) : CoSimulationModel, Closeable by fmu {

override val modelDescription: CoSimulationModelDescription by lazy {
fmu.modelDescription.asCoSimulationModelDescription()
Expand Down

0 comments on commit 3383030

Please sign in to comment.