Convert OmnipodDashPumpPlugin to Kotlin

This commit is contained in:
Bart Sopers 2021-02-25 23:55:12 +01:00
parent d5679e51dd
commit bc8eefaffd
2 changed files with 206 additions and 213 deletions

View file

@ -1,213 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash;
import androidx.annotation.Nullable;
import com.google.gson.JsonObject;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.PumpPluginBase;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.common.ManufacturerType;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.OmnipodDashOverviewFragment;
import info.nightscout.androidaps.queue.commands.CustomCommand;
import info.nightscout.androidaps.utils.TimeChangeType;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
@Singleton
public class OmnipodDashPumpPlugin extends PumpPluginBase implements PumpInterface {
private static final PumpDescription PUMP_DESCRIPTION = new PumpDescription(PumpType.Omnipod_Dash);
private final AAPSLogger aapsLogger;
private final ResourceHelper resourceHelper;
private final CommandQueueProvider commandQueue;
@Inject
public OmnipodDashPumpPlugin(HasAndroidInjector injector, AAPSLogger aapsLogger, ResourceHelper resourceHelper, CommandQueueProvider commandQueue) {
super(new PluginDescription() //
.mainType(PluginType.PUMP) //
.fragmentClass(OmnipodDashOverviewFragment.class.getName()) //
.pluginIcon(R.drawable.ic_pod_128)
.pluginName(R.string.omnipod_dash_name) //
.shortName(R.string.omnipod_dash_name_short) //
.preferencesId(R.xml.omnipod_dash_preferences) //
.description(R.string.omnipod_dash_pump_description), injector, aapsLogger, resourceHelper, commandQueue);
this.aapsLogger = aapsLogger;
this.resourceHelper = resourceHelper;
this.commandQueue = commandQueue;
}
@Override public boolean isInitialized() {
return true;
}
@Override public boolean isSuspended() {
return false;
}
@Override public boolean isBusy() {
// prevents the queue from executing
return true;
}
@Override public boolean isConnected() {
return false;
}
@Override public boolean isConnecting() {
return false;
}
@Override public boolean isHandshakeInProgress() {
return false;
}
@Override public void finishHandshaking() {
}
@Override public void connect(@NotNull String reason) {
}
@Override public void disconnect(@NotNull String reason) {
}
@Override public void stopConnecting() {
}
@Override public void getPumpStatus(@NotNull String reason) {
}
@NotNull @Override public PumpEnactResult setNewBasalProfile(@NotNull Profile profile) {
// TODO
return new PumpEnactResult(getInjector()).success(true).enacted(true);
}
@Override public boolean isThisProfileSet(@NotNull Profile profile) {
// TODO
return true;
}
@Override public long lastDataTime() {
// TODO
return System.currentTimeMillis();
}
@Override public double getBaseBasalRate() {
return 0;
}
@Override public double getReservoirLevel() {
return 0;
}
@Override public int getBatteryLevel() {
return 0;
}
@NotNull @Override public PumpEnactResult deliverTreatment(@NotNull DetailedBolusInfo detailedBolusInfo) {
return null;
}
@Override public void stopBolusDelivering() {
}
@NotNull @Override public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NotNull Profile profile, boolean enforceNew) {
return null;
}
@NotNull @Override public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NotNull Profile profile, boolean enforceNew) {
return null;
}
@NotNull @Override public PumpEnactResult setExtendedBolus(double insulin, int durationInMinutes) {
return null;
}
@NotNull @Override public PumpEnactResult cancelTempBasal(boolean enforceNew) {
return null;
}
@NotNull @Override public PumpEnactResult cancelExtendedBolus() {
return null;
}
@NotNull @Override public JSONObject getJSONStatus(@NotNull Profile profile, @NotNull String profileName, @NotNull String version) {
return new JSONObject();
}
@NotNull @Override public ManufacturerType manufacturer() {
return getPumpDescription().pumpType.getManufacturer();
}
@NotNull @Override public PumpType model() {
return getPumpDescription().pumpType;
}
@NotNull @Override public String serialNumber() {
return null;
}
@NotNull @Override public PumpDescription getPumpDescription() {
return PUMP_DESCRIPTION;
}
@NotNull @Override public String shortStatus(boolean veryShort) {
return null;
}
@Override public boolean isFakingTempsByExtendedBoluses() {
return false;
}
@NotNull @Override public PumpEnactResult loadTDDs() {
return null;
}
@Override public boolean canHandleDST() {
return false;
}
@Override
public List<CustomAction> getCustomActions() {
return Collections.emptyList();
}
@Override
public void executeCustomAction(@NotNull CustomActionType customActionType) {
aapsLogger.warn(LTag.PUMP, "Unsupported custom action: " + customActionType);
}
@Nullable @Override public PumpEnactResult executeCustomCommand(@NotNull CustomCommand customCommand) {
return null;
}
@Override public void timezoneOrDSTChanged(@NotNull TimeChangeType timeChangeType) {
}
}

