Merge branch 'meallink' into meallink_ValueWithUnit

This commit is contained in:
Philoul 2021-04-01 08:13:48 +02:00
commit e13e5e10eb
28 changed files with 100 additions and 93 deletions

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.db; package info.nightscout.androidaps.db;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.j256.ormlite.dao.CloseableIterator; import com.j256.ormlite.dao.CloseableIterator;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject; import org.json.JSONObject;
import java.sql.SQLException; import java.sql.SQLException;
@ -78,7 +78,7 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface {
return MainApp.Companion.getDbHelper().createOrUpdate(tempBasal); return MainApp.Companion.getDbHelper().createOrUpdate(tempBasal);
} }
@NonNull @Override public TemporaryBasal findTempBasalByPumpId(long id) { @Nullable @Override public TemporaryBasal findTempBasalByPumpId(long id) {
return MainApp.Companion.getDbHelper().findTempBasalByPumpId(id); return MainApp.Companion.getDbHelper().findTempBasalByPumpId(id);
} }

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.food
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -55,7 +56,7 @@ class FoodPlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
val foods = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) val foods = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
aapsLogger.debug(LTag.DATABASE, "Received Food Data: $foods") aapsLogger.debug(LTag.DATABASE, "Received Food Data: $foods")
var ret = Result.success() var ret = Result.success()
@ -77,7 +78,7 @@ class FoodPlugin @Inject constructor(
repository.runTransactionForResult(SyncNsFoodTransaction(delFood)) repository.runTransactionForResult(SyncNsFoodTransaction(delFood))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while removing food", it) aapsLogger.error(LTag.DATABASE, "Error while removing food", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { .also {
@ -91,7 +92,7 @@ class FoodPlugin @Inject constructor(
repository.runTransactionForResult(SyncNsFoodTransaction(food)) repository.runTransactionForResult(SyncNsFoodTransaction(food))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while adding/updating food", it) aapsLogger.error(LTag.DATABASE, "Error while adding/updating food", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -101,7 +102,7 @@ class FoodPlugin @Inject constructor(
} }
} else { } else {
aapsLogger.error(LTag.DATABASE, "Error parsing food", jsonFood.toString()) aapsLogger.error(LTag.DATABASE, "Error parsing food", jsonFood.toString())
ret = Result.failure() ret = Result.failure(workDataOf("Error" to "Error parsing food"))
} }
} }
} }

View file

@ -1,8 +1,10 @@
package info.nightscout.androidaps.plugins.general.nsclient package info.nightscout.androidaps.plugins.general.nsclient
import android.content.Context import android.content.Context
import androidx.work.Data
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -57,10 +59,10 @@ class NSClientAddUpdateWorker(
override fun doWork(): Result { override fun doWork(): Result {
val acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, true) && buildHelper.isEngineeringMode() || config.NSCLIENT val acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, true) && buildHelper.isEngineeringMode() || config.NSCLIENT
if (!acceptNSData) return Result.failure() if (!acceptNSData) return Result.success()
val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
var ret = Result.success() var ret = Result.success()
var latestDateInReceivedData = 0L var latestDateInReceivedData = 0L
@ -86,7 +88,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsBolusTransaction(bolus)) repository.runTransactionForResult(SyncNsBolusTransaction(bolus))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -112,7 +114,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsCarbsTransaction(carb)) repository.runTransactionForResult(SyncNsCarbsTransaction(carb))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -140,7 +142,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget)) repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -204,7 +206,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent)) repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -36,14 +37,14 @@ class NSClientMbgWorker(
if (!acceptNSData) return ret if (!acceptNSData) return ret
val mbgArray = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) val mbgArray = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
for (i in 0 until mbgArray.length()) { for (i in 0 until mbgArray.length()) {
val nsMbg = NSMbg(mbgArray.getJSONObject(i)) val nsMbg = NSMbg(mbgArray.getJSONObject(i))
if (!nsMbg.isValid()) continue if (!nsMbg.isValid()) continue
repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEventFromNsMbg(nsMbg))) repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEventFromNsMbg(nsMbg)))
.doOnError { .doOnError {
aapsLogger.error("Error while saving therapy event", it) aapsLogger.error("Error while saving therapy event", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { .also {

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -52,12 +53,12 @@ class NSClientRemoveWorker(
override fun doWork(): Result { override fun doWork(): Result {
val acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, true) && buildHelper.isEngineeringMode() || config.NSCLIENT val acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, true) && buildHelper.isEngineeringMode() || config.NSCLIENT
if (!acceptNSData) return Result.failure() if (!acceptNSData) return Result.success()
var ret = Result.success() var ret = Result.success()
val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
for (i in 0 until treatments.length()) { for (i in 0 until treatments.length()) {
val json = treatments.getJSONObject(i) val json = treatments.getJSONObject(i)
@ -68,7 +69,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget)) repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating temporary target", it) aapsLogger.error(LTag.DATABASE, "Error while invalidating temporary target", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -98,7 +99,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent)) repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating therapy event", it) aapsLogger.error(LTag.DATABASE, "Error while invalidating therapy event", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -121,7 +122,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsBolusTransaction(bolus)) repository.runTransactionForResult(SyncNsBolusTransaction(bolus))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating bolus", it) aapsLogger.error(LTag.DATABASE, "Error while invalidating bolus", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -138,7 +139,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsCarbsTransaction(carbs)) repository.runTransactionForResult(SyncNsCarbsTransaction(carbs))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it) aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.general.smsCommunicator package info.nightscout.androidaps.plugins.general.smsCommunicator
import android.telephony.SmsMessage import android.telephony.SmsMessage
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
class Sms { class Sms {

View file

@ -9,6 +9,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
@ -182,8 +183,8 @@ class SmsCommunicatorPlugin @Inject constructor(
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
override fun doWork(): Result { override fun doWork(): Result {
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
val format = bundle.getString("format") ?: return Result.failure() val format = bundle.getString("format") ?: return Result.failure(workDataOf("Error" to "missing format in input data"))
val pdus = bundle["pdus"] as Array<*> val pdus = bundle["pdus"] as Array<*>
for (pdu in pdus) { for (pdu in pdus) {
val message = SmsMessage.createFromPdu(pdu as ByteArray, format) val message = SmsMessage.createFromPdu(pdu as ByteArray, format)

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.profile.ns
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
@ -96,7 +97,7 @@ class NSProfilePlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
val profileString = dataWorker.pickupJSONObject(inputData.getLong(DataWorker.STORE_KEY, -1)) val profileString = dataWorker.pickupJSONObject(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
nsProfilePlugin.profile = ProfileStore(injector, profileString) nsProfilePlugin.profile = ProfileStore(injector, profileString)
nsProfilePlugin.storeNSProfile() nsProfilePlugin.storeNSProfile()
if (nsProfilePlugin.isEnabled()) { if (nsProfilePlugin.isEnabled()) {

View file

@ -74,29 +74,27 @@ open class VirtualPumpPlugin @Inject constructor(
var pumpType: PumpType? = null var pumpType: PumpType? = null
private set private set
private var lastDataTime: Long = 0 private var lastDataTime: Long = 0
override val pumpDescription = PumpDescription() override val pumpDescription = PumpDescription().also {
it.isBolusCapable = true
init { it.bolusStep = 0.1
pumpDescription.isBolusCapable = true it.isExtendedBolusCapable = true
pumpDescription.bolusStep = 0.1 it.extendedBolusStep = 0.05
pumpDescription.isExtendedBolusCapable = true it.extendedBolusDurationStep = 30.0
pumpDescription.extendedBolusStep = 0.05 it.extendedBolusMaxDuration = 8 * 60.toDouble()
pumpDescription.extendedBolusDurationStep = 30.0 it.isTempBasalCapable = true
pumpDescription.extendedBolusMaxDuration = 8 * 60.toDouble() it.tempBasalStyle = PumpDescription.PERCENT or PumpDescription.ABSOLUTE
pumpDescription.isTempBasalCapable = true it.maxTempPercent = 500
pumpDescription.tempBasalStyle = PumpDescription.PERCENT or PumpDescription.ABSOLUTE it.tempPercentStep = 10
pumpDescription.maxTempPercent = 500 it.tempDurationStep = 30
pumpDescription.tempPercentStep = 10 it.tempDurationStep15mAllowed = true
pumpDescription.tempDurationStep = 30 it.tempDurationStep30mAllowed = true
pumpDescription.tempDurationStep15mAllowed = true it.tempMaxDuration = 24 * 60
pumpDescription.tempDurationStep30mAllowed = true it.isSetBasalProfileCapable = true
pumpDescription.tempMaxDuration = 24 * 60 it.basalStep = 0.01
pumpDescription.isSetBasalProfileCapable = true it.basalMinimumRate = 0.01
pumpDescription.basalStep = 0.01 it.isRefillingCapable = true
pumpDescription.basalMinimumRate = 0.01 it.storesCarbInfo = false
pumpDescription.isRefillingCapable = true it.is30minBasalRatesCapable = true
pumpDescription.storesCarbInfo = false
pumpDescription.is30minBasalRatesCapable = true
} }
fun getFakingStatus(): Boolean { fun getFakingStatus(): Boolean {

View file

@ -6,6 +6,7 @@ import android.content.pm.PackageManager
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
@ -97,9 +98,9 @@ class DexcomPlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
var ret = Result.success() var ret = Result.success()
if (!dexcomPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() if (!dexcomPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success()
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
try { try {
val sourceSensor = when (bundle.getString("sensorType") ?: "") { val sourceSensor = when (bundle.getString("sensorType") ?: "") {
"G6" -> GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE "G6" -> GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE
@ -107,7 +108,7 @@ class DexcomPlugin @Inject constructor(
else -> GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN else -> GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN
} }
val glucoseValuesBundle = bundle.getBundle("glucoseValues") val glucoseValuesBundle = bundle.getBundle("glucoseValues")
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing glucoseValues"))
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
for (i in 0 until glucoseValuesBundle.size()) { for (i in 0 until glucoseValuesBundle.size()) {
val glucoseValueBundle = glucoseValuesBundle.getBundle(i.toString())!! val glucoseValueBundle = glucoseValuesBundle.getBundle(i.toString())!!
@ -144,7 +145,7 @@ class DexcomPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Dexcom App", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from Dexcom App", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -161,7 +162,7 @@ class DexcomPlugin @Inject constructor(
} }
} catch (e: Exception) { } catch (e: Exception) {
aapsLogger.error("Error while processing intent from Dexcom App", e) aapsLogger.error("Error while processing intent from Dexcom App", e)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to e))
} }
return ret return ret
} }

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -68,9 +69,9 @@ class EversensePlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
var ret = Result.success() var ret = Result.success()
if (!eversensePlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() if (!eversensePlugin.isEnabled(PluginType.BGSOURCE)) return Result.success()
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase")) if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase"))
if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress")) if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress"))
if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel")) if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel"))
@ -111,7 +112,7 @@ class EversensePlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { savedValues -> .also { savedValues ->
@ -141,7 +142,7 @@ class EversensePlugin @Inject constructor(
)) ))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -55,7 +56,7 @@ class GlimpPlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
var ret = Result.success() var ret = Result.success()
if (!glimpPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() if (!glimpPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success()
aapsLogger.debug(LTag.BGSOURCE, "Received Glimp Data: $inputData}") aapsLogger.debug(LTag.BGSOURCE, "Received Glimp Data: $inputData}")
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += CgmSourceTransaction.TransactionGlucoseValue(
@ -69,7 +70,7 @@ class GlimpPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Glimp App", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from Glimp App", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { savedValues -> .also { savedValues ->

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -60,8 +61,8 @@ class MM640gPlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
var ret = Result.success() var ret = Result.success()
if (!mM640gPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() if (!mM640gPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success()
val collection = inputData.getString("collection") ?: return Result.failure() val collection = inputData.getString("collection") ?: return Result.failure(workDataOf("Error" to "missing collection"))
if (collection == "entries") { if (collection == "entries") {
val data = inputData.getString("data") val data = inputData.getString("data")
aapsLogger.debug(LTag.BGSOURCE, "Received MM640g Data: $data") aapsLogger.debug(LTag.BGSOURCE, "Received MM640g Data: $data")
@ -87,7 +88,7 @@ class MM640gPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { savedValues -> .also { savedValues ->
@ -98,7 +99,7 @@ class MM640gPlugin @Inject constructor(
} }
} catch (e: JSONException) { } catch (e: JSONException) {
aapsLogger.error("Exception: ", e) aapsLogger.error("Exception: ", e)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to e))
} }
} }
} }

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
@ -117,7 +118,7 @@ class NSClientSourcePlugin @Inject constructor(
if (!nsClientSourcePlugin.isEnabled() && !sp.getBoolean(R.string.key_ns_autobackfill, true) && !dexcomPlugin.isEnabled()) return Result.success() if (!nsClientSourcePlugin.isEnabled() && !sp.getBoolean(R.string.key_ns_autobackfill, true) && !dexcomPlugin.isEnabled()) return Result.success()
val sgvs = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) val sgvs = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
try { try {
var latestDateInReceivedData: Long = 0 var latestDateInReceivedData: Long = 0
@ -141,7 +142,7 @@ class NSClientSourcePlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null, !nsClientSourcePlugin.isEnabled())) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null, !nsClientSourcePlugin.isEnabled()))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from NSClient App", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from NSClient App", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
@ -158,7 +159,7 @@ class NSClientSourcePlugin @Inject constructor(
} }
} catch (e: Exception) { } catch (e: Exception) {
aapsLogger.error("Unhandled exception", e) aapsLogger.error("Unhandled exception", e)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to e))
} }
// Objectives 0 // Objectives 0
sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true) sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true)

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
@ -59,7 +60,7 @@ class PoctechPlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
var ret = Result.success() var ret = Result.success()
if (!poctechPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() if (!poctechPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success()
aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data $inputData") aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data $inputData")
try { try {
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
@ -80,7 +81,7 @@ class PoctechPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Poctech App", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from Poctech App", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { savedValues -> .also { savedValues ->
@ -91,7 +92,7 @@ class PoctechPlugin @Inject constructor(
} }
} catch (e: JSONException) { } catch (e: JSONException) {
aapsLogger.error("Exception: ", e) aapsLogger.error("Exception: ", e)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to e))
} }
return ret return ret
} }

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -60,7 +61,7 @@ class TomatoPlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
var ret = Result.success() var ret = Result.success()
if (!tomatoPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() if (!tomatoPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success()
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += CgmSourceTransaction.TransactionGlucoseValue(
timestamp = inputData.getLong("com.fanqies.tomatofn.Extras.Time", 0), timestamp = inputData.getLong("com.fanqies.tomatofn.Extras.Time", 0),
@ -73,7 +74,7 @@ class TomatoPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Tomato App", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from Tomato App", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { savedValues -> .also { savedValues ->

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
@ -72,9 +73,9 @@ class XdripPlugin @Inject constructor(
override fun doWork(): Result { override fun doWork(): Result {
var ret = Result.success() var ret = Result.success()
if (!xdripPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() if (!xdripPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success()
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
?: return Result.failure() ?: return Result.failure(workDataOf("Error" to "missing input data"))
aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: $bundle") aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: $bundle")
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
@ -90,7 +91,7 @@ class XdripPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Xdrip", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from Xdrip", it)
ret = Result.failure() ret = Result.failure(workDataOf("Error" to it))
} }
.blockingGet() .blockingGet()
.also { savedValues -> .also { savedValues ->

View file

@ -95,7 +95,6 @@ public class TimeListEdit {
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
llp.setMargins(0, 5, 0, 5); llp.setMargins(0, 5, 0, 5);
textlabel.setLayoutParams(llp); textlabel.setLayoutParams(llp);
//textlabel.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.linearBlockBackground));
TextViewCompat.setTextAppearance(textlabel, android.R.style.TextAppearance_Medium); TextViewCompat.setTextAppearance(textlabel, android.R.style.TextAppearance_Medium);
layout.addView(textlabel); layout.addView(textlabel);

View file

@ -143,7 +143,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, repository) hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, repository)
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config(), uel) objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config(), uel)
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsInterface, sp, commandQueue, context, databaseHelper) comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsInterface, sp, commandQueue, context, databaseHelper)
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy) danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync)
danaRSPlugin = DanaRSPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil) danaRSPlugin = DanaRSPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsInterface, sp, commandQueue, profileFunction, nsUpload, context, uploadQueue, Config(), dateUtil, databaseHelper, pumpSync) insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsInterface, sp, commandQueue, profileFunction, nsUpload, context, uploadQueue, Config(), dateUtil, databaseHelper, pumpSync)
openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsInterface, iobCobCalculator, hardLimits, profiler, sp, dateUtil, repository, glucoseStatusProvider) openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsInterface, iobCobCalculator, hardLimits, profiler, sp, dateUtil, repository, glucoseStatusProvider)

View file

@ -8,13 +8,10 @@ import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpDescription
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
@ -34,7 +31,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class) @RunWith(PowerMockRunner::class)
@PrepareForTest(ConstraintChecker::class, ReceiverStatusStore::class) @PrepareForTest(ConstraintChecker::class, ReceiverStatusStore::class, RunningConfiguration::class)
class LoopPluginTest : TestBase() { class LoopPluginTest : TestBase() {
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@ -54,13 +51,14 @@ class LoopPluginTest : TestBase() {
@Mock lateinit var notificationManager: NotificationManager @Mock lateinit var notificationManager: NotificationManager
@Mock lateinit var repository: AppRepository @Mock lateinit var repository: AppRepository
@Mock lateinit var dateUtil: DateUtil @Mock lateinit var dateUtil: DateUtil
@Mock lateinit var runningConfiguration: RunningConfiguration
private lateinit var loopPlugin: LoopPlugin private lateinit var loopPlugin: LoopPlugin
val injector = HasAndroidInjector { AndroidInjector { } } val injector = HasAndroidInjector { AndroidInjector { } }
@Before fun prepareMock() { @Before fun prepareMock() {
loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, Config(), constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, nsUpload, dateUtil, repository) loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, Config(), constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, nsUpload, dateUtil, repository, runningConfiguration)
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
`when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager) `when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager)
} }

View file

@ -25,7 +25,6 @@ class LabelWithElement(
textViewPre.text = textPre textViewPre.text = textPre
textViewPre.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, textViewPre.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT) ViewGroup.LayoutParams.WRAP_CONTENT)
//textViewPre.setWidth(MainApp.dpToPx(120));
textViewPre.setPadding(px, px, px, px) textViewPre.setPadding(px, px, px, px)
textViewPre.setTypeface(textViewPre.typeface, Typeface.BOLD) textViewPre.setTypeface(textViewPre.typeface, Typeface.BOLD)
layout.addView(textViewPre) layout.addView(textViewPre)
@ -40,7 +39,6 @@ class LabelWithElement(
textViewPost.text = textPost textViewPost.text = textPost
textViewPost.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, textViewPost.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT) ViewGroup.LayoutParams.WRAP_CONTENT)
//textViewPost.setWidth(MainApp.dpToPx(45));
textViewPost.setPadding(px, px, px, px) textViewPost.setPadding(px, px, px, px)
textViewPost.setTypeface(textViewPost.typeface, Typeface.BOLD) textViewPost.setTypeface(textViewPost.typeface, Typeface.BOLD)
layout.addView(textViewPost) layout.addView(textViewPost)

View file

@ -30,7 +30,7 @@ interface DatabaseHelperInterface {
fun roundDateToSec(date: Long): Long fun roundDateToSec(date: Long): Long
fun createOrUpdateTDD(record: TDD) fun createOrUpdateTDD(record: TDD)
fun createOrUpdate(tempBasal: TemporaryBasal): Boolean fun createOrUpdate(tempBasal: TemporaryBasal): Boolean
fun findTempBasalByPumpId(id: Long): TemporaryBasal fun findTempBasalByPumpId(id: Long): TemporaryBasal?
fun getTemporaryBasalsDataFromTime(mills: Long, ascending: Boolean): List<TemporaryBasal> fun getTemporaryBasalsDataFromTime(mills: Long, ascending: Boolean): List<TemporaryBasal>
fun getExtendedBolusDataFromTime(mills: Long, ascending: Boolean): List<ExtendedBolus> fun getExtendedBolusDataFromTime(mills: Long, ascending: Boolean): List<ExtendedBolus>
fun getProfileSwitchEventsFromTime(from: Long, to: Long, ascending: Boolean): List<ProfileSwitch> fun getProfileSwitchEventsFromTime(from: Long, to: Long, ascending: Boolean): List<ProfileSwitch>

View file

@ -37,7 +37,7 @@ fun buildDeviceStatus(
version: String version: String
): DeviceStatus? { ): DeviceStatus? {
val profile = profileFunction.getProfile() ?: return null val profile = profileFunction.getProfile() ?: return null
val profileName = profileFunction.getProfileName() ?: return null val profileName = profileFunction.getProfileName()
val lastRun = loopPlugin.lastRun val lastRun = loopPlugin.lastRun
var apsResult: JSONObject? = null var apsResult: JSONObject? = null

View file

@ -105,7 +105,6 @@ class ProfileTest : TestBaseWithProfile() {
//Test basal profile below limit //Test basal profile below limit
p = Profile(profileInjector, JSONObject(belowLimitValidProfile), 100, 0) p = Profile(profileInjector, JSONObject(belowLimitValidProfile), 100, 0)
p.isValid("Test") p.isValid("Test")
//Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent);
// Test profile w/o units // Test profile w/o units
p = Profile(profileInjector, JSONObject(noUnitsValidProfile), 100, 0) p = Profile(profileInjector, JSONObject(noUnitsValidProfile), 100, 0)
@ -142,9 +141,7 @@ class ProfileTest : TestBaseWithProfile() {
// Test hour alignment // Test hour alignment
testPumpPlugin.pumpDescription.is30minBasalRatesCapable = false testPumpPlugin.pumpDescription.is30minBasalRatesCapable = false
//((AAPSMocker.MockedBus) MainApp.bus()).notificationSent = false;
p = Profile(profileInjector, JSONObject(notAlignedBasalValidProfile), 100, 0) p = Profile(profileInjector, JSONObject(notAlignedBasalValidProfile), 100, 0)
p.isValid("Test") p.isValid("Test")
//Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent);
} }
} }

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.danar.R
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
@ -30,6 +31,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
@Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var constraintChecker: ConstraintChecker
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@Mock lateinit var commandQueue: CommandQueueProvider @Mock lateinit var commandQueue: CommandQueueProvider
@Mock lateinit var pumpSync: PumpSync
lateinit var danaPump: DanaPump lateinit var danaPump: DanaPump
@ -46,7 +48,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") `when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
danaPump = DanaPump(aapsLogger, sp, injector) danaPump = DanaPump(aapsLogger, sp, injector)
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy) danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync)
} }
@Test @Throws(Exception::class) @Test @Throws(Exception::class)

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.danar.R
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import org.junit.Before import org.junit.Before
@ -30,6 +31,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
@Mock lateinit var sp: info.nightscout.androidaps.utils.sharedPreferences.SP @Mock lateinit var sp: info.nightscout.androidaps.utils.sharedPreferences.SP
@Mock lateinit var commandQueue: CommandQueueProvider @Mock lateinit var commandQueue: CommandQueueProvider
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
@Mock lateinit var pumpSync: PumpSync
lateinit var danaPump: DanaPump lateinit var danaPump: DanaPump
@ -46,7 +48,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") `when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
danaPump = DanaPump(aapsLogger, sp, injector) danaPump = DanaPump(aapsLogger, sp, injector)
danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, danaPump, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, detailedBolusInfoStorage, dateUtil, fabricPrivacy) danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, danaPump, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, detailedBolusInfoStorage, dateUtil, fabricPrivacy, pumpSync)
} }
@Test @Test

View file

@ -9,11 +9,10 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
* Created by andy on 6/16/18. * Created by andy on 6/16/18.
*/ */
//@RunWith(PowerMockRunner.class) //@RunWith(PowerMockRunner.class)
//@PrepareForTest({ MainApp.class, DatabaseHelper.class, DateUtil.class, SP.class }) //@PrepareForTest({ DatabaseHelper.class, DateUtil.class, SP.class })
@Ignore @Ignore
public class BasalProfileUTest { public class BasalProfileUTest {
/* /*
// MainApp mainApp = new MainApp();
@Before @Before
public void initMocking() { public void initMocking() {