Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
6
600SeriesAndroidUploader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cgm
uploader
600SeriesAndroidUploader
Commits
2df004a0
Unverified
Commit
2df004a0
authored
Jun 28, 2017
by
Johannes Mockenhaupt
Browse files
Options
Downloads
Patches
Plain Diff
Add comment, make some variables final
to show which variables change throughout the course of the method
parent
a593ba59
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/info/nightscout/android/medtronic/service/MedtronicCnlIntentService.java
+19
-7
19 additions, 7 deletions
.../android/medtronic/service/MedtronicCnlIntentService.java
with
19 additions
and
7 deletions
app/src/main/java/info/nightscout/android/medtronic/service/MedtronicCnlIntentService.java
+
19
−
7
View file @
2df004a0
...
@@ -106,15 +106,26 @@ public class MedtronicCnlIntentService extends IntentService {
...
@@ -106,15 +106,26 @@ public class MedtronicCnlIntentService extends IntentService {
protected
void
onHandleIntent
(
Intent
intent
)
{
protected
void
onHandleIntent
(
Intent
intent
)
{
Log
.
d
(
TAG
,
"onHandleIntent called"
);
Log
.
d
(
TAG
,
"onHandleIntent called"
);
try
{
try
{
// TODO use of ConfigurationStore is confusinng if pollInterval uses the CS, which
long
timePollStarted
=
System
.
currentTimeMillis
(),
// uses the POLL_PERIOD_MS, while the latter constant is also used directly.
timePollExpected
=
timePollStarted
,
timeLastGoodSGV
=
dataStore
.
getLastPumpStatus
().
getSgvDate
().
getTime
();
// Note that the variable pollInterval refers to the poll we'd like to make to the pump,
// based on settings and battery level, while POLL_PERIOD_MS is used to calculate
short
pumpBatteryLevel
=
dataStore
.
getLastPumpStatus
().
getBatteryPercentage
();
// when the pump is going to poll data from the transmitter again.
// Thus POLL_PERIOD_MS is important to calculate times we'd be clashing with transmitter
// to pump transmissions, which are then checked against the time the uploader would
// like to poll, which is calculated using the pollInterval variable.
// TODO find better variable names to make this distinction clearer and/or if possible
// do more method extraction refactorings to make this method easier to grasp
final
long
timePollStarted
=
System
.
currentTimeMillis
();
final
long
timeLastGoodSGV
=
dataStore
.
getLastPumpStatus
().
getSgvDate
().
getTime
();
final
long
timePollExpected
;
if
(
timeLastGoodSGV
!=
0
)
{
if
(
timeLastGoodSGV
!=
0
)
{
timePollExpected
=
timeLastGoodSGV
+
POLL_PERIOD_MS
+
POLL_GRACE_PERIOD_MS
+
(
POLL_PERIOD_MS
*
((
timePollStarted
-
1000L
-
(
timeLastGoodSGV
+
POLL_GRACE_PERIOD_MS
))
/
POLL_PERIOD_MS
));
timePollExpected
=
timeLastGoodSGV
+
POLL_PERIOD_MS
+
POLL_GRACE_PERIOD_MS
+
(
POLL_PERIOD_MS
*
((
timePollStarted
-
1000L
-
(
timeLastGoodSGV
+
POLL_GRACE_PERIOD_MS
))
/
POLL_PERIOD_MS
));
}
else
{
timePollExpected
=
timePollStarted
;
}
}
// avoid polling when too close to sensor-pump comms
// avoid polling when too close to sensor-pump comms
...
@@ -124,6 +135,7 @@ public class MedtronicCnlIntentService extends IntentService {
...
@@ -124,6 +135,7 @@ public class MedtronicCnlIntentService extends IntentService {
return
;
return
;
}
}
final
short
pumpBatteryLevel
=
dataStore
.
getLastPumpStatus
().
getBatteryPercentage
();
long
pollInterval
=
configurationStore
.
getPollInterval
();
long
pollInterval
=
configurationStore
.
getPollInterval
();
if
((
pumpBatteryLevel
>
0
)
&&
(
pumpBatteryLevel
<=
25
))
{
if
((
pumpBatteryLevel
>
0
)
&&
(
pumpBatteryLevel
<=
25
))
{
pollInterval
=
configurationStore
.
getLowBatteryPollInterval
();
pollInterval
=
configurationStore
.
getLowBatteryPollInterval
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment