commit
42b5c94755
63 changed files with 208 additions and 120 deletions
|
@ -177,6 +177,7 @@ dependencies {
|
|||
wearApp project(':wear')
|
||||
|
||||
implementation project(':core')
|
||||
implementation project(':combo')
|
||||
implementation project(':database')
|
||||
implementation project(':dana')
|
||||
implementation project(':danars')
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
<string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string>
|
||||
<string name="description_profile_local">Define a profile which is available offline.</string>
|
||||
<string name="description_profile_nightscout">Provides the profile you have defined in Nightscout</string>
|
||||
<string name="description_pump_combo">Pump integration for Accu-Chek Combo pumps, requires having ruffy installed</string>
|
||||
<string name="description_pump_mdi">Pump integration for people who do multiple daily injections for their diabetes therapy</string>
|
||||
<string name="description_pump_virtual">Pump integration for pumps which don\'t have any driver yet (Open Loop)</string>
|
||||
<string name="description_sensitivity_aaps">Sensitivity is calculated the same way like Oref0, but you can specify timeframe to the past. Minimal carb absorption is calculated from max carb absorption time from preferences.</string>
|
||||
|
@ -92,7 +91,6 @@
|
|||
<string name="treatments_wizard_bolusiob_label">Bolus IOB</string>
|
||||
<string name="openapsma_run">Run now</string>
|
||||
<string name="vitualpump_label">VIRTUAL PUMP</string>
|
||||
<string name="virtualpump_resultok">OK</string>
|
||||
<string name="openapsma_lastrun_label">Last run</string>
|
||||
<string name="openapsma_inputparameters_label">Input parameters</string>
|
||||
<string name="openapsma_glucosestatus_label">Glucose status</string>
|
||||
|
@ -163,7 +161,6 @@
|
|||
<string name="openloop_newsuggestion">New suggestion available</string>
|
||||
<string name="carbssuggestion">Carbs Suggestion</string>
|
||||
<string name="unsupportednsversion">Unsupported version of Nightscout</string>
|
||||
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
|
||||
<string name="treatments_wizard_basaliob_label">Basal IOB</string>
|
||||
<string name="bolusconstraintapplied">Bolus constraint applied</string>
|
||||
<string name="carbsconstraintapplied">Carbs constraint applied</string>
|
||||
|
@ -233,7 +230,6 @@
|
|||
<string name="smscommunicator_remotebolusmindistance_summary">Minimum number of minutes that must elapse between one remote bolus and the next</string>
|
||||
<string name="smscommunicator_remotebolusmindistance">How many minutes must elapse, at least, between one bolus and the next</string>
|
||||
<string name="smscommunicator_remotebolusmindistance_caveat">For your safety, to edit this preference you need to add at least 2 phone numbers.</string>
|
||||
<string name="bolusdelivered">Bolus %1$.2f U delivered successfully</string>
|
||||
<string name="bolusrequested">Going to deliver %1$.2f U</string>
|
||||
<string name="smscommunicator_bolusdelivered">Bolus %1$.2f U delivered successfully</string>
|
||||
<string name="smscommunicator_mealbolusdelivered">Meal Bolus %1$.2f U delivered successfully</string>
|
||||
|
@ -241,8 +237,6 @@
|
|||
<string name="smscommunicator_tt_set">Target %1$s for %2$d minutes set successfully</string>
|
||||
<string name="smscommunicator_tt_canceled">Temp Target canceled successfully</string>
|
||||
<string name="smscommunicator_remotecommandsallowed">Allow remote commands via SMS</string>
|
||||
<string name="bolusstopped">Bolus stopped</string>
|
||||
<string name="bolusstopping">Stopping bolus</string>
|
||||
<string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string>
|
||||
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>
|
||||
<string name="smscommunicator_loopisdisabled">Loop is disabled</string>
|
||||
|
@ -556,8 +550,6 @@
|
|||
<string name="mdtp_cancel">Cancel</string>
|
||||
<string name="notloadedplugins">Not all profiles loaded!</string>
|
||||
<string name="valuesnotstored">Values not stored!</string>
|
||||
<string name="combopump" translatable="false">Accu-Chek Combo</string>
|
||||
<string name="combopump_shortname" translatable="false">COMBO</string>
|
||||
<string name="ns_localbroadcasts">Enable broadcasts to other apps (like xDrip+). Do not enable if you have more than one instance of AAPS or NSClient installed!</string>
|
||||
<string name="ns_localbroadcasts_title">Enable local Broadcasts.</string>
|
||||
<string name="careportal_newnstreatment_duration_min_label">Duration [min]</string>
|
||||
|
@ -602,7 +594,6 @@
|
|||
<string name="shortfat">Fat</string>
|
||||
<string name="active"><![CDATA[<Active>]]></string>
|
||||
<string name="executingrightnow">Command is executed right now</string>
|
||||
<string name="pump_unreachable">Pump unreachable</string>
|
||||
<string name="missed_bg_readings">Missed BG readings</string>
|
||||
<string name="key_raise_notifications_as_android_notifications" translatable="false">raise_urgent_alarms_as_android_notification</string>
|
||||
<string name="raise_notifications_as_android_notifications">Use system notifications for alerts and notifications</string>
|
||||
|
@ -650,40 +641,6 @@
|
|||
<string name="closedmodeenabled">Closed mode enabled</string>
|
||||
<string name="maxiobset">Maximal IOB set properly</string>
|
||||
<string name="hasbgdata">BG available from selected source</string>
|
||||
<string name="combo_programming_bolus">Programming pump for bolusing</string>
|
||||
<string name="combo_pump_state_label">State</string>
|
||||
<string name="combo_pump_activity_label">Activity</string>
|
||||
<string name="combo_no_pump_connection">No connection for %1$d min</string>
|
||||
<string name="combo_tbr_remaining">%1$d%% (%2$d min remaining)</string>
|
||||
<string name="combo_last_bolus" translatable="false">%1$.1f %2$s (%3$s)</string>
|
||||
<string name="combo_pump_state_initializing">Initializing</string>
|
||||
<string name="combo_pump_state_suspended_due_to_error">Suspended due to error</string>
|
||||
<string name="combo_pump_state_suspended_by_user">Suspended by user</string>
|
||||
<string name="combo_pump_state_running">Running</string>
|
||||
<string name="combo_pump_action_cancelling_tbr">Cancelling TBR</string>
|
||||
<string name="combo_pump_action_setting_tbr">Setting TBR (%1$d%% / %2$d min)</string>
|
||||
<string name="combo_pump_action_bolusing">Bolusing (%1$.1f U)</string>
|
||||
<string name="combo_pump_action_refreshing">Refreshing</string>
|
||||
<string name="combo_pump_unsupported_operation">Requested operation not supported by pump</string>
|
||||
<string name="combo_low_suspend_forced_notification">Unsafe usage: extended or multiwave boluses are active. Loop mode has been set to low-suspend only 6 hours. Only normal boluses are supported in loop mode</string>
|
||||
<string name="combo_force_disabled_notification">Unsafe usage: the pump uses a different basal rate profile than the first. The loop has been disabled. Select the first profile on the pump and refresh.</string>
|
||||
<string name="bolus_frequency_exceeded">A bolus with the same amount was requested within the last two minutes. To prevent accidental double boluses and to guard against bugs this is disallowed.</string>
|
||||
<string name="combo_pump_connected_now">Now</string>
|
||||
<string name="combo_activity_reading_pump_history">Reading pump history</string>
|
||||
<string name="combo_activity_setting_basal_profile">Setting basal profile</string>
|
||||
<string name="combo_pump_cartridge_low_warrning">Pump cartridge level is low</string>
|
||||
<string name="combo_pump_battery_low_warrning">Pump battery is low</string>
|
||||
<string name="combo_is_in_error_state">The pump is showing the error E%1$d: %2$s</string>
|
||||
<string name="combo_reservoir_low">Low</string>
|
||||
<string name="combo_reservoir_empty">Empty</string>
|
||||
<string name="combo_reservoir_normal">Normal</string>
|
||||
<string name="combo_notification_check_time_date">Pump clock update needed</string>
|
||||
<string name="combo_pump_tbr_cancelled_warrning">TBR CANCELLED warning was confirmed</string>
|
||||
<string name="combo_error_no_connection_no_bolus_delivered">The pump could not be reached. No bolus was given</string>
|
||||
<string name="combo_error_no_bolus_delivered">Bolus delivery failed. It appears no bolus was delivered. To be sure, please check the pump to avoid a double bolus and then bolus again. To guard against bugs, boluses are not automatically retried.</string>
|
||||
<string name="combo_error_partial_bolus_delivered">Only %1$.2f U of the requested bolus of %2$.2f U was delivered due to an error. Please check the pump to verify this and take appropriate actions.</string>
|
||||
<string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump. If a bolus was delivered, it will be added to treatments during the next connection to the pump.</string>
|
||||
<string name="combo_reservoir_level_insufficient_for_bolus">Not enough insulin for bolus left in reservoir</string>
|
||||
<string name="extendedbolusdeliveryerror">Extended bolus delivery error</string>
|
||||
<string name="insightpump_shortname">Sight</string>
|
||||
<string name="key_enableSMB_always" translatable="false">enableSMB_always</string>
|
||||
|
@ -763,23 +720,8 @@
|
|||
<string name="closed_loop_disabled_on_dev_branch">Running dev version. Closed loop is disabled.</string>
|
||||
<string name="key_fromNSAreCommingFakedExtendedBoluses" translatable="false">fromNSAreCommingFakedExtendedBoluses</string>
|
||||
<string name="engineering_mode_enabled">Engineering mode enabled</string>
|
||||
<string name="combo_actvity_reading_basal_profile">Reading basal profile</string>
|
||||
<string name="combo_bolus_rejected_due_to_pump_history_change">The pump history has changed after the bolus calculation was performed. The bolus was not delivered. Please recalculate if a bolus is still needed.</string>
|
||||
<string name="combo_error_updating_treatment_record">Bolus successfully delivered, but adding the treatment entry failed. This can happen if two small boluses of the same size are administered within the last two minutes. Please check the pump history and treatment entries and use the Careportal to add missing entries. Make sure not to add any entries for the exact same minute and same amount.</string>
|
||||
<string name="combo_high_temp_rejected_due_to_pump_history_changes">Rejecting high temp since calculation didn\'t consider recently changed pump history</string>
|
||||
<string name="combo_activity_checking_pump_state">Refreshing pump state</string>
|
||||
<string name="combo_warning_pump_basal_rate_changed">The basal rate on the pump has changed and will be updated soon</string>
|
||||
<string name="combo_error_failure_reading_changed_basal_rate">Basal rate changed on pump, but reading it failed</string>
|
||||
<string name="combo_activity_checking_for_history_changes">Checking for history changes</string>
|
||||
<string name="combo_error_multiple_boluses_with_identical_timestamp">Multiple boluses with the same amount within the same minute were just imported. Only one record could be added to treatments. Please check the pump and manually add a bolus record using the Careportal tab. Make sure to create a bolus with a time no other bolus uses.</string>
|
||||
<string name="about_link_urls">\n\ndocumentation:\nhttps://androidaps.readthedocs.io\n\nfacebook:\nhttps://www.facebook.com/groups/AndroidAPSUsers</string>
|
||||
<string name="combo_check_date">The last bolus is older than 24 hours or is in the future. Please check the date on the pump is set correctly.</string>
|
||||
<string name="combo_suspious_bolus_time">Time/date of the delivered bolus on pump seems wrong, IOB is likely incorrect. Please check pump time/date.</string>
|
||||
<string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string>
|
||||
<string name="combo_bolus_count">Bolus count</string>
|
||||
<string name="combo_tbr_count">TBR count</string>
|
||||
<string name="pumpisnottempbasalcapable">Pump is not temp basal capable</string>
|
||||
<string name="novalidbasalrate">No valid basal rate read from pump</string>
|
||||
<string name="closedmodedisabledinpreferences">Closed loop mode disabled in preferences</string>
|
||||
<string name="autosensdisabledinpreferences">Autosens disabled in preferences</string>
|
||||
<string name="smbdisabledinpreferences">SMB disabled in preferences</string>
|
||||
|
@ -795,13 +737,11 @@
|
|||
<string name="basal_set_correctly">Basal set correctly</string>
|
||||
<string name="key_treatmentssafety_maxbolus" translatable="false">treatmentssafety_maxbolus</string>
|
||||
<string name="limitingextendedbolus">Limiting extended bolus to %1$.1f U because of %2$s</string>
|
||||
<string name="limitingmaxiob">Limiting max IOB to %1$.1f U because of %2$s</string>
|
||||
<string name="limitingcarbs">Limiting carbs to %1$d g because of %2$s</string>
|
||||
<string name="limitingiob">Limiting IOB to %1$.1f U because of %2$s</string>
|
||||
<string name="maxvalueinpreferences">max value in preferences</string>
|
||||
<string name="hardlimit">hard limit</string>
|
||||
<string name="key_treatmentssafety_maxcarbs" translatable="false">treatmentssafety_maxcarbs</string>
|
||||
<string name="unsafeusage">unsafe usage</string>
|
||||
<string name="key_openapsama_useautosens" translatable="false">openapsama_useautosens</string>
|
||||
<string name="readstatusfailed">Read status failed</string>
|
||||
<string name="record_pump_site_change">Record pump site change</string>
|
||||
|
@ -910,7 +850,6 @@
|
|||
<string name="key_sensitivity_raises_target" translatable="false">sensitivity_raises_target</string>
|
||||
<string name="sensitivity_raises_target_title">Sensitivity raises target</string>
|
||||
<string name="sensitivity_raises_target_summary">When sensitivity is detected, raise the target glucose</string>
|
||||
<string name="combo_invalid_setup">Invalid pump setup, check the docs and verify that the Quick Info menu is named QUICK INFO using the 360 configuration software.</string>
|
||||
<string name="key_keep_screen_on" translatable="false">keep_screen_on</string>
|
||||
<string name="careportal_removestartedevents">Clean AndroidAPS started</string>
|
||||
<string name="storedsettingsfound">Stored settings found</string>
|
||||
|
|
|
@ -69,10 +69,11 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
|||
@Mock lateinit var uploadQueue: UploadQueue
|
||||
@Mock lateinit var uel: UserEntryLogger
|
||||
@Mock lateinit var loggerUtils: LoggerUtils
|
||||
@Mock lateinit var databaseHelper: DatabaseHelperInterface
|
||||
|
||||
lateinit var danaPump: DanaPump
|
||||
private lateinit var danaPump: DanaPump
|
||||
|
||||
lateinit var constraintChecker: ConstraintChecker
|
||||
private lateinit var constraintChecker: ConstraintChecker
|
||||
private lateinit var safetyPlugin: SafetyPlugin
|
||||
private lateinit var objectivesPlugin: ObjectivesPlugin
|
||||
private lateinit var comboPlugin: ComboPlugin
|
||||
|
@ -123,7 +124,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
|||
danaPump = DanaPump(aapsLogger, sp, injector)
|
||||
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, nsUpload)
|
||||
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config(), uel)
|
||||
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsInterface, sp, commandQueue, context)
|
||||
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)
|
||||
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)
|
||||
|
|
1
combo/.gitignore
vendored
Normal file
1
combo/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
20
combo/build.gradle
Normal file
20
combo/build.gradle
Normal file
|
@ -0,0 +1,20 @@
|
|||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'com.hiya.jacoco-android'
|
||||
|
||||
apply from: "${project.rootDir}/gradle/android_dependencies.gradle"
|
||||
apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle"
|
||||
apply from: "${project.rootDir}/gradle/test_dependencies.gradle"
|
||||
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':core')
|
||||
}
|
0
combo/consumer-rules.pro
Normal file
0
combo/consumer-rules.pro
Normal file
21
combo/proguard-rules.pro
vendored
Normal file
21
combo/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
5
combo/src/main/AndroidManifest.xml
Normal file
5
combo/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="info.nightscout.androidaps.combo">
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,7 @@
|
|||
package info.nightscout.androidaps.combo.di
|
||||
|
||||
import dagger.Module
|
||||
|
||||
@Module(includes = [
|
||||
])
|
||||
open class ComboModule
|
|
@ -16,13 +16,13 @@ import androidx.fragment.app.FragmentActivity;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.support.DaggerFragment;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.combo.R;
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.combo.events.EventComboPumpUpdateGUI;
|
||||
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.PumpState;
|
||||
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Bolus;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
|
@ -31,9 +31,9 @@ import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
|||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
||||
public class ComboFragment extends DaggerFragment implements View.OnClickListener {
|
||||
public class ComboFragment extends DaggerFragment {
|
||||
@Inject ComboPlugin comboPlugin;
|
||||
@Inject CommandQueue commandQueue;
|
||||
@Inject CommandQueueProvider commandQueue;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject RxBusWrapper rxBus;
|
||||
@Inject SP sp;
|
||||
|
@ -71,7 +71,15 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
|||
tbrCount = view.findViewById(R.id.combo_tbr_count);
|
||||
|
||||
refreshButton = view.findViewById(R.id.combo_refresh_button);
|
||||
refreshButton.setOnClickListener(this);
|
||||
refreshButton.setOnClickListener(v -> {
|
||||
refreshButton.setEnabled(false);
|
||||
commandQueue.readStatus("User request", new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(() -> refreshButton.setEnabled(true));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -105,21 +113,6 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.combo_refresh_button:
|
||||
refreshButton.setEnabled(false);
|
||||
commandQueue.readStatus("User request", new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(() -> refreshButton.setEnabled(true));
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGui() {
|
||||
|
||||
// state
|
|
@ -6,6 +6,7 @@ import android.os.SystemClock;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,8 +21,7 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.combo.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
|
@ -35,6 +35,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
|||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||
|
@ -64,10 +65,8 @@ import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.PumpH
|
|||
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.PumpHistoryRequest;
|
||||
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Tdd;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.InstanceId;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
@ -79,13 +78,13 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
||||
static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
||||
|
||||
private final ResourceHelper resourceHelper;
|
||||
private final ProfileFunction profileFunction;
|
||||
private final TreatmentsInterface treatmentsPlugin;
|
||||
private final info.nightscout.androidaps.utils.sharedPreferences.SP sp;
|
||||
private RxBusWrapper rxBus;
|
||||
private final CommandQueueProvider commandQueue;
|
||||
private final Context context;
|
||||
private final DatabaseHelperInterface databaseHelper;
|
||||
|
||||
private final static PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
|
@ -140,7 +139,8 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
TreatmentsInterface treatmentsPlugin,
|
||||
SP sp,
|
||||
CommandQueueProvider commandQueue,
|
||||
Context context
|
||||
Context context,
|
||||
DatabaseHelperInterface databaseHelper
|
||||
) {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
|
@ -152,12 +152,12 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
injector, aapsLogger, resourceHelper, commandQueue
|
||||
);
|
||||
this.rxBus = rxBus;
|
||||
this.resourceHelper = resourceHelper;
|
||||
this.profileFunction = profileFunction;
|
||||
this.treatmentsPlugin = treatmentsPlugin;
|
||||
this.sp = sp;
|
||||
this.commandQueue = commandQueue;
|
||||
this.context = context;
|
||||
this.databaseHelper = databaseHelper;
|
||||
|
||||
pumpDescription.setPumpDescription(PumpType.AccuChekCombo);
|
||||
}
|
||||
|
@ -752,9 +752,9 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
}
|
||||
|
||||
if (adjustedPercent % 10 != 0) {
|
||||
Long rounded = Math.round(adjustedPercent / 10d) * 10;
|
||||
long rounded = Math.round(adjustedPercent / 10d) * 10;
|
||||
getAapsLogger().debug(LTag.PUMP, "Rounded requested percentage:" + adjustedPercent + " -> " + rounded);
|
||||
adjustedPercent = rounded.intValue();
|
||||
adjustedPercent = (int) rounded;
|
||||
}
|
||||
|
||||
// do a soft TBR-cancel when requested rate was rounded to 100% (>94% && <104%)
|
||||
|
@ -964,8 +964,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
checkAndResolveTbrMismatch(preCheckResult.state);
|
||||
checkPumpTime(preCheckResult.state);
|
||||
checkBasalRate(preCheckResult.state);
|
||||
CommandResult historyCheckError = checkHistory();
|
||||
return historyCheckError;
|
||||
return checkHistory();
|
||||
} else {
|
||||
long now = System.currentTimeMillis();
|
||||
TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistory(now);
|
||||
|
@ -1256,7 +1255,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
}
|
||||
|
||||
@NonNull @Override
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
|
||||
public JSONObject getJSONStatus(@NotNull Profile profile, @NotNull String profileName, @NotNull String version) {
|
||||
if (!pump.initialized) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1360,7 +1359,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
Collection<TDD> uniqueColl = map.values();
|
||||
|
||||
for (TDD currTdd : uniqueColl) {
|
||||
MainApp.getDbHelper().createOrUpdateTDD(currTdd);
|
||||
databaseHelper.createOrUpdateTDD(currTdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1390,10 +1389,4 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
public boolean canHandleDST() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timezoneOrDSTChanged(TimeChangeType changeType) {
|
||||
}
|
||||
|
||||
|
||||
}
|
57
combo/src/main/res/values/strings.xml
Normal file
57
combo/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="combopump" translatable="false">Accu-Chek Combo</string>
|
||||
<string name="combopump_shortname" translatable="false">COMBO</string>
|
||||
<string name="description_pump_combo">Pump integration for Accu-Chek Combo pumps, requires having ruffy installed</string>
|
||||
<string name="combo_programming_bolus">Programming pump for bolusing</string>
|
||||
<string name="combo_pump_state_label">State</string>
|
||||
<string name="combo_pump_activity_label">Activity</string>
|
||||
<string name="combo_no_pump_connection">No connection for %1$d min</string>
|
||||
<string name="combo_tbr_remaining">%1$d%% (%2$d min remaining)</string>
|
||||
<string name="combo_last_bolus" translatable="false">%1$.1f %2$s (%3$s)</string>
|
||||
<string name="combo_pump_state_initializing">Initializing</string>
|
||||
<string name="combo_pump_state_suspended_due_to_error">Suspended due to error</string>
|
||||
<string name="combo_pump_state_suspended_by_user">Suspended by user</string>
|
||||
<string name="combo_pump_state_running">Running</string>
|
||||
<string name="combo_pump_action_cancelling_tbr">Cancelling TBR</string>
|
||||
<string name="combo_pump_action_setting_tbr">Setting TBR (%1$d%% / %2$d min)</string>
|
||||
<string name="combo_pump_action_bolusing">Bolusing (%1$.1f U)</string>
|
||||
<string name="combo_pump_action_refreshing">Refreshing</string>
|
||||
<string name="combo_pump_unsupported_operation">Requested operation not supported by pump</string>
|
||||
<string name="combo_low_suspend_forced_notification">Unsafe usage: extended or multiwave boluses are active. Loop mode has been set to low-suspend only 6 hours. Only normal boluses are supported in loop mode</string>
|
||||
<string name="combo_force_disabled_notification">Unsafe usage: the pump uses a different basal rate profile than the first. The loop has been disabled. Select the first profile on the pump and refresh.</string>
|
||||
<string name="bolus_frequency_exceeded">A bolus with the same amount was requested within the last two minutes. To prevent accidental double boluses and to guard against bugs this is disallowed.</string>
|
||||
<string name="combo_pump_connected_now">Now</string>
|
||||
<string name="combo_activity_reading_pump_history">Reading pump history</string>
|
||||
<string name="combo_activity_setting_basal_profile">Setting basal profile</string>
|
||||
<string name="combo_pump_cartridge_low_warrning">Pump cartridge level is low</string>
|
||||
<string name="combo_pump_battery_low_warrning">Pump battery is low</string>
|
||||
<string name="combo_is_in_error_state">The pump is showing the error E%1$d: %2$s</string>
|
||||
<string name="combo_reservoir_low">Low</string>
|
||||
<string name="combo_reservoir_empty">Empty</string>
|
||||
<string name="combo_reservoir_normal">Normal</string>
|
||||
<string name="combo_notification_check_time_date">Pump clock update needed</string>
|
||||
<string name="combo_pump_tbr_cancelled_warrning">TBR CANCELLED warning was confirmed</string>
|
||||
<string name="combo_error_no_connection_no_bolus_delivered">The pump could not be reached. No bolus was given</string>
|
||||
<string name="combo_error_no_bolus_delivered">Bolus delivery failed. It appears no bolus was delivered. To be sure, please check the pump to avoid a double bolus and then bolus again. To guard against bugs, boluses are not automatically retried.</string>
|
||||
<string name="combo_error_partial_bolus_delivered">Only %1$.2f U of the requested bolus of %2$.2f U was delivered due to an error. Please check the pump to verify this and take appropriate actions.</string>
|
||||
<string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump. If a bolus was delivered, it will be added to treatments during the next connection to the pump.</string>
|
||||
<string name="combo_reservoir_level_insufficient_for_bolus">Not enough insulin for bolus left in reservoir</string>
|
||||
<string name="combo_invalid_setup">Invalid pump setup, check the docs and verify that the Quick Info menu is named QUICK INFO using the 360 configuration software.</string>
|
||||
<string name="combo_actvity_reading_basal_profile">Reading basal profile</string>
|
||||
<string name="combo_bolus_rejected_due_to_pump_history_change">The pump history has changed after the bolus calculation was performed. The bolus was not delivered. Please recalculate if a bolus is still needed.</string>
|
||||
<string name="combo_error_updating_treatment_record">Bolus successfully delivered, but adding the treatment entry failed. This can happen if two small boluses of the same size are administered within the last two minutes. Please check the pump history and treatment entries and use the Careportal to add missing entries. Make sure not to add any entries for the exact same minute and same amount.</string>
|
||||
<string name="combo_high_temp_rejected_due_to_pump_history_changes">Rejecting high temp since calculation didn\'t consider recently changed pump history</string>
|
||||
<string name="combo_activity_checking_pump_state">Refreshing pump state</string>
|
||||
<string name="combo_warning_pump_basal_rate_changed">The basal rate on the pump has changed and will be updated soon</string>
|
||||
<string name="combo_error_failure_reading_changed_basal_rate">Basal rate changed on pump, but reading it failed</string>
|
||||
<string name="combo_activity_checking_for_history_changes">Checking for history changes</string>
|
||||
<string name="combo_error_multiple_boluses_with_identical_timestamp">Multiple boluses with the same amount within the same minute were just imported. Only one record could be added to treatments. Please check the pump and manually add a bolus record using the Careportal tab. Make sure to create a bolus with a time no other bolus uses.</string>
|
||||
<string name="about_link_urls">\n\ndocumentation:\nhttps://androidaps.readthedocs.io\n\nfacebook:\nhttps://www.facebook.com/groups/AndroidAPSUsers</string>
|
||||
<string name="combo_check_date">The last bolus is older than 24 hours or is in the future. Please check the date on the pump is set correctly.</string>
|
||||
<string name="combo_suspious_bolus_time">Time/date of the delivered bolus on pump seems wrong, IOB is likely incorrect. Please check pump time/date.</string>
|
||||
<string name="combo_bolus_count">Bolus count</string>
|
||||
<string name="combo_tbr_count">TBR count</string>
|
||||
<string name="bolusstopped">Bolus stopped</string>
|
||||
<string name="bolusstopping">Stopping bolus</string>
|
||||
</resources>
|
|
@ -4,19 +4,10 @@ import android.content.Context
|
|||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.combo.R
|
||||
import info.nightscout.androidaps.interfaces.*
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Bolus
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.queue.CommandQueue
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Assert
|
||||
|
@ -29,17 +20,17 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(MainApp::class, ConfigBuilderPlugin::class, ConstraintChecker::class, Context::class, CommandQueue::class)
|
||||
@PrepareForTest(Context::class)
|
||||
class ComboPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
@Mock lateinit var treatmentsPlugin: TreatmentsInterface
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var context: Context
|
||||
@Mock lateinit var databaseHelper: DatabaseHelperInterface
|
||||
|
||||
val injector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
|
@ -51,7 +42,7 @@ class ComboPluginTest : TestBase() {
|
|||
@Before
|
||||
fun prepareMocks() {
|
||||
`when`(resourceHelper.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump")
|
||||
comboPlugin = ComboPlugin(injector, aapsLogger, RxBusWrapper(aapsSchedulers), resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context)
|
||||
comboPlugin = ComboPlugin(injector, aapsLogger, RxBusWrapper(aapsSchedulers), resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context, databaseHelper)
|
||||
}
|
||||
|
||||
@Test
|
|
@ -0,0 +1,40 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import info.nightscout.androidaps.logging.AAPSLoggerTest
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.junit.MockitoRule
|
||||
import java.util.*
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
open class TestBase {
|
||||
|
||||
val aapsLogger = AAPSLoggerTest()
|
||||
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
||||
|
||||
// Add a JUnit rule that will setup the @Mock annotated vars and log.
|
||||
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
|
||||
@get:Rule
|
||||
val mockitoRule: MockitoRule = MockitoJUnit.rule()
|
||||
|
||||
@Before
|
||||
fun setupLocale() {
|
||||
Locale.setDefault(Locale.ENGLISH)
|
||||
System.setProperty("disableFirebase", "true")
|
||||
}
|
||||
|
||||
// Workaround for Kotlin nullability.
|
||||
// https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791
|
||||
// https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin
|
||||
fun <T> anyObject(): T {
|
||||
Mockito.any<T>()
|
||||
return uninitialized()
|
||||
}
|
||||
|
||||
@Suppress("Unchecked_Cast")
|
||||
fun <T> uninitialized(): T = null as T
|
||||
}
|
|
@ -99,6 +99,13 @@
|
|||
<string name="pairing">Pairing</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
|
||||
<string name="bolusdelivered">Bolus %1$.2f U delivered successfully</string>
|
||||
<string name="virtualpump_resultok">OK</string>
|
||||
<string name="novalidbasalrate">No valid basal rate read from pump</string>
|
||||
<string name="limitingmaxiob">Limiting max IOB to %1$.1f U because of %2$s</string>
|
||||
<string name="unsafeusage">unsafe usage</string>
|
||||
<string name="pump_unreachable">Pump unreachable</string>
|
||||
|
||||
<!-- Constraints-->
|
||||
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>
|
||||
|
|
|
@ -15,6 +15,8 @@ files:
|
|||
translation: /core/src/main/res/values-%android_code%/validator.xml
|
||||
- source: /core/src/main/res/values/strings.xml
|
||||
translation: /core/src/main/res/values-%android_code%/strings.xml
|
||||
- source: /combo/src/main/res/values/strings.xml
|
||||
translation: /combo/src/main/res/values-%android_code%/strings.xml
|
||||
- source: /dana/src/main/res/values/strings.xml
|
||||
translation: /dana/src/main/res/values-%android_code%/strings.xml
|
||||
- source: /medtronic/src/main/res/values/strings.xml
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
include ':app', ':database', ':wear', ':core', ':dana', ':danar', ':danars', ':rileylink', ':medtronic', ':omnipod-eros', ':omnipod-dash'
|
||||
|
||||
include ':app'
|
||||
include ':wear'
|
||||
include ':database'
|
||||
include ':core'
|
||||
include ':combo'
|
||||
include ':dana'
|
||||
include ':danar'
|
||||
include ':danars'
|
||||
include ':rileylink'
|
||||
include ':medtronic'
|
||||
include ':omnipod-eros'
|
||||
include ':omnipod-dash'
|
Loading…
Reference in a new issue