-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Update for x22 Pumps to Display Reservoir Status HUD #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This branch commit encapsulates the Update to allow x22 pumps to display the Reservoir Status in the HUD. Added PumpMode.swift Extension, Updated Logic and tested values.
Added BIOB Value for x22 pumps from IOB Calculated Decay from dosestore.
|
I also added the x22 BIoB value from the Chart Decay |
|
That's not bolus IOB, that's net IOB. |
|
The first commit looks good, but the second one is displaying incorrect data. Please resubmit with just the reservoir change. |
| } else { | ||
| cell.detailTextLabel?.text = emptyValueString | ||
| //x22 BIoB Value from IOB Chart Decay Data | ||
| dataManager.doseStore.getInsulinOnBoardValues(startDate: NSDate(), endDate: NSDate().dateByAddingTimeInterval(300)) { (values, error) -> Void in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tip here: you don't usually want to make asynchronous calls in table data source methods, because you don't own the underlying cell views or control their mapping and reuse. By the time this completion closure executes, the system may have reused the cell for a completely different index path – and your call would be setting label text that's completely out-of-place.
Another issue is that the documentation for getInsulinOnBoardValues states that it executes your completion closure on an arbitrary background queue. You cannot use the vast majority of UIKit APIs (like setting label text) on any queue except the main one, so you'll need to create a dispatch call to the main queue. Using UIKit on a background queue can result in unexpected behavior. At best, that means the label text isn't drawn at all until someone else invokes a display call. At worst, the app can crash.
Finally,
NSDate().dateByAddingTimeInterval(300)can be more expressively written as
NSDate(timeIntervalSinceNow: NSTimeInterval(minutes: 5))|
I pulled the Net IOB Code out. Especially if the plan is to move away from text cells in future. Thanks again for the knowledge share. |
|
Awesome, thanks! I can squash the the multiple commits into one, single commit. Just be aware that you'll need to re-merge from Loop/dev into your own fork because the commit hash will change. |
Moves the example app to the Carthage project
(Put back obsolescent DeviceManagerDelegate code)
Update to allow x22 pumps to display the Reservoir Status in the HUD. Added PumpModel.swift Extension, Updated Logic and Tested Values and Display.