View file

@ -0,0 +1,206 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.OmnipodDashOverviewFragment
import info.nightscout.androidaps.queue.commands.CustomCommand
import info.nightscout.androidaps.utils.TimeChangeType
import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.json.JSONObject
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class OmnipodDashPumpPlugin @Inject constructor(
injector: HasAndroidInjector,
aapsLogger: AAPSLogger,
resourceHelper: ResourceHelper,
commandQueue: CommandQueueProvider)
: PumpPluginBase(pluginDescription, injector, aapsLogger, resourceHelper, commandQueue), PumpInterface {
companion object {
private val pluginDescription = PluginDescription() //
.mainType(PluginType.PUMP) //
.fragmentClass(OmnipodDashOverviewFragment::class.java.name) //
.pluginIcon(R.drawable.ic_pod_128)
.pluginName(R.string.omnipod_dash_name) //
.shortName(R.string.omnipod_dash_name_short) //
.preferencesId(R.xml.omnipod_dash_preferences) //
.description(R.string.omnipod_dash_pump_description)
private val pumpDescription = PumpDescription(PumpType.Omnipod_Dash)
}
override fun isInitialized(): Boolean {
// TODO
return true
}
override fun isSuspended(): Boolean {
// TODO
return false
}
override fun isBusy(): Boolean {
// prevents the queue from executing commands
// TODO
return true
}
override fun isConnected(): Boolean {
// TODO
return false
}
override fun isConnecting(): Boolean {
// TODO
return false
}
override fun isHandshakeInProgress(): Boolean {
// TODO
return false
}
override fun finishHandshaking() {
// TODO
}
override fun connect(reason: String) {
// TODO
}
override fun disconnect(reason: String) {
// TODO
}
override fun stopConnecting() {
// TODO
}
override fun getPumpStatus(reason: String) {
// TODO
}
override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
// TODO
return PumpEnactResult(injector).success(true).enacted(true)
}
override fun isThisProfileSet(profile: Profile): Boolean {
// TODO
return true
}
override fun lastDataTime(): Long {
// TODO
return System.currentTimeMillis()
}
override val baseBasalRate: Double
get() = 0.0 // TODO
override val reservoirLevel: Double
get() = 0.0 // TODO
override val batteryLevel: Int
get() = 0
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
// TODO
return PumpEnactResult(injector).success(false).enacted(false).comment("TODO")
}
override fun stopBolusDelivering() {
// TODO
}
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult {
// TODO
return PumpEnactResult(injector).success(false).enacted(false).comment("TODO")
}
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult {
// TODO i18n
return PumpEnactResult(injector).success(false).enacted(false).comment("Omnipod Dash driver does not support percentage temp basals")
}
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult {
// TODO i18n
return PumpEnactResult(injector).success(false).enacted(false).comment("Omnipod Dash driver does not support extended boluses")
}
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
// TODO
return PumpEnactResult(injector).success(false).enacted(false).comment("TODO")
}
override fun cancelExtendedBolus(): PumpEnactResult {
// TODO i18n
return PumpEnactResult(injector).success(false).enacted(false).comment("Omnipod Dash driver does not support extended boluses")
}
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject {
// TODO
return JSONObject()
}
override val pumpDescription: PumpDescription = Companion.pumpDescription
override fun manufacturer(): ManufacturerType {
return pumpDescription.pumpType.manufacturer
}
override fun model(): PumpType {
return pumpDescription.pumpType
}
override fun serialNumber(): String {
// TODO
return "TODO"
}
override fun shortStatus(veryShort: Boolean): String {
// TODO
return "TODO"
}
override val isFakingTempsByExtendedBoluses: Boolean
get() = false
override fun loadTDDs(): PumpEnactResult {
// TODO i18n
return PumpEnactResult(injector).success(false).enacted(false).comment("Omnipod Dash driver does not support TDD")
}
override fun canHandleDST(): Boolean {
return false
}
override fun getCustomActions(): List<CustomAction> {
return emptyList()
}
override fun executeCustomAction(customActionType: CustomActionType) {
aapsLogger.warn(LTag.PUMP, "Unsupported custom action: $customActionType")
}
override fun executeCustomCommand(customCommand: CustomCommand): PumpEnactResult? {
// TODO
return null
}
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {
// TODO
}
}