AndroidAPS/app/src/test/java/info/nightscout/androidaps/TestPumpPlugin.kt

68 lines
3.4 KiB
Kotlin
Raw Normal View History

2021-02-17 09:26:17 +01:00
package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.DetailedBolusInfo
2021-04-19 18:44:17 +02:00
import info.nightscout.androidaps.interfaces.Profile
2021-02-17 09:26:17 +01:00
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.PumpDescription
2021-04-14 19:36:13 +02:00
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.PumpSync
2021-02-17 09:26:17 +01:00
import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.utils.TimeChangeType
import org.json.JSONObject
@Suppress("MemberVisibilityCanBePrivate")
2021-04-14 19:36:13 +02:00
class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
2021-02-17 09:26:17 +01:00
var connected = false
2021-02-17 20:15:45 +01:00
var isProfileSet = true
override fun isConnected() = connected
override fun isConnecting() = false
override fun isHandshakeInProgress() = false
2021-02-17 09:26:17 +01:00
val lastData = 0L
val baseBasal = 0.0
override val pumpDescription = PumpDescription()
override fun isInitialized(): Boolean = true
override fun isSuspended(): Boolean = false
override fun isBusy(): Boolean = false
2021-02-17 09:26:17 +01:00
override fun connect(reason: String) {
connected = true
2021-02-17 09:26:17 +01:00
}
override fun disconnect(reason: String) {
connected = false
2021-02-17 09:26:17 +01:00
}
override fun stopConnecting() {
connected = false
2021-02-17 09:26:17 +01:00
}
override fun waitForDisconnectionInSeconds(): Int = 0
override fun getPumpStatus(reason: String) {}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
2021-02-17 20:15:45 +01:00
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
2021-02-17 09:26:17 +01:00
override fun lastDataTime(): Long = lastData
override val baseBasalRate: Double = baseBasal
override val reservoirLevel: Double = 0.0
override val batteryLevel: Int = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun stopBolusDelivering() {}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult = PumpEnactResult(injector).success(true)
2021-02-17 09:26:17 +01:00
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AndroidAPS
2021-03-25 17:48:07 +01:00
override fun model(): PumpType = PumpType.GENERIC_AAPS
2021-02-17 09:26:17 +01:00
override fun serialNumber(): String = "1"
override fun shortStatus(veryShort: Boolean): String = ""
override val isFakingTempsByExtendedBoluses: Boolean = false
override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true)
override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
}