Merge branch 'dev' of https://github.com/nightscout/AndroidAPS into avereha/merge-dev-6

This commit is contained in:
Andrei Vereha 2021-09-21 21:17:53 +02:00
commit 2a2cf9fa3c
13 changed files with 82 additions and 140 deletions

View file

@ -54,9 +54,8 @@ class ObjectivesPlugin @Inject constructor(
const val MAXIOB_ZERO_CL_OBJECTIVE = 5 const val MAXIOB_ZERO_CL_OBJECTIVE = 5
@Suppress("unused") const val MAXIOB_OBJECTIVE = 6 @Suppress("unused") const val MAXIOB_OBJECTIVE = 6
const val AUTOSENS_OBJECTIVE = 7 const val AUTOSENS_OBJECTIVE = 7
const val AMA_OBJECTIVE = 8 const val SMB_OBJECTIVE = 8
const val SMB_OBJECTIVE = 9 const val AUTO_OBJECTIVE = 9
const val AUTO_OBJECTIVE = 10
} }
public override fun onStart() { public override fun onStart() {
@ -64,9 +63,8 @@ class ObjectivesPlugin @Inject constructor(
setupObjectives() setupObjectives()
} }
override fun specialEnableCondition(): Boolean { override fun specialEnableCondition(): Boolean =
return activePlugin.activePump.pumpDescription.isTempBasalCapable activePlugin.activePump.pumpDescription.isTempBasalCapable
}
private fun setupObjectives() { private fun setupObjectives() {
objectives.clear() objectives.clear()
@ -80,6 +78,7 @@ class ObjectivesPlugin @Inject constructor(
objectives.add(Objective7(injector)) objectives.add(Objective7(injector))
objectives.add(Objective9(injector)) objectives.add(Objective9(injector))
objectives.add(Objective10(injector)) objectives.add(Objective10(injector))
// edit companion object if you remove/add Objective
} }
fun reset() { fun reset() {
@ -115,8 +114,6 @@ class ObjectivesPlugin @Inject constructor(
sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil.now()) sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "autosens" + "_started", dateUtil.now()) sp.putLong("Objectives_" + "autosens" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "autosens" + "_accomplished", dateUtil.now()) sp.putLong("Objectives_" + "autosens" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "ama" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "ama" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "smb" + "_started", dateUtil.now()) sp.putLong("Objectives_" + "smb" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil.now()) sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "auto" + "_started", dateUtil.now()) sp.putLong("Objectives_" + "auto" + "_started", dateUtil.now())
@ -142,49 +139,43 @@ class ObjectivesPlugin @Inject constructor(
*/ */
override fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> { override fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[FIRST_OBJECTIVE].isStarted) if (!objectives[FIRST_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), FIRST_OBJECTIVE + 1), this) value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, FIRST_OBJECTIVE + 1), this)
return value return value
} }
override fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> { override fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[MAXBASAL_OBJECTIVE].isStarted) if (!objectives[MAXBASAL_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), MAXBASAL_OBJECTIVE + 1), this) value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, MAXBASAL_OBJECTIVE + 1), this)
return value return value
} }
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> { override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted) if (!objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), MAXIOB_ZERO_CL_OBJECTIVE + 1), this) value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
return value return value
} }
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> { override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[AUTOSENS_OBJECTIVE].isStarted) if (!objectives[AUTOSENS_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AUTOSENS_OBJECTIVE + 1), this) value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, AUTOSENS_OBJECTIVE + 1), this)
return value
}
override fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[AMA_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AMA_OBJECTIVE + 1), this)
return value return value
} }
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> { override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[SMB_OBJECTIVE].isStarted) if (!objectives[SMB_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), SMB_OBJECTIVE + 1), this) value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, SMB_OBJECTIVE + 1), this)
return value return value
} }
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> { override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
if (objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted && !objectives[MAXIOB_ZERO_CL_OBJECTIVE].isAccomplished) if (objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted && !objectives[MAXIOB_ZERO_CL_OBJECTIVE].isAccomplished)
maxIob.set(aapsLogger, 0.0, String.format(resourceHelper.gs(R.string.objectivenotfinished), MAXIOB_ZERO_CL_OBJECTIVE + 1), this) maxIob.set(aapsLogger, 0.0, resourceHelper.gs(R.string.objectivenotfinished, MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
return maxIob return maxIob
} }
override fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> { override fun isAutomationEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
if (!objectives[AUTO_OBJECTIVE].isStarted) if (!objectives[AUTO_OBJECTIVE].isStarted)
value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AUTO_OBJECTIVE + 1), this) value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, AUTO_OBJECTIVE + 1), this)
return value return value
} }
} }

View file

@ -156,7 +156,7 @@ class ActionsFragment : DaggerFragment() {
pbLevelLabel = view.findViewById(R.id.pb_level_label) pbLevelLabel = view.findViewById(R.id.pb_level_label)
profileSwitch?.setOnClickListener { profileSwitch?.setOnClickListener {
ProfileSwitchDialog().show(childFragmentManager, "Actions") ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog")
} }
tempTarget?.setOnClickListener { tempTarget?.setOnClickListener {
TempTargetDialog().show(childFragmentManager, "Actions") TempTargetDialog().show(childFragmentManager, "Actions")

View file

@ -377,7 +377,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
R.id.temp_target -> v.performClick() R.id.temp_target -> v.performClick()
R.id.active_profile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") }) } R.id.active_profile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") }) }
} }
return false return false

View file

@ -29,12 +29,9 @@ import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.AndroidInjection; import dagger.android.AndroidInjection;
import info.nightscout.androidaps.interfaces.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.interfaces.GlucoseUnit;
import info.nightscout.androidaps.interfaces.Profile;
import info.nightscout.androidaps.database.AppRepository; import info.nightscout.androidaps.database.AppRepository;
import info.nightscout.androidaps.database.entities.Bolus; import info.nightscout.androidaps.database.entities.Bolus;
import info.nightscout.androidaps.database.entities.GlucoseValue; import info.nightscout.androidaps.database.entities.GlucoseValue;
@ -42,8 +39,11 @@ import info.nightscout.androidaps.database.entities.TemporaryBasal;
import info.nightscout.androidaps.extensions.GlucoseValueExtensionKt; import info.nightscout.androidaps.extensions.GlucoseValueExtensionKt;
import info.nightscout.androidaps.extensions.TemporaryBasalExtensionKt; import info.nightscout.androidaps.extensions.TemporaryBasalExtensionKt;
import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.interfaces.ActivePlugin;
import info.nightscout.androidaps.interfaces.Config;
import info.nightscout.androidaps.interfaces.GlucoseUnit;
import info.nightscout.androidaps.interfaces.IobCobCalculator; import info.nightscout.androidaps.interfaces.IobCobCalculator;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.Profile;
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;
@ -59,7 +59,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv
import info.nightscout.androidaps.receivers.ReceiverStatusStore; import info.nightscout.androidaps.receivers.ReceiverStatusStore;
import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.DefaultValueHelper; import info.nightscout.androidaps.utils.DefaultValueHelper;
import info.nightscout.androidaps.utils.ToastUtils; import info.nightscout.androidaps.utils.TrendCalculator;
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;
@ -79,6 +79,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
@Inject public AppRepository repository; @Inject public AppRepository repository;
@Inject ReceiverStatusStore receiverStatusStore; @Inject ReceiverStatusStore receiverStatusStore;
@Inject Config config; @Inject Config config;
@Inject public TrendCalculator trendCalculator;
public static final String ACTION_RESEND = WatchUpdaterService.class.getName().concat(".Resend"); public static final String ACTION_RESEND = WatchUpdaterService.class.getName().concat(".Resend");
public static final String ACTION_OPEN_SETTINGS = WatchUpdaterService.class.getName().concat(".OpenSettings"); public static final String ACTION_OPEN_SETTINGS = WatchUpdaterService.class.getName().concat(".OpenSettings");
@ -322,7 +323,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
dataMap.putString("delta", "--"); dataMap.putString("delta", "--");
dataMap.putString("avgDelta", "--"); dataMap.putString("avgDelta", "--");
} else { } else {
dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.getDelta())); dataMap.putString("slopeArrow", trendCalculator.getTrendArrow(lastBG).getSymbol());
dataMap.putString("delta", deltastring(glucoseStatus.getDelta(), glucoseStatus.getDelta() * Constants.MGDL_TO_MMOLL, units)); dataMap.putString("delta", deltastring(glucoseStatus.getDelta(), glucoseStatus.getDelta() * Constants.MGDL_TO_MMOLL, units));
dataMap.putString("avgDelta", deltastring(glucoseStatus.getShortAvgDelta(), glucoseStatus.getShortAvgDelta() * Constants.MGDL_TO_MMOLL, units)); dataMap.putString("avgDelta", deltastring(glucoseStatus.getShortAvgDelta(), glucoseStatus.getShortAvgDelta() * Constants.MGDL_TO_MMOLL, units));
} }
@ -358,25 +359,6 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
return deltastring; return deltastring;
} }
private String slopeArrow(double delta) {
if (delta <= (-3.5 * 5)) {
return "\u21ca";
} else if (delta <= (-2 * 5)) {
return "\u2193";
} else if (delta <= (-1 * 5)) {
return "\u2198";
} else if (delta <= (1 * 5)) {
return "\u2192";
} else if (delta <= (2 * 5)) {
return "\u2197";
} else if (delta <= (3.5 * 5)) {
return "\u2191";
} else {
return "\u21c8";
}
}
private void resendData() { private void resendData() {
if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) { if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
googleApiConnect(); googleApiConnect();
@ -391,16 +373,10 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
if (!graph_bgs.isEmpty()) { if (!graph_bgs.isEmpty()) {
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus); DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
if (entries == null) {
ToastUtils.showToastInUiThread(this, resourceHelper.gs(R.string.noprofile));
return;
}
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size()); final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
for (GlucoseValue bg : graph_bgs) { for (GlucoseValue bg : graph_bgs) {
DataMap dataMap = dataMapSingleBG(bg, glucoseStatus); DataMap dataMap = dataMapSingleBG(bg, glucoseStatus);
if (dataMap != null) { dataMaps.add(dataMap);
dataMaps.add(dataMap);
}
} }
entries.putDataMapArrayList("entries", dataMaps); entries.putDataMapArrayList("entries", dataMaps);
(new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, entries); (new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, entries);
@ -505,7 +481,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
tb2 = iobCobCalculator.getTempBasalIncludingConvertedExtended(now); //use "now" to express current situation tb2 = iobCobCalculator.getTempBasalIncludingConvertedExtended(now); //use "now" to express current situation
if (tb2 == null) { if (tb2 == null) {
//express the cancelled temp by painting it down one minute early //express the cancelled temp by painting it down one minute early
temps.add(tempDatamap(tb_start, tb_before, now - 1 * 60 * 1000, endBasalValue, tb_amount)); temps.add(tempDatamap(tb_start, tb_before, now - 60 * 1000, endBasalValue, tb_amount));
} else { } else {
//express currently running temp by painting it a bit into the future //express currently running temp by painting it a bit into the future
Profile profileNow = profileFunction.getProfile(now); Profile profileNow = profileFunction.getProfile(now);
@ -523,7 +499,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
//onset at the end //onset at the end
Profile profileTB = profileFunction.getProfile(runningTime); Profile profileTB = profileFunction.getProfile(runningTime);
double currentAmount = TemporaryBasalExtensionKt.convertedToAbsolute(tb2, runningTime, profileTB); double currentAmount = TemporaryBasalExtensionKt.convertedToAbsolute(tb2, runningTime, profileTB);
temps.add(tempDatamap(now - 1 * 60 * 1000, endBasalValue, runningTime + 5 * 60 * 1000, currentAmount, currentAmount)); temps.add(tempDatamap(now - 60 * 1000, endBasalValue, runningTime + 5 * 60 * 1000, currentAmount, currentAmount));
} }
} }

View file

@ -212,7 +212,7 @@ class LocalProfileFragment : DaggerFragment() {
binding.profileswitch.setOnClickListener { binding.profileswitch.setOnClickListener {
ProfileSwitchDialog() ProfileSwitchDialog()
.also { it.arguments = Bundle().also { bundle -> bundle.putInt("profileIndex", localProfilePlugin.currentProfileIndex) } } .also { it.arguments = Bundle().also { bundle -> bundle.putInt("profileIndex", localProfilePlugin.currentProfileIndex) } }
.show(childFragmentManager, "NewNSTreatmentDialog") .show(childFragmentManager, "ProfileSwitchDialog")
} }
binding.reset.setOnClickListener { binding.reset.setOnClickListener {
@ -259,7 +259,7 @@ class LocalProfileFragment : DaggerFragment() {
updateGUI() updateGUI()
} }
fun updateGUI() { private fun updateGUI() {
if (_binding == null) return if (_binding == null) return
val isValid = localProfilePlugin.isValidEditState() val isValid = localProfilePlugin.isValidEditState()
val isEdited = localProfilePlugin.isEdited val isEdited = localProfilePlugin.isEdited

View file

@ -267,7 +267,7 @@ class SWDefinition @Inject constructor(
.label(R.string.profileswitch_ismissing)) .label(R.string.profileswitch_ismissing))
.add(SWButton(injector) .add(SWButton(injector)
.text(R.string.doprofileswitch) .text(R.string.doprofileswitch)
.action { ProfileSwitchDialog().show(activity.supportFragmentManager, "SetupWizard") }) .action { ProfileSwitchDialog().show(activity.supportFragmentManager, "ProfileSwitchDialog") })
.validator { profileFunction.getProfile() != null } .validator { profileFunction.getProfile() != null }
.visibility { profileFunction.getProfile() == null } .visibility { profileFunction.getProfile() == null }
private val screenPump = SWScreen(injector, R.string.configbuilder_pump) private val screenPump = SWScreen(injector, R.string.configbuilder_pump)

View file

@ -198,16 +198,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
Assert.assertEquals(java.lang.Boolean.FALSE, c.value()) Assert.assertEquals(java.lang.Boolean.FALSE, c.value())
} }
// Objectives
@Test
fun isAMAModeEnabledTest() {
objectivesPlugin.objectives[ObjectivesPlugin.AMA_OBJECTIVE].startedOn = 0
val c = constraintChecker.isAMAModeEnabled()
Assert.assertEquals(true, c.reasonList.size == 1) // Objectives
Assert.assertEquals(true, c.mostLimitedReasonList.size == 1) // Objectives
Assert.assertEquals(java.lang.Boolean.FALSE, c.value())
}
// Safety // Safety
@Test @Test
fun isAdvancedFilteringEnabledTest() { fun isAdvancedFilteringEnabledTest() {

View file

@ -74,14 +74,6 @@ class ObjectivesPluginTest : TestBase() {
Assert.assertEquals(false, c.value()) Assert.assertEquals(false, c.value())
} }
@Test fun notStartedObjective9ShouldLimitAMAMode() {
objectivesPlugin.objectives[ObjectivesPlugin.AMA_OBJECTIVE].startedOn = 0
var c = Constraint(true)
c = objectivesPlugin.isAMAModeEnabled(c)
Assert.assertEquals(true, c.getReasons(aapsLogger).contains("Objective 9 not started"))
Assert.assertEquals(false, c.value())
}
@Test fun notStartedObjective10ShouldLimitSMBMode() { @Test fun notStartedObjective10ShouldLimitSMBMode() {
objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0 objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0
var c = Constraint(true) var c = Constraint(true)

View file

@ -72,7 +72,6 @@ class AutomationEvent(private val injector: HasAndroidInjector) {
readOnly = d.optBoolean("readOnly", false) readOnly = d.optBoolean("readOnly", false)
autoRemove = d.optBoolean("autoRemove", false) autoRemove = d.optBoolean("autoRemove", false)
trigger = TriggerDummy(injector).instantiate(JSONObject(d.getString("trigger"))) trigger = TriggerDummy(injector).instantiate(JSONObject(d.getString("trigger")))
?: TriggerConnector(injector)
val array = d.getJSONArray("actions") val array = d.getJSONArray("actions")
actions.clear() actions.clear()
for (i in 0 until array.length()) { for (i in 0 until array.length()) {

View file

@ -95,7 +95,7 @@ class TriggerConnector(injector: HasAndroidInjector) : Trigger(injector) {
val array = d.getJSONArray("triggerList") val array = d.getJSONArray("triggerList")
list.clear() list.clear()
for (i in 0 until array.length()) { for (i in 0 until array.length()) {
instantiate(JSONObject(array.getString(i)))?.let { instantiate(JSONObject(array.getString(i))).let {
list.add(it) list.add(it)
} }
} }

View file

@ -17,7 +17,6 @@ interface Constraints {
fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value fun isLgsAllowed(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value
fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> = value

View file

@ -24,9 +24,6 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
fun isAutosensModeEnabled(): Constraint<Boolean> = fun isAutosensModeEnabled(): Constraint<Boolean> =
isAutosensModeEnabled(Constraint(true)) isAutosensModeEnabled(Constraint(true))
fun isAMAModeEnabled(): Constraint<Boolean> =
isAMAModeEnabled(Constraint(true))
fun isSMBModeEnabled(): Constraint<Boolean> = fun isSMBModeEnabled(): Constraint<Boolean> =
isSMBModeEnabled(Constraint(true)) isSMBModeEnabled(Constraint(true))
@ -100,16 +97,6 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug
return value return value
} }
override fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
for (p in constraintsPlugins) {
val constrain = p as Constraints
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue
constrain.isAMAModeEnabled(value)
}
return value
}
override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> { override fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)
for (p in constraintsPlugins) { for (p in constraintsPlugins) {

View file

@ -1,25 +1,31 @@
package info.nightscout.androidaps.database.entities package info.nightscout.androidaps.database.entities
import com.google.gson.annotations.SerializedName import androidx.room.Embedded
import androidx.room.* import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import info.nightscout.androidaps.database.TABLE_GLUCOSE_VALUES import info.nightscout.androidaps.database.TABLE_GLUCOSE_VALUES
import info.nightscout.androidaps.database.embedments.InterfaceIDs import info.nightscout.androidaps.database.embedments.InterfaceIDs
import info.nightscout.androidaps.database.interfaces.DBEntryWithTime import info.nightscout.androidaps.database.interfaces.DBEntryWithTime
import info.nightscout.androidaps.database.interfaces.TraceableDBEntry import info.nightscout.androidaps.database.interfaces.TraceableDBEntry
import java.util.TimeZone import java.util.*
@Entity(tableName = TABLE_GLUCOSE_VALUES, @Entity(
tableName = TABLE_GLUCOSE_VALUES,
foreignKeys = [ForeignKey( foreignKeys = [ForeignKey(
entity = GlucoseValue::class, entity = GlucoseValue::class,
parentColumns = ["id"], parentColumns = ["id"],
childColumns = ["referenceId"])], childColumns = ["referenceId"]
)],
indices = [ indices = [
Index("id"), Index("id"),
Index("nightscoutId"), Index("nightscoutId"),
Index("sourceSensor"), Index("sourceSensor"),
Index("referenceId"), Index("referenceId"),
Index("timestamp") Index("timestamp")
]) ]
)
data class GlucoseValue( data class GlucoseValue(
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
override var id: Long = 0, override var id: Long = 0,
@ -51,53 +57,55 @@ data class GlucoseValue(
fun isRecordDeleted(other: GlucoseValue): Boolean = fun isRecordDeleted(other: GlucoseValue): Boolean =
isValid && !other.isValid isValid && !other.isValid
enum class TrendArrow (val text:String, val symbol:String){ enum class TrendArrow(val text: String, val symbol: String) {
@SerializedName("NONE") NONE("NONE", "??"), NONE("NONE", "??"),
@SerializedName("TripleUp")TRIPLE_UP("TripleUp", "X"), TRIPLE_UP("TripleUp", "X"),
@SerializedName("DoubleUp")DOUBLE_UP("DoubleUp", "\u21c8"), DOUBLE_UP("DoubleUp", "\u21c8"),
@SerializedName("SingleUp")SINGLE_UP("SingleUp", "\u2191"), SINGLE_UP("SingleUp", "\u2191"),
@SerializedName("FortyFiveUp")FORTY_FIVE_UP("FortyFiveUp", "\u2197"), FORTY_FIVE_UP("FortyFiveUp", "\u2197"),
@SerializedName("Flat")FLAT("Flat", "\u2192"), FLAT("Flat", "\u2192"),
@SerializedName("FortyFiveDown")FORTY_FIVE_DOWN("FortyFiveDown", "\u2198"), FORTY_FIVE_DOWN("FortyFiveDown", "\u2198"),
@SerializedName("SingleDown")SINGLE_DOWN("SingleDown", "\u2193"), SINGLE_DOWN("SingleDown", "\u2193"),
@SerializedName("DoubleDown")DOUBLE_DOWN("DoubleDown", "\u21ca"), DOUBLE_DOWN("DoubleDown", "\u21ca"),
@SerializedName("TripleDown")TRIPLE_DOWN("TripleDown", "X") TRIPLE_DOWN("TripleDown", "X")
; ;
companion object { companion object {
fun fromString(direction : String?) = values().firstOrNull {it.text == direction} ?: NONE
fun fromString(direction: String?) =
values().firstOrNull { it.text == direction } ?: NONE
} }
} }
enum class SourceSensor(val text : String) { enum class SourceSensor(val text: String) {
@SerializedName("AndroidAPS-Dexcom") DEXCOM_NATIVE_UNKNOWN("AndroidAPS-Dexcom"), DEXCOM_NATIVE_UNKNOWN("AndroidAPS-Dexcom"),
@SerializedName("AndroidAPS-DexcomG6") DEXCOM_G6_NATIVE("AndroidAPS-DexcomG6"), DEXCOM_G6_NATIVE("AndroidAPS-DexcomG6"),
@SerializedName("AndroidAPS-DexcomG5") DEXCOM_G5_NATIVE("AndroidAPS-DexcomG5"), DEXCOM_G5_NATIVE("AndroidAPS-DexcomG5"),
@SerializedName("Bluetooth Wixel") DEXCOM_G4_WIXEL("Bluetooth Wixel"), DEXCOM_G4_WIXEL("Bluetooth Wixel"),
@SerializedName("xBridge Wixel") DEXCOM_G4_XBRIDGE("xBridge Wixel"), DEXCOM_G4_XBRIDGE("xBridge Wixel"),
@SerializedName("G4 Share Receiver") DEXCOM_G4_NATIVE("G4 Share Receiver"), DEXCOM_G4_NATIVE("G4 Share Receiver"),
@SerializedName("Medtrum A6") MEDTRUM_A6("Medtrum A6"), MEDTRUM_A6("Medtrum A6"),
@SerializedName("Network G4") DEXCOM_G4_NET("Network G4"), DEXCOM_G4_NET("Network G4"),
@SerializedName("Network G4 and xBridge") DEXCOM_G4_NET_XBRIDGE("Network G4 and xBridge"), DEXCOM_G4_NET_XBRIDGE("Network G4 and xBridge"),
@SerializedName("Network G4 and Classic xDrip") DEXCOM_G4_NET_CLASSIC("Network G4 and Classic xDrip"), DEXCOM_G4_NET_CLASSIC("Network G4 and Classic xDrip"),
@SerializedName("DexcomG5") DEXCOM_G5_XDRIP("DexcomG5"), DEXCOM_G5_XDRIP("DexcomG5"),
@SerializedName("G6 Native") DEXCOM_G6_NATIVE_XDRIP("G6 Native"), DEXCOM_G6_NATIVE_XDRIP("G6 Native"),
@SerializedName("G5 Native") DEXCOM_G5_NATIVE_XDRIP("G5 Native"), DEXCOM_G5_NATIVE_XDRIP("G5 Native"),
@SerializedName("G6 Native / G5 Native") DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"), DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"),
@SerializedName("Network libre") LIBRE_1_NET("Network libre"), LIBRE_1_NET("Network libre"),
@SerializedName("BlueReader") LIBRE_1_BLUE("BlueReader"), LIBRE_1_BLUE("BlueReader"),
@SerializedName("Transmiter PL") LIBRE_1_PL("Transmiter PL"), LIBRE_1_PL("Transmiter PL"),
@SerializedName("Blucon") LIBRE_1_BLUCON("Blucon"), LIBRE_1_BLUCON("Blucon"),
@SerializedName("Tomato") LIBRE_1_TOMATO("Tomato"), LIBRE_1_TOMATO("Tomato"),
@SerializedName("Rfduino") LIBRE_1_RF("Rfduino"), LIBRE_1_RF("Rfduino"),
@SerializedName("LimiTTer") LIBRE_1_LIMITTER("LimiTTer"), LIBRE_1_LIMITTER("LimiTTer"),
@SerializedName("Glimp") GLIMP("Glimp"), GLIMP("Glimp"),
@SerializedName("Libre2") LIBRE_2_NATIVE("Libre2"), LIBRE_2_NATIVE("Libre2"),
@SerializedName("Poctech") POCTECH_NATIVE("Poctech"), POCTECH_NATIVE("Poctech"),
@SerializedName("MM600Series") MM_600_SERIES("MM600Series"), MM_600_SERIES("MM600Series"),
@SerializedName("Eversense") EVERSENSE("Eversense"), EVERSENSE("Eversense"),
@SerializedName("Random") RANDOM("Random"), RANDOM("Random"),
@SerializedName("Unknown") UNKNOWN("Unknown"), UNKNOWN("Unknown"),
IOB_PREDICTION("IOBPrediction"), IOB_PREDICTION("IOBPrediction"),
A_COB_PREDICTION("aCOBPrediction"), A_COB_PREDICTION("aCOBPrediction"),