automated copy of configuration AAPS -> NSCLIENT
This commit is contained in:
parent
d0d5dca959
commit
3f77496c88
30 changed files with 352 additions and 100 deletions
|
@ -147,7 +147,7 @@ class ConfigBuilderPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) {
|
override fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) {
|
||||||
changedPlugin.setPluginEnabled(type, enabled)
|
changedPlugin.setPluginEnabled(type, enabled)
|
||||||
changedPlugin.setFragmentVisible(type, enabled)
|
changedPlugin.setFragmentVisible(type, enabled)
|
||||||
processOnEnabledCategoryChanged(changedPlugin, type)
|
processOnEnabledCategoryChanged(changedPlugin, type)
|
||||||
|
|
|
@ -15,10 +15,13 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.ConfigInterface;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper;
|
import info.nightscout.androidaps.utils.HtmlHelper;
|
||||||
import info.nightscout.androidaps.utils.Round;
|
import info.nightscout.androidaps.utils.Round;
|
||||||
|
@ -85,6 +88,8 @@ public class NSDeviceStatus {
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final NSSettingsStatus nsSettingsStatus;
|
private final NSSettingsStatus nsSettingsStatus;
|
||||||
|
private final ConfigInterface config;
|
||||||
|
private final RunningConfiguration runningConfiguration;
|
||||||
|
|
||||||
private JSONObject data = null;
|
private JSONObject data = null;
|
||||||
|
|
||||||
|
@ -93,12 +98,16 @@ public class NSDeviceStatus {
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
SP sp,
|
SP sp,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
NSSettingsStatus nsSettingsStatus
|
NSSettingsStatus nsSettingsStatus,
|
||||||
|
ConfigInterface config,
|
||||||
|
RunningConfiguration runningConfiguration
|
||||||
) {
|
) {
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.nsSettingsStatus = nsSettingsStatus;
|
this.nsSettingsStatus = nsSettingsStatus;
|
||||||
|
this.config = config;
|
||||||
|
this.runningConfiguration = runningConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleNewData(JSONArray devicestatuses) {
|
public void handleNewData(JSONArray devicestatuses) {
|
||||||
|
@ -114,8 +123,13 @@ public class NSDeviceStatus {
|
||||||
// Objectives 0
|
// Objectives 0
|
||||||
sp.putBoolean(R.string.key_ObjectivespumpStatusIsAvailableInNS, true);
|
sp.putBoolean(R.string.key_ObjectivespumpStatusIsAvailableInNS, true);
|
||||||
}
|
}
|
||||||
|
if (devicestatusJson.has("configuration") && config.getNSCLIENT()) {
|
||||||
|
// copy configuration of Insulin and Sensitivity from main AAPS
|
||||||
|
runningConfiguration.apply(devicestatusJson.getJSONObject("configuration"));
|
||||||
}
|
}
|
||||||
} catch (JSONException ignored) {
|
}
|
||||||
|
} catch (JSONException jsonException) {
|
||||||
|
jsonException.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@ class InsulinFragment : DaggerFragment() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
insulin_name?.setText(activePlugin.getActiveInsulin().getFriendlyName())
|
insulin_name?.setText(activePlugin.getActiveInsulin().friendlyName)
|
||||||
insulin_comment?.setText(activePlugin.getActiveInsulin().getComment())
|
insulin_comment?.setText(activePlugin.getActiveInsulin().comment)
|
||||||
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.getActiveInsulin().getDia() + "h"
|
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.getActiveInsulin().dia + "h"
|
||||||
insulin_graph?.show(activePlugin.getActiveInsulin())
|
insulin_graph?.show(activePlugin.getActiveInsulin())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,10 +3,11 @@ package info.nightscout.androidaps.plugins.insulin
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -18,10 +19,11 @@ class InsulinLyumjevPlugin @Inject constructor(
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||||
|
|
||||||
|
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.OREF_LYUMJEV
|
||||||
|
override val friendlyName get(): String = resourceHelper.gs(R.string.lyumjev)
|
||||||
|
|
||||||
override fun getId(): Int = InsulinInterface.OREF_LYUMJEV
|
override fun configuration(): JSONObject = JSONObject()
|
||||||
|
override fun applyConfiguration(configuration: JSONObject) {}
|
||||||
override fun getFriendlyName(): String = resourceHelper.gs(R.string.lyumjev)
|
|
||||||
|
|
||||||
override fun commentStandardText(): String = resourceHelper.gs(R.string.lyumjev)
|
override fun commentStandardText(): String = resourceHelper.gs(R.string.lyumjev)
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,16 @@ package info.nightscout.androidaps.plugins.insulin
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Iob
|
import info.nightscout.androidaps.data.Iob
|
||||||
|
import info.nightscout.androidaps.db.Treatment
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
import info.nightscout.androidaps.db.Treatment
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,8 @@ abstract class InsulinOrefBasePlugin(
|
||||||
), InsulinInterface {
|
), InsulinInterface {
|
||||||
|
|
||||||
private var lastWarned: Long = 0
|
private var lastWarned: Long = 0
|
||||||
override fun getDia(): Double {
|
override val dia
|
||||||
|
get(): Double {
|
||||||
val dia = userDefinedDia
|
val dia = userDefinedDia
|
||||||
return if (dia >= MIN_DIA) {
|
return if (dia >= MIN_DIA) {
|
||||||
dia
|
dia
|
||||||
|
@ -72,7 +73,7 @@ abstract class InsulinOrefBasePlugin(
|
||||||
if (treatment.insulin != 0.0) {
|
if (treatment.insulin != 0.0) {
|
||||||
val bolusTime = treatment.date
|
val bolusTime = treatment.date
|
||||||
val t = (time - bolusTime) / 1000.0 / 60.0
|
val t = (time - bolusTime) / 1000.0 / 60.0
|
||||||
val td = getDia() * 60 //getDIA() always >= MIN_DIA
|
val td = dia * 60 //getDIA() always >= MIN_DIA
|
||||||
val tp = peak.toDouble()
|
val tp = peak.toDouble()
|
||||||
// force the IOB to 0 if over DIA hours have passed
|
// force the IOB to 0 if over DIA hours have passed
|
||||||
if (t < td) {
|
if (t < td) {
|
||||||
|
@ -86,7 +87,8 @@ abstract class InsulinOrefBasePlugin(
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getComment(): String {
|
override val comment
|
||||||
|
get(): String {
|
||||||
var comment = commentStandardText()
|
var comment = commentStandardText()
|
||||||
val userDia = userDefinedDia
|
val userDia = userDefinedDia
|
||||||
if (userDia < MIN_DIA) {
|
if (userDia < MIN_DIA) {
|
||||||
|
@ -99,6 +101,7 @@ abstract class InsulinOrefBasePlugin(
|
||||||
abstract fun commentStandardText(): String
|
abstract fun commentStandardText(): String
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val MIN_DIA = 5.0
|
const val MIN_DIA = 5.0
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,11 +3,12 @@ package info.nightscout.androidaps.plugins.insulin
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -23,12 +24,14 @@ class InsulinOrefFreePeakPlugin @Inject constructor(
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||||
|
|
||||||
override fun getId(): Int {
|
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.OREF_FREE_PEAK
|
||||||
return InsulinInterface.OREF_FREE_PEAK
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getFriendlyName(): String {
|
override val friendlyName get(): String = resourceHelper.gs(R.string.free_peak_oref)
|
||||||
return resourceHelper.gs(R.string.free_peak_oref)
|
|
||||||
|
override fun configuration(): JSONObject = JSONObject().put(resourceHelper.gs(R.string.key_insulin_oref_peak), peak)
|
||||||
|
override fun applyConfiguration(configuration: JSONObject) {
|
||||||
|
if (configuration.has(resourceHelper.gs(R.string.key_insulin_oref_peak)))
|
||||||
|
sp.putInt(R.string.key_insulin_oref_peak, configuration.getInt(resourceHelper.gs(R.string.key_insulin_oref_peak)))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun commentStandardText(): String {
|
override fun commentStandardText(): String {
|
||||||
|
@ -39,6 +42,7 @@ class InsulinOrefFreePeakPlugin @Inject constructor(
|
||||||
get() = sp.getInt(R.string.key_insulin_oref_peak, DEFAULT_PEAK)
|
get() = sp.getInt(R.string.key_insulin_oref_peak, DEFAULT_PEAK)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val DEFAULT_PEAK = 75
|
private const val DEFAULT_PEAK = 75
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,11 @@ package info.nightscout.androidaps.plugins.insulin
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -21,18 +22,13 @@ class InsulinOrefRapidActingPlugin @Inject constructor(
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||||
|
|
||||||
|
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.OREF_RAPID_ACTING
|
||||||
|
override val friendlyName get(): String = resourceHelper.gs(R.string.rapid_acting_oref)
|
||||||
|
|
||||||
override fun getId(): Int {
|
override fun configuration(): JSONObject = JSONObject()
|
||||||
return InsulinInterface.OREF_RAPID_ACTING
|
override fun applyConfiguration(configuration: JSONObject) {}
|
||||||
}
|
|
||||||
|
|
||||||
override fun getFriendlyName(): String {
|
override fun commentStandardText(): String = resourceHelper.gs(R.string.fastactinginsulincomment)
|
||||||
return resourceHelper.gs(R.string.rapid_acting_oref)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun commentStandardText(): String {
|
|
||||||
return resourceHelper.gs(R.string.fastactinginsulincomment)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val peak = 75
|
override val peak = 75
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,11 @@ package info.nightscout.androidaps.plugins.insulin
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -21,10 +22,11 @@ class InsulinOrefUltraRapidActingPlugin @Inject constructor(
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||||
|
|
||||||
|
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.OREF_ULTRA_RAPID_ACTING
|
||||||
|
override val friendlyName get(): String = resourceHelper.gs(R.string.ultrarapid_oref)
|
||||||
|
|
||||||
override fun getId(): Int = InsulinInterface.OREF_ULTRA_RAPID_ACTING
|
override fun configuration(): JSONObject = JSONObject()
|
||||||
|
override fun applyConfiguration(configuration: JSONObject) {}
|
||||||
override fun getFriendlyName(): String = resourceHelper.gs(R.string.ultrarapid_oref)
|
|
||||||
|
|
||||||
override fun commentStandardText(): String = resourceHelper.gs(R.string.ultrafastactinginsulincomment)
|
override fun commentStandardText(): String = resourceHelper.gs(R.string.ultrafastactinginsulincomment)
|
||||||
|
|
||||||
|
|
|
@ -404,7 +404,7 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshConfiguration() {
|
fun refreshConfiguration() {
|
||||||
val pumptype = sp.getString(R.string.key_virtualpump_type, "Generic AAPS")
|
val pumptype = sp.getString(R.string.key_virtualpump_type, PumpType.GenericAAPS.description)
|
||||||
val pumpTypeNew = PumpType.getByDescription(pumptype)
|
val pumpTypeNew = PumpType.getByDescription(pumptype)
|
||||||
aapsLogger.debug(LTag.PUMP, "Pump in configuration: $pumptype, PumpType object: $pumpTypeNew")
|
aapsLogger.debug(LTag.PUMP, "Pump in configuration: $pumptype, PumpType object: $pumpTypeNew")
|
||||||
if (pumpType == pumpTypeNew) return
|
if (pumpType == pumpTypeNew) return
|
||||||
|
|
|
@ -3,6 +3,10 @@ package info.nightscout.androidaps.plugins.sensitivity;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.collection.LongSparseArray;
|
import androidx.collection.LongSparseArray;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -11,6 +15,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
@ -22,6 +27,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
@ -179,4 +185,36 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public SensitivityType getId() {
|
||||||
|
return SensitivityType.SENSITIVITY_AAPS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public JSONObject configuration() {
|
||||||
|
JSONObject c = new JSONObject();
|
||||||
|
try {
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_absorption_maxtime), getSp().getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_autosens_period), getSp().getInt(R.string.key_openapsama_autosens_period, 24));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_autosens_max), getSp().getDouble(R.string.key_openapsama_autosens_max, 1.2));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_autosens_min), getSp().getDouble(R.string.key_openapsama_autosens_min, 0.7));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void applyConfiguration(@NotNull JSONObject configuration) {
|
||||||
|
try {
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_absorption_maxtime)))
|
||||||
|
getSp().putDouble(R.string.key_absorption_maxtime, configuration.getDouble(getResourceHelper().gs(R.string.key_absorption_maxtime)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_autosens_period)))
|
||||||
|
getSp().putDouble(R.string.key_openapsama_autosens_period, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_autosens_period)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_autosens_max)))
|
||||||
|
getSp().getDouble(R.string.key_openapsama_autosens_max, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_autosens_max)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_autosens_min)))
|
||||||
|
getSp().getDouble(R.string.key_openapsama_autosens_min, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_autosens_min)));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.sensitivity;
|
||||||
import androidx.collection.LongSparseArray;
|
import androidx.collection.LongSparseArray;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -12,6 +14,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
@ -23,6 +26,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData;
|
||||||
|
@ -246,4 +250,36 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public JSONObject configuration() {
|
||||||
|
JSONObject c = new JSONObject();
|
||||||
|
try {
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_min_5m_carbimpact), getSp().getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_absorption_cutoff), getSp().getDouble(R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_autosens_max), getSp().getDouble(R.string.key_openapsama_autosens_max, 1.2));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_autosens_min), getSp().getDouble(R.string.key_openapsama_autosens_min, 0.7));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void applyConfiguration(@NotNull JSONObject configuration) {
|
||||||
|
try {
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_min_5m_carbimpact)))
|
||||||
|
getSp().putDouble(R.string.key_openapsama_min_5m_carbimpact, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_min_5m_carbimpact)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_absorption_cutoff)))
|
||||||
|
getSp().putDouble(R.string.key_absorption_cutoff, configuration.getDouble(getResourceHelper().gs(R.string.key_absorption_cutoff)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_autosens_max)))
|
||||||
|
getSp().getDouble(R.string.key_openapsama_autosens_max, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_autosens_max)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_autosens_min)))
|
||||||
|
getSp().getDouble(R.string.key_openapsama_autosens_min, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_autosens_min)));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public SensitivityType getId() {
|
||||||
|
return SensitivityType.SENSITIVITY_OREF1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,17 @@ package info.nightscout.androidaps.plugins.sensitivity;
|
||||||
|
|
||||||
import androidx.collection.LongSparseArray;
|
import androidx.collection.LongSparseArray;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
@ -199,4 +204,36 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public SensitivityType getId() {
|
||||||
|
return SensitivityType.SENSITIVITY_WEIGHTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public JSONObject configuration() {
|
||||||
|
JSONObject c = new JSONObject();
|
||||||
|
try {
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_absorption_maxtime), getSp().getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_autosens_period), getSp().getInt(R.string.key_openapsama_autosens_period, 24));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_autosens_max), getSp().getDouble(R.string.key_openapsama_autosens_max, 1.2));
|
||||||
|
c.put(getResourceHelper().gs(R.string.key_openapsama_autosens_min), getSp().getDouble(R.string.key_openapsama_autosens_min, 0.7));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void applyConfiguration(@NotNull JSONObject configuration) {
|
||||||
|
try {
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_absorption_maxtime)))
|
||||||
|
getSp().putDouble(R.string.key_absorption_maxtime, configuration.getDouble(getResourceHelper().gs(R.string.key_absorption_maxtime)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_autosens_period)))
|
||||||
|
getSp().putDouble(R.string.key_openapsama_autosens_period, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_autosens_period)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_autosens_max)))
|
||||||
|
getSp().getDouble(R.string.key_openapsama_autosens_max, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_autosens_max)));
|
||||||
|
if (configuration.has(getResourceHelper().gs(R.string.key_openapsama_autosens_min)))
|
||||||
|
getSp().getDouble(R.string.key_openapsama_autosens_min, configuration.getDouble(getResourceHelper().gs(R.string.key_openapsama_autosens_min)));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -932,7 +932,6 @@
|
||||||
<string name="openapsama_max_daily_safety_multiplier">Max daily safety multiplier</string>
|
<string name="openapsama_max_daily_safety_multiplier">Max daily safety multiplier</string>
|
||||||
<string name="openapsama_current_basal_safety_multiplier">Current basal safety multiplier</string>
|
<string name="openapsama_current_basal_safety_multiplier">Current basal safety multiplier</string>
|
||||||
<string name="value_unavailable_short">n/a</string>
|
<string name="value_unavailable_short">n/a</string>
|
||||||
<string name="key_virtualpump_type" translatable="false">virtualpump_type</string>
|
|
||||||
<string name="key_virtualpump_uploadstatus" translatable="false">virtualpump_uploadstatus</string>
|
<string name="key_virtualpump_uploadstatus" translatable="false">virtualpump_uploadstatus</string>
|
||||||
<string name="virtualpump_type">Virtual Pump Type</string>
|
<string name="virtualpump_type">Virtual Pump Type</string>
|
||||||
<string name="virtualpump_definition">Pump Definition</string>
|
<string name="virtualpump_definition">Pump Definition</string>
|
||||||
|
|
|
@ -47,7 +47,7 @@ class InsulinLyumjevPluginTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getIdTest() {
|
fun getIdTest() {
|
||||||
assertEquals(InsulinInterface.OREF_LYUMJEV, sut.id)
|
assertEquals(InsulinInterface.InsulinType.OREF_LYUMJEV, sut.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -9,8 +9,10 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA
|
||||||
import info.nightscout.androidaps.db.Treatment
|
import info.nightscout.androidaps.db.Treatment
|
||||||
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.json.JSONObject
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
|
@ -46,8 +48,10 @@ class InsulinOrefBasePluginTest {
|
||||||
get() = testPeak
|
get() = testPeak
|
||||||
|
|
||||||
override fun commentStandardText(): String = ""
|
override fun commentStandardText(): String = ""
|
||||||
override fun getId(): Int = 0
|
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.UNKNOWN
|
||||||
override fun getFriendlyName(): String = ""
|
override val friendlyName get(): String = ""
|
||||||
|
override fun configuration(): JSONObject = JSONObject()
|
||||||
|
override fun applyConfiguration(configuration: JSONObject) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
|
|
|
@ -54,7 +54,7 @@ class InsulinOrefFreePeakPluginTest : TestBase() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getIdTest() {
|
fun getIdTest() {
|
||||||
assertEquals(InsulinInterface.OREF_FREE_PEAK, sut.id)
|
assertEquals(InsulinInterface.InsulinType.OREF_FREE_PEAK, sut.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -47,7 +47,7 @@ class InsulinOrefRapidActingPluginTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getIdTest() {
|
fun getIdTest() {
|
||||||
assertEquals(InsulinInterface.OREF_RAPID_ACTING, sut.id)
|
assertEquals(InsulinInterface.InsulinType.OREF_RAPID_ACTING, sut.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -47,7 +47,7 @@ class InsulinOrefUltraRapidActingPluginTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getIdTest() {
|
fun getIdTest() {
|
||||||
assertEquals(InsulinInterface.OREF_ULTRA_RAPID_ACTING, sut.id)
|
assertEquals(InsulinInterface.InsulinType.OREF_ULTRA_RAPID_ACTING, sut.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -5,11 +5,13 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface
|
import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
|
import info.nightscout.androidaps.interfaces.SensitivityInterface
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import org.json.JSONObject
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -28,6 +30,13 @@ class AbstractSensitivityPluginTest : TestBase() {
|
||||||
override fun detectSensitivity(plugin: IobCobCalculatorInterface, fromTime: Long, toTime: Long): AutosensResult {
|
override fun detectSensitivity(plugin: IobCobCalculatorInterface, fromTime: Long, toTime: Long): AutosensResult {
|
||||||
return AutosensResult()
|
return AutosensResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val id: SensitivityInterface.SensitivityType
|
||||||
|
get() = SensitivityInterface.SensitivityType.UNKNOWN
|
||||||
|
|
||||||
|
override fun configuration(): JSONObject = JSONObject()
|
||||||
|
|
||||||
|
override fun applyConfiguration(configuration: JSONObject) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
public int durationInMinutes = 0; // duration == 0 means end of extended bolus
|
public int durationInMinutes = 0; // duration == 0 means end of extended bolus
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public int insulinInterfaceID = InsulinInterface.OREF_RAPID_ACTING;
|
public int insulinInterfaceID = InsulinInterface.InsulinType.OREF_RAPID_ACTING.getValue();
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double dia = Constants.defaultDIA;
|
public double dia = Constants.defaultDIA;
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class Treatment implements DataPointWithLabelInterface, DbObjectBase {
|
||||||
public boolean isSMB = false;
|
public boolean isSMB = false;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public int insulinInterfaceID = InsulinInterface.OREF_RAPID_ACTING; // currently unused, will be used in the future
|
public int insulinInterfaceID = InsulinInterface.InsulinType.OREF_RAPID_ACTING.getValue(); // currently unused, will be used in the future
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double dia = Constants.defaultDIA; // currently unused, will be used in the future
|
public double dia = Constants.defaultDIA; // currently unused, will be used in the future
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
|
|
|
@ -2,4 +2,5 @@ package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
interface ConfigBuilderInterface {
|
interface ConfigBuilderInterface {
|
||||||
fun storeSettings(from: String)
|
fun storeSettings(from: String)
|
||||||
|
fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType)
|
||||||
}
|
}
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 17.04.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface InsulinInterface {
|
|
||||||
// int FASTACTINGINSULIN = 0; // old model no longer available
|
|
||||||
// int FASTACTINGINSULINPROLONGED = 1; // old model no longer available
|
|
||||||
int OREF_RAPID_ACTING = 2;
|
|
||||||
int OREF_ULTRA_RAPID_ACTING = 3;
|
|
||||||
int OREF_FREE_PEAK = 4;
|
|
||||||
int OREF_LYUMJEV = 5;
|
|
||||||
|
|
||||||
|
|
||||||
int getId();
|
|
||||||
String getFriendlyName();
|
|
||||||
String getComment();
|
|
||||||
double getDia();
|
|
||||||
Iob iobCalcForTreatment(Treatment treatment, long time, double dia);
|
|
||||||
}
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.data.Iob
|
||||||
|
import info.nightscout.androidaps.db.Treatment
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
interface InsulinInterface {
|
||||||
|
|
||||||
|
enum class InsulinType(val value: Int) {
|
||||||
|
UNKNOWN(-1),
|
||||||
|
// int FASTACTINGINSULIN = 0; // old model no longer available
|
||||||
|
// int FASTACTINGINSULINPROLONGED = 1; // old model no longer available
|
||||||
|
OREF_RAPID_ACTING(2),
|
||||||
|
OREF_ULTRA_RAPID_ACTING(3),
|
||||||
|
OREF_FREE_PEAK(4),
|
||||||
|
OREF_LYUMJEV(5);
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val map = values().associateBy(InsulinType::value)
|
||||||
|
fun fromInt(type: Int) = map[type]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val id: InsulinType
|
||||||
|
val friendlyName: String
|
||||||
|
val comment: String
|
||||||
|
val dia: Double
|
||||||
|
|
||||||
|
fun iobCalcForTreatment(treatment: Treatment, time: Long, dia: Double): Iob
|
||||||
|
|
||||||
|
fun configuration(): JSONObject
|
||||||
|
fun applyConfiguration(configuration: JSONObject)
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 24.06.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface SensitivityInterface {
|
|
||||||
|
|
||||||
double MIN_HOURS = 1;
|
|
||||||
double MIN_HOURS_FULL_AUTOSENS = 4;
|
|
||||||
|
|
||||||
AutosensResult detectSensitivity(IobCobCalculatorInterface plugin, long fromTime, long toTime);
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
interface SensitivityInterface {
|
||||||
|
|
||||||
|
enum class SensitivityType(val value: Int) {
|
||||||
|
UNKNOWN(-1),
|
||||||
|
SENSITIVITY_AAPS(0),
|
||||||
|
SENSITIVITY_WEIGHTED(1),
|
||||||
|
SENSITIVITY_OREF1(2);
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val map = values().associateBy(SensitivityType::value)
|
||||||
|
fun fromInt(type: Int) = map[type]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val id: SensitivityType
|
||||||
|
fun detectSensitivity(plugin: IobCobCalculatorInterface, fromTime: Long, toTime: Long): AutosensResult
|
||||||
|
|
||||||
|
fun configuration(): JSONObject
|
||||||
|
fun applyConfiguration(configuration: JSONObject)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val MIN_HOURS = 1.0
|
||||||
|
const val MIN_HOURS_FULL_AUTOSENS = 4.0
|
||||||
|
}
|
||||||
|
}
|
|
@ -375,6 +375,7 @@ public class DeviceStatus {
|
||||||
public JSONObject iob = null;
|
public JSONObject iob = null;
|
||||||
public int uploaderBattery = 0;
|
public int uploaderBattery = 0;
|
||||||
public String created_at = null;
|
public String created_at = null;
|
||||||
|
public JSONObject configuration = null;
|
||||||
|
|
||||||
public DeviceStatus(AAPSLogger aapsLogger) {
|
public DeviceStatus(AAPSLogger aapsLogger) {
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
|
@ -393,6 +394,7 @@ public class DeviceStatus {
|
||||||
record.put("openaps", openaps);
|
record.put("openaps", openaps);
|
||||||
if (uploaderBattery != 0) record.put("uploaderBattery", uploaderBattery);
|
if (uploaderBattery != 0) record.put("uploaderBattery", uploaderBattery);
|
||||||
if (created_at != null) record.put("created_at", created_at);
|
if (created_at != null) record.put("created_at", created_at);
|
||||||
|
if (configuration != null) record.put("configuration", configuration);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
aapsLogger.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
package info.nightscout.androidaps.plugins.configBuilder
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.core.R
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.interfaces.SensitivityInterface
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import org.json.JSONException
|
||||||
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class RunningConfiguration @Inject constructor(
|
||||||
|
private val activePlugin: ActivePluginProvider,
|
||||||
|
private val configBuilder: ConfigBuilderInterface,
|
||||||
|
private val sp: SP,
|
||||||
|
private val aapsLogger: AAPSLogger
|
||||||
|
) {
|
||||||
|
|
||||||
|
// called in AAPS mode only
|
||||||
|
fun configuration(): JSONObject {
|
||||||
|
val json = JSONObject()
|
||||||
|
try {
|
||||||
|
val insulinInterface = activePlugin.activeInsulin
|
||||||
|
val sensitivityInterface = activePlugin.activeSensitivity
|
||||||
|
val pumpInterface = activePlugin.activePump
|
||||||
|
|
||||||
|
json.put("insulin", insulinInterface.id.value)
|
||||||
|
json.put("insulinConfiguration", insulinInterface.configuration())
|
||||||
|
json.put("sensitivity", sensitivityInterface.id.value)
|
||||||
|
json.put("sensitivityConfiguration", sensitivityInterface.configuration())
|
||||||
|
json.put("pump", pumpInterface.model().description)
|
||||||
|
} catch (e: JSONException) {
|
||||||
|
aapsLogger.error("Unhandled exception", e)
|
||||||
|
}
|
||||||
|
return json
|
||||||
|
}
|
||||||
|
|
||||||
|
// called in NSClient mode only
|
||||||
|
fun apply(configuration: JSONObject) {
|
||||||
|
val insulin = InsulinInterface.InsulinType.fromInt(JsonHelper.safeGetInt(configuration, "insulin", InsulinInterface.InsulinType.UNKNOWN.value))
|
||||||
|
for (p in activePlugin.getSpecificPluginsListByInterface(InsulinInterface::class.java)) {
|
||||||
|
val insulinPlugin = p as InsulinInterface
|
||||||
|
if (insulinPlugin.id == insulin) {
|
||||||
|
if (!p.isEnabled()) {
|
||||||
|
aapsLogger.debug(LTag.CORE, "Changing insulin plugin to ${insulin.name}")
|
||||||
|
configBuilder.performPluginSwitch(p, true, PluginType.INSULIN)
|
||||||
|
}
|
||||||
|
insulinPlugin.applyConfiguration(configuration.getJSONObject("insulinConfiguration"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val sensitivity = SensitivityInterface.SensitivityType.fromInt(JsonHelper.safeGetInt(configuration, "sensitivity", SensitivityInterface.SensitivityType.UNKNOWN.value))
|
||||||
|
for (p in activePlugin.getSpecificPluginsListByInterface(SensitivityInterface::class.java)) {
|
||||||
|
val sensitivityPlugin = p as SensitivityInterface
|
||||||
|
if (sensitivityPlugin.id == sensitivity) {
|
||||||
|
if (!p.isEnabled()) {
|
||||||
|
aapsLogger.debug(LTag.CORE, "Changing sensitivity plugin to ${sensitivity.name}")
|
||||||
|
configBuilder.performPluginSwitch(p, true, PluginType.SENSITIVITY)
|
||||||
|
}
|
||||||
|
sensitivityPlugin.applyConfiguration(configuration.getJSONObject("sensitivityConfiguration"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val pumpType = JsonHelper.safeGetString(configuration, "pump", PumpType.GenericAAPS.description)
|
||||||
|
sp.putString(R.string.key_virtualpump_type, pumpType)
|
||||||
|
activePlugin.activePump.pumpDescription.setPumpDescription(PumpType.getByDescription(pumpType))
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,10 +42,10 @@ import info.nightscout.androidaps.interfaces.ProfileStore;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.UploadQueueInterface;
|
import info.nightscout.androidaps.interfaces.UploadQueueInterface;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.DeviceStatus;
|
import info.nightscout.androidaps.plugins.aps.loop.DeviceStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration;
|
||||||
import info.nightscout.androidaps.receivers.ReceiverStatusStore;
|
import info.nightscout.androidaps.receivers.ReceiverStatusStore;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.JsonHelper;
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
|
@ -65,6 +65,7 @@ public class NSUpload {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final UploadQueueInterface uploadQueue;
|
private final UploadQueueInterface uploadQueue;
|
||||||
private final DatabaseHelperInterface databaseHelper;
|
private final DatabaseHelperInterface databaseHelper;
|
||||||
|
private final RunningConfiguration runningConfiguration;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NSUpload(
|
public NSUpload(
|
||||||
|
@ -74,6 +75,7 @@ public class NSUpload {
|
||||||
SP sp,
|
SP sp,
|
||||||
Context context,
|
Context context,
|
||||||
UploadQueueInterface uploadQueue,
|
UploadQueueInterface uploadQueue,
|
||||||
|
RunningConfiguration runningConfiguration,
|
||||||
DatabaseHelperInterface databaseHelper
|
DatabaseHelperInterface databaseHelper
|
||||||
) {
|
) {
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
|
@ -82,6 +84,7 @@ public class NSUpload {
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.uploadQueue = uploadQueue;
|
this.uploadQueue = uploadQueue;
|
||||||
|
this.runningConfiguration = runningConfiguration;
|
||||||
this.databaseHelper = databaseHelper;
|
this.databaseHelper = databaseHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +252,9 @@ public class NSUpload {
|
||||||
deviceStatus.uploaderBattery = batteryLevel;
|
deviceStatus.uploaderBattery = batteryLevel;
|
||||||
|
|
||||||
deviceStatus.created_at = DateUtil.toISOString(new Date());
|
deviceStatus.created_at = DateUtil.toISOString(new Date());
|
||||||
|
|
||||||
|
deviceStatus.configuration = runningConfiguration.configuration();
|
||||||
|
|
||||||
uploadQueue.add(new DbRequest("dbAdd", "devicestatus", deviceStatus.mongoRecord()));
|
uploadQueue.add(new DbRequest("dbAdd", "devicestatus", deviceStatus.mongoRecord()));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
aapsLogger.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
<string name="key_missed_bg_readings_threshold_minutes" translatable="false">missed_bg_readings_threshold</string>
|
<string name="key_missed_bg_readings_threshold_minutes" translatable="false">missed_bg_readings_threshold</string>
|
||||||
<string name="key_gradually_increase_notification_volume" translatable="false">gradually_increase_notification_volume</string>
|
<string name="key_gradually_increase_notification_volume" translatable="false">gradually_increase_notification_volume</string>
|
||||||
<string name="key_ns_sync_use_absolute" translatable="false">ns_sync_use_absolute</string>
|
<string name="key_ns_sync_use_absolute" translatable="false">ns_sync_use_absolute</string>
|
||||||
|
<string name="key_virtualpump_type" translatable="false">virtualpump_type</string>
|
||||||
|
|
||||||
<!-- General-->
|
<!-- General-->
|
||||||
<string name="error">Error</string>
|
<string name="error">Error</string>
|
||||||
|
|
Loading…
Reference in a new issue