NSClient mode sync
This commit is contained in:
parent
61d5565d18
commit
50720b8497
6 changed files with 24 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ interface Profile {
|
|||
*/
|
||||
val timeshift: Int
|
||||
|
||||
/**
|
||||
* is equal to another profile?
|
||||
*/
|
||||
fun isEqual(profile: Profile): Boolean
|
||||
|
||||
/**
|
||||
* Basal value according to "now"
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue