Merge remote-tracking branch 'origin/dev' into ns15
This commit is contained in:
commit
8db9891140
5 changed files with 26 additions and 25 deletions
|
@ -377,7 +377,7 @@ sealed class ProfileSealed(
|
||||||
val ret = Array(shifted.size) { ProfileValue(0, 0.0) }
|
val ret = Array(shifted.size) { ProfileValue(0, 0.0) }
|
||||||
var elapsed = 0
|
var elapsed = 0
|
||||||
for (index in shifted.indices) {
|
for (index in shifted.indices) {
|
||||||
ret[index] = ProfileValue(elapsed, (shifted[index].lowTarget + shifted[index].highTarget) / 2.0)
|
ret[index] = ProfileValue(elapsed, Profile.toMgdl((shifted[index].lowTarget + shifted[index].highTarget) / 2.0, units))
|
||||||
elapsed += T.msecs(shifted[index].duration).secs().toInt()
|
elapsed += T.msecs(shifted[index].duration).secs().toInt()
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.plugins.sync.R
|
import info.nightscout.plugins.sync.R
|
||||||
import info.nightscout.plugins.sync.tidepool.events.EventTidepoolStatus
|
import info.nightscout.plugins.sync.tidepool.events.EventTidepoolStatus
|
||||||
|
@ -37,7 +38,8 @@ class TidepoolUploader @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val uploadChunk: UploadChunk,
|
private val uploadChunk: UploadChunk,
|
||||||
private val activePlugin: ActivePlugin,
|
private val activePlugin: ActivePlugin,
|
||||||
private val dateUtil: DateUtil
|
private val dateUtil: DateUtil,
|
||||||
|
private val config: Config
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var wl: PowerManager.WakeLock? = null
|
private var wl: PowerManager.WakeLock? = null
|
||||||
|
@ -157,7 +159,7 @@ class TidepoolUploader @Inject constructor(
|
||||||
rxBus.send(EventTidepoolStatus(("Creating new dataset")))
|
rxBus.send(EventTidepoolStatus(("Creating new dataset")))
|
||||||
val call = session.service.openDataSet(
|
val call = session.service.openDataSet(
|
||||||
session.token!!, session.authReply!!.userid!!,
|
session.token!!, session.authReply!!.userid!!,
|
||||||
OpenDatasetRequestMessage(activePlugin.activePump.serialNumber(), dateUtil).getBody()
|
OpenDatasetRequestMessage(config, dateUtil).getBody()
|
||||||
)
|
)
|
||||||
call.enqueue(TidepoolCallback<DatasetReplyMessage>(aapsLogger, rxBus, session, "Open New Dataset", {
|
call.enqueue(TidepoolCallback<DatasetReplyMessage>(aapsLogger, rxBus, session, "Open New Dataset", {
|
||||||
connectionStatus = ConnectionStatus.CONNECTED
|
connectionStatus = ConnectionStatus.CONNECTED
|
||||||
|
@ -229,8 +231,9 @@ class TidepoolUploader @Inject constructor(
|
||||||
releaseWakeLock()
|
releaseWakeLock()
|
||||||
uploadNext()
|
uploadNext()
|
||||||
}, {
|
}, {
|
||||||
rxBus.send(EventTidepoolStatus(("Upload FAILED")))
|
connectionStatus = ConnectionStatus.FAILED
|
||||||
releaseWakeLock()
|
rxBus.send(EventTidepoolStatus(("Upload FAILED")))
|
||||||
|
releaseWakeLock()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,9 @@ class UploadChunk @Inject constructor(
|
||||||
val pss = repository.getEffectiveProfileSwitchDataFromTimeToTime(start, end, true).blockingGet()
|
val pss = repository.getEffectiveProfileSwitchDataFromTimeToTime(start, end, true).blockingGet()
|
||||||
val selection = LinkedList<ProfileElement>()
|
val selection = LinkedList<ProfileElement>()
|
||||||
for (ps in pss) {
|
for (ps in pss) {
|
||||||
newInstanceOrNull(ps)?.let { selection.add(it) }
|
newInstanceOrNull(ps)?.let {
|
||||||
|
selection.add(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (selection.size > 0)
|
if (selection.size > 0)
|
||||||
rxBus.send(EventTidepoolStatus("${selection.size} ProfileSwitches selected for upload"))
|
rxBus.send(EventTidepoolStatus("${selection.size} ProfileSwitches selected for upload"))
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ProfileElement(ps: EffectiveProfileSwitch, serialNumber: String, dateUtil:
|
||||||
@Expose
|
@Expose
|
||||||
internal var insulinSensitivities: IsfProfile = IsfProfile()
|
internal var insulinSensitivities: IsfProfile = IsfProfile()
|
||||||
@Expose
|
@Expose
|
||||||
internal var deviceId: String = TidepoolUploader.PUMP_TYPE + ":" + serialNumber
|
internal var deviceId: String? = TidepoolUploader.PUMP_TYPE + ":" + serialNumber
|
||||||
@Expose
|
@Expose
|
||||||
internal var deviceSerialNumber: String = serialNumber
|
internal var deviceSerialNumber: String = serialNumber
|
||||||
@Expose
|
@Expose
|
||||||
|
@ -35,15 +35,14 @@ class ProfileElement(ps: EffectiveProfileSwitch, serialNumber: String, dateUtil:
|
||||||
init {
|
init {
|
||||||
type = "pumpSettings"
|
type = "pumpSettings"
|
||||||
val profile: Profile = ProfileSealed.EPS(ps)
|
val profile: Profile = ProfileSealed.EPS(ps)
|
||||||
checkNotNull(profile)
|
|
||||||
for (br in profile.getBasalValues())
|
for (br in profile.getBasalValues())
|
||||||
basalSchedules.Normal.add(BasalRate(br.timeAsSeconds * 1000, br.value))
|
basalSchedules.Normal.add(BasalRate(br.timeAsSeconds * 1000, br.value))
|
||||||
for (target in profile.getSingleTargetsMgdl())
|
for (target in profile.getSingleTargetsMgdl())
|
||||||
bgTargets.Normal.add(Target(target.timeAsSeconds * 1000, target.value))
|
bgTargets.Normal.add(Target(target.timeAsSeconds * 1000, target.value.toInt()))
|
||||||
for (ic in profile.getIcsValues())
|
for (ic in profile.getIcsValues())
|
||||||
carbRatios.Normal.add(Ratio(ic.timeAsSeconds * 1000, ic.value))
|
carbRatios.Normal.add(Ratio(ic.timeAsSeconds * 1000, ic.value.toInt()))
|
||||||
for (isf in profile.getIsfsMgdlValues())
|
for (isf in profile.getIsfsMgdlValues())
|
||||||
insulinSensitivities.Normal.add(Ratio(isf.timeAsSeconds * 1000, isf.value))
|
insulinSensitivities.Normal.add(Ratio(isf.timeAsSeconds * 1000, isf.value.toInt()))
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class BasalProfile internal constructor(
|
inner class BasalProfile internal constructor(
|
||||||
|
@ -74,7 +73,7 @@ class ProfileElement(ps: EffectiveProfileSwitch, serialNumber: String, dateUtil:
|
||||||
@field:Expose
|
@field:Expose
|
||||||
internal var start: Int,
|
internal var start: Int,
|
||||||
@field:Expose
|
@field:Expose
|
||||||
internal var target: Double
|
internal var target: Int
|
||||||
)
|
)
|
||||||
|
|
||||||
inner class IcProfile internal constructor(
|
inner class IcProfile internal constructor(
|
||||||
|
@ -91,6 +90,6 @@ class ProfileElement(ps: EffectiveProfileSwitch, serialNumber: String, dateUtil:
|
||||||
@field:Expose
|
@field:Expose
|
||||||
internal var start: Int,
|
internal var start: Int,
|
||||||
@field:Expose
|
@field:Expose
|
||||||
internal var amount: Double
|
internal var amount: Int
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package info.nightscout.plugins.sync.tidepool.messages
|
package info.nightscout.plugins.sync.tidepool.messages
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose
|
import com.google.gson.annotations.Expose
|
||||||
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.plugins.sync.tidepool.comm.TidepoolUploader
|
import info.nightscout.plugins.sync.tidepool.comm.TidepoolUploader
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import info.nightscout.shared.utils.T
|
import info.nightscout.shared.utils.T
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
|
|
||||||
class OpenDatasetRequestMessage(serialNumber: String, dateUtil: DateUtil) : BaseMessage() {
|
class OpenDatasetRequestMessage(config: Config, dateUtil: DateUtil) : BaseMessage() {
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
var deviceId: String = TidepoolUploader.PUMP_TYPE + ":" + serialNumber
|
var deviceId: String? = null
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
var time: String = dateUtil.toISOAsUTC(System.currentTimeMillis())
|
var time: String = dateUtil.toISOAsUTC(System.currentTimeMillis())
|
||||||
|
@ -22,7 +23,7 @@ class OpenDatasetRequestMessage(serialNumber: String, dateUtil: DateUtil) : Base
|
||||||
|
|
||||||
//public String byUser;
|
//public String byUser;
|
||||||
@Expose
|
@Expose
|
||||||
var client = ClientInfo()
|
var client = ClientInfo(config.APPLICATION_ID)
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
var computerTime: String = dateUtil.toISONoZone(System.currentTimeMillis())
|
var computerTime: String = dateUtil.toISONoZone(System.currentTimeMillis())
|
||||||
|
@ -49,16 +50,12 @@ class OpenDatasetRequestMessage(serialNumber: String, dateUtil: DateUtil) : Base
|
||||||
var timezone: String = TimeZone.getDefault().id
|
var timezone: String = TimeZone.getDefault().id
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
var version = "1.0"
|
var version = config.VERSION_NAME
|
||||||
|
|
||||||
inner class ClientInfo {
|
inner class ClientInfo(
|
||||||
|
@Expose val name: String,
|
||||||
@Expose
|
@Expose val version: String = TidepoolUploader.VERSION
|
||||||
val name = "AAPS"
|
)
|
||||||
|
|
||||||
@Expose
|
|
||||||
val version = TidepoolUploader.VERSION
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class Deduplicator {
|
inner class Deduplicator {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue