NSClientV3PluginTest #2
This commit is contained in:
parent
eb1fff54f1
commit
0873df5f56
|
@ -43,43 +43,43 @@ interface DataSyncSelector {
|
||||||
fun resetToNextFullSync()
|
fun resetToNextFullSync()
|
||||||
|
|
||||||
fun confirmLastBolusIdIfGreater(lastSynced: Long)
|
fun confirmLastBolusIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedBolusesCompat()
|
fun processChangedBoluses()
|
||||||
|
|
||||||
fun confirmLastCarbsIdIfGreater(lastSynced: Long)
|
fun confirmLastCarbsIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedCarbsCompat()
|
fun processChangedCarbs()
|
||||||
|
|
||||||
fun confirmLastBolusCalculatorResultsIdIfGreater(lastSynced: Long)
|
fun confirmLastBolusCalculatorResultsIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedBolusCalculatorResultsCompat()
|
fun processChangedBolusCalculatorResults()
|
||||||
|
|
||||||
fun confirmLastTempTargetsIdIfGreater(lastSynced: Long)
|
fun confirmLastTempTargetsIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedTempTargetsCompat()
|
fun processChangedTempTargets()
|
||||||
|
|
||||||
fun confirmLastGlucoseValueIdIfGreater(lastSynced: Long)
|
fun confirmLastGlucoseValueIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedGlucoseValuesCompat()
|
fun processChangedGlucoseValues()
|
||||||
|
|
||||||
fun confirmLastTherapyEventIdIfGreater(lastSynced: Long)
|
fun confirmLastTherapyEventIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedTherapyEventsCompat()
|
fun processChangedTherapyEvents()
|
||||||
|
|
||||||
fun confirmLastFoodIdIfGreater(lastSynced: Long)
|
fun confirmLastFoodIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedFoodsCompat()
|
fun processChangedFoods()
|
||||||
|
|
||||||
fun confirmLastDeviceStatusIdIfGreater(lastSynced: Long)
|
fun confirmLastDeviceStatusIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedDeviceStatusesCompat()
|
fun processChangedDeviceStatuses()
|
||||||
|
|
||||||
fun confirmLastTemporaryBasalIdIfGreater(lastSynced: Long)
|
fun confirmLastTemporaryBasalIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedTemporaryBasalsCompat()
|
fun processChangedTemporaryBasals()
|
||||||
|
|
||||||
fun confirmLastExtendedBolusIdIfGreater(lastSynced: Long)
|
fun confirmLastExtendedBolusIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedExtendedBolusesCompat()
|
fun processChangedExtendedBoluses()
|
||||||
|
|
||||||
fun confirmLastProfileSwitchIdIfGreater(lastSynced: Long)
|
fun confirmLastProfileSwitchIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedProfileSwitchesCompat()
|
fun processChangedProfileSwitches()
|
||||||
|
|
||||||
fun confirmLastEffectiveProfileSwitchIdIfGreater(lastSynced: Long)
|
fun confirmLastEffectiveProfileSwitchIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedEffectiveProfileSwitchesCompat()
|
fun processChangedEffectiveProfileSwitches()
|
||||||
|
|
||||||
fun confirmLastOfflineEventIdIfGreater(lastSynced: Long)
|
fun confirmLastOfflineEventIdIfGreater(lastSynced: Long)
|
||||||
fun processChangedOfflineEventsCompat()
|
fun processChangedOfflineEvents()
|
||||||
|
|
||||||
fun confirmLastProfileStore(lastSynced: Long)
|
fun confirmLastProfileStore(lastSynced: Long)
|
||||||
fun processChangedProfileStore()
|
fun processChangedProfileStore()
|
||||||
|
|
|
@ -62,19 +62,19 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
|
|
||||||
override fun doUpload() {
|
override fun doUpload() {
|
||||||
if (sp.getBoolean(R.string.key_ns_upload, true) && !isPaused) {
|
if (sp.getBoolean(R.string.key_ns_upload, true) && !isPaused) {
|
||||||
processChangedBolusesCompat()
|
processChangedBoluses()
|
||||||
processChangedCarbsCompat()
|
processChangedCarbs()
|
||||||
processChangedBolusCalculatorResultsCompat()
|
processChangedBolusCalculatorResults()
|
||||||
processChangedTemporaryBasalsCompat()
|
processChangedTemporaryBasals()
|
||||||
processChangedExtendedBolusesCompat()
|
processChangedExtendedBoluses()
|
||||||
processChangedProfileSwitchesCompat()
|
processChangedProfileSwitches()
|
||||||
processChangedEffectiveProfileSwitchesCompat()
|
processChangedEffectiveProfileSwitches()
|
||||||
processChangedGlucoseValuesCompat()
|
processChangedGlucoseValues()
|
||||||
processChangedTempTargetsCompat()
|
processChangedTempTargets()
|
||||||
processChangedFoodsCompat()
|
processChangedFoods()
|
||||||
processChangedTherapyEventsCompat()
|
processChangedTherapyEvents()
|
||||||
processChangedDeviceStatusesCompat()
|
processChangedDeviceStatuses()
|
||||||
processChangedOfflineEventsCompat()
|
processChangedOfflineEvents()
|
||||||
processChangedProfileStore()
|
processChangedProfileStore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedBolusesCompat() {
|
override tailrec fun processChangedBoluses() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastBolusIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastBolusIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -123,14 +123,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
bolus.first.id == bolus.second.id && bolus.first.interfaceIDs.nightscoutId != null -> {
|
bolus.first.id == bolus.second.id && bolus.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring Bolus. Loaded from NS: ${bolus.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring Bolus. Loaded from NS: ${bolus.second.id} ")
|
||||||
confirmLastBolusIdIfGreater(bolus.second.id)
|
confirmLastBolusIdIfGreater(bolus.second.id)
|
||||||
processChangedBolusesCompat()
|
processChangedBoluses()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
bolus.first.onlyNsIdAdded(bolus.second) -> {
|
bolus.first.onlyNsIdAdded(bolus.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring Bolus. Only NS id changed: ${bolus.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring Bolus. Only NS id changed: ${bolus.second.id} ")
|
||||||
confirmLastBolusIdIfGreater(bolus.second.id)
|
confirmLastBolusIdIfGreater(bolus.second.id)
|
||||||
processChangedBolusesCompat()
|
processChangedBoluses()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -159,7 +159,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedCarbsCompat() {
|
override tailrec fun processChangedCarbs() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastCarbsIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastCarbsIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -176,14 +176,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
carb.first.id == carb.second.id && carb.first.interfaceIDs.nightscoutId != null -> {
|
carb.first.id == carb.second.id && carb.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring Carbs. Loaded from NS: ${carb.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring Carbs. Loaded from NS: ${carb.second.id} ")
|
||||||
confirmLastCarbsIdIfGreater(carb.second.id)
|
confirmLastCarbsIdIfGreater(carb.second.id)
|
||||||
processChangedCarbsCompat()
|
processChangedCarbs()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
carb.first.onlyNsIdAdded(carb.second) -> {
|
carb.first.onlyNsIdAdded(carb.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring Carbs. Only NS id changed ID: ${carb.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring Carbs. Only NS id changed ID: ${carb.second.id} ")
|
||||||
confirmLastCarbsIdIfGreater(carb.second.id)
|
confirmLastCarbsIdIfGreater(carb.second.id)
|
||||||
processChangedCarbsCompat()
|
processChangedCarbs()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -208,7 +208,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedBolusCalculatorResultsCompat() {
|
override tailrec fun processChangedBolusCalculatorResults() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastBolusCalculatorResultIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastBolusCalculatorResultIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -225,14 +225,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
bolusCalculatorResult.first.id == bolusCalculatorResult.second.id && bolusCalculatorResult.first.interfaceIDs.nightscoutId != null -> {
|
bolusCalculatorResult.first.id == bolusCalculatorResult.second.id && bolusCalculatorResult.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring BolusCalculatorResult. Loaded from NS: ${bolusCalculatorResult.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring BolusCalculatorResult. Loaded from NS: ${bolusCalculatorResult.second.id} ")
|
||||||
confirmLastBolusCalculatorResultsIdIfGreater(bolusCalculatorResult.second.id)
|
confirmLastBolusCalculatorResultsIdIfGreater(bolusCalculatorResult.second.id)
|
||||||
processChangedBolusCalculatorResultsCompat()
|
processChangedBolusCalculatorResults()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
bolusCalculatorResult.first.onlyNsIdAdded(bolusCalculatorResult.second) -> {
|
bolusCalculatorResult.first.onlyNsIdAdded(bolusCalculatorResult.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring BolusCalculatorResult. Only NS id changed ID: ${bolusCalculatorResult.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring BolusCalculatorResult. Only NS id changed ID: ${bolusCalculatorResult.second.id} ")
|
||||||
confirmLastBolusCalculatorResultsIdIfGreater(bolusCalculatorResult.second.id)
|
confirmLastBolusCalculatorResultsIdIfGreater(bolusCalculatorResult.second.id)
|
||||||
processChangedBolusCalculatorResultsCompat()
|
processChangedBolusCalculatorResults()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -260,7 +260,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedTempTargetsCompat() {
|
override tailrec fun processChangedTempTargets() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastTempTargetIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastTempTargetIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -277,14 +277,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
tt.first.id == tt.second.id && tt.first.interfaceIDs.nightscoutId != null -> {
|
tt.first.id == tt.second.id && tt.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring TemporaryTarget. Loaded from NS: ${tt.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring TemporaryTarget. Loaded from NS: ${tt.second.id} ")
|
||||||
confirmLastTempTargetsIdIfGreater(tt.second.id)
|
confirmLastTempTargetsIdIfGreater(tt.second.id)
|
||||||
processChangedTempTargetsCompat()
|
processChangedTempTargets()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
tt.first.onlyNsIdAdded(tt.second) -> {
|
tt.first.onlyNsIdAdded(tt.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring TemporaryTarget. Only NS id changed ID: ${tt.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring TemporaryTarget. Only NS id changed ID: ${tt.second.id} ")
|
||||||
confirmLastTempTargetsIdIfGreater(tt.second.id)
|
confirmLastTempTargetsIdIfGreater(tt.second.id)
|
||||||
processChangedTempTargetsCompat()
|
processChangedTempTargets()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -313,7 +313,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedFoodsCompat() {
|
override tailrec fun processChangedFoods() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastFoodIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastFoodIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -330,14 +330,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
food.first.id == food.second.id && food.first.interfaceIDs.nightscoutId != null -> {
|
food.first.id == food.second.id && food.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring Food. Loaded from NS: ${food.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring Food. Loaded from NS: ${food.second.id} ")
|
||||||
confirmLastFoodIdIfGreater(food.second.id)
|
confirmLastFoodIdIfGreater(food.second.id)
|
||||||
processChangedFoodsCompat()
|
processChangedFoods()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
food.first.onlyNsIdAdded(food.second) -> {
|
food.first.onlyNsIdAdded(food.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring Food. Only NS id changed ID: ${food.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring Food. Only NS id changed ID: ${food.second.id} ")
|
||||||
confirmLastFoodIdIfGreater(food.second.id)
|
confirmLastFoodIdIfGreater(food.second.id)
|
||||||
processChangedFoodsCompat()
|
processChangedFoods()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -362,7 +362,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedGlucoseValuesCompat() {
|
override tailrec fun processChangedGlucoseValues() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastGlucoseValueIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastGlucoseValueIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -380,14 +380,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
gv.first.id == gv.second.id && gv.first.interfaceIDs.nightscoutId != null -> {
|
gv.first.id == gv.second.id && gv.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring GlucoseValue. Loaded from NS: ${gv.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring GlucoseValue. Loaded from NS: ${gv.second.id} ")
|
||||||
confirmLastGlucoseValueIdIfGreater(gv.second.id)
|
confirmLastGlucoseValueIdIfGreater(gv.second.id)
|
||||||
processChangedGlucoseValuesCompat()
|
processChangedGlucoseValues()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
gv.first.onlyNsIdAdded(gv.second) -> {
|
gv.first.onlyNsIdAdded(gv.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring GlucoseValue. Only NS id changed ID: ${gv.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring GlucoseValue. Only NS id changed ID: ${gv.second.id} ")
|
||||||
confirmLastGlucoseValueIdIfGreater(gv.second.id)
|
confirmLastGlucoseValueIdIfGreater(gv.second.id)
|
||||||
processChangedGlucoseValuesCompat()
|
processChangedGlucoseValues()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -403,7 +403,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
confirmLastGlucoseValueIdIfGreater(gv.second.id)
|
confirmLastGlucoseValueIdIfGreater(gv.second.id)
|
||||||
processChangedGlucoseValuesCompat()
|
processChangedGlucoseValues()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,7 +416,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedTherapyEventsCompat() {
|
override tailrec fun processChangedTherapyEvents() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastTherapyEventIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastTherapyEventIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -433,14 +433,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
te.first.id == te.second.id && te.first.interfaceIDs.nightscoutId != null -> {
|
te.first.id == te.second.id && te.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring TherapyEvent. Loaded from NS: ${te.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring TherapyEvent. Loaded from NS: ${te.second.id} ")
|
||||||
confirmLastTherapyEventIdIfGreater(te.second.id)
|
confirmLastTherapyEventIdIfGreater(te.second.id)
|
||||||
processChangedTherapyEventsCompat()
|
processChangedTherapyEvents()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
te.first.onlyNsIdAdded(te.second) -> {
|
te.first.onlyNsIdAdded(te.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring TherapyEvent. Only NS id changed ID: ${te.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring TherapyEvent. Only NS id changed ID: ${te.second.id} ")
|
||||||
confirmLastTherapyEventIdIfGreater(te.second.id)
|
confirmLastTherapyEventIdIfGreater(te.second.id)
|
||||||
processChangedTherapyEventsCompat()
|
processChangedTherapyEvents()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -465,7 +465,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processChangedDeviceStatusesCompat() {
|
override fun processChangedDeviceStatuses() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastDeviceStatusIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastDeviceStatusIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -495,7 +495,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedTemporaryBasalsCompat() {
|
override tailrec fun processChangedTemporaryBasals() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastTemporaryBasalIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastTemporaryBasalIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -512,14 +512,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
tb.first.id == tb.second.id && tb.first.interfaceIDs.nightscoutId != null -> {
|
tb.first.id == tb.second.id && tb.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring TemporaryBasal. Loaded from NS: ${tb.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring TemporaryBasal. Loaded from NS: ${tb.second.id} ")
|
||||||
confirmLastTemporaryBasalIdIfGreater(tb.second.id)
|
confirmLastTemporaryBasalIdIfGreater(tb.second.id)
|
||||||
processChangedTemporaryBasalsCompat()
|
processChangedTemporaryBasals()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
tb.first.onlyNsIdAdded(tb.second) -> {
|
tb.first.onlyNsIdAdded(tb.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring TemporaryBasal. Only NS id changed ID: ${tb.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring TemporaryBasal. Only NS id changed ID: ${tb.second.id} ")
|
||||||
confirmLastTemporaryBasalIdIfGreater(tb.second.id)
|
confirmLastTemporaryBasalIdIfGreater(tb.second.id)
|
||||||
processChangedTemporaryBasalsCompat()
|
processChangedTemporaryBasals()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -548,7 +548,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedExtendedBolusesCompat() {
|
override tailrec fun processChangedExtendedBoluses() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastExtendedBolusIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastExtendedBolusIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -567,14 +567,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
eb.first.id == eb.second.id && eb.first.interfaceIDs.nightscoutId != null -> {
|
eb.first.id == eb.second.id && eb.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring ExtendedBolus. Loaded from NS: ${eb.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring ExtendedBolus. Loaded from NS: ${eb.second.id} ")
|
||||||
confirmLastExtendedBolusIdIfGreater(eb.second.id)
|
confirmLastExtendedBolusIdIfGreater(eb.second.id)
|
||||||
processChangedExtendedBolusesCompat()
|
processChangedExtendedBoluses()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
eb.first.onlyNsIdAdded(eb.second) -> {
|
eb.first.onlyNsIdAdded(eb.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring ExtendedBolus. Only NS id changed ID: ${eb.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring ExtendedBolus. Only NS id changed ID: ${eb.second.id} ")
|
||||||
confirmLastExtendedBolusIdIfGreater(eb.second.id)
|
confirmLastExtendedBolusIdIfGreater(eb.second.id)
|
||||||
processChangedExtendedBolusesCompat()
|
processChangedExtendedBoluses()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -596,7 +596,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring ExtendedBolus. No profile: ${eb.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring ExtendedBolus. No profile: ${eb.second.id} ")
|
||||||
confirmLastExtendedBolusIdIfGreater(eb.second.id)
|
confirmLastExtendedBolusIdIfGreater(eb.second.id)
|
||||||
processChangedExtendedBolusesCompat()
|
processChangedExtendedBoluses()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,7 +609,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedProfileSwitchesCompat() {
|
override tailrec fun processChangedProfileSwitches() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastProfileSwitchIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastProfileSwitchIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -626,14 +626,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
ps.first.id == ps.second.id && ps.first.interfaceIDs.nightscoutId != null -> {
|
ps.first.id == ps.second.id && ps.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring ProfileSwitch. Loaded from NS: ${ps.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring ProfileSwitch. Loaded from NS: ${ps.second.id} ")
|
||||||
confirmLastProfileSwitchIdIfGreater(ps.second.id)
|
confirmLastProfileSwitchIdIfGreater(ps.second.id)
|
||||||
processChangedProfileSwitchesCompat()
|
processChangedProfileSwitches()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
ps.first.onlyNsIdAdded(ps.second) -> {
|
ps.first.onlyNsIdAdded(ps.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring ProfileSwitch. Only NS id changed ID: ${ps.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring ProfileSwitch. Only NS id changed ID: ${ps.second.id} ")
|
||||||
confirmLastProfileSwitchIdIfGreater(ps.second.id)
|
confirmLastProfileSwitchIdIfGreater(ps.second.id)
|
||||||
processChangedProfileSwitchesCompat()
|
processChangedProfileSwitches()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -658,7 +658,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedEffectiveProfileSwitchesCompat() {
|
override tailrec fun processChangedEffectiveProfileSwitches() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastEffectiveProfileSwitchIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastEffectiveProfileSwitchIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -675,14 +675,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
ps.first.id == ps.second.id && ps.first.interfaceIDs.nightscoutId != null -> {
|
ps.first.id == ps.second.id && ps.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring EffectiveProfileSwitch. Loaded from NS: ${ps.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring EffectiveProfileSwitch. Loaded from NS: ${ps.second.id} ")
|
||||||
confirmLastEffectiveProfileSwitchIdIfGreater(ps.second.id)
|
confirmLastEffectiveProfileSwitchIdIfGreater(ps.second.id)
|
||||||
processChangedEffectiveProfileSwitchesCompat()
|
processChangedEffectiveProfileSwitches()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
ps.first.onlyNsIdAdded(ps.second) -> {
|
ps.first.onlyNsIdAdded(ps.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring EffectiveProfileSwitch. Only NS id changed ID: ${ps.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring EffectiveProfileSwitch. Only NS id changed ID: ${ps.second.id} ")
|
||||||
confirmLastEffectiveProfileSwitchIdIfGreater(ps.second.id)
|
confirmLastEffectiveProfileSwitchIdIfGreater(ps.second.id)
|
||||||
processChangedEffectiveProfileSwitchesCompat()
|
processChangedEffectiveProfileSwitches()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
@ -711,7 +711,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override tailrec fun processChangedOfflineEventsCompat() {
|
override tailrec fun processChangedOfflineEvents() {
|
||||||
if (isPaused) return
|
if (isPaused) return
|
||||||
val lastDbIdWrapped = appRepository.getLastOfflineEventIdWrapped().blockingGet()
|
val lastDbIdWrapped = appRepository.getLastOfflineEventIdWrapped().blockingGet()
|
||||||
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
val lastDbId = if (lastDbIdWrapped is ValueWrapper.Existing) lastDbIdWrapped.value else 0L
|
||||||
|
@ -728,14 +728,14 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
oe.first.id == oe.second.id && oe.first.interfaceIDs.nightscoutId != null -> {
|
oe.first.id == oe.second.id && oe.first.interfaceIDs.nightscoutId != null -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring OfflineEvent. Loaded from NS: ${oe.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring OfflineEvent. Loaded from NS: ${oe.second.id} ")
|
||||||
confirmLastOfflineEventIdIfGreater(oe.second.id)
|
confirmLastOfflineEventIdIfGreater(oe.second.id)
|
||||||
processChangedOfflineEventsCompat()
|
processChangedOfflineEvents()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// only NsId changed, no need to upload
|
// only NsId changed, no need to upload
|
||||||
oe.first.onlyNsIdAdded(oe.second) -> {
|
oe.first.onlyNsIdAdded(oe.second) -> {
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Ignoring OfflineEvent. Only NS id changed ID: ${oe.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Ignoring OfflineEvent. Only NS id changed ID: ${oe.second.id} ")
|
||||||
confirmLastOfflineEventIdIfGreater(oe.second.id)
|
confirmLastOfflineEventIdIfGreater(oe.second.id)
|
||||||
processChangedOfflineEventsCompat()
|
processChangedOfflineEvents()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
|
|
|
@ -63,7 +63,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryTarget " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryTarget " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedTempTargetsCompat()
|
dataSyncSelector.processChangedTempTargets()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairGlucoseValue -> {
|
is PairGlucoseValue -> {
|
||||||
|
@ -74,7 +74,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked GlucoseValue " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked GlucoseValue " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedGlucoseValuesCompat()
|
dataSyncSelector.processChangedGlucoseValues()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairFood -> {
|
is PairFood -> {
|
||||||
|
@ -85,7 +85,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Food " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked Food " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedFoodsCompat()
|
dataSyncSelector.processChangedFoods()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairTherapyEvent -> {
|
is PairTherapyEvent -> {
|
||||||
|
@ -96,7 +96,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TherapyEvent " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked TherapyEvent " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedTherapyEventsCompat()
|
dataSyncSelector.processChangedTherapyEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairBolus -> {
|
is PairBolus -> {
|
||||||
|
@ -107,7 +107,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Bolus " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked Bolus " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedBolusesCompat()
|
dataSyncSelector.processChangedBoluses()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairCarbs -> {
|
is PairCarbs -> {
|
||||||
|
@ -118,7 +118,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Carbs " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked Carbs " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedCarbsCompat()
|
dataSyncSelector.processChangedCarbs()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairBolusCalculatorResult -> {
|
is PairBolusCalculatorResult -> {
|
||||||
|
@ -129,7 +129,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked BolusCalculatorResult " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked BolusCalculatorResult " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedBolusCalculatorResultsCompat()
|
dataSyncSelector.processChangedBolusCalculatorResults()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairTemporaryBasal -> {
|
is PairTemporaryBasal -> {
|
||||||
|
@ -140,7 +140,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryBasal " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryBasal " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedTemporaryBasalsCompat()
|
dataSyncSelector.processChangedTemporaryBasals()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairExtendedBolus -> {
|
is PairExtendedBolus -> {
|
||||||
|
@ -151,7 +151,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked ExtendedBolus " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked ExtendedBolus " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedExtendedBolusesCompat()
|
dataSyncSelector.processChangedExtendedBoluses()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairProfileSwitch -> {
|
is PairProfileSwitch -> {
|
||||||
|
@ -162,7 +162,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileSwitch " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileSwitch " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedProfileSwitchesCompat()
|
dataSyncSelector.processChangedProfileSwitches()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairEffectiveProfileSwitch -> {
|
is PairEffectiveProfileSwitch -> {
|
||||||
|
@ -173,7 +173,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked EffectiveProfileSwitch " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked EffectiveProfileSwitch " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedEffectiveProfileSwitchesCompat()
|
dataSyncSelector.processChangedEffectiveProfileSwitches()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairDeviceStatus -> {
|
is DataSyncSelector.PairDeviceStatus -> {
|
||||||
|
@ -184,7 +184,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked DeviceStatus " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked DeviceStatus " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedDeviceStatusesCompat()
|
dataSyncSelector.processChangedDeviceStatuses()
|
||||||
}
|
}
|
||||||
|
|
||||||
is PairProfileStore -> {
|
is PairProfileStore -> {
|
||||||
|
@ -200,7 +200,7 @@ class NSClientAddAckWorker(
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
storeDataForDb.scheduleNsIdUpdate()
|
||||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked OfflineEvent " + pair.value.interfaceIDs.nightscoutId))
|
rxBus.send(EventNSClientNewLog("DBADD", "Acked OfflineEvent " + pair.value.interfaceIDs.nightscoutId))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedOfflineEventsCompat()
|
dataSyncSelector.processChangedOfflineEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastTempTargetsIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastTempTargetsIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryTarget" + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryTarget" + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedTempTargetsCompat()
|
dataSyncSelector.processChangedTempTargets()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastGlucoseValueIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastGlucoseValueIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked GlucoseValue " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked GlucoseValue " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedGlucoseValuesCompat()
|
dataSyncSelector.processChangedGlucoseValues()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastFoodIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastFoodIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Food " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Food " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedFoodsCompat()
|
dataSyncSelector.processChangedFoods()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastTherapyEventIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastTherapyEventIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TherapyEvent " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TherapyEvent " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedTherapyEventsCompat()
|
dataSyncSelector.processChangedTherapyEvents()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastBolusIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastBolusIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Bolus " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Bolus " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedBolusesCompat()
|
dataSyncSelector.processChangedBoluses()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastCarbsIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastCarbsIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Carbs " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Carbs " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedCarbsCompat()
|
dataSyncSelector.processChangedCarbs()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastBolusCalculatorResultsIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastBolusCalculatorResultsIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked BolusCalculatorResult " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked BolusCalculatorResult " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedBolusCalculatorResultsCompat()
|
dataSyncSelector.processChangedBolusCalculatorResults()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryBasal " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryBasal " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedTemporaryBasalsCompat()
|
dataSyncSelector.processChangedTemporaryBasals()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastExtendedBolusIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastExtendedBolusIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ExtendedBolus " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ExtendedBolus " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedExtendedBolusesCompat()
|
dataSyncSelector.processChangedExtendedBoluses()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastProfileSwitchIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastProfileSwitchIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ProfileSwitch " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ProfileSwitch " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedProfileSwitchesCompat()
|
dataSyncSelector.processChangedProfileSwitches()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastEffectiveProfileSwitchIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastEffectiveProfileSwitchIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked EffectiveProfileSwitch " + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked EffectiveProfileSwitch " + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedEffectiveProfileSwitchesCompat()
|
dataSyncSelector.processChangedEffectiveProfileSwitches()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class NSClientUpdateRemoveAckWorker(
|
||||||
dataSyncSelector.confirmLastOfflineEventIdIfGreater(pair.id)
|
dataSyncSelector.confirmLastOfflineEventIdIfGreater(pair.id)
|
||||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked OfflineEvent" + ack._id))
|
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked OfflineEvent" + ack._id))
|
||||||
// Send new if waiting
|
// Send new if waiting
|
||||||
dataSyncSelector.processChangedOfflineEventsCompat()
|
dataSyncSelector.processChangedOfflineEvents()
|
||||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,13 +346,13 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdDeviceStatuses.add(dataPair.value)
|
// storeDataForDb.nsIdDeviceStatuses.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastDeviceStatusIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastDeviceStatusIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedDeviceStatusesCompat()
|
dataSyncSelector.processChangedDeviceStatuses()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
aapsLogger.error(LTag.NSCLIENT, "Upload exception", e)
|
aapsLogger.error(LTag.NSCLIENT, "Upload exception", e)
|
||||||
|
@ -397,13 +397,13 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
}
|
}
|
||||||
when (dataPair) {
|
when (dataPair) {
|
||||||
is DataSyncSelector.PairGlucoseValue -> {
|
is DataSyncSelector.PairGlucoseValue -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdGlucoseValues.add(dataPair.value)
|
// storeDataForDb.nsIdGlucoseValues.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastGlucoseValueIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastGlucoseValueIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedGlucoseValuesCompat()
|
dataSyncSelector.processChangedGlucoseValues()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,13 +451,13 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
}
|
}
|
||||||
when (dataPair) {
|
when (dataPair) {
|
||||||
is DataSyncSelector.PairFood -> {
|
is DataSyncSelector.PairFood -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdFoods.add(dataPair.value)
|
// storeDataForDb.nsIdFoods.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastFoodIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastFoodIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedFoodsCompat()
|
dataSyncSelector.processChangedFoods()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
val profile = profileFunction.getProfile(dataPair.value.timestamp)
|
val profile = profileFunction.getProfile(dataPair.value.timestamp)
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedTemporaryBasalsCompat()
|
dataSyncSelector.processChangedTemporaryBasals()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dataPair.value.toNSTemporaryBasal(profile)
|
dataPair.value.toNSTemporaryBasal(profile)
|
||||||
|
@ -494,7 +494,7 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
val profile = profileFunction.getProfile(dataPair.value.timestamp)
|
val profile = profileFunction.getProfile(dataPair.value.timestamp)
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
dataSyncSelector.confirmLastExtendedBolusIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastExtendedBolusIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedExtendedBolusesCompat()
|
dataSyncSelector.processChangedExtendedBoluses()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dataPair.value.toNSExtendedBolus(profile)
|
dataPair.value.toNSExtendedBolus(profile)
|
||||||
|
@ -533,103 +533,103 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
}
|
}
|
||||||
when (dataPair) {
|
when (dataPair) {
|
||||||
is DataSyncSelector.PairBolus -> {
|
is DataSyncSelector.PairBolus -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdBoluses.add(dataPair.value)
|
// storeDataForDb.nsIdBoluses.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastBolusIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastBolusIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedBolusesCompat()
|
dataSyncSelector.processChangedBoluses()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairCarbs -> {
|
is DataSyncSelector.PairCarbs -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdCarbs.add(dataPair.value)
|
// storeDataForDb.nsIdCarbs.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastCarbsIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastCarbsIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedCarbsCompat()
|
dataSyncSelector.processChangedCarbs()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairBolusCalculatorResult -> {
|
is DataSyncSelector.PairBolusCalculatorResult -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdBolusCalculatorResults.add(dataPair.value)
|
// storeDataForDb.nsIdBolusCalculatorResults.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastBolusCalculatorResultsIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastBolusCalculatorResultsIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedBolusCalculatorResultsCompat()
|
dataSyncSelector.processChangedBolusCalculatorResults()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairTemporaryTarget -> {
|
is DataSyncSelector.PairTemporaryTarget -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdTemporaryTargets.add(dataPair.value)
|
// storeDataForDb.nsIdTemporaryTargets.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastTempTargetsIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastTempTargetsIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedTempTargetsCompat()
|
dataSyncSelector.processChangedTempTargets()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairTherapyEvent -> {
|
is DataSyncSelector.PairTherapyEvent -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdTherapyEvents.add(dataPair.value)
|
// storeDataForDb.nsIdTherapyEvents.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastTherapyEventIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastTherapyEventIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedTherapyEventsCompat()
|
dataSyncSelector.processChangedTherapyEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairTemporaryBasal -> {
|
is DataSyncSelector.PairTemporaryBasal -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdTemporaryBasals.add(dataPair.value)
|
// storeDataForDb.nsIdTemporaryBasals.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedTemporaryBasalsCompat()
|
dataSyncSelector.processChangedTemporaryBasals()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairExtendedBolus -> {
|
is DataSyncSelector.PairExtendedBolus -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdExtendedBoluses.add(dataPair.value)
|
// storeDataForDb.nsIdExtendedBoluses.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastExtendedBolusIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastExtendedBolusIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedExtendedBolusesCompat()
|
dataSyncSelector.processChangedExtendedBoluses()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairProfileSwitch -> {
|
is DataSyncSelector.PairProfileSwitch -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdProfileSwitches.add(dataPair.value)
|
// storeDataForDb.nsIdProfileSwitches.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastProfileSwitchIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastProfileSwitchIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedProfileSwitchesCompat()
|
dataSyncSelector.processChangedProfileSwitches()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairEffectiveProfileSwitch -> {
|
is DataSyncSelector.PairEffectiveProfileSwitch -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdEffectiveProfileSwitches.add(dataPair.value)
|
// storeDataForDb.nsIdEffectiveProfileSwitches.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastEffectiveProfileSwitchIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastEffectiveProfileSwitchIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedEffectiveProfileSwitchesCompat()
|
dataSyncSelector.processChangedEffectiveProfileSwitches()
|
||||||
}
|
}
|
||||||
|
|
||||||
is DataSyncSelector.PairOfflineEvent -> {
|
is DataSyncSelector.PairOfflineEvent -> {
|
||||||
if (result.response == 201) { // created
|
// if (result.response == 201) { // created
|
||||||
dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
// dataPair.value.interfaceIDs.nightscoutId = result.identifier
|
||||||
storeDataForDb.nsIdOfflineEvents.add(dataPair.value)
|
// storeDataForDb.nsIdOfflineEvents.add(dataPair.value)
|
||||||
storeDataForDb.scheduleNsIdUpdate()
|
// storeDataForDb.scheduleNsIdUpdate()
|
||||||
}
|
// }
|
||||||
dataSyncSelector.confirmLastOfflineEventIdIfGreater(dataPair.id)
|
dataSyncSelector.confirmLastOfflineEventIdIfGreater(dataPair.id)
|
||||||
dataSyncSelector.processChangedOfflineEventsCompat()
|
dataSyncSelector.processChangedOfflineEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ open class TestBaseWithProfile : TestBase() {
|
||||||
@Mock lateinit var processedDeviceStatusData: ProcessedDeviceStatusData
|
@Mock lateinit var processedDeviceStatusData: ProcessedDeviceStatusData
|
||||||
@Mock lateinit var insulin: Insulin
|
@Mock lateinit var insulin: Insulin
|
||||||
|
|
||||||
lateinit var profileFunction: ProfileFunction
|
open lateinit var profileFunction: ProfileFunction
|
||||||
lateinit var dateUtil: DateUtil
|
lateinit var dateUtil: DateUtil
|
||||||
var insulinConfiguration: InsulinConfiguration = InsulinConfiguration("Insulin", 360 * 60 * 1000, 60 * 60 * 1000)
|
var insulinConfiguration: InsulinConfiguration = InsulinConfiguration("Insulin", 360 * 60 * 1000, 60 * 60 * 1000)
|
||||||
val rxBus = RxBus(aapsSchedulers, aapsLogger)
|
val rxBus = RxBus(aapsSchedulers, aapsLogger)
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3
|
package info.nightscout.plugins.sync.nsclientV3
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.extensions.fromConstant
|
||||||
|
import info.nightscout.database.entities.Bolus
|
||||||
|
import info.nightscout.database.entities.BolusCalculatorResult
|
||||||
|
import info.nightscout.database.entities.Carbs
|
||||||
import info.nightscout.database.entities.DeviceStatus
|
import info.nightscout.database.entities.DeviceStatus
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.database.entities.ExtendedBolus
|
||||||
|
import info.nightscout.database.entities.Food
|
||||||
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
|
import info.nightscout.database.entities.OfflineEvent
|
||||||
|
import info.nightscout.database.entities.ProfileSwitch
|
||||||
|
import info.nightscout.database.entities.TemporaryBasal
|
||||||
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
|
import info.nightscout.database.entities.TherapyEvent
|
||||||
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.interfaces.XDripBroadcast
|
import info.nightscout.interfaces.XDripBroadcast
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.nsclient.StoreDataForDb
|
import info.nightscout.interfaces.nsclient.StoreDataForDb
|
||||||
|
@ -18,43 +28,32 @@ import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
|
import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
|
||||||
import info.nightscout.plugins.sync.nsclient.NsClientReceiverDelegate
|
import info.nightscout.plugins.sync.nsclient.NsClientReceiverDelegate
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.plugins.sync.nsclient.extensions.fromConstant
|
||||||
import info.nightscout.sdk.interfaces.NSAndroidClient
|
import info.nightscout.sdk.interfaces.NSAndroidClient
|
||||||
import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse
|
import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
import org.mockito.Mockito.anyLong
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.internal.verification.Times
|
import org.mockito.internal.verification.Times
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
internal class NSClientV3PluginTest : TestBase() {
|
internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var rxBus: RxBus
|
|
||||||
@Mock lateinit var rh: ResourceHelper
|
|
||||||
@Mock lateinit var context: Context
|
|
||||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
|
||||||
@Mock lateinit var sp: SP
|
|
||||||
@Mock lateinit var nsClientReceiverDelegate: NsClientReceiverDelegate
|
@Mock lateinit var nsClientReceiverDelegate: NsClientReceiverDelegate
|
||||||
@Mock lateinit var config: Config
|
|
||||||
@Mock lateinit var dateUtil: DateUtil
|
|
||||||
@Mock lateinit var uiInteraction: UiInteraction
|
@Mock lateinit var uiInteraction: UiInteraction
|
||||||
@Mock lateinit var dataSyncSelector: DataSyncSelector
|
@Mock lateinit var dataSyncSelector: DataSyncSelector
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
|
||||||
@Mock lateinit var nsAndroidClient: NSAndroidClient
|
@Mock lateinit var nsAndroidClient: NSAndroidClient
|
||||||
@Mock lateinit var repository: AppRepository
|
|
||||||
@Mock lateinit var uel: UserEntryLogger
|
@Mock lateinit var uel: UserEntryLogger
|
||||||
@Mock lateinit var nsClientSource: NSClientSource
|
@Mock lateinit var nsClientSource: NSClientSource
|
||||||
@Mock lateinit var xDripBroadcast: XDripBroadcast
|
@Mock lateinit var xDripBroadcast: XDripBroadcast
|
||||||
@Mock lateinit var virtualPump: VirtualPump
|
@Mock lateinit var virtualPump: VirtualPump
|
||||||
|
@Mock lateinit var mockedProfileFunction: ProfileFunction
|
||||||
|
|
||||||
private lateinit var storeDataForDb: StoreDataForDb
|
private lateinit var storeDataForDb: StoreDataForDb
|
||||||
private lateinit var sut: NSClientV3Plugin
|
private lateinit var sut: NSClientV3Plugin
|
||||||
|
@ -70,9 +69,10 @@ internal class NSClientV3PluginTest : TestBase() {
|
||||||
sut =
|
sut =
|
||||||
NSClientV3Plugin(
|
NSClientV3Plugin(
|
||||||
injector, aapsLogger, aapsSchedulers, rxBus, rh, context, fabricPrivacy,
|
injector, aapsLogger, aapsSchedulers, rxBus, rh, context, fabricPrivacy,
|
||||||
sp, nsClientReceiverDelegate, config, dateUtil, uiInteraction, storeDataForDb, dataSyncSelector, profileFunction
|
sp, nsClientReceiverDelegate, config, dateUtil, uiInteraction, storeDataForDb, dataSyncSelector, mockedProfileFunction
|
||||||
)
|
)
|
||||||
sut.nsAndroidClient = nsAndroidClient
|
sut.nsAndroidClient = nsAndroidClient
|
||||||
|
`when`(mockedProfileFunction.getProfile(anyLong())).thenReturn(validProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -92,10 +92,431 @@ internal class NSClientV3PluginTest : TestBase() {
|
||||||
configuration = "{\"insulin\":5,\"insulinConfiguration\":{},\"sensitivity\":2,\"sensitivityConfiguration\":{\"openapsama_min_5m_carbimpact\":8,\"absorption_cutoff\":4,\"autosens_max\":1.2,\"autosens_min\":0.7},\"overviewConfiguration\":{\"units\":\"mmol\",\"QuickWizard\":\"[]\",\"eatingsoon_duration\":60,\"eatingsoon_target\":4,\"activity_duration\":180,\"activity_target\":7.5,\"hypo_duration\":90,\"hypo_target\":8,\"low_mark\":3.9,\"high_mark\":10,\"statuslights_cage_warning\":72,\"statuslights_cage_critical\":96,\"statuslights_iage_warning\":120,\"statuslights_iage_critical\":150,\"statuslights_sage_warning\":168,\"statuslights_sage_critical\":336,\"statuslights_sbat_warning\":25,\"statuslights_sbat_critical\":5,\"statuslights_bage_warning\":720,\"statuslights_bage_critical\":800,\"statuslights_res_warning\":30,\"statuslights_res_critical\":10,\"statuslights_bat_warning\":50,\"statuslights_bat_critical\":25,\"boluswizard_percentage\":70},\"safetyConfiguration\":{\"age\":\"resistantadult\",\"treatmentssafety_maxbolus\":10,\"treatmentssafety_maxcarbs\":70}}"
|
configuration = "{\"insulin\":5,\"insulinConfiguration\":{},\"sensitivity\":2,\"sensitivityConfiguration\":{\"openapsama_min_5m_carbimpact\":8,\"absorption_cutoff\":4,\"autosens_max\":1.2,\"autosens_min\":0.7},\"overviewConfiguration\":{\"units\":\"mmol\",\"QuickWizard\":\"[]\",\"eatingsoon_duration\":60,\"eatingsoon_target\":4,\"activity_duration\":180,\"activity_target\":7.5,\"hypo_duration\":90,\"hypo_target\":8,\"low_mark\":3.9,\"high_mark\":10,\"statuslights_cage_warning\":72,\"statuslights_cage_critical\":96,\"statuslights_iage_warning\":120,\"statuslights_iage_critical\":150,\"statuslights_sage_warning\":168,\"statuslights_sage_critical\":336,\"statuslights_sbat_warning\":25,\"statuslights_sbat_critical\":5,\"statuslights_bage_warning\":720,\"statuslights_bage_critical\":800,\"statuslights_res_warning\":30,\"statuslights_res_critical\":10,\"statuslights_bat_warning\":50,\"statuslights_bat_critical\":25,\"boluswizard_percentage\":70},\"safetyConfiguration\":{\"age\":\"resistantadult\",\"treatmentssafety_maxbolus\":10,\"treatmentssafety_maxcarbs\":70}}"
|
||||||
)
|
)
|
||||||
val dataPair = DataSyncSelector.PairDeviceStatus(deviceStatus, 1000)
|
val dataPair = DataSyncSelector.PairDeviceStatus(deviceStatus, 1000)
|
||||||
|
// create
|
||||||
`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
sut.nsAdd("devicestatus", dataPair, "1/3")
|
sut.nsAdd("devicestatus", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdDeviceStatuses.size)
|
// Assertions.assertEquals(1, storeDataForDb.nsIdDeviceStatuses.size)
|
||||||
verify(dataSyncSelector, Times(1)).confirmLastDeviceStatusIdIfGreater(1000)
|
verify(dataSyncSelector, Times(1)).confirmLastDeviceStatusIdIfGreater(1000)
|
||||||
verify(dataSyncSelector, Times(1)).processChangedDeviceStatusesCompat()
|
verify(dataSyncSelector, Times(1)).processChangedDeviceStatuses()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsAdd("devicestatus", dataPair, "1/3")
|
||||||
|
// Assertions.assertEquals(1, storeDataForDb.nsIdDeviceStatuses.size) // still only 1
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastDeviceStatusIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedDeviceStatuses()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddEntries() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val glucoseValue = GlucoseValue(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
raw = 101.0,
|
||||||
|
value = 99.0,
|
||||||
|
trendArrow = GlucoseValue.TrendArrow.DOUBLE_UP,
|
||||||
|
noise = 1.0,
|
||||||
|
sourceSensor = GlucoseValue.SourceSensor.DEXCOM_G4_WIXEL,
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairGlucoseValue(glucoseValue, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createSvg(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("entries", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastGlucoseValueIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedGlucoseValues()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateSvg(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("entries", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastGlucoseValueIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedGlucoseValues()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddFood() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val food = Food(
|
||||||
|
isValid = true,
|
||||||
|
name = "name",
|
||||||
|
category = "category",
|
||||||
|
subCategory = "subcategory",
|
||||||
|
portion = 2.0,
|
||||||
|
carbs = 20,
|
||||||
|
fat = 21,
|
||||||
|
protein = 22,
|
||||||
|
energy = 23,
|
||||||
|
unit = "g",
|
||||||
|
gi = 25,
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairFood(food, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createFood(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("food", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastFoodIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedFoods()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateFood(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("food", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastFoodIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedFoods()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddBolus() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val bolus = Bolus(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
amount = 1.0,
|
||||||
|
type = Bolus.Type.SMB,
|
||||||
|
notes = "aaaa",
|
||||||
|
isBasalInsulin = false,
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairBolus(bolus, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastBolusIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedBoluses()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastBolusIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedBoluses()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddCarbs() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val carbs = Carbs(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
amount = 1.0,
|
||||||
|
duration = 0,
|
||||||
|
notes = "aaaa",
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairCarbs(carbs, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastCarbsIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedCarbs()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastCarbsIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedCarbs()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddBolusCalculatorResult() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val bolus = BolusCalculatorResult(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
targetBGLow = 110.0,
|
||||||
|
targetBGHigh = 120.0,
|
||||||
|
isf = 30.0,
|
||||||
|
ic = 2.0,
|
||||||
|
bolusIOB = 1.1,
|
||||||
|
wasBolusIOBUsed = true,
|
||||||
|
basalIOB = 1.2,
|
||||||
|
wasBasalIOBUsed = true,
|
||||||
|
glucoseValue = 150.0,
|
||||||
|
wasGlucoseUsed = true,
|
||||||
|
glucoseDifference = 30.0,
|
||||||
|
glucoseInsulin = 1.3,
|
||||||
|
glucoseTrend = 15.0,
|
||||||
|
wasTrendUsed = true,
|
||||||
|
trendInsulin = 1.4,
|
||||||
|
cob = 24.0,
|
||||||
|
wasCOBUsed = true,
|
||||||
|
cobInsulin = 1.5,
|
||||||
|
carbs = 36.0,
|
||||||
|
wereCarbsUsed = true,
|
||||||
|
carbsInsulin = 1.6,
|
||||||
|
otherCorrection = 1.7,
|
||||||
|
wasSuperbolusUsed = true,
|
||||||
|
superbolusInsulin = 0.3,
|
||||||
|
wasTempTargetUsed = false,
|
||||||
|
totalInsulin = 9.1,
|
||||||
|
percentageCorrection = 70,
|
||||||
|
profileName = " sss",
|
||||||
|
note = "ddd",
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairBolusCalculatorResult(bolus, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastBolusCalculatorResultsIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedBolusCalculatorResults()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastBolusCalculatorResultsIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedBolusCalculatorResults()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddEffectiveProfileSwitch() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val profileSwitch = EffectiveProfileSwitch(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
basalBlocks = validProfile.basalBlocks,
|
||||||
|
isfBlocks = validProfile.isfBlocks,
|
||||||
|
icBlocks = validProfile.icBlocks,
|
||||||
|
targetBlocks = validProfile.targetBlocks,
|
||||||
|
glucoseUnit = EffectiveProfileSwitch.GlucoseUnit.fromConstant(validProfile.units),
|
||||||
|
originalProfileName = "SomeProfile",
|
||||||
|
originalCustomizedName = "SomeProfile (150%, 1h)",
|
||||||
|
originalTimeshift = 3600000,
|
||||||
|
originalPercentage = 150,
|
||||||
|
originalDuration = 3600000,
|
||||||
|
originalEnd = 0,
|
||||||
|
insulinConfiguration = activePlugin.activeInsulin.insulinConfiguration.also {
|
||||||
|
it.insulinEndTime = (validProfile.dia * 3600 * 1000).toLong()
|
||||||
|
},
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairEffectiveProfileSwitch(profileSwitch, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastEffectiveProfileSwitchIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedEffectiveProfileSwitches()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastEffectiveProfileSwitchIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedEffectiveProfileSwitches()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddProfileSwitch() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val profileSwitch = ProfileSwitch(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
basalBlocks = validProfile.basalBlocks,
|
||||||
|
isfBlocks = validProfile.isfBlocks,
|
||||||
|
icBlocks = validProfile.icBlocks,
|
||||||
|
targetBlocks = validProfile.targetBlocks,
|
||||||
|
glucoseUnit = ProfileSwitch.GlucoseUnit.fromConstant(validProfile.units),
|
||||||
|
profileName = "SomeProfile",
|
||||||
|
timeshift = 0,
|
||||||
|
percentage = 100,
|
||||||
|
duration = 0,
|
||||||
|
insulinConfiguration = activePlugin.activeInsulin.insulinConfiguration.also {
|
||||||
|
it.insulinEndTime = (validProfile.dia * 3600 * 1000).toLong()
|
||||||
|
},
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairProfileSwitch(profileSwitch, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastProfileSwitchIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedProfileSwitches()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastProfileSwitchIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedProfileSwitches()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddExtendedBolus() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val extendedBolus = ExtendedBolus(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
amount = 2.0,
|
||||||
|
isEmulatingTempBasal = false,
|
||||||
|
duration = 3600000,
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairExtendedBolus(extendedBolus, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastExtendedBolusIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedExtendedBoluses()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastExtendedBolusIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedExtendedBoluses()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddOffilineEvent() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val offlineEvent = OfflineEvent(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
reason = OfflineEvent.Reason.DISCONNECT_PUMP,
|
||||||
|
duration = 30000,
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairOfflineEvent(offlineEvent, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastOfflineEventIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedOfflineEvents()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastOfflineEventIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedOfflineEvents()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddTemporaryBasal() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val temporaryBasal = TemporaryBasal(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
type = TemporaryBasal.Type.NORMAL,
|
||||||
|
rate = 2.0,
|
||||||
|
isAbsolute = true,
|
||||||
|
duration = 3600000,
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairTemporaryBasal(temporaryBasal, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastTemporaryBasalIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedTemporaryBasals()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastTemporaryBasalIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedTemporaryBasals()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddTemporaryTarget() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val temporaryTarget = TemporaryTarget(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
reason = TemporaryTarget.Reason.ACTIVITY,
|
||||||
|
highTarget = 100.0,
|
||||||
|
lowTarget = 99.0,
|
||||||
|
duration = 3600000,
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairTemporaryTarget(temporaryTarget, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastTempTargetsIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedTempTargets()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastTempTargetsIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedTempTargets()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
|
||||||
|
fun nsAddTherapyEvent() = runTest {
|
||||||
|
sut.scope = CoroutineScope(UnconfinedTestDispatcher(testScheduler))
|
||||||
|
val therapyEvent = TherapyEvent(
|
||||||
|
timestamp = 10000,
|
||||||
|
isValid = true,
|
||||||
|
type = TherapyEvent.Type.ANNOUNCEMENT,
|
||||||
|
note = "ccccc",
|
||||||
|
enteredBy = "dddd",
|
||||||
|
glucose = 101.0,
|
||||||
|
glucoseType = TherapyEvent.MeterType.FINGER,
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL,
|
||||||
|
duration = 3600000,
|
||||||
|
interfaceIDs_backing = InterfaceIDs(
|
||||||
|
nightscoutId = "nightscoutId",
|
||||||
|
pumpId = 11000,
|
||||||
|
pumpType = InterfaceIDs.PumpType.DANA_I,
|
||||||
|
pumpSerial = "bbbb"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val dataPair = DataSyncSelector.PairTherapyEvent(therapyEvent, 1000)
|
||||||
|
// create
|
||||||
|
`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, null))
|
||||||
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(1)).confirmLastTherapyEventIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(1)).processChangedTherapyEvents()
|
||||||
|
// update
|
||||||
|
`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, null))
|
||||||
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
|
verify(dataSyncSelector, Times(2)).confirmLastTherapyEventIdIfGreater(1000)
|
||||||
|
verify(dataSyncSelector, Times(2)).processChangedTherapyEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue