Skip to content
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

Add predicted iob data to broadcastservice #2294

Conversation

bigdigital
Copy link
Contributor

@bigdigital bigdigital commented Aug 25, 2022

Some people would like to see predicted(simulated) iob data on the watch. So this PR extends the broadcast data with a predicted IOB and BWP info.
Also it enables not simple mode in defaultLines function in order to receive simulated data including predicted lgraph lines.
The 28.01.2023 updates.
added cancel_alarm not notify remote devices in case alert were stopped
added external status line in extra key as string + timeStamp

@@ -495,6 +527,9 @@ protected Bundle prepareBgBundle(BroadcastModel broadcastModel) {
bundle.putLong("treatment.timeStamp", treatment.timestamp);
}

predictedIOB = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMHO this always sets the variables to an empty string which does not change till line 569. Maybe you should initialize the strings to "" in line 84/85?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a place where the variable resets in case if the iob data would not be updated in BgGraphBuilder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But in case if settings.isDisplayGraph() is false, the predictedIOB and predictedBWP always would be empty. Maybe it would be better to transfer iob only if graph is enabled.

Copy link
Collaborator

@tolot27 tolot27 Aug 31, 2022

Choose a reason for hiding this comment

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

The only location where predictedIOB and predictedBWP are set to likely non-empty value is in the statusReceiver onReceive event. The next use is bundle.putString("predict.IOB", predictedIOB); but right before the if condition these two variables will be emptied. Hence, an empty string is always passed to bundle.putString. That's my main concern. Did I oversee anything?

Copy link
Contributor Author

@bigdigital bigdigital Aug 31, 2022

Choose a reason for hiding this comment

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

Yes. the variables are filled via statusReceiver by receiving the broadcast messages. And those broadcast messages can be triggered by bgGraphBuilder.defaultLines(false) function which calls addBgReadingValues(simple) and the last one function calls Home.updateStatusLine("iob", df.format(iob.iob)) . So when the code reaches to the bundle.putString , the iob and wpb values would be filled with the valid data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tolot27 as i understand this pr was stuck because the "bwp" and "iob" broadcast data which is generated in BgGraphBuilder transfers with help of sendBroadcast finction which is runs asynchronously. Maybe to resolve this problem we can change sendBroadcast in updateStatusLine to sendBroadcastSync which should block the execution of the thread .

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about using the keystore data like is done with bwp_last_insulin in PebbleDisplayTrend ? I could easily add more keystore fields if this doesn't include everything needed. Then you don't need to worry about asynchronous broadcasts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. I guess this should help to transfer data across different parts of the application. It is enough to add bwp_update data (but maybe better to divide the current string inot two separate variables with the carb and insulin info). And a separate keystore for "iob" which is declared by this line Home.updateStatusLine("iob", df.format(iob.iob));

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have added both, let me know if this helps: 094b09c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Now works fine, added appropriate code changes

@tolot27 tolot27 added enhancement sync related to share and sync data labels Aug 30, 2022
sedy89 added a commit to sedy89/xDrip that referenced this pull request Sep 17, 2022
sedy89 pushed a commit to sedy89/xDrip that referenced this pull request Sep 18, 2022
@bigdigital bigdigital mentioned this pull request Jan 3, 2023
4 tasks
@4RK4N
Copy link

4RK4N commented Jan 6, 2023

so what exactly is blocking the merge of this PR ?

@Navid200 Navid200 requested review from jamorham and removed request for jamorham January 7, 2023 16:57
@Navid200
Copy link
Collaborator

Navid200 commented Jan 7, 2023

@bigdigital Your last post in this PR is a question. Do you believe this PR is ready as is?

If this PR is merged, what else could WatchDrip need in the future that would require another change to xDrip?
Is it not possible to create a mechanism that would allow editing what Nightscout sends if needed in the future?
For example, is it not possible for WatchDrip to request a parameter and xDrip sends it on the next broadcast? Then, if 2 months from now, WatchDrip needs another parameter, you will not need to open another PR. You will just modify WatchDrip to request something that it did not previously.

Or, is that not practical?

If that is not practical, can you think of any other parameters that may become required in the future and include them right now in this same PR?

Please note none of my comments are needed to be answered and addressed. I am just hoping to help the conversation flowing.

@oakeley
Copy link

oakeley commented Jan 8, 2023

Please could this be added to xDrip? This would enable so much. Many thanks @bigdigital for proposing it and @4RK4N for seconding it

@bigdigital
Copy link
Contributor Author

bigdigital commented Jan 8, 2023

Do you believe this PR is ready as is?

The last time i tested it, it works fine.

If this PR is merged, what else could WatchDrip need in the future that would require another change to xDrip?

Maybe a small fix to transfer the dismissed snooze alarms action to the watch bigdigital/watchdrip#4

For example, is it not possible for WatchDrip to request a parameter and xDrip sends it on the next broadcast? Then, if 2 months from now, WatchDrip needs another parameter, you will not need to open another PR. You will just modify WatchDrip to request something that it did not previously.

This would be of course great, but as i know there is no such global variable store, where you can get all those values. For example, predicated IOB and BWP are not stored anywhere. And updates only by graph update.

@4RK4N
Copy link

4RK4N commented Jan 25, 2023

Do you believe this PR is ready as is?

The last time i tested it, it works fine.

If this PR is merged, what else could WatchDrip need in the future that would require another change to xDrip?

Maybe a small fix to transfer the dismissed snooze alarms action to the watch bigdigital/watchdrip#4

For example, is it not possible for WatchDrip to request a parameter and xDrip sends it on the next broadcast? Then, if 2 months from now, WatchDrip needs another parameter, you will not need to open another PR. You will just modify WatchDrip to request something that it did not previously.

This would be of course great, but as i know there is no such global variable store, where you can get all those values. For example, predicated IOB and BWP are not stored anywhere. And updates only by graph update.

adding parsed iob cob and maybe tbr data from the external status line aaps sends into xdrip would be good. i have a hacky modification doing that right now. for a proper PR the ExternalStatusService.java would need a getCOB() added and maybe some testing on getTBR(), getIOB() and getAbsoluteBR() if they output the desired result.

many xdrip users also use aaps and in turn the xdrip predictions are not as good as aaps predictions. which is totally ok since that's not the primary purpose of xdrip. but to have the aaps external status data sent by the broadcastservice would help aaps users a lot.

EDIT UPDATE:
i cleaned up my xdrip fork and sent a PR with the changes to @bigdigital to integrate it into this PR.
ExternalStatusLine now gets transmitted as a string as-is with a timeStamp added in a seperate bundle field. Further parsing can be done in the recieving app (watchdrip) if needed.
here is my small addition: bigdigital@90369a2
I hope we can get this merged soon.

EDIT UPDATE 2:
i compiled a new xdrip with tis pr merged in. no problems so far. im also using the sendBroadcastSync() change mentioned earlier in this PR #2294 (comment)

@Navid200 Navid200 requested a review from jamorham March 4, 2023 15:23
@jamorham jamorham merged commit 4e5abd9 into NightscoutFoundation:master Mar 28, 2023
@bigdigital
Copy link
Contributor Author

Thank you. @jamorham

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement sync related to share and sync data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants