Skip to content

Conversation

@ps2
Copy link
Collaborator

@ps2 ps2 commented Aug 8, 2016

Uploads Loop status to Nightscout, with BG forecasts.

failureReason = nil
}

let loopName = NSBundle.mainBundle().bundleDisplayName
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move lines like this out of the LoopDataManager and into the receiver's method?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ideally all the NightscoutUploadKit models would be created somewhere else, like DiagnosticLogger, or an extension of NightscoutUploader?

@mddub
Copy link
Contributor

mddub commented Aug 9, 2016

🎉👍👏😂😍 So glad you did this, @ps2.

This will make integrating with Urchin so much easier - I've been running a much simpler/hackier version of these changes to show the prediction graph and eventual BG:

img_3200


if insulinOnBoard == nil {
dispatch_group_enter(updateGroup)
deviceDataManager.doseStore.insulinOnBoardAtDate(NSDate()) { (value, error) in
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right timestamp to use?

Copy link
Collaborator

@loudnate loudnate Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a dosing perspective, yeah, you'd want it to be as close-as-possible to startDate on line 331, which it will be here, since these data retrievals should be pretty fast. If it needs to be exact, you could set startDate on line 126 and pass it in as an argument to self.updatePredictedGlucoseAndRecommendedBasal


let loopStatus = LoopStatus(name: loopName, version: loopVersion, timestamp: statusTime, iob: iob, suggested: loopSuggested, enacted: loopEnacted, failureReason: lastLoopError)

deviceDataManager.remoteDataManager.uploadDeviceStatus(nil, loopStatus: loopStatus)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this implementation can move into here, now, to keep all the NS models together?

Also, would be good to punt at the top of this method if there's no nightscout uploader

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds good.

…ting suggested attributes when last basal is successful
@ps2
Copy link
Collaborator Author

ps2 commented Aug 10, 2016

@mddub I've been using urchin, and love it. Forecasted bg would be amazing! I'm just about done with this, I think.

@ps2
Copy link
Collaborator Author

ps2 commented Aug 10, 2016

Was trying to get COB and IOB NS attributes populated to wrap this up, but it looks like they might require more work, so I'll tackle that as a separate PR. I'll cut a RL release, and then point this to it, and the PR should be ready for review again.

- parameter resultsHandler: A closure called once the values have been retrieved. The closure takes the following arguments:
- predictedGlucose: The calculated timeline of predicted glucose values
- insulinEffect: The predicted effect of insulin
- carbEffect: The predicted effect of carbohydrates
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need to add these?

Copy link
Collaborator Author

@ps2 ps2 Aug 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to soon; I just need to figure out how to turn them into BG lines. carbEffect -> predicted BG if only carbs were considered, and insulinEffect -> predicted BG if only insulin were considered.

But I can remove them for this PR, if you'd like.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow with the "only [x] were considered"?

I'm good with merging this PR if you are, which would mean reconciling this docstring and reverting the import line at the top. It sounds like there's still some munging of the carb/insulin effect lines for Nightscout, though ideally you can sort that processing out in the cloud. Just let me know what you'd like to do.

let predBGs: PredictedBG?

if let predicted = predictedGlucose {
let values = predicted.map({ (value) -> HKQuantity in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can condense this to predicted.map { $0.quantity } if you like.


- parameter resultsHandler: A closure called once the values have been retrieved. The closure takes the following arguments:
- predictedGlucose: The calculated timeline of predicted glucose values
- insulinOnBoard Current insulin on board
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order here doesn't match the arguments below (which is OK for Swift 2, but not for Swift 3)

@loudnate
Copy link
Collaborator

LGTM – cut a final build of RileyLink frameworks?

@loudnate loudnate merged commit 240995a into LoopKit:dev Aug 11, 2016
@loudnate
Copy link
Collaborator

Huzzah! Thanks for all the work you put into this.

ps2 pushed a commit that referenced this pull request Aug 4, 2020
- https://tidepool.atlassian.net/browse/LOOP-1361
- Add wasUserEntered property to various glucose data structures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants