|
@@ -86,6 +86,7 @@ extension MainViewController {
|
|
|
webLoadNSSage()
|
|
webLoadNSSage()
|
|
|
|
|
|
|
|
// Give the alarms and calendar 15 seconds delay to allow time for data to compile
|
|
// Give the alarms and calendar 15 seconds delay to allow time for data to compile
|
|
|
|
|
+ print("Start View Timer")
|
|
|
self.startViewTimer(time: viewTimeInterval)
|
|
self.startViewTimer(time: viewTimeInterval)
|
|
|
} else {
|
|
} else {
|
|
|
// Things to do if we already have data and don't need a network call
|
|
// Things to do if we already have data and don't need a network call
|
|
@@ -99,6 +100,10 @@ extension MainViewController {
|
|
|
if UserDefaultsRepository.downloadCarbs.value {
|
|
if UserDefaultsRepository.downloadCarbs.value {
|
|
|
webLoadNSCarbs()
|
|
webLoadNSCarbs()
|
|
|
}*/
|
|
}*/
|
|
|
|
|
+ if bgData.count > 0 {
|
|
|
|
|
+ self.checkAlarms(bgs: bgData)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -157,6 +162,7 @@ extension MainViewController {
|
|
|
// NS BG Data Response processor
|
|
// NS BG Data Response processor
|
|
|
func ProcessNSBGData(data: [sgvData], onlyPullLastRecord: Bool){
|
|
func ProcessNSBGData(data: [sgvData], onlyPullLastRecord: Bool){
|
|
|
print("Enter BG Processor")
|
|
print("Enter BG Processor")
|
|
|
|
|
+
|
|
|
var pullDate = data[data.count - 1].date / 1000
|
|
var pullDate = data[data.count - 1].date / 1000
|
|
|
pullDate.round(FloatingPointRoundingRule.toNearestOrEven)
|
|
pullDate.round(FloatingPointRoundingRule.toNearestOrEven)
|
|
|
|
|
|
|
@@ -209,18 +215,22 @@ extension MainViewController {
|
|
|
|
|
|
|
|
if let directionBG = entries[latestEntryi].direction {
|
|
if let directionBG = entries[latestEntryi].direction {
|
|
|
DirectionText.text = bgDirectionGraphic(directionBG)
|
|
DirectionText.text = bgDirectionGraphic(directionBG)
|
|
|
|
|
+ latestDirectionString = bgDirectionGraphic(directionBG)
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
DirectionText.text = ""
|
|
DirectionText.text = ""
|
|
|
|
|
+ latestDirectionString = ""
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if deltaBG < 0 {
|
|
if deltaBG < 0 {
|
|
|
self.DeltaText.text = String(deltaBG)
|
|
self.DeltaText.text = String(deltaBG)
|
|
|
|
|
+ latestDeltaString = String(deltaBG)
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
self.DeltaText.text = "+" + String(deltaBG)
|
|
self.DeltaText.text = "+" + String(deltaBG)
|
|
|
|
|
+ latestDeltaString = "+" + String(deltaBG)
|
|
|
}
|
|
}
|
|
|
self.updateBadge(val: latestBG)
|
|
self.updateBadge(val: latestBG)
|
|
|
|
|
|
|
@@ -314,6 +324,7 @@ extension MainViewController {
|
|
|
UserDefaultsRepository.alertLastLoopTime.value = lastLoopTime
|
|
UserDefaultsRepository.alertLastLoopTime.value = lastLoopTime
|
|
|
if let failure = lastLoopRecord["failureReason"] {
|
|
if let failure = lastLoopRecord["failureReason"] {
|
|
|
LoopStatusLabel.text = "X"
|
|
LoopStatusLabel.text = "X"
|
|
|
|
|
+ latestLoopStatusString = "X"
|
|
|
} else {
|
|
} else {
|
|
|
if let enacted = lastLoopRecord["enacted"] as? [String:AnyObject] {
|
|
if let enacted = lastLoopRecord["enacted"] as? [String:AnyObject] {
|
|
|
if let lastTempBasal = enacted["rate"] as? Double {
|
|
if let lastTempBasal = enacted["rate"] as? Double {
|
|
@@ -322,9 +333,11 @@ extension MainViewController {
|
|
|
}
|
|
}
|
|
|
if let iobdata = lastLoopRecord["iob"] as? [String:AnyObject] {
|
|
if let iobdata = lastLoopRecord["iob"] as? [String:AnyObject] {
|
|
|
tableData[0].value = String(format:"%.1f", (iobdata["iob"] as! Double))
|
|
tableData[0].value = String(format:"%.1f", (iobdata["iob"] as! Double))
|
|
|
|
|
+ latestIOB = String(format:"%.1f", (iobdata["iob"] as! Double))
|
|
|
}
|
|
}
|
|
|
if let cobdata = lastLoopRecord["cob"] as? [String:AnyObject] {
|
|
if let cobdata = lastLoopRecord["cob"] as? [String:AnyObject] {
|
|
|
tableData[1].value = String(format:"%.0f", cobdata["cob"] as! Double)
|
|
tableData[1].value = String(format:"%.0f", cobdata["cob"] as! Double)
|
|
|
|
|
+ latestCOB = String(format:"%.0f", cobdata["cob"] as! Double)
|
|
|
}
|
|
}
|
|
|
if let predictdata = lastLoopRecord["predicted"] as? [String:AnyObject] {
|
|
if let predictdata = lastLoopRecord["predicted"] as? [String:AnyObject] {
|
|
|
let prediction = predictdata["values"] as! [Double]
|
|
let prediction = predictdata["values"] as! [Double]
|
|
@@ -347,18 +360,22 @@ extension MainViewController {
|
|
|
}
|
|
}
|
|
|
if tempBasalTime > lastBGTime {
|
|
if tempBasalTime > lastBGTime {
|
|
|
LoopStatusLabel.text = "⏀"
|
|
LoopStatusLabel.text = "⏀"
|
|
|
|
|
+ latestLoopStatusString = "⏀"
|
|
|
} else {
|
|
} else {
|
|
|
LoopStatusLabel.text = "↻"
|
|
LoopStatusLabel.text = "↻"
|
|
|
|
|
+ latestLoopStatusString = "↻"
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
LoopStatusLabel.text = "↻"
|
|
LoopStatusLabel.text = "↻"
|
|
|
|
|
+ latestLoopStatusString = "↻"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ((TimeInterval(Date().timeIntervalSince1970) - lastLoopTime) / 60) > 10 {
|
|
if ((TimeInterval(Date().timeIntervalSince1970) - lastLoopTime) / 60) > 10 {
|
|
|
LoopStatusLabel.text = "⚠"
|
|
LoopStatusLabel.text = "⚠"
|
|
|
|
|
+ latestLoopStatusString = "⚠"
|
|
|
}
|
|
}
|
|
|
} // end lastLoopTime
|
|
} // end lastLoopTime
|
|
|
} // end lastLoop Record
|
|
} // end lastLoop Record
|
|
@@ -709,6 +726,7 @@ extension MainViewController {
|
|
|
if i == entries.count - 1 && dateTimeStamp + duration <= dateTimeUtils.getNowTimeIntervalUTC() {
|
|
if i == entries.count - 1 && dateTimeStamp + duration <= dateTimeUtils.getNowTimeIntervalUTC() {
|
|
|
lastEndDot = Date().timeIntervalSince1970 + (55 * 60)
|
|
lastEndDot = Date().timeIntervalSince1970 + (55 * 60)
|
|
|
tableData[2].value = String(format:"%.1f", basalRate)
|
|
tableData[2].value = String(format:"%.1f", basalRate)
|
|
|
|
|
+ latestBasal = String(format:"%.1f", basalRate)
|
|
|
} else {
|
|
} else {
|
|
|
lastEndDot = dateTimeStamp + (duration * 60)
|
|
lastEndDot = dateTimeStamp + (duration * 60)
|
|
|
}
|
|
}
|
|
@@ -754,6 +772,7 @@ extension MainViewController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tableData[2].value = String(format:"%.1f", scheduled)
|
|
tableData[2].value = String(format:"%.1f", scheduled)
|
|
|
|
|
+ latestBasal = String(format:"%.1f", scheduled)
|
|
|
// Make the starting dot at the last ending dot
|
|
// Make the starting dot at the last ending dot
|
|
|
let startDot = basalGraphStruct(basalRate: scheduled, date: Double(lastEndDot))
|
|
let startDot = basalGraphStruct(basalRate: scheduled, date: Double(lastEndDot))
|
|
|
basalData.append(startDot)
|
|
basalData.append(startDot)
|