From 2ec8afba054458f7ea0dab98a74623cf7db05ff1 Mon Sep 17 00:00:00 2001 From: katie disimone Date: Tue, 20 Feb 2018 09:55:52 -0800 Subject: [PATCH 1/3] add devicestatus output: eventualBG and BG targets --- Loop/Managers/NightscoutDataManager.swift | 36 ++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/Loop/Managers/NightscoutDataManager.swift b/Loop/Managers/NightscoutDataManager.swift index c4ae3ffcc0..5d20cec32e 100644 --- a/Loop/Managers/NightscoutDataManager.swift +++ b/Loop/Managers/NightscoutDataManager.swift @@ -138,7 +138,41 @@ final class NightscoutDataManager { let loopName = Bundle.main.bundleDisplayName let loopVersion = Bundle.main.shortVersionString - let loopStatus = LoopStatus(name: loopName, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError) + //add new loop parameters + var loopParams : String = "" + var loopBGTlow : String = "" + var loopBGThigh : String = "" + var loopEventualBG : String = "" + if let loopBGRange = deviceDataManager.loopManager.settings.glucoseTargetRangeSchedule?.value(at: Date()), let userUnit = deviceDataManager.loopManager.settings.glucoseTargetRangeSchedule?.unit { + if userUnit == HKUnit.milligramsPerDeciliter() { + loopBGTlow = String(Int((loopBGRange.minValue))) + loopBGThigh = String(Int((loopBGRange.maxValue))) + } + else + { + loopBGTlow = String(format:"%.1f", (loopBGRange.minValue)) + loopBGThigh = String(format:"%.1f",(loopBGRange.maxValue)) + } + } + + else { + loopBGTlow = "N/A" + loopBGThigh = "N/A" + } + + if let loopEventualBGquantity = predictedGlucose?.last?.quantity, let userUnit = deviceDataManager.loopManager.settings.glucoseTargetRangeSchedule?.unit { + loopEventualBG = String(Int(loopEventualBGquantity.doubleValue(for: userUnit))) + } + else + { + loopEventualBG = "N/A" + } + + loopParams = "BGTargets (" + loopBGTlow + ":" + loopBGThigh + ") | EvBG " + loopEventualBG + " | " + loopName + + //upload loopParams instead of just loopName + //that is the only pill that has the option to modify the text + let loopStatus = LoopStatus(name: loopParams, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError) uploadDeviceStatus(nil, loopStatus: loopStatus, includeUploaderStatus: false) From f68fc0ebe057dedefa03c9bc930bed939823bd82 Mon Sep 17 00:00:00 2001 From: katie disimone Date: Tue, 20 Feb 2018 11:42:25 -0800 Subject: [PATCH 2/3] added decimal format for mmol users --- Loop/Managers/NightscoutDataManager.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Loop/Managers/NightscoutDataManager.swift b/Loop/Managers/NightscoutDataManager.swift index 5d20cec32e..9bbb196e93 100644 --- a/Loop/Managers/NightscoutDataManager.swift +++ b/Loop/Managers/NightscoutDataManager.swift @@ -161,7 +161,13 @@ final class NightscoutDataManager { } if let loopEventualBGquantity = predictedGlucose?.last?.quantity, let userUnit = deviceDataManager.loopManager.settings.glucoseTargetRangeSchedule?.unit { - loopEventualBG = String(Int(loopEventualBGquantity.doubleValue(for: userUnit))) + if userUnit == HKUnit.milligramsPerDeciliter() { + loopEventualBG = String(Int(loopEventualBGquantity.doubleValue(for: userUnit))) + } + else + { + loopEventualBG = String(format:"%.1f",loopEventualBGquantity.doubleValue(for: userUnit)) + } } else { From e2ff0fd13d84b85bcfad54761fa9c3ceced5e9f6 Mon Sep 17 00:00:00 2001 From: katie disimone Date: Tue, 20 Feb 2018 12:21:38 -0800 Subject: [PATCH 3/3] hint to undo the LoopPill changes everyone may not want the Loop pill expanded. so to help with customization option, added a note. --- Loop/Managers/NightscoutDataManager.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Loop/Managers/NightscoutDataManager.swift b/Loop/Managers/NightscoutDataManager.swift index 9bbb196e93..abfe57804b 100644 --- a/Loop/Managers/NightscoutDataManager.swift +++ b/Loop/Managers/NightscoutDataManager.swift @@ -180,6 +180,10 @@ final class NightscoutDataManager { //that is the only pill that has the option to modify the text let loopStatus = LoopStatus(name: loopParams, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError) + //if you wish to have the Loop pill clean, without the added BGtargets and EventualBG showing, remove the slashes on code line below, and add slashes to code line above + + //let loopStatus = LoopStatus(name: loopName, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError) + uploadDeviceStatus(nil, loopStatus: loopStatus, includeUploaderStatus: false) }