- gradle fixes
- remove formatting changes - moved plugins/general/overview/Dialogs/ to plugins/general/overview/dialogs/ - fixing treatment changes that are received from NS, and extending copying of data to ignore pumpId
This commit is contained in:
parent
26a50bbbc4
commit
7392eaeb58
47 changed files with 842 additions and 1329 deletions
276
app/build.gradle
276
app/build.gradle
|
@ -1,276 +0,0 @@
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
maven { url 'https://maven.fabric.io/public' }
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath 'io.fabric.tools:gradle:1.+'
|
|
||||||
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.3'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: "com.android.application"
|
|
||||||
apply plugin: 'com.google.gms.google-services'
|
|
||||||
apply plugin: "io.fabric"
|
|
||||||
apply plugin: "jacoco-android"
|
|
||||||
apply plugin: 'com.jakewharton.butterknife'
|
|
||||||
|
|
||||||
ext {
|
|
||||||
supportLibraryVersion = "27.1.1"
|
|
||||||
ormLiteVersion = "4.46"
|
|
||||||
powermockVersion = "1.7.3"
|
|
||||||
dexmakerVersion = "1.2"
|
|
||||||
butterknifeVersion = "8.8.1"
|
|
||||||
playServicesWearVersion = "10.2.1" // 10.2.1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven { url 'https://maven.fabric.io/public' }
|
|
||||||
jcenter { url "https://jcenter.bintray.com/" }
|
|
||||||
}
|
|
||||||
|
|
||||||
def generateGitBuild = { ->
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
try {
|
|
||||||
def stdout = new ByteArrayOutputStream()
|
|
||||||
exec {
|
|
||||||
commandLine 'git', 'describe', '--always'
|
|
||||||
standardOutput = stdout
|
|
||||||
}
|
|
||||||
String commitObject = stdout.toString().trim()
|
|
||||||
stringBuilder.append(commitObject)
|
|
||||||
} catch (ignored) {
|
|
||||||
stringBuilder.append('NoGitSystemAvailable')
|
|
||||||
}
|
|
||||||
return stringBuilder.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
def generateDate = { ->
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append((new Date()).format('yyyy.MM.dd-HH:mm'))
|
|
||||||
return stringBuilder.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.matching { it instanceof Test }.all {
|
|
||||||
testLogging.events = ["failed", "skipped", "started"]
|
|
||||||
testLogging.exceptionFormat = "full"
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 27
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
minSdkVersion 21
|
|
||||||
targetSdkVersion 25
|
|
||||||
multiDexEnabled true
|
|
||||||
versionCode 1500
|
|
||||||
// dev_version: 2.2.3-dev
|
|
||||||
version "medtronic-0.9.1-SNAPSHOT"
|
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
|
||||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
|
||||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
|
||||||
buildConfigField "String", "DEV_VERSION", '"2.2.3-dev"'
|
|
||||||
buildConfigField "String", "DEV_DATE", '"7.4.2019"'
|
|
||||||
buildConfigField "String", "DEV_CHECKIN", '"a076b00363067fd43c83cbbd91cc964fa6978ddd"'
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
||||||
// if you change minSdkVersion to less than 11, you need to change executeTask for wear
|
|
||||||
|
|
||||||
ndk {
|
|
||||||
moduleName "BleCommandUtil"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lintOptions {
|
|
||||||
// TODO remove once wear dependency com.google.android.gms:play-services-wearable:7.3.0
|
|
||||||
// has been upgraded (requiring significant code changes), which currently fails release
|
|
||||||
// build with a deprecation warning
|
|
||||||
// abortOnError false
|
|
||||||
// (disabled entirely to avoid reports on the error, which would still be displayed
|
|
||||||
// and it's easy to overlook that it's ignored)
|
|
||||||
checkReleaseBuilds false
|
|
||||||
disable 'MissingTranslation'
|
|
||||||
disable 'ExtraTranslation'
|
|
||||||
}
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
debug {
|
|
||||||
testCoverageEnabled(project.hasProperty('coverage'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
productFlavors {
|
|
||||||
flavorDimensions "standard"
|
|
||||||
full {
|
|
||||||
applicationId "info.nightscout.androidaps"
|
|
||||||
dimension "standard"
|
|
||||||
resValue "string", "app_name", "AndroidAPS"
|
|
||||||
versionName version
|
|
||||||
manifestPlaceholders = [
|
|
||||||
appIcon : "@mipmap/ic_launcher",
|
|
||||||
appIconRound: "@mipmap/ic_launcher_round"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
pumpcontrol {
|
|
||||||
applicationId "info.nightscout.aapspumpcontrol"
|
|
||||||
dimension "standard"
|
|
||||||
resValue "string", "app_name", "Pumpcontrol"
|
|
||||||
versionName version + "-pumpcontrol"
|
|
||||||
manifestPlaceholders = [
|
|
||||||
appIcon : "@mipmap/ic_pumpcontrol",
|
|
||||||
appIconRound: "@null"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
nsclient {
|
|
||||||
applicationId "info.nightscout.nsclient"
|
|
||||||
dimension "standard"
|
|
||||||
resValue "string", "app_name", "NSClient"
|
|
||||||
versionName version + "-nsclient"
|
|
||||||
manifestPlaceholders = [
|
|
||||||
appIcon : "@mipmap/ic_yellowowl",
|
|
||||||
appIconRound: "@null"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
nsclient2 {
|
|
||||||
applicationId "info.nightscout.nsclient2"
|
|
||||||
dimension "standard"
|
|
||||||
resValue "string", "app_name", "NSClient2"
|
|
||||||
versionName version + "-nsclient"
|
|
||||||
manifestPlaceholders = [
|
|
||||||
appIcon : "@mipmap/ic_yellowowl",
|
|
||||||
appIconRound: "@null"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
|
|
||||||
testOptions {
|
|
||||||
unitTests.returnDefaultValues = true
|
|
||||||
unitTests.includeAndroidResources = true
|
|
||||||
}
|
|
||||||
|
|
||||||
useLibrary "org.apache.http.legacy"
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
maven {
|
|
||||||
url "https://maven.google.com"
|
|
||||||
}
|
|
||||||
|
|
||||||
flatDir {
|
|
||||||
dirs 'libs'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
libs
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
wearApp project(':wear')
|
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
|
||||||
implementation "com.google.android.gms:play-services-wearable:16.0.1"
|
|
||||||
implementation 'com.google.firebase:firebase-core:16.0.8'
|
|
||||||
//implementation 'com.google.android.gms:play-services-auth:16.0.1'
|
|
||||||
//implementation 'com.google.firebase:firebase-auth:16.0.1'
|
|
||||||
implementation("com.crashlytics.sdk.android:crashlytics:2.9.9@aar") {
|
|
||||||
transitive = true;
|
|
||||||
}
|
|
||||||
libs "MilosKozak:danars-support-lib:master@zip"
|
|
||||||
|
|
||||||
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
|
|
||||||
implementation "com.android.support:support-v13:${supportLibraryVersion}"
|
|
||||||
implementation "com.android.support:support-v4:${supportLibraryVersion}"
|
|
||||||
implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
|
|
||||||
implementation "com.android.support:recyclerview-v7:${supportLibraryVersion}"
|
|
||||||
implementation "com.android.support:gridlayout-v7:${supportLibraryVersion}"
|
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
|
||||||
implementation "com.android.support:design:${supportLibraryVersion}"
|
|
||||||
implementation "com.android.support:percent:${supportLibraryVersion}"
|
|
||||||
implementation "com.wdullaer:materialdatetimepicker:2.3.0"
|
|
||||||
implementation "com.squareup:otto:1.3.7"
|
|
||||||
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
|
|
||||||
implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
|
|
||||||
implementation("com.github.tony19:logback-android-classic:1.1.1-6") {
|
|
||||||
exclude group: "com.google.android", module: "android"
|
|
||||||
}
|
|
||||||
implementation "org.apache.commons:commons-lang3:3.7"
|
|
||||||
implementation "org.slf4j:slf4j-api:1.7.21"
|
|
||||||
// Graphview cannot be upgraded
|
|
||||||
implementation "com.jjoe64:graphview:4.0.1"
|
|
||||||
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1"
|
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
|
||||||
|
|
||||||
implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar")
|
|
||||||
implementation 'com.madgag.spongycastle:core:1.58.0.0'
|
|
||||||
|
|
||||||
implementation("com.google.android:flexbox:0.3.0") {
|
|
||||||
exclude group: "com.android.support"
|
|
||||||
}
|
|
||||||
implementation("io.socket:socket.io-client:1.0.0") {
|
|
||||||
// excluding org.json which is provided by Android
|
|
||||||
exclude group: "org.json", module: "json"
|
|
||||||
}
|
|
||||||
implementation "com.google.code.gson:gson:2.8.2"
|
|
||||||
implementation "com.google.guava:guava:24.1-jre"
|
|
||||||
|
|
||||||
implementation "net.danlew:android.joda:2.9.9.1"
|
|
||||||
implementation "uk.com.robust-it:cloning:1.9.9"
|
|
||||||
|
|
||||||
implementation 'org.mozilla:rhino:1.7.7.2'
|
|
||||||
|
|
||||||
implementation "com.jakewharton:butterknife:${butterknifeVersion}"
|
|
||||||
annotationProcessor "com.jakewharton:butterknife-compiler:${butterknifeVersion}"
|
|
||||||
|
|
||||||
testImplementation "junit:junit:4.12"
|
|
||||||
testImplementation "org.json:json:20140107"
|
|
||||||
testImplementation "org.mockito:mockito-core:2.8.47"
|
|
||||||
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
|
||||||
testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}"
|
|
||||||
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
|
||||||
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
|
||||||
testImplementation "joda-time:joda-time:2.9.9"
|
|
||||||
testImplementation "com.google.truth:truth:0.39"
|
|
||||||
testImplementation 'org.robolectric:robolectric:3.8'
|
|
||||||
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
|
||||||
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
|
||||||
testImplementation "uk.org.lidalia:slf4j-test:1.2.0"
|
|
||||||
|
|
||||||
androidTestImplementation "org.mockito:mockito-core:2.8.47"
|
|
||||||
androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}"
|
|
||||||
androidTestImplementation "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}"
|
|
||||||
}
|
|
||||||
|
|
||||||
task unzip(type: Copy) {
|
|
||||||
def zipPath = configurations.libs.find { it.name.startsWith("danars") }
|
|
||||||
def zipFile = file(zipPath)
|
|
||||||
def outputDir = file("${buildDir}/unpacked/dist")
|
|
||||||
|
|
||||||
from zipTree(zipFile)
|
|
||||||
into outputDir
|
|
||||||
}
|
|
||||||
|
|
||||||
task copyLibs(dependsOn: unzip, type: Copy) {
|
|
||||||
def src = file("${buildDir}/unpacked/dist/danars-support-lib-master")
|
|
||||||
def target = file("src/main/jniLibs/")
|
|
||||||
|
|
||||||
from src
|
|
||||||
into target
|
|
||||||
}
|
|
||||||
|
|
||||||
task full_clean(type: Delete) {
|
|
||||||
delete file("src/main/jniLibs")
|
|
||||||
}
|
|
||||||
|
|
||||||
clean.dependsOn full_clean
|
|
||||||
preBuild.dependsOn copyLibs
|
|
1
app/build.gradle
Symbolic link
1
app/build.gradle
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/home/andy/Dropbox/workspaces/aaps/andy_AndroidAPS_Medtronic_Shared/app/build.gradle
|
|
@ -47,15 +47,11 @@
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".activities.PreferencesActivity" />
|
<activity android:name=".activities.PreferencesActivity" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".plugins.general.overview.Dialogs.BolusProgressHelperActivity"
|
android:name=".plugins.general.overview.dialogs.BolusProgressHelperActivity"
|
||||||
android:theme="@style/Theme.AppCompat.Translucent" />
|
android:theme="@style/Theme.AppCompat.Translucent" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".plugins.general.overview.Dialogs.ErrorHelperActivity"
|
android:name=".plugins.general.overview.dialogs.ErrorHelperActivity"
|
||||||
android:theme="@style/Theme.AppCompat.Translucent" />
|
android:theme="@style/Theme.AppCompat.Translucent" />
|
||||||
<activity
|
|
||||||
android:name=".plugins.general.overview.Dialogs.MessageHelperActivity"
|
|
||||||
android:theme="@style/Theme.AppCompat.Translucent" />
|
|
||||||
|
|
||||||
<activity android:name=".activities.AgreementActivity" />
|
<activity android:name=".activities.AgreementActivity" />
|
||||||
<activity android:name=".plugins.pump.danaR.activities.DanaRHistoryActivity" />
|
<activity android:name=".plugins.pump.danaR.activities.DanaRHistoryActivity" />
|
||||||
<activity android:name=".plugins.pump.danaR.activities.DanaRUserOptionsActivity" />
|
<activity android:name=".plugins.pump.danaR.activities.DanaRUserOptionsActivity" />
|
||||||
|
@ -80,7 +76,8 @@
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receivers.DataReceiver"
|
android:name=".receivers.DataReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true"
|
||||||
|
android:permission="android.permission.BROADCAST_SMS">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
||||||
<!-- Receive new SMS messages -->
|
<!-- Receive new SMS messages -->
|
||||||
|
@ -180,57 +177,57 @@
|
||||||
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
|
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
|
||||||
|
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_data" />
|
android:pathPrefix="/nightscout_watch_data"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_data_resend" />
|
android:pathPrefix="/nightscout_watch_data_resend"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_cancel_bolus" />
|
android:pathPrefix="/nightscout_watch_cancel_bolus"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_confirmactionstring" />
|
android:pathPrefix="/nightscout_watch_confirmactionstring"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_initiateactionstring" />
|
android:pathPrefix="/nightscout_watch_initiateactionstring"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/openwearsettings" />
|
android:pathPrefix="/openwearsettings"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/sendstatustowear" />
|
android:pathPrefix="/sendstatustowear"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/sendpreferencestowear" />
|
android:pathPrefix="/sendpreferencestowear"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_basal" />
|
android:pathPrefix="/nightscout_watch_basal"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_bolusprogress" />
|
android:pathPrefix="/nightscout_watch_bolusprogress"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_actionconfirmationrequest" />
|
android:pathPrefix="/nightscout_watch_actionconfirmationrequest"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_changeconfirmationrequest" />
|
android:pathPrefix="/nightscout_watch_changeconfirmationrequest"
|
||||||
|
android:scheme="wear" />
|
||||||
<data
|
<data
|
||||||
android:scheme="wear"
|
|
||||||
android:host="*"
|
android:host="*"
|
||||||
android:pathPrefix="/nightscout_watch_cancelnotificationrequest" />
|
android:pathPrefix="/nightscout_watch_cancelnotificationrequest"
|
||||||
|
android:scheme="wear" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
<service
|
<service
|
||||||
|
@ -262,38 +259,39 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.SingleFragmentActivity"
|
android:name=".activities.SingleFragmentActivity"
|
||||||
android:theme="@style/AppTheme" />
|
android:theme="@style/AppTheme" />
|
||||||
<activity android:name=".plugins.general.maintenance.activities.LogSettingActivity"></activity>
|
<activity android:name=".plugins.general.maintenance.activities.LogSettingActivity" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".plugins.pump.insight.activities.InsightPairingActivity"
|
android:name=".plugins.pump.insight.activities.InsightPairingActivity"
|
||||||
android:theme="@style/AppTheme"
|
android:label="@string/insight_pairing"
|
||||||
android:label="@string/insight_pairing" />
|
android:theme="@style/AppTheme" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".plugins.pump.insight.activities.InsightAlertActivity"
|
android:name=".plugins.pump.insight.activities.InsightAlertActivity"
|
||||||
android:label="@string/pump_alert"
|
android:label="@string/pump_alert"
|
||||||
android:theme="@style/InsightAlertDialog" />
|
android:theme="@style/InsightAlertDialog" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".plugins.pump.insight.activities.InsightPairingInformationActivity"
|
android:name=".plugins.pump.insight.activities.InsightPairingInformationActivity"
|
||||||
android:theme="@style/AppTheme"
|
android:label="@string/pairing_information"
|
||||||
android:label="@string/pairing_information" />
|
android:theme="@style/AppTheme" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Medtronic service and activities -->
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.pump.medtronic.service.RileyLinkMedtronicService"
|
android:name=".plugins.pump.medtronic.service.RileyLinkMedtronicService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
<activity
|
||||||
|
android:name=".plugins.general.overview.dialogs.MessageHelperActivity"
|
||||||
|
android:theme="@style/Theme.AppCompat.Translucent" />
|
||||||
<activity android:name=".plugins.pump.common.dialog.RileyLinkBLEScanActivity">
|
<activity android:name=".plugins.pump.common.dialog.RileyLinkBLEScanActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
|
<action android:name="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity"
|
android:name=".plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity"
|
||||||
android:label="@string/title_activity_rileylink_settings"
|
android:label="@string/title_activity_rileylink_settings"
|
||||||
android:theme="@style/Theme.AppCompat.NoTitle" />
|
android:theme="@style/Theme.AppCompat.NoTitle" />
|
||||||
|
|
||||||
<activity android:name=".plugins.pump.medtronic.dialog.MedtronicHistoryActivity" />
|
<activity android:name=".plugins.pump.medtronic.dialog.MedtronicHistoryActivity" />
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
|
@ -78,9 +78,9 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
MainApp.bus().post(new EventRefreshGui());
|
MainApp.bus().post(new EventRefreshGui());
|
||||||
}
|
}
|
||||||
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens))
|
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens))
|
||||||
&& SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
|
&& SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
|
||||||
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity),
|
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity),
|
||||||
MainApp.gs(R.string.sensitivity_warning), null);
|
MainApp.gs(R.string.sensitivity_warning), null);
|
||||||
}
|
}
|
||||||
updatePrefSummary(myPreferenceFragment.getPreference(key));
|
updatePrefSummary(myPreferenceFragment.getPreference(key));
|
||||||
}
|
}
|
||||||
|
@ -88,20 +88,20 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
|
|
||||||
private static void updatePrefSummary(Preference pref) {
|
private static void updatePrefSummary(Preference pref) {
|
||||||
if (pref instanceof ListPreference) {
|
if (pref instanceof ListPreference) {
|
||||||
ListPreference listPref = (ListPreference)pref;
|
ListPreference listPref = (ListPreference) pref;
|
||||||
pref.setSummary(listPref.getEntry());
|
pref.setSummary(listPref.getEntry());
|
||||||
}
|
}
|
||||||
if (pref instanceof EditTextPreference) {
|
if (pref instanceof EditTextPreference) {
|
||||||
EditTextPreference editTextPref = (EditTextPreference)pref;
|
EditTextPreference editTextPref = (EditTextPreference) pref;
|
||||||
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
|
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
|
||||||
pref.setSummary("******");
|
pref.setSummary("******");
|
||||||
} else if (pref.getKey().equals(MainApp.gs(R.string.key_danars_name))) {
|
} else if (pref.getKey().equals(MainApp.gs(R.string.key_danars_name))) {
|
||||||
pref.setSummary(SP.getString(R.string.key_danars_name, ""));
|
pref.setSummary(SP.getString(R.string.key_danars_name, ""));
|
||||||
} else if (editTextPref.getText() != null) {
|
} else if (editTextPref.getText() != null) {
|
||||||
((EditTextPreference)pref).setDialogMessage(editTextPref.getDialogMessage());
|
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
|
||||||
pref.setSummary(editTextPref.getText());
|
pref.setSummary(editTextPref.getText());
|
||||||
} else if (pref.getKey().contains("smscommunicator_allowednumbers")
|
} else if (pref.getKey().contains("smscommunicator_allowednumbers")
|
||||||
&& TextUtils.isEmpty(editTextPref.getText().trim())) {
|
&& TextUtils.isEmpty(editTextPref.getText().trim())) {
|
||||||
pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
|
pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
|
|
||||||
public static void initSummary(Preference p) {
|
public static void initSummary(Preference p) {
|
||||||
if (p instanceof PreferenceGroup) {
|
if (p instanceof PreferenceGroup) {
|
||||||
PreferenceGroup pGrp = (PreferenceGroup)p;
|
PreferenceGroup pGrp = (PreferenceGroup) p;
|
||||||
for (int i = 0; i < pGrp.getPreferenceCount(); i++) {
|
for (int i = 0; i < pGrp.getPreferenceCount(); i++) {
|
||||||
initSummary(pGrp.getPreference(i));
|
initSummary(pGrp.getPreference(i));
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
|
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), PluginType.SENSITIVITY);
|
addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), PluginType.SENSITIVITY);
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(),
|
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(),
|
||||||
PluginType.SENSITIVITY);
|
PluginType.SENSITIVITY);
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginType.SENSITIVITY);
|
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginType.SENSITIVITY);
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityOref1Plugin.getPlugin(), PluginType.SENSITIVITY);
|
addPreferencesFromResourceIfEnabled(SensitivityOref1Plugin.getPlugin(), PluginType.SENSITIVITY);
|
||||||
|
|
||||||
|
@ -183,9 +183,9 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), PluginType.PUMP);
|
||||||
|
|
||||||
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||||
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||||
|| DanaRv2Plugin.getPlugin().isEnabled(PluginType.PROFILE)
|
|| DanaRv2Plugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||||
|| DanaRSPlugin.getPlugin().isEnabled(PluginType.PROFILE)) {
|
|| DanaRSPlugin.getPlugin().isEnabled(PluginType.PROFILE)) {
|
||||||
addPreferencesFromResource(R.xml.pref_danarprofile);
|
addPreferencesFromResource(R.xml.pref_danarprofile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,16 +207,16 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.NSCLIENT) {
|
if (Config.NSCLIENT) {
|
||||||
PreferenceScreen scrnAdvancedSettings = (PreferenceScreen)findPreference(getString(R.string.key_advancedsettings));
|
PreferenceScreen scrnAdvancedSettings = (PreferenceScreen) findPreference(getString(R.string.key_advancedsettings));
|
||||||
if (scrnAdvancedSettings != null) {
|
if (scrnAdvancedSettings != null) {
|
||||||
scrnAdvancedSettings
|
scrnAdvancedSettings
|
||||||
.removePreference(getPreference(getString(R.string.key_statuslights_res_warning)));
|
.removePreference(getPreference(getString(R.string.key_statuslights_res_warning)));
|
||||||
scrnAdvancedSettings
|
scrnAdvancedSettings
|
||||||
.removePreference(getPreference(getString(R.string.key_statuslights_res_critical)));
|
.removePreference(getPreference(getString(R.string.key_statuslights_res_critical)));
|
||||||
scrnAdvancedSettings
|
scrnAdvancedSettings
|
||||||
.removePreference(getPreference(getString(R.string.key_statuslights_bat_warning)));
|
.removePreference(getPreference(getString(R.string.key_statuslights_bat_warning)));
|
||||||
scrnAdvancedSettings
|
scrnAdvancedSettings
|
||||||
.removePreference(getPreference(getString(R.string.key_statuslights_bat_critical)));
|
.removePreference(getPreference(getString(R.string.key_statuslights_bat_critical)));
|
||||||
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_show_statuslights)));
|
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_show_statuslights)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
package info.nightscout.androidaps.db;
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.DatabaseUtils;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
||||||
|
import com.j256.ormlite.dao.CloseableIterator;
|
||||||
|
import com.j256.ormlite.dao.Dao;
|
||||||
|
import com.j256.ormlite.stmt.PreparedQuery;
|
||||||
|
import com.j256.ormlite.stmt.QueryBuilder;
|
||||||
|
import com.j256.ormlite.stmt.Where;
|
||||||
|
import com.j256.ormlite.support.ConnectionSource;
|
||||||
|
import com.j256.ormlite.table.TableUtils;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
@ -11,25 +31,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.DatabaseUtils;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
|
||||||
import com.j256.ormlite.dao.CloseableIterator;
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
|
||||||
import com.j256.ormlite.stmt.PreparedQuery;
|
|
||||||
import com.j256.ormlite.stmt.QueryBuilder;
|
|
||||||
import com.j256.ormlite.stmt.Where;
|
|
||||||
import com.j256.ormlite.support.ConnectionSource;
|
|
||||||
import com.j256.ormlite.table.TableUtils;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||||
|
@ -107,7 +108,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static ScheduledFuture<?> scheduledCareportalEventPost = null;
|
private static ScheduledFuture<?> scheduledCareportalEventPost = null;
|
||||||
|
|
||||||
private static final ScheduledExecutorService profileSwitchEventWorker = Executors
|
private static final ScheduledExecutorService profileSwitchEventWorker = Executors
|
||||||
.newSingleThreadScheduledExecutor();
|
.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledProfileSwitchEventPost = null;
|
private static ScheduledFuture<?> scheduledProfileSwitchEventPost = null;
|
||||||
|
|
||||||
private int oldVersion = 0;
|
private int oldVersion = 0;
|
||||||
|
@ -437,6 +438,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventNewBg");
|
log.debug("Firing EventNewBg");
|
||||||
|
Log.d("DatabaseHelper", "WR: Firing EventNewBg");
|
||||||
MainApp.bus().post(new EventNewBG(bgReading));
|
MainApp.bus().post(new EventNewBG(bgReading));
|
||||||
scheduledBgPost = null;
|
scheduledBgPost = null;
|
||||||
}
|
}
|
||||||
|
@ -707,7 +709,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTempTargets().create(old);
|
getDaoTempTargets().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPTARGET: Updating record by date from: "
|
log.debug("TEMPTARGET: Updating record by date from: "
|
||||||
+ Source.getString(tempTarget.source) + " " + old.toString());
|
+ Source.getString(tempTarget.source) + " " + old.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -728,7 +730,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTempTargets().create(old);
|
getDaoTempTargets().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPTARGET: Updating record by _id from: "
|
log.debug("TEMPTARGET: Updating record by _id from: "
|
||||||
+ Source.getString(tempTarget.source) + " " + old.toString());
|
+ Source.getString(tempTarget.source) + " " + old.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -737,7 +739,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTempTargets().create(tempTarget);
|
getDaoTempTargets().create(tempTarget);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " "
|
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " "
|
||||||
+ tempTarget.toString());
|
+ tempTarget.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -745,7 +747,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTempTargets().create(tempTarget);
|
getDaoTempTargets().create(tempTarget);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " "
|
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " "
|
||||||
+ tempTarget.toString());
|
+ tempTarget.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -805,12 +807,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
|
public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
|
||||||
try {
|
try {
|
||||||
String units = JsonHelper.safeGetString(trJson, "units", Constants.MGDL);
|
String units = JsonHelper.safeGetString(trJson, "units", Constants.MGDL);
|
||||||
TempTarget tempTarget = new TempTarget().date(trJson.getLong("mills"))
|
TempTarget tempTarget = new TempTarget().date(trJson.getLong("mills")).duration(trJson.getInt("duration"))
|
||||||
.duration(JsonHelper.safeGetInt(trJson, "duration"))
|
.low(Profile.toMgdl(trJson.getDouble("targetBottom"), units))
|
||||||
.low(Profile.toMgdl(trJson.getDouble("targetBottom"), units))
|
.high(Profile.toMgdl(trJson.getDouble("targetTop"), units))
|
||||||
.high(Profile.toMgdl(trJson.getDouble("targetTop"), units))
|
.reason(JsonHelper.safeGetString(trJson, "reason", ""))._id(trJson.getString("_id"))
|
||||||
.reason(JsonHelper.safeGetString(trJson, "reason", ""))._id(trJson.getString("_id"))
|
.source(Source.NIGHTSCOUT);
|
||||||
.source(Source.NIGHTSCOUT);
|
|
||||||
createOrUpdate(tempTarget);
|
createOrUpdate(tempTarget);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception: " + trJson.toString(), e);
|
log.error("Unhandled exception: " + trJson.toString(), e);
|
||||||
|
@ -928,13 +929,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
// do nothing, pump history record cannot be changed
|
// do nothing, pump history record cannot be changed
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " "
|
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " "
|
||||||
+ tempBasal.toString());
|
+ tempBasal.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
getDaoTemporaryBasal().create(tempBasal);
|
getDaoTemporaryBasal().create(tempBasal);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " "
|
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " "
|
||||||
+ tempBasal.toString());
|
+ tempBasal.toString());
|
||||||
updateEarliestDataChange(tempBasal.date);
|
updateEarliestDataChange(tempBasal.date);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -953,7 +954,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTemporaryBasal().create(old);
|
getDaoTemporaryBasal().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source)
|
log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source)
|
||||||
+ " " + old.toString());
|
+ " " + old.toString());
|
||||||
updateEarliestDataChange(oldDate);
|
updateEarliestDataChange(oldDate);
|
||||||
updateEarliestDataChange(old.date);
|
updateEarliestDataChange(old.date);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
|
@ -977,7 +978,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTemporaryBasal().create(old);
|
getDaoTemporaryBasal().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPBASAL: Updating record by _id from: "
|
log.debug("TEMPBASAL: Updating record by _id from: "
|
||||||
+ Source.getString(tempBasal.source) + " " + old.toString());
|
+ Source.getString(tempBasal.source) + " " + old.toString());
|
||||||
updateEarliestDataChange(oldDate);
|
updateEarliestDataChange(oldDate);
|
||||||
updateEarliestDataChange(old.date);
|
updateEarliestDataChange(old.date);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
|
@ -988,7 +989,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTemporaryBasal().create(tempBasal);
|
getDaoTemporaryBasal().create(tempBasal);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " "
|
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " "
|
||||||
+ tempBasal.toString());
|
+ tempBasal.toString());
|
||||||
updateEarliestDataChange(tempBasal.date);
|
updateEarliestDataChange(tempBasal.date);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -997,7 +998,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTemporaryBasal().create(tempBasal);
|
getDaoTemporaryBasal().create(tempBasal);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " "
|
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " "
|
||||||
+ tempBasal.toString());
|
+ tempBasal.toString());
|
||||||
updateEarliestDataChange(tempBasal.date);
|
updateEarliestDataChange(tempBasal.date);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1082,9 +1083,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
try {
|
try {
|
||||||
if (trJson.has("originalExtendedAmount")) { // extended bolus uploaded as temp basal
|
if (trJson.has("originalExtendedAmount")) { // extended bolus uploaded as temp basal
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus().source(Source.NIGHTSCOUT)
|
ExtendedBolus extendedBolus = new ExtendedBolus().source(Source.NIGHTSCOUT)
|
||||||
.date(trJson.getLong("mills")).pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0)
|
.date(trJson.getLong("mills")).pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0)
|
||||||
.durationInMinutes(trJson.getInt("duration")).insulin(trJson.getDouble("originalExtendedAmount"))
|
.durationInMinutes(trJson.getInt("duration")).insulin(trJson.getDouble("originalExtendedAmount"))
|
||||||
._id(trJson.getString("_id"));
|
._id(trJson.getString("_id"));
|
||||||
// if faking found in NS, adapt AAPS to use it too
|
// if faking found in NS, adapt AAPS to use it too
|
||||||
if (!VirtualPumpPlugin.getPlugin().getFakingStatus()) {
|
if (!VirtualPumpPlugin.getPlugin().getFakingStatus()) {
|
||||||
VirtualPumpPlugin.getPlugin().setFakingStatus(true);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(true);
|
||||||
|
@ -1109,7 +1110,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
createOrUpdate(extendedBolus);
|
createOrUpdate(extendedBolus);
|
||||||
} else {
|
} else {
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal().date(trJson.getLong("mills")).source(Source.NIGHTSCOUT)
|
TemporaryBasal tempBasal = new TemporaryBasal().date(trJson.getLong("mills")).source(Source.NIGHTSCOUT)
|
||||||
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0);
|
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0);
|
||||||
if (trJson.has("duration")) {
|
if (trJson.has("duration")) {
|
||||||
tempBasal.durationInMinutes = trJson.getInt("duration");
|
tempBasal.durationInMinutes = trJson.getInt("duration");
|
||||||
}
|
}
|
||||||
|
@ -1169,7 +1170,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
try {
|
try {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: createOrUpdate: " + Source.getString(extendedBolus.source) + " "
|
log.debug("EXTENDEDBOLUS: createOrUpdate: " + Source.getString(extendedBolus.source) + " "
|
||||||
+ extendedBolus.log());
|
+ extendedBolus.log());
|
||||||
|
|
||||||
ExtendedBolus old;
|
ExtendedBolus old;
|
||||||
extendedBolus.date = roundDateToSec(extendedBolus.date);
|
extendedBolus.date = roundDateToSec(extendedBolus.date);
|
||||||
|
@ -1195,7 +1196,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " "
|
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " "
|
||||||
+ extendedBolus.log());
|
+ extendedBolus.log());
|
||||||
updateEarliestDataChange(extendedBolus.date);
|
updateEarliestDataChange(extendedBolus.date);
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1210,7 +1211,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoExtendedBolus().create(old);
|
getDaoExtendedBolus().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: Updating record by date from: "
|
log.debug("EXTENDEDBOLUS: Updating record by date from: "
|
||||||
+ Source.getString(extendedBolus.source) + " " + old.log());
|
+ Source.getString(extendedBolus.source) + " " + old.log());
|
||||||
updateEarliestDataChange(oldDate);
|
updateEarliestDataChange(oldDate);
|
||||||
updateEarliestDataChange(old.date);
|
updateEarliestDataChange(old.date);
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
|
@ -1234,7 +1235,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoExtendedBolus().create(old);
|
getDaoExtendedBolus().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: Updating record by _id from: "
|
log.debug("EXTENDEDBOLUS: Updating record by _id from: "
|
||||||
+ Source.getString(extendedBolus.source) + " " + old.log());
|
+ Source.getString(extendedBolus.source) + " " + old.log());
|
||||||
updateEarliestDataChange(oldDate);
|
updateEarliestDataChange(oldDate);
|
||||||
updateEarliestDataChange(old.date);
|
updateEarliestDataChange(old.date);
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
|
@ -1245,7 +1246,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoExtendedBolus().create(extendedBolus);
|
getDaoExtendedBolus().create(extendedBolus);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " "
|
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " "
|
||||||
+ extendedBolus.log());
|
+ extendedBolus.log());
|
||||||
updateEarliestDataChange(extendedBolus.date);
|
updateEarliestDataChange(extendedBolus.date);
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1254,7 +1255,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoExtendedBolus().create(extendedBolus);
|
getDaoExtendedBolus().create(extendedBolus);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " "
|
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " "
|
||||||
+ extendedBolus.log());
|
+ extendedBolus.log());
|
||||||
updateEarliestDataChange(extendedBolus.date);
|
updateEarliestDataChange(extendedBolus.date);
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1632,12 +1633,12 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
if (!old.isEqual(profileSwitch)) {
|
if (!old.isEqual(profileSwitch)) {
|
||||||
profileSwitch.source = old.source;
|
profileSwitch.source = old.source;
|
||||||
profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP
|
profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP
|
||||||
// extension
|
// extension
|
||||||
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
|
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("PROFILESWITCH: Updating record by date from: "
|
log.debug("PROFILESWITCH: Updating record by date from: "
|
||||||
+ Source.getString(profileSwitch.source) + " " + old.toString());
|
+ Source.getString(profileSwitch.source) + " " + old.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1658,7 +1659,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoProfileSwitch().create(old);
|
getDaoProfileSwitch().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("PROFILESWITCH: Updating record by _id from: "
|
log.debug("PROFILESWITCH: Updating record by _id from: "
|
||||||
+ Source.getString(profileSwitch.source) + " " + old.toString());
|
+ Source.getString(profileSwitch.source) + " " + old.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1669,7 +1670,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " "
|
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " "
|
||||||
+ profileSwitch.toString());
|
+ profileSwitch.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1677,7 +1678,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " "
|
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " "
|
||||||
+ profileSwitch.toString());
|
+ profileSwitch.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1849,8 +1850,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public InsightBolusID getInsightBolusID(String pumpSerial, int bolusID, long timestamp) {
|
public InsightBolusID getInsightBolusID(String pumpSerial, int bolusID, long timestamp) {
|
||||||
try {
|
try {
|
||||||
return getDaoInsightBolusID().queryBuilder().where().eq("pumpSerial", pumpSerial).and()
|
return getDaoInsightBolusID().queryBuilder().where().eq("pumpSerial", pumpSerial).and()
|
||||||
.eq("bolusID", bolusID).and().between("timestamp", timestamp - 259200000, timestamp + 259200000)
|
.eq("bolusID", bolusID).and().between("timestamp", timestamp - 259200000, timestamp + 259200000)
|
||||||
.queryForFirst();
|
.queryForFirst();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -1870,8 +1871,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public InsightPumpID getPumpStoppedEvent(String pumpSerial, long before) {
|
public InsightPumpID getPumpStoppedEvent(String pumpSerial, long before) {
|
||||||
try {
|
try {
|
||||||
return getDaoInsightPumpID().queryBuilder().orderBy("timestamp", false).where()
|
return getDaoInsightPumpID().queryBuilder().orderBy("timestamp", false).where()
|
||||||
.eq("pumpSerial", pumpSerial).and().in("eventType", "PumpStopped", "PumpPaused").and()
|
.eq("pumpSerial", pumpSerial).and().in("eventType", "PumpStopped", "PumpPaused").and()
|
||||||
.lt("timestamp", before).queryForFirst();
|
.lt("timestamp", before).queryForFirst();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package info.nightscout.androidaps.db;
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import java.util.Objects;
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
|
||||||
|
@ -13,9 +14,9 @@ import info.nightscout.androidaps.logging.L;
|
||||||
* Created by mike on 20.09.2017.
|
* Created by mike on 20.09.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TDDS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TDDS)
|
||||||
public class TDD {
|
public class TDD {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(L.DATABASE);
|
private static Logger log = LoggerFactory.getLogger(L.DATABASE);
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
|
@ -31,30 +32,17 @@ public class TDD {
|
||||||
public double total;
|
public double total;
|
||||||
|
|
||||||
|
|
||||||
public double getTotal() {
|
public double getTotal(){
|
||||||
return (total > 0d) ? total : (bolus + basal);
|
return (total > 0d) ? total:(bolus+basal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TDD() {
|
public TDD() { }
|
||||||
}
|
|
||||||
|
|
||||||
|
public TDD(long date, double bolus, double basal, double total){
|
||||||
public TDD(long date, double bolus, double basal, double total) {
|
|
||||||
this.date = date;
|
this.date = date;
|
||||||
this.bolus = bolus;
|
this.bolus = bolus;
|
||||||
this.basal = basal;
|
this.basal = basal;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return MoreObjects.toStringHelper(this) //
|
|
||||||
.add("date", date) //
|
|
||||||
.add("bolus", bolus) //
|
|
||||||
.add("basal", basal) //
|
|
||||||
.add("total", total) //
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,16 +3,16 @@ package info.nightscout.androidaps.interfaces;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.Intervals;
|
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileIntervals;
|
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
|
import info.nightscout.androidaps.data.ProfileIntervals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 14.06.2016.
|
* Created by mike on 14.06.2016.
|
||||||
|
@ -20,94 +20,48 @@ import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
public interface TreatmentsInterface {
|
public interface TreatmentsInterface {
|
||||||
|
|
||||||
void updateTotalIOBTreatments();
|
void updateTotalIOBTreatments();
|
||||||
|
|
||||||
|
|
||||||
void updateTotalIOBTempBasals();
|
void updateTotalIOBTempBasals();
|
||||||
|
|
||||||
|
|
||||||
IobTotal getLastCalculationTreatments();
|
IobTotal getLastCalculationTreatments();
|
||||||
|
|
||||||
|
|
||||||
IobTotal getCalculationToTimeTreatments(long time);
|
IobTotal getCalculationToTimeTreatments(long time);
|
||||||
|
|
||||||
|
|
||||||
IobTotal getLastCalculationTempBasals();
|
IobTotal getLastCalculationTempBasals();
|
||||||
|
|
||||||
|
|
||||||
IobTotal getCalculationToTimeTempBasals(long time, Profile profile);
|
IobTotal getCalculationToTimeTempBasals(long time, Profile profile);
|
||||||
|
|
||||||
|
|
||||||
MealData getMealData();
|
MealData getMealData();
|
||||||
|
|
||||||
|
|
||||||
List<Treatment> getTreatmentsFromHistory();
|
List<Treatment> getTreatmentsFromHistory();
|
||||||
|
|
||||||
|
|
||||||
List<Treatment> getTreatments5MinBackFromHistory(long time);
|
List<Treatment> getTreatments5MinBackFromHistory(long time);
|
||||||
|
List<Treatment> getTreatmentsFromHistoryXMinutesAgo(int minutesAgo);
|
||||||
|
|
||||||
long getLastBolusTime();
|
long getLastBolusTime();
|
||||||
|
|
||||||
|
|
||||||
// real basals (not faked by extended bolus)
|
// real basals (not faked by extended bolus)
|
||||||
boolean isInHistoryRealTempBasalInProgress();
|
boolean isInHistoryRealTempBasalInProgress();
|
||||||
|
|
||||||
|
|
||||||
TemporaryBasal getRealTempBasalFromHistory(long time);
|
TemporaryBasal getRealTempBasalFromHistory(long time);
|
||||||
|
|
||||||
|
|
||||||
boolean addToHistoryTempBasal(TemporaryBasal tempBasal);
|
boolean addToHistoryTempBasal(TemporaryBasal tempBasal);
|
||||||
|
|
||||||
|
|
||||||
// basal that can be faked by extended boluses
|
// basal that can be faked by extended boluses
|
||||||
boolean isTempBasalInProgress();
|
boolean isTempBasalInProgress();
|
||||||
|
|
||||||
|
|
||||||
TemporaryBasal getTempBasalFromHistory(long time);
|
TemporaryBasal getTempBasalFromHistory(long time);
|
||||||
|
|
||||||
|
|
||||||
Intervals<TemporaryBasal> getTemporaryBasalsFromHistory();
|
Intervals<TemporaryBasal> getTemporaryBasalsFromHistory();
|
||||||
|
|
||||||
|
|
||||||
boolean isInHistoryExtendedBoluslInProgress();
|
boolean isInHistoryExtendedBoluslInProgress();
|
||||||
|
|
||||||
|
|
||||||
ExtendedBolus getExtendedBolusFromHistory(long time);
|
ExtendedBolus getExtendedBolusFromHistory(long time);
|
||||||
|
|
||||||
|
|
||||||
Intervals<ExtendedBolus> getExtendedBolusesFromHistory();
|
Intervals<ExtendedBolus> getExtendedBolusesFromHistory();
|
||||||
|
|
||||||
|
|
||||||
boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus);
|
boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus);
|
||||||
|
|
||||||
|
|
||||||
boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate);
|
boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate);
|
||||||
|
|
||||||
|
|
||||||
TempTarget getTempTargetFromHistory();
|
TempTarget getTempTargetFromHistory();
|
||||||
|
|
||||||
|
|
||||||
TempTarget getTempTargetFromHistory(long time);
|
TempTarget getTempTargetFromHistory(long time);
|
||||||
|
|
||||||
|
|
||||||
Intervals<TempTarget> getTempTargetsFromHistory();
|
Intervals<TempTarget> getTempTargetsFromHistory();
|
||||||
|
|
||||||
|
|
||||||
void addToHistoryTempTarget(TempTarget tempTarget);
|
void addToHistoryTempTarget(TempTarget tempTarget);
|
||||||
|
|
||||||
|
|
||||||
ProfileSwitch getProfileSwitchFromHistory(long time);
|
ProfileSwitch getProfileSwitchFromHistory(long time);
|
||||||
|
|
||||||
|
|
||||||
ProfileIntervals<ProfileSwitch> getProfileSwitchesFromHistory();
|
ProfileIntervals<ProfileSwitch> getProfileSwitchesFromHistory();
|
||||||
|
|
||||||
|
|
||||||
void addToHistoryProfileSwitch(ProfileSwitch profileSwitch);
|
void addToHistoryProfileSwitch(ProfileSwitch profileSwitch);
|
||||||
|
|
||||||
|
|
||||||
long oldestDataAvailable();
|
long oldestDataAvailable();
|
||||||
|
|
||||||
|
}
|
||||||
List<Treatment> getTreatmentsFromHistoryXMinutesAgo(int minutesAgo);
|
|
||||||
|
|
||||||
}
|
|
|
@ -23,7 +23,7 @@ import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.general.actions;
|
package info.nightscout.androidaps.plugins.general.actions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -44,8 +40,8 @@ import info.nightscout.androidaps.plugins.general.actions.dialogs.FillDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.dialogs.NewExtendedBolusDialog;
|
import info.nightscout.androidaps.plugins.general.actions.dialogs.NewExtendedBolusDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.dialogs.NewTempBasalDialog;
|
import info.nightscout.androidaps.plugins.general.actions.dialogs.NewTempBasalDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
|
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SingleClickButton;
|
import info.nightscout.androidaps.utils.SingleClickButton;
|
||||||
|
@ -58,7 +54,6 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
|
|
||||||
static ActionsPlugin actionsPlugin = new ActionsPlugin();
|
static ActionsPlugin actionsPlugin = new ActionsPlugin();
|
||||||
|
|
||||||
|
|
||||||
static public ActionsPlugin getPlugin() {
|
static public ActionsPlugin getPlugin() {
|
||||||
return actionsPlugin;
|
return actionsPlugin;
|
||||||
}
|
}
|
||||||
|
@ -77,24 +72,24 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
private Map<String, CustomAction> pumpCustomActions = new HashMap<>();
|
private Map<String, CustomAction> pumpCustomActions = new HashMap<>();
|
||||||
private List<SingleClickButton> pumpCustomButtons = new ArrayList<>();
|
private List<SingleClickButton> pumpCustomButtons = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
public ActionsFragment() {
|
public ActionsFragment() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
try {
|
try {
|
||||||
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
||||||
|
|
||||||
profileSwitch = (SingleClickButton)view.findViewById(R.id.actions_profileswitch);
|
profileSwitch = (SingleClickButton) view.findViewById(R.id.actions_profileswitch);
|
||||||
tempTarget = (SingleClickButton)view.findViewById(R.id.actions_temptarget);
|
tempTarget = (SingleClickButton) view.findViewById(R.id.actions_temptarget);
|
||||||
extendedBolus = (SingleClickButton)view.findViewById(R.id.actions_extendedbolus);
|
extendedBolus = (SingleClickButton) view.findViewById(R.id.actions_extendedbolus);
|
||||||
extendedBolusCancel = (SingleClickButton)view.findViewById(R.id.actions_extendedbolus_cancel);
|
extendedBolusCancel = (SingleClickButton) view.findViewById(R.id.actions_extendedbolus_cancel);
|
||||||
tempBasal = (SingleClickButton)view.findViewById(R.id.actions_settempbasal);
|
tempBasal = (SingleClickButton) view.findViewById(R.id.actions_settempbasal);
|
||||||
tempBasalCancel = (SingleClickButton)view.findViewById(R.id.actions_canceltempbasal);
|
tempBasalCancel = (SingleClickButton) view.findViewById(R.id.actions_canceltempbasal);
|
||||||
fill = (SingleClickButton)view.findViewById(R.id.actions_fill);
|
fill = (SingleClickButton) view.findViewById(R.id.actions_fill);
|
||||||
tddStats = view.findViewById(R.id.actions_tddstats);
|
tddStats = view.findViewById(R.id.actions_tddstats);
|
||||||
history = view.findViewById(R.id.actions_historybrowser);
|
history = view.findViewById(R.id.actions_historybrowser);
|
||||||
|
|
||||||
|
@ -119,47 +114,39 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventInitializationChanged ev) {
|
public void onStatusEvent(final EventInitializationChanged ev) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
public void onStatusEvent(final EventRefreshOverview ev) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
public void onStatusEvent(final EventTempBasalChange ev) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventCustomActionsChanged ev) {
|
public void onStatusEvent(final EventCustomActionsChanged ev) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateGUI() {
|
protected void updateGUI() {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null
|
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null) {
|
||||||
&& ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null) {
|
|
||||||
profileSwitch.setVisibility(View.VISIBLE);
|
profileSwitch.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
profileSwitch.setVisibility(View.GONE);
|
profileSwitch.setVisibility(View.GONE);
|
||||||
|
@ -177,37 +164,34 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
|
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
final boolean basalprofileEnabled = MainApp.isEngineeringModeOrRelease()
|
final boolean basalprofileEnabled = MainApp.isEngineeringModeOrRelease()
|
||||||
&& pump.getPumpDescription().isSetBasalProfileCapable;
|
&& pump.getPumpDescription().isSetBasalProfileCapable;
|
||||||
|
|
||||||
if (!basalprofileEnabled || !pump.isInitialized() || pump.isSuspended())
|
if (!basalprofileEnabled || !pump.isInitialized() || pump.isSuspended())
|
||||||
profileSwitch.setVisibility(View.GONE);
|
profileSwitch.setVisibility(View.GONE);
|
||||||
else
|
else
|
||||||
profileSwitch.setVisibility(View.VISIBLE);
|
profileSwitch.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (!pump.getPumpDescription().isExtendedBolusCapable || !pump.isInitialized()
|
if (!pump.getPumpDescription().isExtendedBolusCapable || !pump.isInitialized() || pump.isSuspended() || pump.isFakingTempsByExtendedBoluses()) {
|
||||||
|| pump.isSuspended() || pump.isFakingTempsByExtendedBoluses()) {
|
|
||||||
extendedBolus.setVisibility(View.GONE);
|
extendedBolus.setVisibility(View.GONE);
|
||||||
extendedBolusCancel.setVisibility(View.GONE);
|
extendedBolusCancel.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(
|
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
System.currentTimeMillis());
|
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
extendedBolus.setVisibility(View.GONE);
|
extendedBolus.setVisibility(View.GONE);
|
||||||
extendedBolusCancel.setVisibility(View.VISIBLE);
|
extendedBolusCancel.setVisibility(View.VISIBLE);
|
||||||
extendedBolusCancel.setText(MainApp.gs(R.string.cancel) + " "
|
extendedBolusCancel.setText(MainApp.gs(R.string.cancel) + " " + activeExtendedBolus.toString());
|
||||||
+ activeExtendedBolus.toString());
|
|
||||||
} else {
|
} else {
|
||||||
extendedBolus.setVisibility(View.VISIBLE);
|
extendedBolus.setVisibility(View.VISIBLE);
|
||||||
extendedBolusCancel.setVisibility(View.GONE);
|
extendedBolusCancel.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!pump.getPumpDescription().isTempBasalCapable || !pump.isInitialized() || pump.isSuspended()) {
|
if (!pump.getPumpDescription().isTempBasalCapable || !pump.isInitialized() || pump.isSuspended()) {
|
||||||
tempBasal.setVisibility(View.GONE);
|
tempBasal.setVisibility(View.GONE);
|
||||||
tempBasalCancel.setVisibility(View.GONE);
|
tempBasalCancel.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(
|
final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
System.currentTimeMillis());
|
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
tempBasal.setVisibility(View.GONE);
|
tempBasal.setVisibility(View.GONE);
|
||||||
tempBasalCancel.setVisibility(View.VISIBLE);
|
tempBasalCancel.setVisibility(View.VISIBLE);
|
||||||
|
@ -239,6 +223,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
View.OnClickListener pumpCustomActionsListener = v -> {
|
View.OnClickListener pumpCustomActionsListener = v -> {
|
||||||
|
|
||||||
SingleClickButton btn = (SingleClickButton) v;
|
SingleClickButton btn = (SingleClickButton) v;
|
||||||
|
@ -260,7 +245,6 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new actions
|
|
||||||
List<CustomAction> customActions = activePump.getCustomActions();
|
List<CustomAction> customActions = activePump.getCustomActions();
|
||||||
|
|
||||||
if (customActions != null && customActions.size() > 0) {
|
if (customActions != null && customActions.size() > 0) {
|
||||||
|
@ -276,7 +260,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
btn.setText(MainApp.gs(customAction.getName()));
|
btn.setText(MainApp.gs(customAction.getName()));
|
||||||
|
|
||||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.5f);
|
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.5f);
|
||||||
layoutParams.setMargins(20, 8, 20, 8); // 10,3,10,3
|
layoutParams.setMargins(20, 8, 20, 8); // 10,3,10,3
|
||||||
|
|
||||||
btn.setLayoutParams(layoutParams);
|
btn.setLayoutParams(layoutParams);
|
||||||
|
@ -360,4 +344,4 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,7 +35,7 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.NumberPicker;
|
import info.nightscout.androidaps.utils.NumberPicker;
|
||||||
|
|
|
@ -19,7 +19,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.NumberPicker;
|
import info.nightscout.androidaps.utils.NumberPicker;
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.NumberPicker;
|
import info.nightscout.androidaps.utils.NumberPicker;
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -18,7 +18,7 @@ import com.squareup.otto.Subscribe;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.QuickWizard;
|
import info.nightscout.androidaps.data.QuickWizard;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.EditQuickWizardDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWizardChange;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWizardChange;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -16,7 +16,7 @@ import info.nightscout.androidaps.R;
|
||||||
public class MessageDialog extends DialogFragment implements View.OnClickListener {
|
public class MessageDialog extends DialogFragment implements View.OnClickListener {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(MessageDialog.class);
|
private static Logger log = LoggerFactory.getLogger(MessageDialog.class);
|
||||||
// Button muteButton;
|
|
||||||
Button okButton;
|
Button okButton;
|
||||||
TextView statusView;
|
TextView statusView;
|
||||||
MessageHelperActivity helperActivity;
|
MessageHelperActivity helperActivity;
|
||||||
|
@ -25,8 +25,6 @@ public class MessageDialog extends DialogFragment implements View.OnClickListene
|
||||||
static String title;
|
static String title;
|
||||||
|
|
||||||
|
|
||||||
// static int soundId;
|
|
||||||
|
|
||||||
public MessageDialog() {
|
public MessageDialog() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -51,14 +49,11 @@ public class MessageDialog extends DialogFragment implements View.OnClickListene
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
getDialog().setTitle(title);
|
getDialog().setTitle(title);
|
||||||
View view = inflater.inflate(R.layout.overview_message_dialog, container, false);
|
View view = inflater.inflate(R.layout.overview_message_dialog, container, false);
|
||||||
// muteButton = (Button)view.findViewById(R.id.overview_error_mute);
|
|
||||||
okButton = (Button)view.findViewById(R.id.overview_message_ok);
|
okButton = (Button)view.findViewById(R.id.overview_message_ok);
|
||||||
statusView = (TextView)view.findViewById(R.id.overview_message_status);
|
statusView = (TextView)view.findViewById(R.id.overview_message_status);
|
||||||
// muteButton.setOnClickListener(this);
|
|
||||||
okButton.setOnClickListener(this);
|
okButton.setOnClickListener(this);
|
||||||
setCancelable(false);
|
setCancelable(false);
|
||||||
|
|
||||||
// startAlarm();
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +81,7 @@ public class MessageDialog extends DialogFragment implements View.OnClickListene
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
|
|
||||||
case R.id.overview_message_ok:
|
case R.id.overview_message_ok:
|
||||||
log.debug("Error dialog ok button pressed");
|
log.debug("Message dialog ok button pressed");
|
||||||
dismiss();
|
dismiss();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
@ -9,16 +9,15 @@ public class MessageHelperActivity extends AppCompatActivity {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
MessageDialog messageDialog = new MessageDialog();
|
MessageDialog messageDialog = new MessageDialog();
|
||||||
messageDialog.setHelperActivity(this);
|
messageDialog.setHelperActivity(this);
|
||||||
messageDialog.setStatus(getIntent().getStringExtra("status"));
|
messageDialog.setStatus(getIntent().getStringExtra("status"));
|
||||||
|
|
||||||
messageDialog.setTitle(getIntent().getStringExtra("title"));
|
messageDialog.setTitle(getIntent().getStringExtra("title"));
|
||||||
messageDialog.show(this.getSupportFragmentManager(), "Message");
|
messageDialog.show(this.getSupportFragmentManager(), "Message");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.Dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
|
@ -43,7 +43,6 @@ public class WearPlugin extends PluginBase {
|
||||||
return wearPlugin;
|
return wearPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static WearPlugin initPlugin(Context ctx) {
|
public static WearPlugin initPlugin(Context ctx) {
|
||||||
|
|
||||||
if (wearPlugin == null) {
|
if (wearPlugin == null) {
|
||||||
|
@ -53,15 +52,18 @@ public class WearPlugin extends PluginBase {
|
||||||
return wearPlugin;
|
return wearPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WearPlugin(Context ctx) {
|
WearPlugin(Context ctx) {
|
||||||
super(new PluginDescription().mainType(PluginType.GENERAL).fragmentClass(WearFragment.class.getName())
|
super(new PluginDescription()
|
||||||
.pluginName(R.string.wear).shortName(R.string.wear_shortname).preferencesId(R.xml.pref_wear)
|
.mainType(PluginType.GENERAL)
|
||||||
.description(R.string.description_wear));
|
.fragmentClass(WearFragment.class.getName())
|
||||||
|
.pluginName(R.string.wear)
|
||||||
|
.shortName(R.string.wear_shortname)
|
||||||
|
.preferencesId(R.xml.pref_wear)
|
||||||
|
.description(R.string.description_wear)
|
||||||
|
);
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
@ -71,13 +73,11 @@ public class WearPlugin extends PluginBase {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void sendDataToWatch(boolean status, boolean basals, boolean bgValue) {
|
private void sendDataToWatch(boolean status, boolean basals, boolean bgValue) {
|
||||||
|
|
||||||
//Log.d(TAG, "WR: WearPlugin:sendDataToWatch (status=" + status + ",basals=" + basals + ",bgValue=" + bgValue + ")");
|
//Log.d(TAG, "WR: WearPlugin:sendDataToWatch (status=" + status + ",basals=" + basals + ",bgValue=" + bgValue + ")");
|
||||||
|
@ -89,35 +89,30 @@ public class WearPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basals) {
|
if (basals) {
|
||||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class)
|
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BASALS));
|
||||||
.setAction(WatchUpdaterService.ACTION_SEND_BASALS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class)
|
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_STATUS));
|
||||||
.setAction(WatchUpdaterService.ACTION_SEND_STATUS));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void resendDataToWatch() {
|
void resendDataToWatch() {
|
||||||
//Log.d(TAG, "WR: WearPlugin:resendDataToWatch");
|
//Log.d(TAG, "WR: WearPlugin:resendDataToWatch");
|
||||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_RESEND));
|
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_RESEND));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void openSettings() {
|
void openSettings() {
|
||||||
//Log.d(TAG, "WR: WearPlugin:openSettings");
|
//Log.d(TAG, "WR: WearPlugin:openSettings");
|
||||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_OPEN_SETTINGS));
|
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_OPEN_SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void requestNotificationCancel(String actionstring) {
|
void requestNotificationCancel(String actionstring) {
|
||||||
//Log.d(TAG, "WR: WearPlugin:requestNotificationCancel");
|
//Log.d(TAG, "WR: WearPlugin:requestNotificationCancel");
|
||||||
|
|
||||||
Intent intent = new Intent(ctx, WatchUpdaterService.class)
|
Intent intent = new Intent(ctx, WatchUpdaterService.class)
|
||||||
.setAction(WatchUpdaterService.ACTION_CANCEL_NOTIFICATION);
|
.setAction(WatchUpdaterService.ACTION_CANCEL_NOTIFICATION);
|
||||||
intent.putExtra("actionstring", actionstring);
|
intent.putExtra("actionstring", actionstring);
|
||||||
ctx.startService(intent);
|
ctx.startService(intent);
|
||||||
}
|
}
|
||||||
|
@ -131,43 +126,36 @@ public class WearPlugin extends PluginBase {
|
||||||
sendDataToWatch(true, false, false);
|
sendDataToWatch(true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
public void onStatusEvent(final EventTreatmentChange ev) {
|
||||||
sendDataToWatch(true, true, false);
|
sendDataToWatch(true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
public void onStatusEvent(final EventTempBasalChange ev) {
|
||||||
sendDataToWatch(true, true, false);
|
sendDataToWatch(true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
||||||
sendDataToWatch(true, true, false);
|
sendDataToWatch(true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
||||||
sendDataToWatch(true, true, false);
|
sendDataToWatch(true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
||||||
sendDataToWatch(true, true, true);
|
sendDataToWatch(true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewBasalProfile ev) {
|
public void onStatusEvent(final EventNewBasalProfile ev) {
|
||||||
sendDataToWatch(false, true, false);
|
sendDataToWatch(false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
public void onStatusEvent(final EventRefreshOverview ev) {
|
||||||
if (WatchUpdaterService.shouldReportLoopStatus(LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))) {
|
if (WatchUpdaterService.shouldReportLoopStatus(LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))) {
|
||||||
|
@ -179,31 +167,26 @@ public class WearPlugin extends PluginBase {
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventOverviewBolusProgress ev) {
|
public void onStatusEvent(final EventOverviewBolusProgress ev) {
|
||||||
if (!ev.isSMB() || SP.getBoolean("wear_notifySMB", true)) {
|
if (!ev.isSMB() || SP.getBoolean("wear_notifySMB", true)) {
|
||||||
Intent intent = new Intent(ctx, WatchUpdaterService.class)
|
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
|
||||||
.setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
|
|
||||||
intent.putExtra("progresspercent", ev.percent);
|
intent.putExtra("progresspercent", ev.percent);
|
||||||
intent.putExtra("progressstatus", ev.status);
|
intent.putExtra("progressstatus", ev.status);
|
||||||
ctx.startService(intent);
|
ctx.startService(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventBolusRequested ev) {
|
public void onStatusEvent(final EventBolusRequested ev) {
|
||||||
String status = String.format(MainApp.gs(R.string.bolusrequested), ev.getAmount());
|
String status = String.format(MainApp.gs(R.string.bolusrequested), ev.getAmount());
|
||||||
Intent intent = new Intent(ctx, WatchUpdaterService.class)
|
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
|
||||||
.setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
|
|
||||||
intent.putExtra("progresspercent", 0);
|
intent.putExtra("progresspercent", 0);
|
||||||
intent.putExtra("progressstatus", status);
|
intent.putExtra("progressstatus", status);
|
||||||
ctx.startService(intent);
|
ctx.startService(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
|
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
|
||||||
if (ev.result == null)
|
if (ev.result == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
String status;
|
String status;
|
||||||
if (ev.result.success) {
|
if (ev.result.success) {
|
||||||
|
@ -211,42 +194,35 @@ public class WearPlugin extends PluginBase {
|
||||||
} else {
|
} else {
|
||||||
status = MainApp.gs(R.string.nosuccess);
|
status = MainApp.gs(R.string.nosuccess);
|
||||||
}
|
}
|
||||||
Intent intent = new Intent(ctx, WatchUpdaterService.class)
|
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
|
||||||
.setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
|
|
||||||
intent.putExtra("progresspercent", 100);
|
intent.putExtra("progresspercent", 100);
|
||||||
intent.putExtra("progressstatus", status);
|
intent.putExtra("progressstatus", status);
|
||||||
ctx.startService(intent);
|
ctx.startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void requestActionConfirmation(String title, String message, String actionstring) {
|
public void requestActionConfirmation(String title, String message, String actionstring) {
|
||||||
|
|
||||||
Intent intent = new Intent(ctx, WatchUpdaterService.class)
|
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_ACTIONCONFIRMATIONREQUEST);
|
||||||
.setAction(WatchUpdaterService.ACTION_SEND_ACTIONCONFIRMATIONREQUEST);
|
|
||||||
intent.putExtra("title", title);
|
intent.putExtra("title", title);
|
||||||
intent.putExtra("message", message);
|
intent.putExtra("message", message);
|
||||||
intent.putExtra("actionstring", actionstring);
|
intent.putExtra("actionstring", actionstring);
|
||||||
ctx.startService(intent);
|
ctx.startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void requestChangeConfirmation(String title, String message, String actionstring) {
|
public void requestChangeConfirmation(String title, String message, String actionstring) {
|
||||||
|
|
||||||
Intent intent = new Intent(ctx, WatchUpdaterService.class)
|
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_CHANGECONFIRMATIONREQUEST);
|
||||||
.setAction(WatchUpdaterService.ACTION_SEND_CHANGECONFIRMATIONREQUEST);
|
|
||||||
intent.putExtra("title", title);
|
intent.putExtra("title", title);
|
||||||
intent.putExtra("message", message);
|
intent.putExtra("message", message);
|
||||||
intent.putExtra("actionstring", actionstring);
|
intent.putExtra("actionstring", actionstring);
|
||||||
ctx.startService(intent);
|
ctx.startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void registerWatchUpdaterService(WatchUpdaterService wus) {
|
public static void registerWatchUpdaterService(WatchUpdaterService wus) {
|
||||||
watchUS = wus;
|
watchUS = wus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void unRegisterWatchUpdaterService() {
|
public static void unRegisterWatchUpdaterService() {
|
||||||
watchUS = null;
|
watchUS = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
|
package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.utils.DateUtil.now;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -16,6 +7,13 @@ import android.support.v4.util.LongSparseArray;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
@ -33,27 +31,27 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
|
||||||
|
import static info.nightscout.androidaps.utils.DateUtil.now;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 24.04.2017.
|
* Created by mike on 24.04.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class IobCobCalculatorPlugin extends PluginBase {
|
public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger(L.AUTOSENS);
|
private Logger log = LoggerFactory.getLogger(L.AUTOSENS);
|
||||||
|
|
||||||
private static IobCobCalculatorPlugin plugin = null;
|
private static IobCobCalculatorPlugin plugin = null;
|
||||||
|
|
||||||
|
|
||||||
public static IobCobCalculatorPlugin getPlugin() {
|
public static IobCobCalculatorPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
plugin = new IobCobCalculatorPlugin();
|
plugin = new IobCobCalculatorPlugin();
|
||||||
|
@ -72,47 +70,44 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
boolean stopCalculationTrigger = false;
|
boolean stopCalculationTrigger = false;
|
||||||
private Thread thread = null;
|
private Thread thread = null;
|
||||||
|
|
||||||
|
|
||||||
public IobCobCalculatorPlugin() {
|
public IobCobCalculatorPlugin() {
|
||||||
super(new PluginDescription().mainType(PluginType.GENERAL).pluginName(R.string.iobcobcalculator)
|
super(new PluginDescription()
|
||||||
.showInList(false).neverVisible(true).alwaysEnabled(true));
|
.mainType(PluginType.GENERAL)
|
||||||
|
.pluginName(R.string.iobcobcalculator)
|
||||||
|
.showInList(false)
|
||||||
|
.neverVisible(true)
|
||||||
|
.alwaysEnabled(true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LongSparseArray<AutosensData> getAutosensDataTable() {
|
public LongSparseArray<AutosensData> getAutosensDataTable() {
|
||||||
return autosensDataTable;
|
return autosensDataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<BgReading> getBgReadings() {
|
public List<BgReading> getBgReadings() {
|
||||||
return bgReadings;
|
return bgReadings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setBgReadings(List<BgReading> bgReadings) {
|
public void setBgReadings(List<BgReading> bgReadings) {
|
||||||
this.bgReadings = bgReadings;
|
this.bgReadings = bgReadings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<BgReading> getBucketedData() {
|
public List<BgReading> getBucketedData() {
|
||||||
return bucketed_data;
|
return bucketed_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// roundup to whole minute
|
// roundup to whole minute
|
||||||
public static long roundUpTime(long time) {
|
public static long roundUpTime(long time) {
|
||||||
if (time % 60000 == 0)
|
if (time % 60000 == 0)
|
||||||
|
@ -121,30 +116,24 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
return rounded;
|
return rounded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loadBgData(long to) {
|
void loadBgData(long to) {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile(to);
|
Profile profile = ProfileFunctions.getInstance().getProfile(to);
|
||||||
double dia = Constants.defaultDIA;
|
double dia = Constants.defaultDIA;
|
||||||
if (profile != null)
|
if (profile != null) dia = profile.getDia();
|
||||||
dia = profile.getDia();
|
long start = to - T.hours((long) (24 + dia)).msecs();
|
||||||
long start = to - T.hours((long)(24 + dia)).msecs();
|
|
||||||
if (DateUtil.isCloseToNow(to)) {
|
if (DateUtil.isCloseToNow(to)) {
|
||||||
// if close to now expect there can be some readings with time in close future (caused by wrong time
|
// if close to now expect there can be some readings with time in close future (caused by wrong time setting)
|
||||||
// setting)
|
|
||||||
// so read all records
|
// so read all records
|
||||||
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, false);
|
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, false);
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("BG data loaded. Size: " + bgReadings.size() + " Start date: "
|
log.debug("BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start));
|
||||||
+ DateUtil.dateAndTimeString(start));
|
|
||||||
} else {
|
} else {
|
||||||
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, to, false);
|
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, to, false);
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("BG data loaded. Size: " + bgReadings.size() + " Start date: "
|
log.debug("BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(to));
|
||||||
+ DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(to));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isAbout5minData() {
|
public boolean isAbout5minData() {
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
if (bgReadings == null || bgReadings.size() < 3) {
|
if (bgReadings == null || bgReadings.size() < 3) {
|
||||||
|
@ -162,21 +151,18 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
diff = Math.abs(diff);
|
diff = Math.abs(diff);
|
||||||
if (diff > T.secs(30).msecs()) {
|
if (diff > T.secs(30).msecs()) {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000)
|
log.debug("Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000) + "[s] is5minData: " + false);
|
||||||
+ "[s] is5minData: " + false);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long averageDiff = totalDiff / bgReadings.size() / 1000;
|
long averageDiff = totalDiff / bgReadings.size() / 1000;
|
||||||
boolean is5mindata = averageDiff < 1;
|
boolean is5mindata = averageDiff < 1;
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Interval detection: values: " + bgReadings.size() + " averageDiff: " + averageDiff
|
log.debug("Interval detection: values: " + bgReadings.size() + " averageDiff: " + averageDiff + "[s] is5minData: " + is5mindata);
|
||||||
+ "[s] is5minData: " + is5mindata);
|
|
||||||
return is5mindata;
|
return is5mindata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createBucketedData() {
|
public void createBucketedData() {
|
||||||
if (isAbout5minData())
|
if (isAbout5minData())
|
||||||
createBucketedData5min();
|
createBucketedData5min();
|
||||||
|
@ -184,43 +170,32 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
createBucketedDataRecalculated();
|
createBucketedDataRecalculated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public BgReading findNewer(long time) {
|
public BgReading findNewer(long time) {
|
||||||
BgReading lastFound = bgReadings.get(0);
|
BgReading lastFound = bgReadings.get(0);
|
||||||
if (lastFound.date < time)
|
if (lastFound.date < time) return null;
|
||||||
return null;
|
|
||||||
for (int i = 1; i < bgReadings.size(); ++i) {
|
for (int i = 1; i < bgReadings.size(); ++i) {
|
||||||
if (bgReadings.get(i).date == time)
|
if (bgReadings.get(i).date == time) return bgReadings.get(i);
|
||||||
return bgReadings.get(i);
|
if (bgReadings.get(i).date > time) continue;
|
||||||
if (bgReadings.get(i).date > time)
|
|
||||||
continue;
|
|
||||||
lastFound = bgReadings.get(i - 1);
|
lastFound = bgReadings.get(i - 1);
|
||||||
if (bgReadings.get(i).date < time)
|
if (bgReadings.get(i).date < time) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return lastFound;
|
return lastFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public BgReading findOlder(long time) {
|
public BgReading findOlder(long time) {
|
||||||
BgReading lastFound = bgReadings.get(bgReadings.size() - 1);
|
BgReading lastFound = bgReadings.get(bgReadings.size() - 1);
|
||||||
if (lastFound.date > time)
|
if (lastFound.date > time) return null;
|
||||||
return null;
|
|
||||||
for (int i = bgReadings.size() - 2; i >= 0; --i) {
|
for (int i = bgReadings.size() - 2; i >= 0; --i) {
|
||||||
if (bgReadings.get(i).date == time)
|
if (bgReadings.get(i).date == time) return bgReadings.get(i);
|
||||||
return bgReadings.get(i);
|
if (bgReadings.get(i).date < time) continue;
|
||||||
if (bgReadings.get(i).date < time)
|
|
||||||
continue;
|
|
||||||
lastFound = bgReadings.get(i + 1);
|
lastFound = bgReadings.get(i + 1);
|
||||||
if (bgReadings.get(i).date > time)
|
if (bgReadings.get(i).date > time) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return lastFound;
|
return lastFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createBucketedDataRecalculated() {
|
private void createBucketedDataRecalculated() {
|
||||||
if (bgReadings == null || bgReadings.size() < 3) {
|
if (bgReadings == null || bgReadings.size() < 3) {
|
||||||
bucketed_data = null;
|
bucketed_data = null;
|
||||||
|
@ -229,7 +204,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
|
|
||||||
bucketed_data = new ArrayList<>();
|
bucketed_data = new ArrayList<>();
|
||||||
long currentTime = bgReadings.get(0).date - bgReadings.get(0).date % T.mins(5).msecs();
|
long currentTime = bgReadings.get(0).date - bgReadings.get(0).date % T.mins(5).msecs();
|
||||||
// log.debug("First reading: " + new Date(currentTime).toLocaleString());
|
//log.debug("First reading: " + new Date(currentTime).toLocaleString());
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// test if current value is older than current time
|
// test if current value is older than current time
|
||||||
|
@ -244,14 +219,12 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
double bgDelta = newer.value - older.value;
|
double bgDelta = newer.value - older.value;
|
||||||
long timeDiffToNew = newer.date - currentTime;
|
long timeDiffToNew = newer.date - currentTime;
|
||||||
|
|
||||||
double currentBg = newer.value - (double)timeDiffToNew / (newer.date - older.date) * bgDelta;
|
double currentBg = newer.value - (double) timeDiffToNew / (newer.date - older.date) * bgDelta;
|
||||||
BgReading newBgreading = new BgReading();
|
BgReading newBgreading = new BgReading();
|
||||||
newBgreading.date = currentTime;
|
newBgreading.date = currentTime;
|
||||||
newBgreading.value = Math.round(currentBg);
|
newBgreading.value = Math.round(currentBg);
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
// log.debug("BG: " + newBgreading.value + " (" + new Date(newBgreading.date).toLocaleString() +
|
//log.debug("BG: " + newBgreading.value + " (" + new Date(newBgreading.date).toLocaleString() + ") Prev: " + older.value + " (" + new Date(older.date).toLocaleString() + ") Newer: " + newer.value + " (" + new Date(newer.date).toLocaleString() + ")");
|
||||||
// ") Prev: " + older.value + " (" + new Date(older.date).toLocaleString() + ") Newer: " + newer.value +
|
|
||||||
// " (" + new Date(newer.date).toLocaleString() + ")");
|
|
||||||
}
|
}
|
||||||
currentTime -= T.mins(5).msecs();
|
currentTime -= T.mins(5).msecs();
|
||||||
|
|
||||||
|
@ -268,14 +241,12 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
bucketed_data = new ArrayList<>();
|
bucketed_data = new ArrayList<>();
|
||||||
bucketed_data.add(bgReadings.get(0));
|
bucketed_data.add(bgReadings.get(0));
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgReadings.get(0).date) + " lastbgTime: "
|
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgReadings.get(0).date) + " lastbgTime: " + "none-first-value" + " " + bgReadings.get(0).toString());
|
||||||
+ "none-first-value" + " " + bgReadings.get(0).toString());
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 1; i < bgReadings.size(); ++i) {
|
for (int i = 1; i < bgReadings.size(); ++i) {
|
||||||
long bgTime = bgReadings.get(i).date;
|
long bgTime = bgReadings.get(i).date;
|
||||||
long lastbgTime = bgReadings.get(i - 1).date;
|
long lastbgTime = bgReadings.get(i - 1).date;
|
||||||
// log.error("Processing " + i + ": " + new Date(bgTime).toString() + " " + bgReadings.get(i).value +
|
//log.error("Processing " + i + ": " + new Date(bgTime).toString() + " " + bgReadings.get(i).value + " Previous: " + new Date(lastbgTime).toString() + " " + bgReadings.get(i - 1).value);
|
||||||
// " Previous: " + new Date(lastbgTime).toString() + " " + bgReadings.get(i - 1).value);
|
|
||||||
if (bgReadings.get(i).value < 39 || bgReadings.get(i - 1).value < 39) {
|
if (bgReadings.get(i).value < 39 || bgReadings.get(i - 1).value < 39) {
|
||||||
throw new IllegalStateException("<39");
|
throw new IllegalStateException("<39");
|
||||||
}
|
}
|
||||||
|
@ -285,7 +256,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
// interpolate missing data points
|
// interpolate missing data points
|
||||||
double lastbg = bgReadings.get(i - 1).value;
|
double lastbg = bgReadings.get(i - 1).value;
|
||||||
elapsed_minutes = Math.abs(elapsed_minutes);
|
elapsed_minutes = Math.abs(elapsed_minutes);
|
||||||
// console.error(elapsed_minutes);
|
//console.error(elapsed_minutes);
|
||||||
long nextbgTime;
|
long nextbgTime;
|
||||||
while (elapsed_minutes > 5) {
|
while (elapsed_minutes > 5) {
|
||||||
nextbgTime = lastbgTime - 5 * 60 * 1000;
|
nextbgTime = lastbgTime - 5 * 60 * 1000;
|
||||||
|
@ -293,14 +264,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
BgReading newBgreading = new BgReading();
|
BgReading newBgreading = new BgReading();
|
||||||
newBgreading.date = nextbgTime;
|
newBgreading.date = nextbgTime;
|
||||||
double gapDelta = bgReadings.get(i).value - lastbg;
|
double gapDelta = bgReadings.get(i).value - lastbg;
|
||||||
// console.error(gapDelta, lastbg, elapsed_minutes);
|
//console.error(gapDelta, lastbg, elapsed_minutes);
|
||||||
double nextbg = lastbg + (5d / elapsed_minutes * gapDelta);
|
double nextbg = lastbg + (5d / elapsed_minutes * gapDelta);
|
||||||
newBgreading.value = Math.round(nextbg);
|
newBgreading.value = Math.round(nextbg);
|
||||||
// console.error("Interpolated", bucketed_data[j]);
|
//console.error("Interpolated", bucketed_data[j]);
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: "
|
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
||||||
+ DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
|
||||||
|
|
||||||
elapsed_minutes = elapsed_minutes - 5;
|
elapsed_minutes = elapsed_minutes - 5;
|
||||||
lastbg = nextbg;
|
lastbg = nextbg;
|
||||||
|
@ -312,8 +282,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
newBgreading.date = bgTime;
|
newBgreading.date = bgTime;
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: "
|
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
||||||
+ DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
|
||||||
} else if (Math.abs(elapsed_minutes) > 2) {
|
} else if (Math.abs(elapsed_minutes) > 2) {
|
||||||
j++;
|
j++;
|
||||||
BgReading newBgreading = new BgReading();
|
BgReading newBgreading = new BgReading();
|
||||||
|
@ -321,11 +290,10 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
newBgreading.date = bgTime;
|
newBgreading.date = bgTime;
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: "
|
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
||||||
+ DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
|
||||||
} else {
|
} else {
|
||||||
bucketed_data.get(j).value = (bucketed_data.get(j).value + bgReadings.get(i).value) / 2;
|
bucketed_data.get(j).value = (bucketed_data.get(j).value + bgReadings.get(i).value) / 2;
|
||||||
// log.error("***** Average");
|
//log.error("***** Average");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,8 +304,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
long msecDiff = current.date - previous.date;
|
long msecDiff = current.date - previous.date;
|
||||||
long adjusted = (msecDiff - T.mins(5).msecs()) / 1000;
|
long adjusted = (msecDiff - T.mins(5).msecs()) / 1000;
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.date) + " to: "
|
log.debug("Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.date) + " to: " + DateUtil.toISOString(previous.date + T.mins(5).msecs()) + " by " + adjusted + " sec");
|
||||||
+ DateUtil.toISOString(previous.date + T.mins(5).msecs()) + " by " + adjusted + " sec");
|
|
||||||
if (Math.abs(adjusted) > 90) {
|
if (Math.abs(adjusted) > 90) {
|
||||||
// too big adjustment, fallback to non 5 min data
|
// too big adjustment, fallback to non 5 min data
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
|
@ -352,50 +319,47 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
log.debug("Bucketed data created. Size: " + bucketed_data.size());
|
log.debug("Bucketed data created. Size: " + bucketed_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) {
|
public long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile(from);
|
Profile profile = ProfileFunctions.getInstance().getProfile(from);
|
||||||
double dia = Constants.defaultDIA;
|
double dia = Constants.defaultDIA;
|
||||||
if (profile != null)
|
if (profile != null) dia = profile.getDia();
|
||||||
dia = profile.getDia();
|
|
||||||
|
|
||||||
long oldestDataAvailable = TreatmentsPlugin.getPlugin().oldestDataAvailable();
|
long oldestDataAvailable = TreatmentsPlugin.getPlugin().oldestDataAvailable();
|
||||||
long getBGDataFrom;
|
long getBGDataFrom;
|
||||||
if (limitDataToOldestAvailable) {
|
if (limitDataToOldestAvailable) {
|
||||||
getBGDataFrom = Math.max(oldestDataAvailable, (long)(from - T.hours(1).msecs() * (24 + dia)));
|
getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia)));
|
||||||
if (getBGDataFrom == oldestDataAvailable)
|
if (getBGDataFrom == oldestDataAvailable)
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Limiting data to oldest available temps: "
|
log.debug("Limiting data to oldest available temps: " + DateUtil.dateAndTimeFullString(oldestDataAvailable));
|
||||||
+ DateUtil.dateAndTimeFullString(oldestDataAvailable));
|
|
||||||
} else
|
} else
|
||||||
getBGDataFrom = (long)(from - T.hours(1).msecs() * (24 + dia));
|
getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia));
|
||||||
return getBGDataFrom;
|
return getBGDataFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IobTotal calculateFromTreatmentsAndTempsSynchronized(long time, Profile profile) {
|
public IobTotal calculateFromTreatmentsAndTempsSynchronized(long time, Profile profile) {
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
return calculateFromTreatmentsAndTemps(time, profile);
|
return calculateFromTreatmentsAndTemps(time, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IobTotal calculateFromTreatmentsAndTemps(long time, Profile profile) {
|
public IobTotal calculateFromTreatmentsAndTemps(long time, Profile profile) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
time = roundUpTime(time);
|
time = roundUpTime(time);
|
||||||
if (time < now && iobTable.get(time) != null) {
|
if (time < now && iobTable.get(time) != null) {
|
||||||
// og.debug(">>> calculateFromTreatmentsAndTemps Cache hit " + new Date(time).toLocaleString());
|
//og.debug(">>> calculateFromTreatmentsAndTemps Cache hit " + new Date(time).toLocaleString());
|
||||||
return iobTable.get(time);
|
return iobTable.get(time);
|
||||||
} else {
|
} else {
|
||||||
// log.debug(">>> calculateFromTreatmentsAndTemps Cache miss " + new Date(time).toLocaleString());
|
//log.debug(">>> calculateFromTreatmentsAndTemps Cache miss " + new Date(time).toLocaleString());
|
||||||
}
|
}
|
||||||
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTreatments(time).round();
|
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTreatments(time).round();
|
||||||
IobTotal basalIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTempBasals(time, profile, true, now)
|
IobTotal basalIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTempBasals(time, profile, true, now).round();
|
||||||
.round();
|
|
||||||
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginType.APS)) {
|
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginType.APS)) {
|
||||||
// Add expected zero temp basal for next 240 mins
|
// Add expected zero temp basal for next 240 mins
|
||||||
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
||||||
TemporaryBasal t = new TemporaryBasal().date(now + 60 * 1000L).duration(240).absolute(0);
|
TemporaryBasal t = new TemporaryBasal()
|
||||||
|
.date(now + 60 * 1000L)
|
||||||
|
.duration(240)
|
||||||
|
.absolute(0);
|
||||||
if (t.date < time) {
|
if (t.date < time) {
|
||||||
IobTotal calc = t.iobCalc(time, profile);
|
IobTotal calc = t.iobCalc(time, profile);
|
||||||
basalIobWithZeroTemp.plus(calc);
|
basalIobWithZeroTemp.plus(calc);
|
||||||
|
@ -411,7 +375,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
return iobTotal;
|
return iobTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Long findPreviousTimeFromBucketedData(long time) {
|
public Long findPreviousTimeFromBucketedData(long time) {
|
||||||
if (bucketed_data == null)
|
if (bucketed_data == null)
|
||||||
|
@ -423,7 +386,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BasalData getBasalData(Profile profile, long time) {
|
public BasalData getBasalData(Profile profile, long time) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
time = roundUpTime(time);
|
time = roundUpTime(time);
|
||||||
|
@ -442,14 +404,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
if (time < now) {
|
if (time < now) {
|
||||||
basalDataTable.append(time, retval);
|
basalDataTable.append(time, retval);
|
||||||
}
|
}
|
||||||
// log.debug(">>> getBasalData Cache miss " + new Date(time).toLocaleString());
|
//log.debug(">>> getBasalData Cache miss " + new Date(time).toLocaleString());
|
||||||
} else {
|
} else {
|
||||||
// log.debug(">>> getBasalData Cache hit " + new Date(time).toLocaleString());
|
//log.debug(">>> getBasalData Cache hit " + new Date(time).toLocaleString());
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public AutosensData getAutosensData(long time) {
|
public AutosensData getAutosensData(long time) {
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
|
@ -464,16 +425,15 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
time = roundUpTime(previous);
|
time = roundUpTime(previous);
|
||||||
AutosensData data = autosensDataTable.get(time);
|
AutosensData data = autosensDataTable.get(time);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
// log.debug(">>> AUTOSENSDATA Cache hit " + data.toString());
|
//log.debug(">>> AUTOSENSDATA Cache hit " + data.toString());
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
// log.debug(">>> AUTOSENSDATA Cache miss " + new Date(time).toLocaleString());
|
//log.debug(">>> AUTOSENSDATA Cache miss " + new Date(time).toLocaleString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public AutosensData getLastAutosensDataSynchronized(String reason) {
|
public AutosensData getLastAutosensDataSynchronized(String reason) {
|
||||||
if (thread != null && thread.isAlive()) {
|
if (thread != null && thread.isAlive()) {
|
||||||
|
@ -494,8 +454,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public CobInfo getCobInfo(boolean _synchronized, String reason) {
|
public CobInfo getCobInfo(boolean _synchronized, String reason) {
|
||||||
AutosensData autosensData = _synchronized ? getLastAutosensDataSynchronized(reason)
|
AutosensData autosensData = _synchronized ? getLastAutosensDataSynchronized(reason) : getLastAutosensData(reason);
|
||||||
: getLastAutosensData(reason);
|
|
||||||
Double displayCob = null;
|
Double displayCob = null;
|
||||||
double futureCarbs = 0;
|
double futureCarbs = 0;
|
||||||
long now = now();
|
long now = now();
|
||||||
|
@ -504,17 +463,15 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
if (autosensData != null) {
|
if (autosensData != null) {
|
||||||
displayCob = autosensData.cob;
|
displayCob = autosensData.cob;
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
if (!treatment.isValid)
|
if (!treatment.isValid) continue;
|
||||||
continue;
|
if (IobCobCalculatorPlugin.roundUpTime(treatment.date) > IobCobCalculatorPlugin.roundUpTime(autosensData.time)
|
||||||
if (IobCobCalculatorPlugin.roundUpTime(treatment.date) > IobCobCalculatorPlugin
|
&& treatment.date <= now && treatment.carbs > 0) {
|
||||||
.roundUpTime(autosensData.time) && treatment.date <= now && treatment.carbs > 0) {
|
|
||||||
displayCob += treatment.carbs;
|
displayCob += treatment.carbs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
if (!treatment.isValid)
|
if (!treatment.isValid) continue;
|
||||||
continue;
|
|
||||||
if (treatment.date > now && treatment.carbs > 0) {
|
if (treatment.date > now && treatment.carbs > 0) {
|
||||||
futureCarbs += treatment.carbs;
|
futureCarbs += treatment.carbs;
|
||||||
}
|
}
|
||||||
|
@ -522,7 +479,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
return new CobInfo(displayCob, futureCarbs);
|
return new CobInfo(displayCob, futureCarbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public AutosensData getLastAutosensData(String reason) {
|
public AutosensData getLastAutosensData(String reason) {
|
||||||
if (autosensDataTable.size() < 1) {
|
if (autosensDataTable.size() < 1) {
|
||||||
|
@ -546,8 +502,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
|
if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size()
|
log.debug("AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time));
|
||||||
+ " lastdata=" + DateUtil.dateAndTimeString(data.time));
|
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
|
@ -556,7 +511,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String lastDataTime() {
|
public String lastDataTime() {
|
||||||
if (autosensDataTable.size() > 0)
|
if (autosensDataTable.size() > 0)
|
||||||
return DateUtil.dateAndTimeString(autosensDataTable.valueAt(autosensDataTable.size() - 1).time);
|
return DateUtil.dateAndTimeString(autosensDataTable.valueAt(autosensDataTable.size() - 1).time);
|
||||||
|
@ -564,12 +518,11 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
return "autosensDataTable empty";
|
return "autosensDataTable empty";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IobTotal[] calculateIobArrayInDia(Profile profile) {
|
public IobTotal[] calculateIobArrayInDia(Profile profile) {
|
||||||
// predict IOB out to DIA plus 30m
|
// predict IOB out to DIA plus 30m
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
time = roundUpTime(time);
|
time = roundUpTime(time);
|
||||||
int len = (int)((profile.getDia() * 60 + 30) / 5);
|
int len = (int) ((profile.getDia() * 60 + 30) / 5);
|
||||||
IobTotal[] array = new IobTotal[len];
|
IobTotal[] array = new IobTotal[len];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
|
@ -581,7 +534,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IobTotal[] calculateIobArrayForSMB(Profile profile) {
|
public IobTotal[] calculateIobArrayForSMB(Profile profile) {
|
||||||
// predict IOB out to DIA plus 30m
|
// predict IOB out to DIA plus 30m
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
|
@ -598,14 +550,12 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AutosensResult detectSensitivityWithLock(long fromTime, long toTime) {
|
public AutosensResult detectSensitivityWithLock(long fromTime, long toTime) {
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
return ConfigBuilderPlugin.getPlugin().getActiveSensitivity().detectSensitivity(this, fromTime, toTime);
|
return ConfigBuilderPlugin.getPlugin().getActiveSensitivity().detectSensitivity(this, fromTime, toTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static JSONArray convertToJSONArray(IobTotal[] iobArray) {
|
public static JSONArray convertToJSONArray(IobTotal[] iobArray) {
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
for (int i = 0; i < iobArray.length; i++) {
|
for (int i = 0; i < iobArray.length; i++) {
|
||||||
|
@ -614,7 +564,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void onEventAppInitialized(EventAppInitialized ev) {
|
public void onEventAppInitialized(EventAppInitialized ev) {
|
||||||
|
@ -626,7 +575,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, ev);
|
runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void onEventNewBG(EventNewBG ev) {
|
public void onEventNewBG(EventNewBG ev) {
|
||||||
|
@ -639,7 +587,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
runCalculation("onEventNewBG", System.currentTimeMillis(), true, true, ev);
|
runCalculation("onEventNewBG", System.currentTimeMillis(), true, true, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void stopCalculation(String from) {
|
public void stopCalculation(String from) {
|
||||||
if (thread != null && thread.getState() != Thread.State.TERMINATED) {
|
if (thread != null && thread.getState() != Thread.State.TERMINATED) {
|
||||||
stopCalculationTrigger = true;
|
stopCalculationTrigger = true;
|
||||||
|
@ -653,9 +600,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) {
|
||||||
public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable,
|
|
||||||
Event cause) {
|
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end));
|
log.debug("Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end));
|
||||||
if (thread == null || thread.getState() == Thread.State.TERMINATED) {
|
if (thread == null || thread.getState() == Thread.State.TERMINATED) {
|
||||||
|
@ -667,7 +612,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onNewProfile(EventNewBasalProfile ev) {
|
public void onNewProfile(EventNewBasalProfile ev) {
|
||||||
if (this != getPlugin()) {
|
if (this != getPlugin()) {
|
||||||
|
@ -683,15 +627,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
stopCalculation("onNewProfile");
|
stopCalculation("onNewProfile");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: "
|
log.debug("Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||||
+ autosensDataTable.size() + " records");
|
|
||||||
iobTable = new LongSparseArray<>();
|
iobTable = new LongSparseArray<>();
|
||||||
autosensDataTable = new LongSparseArray<>();
|
autosensDataTable = new LongSparseArray<>();
|
||||||
}
|
}
|
||||||
runCalculation("onNewProfile", System.currentTimeMillis(), false, true, ev);
|
runCalculation("onNewProfile", System.currentTimeMillis(), false, true, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onEventPreferenceChange(EventPreferenceChange ev) {
|
public void onEventPreferenceChange(EventPreferenceChange ev) {
|
||||||
if (this != getPlugin()) {
|
if (this != getPlugin()) {
|
||||||
|
@ -699,15 +641,18 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
log.debug("Ignoring event for non default instance");
|
log.debug("Ignoring event for non default instance");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ev.isChanged(R.string.key_openapsama_autosens_period) || ev.isChanged(R.string.key_age)
|
if (ev.isChanged(R.string.key_openapsama_autosens_period) ||
|
||||||
|| ev.isChanged(R.string.key_absorption_maxtime) || ev.isChanged(R.string.key_openapsama_min_5m_carbimpact)
|
ev.isChanged(R.string.key_age) ||
|
||||||
|| ev.isChanged(R.string.key_absorption_cutoff) || ev.isChanged(R.string.key_openapsama_autosens_max)
|
ev.isChanged(R.string.key_absorption_maxtime) ||
|
||||||
|| ev.isChanged(R.string.key_openapsama_autosens_min)) {
|
ev.isChanged(R.string.key_openapsama_min_5m_carbimpact) ||
|
||||||
|
ev.isChanged(R.string.key_absorption_cutoff) ||
|
||||||
|
ev.isChanged(R.string.key_openapsama_autosens_max) ||
|
||||||
|
ev.isChanged(R.string.key_openapsama_autosens_min)
|
||||||
|
) {
|
||||||
stopCalculation("onEventPreferenceChange");
|
stopCalculation("onEventPreferenceChange");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size()
|
log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||||
+ " Autosens: " + autosensDataTable.size() + " records");
|
|
||||||
iobTable = new LongSparseArray<>();
|
iobTable = new LongSparseArray<>();
|
||||||
autosensDataTable = new LongSparseArray<>();
|
autosensDataTable = new LongSparseArray<>();
|
||||||
}
|
}
|
||||||
|
@ -715,7 +660,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onEventConfigBuilderChange(EventConfigBuilderChange ev) {
|
public void onEventConfigBuilderChange(EventConfigBuilderChange ev) {
|
||||||
if (this != getPlugin()) {
|
if (this != getPlugin()) {
|
||||||
|
@ -726,15 +670,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
stopCalculation("onEventConfigBuilderChange");
|
stopCalculation("onEventConfigBuilderChange");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size()
|
log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||||
+ " Autosens: " + autosensDataTable.size() + " records");
|
|
||||||
iobTable = new LongSparseArray<>();
|
iobTable = new LongSparseArray<>();
|
||||||
autosensDataTable = new LongSparseArray<>();
|
autosensDataTable = new LongSparseArray<>();
|
||||||
}
|
}
|
||||||
runCalculation("onEventConfigBuilderChange", System.currentTimeMillis(), false, true, ev);
|
runCalculation("onEventConfigBuilderChange", System.currentTimeMillis(), false, true, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated
|
// When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onEventNewHistoryData(EventNewHistoryData ev) {
|
public void onEventNewHistoryData(EventNewHistoryData ev) {
|
||||||
|
@ -743,7 +685,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
log.debug("Ignoring event for non default instance");
|
log.debug("Ignoring event for non default instance");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// log.debug("Locking onNewHistoryData");
|
//log.debug("Locking onNewHistoryData");
|
||||||
stopCalculation("onEventNewHistoryData");
|
stopCalculation("onEventNewHistoryData");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
// clear up 5 min back for proper COB calculation
|
// clear up 5 min back for proper COB calculation
|
||||||
|
@ -762,8 +704,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
for (int index = autosensDataTable.size() - 1; index >= 0; index--) {
|
for (int index = autosensDataTable.size() - 1; index >= 0; index--) {
|
||||||
if (autosensDataTable.keyAt(index) > time) {
|
if (autosensDataTable.keyAt(index) > time) {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Removing from autosensDataTable: "
|
log.debug("Removing from autosensDataTable: " + DateUtil.dateAndTimeFullString(autosensDataTable.keyAt(index)));
|
||||||
+ DateUtil.dateAndTimeFullString(autosensDataTable.keyAt(index)));
|
|
||||||
autosensDataTable.removeAt(index);
|
autosensDataTable.removeAt(index);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -772,8 +713,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
for (int index = basalDataTable.size() - 1; index >= 0; index--) {
|
for (int index = basalDataTable.size() - 1; index >= 0; index--) {
|
||||||
if (basalDataTable.keyAt(index) > time) {
|
if (basalDataTable.keyAt(index) > time) {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Removing from basalDataTable: "
|
log.debug("Removing from basalDataTable: " + DateUtil.dateAndTimeFullString(basalDataTable.keyAt(index)));
|
||||||
+ DateUtil.dateAndTimeFullString(basalDataTable.keyAt(index)));
|
|
||||||
basalDataTable.removeAt(index);
|
basalDataTable.removeAt(index);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -781,10 +721,9 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runCalculation("onEventNewHistoryData", System.currentTimeMillis(), false, true, ev);
|
runCalculation("onEventNewHistoryData", System.currentTimeMillis(), false, true, ev);
|
||||||
// log.debug("Releasing onNewHistoryData");
|
//log.debug("Releasing onNewHistoryData");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
|
@ -794,22 +733,20 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// From https://gist.github.com/IceCreamYou/6ffa1b18c4c8f6aeaad2
|
// From https://gist.github.com/IceCreamYou/6ffa1b18c4c8f6aeaad2
|
||||||
// Returns the value at a given percentile in a sorted numeric array.
|
// Returns the value at a given percentile in a sorted numeric array.
|
||||||
// "Linear interpolation between closest ranks" method
|
// "Linear interpolation between closest ranks" method
|
||||||
public static double percentile(Double[] arr, double p) {
|
public static double percentile(Double[] arr, double p) {
|
||||||
if (arr.length == 0)
|
if (arr.length == 0) return 0;
|
||||||
return 0;
|
if (p <= 0) return arr[0];
|
||||||
if (p <= 0)
|
if (p >= 1) return arr[arr.length - 1];
|
||||||
return arr[0];
|
|
||||||
if (p >= 1)
|
|
||||||
return arr[arr.length - 1];
|
|
||||||
|
|
||||||
double index = arr.length * p, lower = Math.floor(index), upper = lower + 1, weight = index % 1;
|
double index = arr.length * p,
|
||||||
|
lower = Math.floor(index),
|
||||||
|
upper = lower + 1,
|
||||||
|
weight = index % 1;
|
||||||
|
|
||||||
if (upper >= arr.length)
|
if (upper >= arr.length) return arr[(int) lower];
|
||||||
return arr[(int)lower];
|
return arr[(int) lower] * (1 - weight) + arr[(int) upper] * weight;
|
||||||
return arr[(int)lower] * (1 - weight) + arr[(int)upper] * weight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,16 +34,19 @@ public enum PumpCapability {
|
||||||
PumpCapability[] children;
|
PumpCapability[] children;
|
||||||
|
|
||||||
|
|
||||||
PumpCapability() {
|
PumpCapability()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PumpCapability(PumpCapability... children) {
|
PumpCapability(PumpCapability...children)
|
||||||
|
{
|
||||||
this.children = children;
|
this.children = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean hasCapability(PumpCapability capability) {
|
public boolean hasCapability(PumpCapability capability)
|
||||||
|
{
|
||||||
// we can only check presense of simple capabilities
|
// we can only check presense of simple capabilities
|
||||||
if (capability.children != null)
|
if (capability.children != null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -51,15 +54,19 @@ public enum PumpCapability {
|
||||||
if (this == capability)
|
if (this == capability)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (this.children != null) {
|
if (this.children!=null)
|
||||||
|
{
|
||||||
for (PumpCapability child : children) {
|
for (PumpCapability child : children) {
|
||||||
if (child == capability)
|
if (child == capability)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
|
@ -9,80 +9,81 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.DoseSettings;
|
import info.nightscout.androidaps.plugins.pump.common.data.DoseSettings;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 02/05/2018.
|
* Created by andy on 02/05/2018.
|
||||||
* <p>
|
*
|
||||||
* Most of this defintions is intended for VirtualPump only, but they can be used by other plugins.
|
* Most of this defintions is intended for VirtualPump only, but they can be used by other plugins.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum PumpType {
|
public enum PumpType {
|
||||||
|
|
||||||
GenericAAPS("Generic AAPS", 0.1d, null, //
|
GenericAAPS("Generic AAPS", 0.1d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10, 30, 24 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10,30, 24*60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01d, 0.01d, null, PumpCapability.VirtualPumpCapabilities), //
|
0.01d, 0.01d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Cellnovo
|
// Cellnovo
|
||||||
|
|
||||||
Cellnovo1("Cellnovo", 0.05d, null, //
|
Cellnovo1("Cellnovo", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 24 * 60, 1d, null),
|
new DoseSettings(0.05d, 30, 24*60, 1d, null),
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(5, 30, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(5,30, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), //
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Accu-Chek
|
// Accu-Chek
|
||||||
|
|
||||||
AccuChekCombo("Accu-Chek Combo", 0.1d, null, //
|
AccuChekCombo("Accu-Chek Combo", 0.1d, null, //
|
||||||
new DoseSettings(0.1d, 15, 12 * 60, 0.1d), //
|
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01d, 0.01d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
0.01d, 0.01d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
||||||
|
|
||||||
AccuChekSpirit("Accu-Chek Spirit", 0.1d, null, //
|
AccuChekSpirit("Accu-Chek Spirit", 0.1d, null, //
|
||||||
new DoseSettings(0.1d, 15, 12 * 60, 0.1d), //
|
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities), //
|
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
AccuChekInsight("Accu-Chek Insight", 0.05d, DoseStepSize.InsightBolus, //
|
AccuChekInsight("Accu-Chek Insight", 0.05d, DoseStepSize.InsightBolus, //
|
||||||
new DoseSettings(0.05d, 15, 24 * 60, 0.05d), //
|
new DoseSettings(0.05d, 15, 24*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 24*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.02d, 0.01d, null, PumpCapability.InsightCapabilities), //
|
0.02d, 0.01d, null, PumpCapability.InsightCapabilities), //
|
||||||
|
|
||||||
AccuChekInsightBluetooth("Accu-Chek Insight", 0.01d, null, //
|
AccuChekInsightBluetooth("Accu-Chek Insight", 0.01d, null, //
|
||||||
new DoseSettings(0.01d, 15, 24 * 60, 0.05d), //
|
new DoseSettings(0.01d, 15, 24*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 24*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities), //
|
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities), //
|
||||||
|
|
||||||
// Animas
|
// Animas
|
||||||
AnimasVibe("Animas Vibe", 0.05d, null, // AnimasBolus?
|
AnimasVibe("Animas Vibe", 0.05d, null, // AnimasBolus?
|
||||||
new DoseSettings(0.05d, 30, 12 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 12*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10, 30, 24 * 60, 0d, 300d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(10, 30, 24*60, 0d, 300d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities), //
|
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
AnimasPing("Animas Ping", AnimasVibe),
|
AnimasPing("Animas Ping", AnimasVibe),
|
||||||
|
|
||||||
// Dana
|
// Dana
|
||||||
DanaR("DanaR", 0.05d, null, //
|
DanaR("DanaR", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||||
0.04d, 0.01d, null, PumpCapability.DanaCapabilities),
|
0.04d, 0.01d, null, PumpCapability.DanaCapabilities),
|
||||||
|
|
||||||
DanaRKorean("DanaR Korean", 0.05d, null, //
|
DanaRKorean("DanaR Korean", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||||
0.1d, 0.01d, null, PumpCapability.DanaCapabilities),
|
0.1d, 0.01d, null, PumpCapability.DanaCapabilities),
|
||||||
|
|
||||||
DanaRS("DanaRS", 0.05d, null, //
|
DanaRS("DanaRS", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.04d, 0.01d, null, PumpCapability.DanaWithHistoryCapabilities),
|
0.04d, 0.01d, null, PumpCapability.DanaWithHistoryCapabilities),
|
||||||
|
|
||||||
DanaRv2("DanaRv2", DanaRS),
|
DanaRv2("DanaRv2", DanaRS),
|
||||||
|
@ -90,40 +91,40 @@ public enum PumpType {
|
||||||
|
|
||||||
// Insulet
|
// Insulet
|
||||||
Insulet_Omnipod("Insulet Omnipod", 0.05d, null, //
|
Insulet_Omnipod("Insulet Omnipod", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
new DoseSettings(0.05d, 30, 12*60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
||||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
||||||
|
|
||||||
// Medtronic
|
// Medtronic
|
||||||
Medtronic_512_712("Medtronic 512/712", 0.05d, null, //
|
Medtronic_512_712("Medtronic 512/712", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05d, 0.05d, null, PumpCapability.MedtronicCapabilities), // TODO
|
0.05d, 0.05d, null, PumpCapability.MedtronicCapabilities), //
|
||||||
|
|
||||||
Medtronic_515_715("Medtronic 515/715", Medtronic_512_712),
|
Medtronic_515_715("Medtronic 515/715", Medtronic_512_712),
|
||||||
Medtronic_522_722("Medtronic 522/722", Medtronic_512_712),
|
Medtronic_522_722("Medtronic 522/722", Medtronic_512_712),
|
||||||
|
|
||||||
Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", 0.05d, null, //
|
Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.MedtronicCapabilities), //
|
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.MedtronicCapabilities), //
|
||||||
|
|
||||||
Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", Medtronic_523_723_Revel), // TODO
|
Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", Medtronic_523_723_Revel), // TODO
|
||||||
|
|
||||||
Medtronic_640G("Medtronic 640G", 0.025d, null, //
|
Medtronic_640G("Medtronic 640G", 0.025d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Tandem
|
// Tandem
|
||||||
TandemTSlim("Tandem t:slim", 0.01d, null, //
|
TandemTSlim("Tandem t:slim", 0.01d, null, //
|
||||||
new DoseSettings(0.01d, 15, 8 * 60, 0.4d),
|
new DoseSettings(0.01d,15, 8*60, 0.4d),
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(1, 15, 8 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(1,15, 8*60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities),
|
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities),
|
||||||
|
|
||||||
TandemTFlex("Tandem t:flex", TandemTSlim), //
|
TandemTFlex("Tandem t:flex", TandemTSlim), //
|
||||||
|
@ -145,9 +146,10 @@ public enum PumpType {
|
||||||
private PumpCapability pumpCapability;
|
private PumpCapability pumpCapability;
|
||||||
|
|
||||||
private PumpType parent;
|
private PumpType parent;
|
||||||
private static Map<String, PumpType> mapByDescription;
|
private static Map<String,PumpType> mapByDescription;
|
||||||
|
|
||||||
static {
|
static
|
||||||
|
{
|
||||||
mapByDescription = new HashMap<>();
|
mapByDescription = new HashMap<>();
|
||||||
|
|
||||||
for (PumpType pumpType : values()) {
|
for (PumpType pumpType : values()) {
|
||||||
|
@ -156,13 +158,14 @@ public enum PumpType {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PumpType(String description, PumpType parent) {
|
PumpType(String description, PumpType parent)
|
||||||
|
{
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
PumpType(String description, PumpType parent, PumpCapability pumpCapability) {
|
PumpType(String description, PumpType parent, PumpCapability pumpCapability)
|
||||||
|
{
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.pumpCapability = pumpCapability;
|
this.pumpCapability = pumpCapability;
|
||||||
|
@ -170,17 +173,17 @@ public enum PumpType {
|
||||||
|
|
||||||
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
|
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
|
||||||
DoseSettings extendedBolusSettings, //
|
DoseSettings extendedBolusSettings, //
|
||||||
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
||||||
double baseBasalMinValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) {
|
double baseBasalMinValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability)
|
||||||
|
{
|
||||||
this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability);
|
this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability);
|
||||||
}
|
}
|
||||||
|
|
||||||
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
|
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
|
||||||
DoseSettings extendedBolusSettings, //
|
DoseSettings extendedBolusSettings, //
|
||||||
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
||||||
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) {
|
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability)
|
||||||
|
{
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.bolusSize = bolusSize;
|
this.bolusSize = bolusSize;
|
||||||
this.specialBolusSize = specialBolusSize;
|
this.specialBolusSize = specialBolusSize;
|
||||||
|
@ -197,7 +200,6 @@ public enum PumpType {
|
||||||
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,76 +212,69 @@ public enum PumpType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getBolusSize() {
|
public double getBolusSize() {
|
||||||
|
|
||||||
return isParentSet() ? parent.bolusSize : bolusSize;
|
return isParentSet() ? parent.bolusSize : bolusSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DoseStepSize getSpecialBolusSize() {
|
public DoseStepSize getSpecialBolusSize() {
|
||||||
|
|
||||||
return isParentSet() ? parent.specialBolusSize : specialBolusSize;
|
return isParentSet() ? parent.specialBolusSize : specialBolusSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DoseSettings getExtendedBolusSettings() {
|
public DoseSettings getExtendedBolusSettings() {
|
||||||
|
|
||||||
return isParentSet() ? parent.extendedBolusSettings : extendedBolusSettings;
|
return isParentSet() ? parent.extendedBolusSettings : extendedBolusSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpTempBasalType getPumpTempBasalType() {
|
public PumpTempBasalType getPumpTempBasalType() {
|
||||||
|
|
||||||
return isParentSet() ? parent.pumpTempBasalType : pumpTempBasalType;
|
return isParentSet() ? parent.pumpTempBasalType : pumpTempBasalType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DoseSettings getTbrSettings() {
|
public DoseSettings getTbrSettings() {
|
||||||
|
|
||||||
return isParentSet() ? parent.tbrSettings : tbrSettings;
|
return isParentSet() ? parent.tbrSettings : tbrSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getBaseBasalMinValue() {
|
public double getBaseBasalMinValue() {
|
||||||
|
|
||||||
return isParentSet() ? parent.baseBasalMinValue : baseBasalMinValue;
|
return isParentSet() ? parent.baseBasalMinValue : baseBasalMinValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Double getBaseBasalMaxValue() {
|
public Double getBaseBasalMaxValue() {
|
||||||
|
|
||||||
return isParentSet() ? parent.baseBasalMaxValue : baseBasalMaxValue;
|
return isParentSet() ? parent.baseBasalMaxValue : baseBasalMaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getBaseBasalStep() {
|
public double getBaseBasalStep() {
|
||||||
|
|
||||||
return isParentSet() ? parent.baseBasalStep : baseBasalStep;
|
return isParentSet() ? parent.baseBasalStep : baseBasalStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DoseStepSize getBaseBasalSpecialSteps() {
|
public DoseStepSize getBaseBasalSpecialSteps() {
|
||||||
|
|
||||||
return isParentSet() ? parent.baseBasalSpecialSteps : baseBasalSpecialSteps;
|
return isParentSet() ? parent.baseBasalSpecialSteps : baseBasalSpecialSteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpType getParent() {
|
public PumpType getParent() {
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isParentSet() {
|
private boolean isParentSet()
|
||||||
|
{
|
||||||
return this.parent != null;
|
return this.parent!=null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static PumpType getByDescription(String desc) {
|
public static PumpType getByDescription(String desc)
|
||||||
|
{
|
||||||
if (mapByDescription.containsKey(desc)) {
|
if (mapByDescription.containsKey(desc))
|
||||||
|
{
|
||||||
return mapByDescription.get(desc);
|
return mapByDescription.get(desc);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return PumpType.GenericAAPS;
|
return PumpType.GenericAAPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,7 +282,7 @@ public enum PumpType {
|
||||||
|
|
||||||
public String getFullDescription(String i18nTemplate, boolean hasExtendedBasals) {
|
public String getFullDescription(String i18nTemplate, boolean hasExtendedBasals) {
|
||||||
|
|
||||||
String unit = getPumpTempBasalType() == PumpTempBasalType.Percent ? "%" : "";
|
String unit = getPumpTempBasalType()==PumpTempBasalType.Percent ? "%" : "";
|
||||||
|
|
||||||
DoseSettings eb = getExtendedBolusSettings();
|
DoseSettings eb = getExtendedBolusSettings();
|
||||||
DoseSettings tbr = getTbrSettings();
|
DoseSettings tbr = getTbrSettings();
|
||||||
|
@ -296,24 +291,24 @@ public enum PumpType {
|
||||||
|
|
||||||
return String.format(i18nTemplate, //
|
return String.format(i18nTemplate, //
|
||||||
getStep("" + getBolusSize(), getSpecialBolusSize()), //
|
getStep("" + getBolusSize(), getSpecialBolusSize()), //
|
||||||
eb.getStep(), eb.getDurationStep(), eb.getMaxDuration() / 60, //
|
eb.getStep(), eb.getDurationStep(), eb.getMaxDuration()/60, //
|
||||||
getStep(getBaseBasalRange(), getBaseBasalSpecialSteps()), //
|
getStep(getBaseBasalRange(), getBaseBasalSpecialSteps()), //
|
||||||
tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit,
|
tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit,
|
||||||
tbr.getDurationStep(), tbr.getMaxDuration() / 60, extendedNote);
|
tbr.getDurationStep(), tbr.getMaxDuration()/60, extendedNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getBaseBasalRange() {
|
private String getBaseBasalRange()
|
||||||
|
{
|
||||||
Double maxValue = getBaseBasalMaxValue();
|
Double maxValue = getBaseBasalMaxValue();
|
||||||
|
|
||||||
return maxValue == null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue;
|
return maxValue==null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getStep(String step, DoseStepSize stepSize) {
|
private String getStep(String step, DoseStepSize stepSize)
|
||||||
|
{
|
||||||
if (stepSize != null)
|
if (stepSize!=null)
|
||||||
return step + " [" + stepSize.getDescription() + "] *";
|
return step + " [" + stepSize.getDescription() + "] *";
|
||||||
else
|
else
|
||||||
return "" + step;
|
return "" + step;
|
||||||
|
@ -321,23 +316,24 @@ public enum PumpType {
|
||||||
|
|
||||||
|
|
||||||
public boolean hasExtendedBasals() {
|
public boolean hasExtendedBasals() {
|
||||||
|
return ((getBaseBasalSpecialSteps() !=null) || (getSpecialBolusSize() != null));
|
||||||
return ((getBaseBasalSpecialSteps() != null) || (getSpecialBolusSize() != null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpCapability getSpecialBasalDurations() {
|
public PumpCapability getSpecialBasalDurations() {
|
||||||
|
|
||||||
if (isParentSet()) {
|
if (isParentSet())
|
||||||
|
{
|
||||||
return parent.getSpecialBasalDurations();
|
return parent.getSpecialBasalDurations();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return specialBasalDurations == null ? //
|
return specialBasalDurations == null ? //
|
||||||
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
|
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double determineCorrectBolusSize(double bolusAmount) {
|
public double determineCorrectBolusSize(double bolusAmount) {
|
||||||
|
|
||||||
if (bolusAmount == 0.0d) {
|
if (bolusAmount == 0.0d) {
|
||||||
return bolusAmount;
|
return bolusAmount;
|
||||||
}
|
}
|
||||||
|
@ -349,7 +345,7 @@ public enum PumpType {
|
||||||
} else {
|
} else {
|
||||||
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
||||||
|
|
||||||
bolusStepSize = specialBolusSize.getStepSizeForAmount((double) bolusAmount);
|
bolusStepSize = specialBolusSize.getStepSizeForAmount((double)bolusAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
||||||
|
@ -357,7 +353,6 @@ public enum PumpType {
|
||||||
|
|
||||||
|
|
||||||
public double determineCorrectExtendedBolusSize(double bolusAmount) {
|
public double determineCorrectExtendedBolusSize(double bolusAmount) {
|
||||||
|
|
||||||
if (bolusAmount == 0.0d) {
|
if (bolusAmount == 0.0d) {
|
||||||
return bolusAmount;
|
return bolusAmount;
|
||||||
}
|
}
|
||||||
|
@ -381,7 +376,6 @@ public enum PumpType {
|
||||||
|
|
||||||
|
|
||||||
public double determineCorrectBasalSize(double basalAmount) {
|
public double determineCorrectBasalSize(double basalAmount) {
|
||||||
|
|
||||||
if (basalAmount == 0.0d) {
|
if (basalAmount == 0.0d) {
|
||||||
return basalAmount;
|
return basalAmount;
|
||||||
}
|
}
|
||||||
|
@ -402,4 +396,4 @@ public enum PumpType {
|
||||||
return Math.round(basalAmount / basalStepSize) * basalStepSize;
|
return Math.round(basalAmount / basalStepSize) * basalStepSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.BolusProgressDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.BolusProgressDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.BolusProgressDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.BolusProgressDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||||
|
|
|
@ -26,8 +26,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.BolusProgressDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.BolusProgressDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
|
|
|
@ -26,8 +26,8 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.BolusProgressDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.BolusProgressDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
|
|
|
@ -21,9 +21,11 @@ import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
@ -40,7 +42,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.MessageHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.MessageHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
|
@ -69,6 +71,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtro
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -552,6 +555,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
pumpState = PumpDriverState.Initialized;
|
pumpState = PumpDriverState.Initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME andy!!!
|
||||||
// MainApp.getFirebaseAnalytics().logCustomEvent(FirebaseAnalytics.Event.SELECT_CONTENT, event);
|
// MainApp.getFirebaseAnalytics().logCustomEvent(FirebaseAnalytics.Event.SELECT_CONTENT, event);
|
||||||
//
|
//
|
||||||
// FabricPrivacy.getInstance().logCustom( //
|
// FabricPrivacy.getInstance().logCustom( //
|
||||||
|
|
|
@ -22,7 +22,6 @@ import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TDD;
|
import info.nightscout.androidaps.db.TDD;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.configBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||||
|
@ -655,39 +654,39 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
boolean old = false;
|
boolean old = false;
|
||||||
|
|
||||||
if (old) {
|
// if (old) {
|
||||||
treatment.insulin = bolusDTO.getDeliveredAmount();
|
// treatment.insulin = bolusDTO.getDeliveredAmount();
|
||||||
treatment.pumpId = bolus.getPumpId();
|
// treatment.pumpId = bolus.getPumpId();
|
||||||
treatment.source = Source.PUMP;
|
// treatment.source = Source.PUMP;
|
||||||
|
//
|
||||||
|
// bolus.setLinkedObject(treatment);
|
||||||
|
//
|
||||||
|
// TreatmentsPlugin.getPlugin().getService().createOrUpdate(treatment);
|
||||||
|
//
|
||||||
|
// LOG.debug("editBolus - [date={},pumpId={}, insulin={}]", treatment.date, treatment.pumpId,
|
||||||
|
// treatment.insulin);
|
||||||
|
//
|
||||||
|
// MainApp.bus().post(new EventTreatmentChange(treatment));
|
||||||
|
// } else {
|
||||||
|
|
||||||
bolus.setLinkedObject(treatment);
|
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(treatment.date);
|
||||||
|
if (detailedBolusInfo == null) {
|
||||||
TreatmentsPlugin.getPlugin().getService().createOrUpdate(treatment);
|
detailedBolusInfo = new DetailedBolusInfo();
|
||||||
|
|
||||||
LOG.debug("editBolus - [date={},pumpId={}, insulin={}]", treatment.date, treatment.pumpId,
|
|
||||||
treatment.insulin);
|
|
||||||
|
|
||||||
MainApp.bus().post(new EventTreatmentChange(treatment));
|
|
||||||
} else {
|
|
||||||
|
|
||||||
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(treatment.date);
|
|
||||||
if (detailedBolusInfo == null) {
|
|
||||||
detailedBolusInfo = new DetailedBolusInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
detailedBolusInfo.date = treatment.date;
|
|
||||||
detailedBolusInfo.source = Source.PUMP;
|
|
||||||
detailedBolusInfo.pumpId = bolus.getPumpId();
|
|
||||||
detailedBolusInfo.insulin = bolusDTO.getDeliveredAmount();
|
|
||||||
|
|
||||||
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
|
||||||
|
|
||||||
bolus.setLinkedObject(detailedBolusInfo);
|
|
||||||
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
LOG.debug("editBolus - [date={},pumpId={}, insulin={}, newRecord={}]", detailedBolusInfo.date,
|
|
||||||
detailedBolusInfo.pumpId, detailedBolusInfo.insulin, newRecord);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detailedBolusInfo.date = treatment.date;
|
||||||
|
detailedBolusInfo.source = Source.PUMP;
|
||||||
|
detailedBolusInfo.pumpId = bolus.getPumpId();
|
||||||
|
detailedBolusInfo.insulin = bolusDTO.getDeliveredAmount();
|
||||||
|
|
||||||
|
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||||
|
|
||||||
|
bolus.setLinkedObject(detailedBolusInfo);
|
||||||
|
|
||||||
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
|
LOG.debug("editBolus - [date={},pumpId={}, insulin={}, newRecord={}]", detailedBolusInfo.date,
|
||||||
|
detailedBolusInfo.pumpId, detailedBolusInfo.insulin, newRecord);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.virtual;
|
package info.nightscout.androidaps.plugins.pump.virtual;
|
||||||
|
|
||||||
import java.util.List;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import android.os.SystemClock;
|
import java.util.List;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
@ -41,11 +41,11 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger(L.PUMP);
|
private Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
|
||||||
Integer batteryPercent = 50;
|
Integer batteryPercent = 50;
|
||||||
|
@ -56,12 +56,16 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
private long lastDataTime = 0;
|
private long lastDataTime = 0;
|
||||||
private PumpDescription pumpDescription = new PumpDescription();
|
private PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
|
|
||||||
public VirtualPumpPlugin() {
|
public VirtualPumpPlugin() {
|
||||||
super(new PluginDescription().mainType(PluginType.PUMP).fragmentClass(VirtualPumpFragment.class.getName())
|
super(new PluginDescription()
|
||||||
.pluginName(R.string.virtualpump).shortName(R.string.virtualpump_shortname)
|
.mainType(PluginType.PUMP)
|
||||||
.preferencesId(R.xml.pref_virtualpump).neverVisible(Config.NSCLIENT)
|
.fragmentClass(VirtualPumpFragment.class.getName())
|
||||||
.description(R.string.description_pump_virtual));
|
.pluginName(R.string.virtualpump)
|
||||||
|
.shortName(R.string.virtualpump_shortname)
|
||||||
|
.preferencesId(R.xml.pref_virtualpump)
|
||||||
|
.neverVisible(Config.NSCLIENT)
|
||||||
|
.description(R.string.description_pump_virtual)
|
||||||
|
);
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
pumpDescription.bolusStep = 0.1d;
|
pumpDescription.bolusStep = 0.1d;
|
||||||
|
|
||||||
|
@ -81,6 +85,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
pumpDescription.tempDurationStep30mAllowed = true;
|
pumpDescription.tempDurationStep30mAllowed = true;
|
||||||
pumpDescription.tempMaxDuration = 24 * 60;
|
pumpDescription.tempMaxDuration = 24 * 60;
|
||||||
|
|
||||||
|
|
||||||
pumpDescription.isSetBasalProfileCapable = true;
|
pumpDescription.isSetBasalProfileCapable = true;
|
||||||
pumpDescription.basalStep = 0.01d;
|
pumpDescription.basalStep = 0.01d;
|
||||||
pumpDescription.basalMinimumRate = 0.01d;
|
pumpDescription.basalMinimumRate = 0.01d;
|
||||||
|
@ -91,7 +96,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
pumpDescription.is30minBasalRatesCapable = true;
|
pumpDescription.is30minBasalRatesCapable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static VirtualPumpPlugin getPlugin() {
|
public static VirtualPumpPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
plugin = new VirtualPumpPlugin();
|
plugin = new VirtualPumpPlugin();
|
||||||
|
@ -99,23 +103,19 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void loadFakingStatus() {
|
private void loadFakingStatus() {
|
||||||
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, false);
|
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean getFakingStatus() {
|
public boolean getFakingStatus() {
|
||||||
return fromNSAreCommingFakedExtendedBoluses;
|
return fromNSAreCommingFakedExtendedBoluses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setFakingStatus(boolean newStatus) {
|
public void setFakingStatus(boolean newStatus) {
|
||||||
fromNSAreCommingFakedExtendedBoluses = newStatus;
|
fromNSAreCommingFakedExtendedBoluses = newStatus;
|
||||||
SP.putBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, fromNSAreCommingFakedExtendedBoluses);
|
SP.putBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, fromNSAreCommingFakedExtendedBoluses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
@ -123,86 +123,72 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
refreshConfiguration();
|
refreshConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventPreferenceChange s) {
|
public void onStatusEvent(final EventPreferenceChange s) {
|
||||||
if (s.isChanged(R.string.key_virtualpump_type))
|
if (s.isChanged(R.string.key_virtualpump_type))
|
||||||
refreshConfiguration();
|
refreshConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFakingTempsByExtendedBoluses() {
|
public boolean isFakingTempsByExtendedBoluses() {
|
||||||
return (Config.NSCLIENT) && fromNSAreCommingFakedExtendedBoluses;
|
return (Config.NSCLIENT) && fromNSAreCommingFakedExtendedBoluses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult loadTDDs() {
|
public PumpEnactResult loadTDDs() {
|
||||||
// no result, could read DB in the future?
|
//no result, could read DB in the future?
|
||||||
return new PumpEnactResult();
|
return new PumpEnactResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CustomAction> getCustomActions() {
|
public List<CustomAction> getCustomActions() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeCustomAction(CustomActionType customActionType) {
|
public void executeCustomAction(CustomActionType customActionType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInitialized() {
|
public boolean isInitialized() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBusy() {
|
public boolean isBusy() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConnecting() {
|
public boolean isConnecting() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isHandshakeInProgress() {
|
public boolean isHandshakeInProgress() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finishHandshaking() {
|
public void finishHandshaking() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(String reason) {
|
public void connect(String reason) {
|
||||||
if (!Config.NSCLIENT)
|
if (!Config.NSCLIENT)
|
||||||
|
@ -210,48 +196,40 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
lastDataTime = System.currentTimeMillis();
|
lastDataTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect(String reason) {
|
public void disconnect(String reason) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopConnecting() {
|
public void stopConnecting() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getPumpStatus() {
|
public void getPumpStatus() {
|
||||||
lastDataTime = System.currentTimeMillis();
|
lastDataTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
||||||
lastDataTime = System.currentTimeMillis();
|
lastDataTime = System.currentTimeMillis();
|
||||||
// Do nothing here. we are using ConfigBuilderPlugin.getPlugin().getActiveProfile().getProfile();
|
// Do nothing here. we are using ConfigBuilderPlugin.getPlugin().getActiveProfile().getProfile();
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok),
|
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
||||||
Notification.INFO, 60);
|
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isThisProfileSet(Profile profile) {
|
public boolean isThisProfileSet(Profile profile) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long lastDataTime() {
|
public long lastDataTime() {
|
||||||
return lastDataTime;
|
return lastDataTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseBasalRate() {
|
public double getBaseBasalRate() {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
|
@ -263,16 +241,10 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getReservoirLevel() {
|
public double getReservoirLevel() { return reservoirInUnits; }
|
||||||
return reservoirInUnits;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryLevel() {
|
public int getBatteryLevel() { return batteryPercent; }
|
||||||
return batteryPercent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
|
@ -290,7 +262,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
SystemClock.sleep(200);
|
SystemClock.sleep(200);
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||||
bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), delivering);
|
bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), delivering);
|
||||||
bolusingEvent.percent = Math.min((int)(delivering / detailedBolusInfo.insulin * 100), 100);
|
bolusingEvent.percent = Math.min((int) (delivering / detailedBolusInfo.insulin * 100), 100);
|
||||||
MainApp.bus().post(bolusingEvent);
|
MainApp.bus().post(bolusingEvent);
|
||||||
delivering += 0.1d;
|
delivering += 0.1d;
|
||||||
}
|
}
|
||||||
|
@ -301,26 +273,25 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
MainApp.bus().post(bolusingEvent);
|
MainApp.bus().post(bolusingEvent);
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: "
|
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
||||||
+ detailedBolusInfo.carbs + "g " + result);
|
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
lastDataTime = System.currentTimeMillis();
|
lastDataTime = System.currentTimeMillis();
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopBolusDelivering() {
|
public void stopBolusDelivering() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile,
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
boolean enforceNew) {
|
|
||||||
|
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal().date(System.currentTimeMillis()).absolute(absoluteRate)
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
.duration(durationInMinutes).source(Source.USER);
|
.date(System.currentTimeMillis())
|
||||||
|
.absolute(absoluteRate)
|
||||||
|
.duration(durationInMinutes)
|
||||||
|
.source(Source.USER);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
@ -336,12 +307,13 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile,
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
boolean enforceNew) {
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal().date(System.currentTimeMillis()).percent(percent)
|
.date(System.currentTimeMillis())
|
||||||
.duration(durationInMinutes).source(Source.USER);
|
.percent(percent)
|
||||||
|
.duration(durationInMinutes)
|
||||||
|
.source(Source.USER);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
@ -358,15 +330,17 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
PumpEnactResult result = cancelExtendedBolus();
|
PumpEnactResult result = cancelExtendedBolus();
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus().date(System.currentTimeMillis()).insulin(insulin)
|
ExtendedBolus extendedBolus = new ExtendedBolus()
|
||||||
.durationInMinutes(durationInMinutes).source(Source.USER);
|
.date(System.currentTimeMillis())
|
||||||
|
.insulin(insulin)
|
||||||
|
.durationInMinutes(durationInMinutes)
|
||||||
|
.source(Source.USER);
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.bolusDelivered = insulin;
|
result.bolusDelivered = insulin;
|
||||||
|
@ -381,7 +355,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean force) {
|
public PumpEnactResult cancelTempBasal(boolean force) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -392,7 +365,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
// tempBasal = null;
|
//tempBasal = null;
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
log.debug("Canceling temp basal: " + result);
|
log.debug("Canceling temp basal: " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
|
@ -401,7 +374,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelExtendedBolus() {
|
public PumpEnactResult cancelExtendedBolus() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -421,7 +393,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
@ -465,30 +436,25 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
return pump;
|
return pump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String deviceID() {
|
public String deviceID() {
|
||||||
return "VirtualPump";
|
return "VirtualPump";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpDescription getPumpDescription() {
|
public PumpDescription getPumpDescription() {
|
||||||
return pumpDescription;
|
return pumpDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String shortStatus(boolean veryShort) {
|
public String shortStatus(boolean veryShort) {
|
||||||
return "Virtual Pump";
|
return "Virtual Pump";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpType getPumpType() {
|
public PumpType getPumpType() {
|
||||||
return pumpType;
|
return pumpType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canHandleDST() {
|
public boolean canHandleDST() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -515,4 +481,4 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments;
|
package info.nightscout.androidaps.plugins.treatments;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
@ -28,7 +28,6 @@ import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
|
|
||||||
@DatabaseTable(tableName = Treatment.TABLE_TREATMENTS)
|
@DatabaseTable(tableName = Treatment.TABLE_TREATMENTS)
|
||||||
public class Treatment implements DataPointWithLabelInterface {
|
public class Treatment implements DataPointWithLabelInterface {
|
||||||
|
|
||||||
public static final String TABLE_TREATMENTS = "Treatments";
|
public static final String TABLE_TREATMENTS = "Treatments";
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
|
@ -61,22 +60,20 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public String boluscalc;
|
public String boluscalc;
|
||||||
|
|
||||||
|
|
||||||
public Treatment() {
|
public Treatment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Treatment createFromJson(JSONObject json) throws JSONException {
|
public static Treatment createFromJson(JSONObject json) throws JSONException {
|
||||||
Treatment treatment = new Treatment();
|
Treatment treatment = new Treatment();
|
||||||
treatment.source = Source.NIGHTSCOUT;
|
treatment.source = Source.NIGHTSCOUT;
|
||||||
treatment.date = DateUtil.roundDateToSec(JsonHelper.safeGetLong(json, "mills"));
|
treatment.date = DateUtil.roundDateToSec(JsonHelper.safeGetLong(json, "mills"));
|
||||||
if (treatment.date == 0L)
|
if (treatment.date == 0L)
|
||||||
return null;
|
return null;
|
||||||
treatment.carbs = JsonHelper.safeGetDouble(json, "carbs");
|
treatment.carbs = JsonHelper.safeGetDouble(json,"carbs");
|
||||||
treatment.insulin = JsonHelper.safeGetDouble(json, "insulin");
|
treatment.insulin = JsonHelper.safeGetDouble(json,"insulin");
|
||||||
treatment.pumpId = JsonHelper.safeGetLong(json, "pumpId");
|
treatment.pumpId = JsonHelper.safeGetLong(json, "pumpId");
|
||||||
treatment._id = json.getString("_id");
|
treatment._id = json.getString("_id");
|
||||||
treatment.isSMB = JsonHelper.safeGetBoolean(json, "isSMB");
|
treatment.isSMB = JsonHelper.safeGetBoolean(json,"isSMB");
|
||||||
if (json.has("eventType")) {
|
if (json.has("eventType")) {
|
||||||
treatment.mealBolus = !json.get("eventType").equals("Correction Bolus");
|
treatment.mealBolus = !json.get("eventType").equals("Correction Bolus");
|
||||||
double carbs = treatment.carbs;
|
double carbs = treatment.carbs;
|
||||||
|
@ -93,14 +90,21 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return treatment;
|
return treatment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Treatment{" + "date= " + date + ", date= " + new Date(date).toLocaleString() + ", isValid= " + isValid
|
return "Treatment{" +
|
||||||
+ ", isSMB= " + isSMB + ", _id= " + _id + ", pumpId= " + pumpId + ", insulin= " + insulin + ", carbs= "
|
"date= " + date +
|
||||||
+ carbs + ", mealBolus= " + mealBolus + "}";
|
", date= " + new Date(date).toLocaleString() +
|
||||||
|
", isValid= " + isValid +
|
||||||
|
", isSMB= " + isSMB +
|
||||||
|
", _id= " + _id +
|
||||||
|
", pumpId= " + pumpId +
|
||||||
|
", insulin= " + insulin +
|
||||||
|
", carbs= " + carbs +
|
||||||
|
", mealBolus= " + mealBolus +
|
||||||
|
", source= " + source +
|
||||||
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isDataChanging(Treatment other) {
|
public boolean isDataChanging(Treatment other) {
|
||||||
if (date != other.date)
|
if (date != other.date)
|
||||||
return true;
|
return true;
|
||||||
|
@ -111,7 +115,6 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isEqual(Treatment other) {
|
public boolean isEqual(Treatment other) {
|
||||||
if (date != other.date)
|
if (date != other.date)
|
||||||
return false;
|
return false;
|
||||||
|
@ -130,6 +133,22 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEqualWithoutPumpId(Treatment other) {
|
||||||
|
if (date != other.date)
|
||||||
|
return false;
|
||||||
|
if (insulin != other.insulin)
|
||||||
|
return false;
|
||||||
|
if (carbs != other.carbs)
|
||||||
|
return false;
|
||||||
|
if (mealBolus != other.mealBolus)
|
||||||
|
return false;
|
||||||
|
if (isSMB != other.isSMB)
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(_id, other._id))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JSONObject getBoluscalc() {
|
public JSONObject getBoluscalc() {
|
||||||
|
@ -141,7 +160,6 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mealBolus, _id and isSMB cannot be known coming from pump. Only compare rest
|
* mealBolus, _id and isSMB cannot be known coming from pump. Only compare rest
|
||||||
* TODO: remove debug toasts
|
* TODO: remove debug toasts
|
||||||
|
@ -159,7 +177,6 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void copyFrom(Treatment t) {
|
public void copyFrom(Treatment t) {
|
||||||
date = t.date;
|
date = t.date;
|
||||||
_id = t._id;
|
_id = t._id;
|
||||||
|
@ -170,7 +187,6 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
isSMB = t.isSMB;
|
isSMB = t.isSMB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void copyBasics(Treatment t) {
|
public void copyBasics(Treatment t) {
|
||||||
date = t.date;
|
date = t.date;
|
||||||
insulin = t.insulin;
|
insulin = t.insulin;
|
||||||
|
@ -179,8 +195,7 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
source = t.source;
|
source = t.source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------- DataPointInterface --------------------
|
||||||
// ----------------- DataPointInterface --------------------
|
|
||||||
@Override
|
@Override
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return date;
|
return date;
|
||||||
|
@ -189,30 +204,25 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
// default when no sgv around available
|
// default when no sgv around available
|
||||||
private double yValue = 0;
|
private double yValue = 0;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return isSMB ? OverviewPlugin.getPlugin().determineLowLine() : yValue;
|
return isSMB ? OverviewPlugin.getPlugin().determineLowLine() : yValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
String label = "";
|
String label = "";
|
||||||
if (insulin > 0)
|
if (insulin > 0) label += DecimalFormatter.toPumpSupportedBolus(insulin) + "U";
|
||||||
label += DecimalFormatter.toPumpSupportedBolus(insulin) + "U";
|
|
||||||
if (carbs > 0)
|
if (carbs > 0)
|
||||||
label += "~" + DecimalFormatter.to0Decimal(carbs) + "g";
|
label += "~" + DecimalFormatter.to0Decimal(carbs) + "g";
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDuration() {
|
public long getDuration() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PointsWithLabelGraphSeries.Shape getShape() {
|
public PointsWithLabelGraphSeries.Shape getShape() {
|
||||||
if (isSMB)
|
if (isSMB)
|
||||||
|
@ -221,13 +231,11 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return PointsWithLabelGraphSeries.Shape.BOLUS;
|
return PointsWithLabelGraphSeries.Shape.BOLUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSize() {
|
public float getSize() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
if (isSMB)
|
if (isSMB)
|
||||||
|
@ -238,14 +246,12 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return MainApp.instance().getResources().getColor(android.R.color.holo_red_light);
|
return MainApp.instance().getResources().getColor(android.R.color.holo_red_light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setY(double y) {
|
public void setY(double y) {
|
||||||
yValue = y;
|
yValue = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------- DataPointInterface end --------------------
|
||||||
// ----------------- DataPointInterface end --------------------
|
|
||||||
|
|
||||||
public Iob iobCalc(long time, double dia) {
|
public Iob iobCalc(long time, double dia) {
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
|
@ -254,4 +260,4 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
|
InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
|
||||||
return insulinInterface.iobCalcForTreatment(this, time, dia);
|
return insulinInterface.iobCalcForTreatment(this, time, dia);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -242,7 +242,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
try {
|
try {
|
||||||
Treatment treatment = Treatment.createFromJson(json);
|
Treatment treatment = Treatment.createFromJson(json);
|
||||||
if (treatment != null)
|
if (treatment != null)
|
||||||
createOrUpdate(treatment);
|
createOrUpdate(treatment, true);
|
||||||
else
|
else
|
||||||
log.error("Date is null: " + treatment.toString());
|
log.error("Date is null: " + treatment.toString());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -251,7 +251,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if new record is created
|
// return true if new record is created
|
||||||
public UpdateReturn createOrUpdate(Treatment treatment) {
|
public UpdateReturn createOrUpdate(Treatment treatment, boolean fromNightScout) {
|
||||||
try {
|
try {
|
||||||
Treatment old;
|
Treatment old;
|
||||||
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);
|
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);
|
||||||
|
@ -315,11 +315,11 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
if (treatment.source == Source.NIGHTSCOUT) {
|
if (treatment.source == Source.NIGHTSCOUT) {
|
||||||
old = getDao().queryForId(treatment.date);
|
old = getDao().queryForId(treatment.date);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
if (!old.isEqual(treatment)) {
|
if (!old.isEqualWithoutPumpId(treatment)) {
|
||||||
boolean historyChange = old.isDataChanging(treatment);
|
boolean historyChange = old.isDataChanging(treatment);
|
||||||
long oldDate = old.date;
|
long oldDate = old.date;
|
||||||
getDao().delete(old); // need to delete/create because date may change too
|
getDao().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(treatment);
|
treatmentCopy(old, treatment, fromNightScout);
|
||||||
getDao().create(old);
|
getDao().create(old);
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
if (L.isEnabled(L.DATATREATMENTS))
|
||||||
log.debug("Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString());
|
log.debug("Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString());
|
||||||
|
@ -338,11 +338,11 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
if (treatment._id != null) {
|
if (treatment._id != null) {
|
||||||
old = findByNSId(treatment._id);
|
old = findByNSId(treatment._id);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
if (!old.isEqual(treatment)) {
|
if (!old.isEqualWithoutPumpId(treatment)) {
|
||||||
boolean historyChange = old.isDataChanging(treatment);
|
boolean historyChange = old.isDataChanging(treatment);
|
||||||
long oldDate = old.date;
|
long oldDate = old.date;
|
||||||
getDao().delete(old); // need to delete/create because date may change too
|
getDao().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(treatment);
|
treatmentCopy(old, treatment, fromNightScout);
|
||||||
getDao().create(old);
|
getDao().create(old);
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
if (L.isEnabled(L.DATATREATMENTS))
|
||||||
log.debug("Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
|
log.debug("Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
|
||||||
|
@ -379,6 +379,30 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
return new UpdateReturn(false, false);
|
return new UpdateReturn(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void treatmentCopy(Treatment oldTreatment, Treatment newTreatment, boolean fromNightScout) {
|
||||||
|
|
||||||
|
log.debug("treatmentCopy [old={}, new={}]", oldTreatment.toString(), newTreatment.toString());
|
||||||
|
|
||||||
|
if (fromNightScout) {
|
||||||
|
long pumpId_old = oldTreatment.pumpId;
|
||||||
|
oldTreatment.copyFrom(newTreatment);
|
||||||
|
|
||||||
|
if (pumpId_old != 0) {
|
||||||
|
oldTreatment.pumpId = pumpId_old;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldTreatment.pumpId != 0 && oldTreatment.source != Source.PUMP) {
|
||||||
|
oldTreatment.source = Source.PUMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
oldTreatment.copyFrom(newTreatment);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("treatmentCopy [newAfterChange={}]", oldTreatment.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the record for the given id, null if none, throws RuntimeException
|
* Returns the record for the given id, null if none, throws RuntimeException
|
||||||
* if multiple records with the same pump id exist.
|
* if multiple records with the same pump id exist.
|
||||||
|
|
|
@ -43,7 +43,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||||
|
@ -563,7 +563,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
treatment.source = detailedBolusInfo.source;
|
treatment.source = detailedBolusInfo.source;
|
||||||
treatment.mealBolus = treatment.carbs > 0;
|
treatment.mealBolus = treatment.carbs > 0;
|
||||||
treatment.boluscalc = detailedBolusInfo.boluscalc != null ? detailedBolusInfo.boluscalc.toString() : null;
|
treatment.boluscalc = detailedBolusInfo.boluscalc != null ? detailedBolusInfo.boluscalc.toString() : null;
|
||||||
TreatmentService.UpdateReturn creatOrUpdateResult = getService().createOrUpdate(treatment);
|
TreatmentService.UpdateReturn creatOrUpdateResult = getService().createOrUpdate(treatment, false);
|
||||||
boolean newRecordCreated = creatOrUpdateResult.newRecord;
|
boolean newRecordCreated = creatOrUpdateResult.newRecord;
|
||||||
// log.debug("Adding new Treatment record" + treatment.toString());
|
// log.debug("Adding new Treatment record" + treatment.toString());
|
||||||
if (detailedBolusInfo.carbTime != 0) {
|
if (detailedBolusInfo.carbTime != 0) {
|
||||||
|
@ -577,7 +577,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
// records
|
// records
|
||||||
carbsTreatment.carbs = detailedBolusInfo.carbs;
|
carbsTreatment.carbs = detailedBolusInfo.carbs;
|
||||||
carbsTreatment.source = detailedBolusInfo.source;
|
carbsTreatment.source = detailedBolusInfo.source;
|
||||||
getService().createOrUpdate(carbsTreatment);
|
getService().createOrUpdate(carbsTreatment, false);
|
||||||
// log.debug("Adding new Treatment record" + carbsTreatment);
|
// log.debug("Adding new Treatment record" + carbsTreatment);
|
||||||
}
|
}
|
||||||
if (newRecordCreated && detailedBolusInfo.isValid)
|
if (newRecordCreated && detailedBolusInfo.isValid)
|
||||||
|
|
|
@ -23,8 +23,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.BolusProgressDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.BolusProgressDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.BolusProgressHelperActivity;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.BolusProgressHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.Dialogs.BolusProgressDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.BolusProgressDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
|
|
@ -74,7 +74,8 @@ public class FabricPrivacy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean fabricEnabled() {
|
public static boolean fabricEnabled() {
|
||||||
return SP.getBoolean("enable_fabric", true);
|
//return SP.getBoolean("enable_fabric", true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analytics logCustom
|
// Analytics logCustom
|
||||||
|
|
|
@ -53,8 +53,7 @@ public class MedtronicHistoryDataUTest {
|
||||||
RawHistoryPage historyPage = new RawHistoryPage();
|
RawHistoryPage historyPage = new RawHistoryPage();
|
||||||
historyPage.appendData(historyPageData);
|
historyPage.appendData(historyPageData);
|
||||||
|
|
||||||
List<PumpHistoryEntry> pumpHistoryEntries = decoder.processPageAndCreateRecords(historyPage,
|
List<PumpHistoryEntry> pumpHistoryEntries = decoder.processPageAndCreateRecords(historyPage);
|
||||||
PumpHistoryEntry.class);
|
|
||||||
|
|
||||||
System.out.println("PumpHistoryEntries: " + pumpHistoryEntries.size());
|
System.out.println("PumpHistoryEntries: " + pumpHistoryEntries.size());
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ buildscript {
|
||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
maven { url 'https://maven.fabric.io/public' }
|
maven { url 'https://maven.fabric.io/public' }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.0'
|
classpath 'com.android.tools.build:gradle:3.2.0'
|
||||||
classpath 'com.google.gms:google-services:4.2.0'
|
classpath 'com.google.gms:google-services:4.2.0'
|
||||||
|
@ -39,4 +38,4 @@ allprojects {
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
|
@ -1,102 +0,0 @@
|
||||||
apply plugin: 'com.android.application'
|
|
||||||
|
|
||||||
ext {
|
|
||||||
wearableVersion = "2.0.1"
|
|
||||||
playServicesWearable = "16.0.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
def generateGitBuild = { ->
|
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append('"')
|
|
||||||
try {
|
|
||||||
def stdout = new ByteArrayOutputStream()
|
|
||||||
exec {
|
|
||||||
commandLine 'git', 'describe', '--always'
|
|
||||||
standardOutput = stdout
|
|
||||||
}
|
|
||||||
String commitObject = stdout.toString().trim()
|
|
||||||
stringBuilder.append(commitObject)
|
|
||||||
} catch (ignored) {
|
|
||||||
stringBuilder.append('NoGitSystemAvailable')
|
|
||||||
}
|
|
||||||
stringBuilder.append('-')
|
|
||||||
stringBuilder.append((new Date()).format('yyyy.MM.dd'))
|
|
||||||
stringBuilder.append('"')
|
|
||||||
return stringBuilder.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 27
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "info.nightscout.androidaps"
|
|
||||||
minSdkVersion 23
|
|
||||||
targetSdkVersion 23
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0.2"
|
|
||||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
|
||||||
}
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
|
|
||||||
lintOptions {
|
|
||||||
abortOnError false
|
|
||||||
}
|
|
||||||
|
|
||||||
productFlavors {
|
|
||||||
flavorDimensions "standard"
|
|
||||||
full {
|
|
||||||
applicationId "info.nightscout.androidaps"
|
|
||||||
dimension "standard"
|
|
||||||
versionName version
|
|
||||||
}
|
|
||||||
pumpcontrol {
|
|
||||||
applicationId "info.nightscout.aapspumpcontrol"
|
|
||||||
dimension "standard"
|
|
||||||
versionName version + "-pumpcontrol"
|
|
||||||
}
|
|
||||||
nsclient {
|
|
||||||
applicationId "info.nightscout.nsclient"
|
|
||||||
dimension "standard"
|
|
||||||
versionName version + "-nsclient"
|
|
||||||
}
|
|
||||||
nsclient2 {
|
|
||||||
applicationId "info.nightscout.nsclient2"
|
|
||||||
dimension "standard"
|
|
||||||
versionName version + "-nsclient"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
flatDir {
|
|
||||||
dirs 'libs'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
|
||||||
implementation files("libs/hellocharts-library-1.5.5.jar")
|
|
||||||
//compile "com.ustwo.android:clockwise-wearable:1.0.2"
|
|
||||||
compileOnly "com.google.android.wearable:wearable:${wearableVersion}"
|
|
||||||
implementation "com.google.android.support:wearable:${wearableVersion}"
|
|
||||||
implementation "com.google.android.gms:play-services-wearable:${playServicesWearable}"
|
|
||||||
implementation(name:"ustwo-clockwise-debug", ext:"aar")
|
|
||||||
implementation "com.android.support:support-v4:27.0.1"
|
|
||||||
implementation 'com.android.support:wear:27.0.1'
|
|
||||||
implementation "me.denley.wearpreferenceactivity:wearpreferenceactivity:0.5.0"
|
|
||||||
}
|
|
1
wear/build.gradle
Symbolic link
1
wear/build.gradle
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/home/andy/Dropbox/workspaces/aaps/andy_AndroidAPS_Medtronic_Shared/wear/build.gradle
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.interaction.utils;
|
package info.nightscout.androidaps.interaction.utils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,11 +8,9 @@ import java.util.Date;
|
||||||
|
|
||||||
public class WearUtil {
|
public class WearUtil {
|
||||||
|
|
||||||
|
|
||||||
public static String dateTimeText(long timeInMs) {
|
public static String dateTimeText(long timeInMs) {
|
||||||
Date d = new Date(timeInMs);
|
Date d = new Date(timeInMs);
|
||||||
return "" + d.getDay() + "." + d.getMonth() + "." + d.getYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
|
return "" + d.getDay() + "." + d.getMonth() + "." + d.getYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue