diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt index 5cb174b533..4401623286 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt @@ -192,7 +192,7 @@ abstract class PluginsModule { abstract fun bindOpenAPSSMBPlugin(plugin: OpenAPSSMBPlugin): PluginBase @Binds - @NotNSClient + @AllConfigs @IntoMap @IntKey(240) abstract fun bindLocalProfilePlugin(plugin: LocalProfilePlugin): PluginBase diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/DataSyncSelectorImplementation.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/DataSyncSelectorImplementation.kt index 7e3dd1bb8f..9e124bfcca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/DataSyncSelectorImplementation.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/DataSyncSelectorImplementation.kt @@ -279,7 +279,7 @@ class DataSyncSelectorImplementation @Inject constructor( nsClientPlugin.nsClientService?.dbUpdate("entries", gv.first.interfaceIDs.nightscoutId, gv.first.toJson(dateUtil), DataSyncSelector.PairGlucoseValue(gv.first, gv.second)) } return true - } + } else confirmLastGlucoseValueIdIfGreater(gv.second) } return false } @@ -385,7 +385,7 @@ class DataSyncSelectorImplementation @Inject constructor( nsClientPlugin.nsClientService?.dbUpdate("treatments", tb.first.interfaceIDs.nightscoutId, tb.first.toJson(profile, dateUtil), DataSyncSelector.PairTemporaryBasal(tb.first, tb.second)) } return true - } + } ?: confirmLastTemporaryBasalIdIfGreater(tb.second) } return false } @@ -424,7 +424,7 @@ class DataSyncSelectorImplementation @Inject constructor( nsClientPlugin.nsClientService?.dbUpdate("treatments", eb.first.interfaceIDs.nightscoutId, eb.first.toJson(profile, dateUtil), DataSyncSelector.PairExtendedBolus(eb.first, eb.second)) } return true - } + } ?: confirmLastExtendedBolusIdIfGreater(eb.second) } return false } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 86b56591ff..c21cc86463 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -413,7 +413,7 @@ class LocalProfilePlugin @Inject constructor( if (sp.getBoolean(R.string.key_ns_receive_profile_store, false) || config.NSCLIENT) { localProfilePlugin.loadFromStore(ProfileStore(injector, profileJson, dateUtil)) aapsLogger.debug(LTag.PROFILE, "Received profileStore: $profileJson") - return Result.success(workDataOf("Data" to profileJson.toString())) + return Result.success(workDataOf("Data" to profileJson.toString().substring(1..5000))) } return Result.success() } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index 76da448516..cd352a63c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -155,7 +155,8 @@ open class VirtualPumpPlugin @Inject constructor( } override fun isThisProfileSet(profile: Profile): Boolean { - return true + val running = pumpSync.expectedPumpState().profile + return running?.isEqual(profile) ?: false } override fun lastDataTime(): Long { diff --git a/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt b/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt index b308bd6132..8a30319b67 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt @@ -145,6 +145,18 @@ sealed class ProfileSealed( override val timeshift: Int get() = ts + override fun isEqual(profile: Profile): Boolean { + for (hour in 0..23) { + val seconds = T.hours(hour.toLong()).secs().toInt() + if (getBasalTimeFromMidnight(seconds) != profile.getBasalTimeFromMidnight(seconds)) return false + if (getIsfMgdlTimeFromMidnight(seconds) != profile.getIsfMgdlTimeFromMidnight(seconds)) return false + if (getIcTimeFromMidnight(seconds) != profile.getIcTimeFromMidnight(seconds)) return false + if (getTargetLowMgdlTimeFromMidnight(seconds) != profile.getTargetLowMgdlTimeFromMidnight(seconds)) return false + if (getTargetHighMgdlTimeFromMidnight(seconds) != profile.getTargetHighMgdlTimeFromMidnight(seconds)) return false + } + return true + } + override val percentage: Int get() = pct diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Profile.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Profile.kt index 7e371284f1..a3b1328cb9 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/Profile.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Profile.kt @@ -30,6 +30,11 @@ interface Profile { */ val timeshift: Int + /** + * is equal to another profile? + */ + fun isEqual(profile: Profile): Boolean + /** * Basal value according to "now" */