diff --git a/app/build.gradle b/app/build.gradle
index 5b6c4ed3d2..c186b2db55 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -109,7 +109,7 @@ android {
defaultConfig {
multiDexEnabled true
versionCode 1500
- version "3.0.0.1-dev-i"
+ version "3.0.0.2-dev-i"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt
index 94e90b2ad6..4303cb179f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt
@@ -602,6 +602,7 @@ class LoopPlugin @Inject constructor(
private fun applySMBRequest(request: APSResult, callback: Callback?) {
if (!request.bolusRequested()) {
+ aapsLogger.debug(LTag.APS, "No SMB requested")
return
}
val pump = activePlugin.activePump
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt
index 0c93f181ad..c4a10f45a6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt
@@ -21,6 +21,7 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
+import info.nightscout.androidaps.diaconn.events.EventDiaconnG8PumpLogReset
import info.nightscout.androidaps.events.EventAppExit
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.ImportExportPrefs
@@ -339,6 +340,7 @@ class ImportExportPrefsImpl @Inject constructor(
}
private fun restartAppAfterImport(context: Context) {
+ rxBus.send(EventDiaconnG8PumpLogReset())
sp.putBoolean(R.string.key_setupwizard_processed, true)
OKDialog.show(context, rh.gs(R.string.setting_imported), rh.gs(R.string.restartingapp)) {
uel.log(Action.IMPORT_SETTINGS, Sources.Maintenance)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt
index 341ea29e8e..a13f3e467e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt
@@ -101,7 +101,7 @@ abstract class InsulinOrefBasePlugin(
return comment
}
- abstract val peak: Int
+ override abstract val peak: Int
abstract fun commentStandardText(): String
companion object {
diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt
index 3ef7501ae4..2e338955d5 100644
--- a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt
+++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt
@@ -17,6 +17,7 @@ interface SkinInterface {
val mainGraphHeight: Int // in dp
val secondaryGraphHeight: Int // in dp
+ // no pre processing by default
fun preProcessLandscapeActionsLayout(dm: DisplayMetrics, binding: ActionsFragmentBinding) {
}
diff --git a/app/src/main/res/drawable/ic_clone_48.xml b/app/src/main/res/drawable/ic_clone_48.xml
index 5156d7525e..33c95d193f 100644
--- a/app/src/main/res/drawable/ic_clone_48.xml
+++ b/app/src/main/res/drawable/ic_clone_48.xml
@@ -4,6 +4,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
+ android:pathData="M20.156,12.76V4.35l-2.588,2.588c-3.811,-3.012 -8.811,-3.261 -11.692,-0.38C2.715,9.719 3.307,15.437 7.2,19.33c0.377,0.377 0.774,0.713 1.181,1.027c-0.483,-0.742 -0.91,-1.573 -1.245,-2.483c-1.569,-4.257 -0.64,-8.518 2.075,-9.519c1.648,-0.607 3.573,0.134 5.184,1.757l-2.648,2.648H20.156z"
+ android:fillColor="#638CE1"/>
diff --git a/app/src/main/res/layout/localprofile_fragment.xml b/app/src/main/res/layout/localprofile_fragment.xml
index f1bd26f410..ff453c53e0 100644
--- a/app/src/main/res/layout/localprofile_fragment.xml
+++ b/app/src/main/res/layout/localprofile_fragment.xml
@@ -302,6 +302,7 @@
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:text="@string/activate_profile"
+ android:visibility="gone"
app:icon="@drawable/ic_local_activate"
app:iconTint="@color/ic_local_activate" />
@@ -323,6 +324,7 @@
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:text="@string/reset"
+ android:visibility="gone"
app:icon="@drawable/ic_local_reset"
app:iconTint="@color/ic_local_reset" />
@@ -338,6 +340,7 @@
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:text="@string/save"
+ android:visibility="gone"
app:icon="@drawable/ic_local_save"
app:iconTint="@color/ic_local_save" />
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ddc9b5e5ad..d2eea647d5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -561,7 +561,6 @@
En
Pr
Fat
- ]]>
Command is executed right now
Missed BG readings
raise_urgent_alarms_as_android_notification
diff --git a/build.gradle b/build.gradle
index ddcd91c207..d2b9b12afb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -59,7 +59,7 @@ buildscript {
plugins {
id "io.gitlab.arturbosch.detekt" version "1.20.0"
- id "org.jlleitschuh.gradle.ktlint" version "10.2.1"
+ id "org.jlleitschuh.gradle.ktlint" version "10.3.0"
id 'org.barfuin.gradle.jacocolog' version '2.0.0'
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
diff --git a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ruffyscripter/RuffyScripter.java b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ruffyscripter/RuffyScripter.java
index f2fcf05bbf..565cf66f70 100644
--- a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ruffyscripter/RuffyScripter.java
+++ b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ruffyscripter/RuffyScripter.java
@@ -70,7 +70,14 @@ public class RuffyScripter implements RuffyCommands {
private final IRTHandler mHandler = new IRTHandler.Stub() {
@Override
public void log(String message) {
- aapsLogger.debug(LTag.PUMP, "Ruffy says: " + message);
+ // Ruffy is very verbose at this level, but the data provided isn't too helpful for
+ // debugging. For debugging Ruffy, it makes more sense to check logcat, where other
+ // possibly relevant (BT) events are also logged.
+ // Due to the amount of calls, logging this causes timing issues as reported in
+ // https://github.com/nightscout/AndroidAPS/issues/1619#issuecomment-1115811485
+ // This was caused by changing the log level from trace to debug so these messages
+ // where logged by default.
+ //aapsLogger.debug(LTag.PUMP, "Ruffy says: " + message);
}
@Override
diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/DetermineBasalAdapterInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/DetermineBasalAdapterInterface.kt
index 4e1ba57422..9b8ed0d9c2 100644
--- a/core/src/main/java/info/nightscout/androidaps/interfaces/DetermineBasalAdapterInterface.kt
+++ b/core/src/main/java/info/nightscout/androidaps/interfaces/DetermineBasalAdapterInterface.kt
@@ -30,7 +30,7 @@ interface DetermineBasalAdapterInterface {
uamAllowed: Boolean = false,
advancedFiltering: Boolean = false,
isSaveCgmSource: Boolean = false
- ) {}
+ )
operator fun invoke(): APSResult?
}
\ No newline at end of file
diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Insulin.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Insulin.kt
index ab3a8296e3..d483553ba1 100644
--- a/core/src/main/java/info/nightscout/androidaps/interfaces/Insulin.kt
+++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Insulin.kt
@@ -27,6 +27,7 @@ interface Insulin : ConfigExportImport {
val friendlyName: String
val comment: String
val dia: Double
+ val peak: Int
fun iobCalcForTreatment(bolus: Bolus, time: Long, dia: Double): Iob
diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt
index d5c31c6043..20d93069a3 100644
--- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt
+++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt
@@ -271,7 +271,7 @@ class PumpSyncImplementation @Inject constructor(
.blockingGet()
.also { result ->
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted TemporaryBasal $it") }
- result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated TemporaryBasal $it") }
+ result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated ${it.first} TemporaryBasal ${it.second}") }
return result.inserted.size > 0
}
}
diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.kt b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.kt
index 2b341f120c..cd59d1413b 100644
--- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.kt
+++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.kt
@@ -316,7 +316,7 @@ enum class PumpType {
baseBasalMaxValue = 3.0,
baseBasalStep = 0.01,
baseBasalSpecialSteps = null,
- pumpCapability = PumpCapability.DanaWithHistoryCapabilities,
+ pumpCapability = PumpCapability.DiaconnCapabilities,
source = Sources.DiaconnG8,
useHardwareLink = true);
diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/NumberPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/NumberPicker.kt
index b4cecb63f1..71d0b7c392 100644
--- a/core/src/main/java/info/nightscout/androidaps/utils/ui/NumberPicker.kt
+++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/NumberPicker.kt
@@ -136,7 +136,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
}
fun updateA11yDescription() {
- val description = if (mCustomContentDescription != null) mCustomContentDescription else ""
+ val description = mCustomContentDescription ?: ""
binding.minusButton.contentDescription = context.getString(R.string.a11y_min_button_description, description, formatter?.format(this.step))
binding.plusButton.contentDescription = context.getString(R.string.a11y_plus_button_description, description, formatter?.format(this.step))
}
diff --git a/core/src/main/res/drawable/ic_autotune.xml b/core/src/main/res/drawable/ic_autotune.xml
new file mode 100644
index 0000000000..99e966ae4b
--- /dev/null
+++ b/core/src/main/res/drawable/ic_autotune.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/core/src/main/res/drawable/ic_danarstats.xml b/core/src/main/res/drawable/ic_danarstats.xml
index 81b3952eb4..a95eef3884 100644
--- a/core/src/main/res/drawable/ic_danarstats.xml
+++ b/core/src/main/res/drawable/ic_danarstats.xml
@@ -7,24 +7,24 @@
android:pathData="M5.719,19.125L5.719,11.828"
android:strokeWidth="2.2677"
android:fillColor="#00000000"
- android:strokeColor="#FEAF05"
+ android:strokeColor="?attr/statsColor"
android:strokeLineCap="round"/>
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 0038c50eab..fc94c704ef 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -65,6 +65,14 @@
pregnant
app_expiration
use_dark_mode
+ insulin_oref_peak
+ autotune_auto
+ categorize_uam_as_basal
+ autotune_default_tune_days
+ autotune_circadian_ic_isf
+ autotune_additional_log
+ key_autotune_plugin
+ key_autotune_last_run
Refresh
@@ -107,6 +115,7 @@
Carbs
Invalid profile !!!
NO PROFILE SET
+ ]]>
Date
Units
DIA
@@ -536,6 +545,58 @@
file
user
+
+ Autotune
+ Help for potential adjustments of profile (ISF, carb ratio, and basal rates)
+ AT
+ Autotune settings
+ Automation Switch Profile
+ If enabled, Autotune will automatically update and switch to input profile after calculation from an automation rule.
+ Categorize UAM as basal
+ Enable only if you have reliably entered all carbs eaten, with this option sudden rises seen by Autotune will be used to recommend changes to the basal rate.
+ Number of days of data
+ Apply average result in circadian IC/ISF
+ Autotune will not tune circadian variations, this option only apply the average tuning of IC and ISF to your circadian input profile
+ Include more log information for debugging
+ Switch on only if requested by dev to send more log information to help debugging Autotune plugin
+ Default number of days of data to be processed by Autotune (up to xx)
+ Tuned
+ Profile :
+ Tune days :
+ Last run :
+ Warning :
+ Select profile to tune
+ Autotune works with only one IC value, your profile has %1$d values. Average value is %2$.2fg/U
+ Autotune works with only one ISF value, your profile has %1$d values. Average value is %2$.1f%3$s/U
+ Error in input data, try to reduce the number of days
+ Autotune calculation started, please be patient
+ Check the results carefully before using it!
+ Partial result day %1$d / %2$d tuned
+ Result: %1$s
+ Param
+ %
+ Missing
+ Autotune profile %1$s
+ Run Autotune
+ Check input profile
+ Compare profiles
+ Copy to local profile
+ Update input profile
+ Revert input profile
+ Create a new local profile from this Autotune Profile?
+ Update %1$s profile with Autotune Profile?
+ Revert %1$s profile with Input Profile?
+ Profile invalid
+ |Param|Profile|Tuned|%/Miss.\n
+ +------------------------------------------\n
+ | %1$4.4s |\t%2$3.3f |\t%3$3.3f |\n
+ | %1$4.4s |\t%2$3.3f |\t%3$3.3f |\n
+ |\t%1$02.0f\t| %2$3.3f |%3$3.3f\t| %5$.0f%% / %4$d\n
+ |\t∑\t|\t%1$3.1f |\t%2$3.1f |\n
+ Autotune runned without profile switch
+ Autotune runned and profile automatically switched
+ Error during last Autotune run
+
- %1$d day
- %1$d days
diff --git a/dana/src/main/res/layout/danar_fragment.xml b/dana/src/main/res/layout/danar_fragment.xml
index e26919aebd..8cc0d95305 100644
--- a/dana/src/main/res/layout/danar_fragment.xml
+++ b/dana/src/main/res/layout/danar_fragment.xml
@@ -2,6 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="info.nightscout.androidaps.dana.DanaFragment"
android:orientation="vertical">
@@ -658,50 +659,58 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
-
+ android:text="@string/viewprofile"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:iconPadding="-4dp"/>
-
-
+ android:text="@string/stats"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:iconPadding="-4dp"/>
-
+ android:text="@string/danar_useroptions"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:iconPadding="-4dp"/>
diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MessageBase.kt b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MessageBase.kt
index 33f410fd45..491bb0b040 100644
--- a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MessageBase.kt
+++ b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MessageBase.kt
@@ -122,7 +122,7 @@ open class MessageBase(injector: HasAndroidInjector) {
}
}
- open fun handleMessageNotReceived() {}
+ open fun handleMessageNotReceived() {} // do nothing by default
val command: Int
get() = byteFromRawBuff(buffer, 5) or (byteFromRawBuff(buffer, 4) shl 8)
diff --git a/danars/src/main/jniLibs/arm64-v8a/libBleEncryption.so b/danars/src/main/jniLibs/arm64-v8a/libBleEncryption.so
index baf9014328..a475f6b187 100644
Binary files a/danars/src/main/jniLibs/arm64-v8a/libBleEncryption.so and b/danars/src/main/jniLibs/arm64-v8a/libBleEncryption.so differ
diff --git a/danars/src/main/jniLibs/armeabi-v7a/libBleEncryption.so b/danars/src/main/jniLibs/armeabi-v7a/libBleEncryption.so
index f5daf1449d..9dc6e23990 100644
Binary files a/danars/src/main/jniLibs/armeabi-v7a/libBleEncryption.so and b/danars/src/main/jniLibs/armeabi-v7a/libBleEncryption.so differ
diff --git a/danars/src/main/jniLibs/x86/libBleEncryption.so b/danars/src/main/jniLibs/x86/libBleEncryption.so
index b63dd5a234..e29290ce70 100644
Binary files a/danars/src/main/jniLibs/x86/libBleEncryption.so and b/danars/src/main/jniLibs/x86/libBleEncryption.so differ
diff --git a/danars/src/main/jniLibs/x86_64/libBleEncryption.so b/danars/src/main/jniLibs/x86_64/libBleEncryption.so
index 871e79aad5..dc091a585c 100644
Binary files a/danars/src/main/jniLibs/x86_64/libBleEncryption.so and b/danars/src/main/jniLibs/x86_64/libBleEncryption.so differ
diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncPumpTemporaryBasalTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncPumpTemporaryBasalTransaction.kt
index bcd49fd43a..50b14f195d 100644
--- a/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncPumpTemporaryBasalTransaction.kt
+++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncPumpTemporaryBasalTransaction.kt
@@ -29,7 +29,7 @@ class SyncPumpTemporaryBasalTransaction(
existing.duration = temporaryBasal.duration
existing.type = type ?: existing.type
database.temporaryBasalDao.updateExistingEntry(existing)
- result.updated.add(existing)
+ result.updated.add(Pair(Reason.EXISTING_ID, existing))
}
} else {
val running = database.temporaryBasalDao.getTemporaryBasalActiveAt(temporaryBasal.timestamp).blockingGet()
@@ -37,7 +37,7 @@ class SyncPumpTemporaryBasalTransaction(
running.end = temporaryBasal.timestamp
running.interfaceIDs.endId = temporaryBasal.interfaceIDs.pumpId
database.temporaryBasalDao.updateExistingEntry(running)
- result.updated.add(running)
+ result.updated.add(Pair(Reason.ACTIVE, running))
}
database.temporaryBasalDao.insertNewEntry(temporaryBasal)
result.inserted.add(temporaryBasal)
@@ -45,9 +45,12 @@ class SyncPumpTemporaryBasalTransaction(
return result
}
+ enum class Reason {
+ EXISTING_ID, ACTIVE
+ }
class TransactionResult {
val inserted = mutableListOf()
- val updated = mutableListOf()
+ val updated = mutableListOf>()
}
}
\ No newline at end of file
diff --git a/diaconn/schemas/info.nightscout.androidaps.diaconn.database.DiaconnHistoryDatabase/1.json b/diaconn/schemas/info.nightscout.androidaps.diaconn.database.DiaconnHistoryDatabase/1.json
index b6e405a524..e1745bce91 100644
--- a/diaconn/schemas/info.nightscout.androidaps.diaconn.database.DiaconnHistoryDatabase/1.json
+++ b/diaconn/schemas/info.nightscout.androidaps.diaconn.database.DiaconnHistoryDatabase/1.json
@@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 1,
- "identityHash": "698b023da2f9efdc0351236c43eb20b6",
+ "identityHash": "d604d25c3edbdf18cc5a39121cf5a779",
"entities": [
{
"tableName": "diaconnHistory",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`timestamp` INTEGER NOT NULL, `code` INTEGER NOT NULL, `value` REAL NOT NULL, `bolusType` TEXT NOT NULL, `stringValue` TEXT NOT NULL, `duration` INTEGER NOT NULL, `dailyBasal` REAL NOT NULL, `dailyBolus` REAL NOT NULL, `alarm` TEXT NOT NULL, PRIMARY KEY(`timestamp`))",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`timestamp` INTEGER NOT NULL, `code` INTEGER NOT NULL, `value` REAL NOT NULL, `bolusType` TEXT NOT NULL, `stringValue` TEXT NOT NULL, `duration` INTEGER NOT NULL, `dailyBasal` REAL NOT NULL, `dailyBolus` REAL NOT NULL, `alarm` TEXT NOT NULL, `lognum` INTEGER NOT NULL, `wrappingCount` INTEGER NOT NULL, `pumpUid` TEXT NOT NULL, PRIMARY KEY(`timestamp`))",
"fields": [
{
"fieldPath": "timestamp",
@@ -61,6 +61,24 @@
"columnName": "alarm",
"affinity": "TEXT",
"notNull": true
+ },
+ {
+ "fieldPath": "lognum",
+ "columnName": "lognum",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "wrappingCount",
+ "columnName": "wrappingCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pumpUid",
+ "columnName": "pumpUid",
+ "affinity": "TEXT",
+ "notNull": true
}
],
"primaryKey": {
@@ -77,6 +95,7 @@
"code",
"timestamp"
],
+ "orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_diaconnHistory_code_timestamp` ON `${TABLE_NAME}` (`code`, `timestamp`)"
}
],
@@ -86,7 +105,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '698b023da2f9efdc0351236c43eb20b6')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd604d25c3edbdf18cc5a39121cf5a779')"
]
}
}
\ No newline at end of file
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt
index 61d15fc0a6..fcb383fa8c 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt
@@ -187,6 +187,13 @@ class DiaconnG8Pump @Inject constructor(
var lgsTime:Int = 0 // LGS Setting time (0~255 min)
var lgsElapsedTime:Int = 0 // LGS Passed Time (0~255 min)
+ val pumpUid: String
+ get() = "$country-$productType-$makeYear-${makeMonth.toString().padStart(2,'0')}-${makeDay.toString().padStart(2, '0')}-${lotNo.toString().padStart(3,'0')}-${serialNo.toString().padStart(5,'0')}"
+
+ val pumpVersion: String
+ get() = "$majorVersion.$minorVersion"
+
+
fun buildDiaconnG8ProfileRecord(nsProfile: Profile): Array {
val record = Array(24) { 0.0 }
for (hour in 0..23) {
@@ -247,6 +254,7 @@ class DiaconnG8Pump @Inject constructor(
var apslastLogNum = 0 // 앱에서 처리한 마지막 로그 번호.
var apsWrappingCount = 0 // 앱에서 처리한 마지막 로그 번호.
var isProgressPumpLogSync = false // 로그 동기화 진행 여부
+ var isPlatformUploadStarted = false // 플랫폼 로그 동기화 진행 여부
// 6. bolus speed status.
var speed = 0 // 주입 속도(1 ~ 8)
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnApiResponse.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnApiResponse.kt
new file mode 100644
index 0000000000..2f75a27951
--- /dev/null
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnApiResponse.kt
@@ -0,0 +1,25 @@
+package info.nightscout.androidaps.diaconn.api
+
+import com.google.gson.annotations.SerializedName
+
+data class LastNoResponse(val ok: Boolean, val info:Info )
+
+data class Info(val pumplog_no: Long)
+
+data class ApiResponse(val ok: Boolean)
+
+data class PumpLogDto(
+ @SerializedName("app_uid") val app_uid: String,
+ @SerializedName("app_version") val app_version: String,
+ @SerializedName("pump_uid") val pump_uid: String,
+ @SerializedName("pump_version") val pump_version: String,
+ @SerializedName("incarnation_num") val incarnation_num: Int,
+ @SerializedName("pumplog_info") val pumplog_info: List
+)
+
+data class PumpLog(
+ @SerializedName("pumplog_no") val pumplog_no: Long,
+ @SerializedName("pumplog_wrapping_count") val pumplog_wrapping_count: Int,
+ @SerializedName("pumplog_data") val pumplog_data: String,
+ @SerializedName("act_type") val act_type: String
+)
\ No newline at end of file
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnApiService.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnApiService.kt
new file mode 100644
index 0000000000..7c83cfdf10
--- /dev/null
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnApiService.kt
@@ -0,0 +1,24 @@
+package info.nightscout.androidaps.diaconn.api
+
+import retrofit2.Call
+import retrofit2.http.Body
+import retrofit2.http.GET
+import retrofit2.http.Headers
+import retrofit2.http.POST
+import retrofit2.http.Query
+
+interface DiaconnApiService {
+
+ @Headers("api-key: ${DiaconnLogUploader.UPLOAD_API_KEY}")
+ @GET("v1/pumplog/last_no")
+ fun getPumpLastNo(
+ @Query("pump_uid") pump_uid: String,
+ @Query("pump_version") pump_version: String,
+ @Query("incarnation_num") incarnation_num: Int): Call
+
+ @Headers("api-key: ${DiaconnLogUploader.UPLOAD_API_KEY}")
+ @POST("v1/pumplog/save")
+ fun uploadPumpLogs(@Body pumpLogDto: PumpLogDto): Call
+
+
+}
\ No newline at end of file
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnLogUploader.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnLogUploader.kt
new file mode 100644
index 0000000000..bcc35fcb18
--- /dev/null
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/api/DiaconnLogUploader.kt
@@ -0,0 +1,31 @@
+package info.nightscout.androidaps.diaconn.api
+
+import info.nightscout.shared.logging.AAPSLogger
+import info.nightscout.shared.logging.LTag
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import javax.inject.Inject
+import javax.inject.Singleton
+
+@Singleton
+class DiaconnLogUploader @Inject constructor (
+ private val aapsLogger: AAPSLogger,
+) {
+ companion object {
+ private const val BASE_URL = "https://api.diaconn.com/aaps/"
+ const val UPLOAD_API_KEY = "D7B3DA9FA8229D5253F3D75E1E2B1BA4"
+ }
+
+ private var retrofit: Retrofit? = null
+
+ fun getRetrofitInstance(): Retrofit? {
+ aapsLogger.debug(LTag.PUMPCOMM, "diaconn pump logs upload instance")
+ if (retrofit == null) {
+ retrofit = Retrofit.Builder()
+ .baseUrl(BASE_URL)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+ }
+ return retrofit
+ }
+}
\ No newline at end of file
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/database/DiaconnHistoryRecord.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/database/DiaconnHistoryRecord.kt
index 46d7e28e89..45a4b35779 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/database/DiaconnHistoryRecord.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/database/DiaconnHistoryRecord.kt
@@ -15,5 +15,8 @@ data class DiaconnHistoryRecord(
var duration: Int = 0,
var dailyBasal: Double = 0.0,
var dailyBolus: Double = 0.0,
- var alarm: String = ""
+ var alarm: String = "",
+ var lognum: Int = 0,
+ var wrappingCount: Int = 0,
+ var pumpUid: String = ""
)
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/database/DiaconnHistoryRecordDao.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/database/DiaconnHistoryRecordDao.kt
index 5115d3d1b8..9e5a7eb8eb 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/database/DiaconnHistoryRecordDao.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/database/DiaconnHistoryRecordDao.kt
@@ -14,4 +14,7 @@ abstract class DiaconnHistoryRecordDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract fun createOrUpdate(diaconnHistoryRecord: DiaconnHistoryRecord)
+
+ @Query( "SELECT * from $TABLE_DIACONN_HISTORY WHERE pumpUid = :pumpUid ORDER BY timestamp DESC LIMIT 1" )
+ abstract fun getLastRecord(pumpUid: String): DiaconnHistoryRecord?
}
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnG8Module.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnG8Module.kt
index 870d460bf0..89a795be77 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnG8Module.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnG8Module.kt
@@ -6,7 +6,8 @@ import dagger.Module
DiaconnG8ActivitiesModule::class,
DiaconnG8ServiceModule::class,
DiaconnG8PacketModule::class,
- DiaconnHistoryModule::class
+ DiaconnHistoryModule::class,
+ DiaconnLogUploaderModule::class
])
open class DiaconnG8Module
\ No newline at end of file
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnLogUploaderModule.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnLogUploaderModule.kt
new file mode 100644
index 0000000000..3a5f18c52a
--- /dev/null
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/di/DiaconnLogUploaderModule.kt
@@ -0,0 +1,12 @@
+package info.nightscout.androidaps.diaconn.di
+
+import dagger.Module
+import dagger.android.ContributesAndroidInjector
+import info.nightscout.androidaps.diaconn.api.DiaconnLogUploader
+import info.nightscout.androidaps.diaconn.service.DiaconnG8Service
+
+@Module
+@Suppress("unused")
+abstract class DiaconnLogUploaderModule {
+ @ContributesAndroidInjector abstract fun contributesDiaconnLogUploader(): DiaconnLogUploader
+}
\ No newline at end of file
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/events/EventDiaconnG8PumpLogReset.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/events/EventDiaconnG8PumpLogReset.kt
new file mode 100644
index 0000000000..40d1b4a74c
--- /dev/null
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/events/EventDiaconnG8PumpLogReset.kt
@@ -0,0 +1,5 @@
+package info.nightscout.androidaps.diaconn.events
+
+import info.nightscout.androidaps.events.Event
+
+class EventDiaconnG8PumpLogReset : Event()
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt
index ef91fd3dc8..fe347adbf0 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt
@@ -1,9 +1,15 @@
package info.nightscout.androidaps.diaconn.packet
+import android.content.Context
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
+import info.nightscout.androidaps.diaconn.api.ApiResponse
+import info.nightscout.androidaps.diaconn.api.DiaconnApiService
+import info.nightscout.androidaps.diaconn.api.DiaconnLogUploader
+import info.nightscout.androidaps.diaconn.api.PumpLog
+import info.nightscout.androidaps.diaconn.api.PumpLogDto
import info.nightscout.androidaps.diaconn.common.RecordTypes
import info.nightscout.androidaps.diaconn.database.DiaconnHistoryRecord
import info.nightscout.androidaps.diaconn.database.DiaconnHistoryRecordDao
@@ -12,16 +18,19 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.PumpDescription
import info.nightscout.androidaps.interfaces.PumpSync
-import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.interfaces.ResourceHelper
+import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import org.apache.commons.lang3.time.DateUtils
import org.joda.time.DateTime
+import retrofit2.Call
+import retrofit2.Response
+import java.util.*
import javax.inject.Inject
/**
@@ -30,7 +39,6 @@ import javax.inject.Inject
class BigLogInquireResponsePacket(
injector: HasAndroidInjector
) : DiaconnG8Packet(injector) {
-
@Inject lateinit var rxBus: RxBus
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var activePlugin: ActivePlugin
@@ -40,6 +48,9 @@ class BigLogInquireResponsePacket(
@Inject lateinit var sp: SP
@Inject lateinit var pumpSync: PumpSync
@Inject lateinit var diaconnHistoryRecordDao: DiaconnHistoryRecordDao
+ @Inject lateinit var diaconnLogUploader: DiaconnLogUploader
+ @Inject lateinit var context: Context
+
var result = 0// 조회결과
private var pumpDesc = PumpDescription(PumpType.DIACONN_G8)
init {
@@ -66,6 +77,7 @@ class BigLogInquireResponsePacket(
// initalize
val dailyMaxvalInfo = mutableMapOf>()
dailyMaxvalInfo[""] = mutableMapOf()
+ val pumpLogs : MutableList = mutableListOf()
// 15 byte를 로그갯수만큼 돌기.
for(i in 0 until logLength) {
@@ -86,637 +98,761 @@ class BigLogInquireResponsePacket(
PumplogUtil.getByte(bufferData),
PumplogUtil.getByte(bufferData)
)
-
- diaconnG8Pump.apsWrappingCount = wrapingCount
- diaconnG8Pump.apslastLogNum = logNum
- sp.putInt(rh.gs(R.string.apslastLogNum), logNum)
- sp.putInt(rh.gs(R.string.apsWrappingCount), wrapingCount)
-
// process Log to DB
val logDataToHexString = toNarrowHex(logdata)
val pumplogKind: Byte = PumplogUtil.getKind(logDataToHexString)
var status: String
val diaconnG8HistoryRecord = DiaconnHistoryRecord(0)
- when(pumplogKind) {
- LOG_INJECT_MEAL_SUCCESS.LOG_KIND -> {
- val logItem = LOG_INJECT_MEAL_SUCCESS.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
- val newRecord = pumpSync.syncBolusWithPumpId(
- timestamp = logDateTime,
- amount = logItem.injectAmount / 100.0,
- type = detailedBolusInfo?.bolusType,
- pumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT MEALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.bolusType = "M" // meal bolus
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logmealsuccess)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- if (!newRecord && detailedBolusInfo != null) {
- // detailedInfo can be from another similar record. Reinsert
- detailedBolusInfoStorage.add(detailedBolusInfo)
- }
- status = "MEALBOLUSSUCCESS" + dateUtil.timeString(logDateTime)
- }
+ if(diaconnG8Pump.isPlatformUploadStarted){
+ // Diaconn Platform upload start
+ aapsLogger.debug(LTag.PUMPCOMM, "make api upload parameter")
+ val pumpLog = PumpLog(
+ pumplog_no = logNum.toLong(),
+ pumplog_wrapping_count = wrapingCount,
+ pumplog_data = logDataToHexString,
+ act_type = "1"
+ )
+ pumpLogs.add(pumpLog)
+ continue
- LOG_INJECT_MEAL_FAIL.LOG_KIND -> {
- val logItem = LOG_INJECT_MEAL_FAIL.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
- val newRecord = pumpSync.syncBolusWithPumpId(
- timestamp = logDateTime,
- amount = logItem.injectAmount / 100.0,
- type = detailedBolusInfo?.bolusType,
- pumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT MEALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = if ((logItem.injectAmount / 100.0) < 0) 0.0 else (logItem.injectAmount / 100.0)
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.bolusType = "M" // Meal bolus
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logmealfail)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- if (!newRecord && detailedBolusInfo != null) {
- // detailedInfo can be from another similar record. Reinsert
- detailedBolusInfoStorage.add(detailedBolusInfo)
- }
- status = "MEALBOLUSFAIL " + dateUtil.timeString(logDateTime)
- }
+ } else {
+ // APS Local history sync start
+ diaconnG8Pump.apsWrappingCount = wrapingCount
+ diaconnG8Pump.apslastLogNum = logNum
- LOG_INJECT_NORMAL_SUCCESS.LOG_KIND -> {
- val logItem = LOG_INJECT_NORMAL_SUCCESS.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ when(pumplogKind) {
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
- val newRecord = pumpSync.syncBolusWithPumpId(
- timestamp = logDateTime,
- amount = logItem.injectAmount / 100.0,
- type = detailedBolusInfo?.bolusType,
- pumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.bolusType = "B" // bolus
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logsuccess)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- if (!newRecord && detailedBolusInfo != null) {
- // detailedInfo can be from another similar record. Reinsert
- detailedBolusInfoStorage.add(detailedBolusInfo)
- }
- status = "BOLUSSUCCESS" + dateUtil.timeString(logDateTime)
- }
-
- LOG_INJECT_NORMAL_FAIL.LOG_KIND -> {
- val logItem = LOG_INJECT_NORMAL_FAIL.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
-
- // APS DB process
- val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
- val newRecord = pumpSync.syncBolusWithPumpId(
- timestamp = logDateTime,
- amount = logItem.injectAmount / 100.0,
- type = detailedBolusInfo?.bolusType,
- pumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
- // Diaconn History Process
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = if ((logItem.injectAmount / 100.0) < 0) 0.0 else (logItem.injectAmount / 100.0)
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.bolusType = "B" // bolus
- diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- if (!newRecord && detailedBolusInfo != null) {
- // detailedInfo can be from another similar record. Reinsert
- detailedBolusInfoStorage.add(detailedBolusInfo)
- }
- status = "BOLUSFAIL " + dateUtil.timeString(logDateTime)
- }
-
- LOG_SET_SQUARE_INJECTION.LOG_KIND -> {
- val logItem = LOG_SET_SQUARE_INJECTION.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- val newRecord = pumpSync.syncExtendedBolusWithPumpId(
- timestamp = logDateTime,
- amount = logItem.setAmount / 100.0,
- duration = T.mins((logItem.getInjectTime() * 10).toLong()).msecs(),
- isEmulatingTB = false,
- pumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTART (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.setAmount / 100.0 + "U Duration: " + logItem.getInjectTime() * 10 + "min")
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.setAmount / 100.0
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logsquarestart)
- diaconnG8HistoryRecord.bolusType = "E" // Extended
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "EXTENDEDBOLUSSTART " + dateUtil.timeString(logDateTime)
- }
-
- LOG_INJECT_SQUARE_SUCCESS.LOG_KIND -> {
- val logItem = LOG_INJECT_SQUARE_SUCCESS.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logsquaresuccess)
- diaconnG8HistoryRecord.bolusType = "E" // Extended
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "EXTENDEDBOLUSEND " + dateUtil.timeString(logDateTime)
- }
-
- LOG_INJECT_SQUARE_FAIL.LOG_KIND -> {
- val logItem = LOG_INJECT_SQUARE_FAIL.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- val newRecord = pumpSync.syncStopExtendedBolusWithPumpId(
- timestamp = logDateTime,
- endPumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTOP (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Delivered: " + logItem.injectAmount / 100.0 + "U RealDuration: " + logItem.getInjectTime() + "min")
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
- diaconnG8HistoryRecord.bolusType = "E"
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "EXTENDEDBOLUSFAIL " + dateUtil.timeString(logDateTime)
- }
-
- LOG_SET_DUAL_INJECTION.LOG_KIND -> {
- val logItem = LOG_SET_DUAL_INJECTION.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
-
- // dual square 처리.
- val newRecord = pumpSync.syncExtendedBolusWithPumpId(
- timestamp = logDateTime,
- amount = logItem.setSquareAmount / 100.0,
- duration = T.mins((logItem.getInjectTime() * 10).toLong()).msecs(),
- isEmulatingTB = false,
- pumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTART (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.setSquareAmount / 100.0 + "U Duration: " + logItem.getInjectTime() * 10 + "min")
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.setSquareAmount / 100.0
- diaconnG8HistoryRecord.duration = logItem.getInjectTime() * 10 // (1~30) 1:10min 30:300min
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logdualsquarestart)
- diaconnG8HistoryRecord.bolusType = "D" // Extended
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
-
- status = "DUALEXTENTEDSTART " + dateUtil.timeString(logDateTime)
- }
-
- LOG_INJECTION_DUAL_NORMAL.LOG_KIND -> {
- val logItem = LOG_INJECTION_DUAL_NORMAL.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
- val newRecord = pumpSync.syncBolusWithPumpId(
- timestamp = logDateTime,
- amount = logItem.injectAmount / 100.0,
- type = detailedBolusInfo?.bolusType,
- pumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U Duration: " + logItem.getInjectTime() + "min")
-
- diaconnG8Pump.lastBolusAmount = logItem.injectAmount / 100.0
- diaconnG8Pump.lastBolusTime = logDateTime
-
- //Diaconn History
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.bolusType = "D" // bolus
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logdualnormalsuccess)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- if (!newRecord && detailedBolusInfo != null) {
- // detailedInfo can be from another similar record. Reinsert
- detailedBolusInfoStorage.add(detailedBolusInfo)
- }
- status = "DUALBOLUS" + dateUtil.timeString(logDateTime)
- }
-
- LOG_INJECT_DUAL_SUCCESS.LOG_KIND -> {
- val logItem = LOG_INJECT_DUAL_SUCCESS.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
-
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.injectSquareAmount / 100.0
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.bolusType = "D"
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logdualsquaresuccess)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "DUALBOLUS SQUARESUCCESS " + dateUtil.timeString(logDateTime)
- }
-
- LOG_INJECT_DUAL_FAIL.LOG_KIND -> {
- val logItem = LOG_INJECT_DUAL_FAIL.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- val newRecord = pumpSync.syncStopExtendedBolusWithPumpId(
- timestamp = logDateTime,
- endPumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTOP (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Delivered: " + logItem.injectSquareAmount / 100.0 + "U RealDuration: " + logItem.getInjectTime() + "min")
-
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.injectNormAmount / 100.0 + logItem.injectSquareAmount / 100.0
- diaconnG8HistoryRecord.duration = logItem.getInjectTime()
- diaconnG8HistoryRecord.bolusType = "D"
- diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "DUALBOLUS FAIL " + dateUtil.timeString(logDateTime)
- }
-
- LOG_INJECTION_1HOUR_BASAL.LOG_KIND -> {
- val logItem = LOG_INJECTION_1HOUR_BASAL.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BASALHOUR
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.beforeAmount / 100.0
- diaconnG8HistoryRecord.stringValue = "TB before: ${logItem.beforeAmount / 100.0} / TB after: ${logItem.afterAmount / 100.0}"
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "1HOUR BASAL " + dateUtil.dateAndTimeString(logDateTime)
- }
-
- LOG_SUSPEND_V2.LOG_KIND -> {
- val logItem = LOG_SUSPEND_V2.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_SUSPEND
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_lgosuspend, logItem.getBasalPattern())
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "SUSPEND " + dateUtil.timeString(logDateTime)
- }
-
- LOG_SUSPEND_RELEASE_V2.LOG_KIND -> {
- val logItem = LOG_SUSPEND_RELEASE_V2.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_SUSPEND
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_lgorelease, logItem.getBasalPattern())
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "SUSPENDRELEASE " + dateUtil.timeString(logDateTime)
- }
-
- LOG_CHANGE_INJECTOR_SUCCESS.LOG_KIND -> {
- val logItem = LOG_CHANGE_INJECTOR_SUCCESS.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- if (sp.getBoolean(R.string.key_diaconn_g8_loginsulinchange, true)) {
- val newRecord = pumpSync.insertTherapyEventIfNewWithTimestamp(
+ LOG_INJECT_MEAL_SUCCESS.LOG_KIND -> {
+ val logItem = LOG_INJECT_MEAL_SUCCESS.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
+ val newRecord = pumpSync.syncBolusWithPumpId(
timestamp = logDateTime,
- type = DetailedBolusInfo.EventType.INSULIN_CHANGE,
+ amount = logItem.injectAmount / 100.0,
+ type = detailedBolusInfo?.bolusType,
pumpId = logDateTime,
pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString()
- )
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT INSULINCHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.remainAmount / 100.0 + "U")
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT MEALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.bolusType = "M" // meal bolus
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logmealsuccess)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ if (!newRecord && detailedBolusInfo != null) {
+ // detailedInfo can be from another similar record. Reinsert
+ detailedBolusInfoStorage.add(detailedBolusInfo)
+ }
+ status = "MEALBOLUSSUCCESS" + dateUtil.timeString(logDateTime)
}
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_REFILL
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.remainAmount / 100.0
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_loginjectorprime, logItem.primeAmount / 100.0)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "INSULINCHANGE " + dateUtil.timeString(logDateTime)
- }
- LOG_CHANGE_TUBE_SUCCESS.LOG_KIND -> {
- val logItem = LOG_CHANGE_TUBE_SUCCESS.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- if (sp.getBoolean(R.string.key_diaconn_g8_logtubechange, true)) {
- val newRecord = pumpSync.insertTherapyEventIfNewWithTimestamp(
+ LOG_INJECT_MEAL_FAIL.LOG_KIND -> {
+ val logItem = LOG_INJECT_MEAL_FAIL.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
+ val newRecord = pumpSync.syncBolusWithPumpId(
timestamp = logDateTime,
- type = DetailedBolusInfo.EventType.NOTE,
- note = rh.gs(R.string.diaconn_g8_logtubeprime, logItem.primeAmount / 100.0),
+ amount = logItem.injectAmount / 100.0,
+ type = detailedBolusInfo?.bolusType,
pumpId = logDateTime,
pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString()
- )
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT TUBECHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.primeAmount / 100.0 + "U")
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT MEALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = if ((logItem.injectAmount / 100.0) < 0) 0.0 else (logItem.injectAmount / 100.0)
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.bolusType = "M" // Meal bolus
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logmealfail)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ if (!newRecord && detailedBolusInfo != null) {
+ // detailedInfo can be from another similar record. Reinsert
+ detailedBolusInfoStorage.add(detailedBolusInfo)
+ }
+ status = "MEALBOLUSFAIL " + dateUtil.timeString(logDateTime)
}
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_REFILL
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.remainAmount / 100.0
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logtubeprime, logItem.primeAmount / 100.0)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "TUBECHANGE " + dateUtil.timeString(logDateTime)
- }
+ LOG_INJECT_NORMAL_SUCCESS.LOG_KIND -> {
+ val logItem = LOG_INJECT_NORMAL_SUCCESS.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- LOG_INJECTION_1DAY.LOG_KIND -> { // Daily Bolus Log
- val logItem = LOG_INJECTION_1DAY.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
-
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY
- diaconnG8HistoryRecord.timestamp = DateTime(logDateTime).withTimeAtStartOfDay().millis
- diaconnG8HistoryRecord.dailyBolus = logItem.extAmount / 100.0 + logItem.mealAmount / 100.0
-
- val recordDateStr = "" + diaconnG8HistoryRecord.timestamp
- var recordMap: MutableMap = mutableMapOf("dummy" to 0.0)
-
- if (dailyMaxvalInfo.containsKey(recordDateStr)) {
- recordMap = dailyMaxvalInfo[recordDateStr]!!
- } else {
- recordMap["bolus"] = 0.0
- recordMap["basal"] = 0.0
- dailyMaxvalInfo[recordDateStr] = recordMap
- }
-
- if (diaconnG8HistoryRecord.dailyBolus > recordMap["bolus"]!!) {
- recordMap["bolus"] = diaconnG8HistoryRecord.dailyBolus
- } else {
- diaconnG8HistoryRecord.dailyBolus = recordMap["bolus"]!!
- }
-
- if (recordMap["basal"]!! > 0.0) {
- diaconnG8HistoryRecord.dailyBasal = recordMap["basal"]!!
- }
-
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
-
- //If it is a TDD, store it for stats also.
- pumpSync.createOrUpdateTotalDailyDose(
- timestamp = diaconnG8HistoryRecord.timestamp,
- bolusAmount = diaconnG8HistoryRecord.dailyBolus,
- basalAmount = diaconnG8HistoryRecord.dailyBasal,
- totalAmount = 0.0,
- pumpId = null,
- pumpType = PumpType.DIACONN_G8,
- diaconnG8Pump.serialNo.toString()
- )
-
- status = "DAILYBOLUS " + dateUtil.timeString(logDateTime)
- }
-
- LOG_INJECTION_1DAY_BASAL.LOG_KIND -> { // Daily Basal Log
- val logItem = LOG_INJECTION_1DAY_BASAL.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
-
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY
- diaconnG8HistoryRecord.timestamp = DateTime(logDateTime).withTimeAtStartOfDay().millis
- diaconnG8HistoryRecord.dailyBasal = logItem.amount / 100.0
-
- val recordDateStr = "" + diaconnG8HistoryRecord.timestamp
- var recordMap: MutableMap = mutableMapOf("dummy" to 0.0)
-
- if (dailyMaxvalInfo.containsKey(recordDateStr)) {
- recordMap = dailyMaxvalInfo[recordDateStr]!!
- } else {
- recordMap["bolus"] = 0.0
- recordMap["basal"] = 0.0
- dailyMaxvalInfo[recordDateStr] = recordMap
- }
-
- if (diaconnG8HistoryRecord.dailyBasal > recordMap["basal"]!!) {
- recordMap["basal"] = diaconnG8HistoryRecord.dailyBasal
- } else {
- diaconnG8HistoryRecord.dailyBasal = recordMap["basal"]!!
- }
-
- if (recordMap["bolus"]!! > 0.0) {
- diaconnG8HistoryRecord.dailyBolus = recordMap["bolus"]!!
- }
-
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
-
- //If it is a TDD, store it for stats also.
- // pumpSync.createOrUpdateTotalDailyDose(
- // timestamp = diaconnG8HistoryRecord.timestamp,
- // bolusAmount = diaconnG8HistoryRecord.dailyBolus,
- // basalAmount = diaconnG8HistoryRecord.dailyBasal,
- // totalAmount = 0.0,
- // pumpId = null,
- // pumpType = PumpType.DIACONN_G8,
- // diaconnG8Pump.serialNo.toString()
- // )
-
- status = "DAILYBASAL " + dateUtil.timeString(logDateTime)
- }
-
- LOG_CHANGE_NEEDLE_SUCCESS.LOG_KIND -> {
- val logItem = LOG_CHANGE_NEEDLE_SUCCESS.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- if (sp.getBoolean(R.string.key_diaconn_g8_logneedlechange, true)) {
- val newRecord = pumpSync.insertTherapyEventIfNewWithTimestamp(
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
+ val newRecord = pumpSync.syncBolusWithPumpId(
timestamp = logDateTime,
- type = DetailedBolusInfo.EventType.CANNULA_CHANGE,
+ amount = logItem.injectAmount / 100.0,
+ type = detailedBolusInfo?.bolusType,
pumpId = logDateTime,
pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString()
- )
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT NEEDLECHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.remainAmount / 100.0 + "U")
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.bolusType = "B" // bolus
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logsuccess)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ if (!newRecord && detailedBolusInfo != null) {
+ // detailedInfo can be from another similar record. Reinsert
+ detailedBolusInfoStorage.add(detailedBolusInfo)
+ }
+ status = "BOLUSSUCCESS" + dateUtil.timeString(logDateTime)
}
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_REFILL
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.remainAmount / 100.0
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logneedleprime, logItem.primeAmount / 100.0)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "NEEDLECHANGE " + dateUtil.timeString(logDateTime)
- }
+ LOG_INJECT_NORMAL_FAIL.LOG_KIND -> {
+ val logItem = LOG_INJECT_NORMAL_FAIL.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
- LOG_TB_START_V3.LOG_KIND -> {
- val logItem = LOG_TB_START_V3.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
-
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- var absoluteRate = 0.0
- if (logItem.getTbInjectRateRatio() >= 50000) {
- val tempBasalPercent = logItem.getTbInjectRateRatio() - 50000
- absoluteRate = pumpDesc.pumpType.determineCorrectBasalSize(diaconnG8Pump.baseAmount * (tempBasalPercent / 100.0))
+ // APS DB process
+ val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
+ val newRecord = pumpSync.syncBolusWithPumpId(
+ timestamp = logDateTime,
+ amount = logItem.injectAmount / 100.0,
+ type = detailedBolusInfo?.bolusType,
+ pumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U ")
+ // Diaconn History Process
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = if ((logItem.injectAmount / 100.0) < 0) 0.0 else (logItem.injectAmount / 100.0)
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.bolusType = "B" // bolus
+ diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ if (!newRecord && detailedBolusInfo != null) {
+ // detailedInfo can be from another similar record. Reinsert
+ detailedBolusInfoStorage.add(detailedBolusInfo)
+ }
+ status = "BOLUSFAIL " + dateUtil.timeString(logDateTime)
}
- if (logItem.getTbInjectRateRatio() in 1000..2500) {
- absoluteRate = (logItem.getTbInjectRateRatio() - 1000) / 100.0
+ LOG_SET_SQUARE_INJECTION.LOG_KIND -> {
+ val logItem = LOG_SET_SQUARE_INJECTION.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ val newRecord = pumpSync.syncExtendedBolusWithPumpId(
+ timestamp = logDateTime,
+ amount = logItem.setAmount / 100.0,
+ duration = T.mins((logItem.getInjectTime() * 10).toLong()).msecs(),
+ isEmulatingTB = false,
+ pumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTART (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.setAmount / 100.0 + "U Duration: " + logItem.getInjectTime() * 10 + "min")
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.setAmount / 100.0
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logsquarestart)
+ diaconnG8HistoryRecord.bolusType = "E" // Extended
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "EXTENDEDBOLUSSTART " + dateUtil.timeString(logDateTime)
}
- val temporaryBasalInfo = temporaryBasalStorage.findTemporaryBasal(logDateTime, absoluteRate)
- val newRecord = pumpSync.syncTemporaryBasalWithPumpId(
- timestamp = logDateTime,
- rate = absoluteRate,
- duration = T.mins((logItem.tbTime * 15).toLong()).msecs(),
- isAbsolute = true,
- type = temporaryBasalInfo?.type,
- pumpId = logDateTime,
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT TEMPSTART (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Ratio: " + absoluteRate + "U Duration: " + logItem.tbTime * 15 + "min")
-
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_TB
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.duration = logItem.tbTime * 15
- diaconnG8HistoryRecord.value = absoluteRate
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logtempstart)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "TEMPSTART " + dateUtil.timeString(logDateTime)
- }
-
- LOG_TB_STOP_V3.LOG_KIND -> {
- val logItem = LOG_TB_STOP_V3.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
- var absoluteRate = 0.0
- if (logItem.getTbInjectRateRatio() >= 50000) {
- val tempBasalPercent = logItem.getTbInjectRateRatio() - 50000
- absoluteRate = diaconnG8Pump.baseAmount * (tempBasalPercent / 100.0)
- }
- if (logItem.getTbInjectRateRatio() in 1000..2500) {
- absoluteRate = (logItem.getTbInjectRateRatio() - 1000) / 100.0
+ LOG_INJECT_SQUARE_SUCCESS.LOG_KIND -> {
+ val logItem = LOG_INJECT_SQUARE_SUCCESS.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logsquaresuccess)
+ diaconnG8HistoryRecord.bolusType = "E" // Extended
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "EXTENDEDBOLUSEND " + dateUtil.timeString(logDateTime)
}
- val newRecord = pumpSync.syncStopTemporaryBasalWithPumpId(
- timestamp = logDateTime,
- endPumpId = dateUtil.now(),
- pumpType = PumpType.DIACONN_G8,
- pumpSerial = diaconnG8Pump.serialNo.toString())
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT TEMPSTOP (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")")
+ LOG_INJECT_SQUARE_FAIL.LOG_KIND -> {
+ val logItem = LOG_INJECT_SQUARE_FAIL.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ val newRecord = pumpSync.syncStopExtendedBolusWithPumpId(
+ timestamp = logDateTime,
+ endPumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTOP (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Delivered: " + logItem.injectAmount / 100.0 + "U RealDuration: " + logItem.getInjectTime() + "min")
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
+ diaconnG8HistoryRecord.bolusType = "E"
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "EXTENDEDBOLUSFAIL " + dateUtil.timeString(logDateTime)
+ }
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_TB
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = absoluteRate
- diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "TEMPSTOP " + dateUtil.timeString(logDateTime)
- }
+ LOG_SET_DUAL_INJECTION.LOG_KIND -> {
+ val logItem = LOG_SET_DUAL_INJECTION.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
- LOG_ALARM_BATTERY.LOG_KIND -> { // BATTERY SHORTAGE ALARM
- val logItem = LOG_ALARM_BATTERY.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
+ // dual square 처리.
+ val newRecord = pumpSync.syncExtendedBolusWithPumpId(
+ timestamp = logDateTime,
+ amount = logItem.setSquareAmount / 100.0,
+ duration = T.mins((logItem.getInjectTime() * 10).toLong()).msecs(),
+ isEmulatingTB = false,
+ pumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTART (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.setSquareAmount / 100.0 + "U Duration: " + logItem.getInjectTime() * 10 + "min")
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.setSquareAmount / 100.0
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime() * 10 // (1~30) 1:10min 30:300min
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logdualsquarestart)
+ diaconnG8HistoryRecord.bolusType = "D" // Extended
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_ALARM
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logbatteryshorage)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "BATTERYALARM " + dateUtil.timeString(logDateTime)
- }
+ status = "DUALEXTENTEDSTART " + dateUtil.timeString(logDateTime)
+ }
- LOG_ALARM_BLOCK.LOG_KIND -> { // INJECTION BLOCKED ALARM
- val logItem = LOG_ALARM_BLOCK.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ LOG_INJECTION_DUAL_NORMAL.LOG_KIND -> {
+ val logItem = LOG_INJECTION_DUAL_NORMAL.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(logDateTime, logItem.injectAmount / 100.0)
+ val newRecord = pumpSync.syncBolusWithPumpId(
+ timestamp = logDateTime,
+ amount = logItem.injectAmount / 100.0,
+ type = detailedBolusInfo?.bolusType,
+ pumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Bolus: " + logItem.injectAmount / 100.0 + "U Duration: " + logItem.getInjectTime() + "min")
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
+ diaconnG8Pump.lastBolusAmount = logItem.injectAmount / 100.0
+ diaconnG8Pump.lastBolusTime = logDateTime
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_ALARM
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.amount / 100.0
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logalarmblock, getReasonName(pumplogKind, logItem.reason))
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "BLOCKALARM " + dateUtil.timeString(logDateTime)
- }
+ //Diaconn History
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.injectAmount / 100.0
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.bolusType = "D" // bolus
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logdualnormalsuccess)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ if (!newRecord && detailedBolusInfo != null) {
+ // detailedInfo can be from another similar record. Reinsert
+ detailedBolusInfoStorage.add(detailedBolusInfo)
+ }
+ status = "DUALBOLUS" + dateUtil.timeString(logDateTime)
+ }
- LOG_ALARM_SHORTAGE.LOG_KIND -> { // INSULIN SHORTAGE ALARM
- val logItem = LOG_ALARM_SHORTAGE.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ LOG_INJECT_DUAL_SUCCESS.LOG_KIND -> {
+ val logItem = LOG_INJECT_DUAL_SUCCESS.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.injectSquareAmount / 100.0
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.bolusType = "D"
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logdualsquaresuccess)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "DUALBOLUS SQUARESUCCESS " + dateUtil.timeString(logDateTime)
+ }
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_ALARM
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.value = logItem.remain.toDouble()
- diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_loginsulinshorage)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- status = "SHORTAGEALARM " + dateUtil.timeString(logDateTime)
- }
+ LOG_INJECT_DUAL_FAIL.LOG_KIND -> {
+ val logItem = LOG_INJECT_DUAL_FAIL.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ val newRecord = pumpSync.syncStopExtendedBolusWithPumpId(
+ timestamp = logDateTime,
+ endPumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT EXTENDEDSTOP (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Delivered: " + logItem.injectSquareAmount / 100.0 + "U RealDuration: " + logItem.getInjectTime() + "min")
- LOG_RESET_SYS_V3.LOG_KIND -> {
- val logItem = LOG_RESET_SYS_V3.parse(logDataToHexString)
- aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BOLUS
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.injectNormAmount / 100.0 + logItem.injectSquareAmount / 100.0
+ diaconnG8HistoryRecord.duration = logItem.getInjectTime()
+ diaconnG8HistoryRecord.bolusType = "D"
+ diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "DUALBOLUS FAIL " + dateUtil.timeString(logDateTime)
+ }
- val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
- val logDateTime = logStartDate.time
+ LOG_INJECTION_1HOUR_BASAL.LOG_KIND -> {
+ val logItem = LOG_INJECTION_1HOUR_BASAL.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_BASALHOUR
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.beforeAmount / 100.0
+ diaconnG8HistoryRecord.stringValue = "TB before: ${logItem.beforeAmount / 100.0} / TB after: ${logItem.afterAmount / 100.0}"
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "1HOUR BASAL " + dateUtil.dateAndTimeString(logDateTime)
+ }
- diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_ALARM
- diaconnG8HistoryRecord.timestamp = logDateTime
- diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
- diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
- if (logItem.reason == 3.toByte()) {
- if (sp.getBoolean(R.string.key_diaconn_g8_logbatterychange, true)) {
+ LOG_SUSPEND_V2.LOG_KIND -> {
+ val logItem = LOG_SUSPEND_V2.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_SUSPEND
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_lgosuspend, logItem.getBasalPattern())
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "SUSPEND " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_SUSPEND_RELEASE_V2.LOG_KIND -> {
+ val logItem = LOG_SUSPEND_RELEASE_V2.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_SUSPEND
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_lgorelease, logItem.getBasalPattern())
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "SUSPENDRELEASE " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_CHANGE_INJECTOR_SUCCESS.LOG_KIND -> {
+ val logItem = LOG_CHANGE_INJECTOR_SUCCESS.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ if (sp.getBoolean(R.string.key_diaconn_g8_loginsulinchange, true)) {
val newRecord = pumpSync.insertTherapyEventIfNewWithTimestamp(
timestamp = logDateTime,
- type = DetailedBolusInfo.EventType.PUMP_BATTERY_CHANGE,
+ type = DetailedBolusInfo.EventType.INSULIN_CHANGE,
pumpId = logDateTime,
pumpType = PumpType.DIACONN_G8,
pumpSerial = diaconnG8Pump.serialNo.toString()
)
- aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BATTERYCHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " remainAmount: " + logItem.batteryRemain.toInt() + "%")
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT INSULINCHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.remainAmount / 100.0 + "U")
+ }
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_REFILL
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.remainAmount / 100.0
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_loginjectorprime, logItem.primeAmount / 100.0)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "INSULINCHANGE " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_CHANGE_TUBE_SUCCESS.LOG_KIND -> {
+ val logItem = LOG_CHANGE_TUBE_SUCCESS.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ if (sp.getBoolean(R.string.key_diaconn_g8_logtubechange, true)) {
+ val newRecord = pumpSync.insertTherapyEventIfNewWithTimestamp(
+ timestamp = logDateTime,
+ type = DetailedBolusInfo.EventType.NOTE,
+ note = rh.gs(R.string.diaconn_g8_logtubeprime, logItem.primeAmount / 100.0),
+ pumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString()
+ )
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT TUBECHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.primeAmount / 100.0 + "U")
+ }
+
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_REFILL
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.remainAmount / 100.0
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logtubeprime, logItem.primeAmount / 100.0)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "TUBECHANGE " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_INJECTION_1DAY.LOG_KIND -> { // Daily Bolus Log
+ val logItem = LOG_INJECTION_1DAY.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY
+ diaconnG8HistoryRecord.timestamp = DateTime(logDateTime).withTimeAtStartOfDay().millis
+ diaconnG8HistoryRecord.dailyBolus = logItem.extAmount / 100.0 + logItem.mealAmount / 100.0
+
+ val recordDateStr = "" + diaconnG8HistoryRecord.timestamp
+ var recordMap: MutableMap = mutableMapOf("dummy" to 0.0)
+
+ if (dailyMaxvalInfo.containsKey(recordDateStr)) {
+ recordMap = dailyMaxvalInfo[recordDateStr]!!
+ } else {
+ recordMap["bolus"] = 0.0
+ recordMap["basal"] = 0.0
+ dailyMaxvalInfo[recordDateStr] = recordMap
+ }
+
+ if (diaconnG8HistoryRecord.dailyBolus > recordMap["bolus"]!!) {
+ recordMap["bolus"] = diaconnG8HistoryRecord.dailyBolus
+ } else {
+ diaconnG8HistoryRecord.dailyBolus = recordMap["bolus"]!!
+ }
+
+ if (recordMap["basal"]!! > 0.0) {
+ diaconnG8HistoryRecord.dailyBasal = recordMap["basal"]!!
+ }
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+
+ //If it is a TDD, store it for stats also.
+ pumpSync.createOrUpdateTotalDailyDose(
+ timestamp = diaconnG8HistoryRecord.timestamp,
+ bolusAmount = diaconnG8HistoryRecord.dailyBolus,
+ basalAmount = diaconnG8HistoryRecord.dailyBasal,
+ totalAmount = 0.0,
+ pumpId = null,
+ pumpType = PumpType.DIACONN_G8,
+ diaconnG8Pump.serialNo.toString()
+ )
+
+ status = "DAILYBOLUS " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_INJECTION_1DAY_BASAL.LOG_KIND -> { // Daily Basal Log
+ val logItem = LOG_INJECTION_1DAY_BASAL.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_DAILY
+ diaconnG8HistoryRecord.timestamp = DateTime(logDateTime).withTimeAtStartOfDay().millis
+ diaconnG8HistoryRecord.dailyBasal = logItem.amount / 100.0
+
+ val recordDateStr = "" + diaconnG8HistoryRecord.timestamp
+ var recordMap: MutableMap = mutableMapOf("dummy" to 0.0)
+
+ if (dailyMaxvalInfo.containsKey(recordDateStr)) {
+ recordMap = dailyMaxvalInfo[recordDateStr]!!
+ } else {
+ recordMap["bolus"] = 0.0
+ recordMap["basal"] = 0.0
+ dailyMaxvalInfo[recordDateStr] = recordMap
+ }
+
+ if (diaconnG8HistoryRecord.dailyBasal > recordMap["basal"]!!) {
+ recordMap["basal"] = diaconnG8HistoryRecord.dailyBasal
+ } else {
+ diaconnG8HistoryRecord.dailyBasal = recordMap["basal"]!!
+ }
+
+ if (recordMap["bolus"]!! > 0.0) {
+ diaconnG8HistoryRecord.dailyBolus = recordMap["bolus"]!!
+ }
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+
+ //If it is a TDD, store it for stats also.
+ // pumpSync.createOrUpdateTotalDailyDose(
+ // timestamp = diaconnG8HistoryRecord.timestamp,
+ // bolusAmount = diaconnG8HistoryRecord.dailyBolus,
+ // basalAmount = diaconnG8HistoryRecord.dailyBasal,
+ // totalAmount = 0.0,
+ // pumpId = null,
+ // pumpType = PumpType.DIACONN_G8,
+ // diaconnG8Pump.serialNo.toString()
+ // )
+
+
+ status = "DAILYBASAL " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_CHANGE_NEEDLE_SUCCESS.LOG_KIND -> {
+ val logItem = LOG_CHANGE_NEEDLE_SUCCESS.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ if (sp.getBoolean(R.string.key_diaconn_g8_logneedlechange, true)) {
+ val newRecord = pumpSync.insertTherapyEventIfNewWithTimestamp(
+ timestamp = logDateTime,
+ type = DetailedBolusInfo.EventType.CANNULA_CHANGE,
+ pumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString()
+ )
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT NEEDLECHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Amount: " + logItem.remainAmount / 100.0 + "U")
+ }
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_REFILL
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.remainAmount / 100.0
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logneedleprime, logItem.primeAmount / 100.0)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "NEEDLECHANGE " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_TB_START_V3.LOG_KIND -> {
+ val logItem = LOG_TB_START_V3.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ var absoluteRate = 0.0
+ if (logItem.getTbInjectRateRatio() >= 50000) {
+ val tempBasalPercent = logItem.getTbInjectRateRatio() - 50000
+ absoluteRate = pumpDesc.pumpType.determineCorrectBasalSize(diaconnG8Pump.baseAmount * (tempBasalPercent / 100.0))
+ }
+
+ if (logItem.getTbInjectRateRatio() in 1000..2500) {
+ absoluteRate = (logItem.getTbInjectRateRatio() - 1000) / 100.0
+ }
+
+ val temporaryBasalInfo = temporaryBasalStorage.findTemporaryBasal(logDateTime, absoluteRate)
+ val newRecord = pumpSync.syncTemporaryBasalWithPumpId(
+ timestamp = logDateTime,
+ rate = absoluteRate,
+ duration = T.mins((logItem.tbTime * 15).toLong()).msecs(),
+ isAbsolute = true,
+ type = temporaryBasalInfo?.type,
+ pumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT TEMPSTART (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " Ratio: " + absoluteRate + "U Duration: " + logItem.tbTime * 15 + "min")
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_TB
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.duration = logItem.tbTime * 15
+ diaconnG8HistoryRecord.value = absoluteRate
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logtempstart)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "TEMPSTART " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_TB_STOP_V3.LOG_KIND -> {
+ val logItem = LOG_TB_STOP_V3.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+ var absoluteRate = 0.0
+ if (logItem.getTbInjectRateRatio() >= 50000) {
+ val tempBasalPercent = logItem.getTbInjectRateRatio() - 50000
+ absoluteRate = diaconnG8Pump.baseAmount * (tempBasalPercent / 100.0)
+ }
+ if (logItem.getTbInjectRateRatio() in 1000..2500) {
+ absoluteRate = (logItem.getTbInjectRateRatio() - 1000) / 100.0
+ }
+
+ val newRecord = pumpSync.syncStopTemporaryBasalWithPumpId(
+ timestamp = logDateTime,
+ endPumpId = dateUtil.now(),
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString())
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT TEMPSTOP (" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")")
+
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_TB
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = absoluteRate
+ diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "TEMPSTOP " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_ALARM_BATTERY.LOG_KIND -> { // BATTERY SHORTAGE ALARM
+ val logItem = LOG_ALARM_BATTERY.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_ALARM
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logbatteryshorage)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "BATTERYALARM " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_ALARM_BLOCK.LOG_KIND -> { // INJECTION BLOCKED ALARM
+ val logItem = LOG_ALARM_BLOCK.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_ALARM
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.amount / 100.0
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_logalarmblock, getReasonName(pumplogKind, logItem.reason))
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "BLOCKALARM " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_ALARM_SHORTAGE.LOG_KIND -> { // INSULIN SHORTAGE ALARM
+ val logItem = LOG_ALARM_SHORTAGE.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_ALARM
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.value = logItem.remain.toDouble()
+ diaconnG8HistoryRecord.stringValue = rh.gs(R.string.diaconn_g8_loginsulinshorage)
+ diaconnG8HistoryRecord.lognum = logNum
+ diaconnG8HistoryRecord.wrappingCount = wrapingCount
+ diaconnG8HistoryRecord.pumpUid = diaconnG8Pump.pumpUid
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ status = "SHORTAGEALARM " + dateUtil.timeString(logDateTime)
+ }
+
+ LOG_RESET_SYS_V3.LOG_KIND -> {
+ val logItem = LOG_RESET_SYS_V3.parse(logDataToHexString)
+ aapsLogger.debug(LTag.PUMPCOMM, "$logItem ")
+
+ val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss")
+ val logDateTime = logStartDate.time
+
+ diaconnG8HistoryRecord.code = RecordTypes.RECORD_TYPE_ALARM
+ diaconnG8HistoryRecord.timestamp = logDateTime
+ diaconnG8HistoryRecord.stringValue = getReasonName(pumplogKind, logItem.reason)
+ diaconnHistoryRecordDao.createOrUpdate(diaconnG8HistoryRecord)
+ if (logItem.reason == 3.toByte()) {
+ if (sp.getBoolean(R.string.key_diaconn_g8_logbatterychange, true)) {
+ val newRecord = pumpSync.insertTherapyEventIfNewWithTimestamp(
+ timestamp = logDateTime,
+ type = DetailedBolusInfo.EventType.PUMP_BATTERY_CHANGE,
+ pumpId = logDateTime,
+ pumpType = PumpType.DIACONN_G8,
+ pumpSerial = diaconnG8Pump.serialNo.toString()
+ )
+ aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BATTERYCHANGE(" + pumplogKind + ") " + dateUtil.dateAndTimeString(logDateTime) + " (" + logDateTime + ")" + " remainAmount: " + logItem.batteryRemain.toInt() + "%")
+ }
+ }
+ status = "RESET " + dateUtil.timeString(logDateTime)
+ }
+
+ else -> {
+ status = rh.gs(R.string.diaconn_g8_logsyncinprogress)
+ rxBus.send(EventPumpStatusChanged(status))
+ continue
+ }
+ }
+ rxBus.send(EventPumpStatusChanged(rh.gs(R.string.processinghistory) + ": " + status))
+ }
+
+ }
+
+ // 플랫폼 동기화이면,
+ if(diaconnG8Pump.isPlatformUploadStarted){
+ aapsLogger.debug(LTag.PUMPCOMM, "Diaconn api upload start!!")
+ var appUid:String = sp.getString(R.string.key_diaconn_g8_appuid, "")
+ if (appUid.isEmpty()) {
+ appUid = UUID.randomUUID().toString()
+ sp.putString(R.string.key_diaconn_g8_appuid, appUid)
+ }
+ //api send
+ val retrofit = diaconnLogUploader.getRetrofitInstance()
+ val api = retrofit?.create(DiaconnApiService::class.java)
+ val pumpLogDto = PumpLogDto(
+ app_uid = appUid,
+ app_version = context.packageManager.getPackageInfo(context.packageName, 0).versionName,
+ pump_uid = diaconnG8Pump.pumpUid,
+ pump_version = diaconnG8Pump.pumpVersion,
+ incarnation_num = diaconnG8Pump.pumpIncarnationNum,
+ pumplog_info = pumpLogs,
+ )
+ try {
+ api?.uploadPumpLogs(pumpLogDto)?.enqueue(
+ object : retrofit2.Callback {
+ override fun onResponse(call: Call, response: Response) {
+ if(response.body()?.ok == true) {
+ aapsLogger.debug(LTag.PUMPCOMM, "logs upload Success")
+ }
+ }
+ override fun onFailure(call: Call, t: Throwable) {
+ t.printStackTrace()
}
}
- status = "RESET " + dateUtil.timeString(logDateTime)
- }
-
- else -> {
- status = rh.gs(R.string.diaconn_g8_logsyncinprogress)
- rxBus.send(EventPumpStatusChanged(status))
- continue
- }
+ )
+ } catch(e: Exception) {
+ aapsLogger.error("Unhandled exception", e)
}
- rxBus.send(EventPumpStatusChanged(rh.gs(R.string.processinghistory) + ": " + status))
}
}
@@ -780,5 +916,4 @@ class BigLogInquireResponsePacket(
else -> ""
}
}
-
-}
+}
\ No newline at end of file
diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt
index cf4871b025..85e84d4b29 100644
--- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt
+++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt
@@ -14,7 +14,11 @@ import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
+import info.nightscout.androidaps.diaconn.api.DiaconnApiService
+import info.nightscout.androidaps.diaconn.api.DiaconnLogUploader
+import info.nightscout.androidaps.diaconn.database.DiaconnHistoryRecordDao
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8NewStatus
+import info.nightscout.androidaps.diaconn.events.EventDiaconnG8PumpLogReset
import info.nightscout.androidaps.diaconn.packet.*
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
import info.nightscout.androidaps.dialogs.BolusProgressDialog
@@ -50,6 +54,7 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject
import kotlin.math.abs
import kotlin.math.ceil
+import kotlin.math.floor
import kotlin.math.min
class DiaconnG8Service : DaggerService() {
@@ -73,6 +78,8 @@ class DiaconnG8Service : DaggerService() {
@Inject lateinit var pumpSync: PumpSync
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var aapsSchedulers: AapsSchedulers
+ @Inject lateinit var diaconnLogUploader: DiaconnLogUploader
+ @Inject lateinit var diaconnHistoryRecordDao: DiaconnHistoryRecordDao
private val disposable = CompositeDisposable()
private val mBinder: IBinder = LocalBinder()
@@ -129,7 +136,7 @@ class DiaconnG8Service : DaggerService() {
}
private fun sendMessage(message: DiaconnG8Packet) {
- bleCommonService.sendMessage(message, 500)
+ bleCommonService.sendMessage(message, 2000)
}
fun readPumpStatus() {
@@ -232,6 +239,7 @@ class DiaconnG8Service : DaggerService() {
}
fun loadHistory(): PumpEnactResult {
+
if (!diaconnG8Plugin.isInitialized()) {
val result = PumpEnactResult(injector).success(false)
result.comment = "pump not initialized"
@@ -245,6 +253,16 @@ class DiaconnG8Service : DaggerService() {
}
val result = PumpEnactResult(injector)
+ var apsLastLogNum = 9999
+ var apsWrappingCount = -1
+ // get saved last loginfo
+ val diaconnHistoryRecord = diaconnHistoryRecordDao.getLastRecord(diaconnG8Pump.pumpUid)
+ aapsLogger.error(LTag.PUMPCOMM, "diaconnHistoryRecord :: $diaconnHistoryRecord")
+
+ if(diaconnHistoryRecord != null) {
+ apsLastLogNum = diaconnHistoryRecord.lognum
+ apsWrappingCount = diaconnHistoryRecord.wrappingCount
+ }
// pump log status
val pumpLastNum = diaconnG8Pump.pumpLastLogNum
@@ -252,74 +270,107 @@ class DiaconnG8Service : DaggerService() {
val apsIncarnationNum = sp.getInt(rh.gs(R.string.apsIncarnationNo), 65536)
// aps last log num
val pumpSerialNo = sp.getInt(rh.gs(R.string.pumpserialno), 0)
- var apsWrappingCount = sp.getInt(rh.gs(R.string.apsWrappingCount), 0)
- var apsLastLogNum = sp.getInt(rh.gs(R.string.apslastLogNum), 0)
+
// if first install app
- if (apsWrappingCount == 0 && apsLastLogNum == 0) {
- pumpLogDefaultSetting()
+ if (apsWrappingCount == -1 && apsLastLogNum == 9999 ) {
+ apsWrappingCount = pumpWrappingCount
+ apsLastLogNum = if (pumpLastNum - 1 < 0) 0 else pumpLastNum -2
}
-
- // if pump reset
- if (apsIncarnationNum != diaconnG8Pump.pumpIncarnationNum) {
- pumpLogDefaultSetting()
- sp.putInt(rh.gs(R.string.apsIncarnationNo), diaconnG8Pump.pumpIncarnationNum)
- }
-
// if another pump
if (pumpSerialNo != diaconnG8Pump.serialNo) {
- pumpLogDefaultSetting()
+ apsWrappingCount = pumpWrappingCount
+ apsLastLogNum = if (pumpLastNum - 1 < 0) 0 else pumpLastNum -2
sp.putInt(rh.gs(R.string.pumpserialno), diaconnG8Pump.serialNo)
}
-
- apsWrappingCount = sp.getInt(rh.gs(R.string.apsWrappingCount), 0)
- apsLastLogNum = sp.getInt(rh.gs(R.string.apslastLogNum), 0)
-
- val apsLastNum = apsWrappingCount * 10000 + apsLastLogNum
- if ((pumpWrappingCount * 10000 + pumpLastNum) < apsLastLogNum) {
- pumpLogDefaultSetting()
- }
-
- val start: Int? // log sync startNo
- val end: Int? // log sync endNo
- if (((pumpWrappingCount * 10000 + pumpLastNum) - apsLastNum) > 10000) {
- start = pumpLastNum
- end = 10000
- } else if (pumpWrappingCount > apsWrappingCount && apsLastLogNum < 9999) {
- start = apsLastLogNum + 1
- end = 10000
- } else if (pumpWrappingCount > apsWrappingCount && apsLastLogNum >= 9999) {
- start = 0
- end = pumpLastNum
- } else {
- start = apsLastLogNum + 1
- end = pumpLastNum
+ // if pump reset
+ if (apsIncarnationNum != diaconnG8Pump.pumpIncarnationNum) {
+ apsWrappingCount = pumpWrappingCount
+ apsLastLogNum = if (pumpLastNum - 1 < 0) 0 else pumpLastNum -2
+ sp.putInt(R.string.apsIncarnationNo, apsIncarnationNum)
}
+ aapsLogger.debug(LTag.PUMPCOMM, "apsWrappingCount : $apsWrappingCount, apsLastLogNum : $apsLastLogNum")
// pump log loop size
val pumpLogPageSize = 11
- val loopCount: Int = ceil(((end - start) / 11.0)).toInt()
-
+ val (start, end, loopSize) = getLogLoopCount(apsLastLogNum, apsWrappingCount, pumpLastNum, pumpWrappingCount, false)
+ aapsLogger.debug(LTag.PUMPCOMM, "loopinfo start : $start, end : $end, loopSize : $loopSize")
// log sync start!
- if (loopCount > 0) {
- diaconnG8Pump.isProgressPumpLogSync = true
-
- for (i in 0 until loopCount) {
+ if (loopSize > 0) {
+ for (i in 0 until loopSize) {
val startLogNo: Int = start + i * pumpLogPageSize
val endLogNo: Int = startLogNo + min(end - startLogNo, pumpLogPageSize)
val msg = BigLogInquirePacket(injector, startLogNo, endLogNo, 100)
- sendMessage(msg)
- }
- diaconnG8Pump.historyDoneReceived = true
- while (!diaconnG8Pump.historyDoneReceived && bleCommonService.isConnected) {
- SystemClock.sleep(100)
+ sendMessage(msg, 500)
}
result.success(true)
diaconnG8Pump.lastConnection = System.currentTimeMillis()
}
+
+ // upload pump log to Diaconn Cloud
+ if (sp.getBoolean(R.string.key_diaconn_g8_cloudsend, true)) {
+ SystemClock.sleep(1000)
+ try {
+ // getting last uploaded log number
+ val retrofit = diaconnLogUploader.getRetrofitInstance()
+ val api = retrofit?.create(DiaconnApiService::class.java)
+ val response = api?.getPumpLastNo(diaconnG8Pump.pumpUid, diaconnG8Pump.pumpVersion, diaconnG8Pump.pumpIncarnationNum)?.execute()
+ if(response?.body()?.ok == true) {
+ aapsLogger.debug(LTag.PUMPCOMM, "pumplog_no = ${response.body()?.info?.pumplog_no}")
+ val platformLastNo = response.body()?.info?.pumplog_no!!
+ val platformWrappingCount: Int = floor(platformLastNo / 10000.0).toInt()
+ val platformLogNo: Int = if (platformLastNo.toInt() == -1) {
+ 9999
+ } else {
+ (platformLastNo % 10000).toInt()
+ }
+ aapsLogger.debug(LTag.PUMPCOMM, "platformLogNo: $platformLogNo, platformWrappingCount: $platformWrappingCount")
+
+ // 페이지 사이즈로 처리할 때 루핑 횟수 계산
+ val (platformStart, platformEnd, platformLoopSize) = getLogLoopCount(platformLogNo, platformWrappingCount, pumpLastNum, pumpWrappingCount, true)
+ if(platformLoopSize > 0) {
+ diaconnG8Pump.isPlatformUploadStarted = true
+ for (i in 0 until platformLoopSize) {
+ rxBus.send(EventPumpStatusChanged("클라우드동기화 진행 중 : $i / $platformLoopSize"))
+ val startLogNo: Int = platformStart + i * pumpLogPageSize
+ val endLogNo: Int = startLogNo + min(platformEnd - startLogNo, pumpLogPageSize)
+ val msg = BigLogInquirePacket(injector, startLogNo, endLogNo, 100)
+ sendMessage(msg, 500)
+ }
+ SystemClock.sleep(1000)
+ diaconnG8Pump.isPlatformUploadStarted = false
+ }
+ }
+ } catch (e:Exception) {
+ aapsLogger.error("Unhandled exception", e)
+ }
+ }
return result
}
+ private fun getLogLoopCount(lastLogNum: Int, wrappingCount: Int, pumpLastNum: Int, pumpWrappingCount: Int, isPlatform: Boolean): Triple {
+ val start: Int// log sync start number
+ val end: Int // log sync end number1311
+ aapsLogger.debug(LTag.PUMPCOMM, "lastLogNum : $lastLogNum, wrappingCount : $wrappingCount , pumpLastNum: $pumpLastNum, pumpWrappingCount : $pumpWrappingCount")
+
+ if ((pumpWrappingCount * 10000 + pumpLastNum - lastLogNum > 10000 && isPlatform)) {
+ start = pumpLastNum
+ end = 10000
+ } else if (pumpWrappingCount > wrappingCount && lastLogNum < 9999) {
+ start = (lastLogNum + 1)
+ end = 10000
+ } else if (pumpWrappingCount > wrappingCount && lastLogNum >= 9999 && isPlatform) {
+ start = 0 // 처음부터 시작
+ end = pumpLastNum
+ } else {
+ start = (lastLogNum + 1)
+ end = pumpLastNum
+ }
+ val size = ceil((end - start) / 11.0).toInt()
+ //
+ return Triple(start, end, size)
+ }
+
fun setUserSettings(): PumpEnactResult {
val result = PumpEnactResult(injector)
@@ -336,7 +387,7 @@ class DiaconnG8Service : DaggerService() {
if (diaconnG8Pump.otpNumber == 0) {
aapsLogger.error(LTag.PUMPCOMM, "otp is not received yet")
result.success(false)
- result.comment("펌프와 연결 상태를 확인해주세요.")
+ result.comment("")
return result
}
sendMessage(AppConfirmSettingPacket(injector, msg.msgType, diaconnG8Pump.otpNumber))
@@ -348,6 +399,13 @@ class DiaconnG8Service : DaggerService() {
fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: EventOverviewBolusProgress.Treatment): Boolean {
if (!isConnected) return false
if (BolusProgressDialog.stopPressed) return false
+
+ // Only Carbs
+ if (carbs > 0 && insulin == 0.0) {
+ pumpSync.syncCarbsWithTimestamp(carbTime, carbs.toDouble(), null, PumpType.DIACONN_G8, diaconnG8Pump.serialNo.toString())
+ return true
+ }
+
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.startingbolus)))
// bolus speed setting
@@ -614,9 +672,9 @@ class DiaconnG8Service : DaggerService() {
(basalList[23] * 100).toInt()
)
// setting basal pattern 1,2,3,4
- sendMessage(requestReqPacket1)
- sendMessage(requestReqPacket2)
- sendMessage(requestReqPacket3)
+ sendMessage(requestReqPacket1, 500)
+ sendMessage(requestReqPacket2, 500)
+ sendMessage(requestReqPacket3, 500)
sendMessage(requestReqPacket4)
// otp process
@@ -634,13 +692,6 @@ class DiaconnG8Service : DaggerService() {
return requestReqPacket4.success()
}
- private fun pumpLogDefaultSetting() {
- val apsWrappingCount = diaconnG8Pump.pumpWrappingCount
- val apsLastLogNum = if (diaconnG8Pump.pumpLastLogNum - 1 < 0) 0 else diaconnG8Pump.pumpLastLogNum - 1
- sp.putInt(rh.gs(R.string.apslastLogNum), apsLastLogNum)
- sp.putInt(rh.gs(R.string.apsWrappingCount), apsWrappingCount)
- }
-
private fun processConfirm(msgType: Byte): Boolean {
// pump confirm
if (diaconnG8Pump.otpNumber == 0) {
@@ -658,7 +709,7 @@ class DiaconnG8Service : DaggerService() {
return false
}
- sendMessage(AppConfirmSettingPacket(injector, msgType, diaconnG8Pump.otpNumber), 2000)
+ sendMessage(AppConfirmSettingPacket(injector, msgType, diaconnG8Pump.otpNumber))
diaconnG8Pump.otpNumber = 0
return true
}
diff --git a/diaconn/src/main/res/values-ko-rKR/strings.xml b/diaconn/src/main/res/values-ko-rKR/strings.xml
index 29cb87c694..f17e4a3c77 100644
--- a/diaconn/src/main/res/values-ko-rKR/strings.xml
+++ b/diaconn/src/main/res/values-ko-rKR/strings.xml
@@ -89,6 +89,8 @@
바늘 교체
로그 동기화 시 케어포털 \"위치 교체\" 정보 자동 업로드
로그 동기화 시 케어포털 \"베터리 교체\" 정보 자동 업로드
+ 펌프 로그정보를 \"디아콘 클라우드\"로 자동 업로드
+ 디아콘 클라우드 전송
베터리 교체
로그 동기화 진행 중
인슐린 부족 경고
diff --git a/diaconn/src/main/res/values/strings.xml b/diaconn/src/main/res/values/strings.xml
index ac1ad0868e..f74b46b0af 100644
--- a/diaconn/src/main/res/values/strings.xml
+++ b/diaconn/src/main/res/values/strings.xml
@@ -10,6 +10,7 @@
diaconn_g8_logbatterychanges
diaconn_g8_loginsulinchange
diaconn_g8_logneedlechange
+ diaconn_g8_cloudsend
Reset Pairing
No Device available
@@ -166,5 +167,7 @@
LGS status is OFF, OFF Command is declined.
Tempbasal start is rejected when tempbasal is running
Tempbasal stop is rejected when tempbasal is not running
-
+ Send pump logs to the Diaconn Cloud.
+ Diaconn Cloud Sync
+ diaconn_g8_appuid
diff --git a/diaconn/src/main/res/xml/pref_diaconn.xml b/diaconn/src/main/res/xml/pref_diaconn.xml
index f81699e887..ec409e5636 100644
--- a/diaconn/src/main/res/xml/pref_diaconn.xml
+++ b/diaconn/src/main/res/xml/pref_diaconn.xml
@@ -45,6 +45,12 @@
android:summary="@string/diaconn_g8_logbatterychange_summary"
android:title="@string/diaconn_g8_logbatterychange_title" />
+
+
\ No newline at end of file
diff --git a/icons/autotune.svg b/icons/autotune.svg
new file mode 100644
index 0000000000..2ecf74c309
--- /dev/null
+++ b/icons/autotune.svg
@@ -0,0 +1,20 @@
+
+
diff --git a/icons/clone_48.svg b/icons/clone_48.svg
new file mode 100644
index 0000000000..8d9b5d62f4
--- /dev/null
+++ b/icons/clone_48.svg
@@ -0,0 +1,9 @@
+
+
diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightPairingActivity.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightPairingActivity.java
index 65d8185d26..97a5c9dfbe 100644
--- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightPairingActivity.java
+++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightPairingActivity.java
@@ -58,7 +58,7 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
private RecyclerView deviceList;
private final DeviceAdapter deviceAdapter = new DeviceAdapter();
- private final int PERMISSION_REQUEST_BLUETOOTH = 30242;
+ private static final int PERMISSION_REQUEST_BLUETOOTH = 30242;
private InsightConnectionService service;
diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt
index 2dd50e1dc4..571eda4c40 100644
--- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt
+++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt
@@ -1364,16 +1364,17 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun handleCommandConfirmation(confirmation: CommandConfirmed) {
val command = confirmation.command
val historyEntry = history.getById(command.historyId)
- aapsLogger.debug(LTag.PUMPCOMM, "handling command confirmation: $confirmation")
+ aapsLogger.debug(LTag.PUMPCOMM, "handling command confirmation: $confirmation ${historyEntry.commandType}")
when (historyEntry.commandType) {
OmnipodCommandType.CANCEL_TEMPORARY_BASAL -> {
if (confirmation.success) {
- pumpSync.syncStopTemporaryBasalWithPumpId(
+ val ret = pumpSync.syncStopTemporaryBasalWithPumpId(
historyEntry.createdAt,
historyEntry.pumpId(),
PumpType.OMNIPOD_DASH,
serialNumber()
)
+ aapsLogger.info(LTag.PUMP, "syncStopTemporaryBasalWithPumpId ret=$ret")
podStateManager.tempBasal = null
}
rxBus.send(EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS))