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

73 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
2022-11-06 20:55:48 +01:00
import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.interfaces.Profile
2021-04-14 19:36:13 +02:00
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.PumpSync
2022-11-10 14:01:14 +01:00
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpEnactResult
2022-11-10 09:40:49 +01:00
import info.nightscout.interfaces.pump.defs.ManufacturerType
2022-11-10 14:01:14 +01:00
import info.nightscout.interfaces.pump.defs.PumpDescription
2022-11-10 09:40:49 +01:00
import info.nightscout.interfaces.pump.defs.PumpType
2022-11-06 23:58:05 +01:00
import info.nightscout.interfaces.utils.TimeChangeType
2021-02-17 09:26:17 +01:00
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) {}
2022-11-06 20:55:48 +01:00
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResultImpl(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
2022-11-06 20:55:48 +01:00
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultImpl(injector).success(true)
2021-02-17 09:26:17 +01:00
override fun stopBolusDelivering() {}
2022-11-06 20:55:48 +01:00
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultImpl(injector).success(true)
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean, tbrType: PumpSync.TemporaryBasalType): PumpEnactResult =
PumpEnactResultImpl(injector).success(true)
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResultImpl(injector).success(true)
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResultImpl(injector).success(true)
override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResultImpl(injector).success(true)
2021-02-17 09:26:17 +01:00
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject()
override fun manufacturer(): ManufacturerType = ManufacturerType.AAPS
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
2022-11-06 20:55:48 +01:00
override fun loadTDDs(): PumpEnactResult = PumpEnactResultImpl(injector).success(true)
2021-02-17 09:26:17 +01:00
override fun canHandleDST(): Boolean = true
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {}
}