Merge pull request #12 from jotomo/combo-scripter-v2

jan2
This commit is contained in:
Simon Pauwels 2018-01-02 19:20:12 +01:00 committed by GitHub
commit ecbab76ce7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 1623 additions and 838 deletions

View file

@ -55,16 +55,20 @@ Setup:
- Set low cartridge alarm to your liking - Set low cartridge alarm to your liking
- Enable keylock (can also be set on the pump directly, see usage section on reasoning) - Enable keylock (can also be set on the pump directly, see usage section on reasoning)
- Get Android Studio 3 https://developer.android.com/studio/index.html - Get Android Studio 3 https://developer.android.com/studio/index.html
- Clone ruffy from https://github.com/jotomo/ruffy (branch `combo-scripter-v2`) - Follow the link http://ruffy.AndroidAPS.org and clone via git (branch `combo-scripter-v2`)
- Pair the pump, if it doesn't work after multiple attempts, switch to the `pairing` branch, pair, - Pair the pump using ruffy, if it doesn't work after multiple attempts, switch to the `pairing` branch, pair,
then switch back the original branch. If the pump is already paired and then switch back the original branch. If the pump is already paired and
can be controlled via ruffy, installing the above version is sufficient. can be controlled via ruffy, installing the above version is sufficient.
If AAPS is already installed, switch to the MDI plugin to avoid the Combo If AAPS is already installed, switch to the MDI plugin to avoid the Combo
plugin from interfering with ruffy during the pairing process. plugin from interfering with ruffy during the pairing process.
Note that the pairing processing is somewhat fragile and may need a few attempts; Note that the pairing processing is somewhat fragile (but only has to be done once)
and may need a few attempts;
quickly acknowledge prompts and when starting over, remove the pump device quickly acknowledge prompts and when starting over, remove the pump device
from the bluetooth settings beforehand. from the bluetooth settings beforehand.
- Clone AndroidAPS from https://github.com/jotomo/AndroidAPS (Branch `combo-scripter-v2`) When AAPS is using ruffy, the ruffy app can't be used. The easiest way is to just
reboot the phone after the pairing process and let AAPS start ruffy in the background.
- Clone AndroidAPS from https://github.com/jotomo/AndroidAPS (branch `combo-scripter-v2`)
and build AAPS using the instructions in the wiki http://wiki.AndroidAPS.org
- Before enabling the Combo plugin in AAPS make sure your profile is set up - Before enabling the Combo plugin in AAPS make sure your profile is set up
correctly and your basal profile is up to date as AAPS will sync the basal profile correctly and your basal profile is up to date as AAPS will sync the basal profile
to the pump. to the pump.
@ -85,6 +89,8 @@ Usage:
- The integration of the Combo with AndroidAPS is designed with the assumption that all inputs are - The integration of the Combo with AndroidAPS is designed with the assumption that all inputs are
made via AndroidAPS. Boluses entered on the pump will NOT be detected by AAPS and may therefore made via AndroidAPS. Boluses entered on the pump will NOT be detected by AAPS and may therefore
result in too much insulin being delivered. result in too much insulin being delivered.
- The pump's first basal rate profile is read on app start and is updated by AAPS. Manually changing
the pump's basal rate profile will lead to wrong basals being delivered and is NOT supported.
- It's recommended to enable key lock on the pump to prevent bolusing from the pump, esp. when the - It's recommended to enable key lock on the pump to prevent bolusing from the pump, esp. when the
pump was used before and quick bolusing was a habit. pump was used before and quick bolusing was a habit.
Also, with keylock enabled, accidentally pressing a key will NOT interrupt a running command Also, with keylock enabled, accidentally pressing a key will NOT interrupt a running command
@ -124,21 +130,17 @@ Usage:
both of these issues can be resolved in future versions. both of these issues can be resolved in future versions.
Known issues: Known issues:
- On phones with low memory (or aggressive power saving settings), Android may kill - Occasionally (every couple of days or so) AAPS might fail to automatically cancel
AAPS frequently (if the buttons on the overview screen aren't displayed when opening a TBR CANCELLED alert the user then needs to deal with (press the refresh button in AAPS
AAPS, the app was started again after Android killed it). to transfer the warning to AAPS or confirm the alert on the pump).
This may trigger false 'pump unreachable alarms' on start. - Similarly, the 'pump unreachable' bug may occur from time to time, which requires confirming
See the Combo tab's "last connection" field to check when the pump was last connected. the alert on the pump to get the pump to accept connections again.
This may drain the pump's battery quicker since on startup the basal profile is read
from the pump. This may also increase the chance to hit the bug that makes the pump
reject all incoming connections until a button on the pump is pressed.
- Occasionally (every couple of days or less) AAPS might fail to automatically cancel
a TBR CANCELLED alert and needs to be dealt with (press the refresh button in AAPS
to transfer the warning to AAPS or confirm the alert on the pump). Similarly, the
'pump unreachable' bug may occur from time to time.
- Overall the integration seems rather robust, but there are limits to the way the - Overall the integration seems rather robust, but there are limits to the way the
pump is controlled and how stable BT is, so there will be minor issues like the above pump is controlled and how stable BT is, so there will be minor issues like the above
from time to time, though they're small compared to what works well. from time to time, though they're small compared to what works well.
- AAPS might be unresponsive for 10-30s or so when starting and calculating sensitivity.
AAPS might also be unresponsive when doing background work, e.g. after receiving a new
glucose reading.
Reporting bugs: Reporting bugs:
- Note the precise time the problem occurred and describe the circumstances and steps that caused - Note the precise time the problem occurred and describe the circumstances and steps that caused

View file

@ -74,12 +74,19 @@
- [ ] Check displayed data (state, battery, reservoir, temp basal) is the same - [ ] Check displayed data (state, battery, reservoir, temp basal) is the same
as on the pump as on the pump
- [ ] Unsafe usage - [ ] Unsafe usage
- [ ] An extended or multiwave bolus given within the last six hour must raise an alert and - [ ] An active extended or multiwave bolus must raise an alert and
restrict the loop functionality to low-suspend only (setting maxIOB to zero) restrict the loop functionality to low-suspend only for the next 6h (setting maxIOB to zero)
and cancel an active TBR.
- [ ] Closed loop functionality must resume 6 h after the last ext/multiwave bolus - [ ] Closed loop functionality must resume 6 h after the last ext/multiwave bolus
- [ ] An active ext/multiwave bolus must also raise an alert and restrict the loop - [ ] If a basal rate other than profile 1 is active on start, the pump must refuse to finish
- [ ] If a basal rate other than profile 1 is activated, this must also raise an alert and disable initialization and disable the loop. When setting the profile to 1 and refreshing,
the restrict the loop the pump must finish initialization and enable the loop (the overview screen will
still show "closed loop", but the Combo and Loop tabs will say the loop is disabled
due to a constraint violation).
- [ ] When changing profile to one other than the first after AAPS has started and read the first
basal profile, a warning must be shown, the loop must be disabled and the active TBR be cancelled.
- [ ] A request to change the AAPS profil (e.g. increase to 110%) must be rejected if the pump
doesn't have profile one active.
- [ ] Reading/setting basal profile - [ ] Reading/setting basal profile
- [ ] AAPS reads basal rate properly - [ ] AAPS reads basal rate properly
- [ ] Test profile with 115% (or something like that) change to ask the - [ ] Test profile with 115% (or something like that) change to ask the

View file

@ -192,4 +192,7 @@ dependencies {
compile 'com.google.code.gson:gson:2.7' compile 'com.google.code.gson:gson:2.7'
compile 'com.google.guava:guava:20.0' compile 'com.google.guava:guava:20.0'
compile project(path: ':ruffyscripter') compile project(path: ':ruffyscripter')
compile 'net.danlew:android.joda:2.9.9.1'
testCompile 'joda-time:joda-time:2.9.4.2'
} }

View file

@ -15,6 +15,8 @@ import com.squareup.otto.Bus;
import com.squareup.otto.LoggingBus; import com.squareup.otto.LoggingBus;
import com.squareup.otto.ThreadEnforcer; import com.squareup.otto.ThreadEnforcer;
import net.danlew.android.joda.JodaTimeAndroid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -97,6 +99,7 @@ public class MainApp extends Application {
super.onCreate(); super.onCreate();
Fabric.with(this, new Crashlytics()); Fabric.with(this, new Crashlytics());
Fabric.with(this, new Answers()); Fabric.with(this, new Answers());
JodaTimeAndroid.init(this);
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION); Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
log.info("Version: " + BuildConfig.VERSION_NAME); log.info("Version: " + BuildConfig.VERSION_NAME);
log.info("BuildVersion: " + BuildConfig.BUILDVERSION); log.info("BuildVersion: " + BuildConfig.BUILDVERSION);

View file

@ -167,12 +167,6 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginBase.PUMP); addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginBase.PUMP);
} }
/* No usable settings yet
if (Config.COMBO) {
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), PluginBase.PUMP);
}
*/
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginBase.INSULIN); addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginBase.INSULIN);
addPreferencesFromResourceIfEnabled(NSClientInternalPlugin.getPlugin(), PluginBase.GENERAL); addPreferencesFromResourceIfEnabled(NSClientInternalPlugin.getPlugin(), PluginBase.GENERAL);

View file

@ -17,9 +17,13 @@ import java.util.TimeZone;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
@ -160,15 +164,19 @@ public class Profile {
for (Integer index = 0; index < array.length(); index++) { for (Integer index = 0; index < array.length(); index++) {
try { try {
final JSONObject o = array.getJSONObject(index); final JSONObject o = array.getJSONObject(index);
long tas = getShitfTimeSecs((int) o.getLong("timeAsSeconds")); long tas = 0;
try {
tas = getShitfTimeSecs((int) o.getLong("timeAsSeconds"));
} catch (JSONException e) {
String time = o.getString("time");
tas = getShitfTimeSecs(DateUtil.toSeconds(time));
//log.debug(">>>>>>>>>>>> Used recalculated timeAsSecons: " + time + " " + tas);
}
Double value = o.getDouble("value") * multiplier; Double value = o.getDouble("value") * multiplier;
sparse.put(tas, value); sparse.put(tas, value);
} catch (JSONException e) { } catch (JSONException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
try { log.error(json.toString());
log.error(array.getJSONObject(index).toString());
} catch (JSONException e1) {
}
} }
} }
@ -327,8 +335,27 @@ public class Profile {
} }
public Double getBasal(Integer timeAsSeconds) { public Double getBasal(Integer timeAsSeconds) {
if (basal_v == null) if (basal_v == null) {
basal_v = convertToSparseArray(basal); basal_v = convertToSparseArray(basal);
// Check for minimal basal value
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (pump != null) {
PumpDescription description = pump.getPumpDescription();
for (int i = 0; i < basal_v.size(); i++) {
if (basal_v.valueAt(i) < description.basalMinimumRate) {
basal_v.setValueAt(i, description.basalMinimumRate);
MainApp.bus().post(new EventNewNotification(new Notification(Notification.MINIMAL_BASAL_VALUE_REPLACED, MainApp.sResources.getString(R.string.minimalbasalvaluereplaced), Notification.NORMAL)));
}
}
return getValueToTime(basal_v, timeAsSeconds);
} else {
// if pump not available (at start)
// do not store converted array
Double value = getValueToTime(basal_v, timeAsSeconds);
basal_v = null;
return value;
}
}
return getValueToTime(basal_v, timeAsSeconds); return getValueToTime(basal_v, timeAsSeconds);
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.Overview; package info.nightscout.androidaps.data;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
@ -9,11 +9,7 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.utils.DateUtil;
/** /**
* Created by mike on 12.10.2016. * Created by mike on 12.10.2016.
@ -22,84 +18,7 @@ import info.nightscout.utils.DateUtil;
public class QuickWizard { public class QuickWizard {
private static Logger log = LoggerFactory.getLogger(QuickWizard.class); private static Logger log = LoggerFactory.getLogger(QuickWizard.class);
public class QuickWizardEntry { private JSONArray storage = new JSONArray();
public JSONObject storage;
public int position;
/*
{
buttonText: "Meal",
carbs: 36,
validFrom: 8 * 60 * 60, // seconds from midnight
validTo: 9 * 60 * 60, // seconds from midnight
}
*/
public QuickWizardEntry() {
String emptyData = "{\"buttonText\":\"\",\"carbs\":0,\"validFrom\":0,\"validTo\":86340}";
try {
storage = new JSONObject(emptyData);
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
position = -1;
}
public QuickWizardEntry(JSONObject entry, int position) {
storage = entry;
this.position = position;
}
public Boolean isActive() {
return Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo();
}
public String buttonText() {
try {
return storage.getString("buttonText");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return "";
}
public Integer carbs() {
try {
return storage.getInt("carbs");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return 0;
}
public Date validFromDate() {
return DateUtil.toDate(validFrom());
}
public Date validToDate() {
return DateUtil.toDate(validTo());
}
public Integer validFrom() {
try {
return storage.getInt("validFrom");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return 0;
}
public Integer validTo() {
try {
return storage.getInt("validTo");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return 0;
}
}
JSONArray storage = new JSONArray();
public void setData(JSONArray newData) { public void setData(JSONArray newData) {
storage = newData; storage = newData;

View file

@ -0,0 +1,242 @@
package info.nightscout.androidaps.data;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.utils.BolusWizard;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
/**
* Created by mike on 25.12.2017.
*/
public class QuickWizardEntry {
private static Logger log = LoggerFactory.getLogger(QuickWizardEntry.class);
public JSONObject storage;
public int position;
public static final int YES = 0;
public static final int NO = 1;
public static final int POSITIVE_ONLY = 2;
public static final int NEGATIVE_ONLY = 3;
/*
{
buttonText: "Meal",
carbs: 36,
validFrom: 8 * 60 * 60, // seconds from midnight
validTo: 9 * 60 * 60, // seconds from midnight
useBG: 0,
useCOB: 0,
useBolusIOB: 0,
useBasalIOB: 0,
useTrend: 0,
useSuperBolus: 0,
useTemptarget: 0
}
*/
public QuickWizardEntry() {
String emptyData = "{\"buttonText\":\"\",\"carbs\":0,\"validFrom\":0,\"validTo\":86340}";
try {
storage = new JSONObject(emptyData);
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
position = -1;
}
public QuickWizardEntry(JSONObject entry, int position) {
storage = entry;
this.position = position;
}
public Boolean isActive() {
return Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo();
}
public BolusWizard doCalc(Profile profile, TempTarget tempTarget, BgReading lastBG) {
BolusWizard wizard = new BolusWizard();
//BG
double bg = 0;
if (lastBG != null && useBG() == YES) {
bg = lastBG.valueToUnits(profile.getUnits());
}
// COB
double cob = 0d;
AutosensData autosensData = IobCobCalculatorPlugin.getLastAutosensData();
if (autosensData != null && useCOB() == YES) {
cob = autosensData.cob;
}
// Temp target
if (useTempTarget() == NO) {
tempTarget = null;
}
// Bolus IOB
boolean bolusIOB = false;
if (useBolusIOB() == YES) {
bolusIOB = true;
}
// Basal IOB
TreatmentsInterface treatments = MainApp.getConfigBuilder();
treatments.updateTotalIOBTempBasals();
IobTotal basalIob = treatments.getLastCalculationTempBasals().round();
boolean basalIOB = false;
if (useBasalIOB() == YES) {
basalIOB = true;
} else if (useBasalIOB() == POSITIVE_ONLY && basalIob.iob > 0) {
basalIOB = true;
} else if (useBasalIOB() == NEGATIVE_ONLY && basalIob.iob < 0) {
basalIOB = true;
}
// SuperBolus
boolean superBolus = false;
if (useSuperBolus() == YES && SP.getBoolean(R.string.key_usesuperbolus, false)) {
superBolus = true;
}
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus())
superBolus = false;
// Trend
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
boolean trend = false;
if (useTrend() == YES) {
trend = true;
} else if (useTrend() == POSITIVE_ONLY && glucoseStatus != null && glucoseStatus.short_avgdelta > 0) {
trend = true;
} else if (useTrend() == NEGATIVE_ONLY && glucoseStatus != null && glucoseStatus.short_avgdelta < 0) {
trend = true;
}
wizard.doCalc(profile, tempTarget, carbs(), cob, bg, 0d, bolusIOB, basalIOB, superBolus, trend);
return wizard;
}
public String buttonText() {
try {
return storage.getString("buttonText");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return "";
}
public Integer carbs() {
try {
return storage.getInt("carbs");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return 0;
}
public Date validFromDate() {
return DateUtil.toDate(validFrom());
}
public Date validToDate() {
return DateUtil.toDate(validTo());
}
public Integer validFrom() {
try {
return storage.getInt("validFrom");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return 0;
}
public Integer validTo() {
try {
return storage.getInt("validTo");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return 0;
}
public int useBG() {
try {
return storage.getInt("useBG");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return YES;
}
public int useCOB() {
try {
return storage.getInt("useCOB");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return NO;
}
public int useBolusIOB() {
try {
return storage.getInt("useBolusIOB");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return YES;
}
public int useBasalIOB() {
try {
return storage.getInt("useBasalIOB");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return YES;
}
public int useTrend() {
try {
return storage.getInt("useTrend");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return NO;
}
public int useSuperBolus() {
try {
return storage.getInt("useSuperBolus");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return NO;
}
public int useTempTarget() {
try {
return storage.getInt("useTempTarget");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
return NO;
}
}

View file

@ -46,6 +46,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync; import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.utils.PercentageSplitter;
public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static Logger log = LoggerFactory.getLogger(DatabaseHelper.class); private static Logger log = LoggerFactory.getLogger(DatabaseHelper.class);
@ -1633,6 +1634,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
} }
// look for already added percentage from NS
profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName);
getDaoProfileSwitch().create(profileSwitch); getDaoProfileSwitch().create(profileSwitch);
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();

View file

@ -15,6 +15,8 @@ public interface ConstraintsInterface {
boolean isAMAModeEnabled(); boolean isAMAModeEnabled();
boolean isSMBModeEnabled();
Double applyBasalConstraints(Double absoluteRate); Double applyBasalConstraints(Double absoluteRate);
Integer applyBasalConstraints(Integer percentRate); Integer applyBasalConstraints(Integer percentRate);

View file

@ -21,5 +21,5 @@ public interface InsulinInterface {
String getFriendlyName(); String getFriendlyName();
String getComment(); String getComment();
double getDia(); double getDia();
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia); public Iob iobCalcForTreatment(Treatment treatment, long time, double dia);
} }

View file

@ -38,7 +38,7 @@ public interface PumpInterface {
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo); PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
void stopBolusDelivering(); void stopBolusDelivering();
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew); PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew);
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes); PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew);
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes); PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy //some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
//when the cancel request is requested by the user (forced), the pump should always do a real cancel //when the cancel request is requested by the user (forced), the pump should always do a real cancel

View file

@ -8,7 +8,6 @@ import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import com.crashlytics.android.Crashlytics; import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.Answers;
@ -33,6 +32,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.SingleClickButton;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -45,13 +45,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
return actionsPlugin; return actionsPlugin;
} }
Button profileSwitch; SingleClickButton profileSwitch;
Button tempTarget; SingleClickButton tempTarget;
Button extendedBolus; SingleClickButton extendedBolus;
Button extendedBolusCancel; SingleClickButton extendedBolusCancel;
Button tempBasal; SingleClickButton tempBasal;
Button tempBasalCancel; SingleClickButton tempBasalCancel;
Button fill; SingleClickButton fill;
public ActionsFragment() { public ActionsFragment() {
super(); super();
@ -64,13 +64,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
try { try {
View view = inflater.inflate(R.layout.actions_fragment, container, false); View view = inflater.inflate(R.layout.actions_fragment, container, false);
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch); profileSwitch = (SingleClickButton) view.findViewById(R.id.actions_profileswitch);
tempTarget = (Button) view.findViewById(R.id.actions_temptarget); tempTarget = (SingleClickButton) view.findViewById(R.id.actions_temptarget);
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus); extendedBolus = (SingleClickButton) view.findViewById(R.id.actions_extendedbolus);
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel); extendedBolusCancel = (SingleClickButton) view.findViewById(R.id.actions_extendedbolus_cancel);
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal); tempBasal = (SingleClickButton) view.findViewById(R.id.actions_settempbasal);
tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal); tempBasalCancel = (SingleClickButton) view.findViewById(R.id.actions_canceltempbasal);
fill = (Button) view.findViewById(R.id.actions_fill); fill = (SingleClickButton) view.findViewById(R.id.actions_fill);
profileSwitch.setOnClickListener(this); profileSwitch.setOnClickListener(this);
tempTarget.setOnClickListener(this); tempTarget.setOnClickListener(this);

View file

@ -100,6 +100,8 @@ public class FillDialog extends DialogFragment implements OnClickListener {
if (button1.getVisibility() == View.GONE && button2.getVisibility() == View.GONE && button3.getVisibility() == View.GONE) { if (button1.getVisibility() == View.GONE && button2.getVisibility() == View.GONE && button3.getVisibility() == View.GONE) {
divider.setVisibility(View.GONE); divider.setVisibility(View.GONE);
} }
setCancelable(false);
return view; return view;
} }

View file

@ -54,14 +54,9 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
view.findViewById(R.id.ok).setOnClickListener(this); view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this); view.findViewById(R.id.cancel).setOnClickListener(this);
return view;
}
@Override setCancelable(false);
public void onResume() { return view;
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
} }
@Override @Override

View file

@ -102,6 +102,8 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
view.findViewById(R.id.ok).setOnClickListener(this); view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this); view.findViewById(R.id.cancel).setOnClickListener(this);
basalTypeRadioGroup.setOnCheckedChangeListener(this); basalTypeRadioGroup.setOnCheckedChangeListener(this);
setCancelable(false);
return view; return view;
} }
@ -155,7 +157,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
} }
}; };
if (setAsPercent) { if (setAsPercent) {
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, callback); ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, true, callback);
} else { } else {
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, callback); ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, callback);
} }

View file

@ -175,7 +175,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
profileSpinner.setAdapter(adapter); profileSpinner.setAdapter(adapter);
// set selected to actual profile // set selected to actual profile
for (int p = 0; p < profileList.size(); p++) { for (int p = 0; p < profileList.size(); p++) {
if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName())) if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName(false)))
profileSpinner.setSelection(p); profileSpinner.setSelection(p);
} }
@ -360,6 +360,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP); showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP);
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget); showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
setCancelable(false);
return view; return view;
} }

View file

@ -16,9 +16,9 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Intervals;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.MealData;
import info.nightscout.androidaps.data.Intervals;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileIntervals; import info.nightscout.androidaps.data.ProfileIntervals;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
@ -38,8 +38,8 @@ import info.nightscout.androidaps.interfaces.SensitivityInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.CommandQueue; import info.nightscout.androidaps.queue.CommandQueue;
@ -482,8 +482,7 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
@Override @Override
public boolean isAMAModeEnabled() { public boolean isAMAModeEnabled() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); boolean result = SP.getBoolean("openapsama_useautosens", false);
boolean result = preferences.getBoolean("openapsama_useautosens", false);
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
@ -494,6 +493,19 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
return result; return result;
} }
@Override
public boolean isSMBModeEnabled() {
boolean result = true; // TODO update for SMB // SP.getBoolean("openapsama_useautosens", false);
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
result = result && constrain.isSMBModeEnabled();
}
return result;
}
@Override @Override
public Double applyBasalConstraints(Double absoluteRate) { public Double applyBasalConstraints(Double absoluteRate) {
Double rateAfterConstrain = absoluteRate; Double rateAfterConstrain = absoluteRate;
@ -736,6 +748,10 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
return getProfileName(System.currentTimeMillis()); return getProfileName(System.currentTimeMillis());
} }
public String getProfileName(boolean customized) {
return getProfileName(System.currentTimeMillis(), customized);
}
public String getProfileName(long time) { public String getProfileName(long time) {
return getProfileName(time, true); return getProfileName(time, true);
} }

View file

@ -14,9 +14,14 @@ import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.ConstraintsInterface; import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
/** /**
@ -152,14 +157,35 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
RequirementResult requirementsMet(Integer objNum) { RequirementResult requirementsMet(Integer objNum) {
switch (objNum) { switch (objNum) {
case 0: case 0:
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS, boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginBase.PUMP);
boolean vpUploadEnabled = SP.getBoolean("virtualpump_uploadstatus", false);
boolean vpUploadNeeded = !isVirtualPump || vpUploadEnabled;
boolean apsEnabled = false;
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS))
apsEnabled = true;
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientInternalPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded,
MainApp.sResources.getString(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS) MainApp.sResources.getString(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
+ " " + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS)); + " " + MainApp.sResources.getString(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientInternalPlugin.getPlugin().hasWritePermission())
+ (isVirtualPump ? " " + MainApp.sResources.getString(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "")
+ " " + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS)
+ " " + MainApp.sResources.getString(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP))
+ " " + MainApp.sResources.getString(R.string.apsselected) + ": " + yesOrNo(apsEnabled)
);
case 1: case 1:
return new RequirementResult(manualEnacts >= manualEnactsNeeded, return new RequirementResult(manualEnacts >= manualEnactsNeeded,
MainApp.sResources.getString(R.string.objectives_manualenacts) + ": " + manualEnacts + "/" + manualEnactsNeeded); MainApp.sResources.getString(R.string.objectives_manualenacts) + ": " + manualEnacts + "/" + manualEnactsNeeded);
case 2: case 2:
return new RequirementResult(true, ""); return new RequirementResult(true, "");
case 3:
boolean closedModeEnabled = SafetyPlugin.getPlugin().isClosedModeEnabled();
return new RequirementResult(closedModeEnabled, MainApp.sResources.getString(R.string.closedmodeenabled) + ": " + yesOrNo(closedModeEnabled));
case 4:
double maxIOB = MainApp.getConfigBuilder().applyMaxIOBConstraints(1000d);
boolean maxIobSet = maxIOB > 0;
return new RequirementResult(maxIobSet, MainApp.sResources.getString(R.string.maxiobset) + ": " + yesOrNo(maxIobSet));
default: default:
return new RequirementResult(true, ""); return new RequirementResult(true, "");
} }
@ -212,7 +238,13 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
MainApp.sResources.getString(R.string.objectives_6_objective), MainApp.sResources.getString(R.string.objectives_6_objective),
"", "",
new Date(0), new Date(0),
14, 28,
new Date(0)));
objectives.add(new Objective(7,
MainApp.sResources.getString(R.string.objectives_7_objective),
"",
new Date(0),
28,
new Date(0))); new Date(0)));
} }
@ -260,7 +292,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
**/ **/
@Override @Override
public boolean isLoopEnabled() { public boolean isLoopEnabled() {
return objectives.get(1).started.getTime() > 0; return objectives.get(0).started.getTime() > 0;
} }
@Override @Override
@ -278,6 +310,11 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
return objectives.get(6).started.getTime() > 0; return objectives.get(6).started.getTime() > 0;
} }
@Override
public boolean isSMBModeEnabled() {
return objectives.get(7).started.getTime() > 0;
}
@Override @Override
public Double applyMaxIOBConstraints(Double maxIob) { public Double applyMaxIOBConstraints(Double maxIob) {
if (objectives.get(4).started.getTime() > 0 || objectives.get(2).accomplished.getTime() == 0) if (objectives.get(4).started.getTime() > 0 || objectives.get(2).accomplished.getTime() == 0)

View file

@ -116,6 +116,11 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
return true; return true;
} }
@Override
public boolean isSMBModeEnabled() {
return true;
}
@Override @Override
public Double applyBasalConstraints(Double absoluteRate) { public Double applyBasalConstraints(Double absoluteRate) {
Double origAbsoluteRate = absoluteRate; Double origAbsoluteRate = absoluteRate;

View file

@ -107,7 +107,7 @@ public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
} }
@Override @Override
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) { public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
Iob result = new Iob(); Iob result = new Iob();
double scaleFactor = 3.0 / dia; double scaleFactor = 3.0 / dia;

View file

@ -107,7 +107,7 @@ public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInte
} }
@Override @Override
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) { public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
Iob result = new Iob(); Iob result = new Iob();
//Double scaleFactor = 3.0 / dia; //Double scaleFactor = 3.0 / dia;

View file

@ -64,7 +64,7 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
} }
@Override @Override
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) { public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
Iob result = new Iob(); Iob result = new Iob();
int peak = getPeak(); int peak = getPeak();

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.IobCobCalculator.events; package info.nightscout.androidaps.plugins.IobCobCalculator;
/** /**
* Created by mike on 10.06.2017. * Created by mike on 10.06.2017.

View file

@ -31,7 +31,6 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
@ -364,6 +363,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
// check if data already exists // check if data already exists
long bgTime = bucketed_data.get(i).date; long bgTime = bucketed_data.get(i).date;
bgTime = roundUpTime(bgTime); bgTime = roundUpTime(bgTime);
if (bgTime > System.currentTimeMillis())
continue;
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime); Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
AutosensData existing; AutosensData existing;
@ -544,6 +545,10 @@ public class IobCobCalculatorPlugin implements PluginBase {
//log.debug(">>> getAutosensData Cache hit " + data.log(time)); //log.debug(">>> getAutosensData Cache hit " + data.log(time));
return data; return data;
} else { } else {
if (time > now) {
// data may not be calculated yet, use last data
return getLastAutosensData();
}
//log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString()); //log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
return null; return null;
} }
@ -555,7 +560,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
if (autosensDataTable.size() < 1) if (autosensDataTable.size() < 1)
return null; return null;
AutosensData data = autosensDataTable.valueAt(autosensDataTable.size() - 1); AutosensData data = autosensDataTable.valueAt(autosensDataTable.size() - 1);
if (data.time < System.currentTimeMillis() - 5 * 60 * 1000) { if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
return null; return null;
} else { } else {
return data; return data;

View file

@ -259,18 +259,6 @@ public class LoopPlugin implements PluginBase {
if (!isEnabled(PluginBase.LOOP)) if (!isEnabled(PluginBase.LOOP))
return; return;
if (isSuspended()) {
log.debug(MainApp.sResources.getString(R.string.loopsuspended));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopsuspended)));
return;
}
if (pump.isSuspended()) {
log.debug(MainApp.sResources.getString(R.string.pumpsuspended));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.pumpsuspended)));
return;
}
if (MainApp.getConfigBuilder().getProfile() == null) { if (MainApp.getConfigBuilder().getProfile() == null) {
log.debug(MainApp.sResources.getString(R.string.noprofileselected)); log.debug(MainApp.sResources.getString(R.string.noprofileselected));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected))); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected)));
@ -280,7 +268,7 @@ public class LoopPlugin implements PluginBase {
// Check if pump info is loaded // Check if pump info is loaded
if (pump.getBaseBasalRate() < 0.01d) return; if (pump.getBaseBasalRate() < 0.01d) return;
APSInterface usedAPS = MainApp.getConfigBuilder().getActiveAPS(); APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) { if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) {
usedAPS.invoke(initiator); usedAPS.invoke(initiator);
result = usedAPS.getLastAPSResult(); result = usedAPS.getLastAPSResult();
@ -303,6 +291,20 @@ public class LoopPlugin implements PluginBase {
lastRun.source = ((PluginBase) usedAPS).getName(); lastRun.source = ((PluginBase) usedAPS).getName();
lastRun.setByPump = null; lastRun.setByPump = null;
NSUpload.uploadDeviceStatus();
if (isSuspended()) {
log.debug(MainApp.sResources.getString(R.string.loopsuspended));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopsuspended)));
return;
}
if (pump.isSuspended()) {
log.debug(MainApp.sResources.getString(R.string.pumpsuspended));
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.pumpsuspended)));
return;
}
if (constraintsInterface.isClosedModeEnabled()) { if (constraintsInterface.isClosedModeEnabled()) {
if (result.changeRequested) { if (result.changeRequested) {
final PumpEnactResult waiting = new PumpEnactResult(); final PumpEnactResult waiting = new PumpEnactResult();
@ -363,7 +365,6 @@ public class LoopPlugin implements PluginBase {
} }
MainApp.bus().post(new EventLoopUpdateGui()); MainApp.bus().post(new EventLoopUpdateGui());
NSUpload.uploadDeviceStatus();
} finally { } finally {
if (Config.logFunctionCalls) if (Config.logFunctionCalls)
log.debug("invoke end"); log.debug("invoke end");

View file

@ -222,4 +222,8 @@ public class NSClientInternalPlugin implements PluginBase {
public String url() { public String url() {
return NSClientService.nsURL; return NSClientService.nsURL;
} }
public boolean hasWritePermission() {
return nsClientService.hasWriteAuth;
}
} }

View file

@ -30,14 +30,6 @@ public class DBAccessReceiver extends BroadcastReceiver {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
DBAccessReceiver.class.getSimpleName()); DBAccessReceiver.class.getSimpleName());
NSClientInternalPlugin nsClientInternalPlugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
if (!nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
return;
}
if (SP.getBoolean(R.string.key_ns_noupload, false)) {
log.debug("Upload disabled. Message dropped");
return;
}
wakeLock.acquire(); wakeLock.acquire();
try { try {
Bundle bundles = intent.getExtras(); Bundle bundles = intent.getExtras();
@ -83,16 +75,22 @@ public class DBAccessReceiver extends BroadcastReceiver {
} }
if (action.equals("dbRemove")) { if (action.equals("dbRemove")) {
DbRequest dbr = new DbRequest(action, collection, nsclientid.toString(), _id); if (shouldUpload()) {
UploadQueue.add(dbr); DbRequest dbr = new DbRequest(action, collection, nsclientid.toString(), _id);
UploadQueue.add(dbr);
}
} else { } else {
DbRequest dbr = new DbRequest(action, collection, nsclientid.toString(), data); DbRequest dbr = new DbRequest(action, collection, nsclientid.toString(), data);
// this is not used as mongo _id but only for searching in UploadQueue database // this is not used as mongo _id but only for searching in UploadQueue database
// if record has to be removed from queue before upload // if record has to be removed from queue before upload
dbr._id = nsclientid.toString(); dbr._id = nsclientid.toString();
UploadQueue.add(dbr);
if (collection.equals("treatments")) if (shouldUpload()) {
UploadQueue.add(dbr);
}
if (collection.equals("treatments")) {
genereateTreatmentOfflineBroadcast(dbr); genereateTreatmentOfflineBroadcast(dbr);
}
} }
} finally { } finally {
@ -101,6 +99,11 @@ public class DBAccessReceiver extends BroadcastReceiver {
} }
public boolean shouldUpload() {
NSClientInternalPlugin nsClientInternalPlugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
return nsClientInternalPlugin.isEnabled(PluginBase.GENERAL) && !SP.getBoolean(R.string.key_ns_noupload, false);
}
public void genereateTreatmentOfflineBroadcast(DbRequest request) { public void genereateTreatmentOfflineBroadcast(DbRequest request) {
if (request.action.equals("dbAdd")) { if (request.action.equals("dbAdd")) {
try { try {

View file

@ -76,6 +76,7 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units); unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
unitsView.setText(units); unitsView.setText(units);
setCancelable(false);
return view; return view;
} }

View file

@ -9,7 +9,6 @@ import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Spinner; import android.widget.Spinner;
@ -17,13 +16,13 @@ import org.json.JSONException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.QuickWizard;
import info.nightscout.androidaps.data.QuickWizardEntry;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Overview.QuickWizard;
import info.nightscout.androidaps.plugins.Overview.events.EventQuickWizardChange; import info.nightscout.androidaps.plugins.Overview.events.EventQuickWizardChange;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
@ -31,19 +30,25 @@ import info.nightscout.utils.SafeParse;
public class EditQuickWizardDialog extends DialogFragment implements View.OnClickListener { public class EditQuickWizardDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(EditQuickWizardDialog.class); private static Logger log = LoggerFactory.getLogger(EditQuickWizardDialog.class);
QuickWizard.QuickWizardEntry entry = new QuickWizard().newEmptyItem(); QuickWizardEntry entry = new QuickWizard().newEmptyItem();
QuickWizard quickWizard = MainApp.getSpecificPlugin(OverviewPlugin.class).quickWizard; QuickWizard quickWizard = MainApp.getSpecificPlugin(OverviewPlugin.class).quickWizard;
EditText buttonEdit; EditText buttonEdit;
EditText carbsEdit; EditText carbsEdit;
Spinner fromSpinner; Spinner fromSpinner;
Spinner toSpinner; Spinner toSpinner;
Button okButton; Spinner useBGSpinner;
Spinner useCOBSpinner;
Spinner useBolusIOBSpinner;
Spinner useBasalIOBSpinner;
Spinner useTrendSpinner;
Spinner useSuperBolusSpinner;
Spinner useTempTargetSpinner;
public EditQuickWizardDialog() { public EditQuickWizardDialog() {
} }
public void setData(QuickWizard.QuickWizardEntry data) { public void setData(QuickWizardEntry data) {
entry = data; entry = data;
} }
@ -58,8 +63,16 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
carbsEdit = (EditText) view.findViewById(R.id.overview_editquickwizard_carbs_edit); carbsEdit = (EditText) view.findViewById(R.id.overview_editquickwizard_carbs_edit);
fromSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_from_spinner); fromSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_from_spinner);
toSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_to_spinner); toSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_to_spinner);
okButton = (Button) view.findViewById(R.id.overview_editquickwizard_ok_button); useBGSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usebg_spinner);
okButton.setOnClickListener(this); useCOBSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usecob_spinner);
useBolusIOBSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usebolusiob_spinner);
useBasalIOBSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usebasaliob_spinner);
useTrendSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usetrend_spinner);
useSuperBolusSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usesuperbolus_spinner);
useTempTargetSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usetemptarget_spinner);
view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this);
int posFrom = 0; int posFrom = 0;
int posTo = 95; int posTo = 95;
@ -83,6 +96,14 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
fromSpinner.setSelection(posFrom); fromSpinner.setSelection(posFrom);
toSpinner.setSelection(posTo); toSpinner.setSelection(posTo);
setSelection(useBGSpinner, entry.useBG());
setSelection(useCOBSpinner, entry.useCOB());
setSelection(useBolusIOBSpinner, entry.useBolusIOB());
setSelection(useBasalIOBSpinner, entry.useBasalIOB());
setSelection(useTrendSpinner, entry.useTrend());
setSelection(useSuperBolusSpinner, entry.useSuperBolus());
setSelection(useTempTargetSpinner, entry.useTempTarget());
return view; return view;
} }
@ -96,7 +117,7 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.overview_editquickwizard_ok_button: case R.id.ok:
if (fromSpinner.getSelectedItem() == null) return; if (fromSpinner.getSelectedItem() == null) return;
if (toSpinner.getSelectedItem() == null) return; if (toSpinner.getSelectedItem() == null) return;
try { try {
@ -106,13 +127,64 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
entry.storage.put("validFrom", validFromInt); entry.storage.put("validFrom", validFromInt);
int validToInt = DateUtil.toSeconds(toSpinner.getSelectedItem().toString()); int validToInt = DateUtil.toSeconds(toSpinner.getSelectedItem().toString());
entry.storage.put("validTo", validToInt); entry.storage.put("validTo", validToInt);
entry.storage.put("useBG", getSelection(useBGSpinner));
entry.storage.put("useCOB", getSelection(useCOBSpinner));
entry.storage.put("useBolusIOB", getSelection(useBolusIOBSpinner));
entry.storage.put("useBasalIOB", getSelection(useBasalIOBSpinner));
entry.storage.put("useTrend", getSelection(useTrendSpinner));
entry.storage.put("useSuperBolus", getSelection(useSuperBolusSpinner));
entry.storage.put("useTempTarget", getSelection(useTempTargetSpinner));
} catch (JSONException e) { } catch (JSONException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
quickWizard.addOrUpdate(entry); quickWizard.addOrUpdate(entry);
dismiss(); dismiss();
MainApp.bus().post(new EventQuickWizardChange()); MainApp.bus().post(new EventQuickWizardChange());
break; break;
case R.id.cancel:
dismiss();
break;
}
}
int getSelection(Spinner spinner) {
String value = spinner.getSelectedItem().toString();
if (value.equals(MainApp.sResources.getString(R.string.yes)))
return QuickWizardEntry.YES;
if (value.equals(MainApp.sResources.getString(R.string.no)))
return QuickWizardEntry.NO;
if (value.equals(MainApp.sResources.getString(R.string.positiveonly)))
return QuickWizardEntry.POSITIVE_ONLY;
if (value.equals(MainApp.sResources.getString(R.string.negativeonly)))
return QuickWizardEntry.NEGATIVE_ONLY;
return QuickWizardEntry.NO;
}
void setSelection(Spinner spinner, int value) {
String selection;
switch (value) {
case QuickWizardEntry.YES:
selection = MainApp.sResources.getString(R.string.yes);
break;
case QuickWizardEntry.NO:
selection = MainApp.sResources.getString(R.string.no);
break;
case QuickWizardEntry.POSITIVE_ONLY:
selection = MainApp.sResources.getString(R.string.positiveonly);
break;
case QuickWizardEntry.NEGATIVE_ONLY:
selection = MainApp.sResources.getString(R.string.negativeonly);
break;
default:
selection = MainApp.sResources.getString(R.string.no);
break;
}
for (int i = 0; i < spinner.getCount(); i++) {
if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(selection)) {
spinner.setSelection(i);
break;
}
} }
} }
} }

View file

@ -101,6 +101,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher); editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher);
setCancelable(false);
return view; return view;
} }

View file

@ -53,6 +53,8 @@ import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
@ -102,7 +104,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
Integer calculatedCarbs = 0; Integer calculatedCarbs = 0;
Double calculatedTotalInsulin = 0d; Double calculatedTotalInsulin = 0d;
JSONObject boluscalcJSON; JSONObject boluscalcJSON;
boolean cobAvailable = false;
Context context; Context context;
@ -138,25 +139,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
MainApp.bus().unregister(this); MainApp.bus().unregister(this);
} }
@Subscribe
public void onStatusEvent(final EventOpenAPSUpdateGui e) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
cobLayout.setVisibility(View.VISIBLE);
cobAvailable = true;
} else {
cobLayout.setVisibility(View.GONE);
cobAvailable = false;
}
calculateInsulin();
}
});
}
@Subscribe @Subscribe
public void onStatusEvent(final EventNewBG e) { public void onStatusEvent(final EventNewBG e) {
Activity activity = getActivity(); Activity activity = getActivity();
@ -251,6 +233,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false); editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
initDialog(); initDialog();
setCancelable(false);
return view; return view;
} }
@ -344,7 +327,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000); activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshOverview("WizardDialog")); MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
} }
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 120, true, new Callback() { ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
@ -438,14 +421,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U"); bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U"); basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
// COB only if AMA is selected
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
cobLayout.setVisibility(View.VISIBLE);
cobAvailable = true;
} else {
cobLayout.setVisibility(View.GONE);
cobAvailable = false;
}
calculateInsulin(); calculateInsulin();
} }
@ -482,13 +457,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
// COB // COB
Double c_cob = 0d; Double c_cob = 0d;
if (cobAvailable && cobCheckbox.isChecked()) { if (cobCheckbox.isChecked()) {
if (ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) { AutosensData autosensData = IobCobCalculatorPlugin.getLastAutosensData();
try {
c_cob = SafeParse.stringToDouble(ConfigBuilderPlugin.getActiveAPS().getLastAPSResult().json().getString("COB")); if(autosensData != null) {
} catch (JSONException e) { c_cob = autosensData.cob;
log.error("Unhandled exception", e);
}
} }
} }
@ -530,7 +503,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
bgTrendInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromTrend) + "U"); bgTrendInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromTrend) + "U");
// COB // COB
if (cobAvailable && cobCheckbox.isChecked()) { if (cobCheckbox.isChecked()) {
cob.setText(DecimalFormatter.to2Decimal(c_cob) + "g IC: " + DecimalFormatter.to1Decimal(wizard.ic)); cob.setText(DecimalFormatter.to2Decimal(c_cob) + "g IC: " + DecimalFormatter.to1Decimal(wizard.ic));
cobInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCOB) + "U"); cobInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCOB) + "U");
} else { } else {

View file

@ -53,7 +53,6 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -62,6 +61,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.QuickWizardEntry;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
@ -79,6 +79,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
@ -98,6 +99,7 @@ import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
import info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock; import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData; import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
@ -113,9 +115,10 @@ import info.nightscout.utils.NSUpload;
import info.nightscout.utils.OKDialog; import info.nightscout.utils.OKDialog;
import info.nightscout.utils.Profiler; import info.nightscout.utils.Profiler;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.SingleClickButton;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, View.OnLongClickListener {
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class); private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
TextView timeView; TextView timeView;
@ -156,11 +159,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
LinearLayoutManager llm; LinearLayoutManager llm;
LinearLayout acceptTempLayout; LinearLayout acceptTempLayout;
Button treatmentButton; SingleClickButton treatmentButton;
Button wizardButton; SingleClickButton wizardButton;
Button calibrationButton; SingleClickButton calibrationButton;
Button acceptTempButton; SingleClickButton acceptTempButton;
Button quickWizardButton; SingleClickButton quickWizardButton;
CheckBox lockScreen; CheckBox lockScreen;
@ -244,16 +247,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph); bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph); iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton); treatmentButton = (SingleClickButton) view.findViewById(R.id.overview_treatmentbutton);
treatmentButton.setOnClickListener(this); treatmentButton.setOnClickListener(this);
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton); wizardButton = (SingleClickButton) view.findViewById(R.id.overview_wizardbutton);
wizardButton.setOnClickListener(this); wizardButton.setOnClickListener(this);
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton); acceptTempButton = (SingleClickButton) view.findViewById(R.id.overview_accepttempbutton);
if (acceptTempButton != null) if (acceptTempButton != null)
acceptTempButton.setOnClickListener(this); acceptTempButton.setOnClickListener(this);
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton); quickWizardButton = (SingleClickButton) view.findViewById(R.id.overview_quickwizardbutton);
quickWizardButton.setOnClickListener(this); quickWizardButton.setOnClickListener(this);
calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton); quickWizardButton.setOnLongClickListener(this);
calibrationButton = (SingleClickButton) view.findViewById(R.id.overview_calibrationbutton);
if (calibrationButton != null) if (calibrationButton != null)
calibrationButton.setOnClickListener(this); calibrationButton.setOnClickListener(this);
@ -320,6 +324,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
return view; return view;
} catch (Exception e) { } catch (Exception e) {
Crashlytics.logException(e); Crashlytics.logException(e);
log.debug("Runtime Exception", e);
} }
return null; return null;
@ -331,6 +336,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
super.onCreateContextMenu(menu, v, menuInfo); super.onCreateContextMenu(menu, v, menuInfo);
if (v == apsModeView) { if (v == apsModeView) {
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop(); final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
if (activeloop == null) if (activeloop == null)
return; return;
menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop)); menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
@ -341,7 +347,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h)); menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h)); menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h)); menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m)); if (pumpDescription.tempDurationStep <= 30)
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h)); menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h)); menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h)); menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h));
@ -480,7 +487,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
activeloop.disconnectTo(System.currentTimeMillis() + 30L * 60 * 1000); activeloop.disconnectTo(System.currentTimeMillis() + 30L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 30, true, new Callback() { ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 30, true, new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
@ -493,7 +500,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
activeloop.disconnectTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000); activeloop.disconnectTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 60, true, new Callback() { ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 60, true, new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
@ -506,7 +513,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
activeloop.disconnectTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000); activeloop.disconnectTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 2 * 60, true, new Callback() { ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 2 * 60, true, new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
@ -519,7 +526,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
activeloop.disconnectTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000); activeloop.disconnectTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 3 * 60, true, new Callback() { ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 3 * 60, true, new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
@ -574,6 +581,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
@Override
public boolean onLongClick(View v) {
switch (v.getId()) {
case R.id.overview_quickwizardbutton:
Intent i = new Intent(v.getContext(), QuickWizardListActivity.class);
startActivity(i);
return true;
}
return false;
}
private void onClickAcceptTemp() { private void onClickAcceptTemp() {
if (ConfigBuilderPlugin.getActiveLoop() != null) { if (ConfigBuilderPlugin.getActiveLoop() != null) {
ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false); ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
@ -617,11 +635,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
final Profile profile = MainApp.getConfigBuilder().getProfile(); final Profile profile = MainApp.getConfigBuilder().getProfile();
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(); final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive(); final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && actualBg != null) { if (quickWizardEntry != null && actualBg != null) {
quickWizardButton.setVisibility(View.VISIBLE); quickWizardButton.setVisibility(View.VISIBLE);
BolusWizard wizard = new BolusWizard(); final BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, actualBg);
wizard.doCalc(profile, tempTarget, quickWizardEntry.carbs(), 0d, actualBg.valueToUnits(profile.getUnits()), 0d, true, true, false, false);
final JSONObject boluscalcJSON = new JSONObject(); final JSONObject boluscalcJSON = new JSONObject();
try { try {
@ -680,6 +697,26 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
accepted = true; accepted = true;
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) { if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
if (wizard.superBolus) {
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
if (activeloop != null) {
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
}
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, new Callback() {
@Override
public void run() {
if (!result.success) {
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
i.putExtra("title", MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
}
});
}
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD; detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
detailedBolusInfo.insulin = finalInsulinAfterConstraints; detailedBolusInfo.insulin = finalInsulinAfterConstraints;
@ -1084,12 +1121,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
tempTargetView.setLongClickable(true); tempTargetView.setLongClickable(true);
// QuickWizard button // QuickWizard button
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive(); QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) { if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
quickWizardButton.setVisibility(View.VISIBLE); quickWizardButton.setVisibility(View.VISIBLE);
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g"; String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
BolusWizard wizard = new BolusWizard(); BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, lastBG);
wizard.doCalc(profile, tempTarget, quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(units), 0d, true, true, false, false);
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U"; text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
quickWizardButton.setText(text); quickWizardButton.setText(text);
if (wizard.calculatedTotalInsulin <= 0) if (wizard.calculatedTotalInsulin <= 0)
@ -1161,7 +1197,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// cob // cob
if (cobView != null) { // view must not exists if (cobView != null) { // view must not exists
String cobText = ""; String cobText = "";
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis()); AutosensData autosensData = IobCobCalculatorPlugin.getLastAutosensData();
if (autosensData != null) if (autosensData != null)
cobText = (int) autosensData.cob + " g"; cobText = (int) autosensData.cob + " g";
cobView.setText(cobText); cobView.setText(cobText);

View file

@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.QuickWizard;
import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.Overview.activities; package info.nightscout.androidaps.plugins.Overview.activities;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView; import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@ -15,13 +15,11 @@ import android.widget.TextView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.text.SimpleDateFormat;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.QuickWizard;
import info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Overview.QuickWizard;
import info.nightscout.androidaps.plugins.Overview.events.EventQuickWizardChange; import info.nightscout.androidaps.plugins.Overview.events.EventQuickWizardChange;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
@ -153,6 +151,7 @@ public class QuickWizardListActivity extends AppCompatActivity implements View.O
break; break;
} }
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventQuickWizardChange ev) { public void onStatusEvent(final EventQuickWizardChange ev) {
updateGUI(); updateGUI();

View file

@ -27,7 +27,7 @@ import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData; import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData;
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA; import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries; import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;

View file

@ -57,6 +57,7 @@ public class Notification {
public static final int PUMP_UNREACHABLE = 26; public static final int PUMP_UNREACHABLE = 26;
public static final int BG_READINGS_MISSED = 27; public static final int BG_READINGS_MISSED = 27;
public static final int UNSUPPORTED_FIRMWARE = 28; public static final int UNSUPPORTED_FIRMWARE = 28;
public static final int MINIMAL_BASAL_VALUE_REPLACED = 29;
public int id; public int id;
public Date date; public Date date;

View file

@ -23,6 +23,7 @@ import java.text.DecimalFormat;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
@ -84,15 +85,17 @@ public class LocalProfileFragment extends SubscriberFragment {
} }
}; };
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false); View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia); diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
diaView.setParams(localProfilePlugin.dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch); diaView.setParams(localProfilePlugin.dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl); mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol); mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", getPlugin().ic, null, 0.1d, new DecimalFormat("0.0"), save); icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", getPlugin().isf, null, 0.1d, new DecimalFormat("0.0"), save); isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), getPlugin().basal, null, 0.01d, new DecimalFormat("0.00"), save); basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", getPlugin().targetLow, getPlugin().targetHigh, 0.1d, new DecimalFormat("0.0"), save); targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", getPlugin().targetLow, getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch); profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) { if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {

View file

@ -4,6 +4,7 @@ package info.nightscout.androidaps.plugins.PumpCombo;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.text.Spanned; import android.text.Spanned;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -137,11 +138,14 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
if (ps.insulinState == PumpState.EMPTY || ps.batteryState == PumpState.EMPTY if (ps.insulinState == PumpState.EMPTY || ps.batteryState == PumpState.EMPTY
|| ps.activeAlert != null && ps.activeAlert.errorCode != null) { || ps.activeAlert != null && ps.activeAlert.errorCode != null) {
stateView.setTextColor(Color.RED); stateView.setTextColor(Color.RED);
stateView.setTypeface(null, Typeface.BOLD);
} else if (plugin.getPump().state.suspended } else if (plugin.getPump().state.suspended
|| ps.activeAlert != null && ps.activeAlert.warningCode != null) { || ps.activeAlert != null && ps.activeAlert.warningCode != null) {
stateView.setTextColor(Color.YELLOW); stateView.setTextColor(Color.YELLOW);
stateView.setTypeface(null, Typeface.BOLD);
} else { } else {
stateView.setTextColor(Color.WHITE); stateView.setTextColor(Color.WHITE);
stateView.setTypeface(null, Typeface.NORMAL);
} }
// activity // activity
@ -171,12 +175,15 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
if (ps.insulinState == PumpState.LOW) { if (ps.insulinState == PumpState.LOW) {
reservoirView.setTextColor(Color.YELLOW); reservoirView.setTextColor(Color.YELLOW);
reservoirView.setText(R.string.combo_reservoir_low); reservoirView.setText(R.string.combo_reservoir_low);
reservoirView.setTypeface(null, Typeface.BOLD);
} else if (ps.insulinState == PumpState.EMPTY) { } else if (ps.insulinState == PumpState.EMPTY) {
reservoirView.setTextColor(Color.RED); reservoirView.setTextColor(Color.RED);
reservoirView.setText(R.string.combo_reservoir_empty); reservoirView.setText(R.string.combo_reservoir_empty);
reservoirView.setTypeface(null, Typeface.BOLD);
} else { } else {
reservoirView.setTextColor(Color.WHITE); reservoirView.setTextColor(Color.WHITE);
reservoirView.setText(R.string.combo_reservoir_normal); reservoirView.setText(R.string.combo_reservoir_normal);
reservoirView.setTypeface(null, Typeface.NORMAL);
} }
// last connection // last connection
@ -186,7 +193,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
lastConnectionView.setText(R.string.combo_pump_connected_now); lastConnectionView.setText(R.string.combo_pump_connected_now);
lastConnectionView.setTextColor(Color.WHITE); lastConnectionView.setTextColor(Color.WHITE);
} else if (plugin.getPump().lastSuccessfulCmdTime + 30 * 60 * 1000 < System.currentTimeMillis()) { } else if (plugin.getPump().lastSuccessfulCmdTime + 30 * 60 * 1000 < System.currentTimeMillis()) {
lastConnectionView.setText(getString(R.string.combo_no_pump_connection, min)); lastConnectionView.setText(MainApp.sResources.getString(R.string.combo_no_pump_connection, min));
lastConnectionView.setTextColor(Color.RED); lastConnectionView.setTextColor(Color.RED);
} else { } else {
lastConnectionView.setText(minAgo); lastConnectionView.setText(minAgo);
@ -199,7 +206,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
long minSinceRead = (System.currentTimeMillis() - plugin.getPump().state.timestamp) / 1000 / 60; long minSinceRead = (System.currentTimeMillis() - plugin.getPump().state.timestamp) / 1000 / 60;
long remaining = ps.tbrRemainingDuration - minSinceRead; long remaining = ps.tbrRemainingDuration - minSinceRead;
if (remaining >= 0) { if (remaining >= 0) {
tbrStr = getString(R.string.combo_tbr_remaining, ps.tbrPercent, remaining); tbrStr = MainApp.sResources.getString(R.string.combo_tbr_remaining, ps.tbrPercent, remaining);
} }
} }
tempBasalText.setText(tbrStr); tempBasalText.setText(tbrStr);

View file

@ -41,6 +41,7 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
@ -82,7 +83,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
pumpDescription.isSetBasalProfileCapable = true; pumpDescription.isSetBasalProfileCapable = true;
pumpDescription.basalStep = 0.01d; pumpDescription.basalStep = 0.01d;
pumpDescription.basalMinimumRate = 0.0d; pumpDescription.basalMinimumRate = 0.05d;
pumpDescription.isRefillingCapable = true; pumpDescription.isRefillingCapable = true;
} }
@ -138,7 +139,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
String getStateSummary() { String getStateSummary() {
PumpState ps = pump.state; PumpState ps = pump.state;
if (ps.activeAlert != null) { if (!validBasalRateProfileSelectedOnPump) {
return MainApp.sResources.getString(R.string.loopdisabled);
} else if (ps.activeAlert != null) {
return ps.activeAlert.errorCode != null return ps.activeAlert.errorCode != null
? "E" + ps.activeAlert.errorCode + ": " + ps.activeAlert.message ? "E" + ps.activeAlert.errorCode + ": " + ps.activeAlert.message
: "W" + ps.activeAlert.warningCode + ": " + ps.activeAlert.message; : "W" + ps.activeAlert.warningCode + ": " + ps.activeAlert.message;
@ -175,7 +178,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override @Override
public boolean showInList(int type) { public boolean showInList(int type) {
return true; return type == PUMP;
} }
@Override @Override
@ -190,7 +193,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override @Override
public int getPreferencesId() { public int getPreferencesId() {
return R.xml.pref_combo; return -1;
} }
@Override @Override
@ -258,12 +261,17 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return new PumpEnactResult().success(true).enacted(false); return new PumpEnactResult().success(true).enacted(false);
} }
CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState);
if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
return new PumpEnactResult().success(false).enacted(false).comment(MainApp.sResources.getString(R.string.combo_force_disabled_notification));
}
CommandResult setResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_setting_basal_profile), 2, CommandResult setResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_setting_basal_profile), 2,
() -> ruffyScripter.setBasalProfile(requestedBasalProfile)); () -> ruffyScripter.setBasalProfile(requestedBasalProfile));
if (!setResult.success) { if (!setResult.success) {
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT); Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
return new PumpEnactResult().success(false).enacted(false); return new PumpEnactResult().success(false).enacted(false).comment(MainApp.sResources.getString(R.string.failedupdatebasalprofile));
} }
/* don't re-read basal profile to not trigger pump bug; setBasalProfile command checks the total at the end, which must suffice /* don't re-read basal profile to not trigger pump bug; setBasalProfile command checks the total at the end, which must suffice
@ -324,48 +332,54 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return new Date(pump.lastSuccessfulCmdTime); return new Date(pump.lastSuccessfulCmdTime);
} }
/** /** Runs pump initializing if needed and reads the pump state from the main screen. */
* Runs pump initializing if needed, checks for boluses given on the pump, updates the
* reservoir level and checks the running TBR on the pump.
*/
@Override @Override
public synchronized void getPumpStatus() { public synchronized void getPumpStatus() {
log.debug("getPumpStatus called"); log.debug("getPumpStatus called");
if (!pump.initialized) { if (!pump.initialized) {
long maxWait = System.currentTimeMillis() + 15 * 1000; initializePump();
while (!ruffyScripter.isPumpAvailable()) { } else {
log.debug("Waiting for ruffy service to come up ..."); runCommand(MainApp.sResources.getString(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readPumpState);
SystemClock.sleep(100); }
if (System.currentTimeMillis() > maxWait) { }
log.debug("ruffy service unavailable, wtf");
return; private synchronized void initializePump() {
} long maxWait = System.currentTimeMillis() + 15 * 1000;
while (!ruffyScripter.isPumpAvailable()) {
log.debug("Waiting for ruffy service to come up ...");
SystemClock.sleep(100);
if (System.currentTimeMillis() > maxWait) {
log.debug("ruffy service unavailable, wtf");
return;
} }
} }
CommandResult stateResult = runCommand(pump.initialized ? MainApp.sResources.getString(R.string.combo_pump_action_refreshing) : MainApp.sResources.getString(R.string.combo_pump_action_initializing), CommandResult stateResult = runCommand(MainApp.sResources.getString(R.string.combo_pump_action_initializing),1, ruffyScripter::readPumpState);
1, ruffyScripter::readPumpState);
if (!stateResult.success) { if (!stateResult.success) {
return; return;
} }
// read basal profile into cache and update pump profile if needed if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
if (!pump.initialized) { Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
CommandResult readBasalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile); MainApp.sResources.getString(R.string.combo_force_disabled_notification),
if (!readBasalResult.success) { Notification.URGENT);
return; n.soundId = R.raw.alarm;
} MainApp.bus().post(new EventNewNotification(n));
pump.basalProfile = readBasalResult.basalProfile; return;
} }
if (!pump.initialized) { // read basal profile into cache (KeepAlive will trigger a profile update if needed)
pump.initialized = true; CommandResult readBasalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile);
MainApp.bus().post(new EventInitializationChanged()); if (!readBasalResult.success) {
return;
} }
pump.basalProfile = readBasalResult.basalProfile;
validBasalRateProfileSelectedOnPump = true;
pump.initialized = true;
MainApp.bus().post(new EventInitializationChanged());
// ComboFragment updates state fully only after the pump has initialized, // ComboFragment updates state fully only after the pump has initialized, so run this manually here
// this fetches state again and updates the UI proper updateLocalData(readBasalResult);
runCommand(null, 0, ruffyScripter::readPumpState);
} }
private void updateLocalData(CommandResult result) { private void updateLocalData(CommandResult result) {
@ -453,7 +467,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true); lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true);
long pumpTimeWhenBolusWasRequested = runCommand(null, 1, ruffyScripter::readPumpState).state.pumpTime; CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState);
long pumpTimeWhenBolusWasRequested = stateResult .state.pumpTime;
if (!stateResult.success || pumpTimeWhenBolusWasRequested == 0) {
return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.sResources.getString(R.string.combo_error_no_bolus_delivered));
}
try { try {
pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin); pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin);
@ -463,7 +482,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return new PumpEnactResult().success(true).enacted(false); return new PumpEnactResult().success(true).enacted(false);
} }
BolusProgressReporter progressReporter = detailedBolusInfo.isSMB ? nullBolusProgressReporter : ComboPlugin.bolusProgressReporter; BolusProgressReporter progressReporter = detailedBolusInfo.isSMB ? nullBolusProgressReporter : bolusProgressReporter;
// start bolus delivery // start bolus delivery
bolusInProgress = true; bolusInProgress = true;
@ -525,6 +544,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (lastBolus == null // no bolus ever given if (lastBolus == null // no bolus ever given
|| lastBolus.timestamp < pumpTimeWhenBolusWasRequested // this is not the bolus you're looking for || lastBolus.timestamp < pumpTimeWhenBolusWasRequested // this is not the bolus you're looking for
|| lastBolus.amount - detailedBolusInfo.insulin > 0.01 // this one neither, big than requested bolus
|| !lastBolus.isValid) { // ext/multiwave bolus || !lastBolus.isValid) { // ext/multiwave bolus
log.debug("No bolus was delivered"); log.debug("No bolus was delivered");
return new PumpEnactResult().success(false).enacted(false) return new PumpEnactResult().success(false).enacted(false)
@ -535,21 +555,21 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
detailedBolusInfo.insulin = lastBolus.amount; detailedBolusInfo.insulin = lastBolus.amount;
detailedBolusInfo.source = Source.USER; detailedBolusInfo.source = Source.USER;
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
log.debug(String.format(Locale.getDefault(), "Added partial bolus of %.2f to treatments (requested: %.2f", lastBolus.amount, requestedBolus)); log.debug(String.format(Locale.getDefault(), "Added partial bolus of %.2f to treatments (requested: %.2f)", lastBolus.amount, requestedBolus));
return new PumpEnactResult().success(false).enacted(true) return new PumpEnactResult().success(false).enacted(true)
.comment(MainApp.sResources.getString(R.string.combo_error_partial_bolus_delivered, .comment(MainApp.sResources.getString(R.string.combo_error_partial_bolus_delivered,
lastBolus.amount, requestedBolus)); lastBolus.amount, requestedBolus));
} else {
// bolus was correctly and fully delivered
detailedBolusInfo.insulin = lastBolus.amount;
detailedBolusInfo.source = Source.USER;
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
log.debug("Added correctly delivered bolus to treatments");
return new PumpEnactResult().success(true).enacted(true)
.bolusDelivered(lastBolus.amount)
.carbsDelivered(detailedBolusInfo.carbs);
} }
// bolus was correctly and fully delivered
detailedBolusInfo.insulin = lastBolus.amount;
detailedBolusInfo.source = Source.USER;
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
log.debug("Added correctly delivered bolus to treatments");
return new PumpEnactResult().success(true).enacted(true)
.bolusDelivered(lastBolus.amount)
.carbsDelivered(detailedBolusInfo.carbs);
} }
@Override @Override
@ -577,9 +597,18 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return setTempBasalPercent(roundedPercentage, durationInMinutes); return setTempBasalPercent(roundedPercentage, durationInMinutes);
} }
// Note: AAPS calls this directly only for setting a temp basal issued by the user /**
* Note: AAPS calls this directly only for setting a temp basal issued by the user
*
* @param forceNew Driver always applies the requested TBR and simply overrides whatever TBR
* is or isn't running at the moment
*/
@Override @Override
public PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) { public PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes, boolean forceNew) {
return setTempBasalPercent(percent, durationInMinutes);
}
private PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) {
log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min"); log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min");
int adjustedPercent = percent; int adjustedPercent = percent;
@ -707,9 +736,15 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (commandResult.success) { if (commandResult.success) {
pump.lastSuccessfulCmdTime = System.currentTimeMillis(); pump.lastSuccessfulCmdTime = System.currentTimeMillis();
} if (validBasalRateProfileSelectedOnPump && commandResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
validBasalRateProfileSelectedOnPump = false;
if (commandResult.success) { Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
MainApp.sResources.getString(R.string.combo_force_disabled_notification),
Notification.URGENT);
n.soundId = R.raw.alarm;
MainApp.bus().post(new EventNewNotification(n));
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null);
}
updateLocalData(commandResult); updateLocalData(commandResult);
} }
} finally { } finally {
@ -751,7 +786,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
notification.date = new Date(); notification.date = new Date();
notification.id = Notification.COMBO_PUMP_ALARM; notification.id = Notification.COMBO_PUMP_ALARM;
notification.level = Notification.URGENT; notification.level = Notification.URGENT;
notification.text = MainApp.sResources.getString(R.string.combo_is_in_error_state); notification.text = MainApp.sResources.getString(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
return preCheckResult.success(false); return preCheckResult.success(false);
} }
@ -769,9 +804,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (state.pumpTime == 0) { if (state.pumpTime == 0) {
// time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field) // time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field)
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) { } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) {
log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_notification_check_time_date), Notification.URGENT); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_notification_check_time_date), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) { } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) {
log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_notification_check_time_date), Notification.NORMAL); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_notification_check_time_date), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
} }
@ -802,7 +839,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (commandResult == null) return; if (commandResult == null) return;
long lastViolation = 0; long lastViolation = 0;
if (commandResult.state.unsafeUsageDetected) { if (commandResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BOLUS_TYPE) {
lastViolation = System.currentTimeMillis(); lastViolation = System.currentTimeMillis();
} else if (commandResult.lastBolus != null && !commandResult.lastBolus.isValid) { } else if (commandResult.lastBolus != null && !commandResult.lastBolus.isValid) {
lastViolation = commandResult.lastBolus.timestamp; lastViolation = commandResult.lastBolus.timestamp;
@ -814,14 +851,15 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
} }
if (lastViolation > 0) { if (lastViolation > 0) {
lowSuspendOnlyLoopEnforcetTill = lastViolation + 6 * 60 * 60 * 1000; lowSuspendOnlyLoopEnforcedUntil = lastViolation + 6 * 60 * 60 * 1000;
if (lowSuspendOnlyLoopEnforcetTill > System.currentTimeMillis() && violationWarningRaisedFor != lowSuspendOnlyLoopEnforcetTill) { if (lowSuspendOnlyLoopEnforcedUntil > System.currentTimeMillis() && violationWarningRaisedForBolusAt != lowSuspendOnlyLoopEnforcedUntil) {
Notification n = new Notification(Notification.COMBO_PUMP_ALARM, Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
MainApp.sResources.getString(R.string.combo_force_disabled_notification), MainApp.sResources.getString(R.string.combo_low_suspend_forced_notification),
Notification.URGENT); Notification.URGENT);
n.soundId = R.raw.alarm; n.soundId = R.raw.alarm;
MainApp.bus().post(new EventNewNotification(n)); MainApp.bus().post(new EventNewNotification(n));
violationWarningRaisedFor = lowSuspendOnlyLoopEnforcetTill; violationWarningRaisedForBolusAt = lowSuspendOnlyLoopEnforcedUntil;
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null);
} }
} }
} }
@ -1049,12 +1087,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
// Constraints interface // Constraints interface
private long lowSuspendOnlyLoopEnforcetTill = 0; private long lowSuspendOnlyLoopEnforcedUntil = 0;
private long violationWarningRaisedFor = 0; private long violationWarningRaisedForBolusAt = 0;
private boolean validBasalRateProfileSelectedOnPump = true;
@Override @Override
public boolean isLoopEnabled() { public boolean isLoopEnabled() {
return true; return validBasalRateProfileSelectedOnPump;
} }
@Override @Override
@ -1072,6 +1111,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return true; return true;
} }
@Override
public boolean isSMBModeEnabled() {
return true;
}
@Override @Override
public Double applyBasalConstraints(Double absoluteRate) { public Double applyBasalConstraints(Double absoluteRate) {
return absoluteRate; return absoluteRate;
@ -1094,6 +1138,6 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override @Override
public Double applyMaxIOBConstraints(Double maxIob) { public Double applyMaxIOBConstraints(Double maxIob) {
return lowSuspendOnlyLoopEnforcetTill < System.currentTimeMillis() ? maxIob : 0; return lowSuspendOnlyLoopEnforcedUntil < System.currentTimeMillis() ? maxIob : 0;
} }
} }

View file

@ -434,7 +434,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
// Convert duration from minutes to hours // Convert duration from minutes to hours
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes); return setTempBasalPercent(percentRate, durationInMinutes, false);
} }
if (doExtendedTemp) { if (doExtendedTemp) {
// Check if some temp is already in progress // Check if some temp is already in progress
@ -499,7 +499,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
} }
@Override @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent); percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -514,7 +514,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
if (percent > getPumpDescription().maxTempPercent) if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent; percent = getPumpDescription().maxTempPercent;
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) { if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
result.enacted = false; result.enacted = false;
result.success = true; result.success = true;
result.isTempCancel = false; result.isTempCancel = false;
@ -785,6 +785,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
return true; return true;
} }
@Override
public boolean isSMBModeEnabled() {
return true;
}
@SuppressWarnings("PointlessBooleanExpression") @SuppressWarnings("PointlessBooleanExpression")
@Override @Override
public Double applyBasalConstraints(Double absoluteRate) { public Double applyBasalConstraints(Double absoluteRate) {

View file

@ -436,7 +436,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
// Convert duration from minutes to hours // Convert duration from minutes to hours
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes); return setTempBasalPercent(percentRate, durationInMinutes, false);
} }
if (doExtendedTemp) { if (doExtendedTemp) {
// Check if some temp is already in progress // Check if some temp is already in progress
@ -501,7 +501,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
} }
@Override @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent); percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -516,7 +516,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
if (percent > getPumpDescription().maxTempPercent) if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent; percent = getPumpDescription().maxTempPercent;
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) { if (runningTB != null && runningTB.percentRate == percent && enforceNew) {
result.enacted = false; result.enacted = false;
result.success = true; result.success = true;
result.isTempCancel = false; result.isTempCancel = false;
@ -787,6 +787,11 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
return true; return true;
} }
@Override
public boolean isSMBModeEnabled() {
return true;
}
@SuppressWarnings("PointlessBooleanExpression") @SuppressWarnings("PointlessBooleanExpression")
@Override @Override
public Double applyBasalConstraints(Double absoluteRate) { public Double applyBasalConstraints(Double absoluteRate) {

View file

@ -289,6 +289,11 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
return true; return true;
} }
@Override
public boolean isSMBModeEnabled() {
return true;
}
@Override @Override
public Double applyBasalConstraints(Double absoluteRate) { public Double applyBasalConstraints(Double absoluteRate) {
double origAbsoluteRate = absoluteRate; double origAbsoluteRate = absoluteRate;
@ -580,7 +585,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent); percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -595,7 +600,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
if (percent > getPumpDescription().maxTempPercent) if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent; percent = getPumpDescription().maxTempPercent;
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) { if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
result.enacted = false; result.enacted = false;
result.success = true; result.success = true;
result.isTempCancel = false; result.isTempCancel = false;

View file

@ -162,6 +162,7 @@ public class BLEScanActivity extends AppCompatActivity {
public void onClick(View v) { public void onClick(View v) {
SP.putString(R.string.key_danars_address, item.device.getAddress()); SP.putString(R.string.key_danars_address, item.device.getAddress());
SP.putString(R.string.key_danars_name, mName.getText().toString()); SP.putString(R.string.key_danars_name, mName.getText().toString());
item.device.createBond();
MainApp.bus().post(new EventDanaRSDeviceChange()); MainApp.bus().post(new EventDanaRSDeviceChange());
finish(); finish();
} }

View file

@ -118,7 +118,7 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic
@Override @Override
public void dismiss() { public void dismiss() {
super.dismiss(); super.dismissAllowingStateLoss();
if (helperActivity != null) { if (helperActivity != null) {
helperActivity.finish(); helperActivity.finish();
} }

View file

@ -1,8 +1,10 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.events; package info.nightscout.androidaps.plugins.PumpDanaRS.events;
import info.nightscout.androidaps.events.Event;
/** /**
* Created by mike on 05.09.2017. * Created by mike on 05.09.2017.
*/ */
public class EventDanaRSDeviceChange { public class EventDanaRSDeviceChange extends Event {
} }

View file

@ -1,12 +1,13 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.events; package info.nightscout.androidaps.plugins.PumpDanaRS.events;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet; import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet;
/** /**
* Created by mike on 01.09.2017. * Created by mike on 01.09.2017.
*/ */
public class EventDanaRSPacket { public class EventDanaRSPacket extends Event{
public EventDanaRSPacket(DanaRS_Packet data) { public EventDanaRSPacket(DanaRS_Packet data) {
this.data = data; this.data = data;
} }

View file

@ -1,8 +1,10 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.events; package info.nightscout.androidaps.plugins.PumpDanaRS.events;
import info.nightscout.androidaps.events.Event;
/** /**
* Created by mike on 01.09.2017. * Created by mike on 01.09.2017.
*/ */
public class EventDanaRSPairingSuccess { public class EventDanaRSPairingSuccess extends Event{
} }

View file

@ -185,7 +185,10 @@ public class DanaRSService extends Service {
while (!msg.done && bleComm.isConnected()) { while (!msg.done && bleComm.isConnected()) {
SystemClock.sleep(100); SystemClock.sleep(100);
} }
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - 45 * 60 * 1000L; // always load last 45 min if (DanaRS_Packet_APS_History_Events.lastEventTimeLoaded != 0)
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - 45 * 60 * 1000L; // always load last 45 min
else
lastHistoryFetched = 0;
log.debug("Events loaded"); log.debug("Events loaded");
return new PumpEnactResult().success(true); return new PumpEnactResult().success(true);
} }

View file

@ -437,7 +437,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent); percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -452,7 +452,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
if (percent > getPumpDescription().maxTempPercent) if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent; percent = getPumpDescription().maxTempPercent;
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) { if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
result.enacted = false; result.enacted = false;
result.success = true; result.success = true;
result.isTempCancel = false; result.isTempCancel = false;
@ -730,6 +730,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
return true; return true;
} }
@Override
public boolean isSMBModeEnabled() {
return true;
}
@SuppressWarnings("PointlessBooleanExpression") @SuppressWarnings("PointlessBooleanExpression")
@Override @Override
public Double applyBasalConstraints(Double absoluteRate) { public Double applyBasalConstraints(Double absoluteRate) {

View file

@ -527,7 +527,10 @@ public class DanaRv2ExecutionService extends Service {
waitMsec(100); waitMsec(100);
} }
waitMsec(200); waitMsec(200);
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - 45 * 60 * 1000L; //always load last 45 min; if (MsgHistoryEvents_v2.lastEventTimeLoaded != 0)
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - 45 * 60 * 1000L; //always load last 45 min;
else
lastHistoryFetched = 0;
return new PumpEnactResult().success(true); return new PumpEnactResult().success(true);
} }

View file

@ -204,7 +204,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
} }
@Override @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.pumperror); result.comment = MainApp.instance().getString(R.string.pumperror);

View file

@ -1,8 +1,6 @@
package info.nightscout.androidaps.plugins.PumpVirtual; package info.nightscout.androidaps.plugins.PumpVirtual;
import android.content.SharedPreferences;
import android.os.SystemClock; import android.os.SystemClock;
import android.preference.PreferenceManager;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -16,6 +14,7 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
@ -24,7 +23,6 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui; import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
@ -65,6 +63,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
} }
private static VirtualPumpPlugin plugin = null; private static VirtualPumpPlugin plugin = null;
public static VirtualPumpPlugin getPlugin() { public static VirtualPumpPlugin getPlugin() {
loadFakingStatus(); loadFakingStatus();
if (plugin == null) if (plugin == null)
@ -304,7 +303,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
} }
@Override @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
@ -401,8 +400,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override @Override
public JSONObject getJSONStatus() { public JSONObject getJSONStatus() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
if (!preferences.getBoolean("virtualpump_uploadstatus", false)) {
return null; return null;
} }
JSONObject pump = new JSONObject(); JSONObject pump = new JSONObject();

View file

@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin; import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.BolusWizard; import info.nightscout.utils.BolusWizard;
@ -268,13 +269,15 @@ public class ActionStringHandler {
} else if ("tddstats".equals(act[0])) { } else if ("tddstats".equals(act[0])) {
Object activePump = MainApp.getConfigBuilder().getActivePump(); Object activePump = MainApp.getConfigBuilder().getActivePump();
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class); PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class);
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class); PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class); PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
if ((dana == null || dana != activePump) && if ((dana == null || dana != activePump) &&
(danaV2 == null || danaV2 != activePump) && (danaV2 == null || danaV2 != activePump) &&
(danaKorean == null || danaKorean != activePump) (danaKorean == null || danaKorean != activePump) &&
(danaRS == null || danaRS != activePump)
) { ) {
sendError("Pump does not support TDDs!"); sendError("Pump does not support TDDs!");
return; return;

View file

@ -215,6 +215,8 @@ public class WearPlugin implements PluginBase {
@Subscribe @Subscribe
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) { public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
if(ev.result == null) return;
String status; String status;
if(ev.result.success){ if(ev.result.success){
status = MainApp.sResources.getString(R.string.success); status = MainApp.sResources.getString(R.string.success);

View file

@ -533,7 +533,7 @@ public class WatchUpdaterService extends WearableListenerService implements
String iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob); String iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
String iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")"; String iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
String cobString = generateCOBString(); String cobString = generateCOBString();
String tempBasal = generateBasalString(treatmentsInterface); String currentBasal = generateBasalString(treatmentsInterface);
//bgi //bgi
String bgiString = ""; String bgiString = "";
@ -543,7 +543,7 @@ public class WatchUpdaterService extends WearableListenerService implements
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi); bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi);
} }
String status = generateStatusString(profile, tempBasal,iobSum, iobDetail, bgiString); String status = generateStatusString(profile, currentBasal,iobSum, iobDetail, bgiString);
//batteries //batteries
int phoneBattery = getBatteryLevel(getApplicationContext()); int phoneBattery = getBatteryLevel(getApplicationContext());
@ -567,7 +567,7 @@ public class WatchUpdaterService extends WearableListenerService implements
dataMapRequest.getDataMap().putString("iobDetail", iobDetail); dataMapRequest.getDataMap().putString("iobDetail", iobDetail);
dataMapRequest.getDataMap().putBoolean("detailedIob", mPrefs.getBoolean("wear_detailediob", false)); dataMapRequest.getDataMap().putBoolean("detailedIob", mPrefs.getBoolean("wear_detailediob", false));
dataMapRequest.getDataMap().putString("cob", cobString); dataMapRequest.getDataMap().putString("cob", cobString);
dataMapRequest.getDataMap().putString("tempBasal", tempBasal); dataMapRequest.getDataMap().putString("currentBasal", currentBasal);
dataMapRequest.getDataMap().putString("battery", "" + phoneBattery); dataMapRequest.getDataMap().putString("battery", "" + phoneBattery);
dataMapRequest.getDataMap().putString("rigBattery", rigBattery); dataMapRequest.getDataMap().putString("rigBattery", rigBattery);
dataMapRequest.getDataMap().putLong("openApsStatus", openApsStatus); dataMapRequest.getDataMap().putLong("openApsStatus", openApsStatus);
@ -598,7 +598,7 @@ public class WatchUpdaterService extends WearableListenerService implements
} }
@NonNull @NonNull
private String generateStatusString(Profile profile, String tempBasal, String iobSum, String iobDetail, String bgiString) { private String generateStatusString(Profile profile, String currentBasal, String iobSum, String iobDetail, String bgiString) {
String status = ""; String status = "";
@ -623,7 +623,7 @@ public class WatchUpdaterService extends WearableListenerService implements
iobString = iobSum + "U"; iobString = iobSum + "U";
} }
status += tempBasal + " " + iobString; status += currentBasal + " " + iobString;
//add BGI if shown, otherwise return //add BGI if shown, otherwise return
if (mPrefs.getBoolean("wear_showbgi", false)) { if (mPrefs.getBoolean("wear_showbgi", false)) {
@ -636,10 +636,16 @@ public class WatchUpdaterService extends WearableListenerService implements
@NonNull @NonNull
private String generateBasalString(TreatmentsInterface treatmentsInterface) { private String generateBasalString(TreatmentsInterface treatmentsInterface) {
String basalStringResult = "-.--U/h"; String basalStringResult;
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) { if (activeTemp != null) {
basalStringResult = activeTemp.toStringShort(); basalStringResult = activeTemp.toStringShort();
} else {
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false)) {
basalStringResult = "100%";
} else {
basalStringResult = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h";
}
} }
return basalStringResult; return basalStringResult;
} }
@ -648,7 +654,7 @@ public class WatchUpdaterService extends WearableListenerService implements
private String generateCOBString() { private String generateCOBString() {
String cobStringResult = "--"; String cobStringResult = "--";
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis()); AutosensData autosensData = IobCobCalculatorPlugin.getLastAutosensData();
if (autosensData != null) { if (autosensData != null) {
cobStringResult = (int) autosensData.cob + "g"; cobStringResult = (int) autosensData.cob + "g";
} }

View file

@ -128,7 +128,7 @@ public class CommandQueue {
// After new command added to the queue // After new command added to the queue
// start thread again if not already running // start thread again if not already running
private void notifyAboutNewCommand() { private synchronized void notifyAboutNewCommand() {
if (thread == null || thread.getState() == Thread.State.TERMINATED) { if (thread == null || thread.getState() == Thread.State.TERMINATED) {
thread = new QueueThread(this); thread = new QueueThread(this);
thread.start(); thread.start();
@ -203,7 +203,7 @@ public class CommandQueue {
} }
// returns true if command is queued // returns true if command is queued
public boolean tempBasalPercent(int percent, int durationInMinutes, Callback callback) { public boolean tempBasalPercent(int percent, int durationInMinutes, boolean enforceNew, Callback callback) {
if (isRunning(Command.CommandType.TEMPBASAL)) { if (isRunning(Command.CommandType.TEMPBASAL)) {
if (callback != null) if (callback != null)
callback.result(executingNowError()).run(); callback.result(executingNowError()).run();
@ -216,7 +216,7 @@ public class CommandQueue {
Integer percentAfterConstraints = MainApp.getConfigBuilder().applyBasalConstraints(percent); Integer percentAfterConstraints = MainApp.getConfigBuilder().applyBasalConstraints(percent);
// add new command to queue // add new command to queue
add(new CommandTempBasalPercent(percentAfterConstraints, durationInMinutes, callback)); add(new CommandTempBasalPercent(percentAfterConstraints, durationInMinutes, enforceNew, callback));
notifyAboutNewCommand(); notifyAboutNewCommand();
@ -326,14 +326,14 @@ public class CommandQueue {
// returns true if command is queued // returns true if command is queued
public boolean readStatus(String reason, Callback callback) { public boolean readStatus(String reason, Callback callback) {
if (isRunning(Command.CommandType.READSTATUS)) { //if (isRunning(Command.CommandType.READSTATUS)) {
if (callback != null) // if (callback != null)
callback.result(executingNowError()).run(); // callback.result(executingNowError()).run();
return false; // return false;
} //}
// remove all unfinished // remove all unfinished
removeAll(Command.CommandType.READSTATUS); //removeAll(Command.CommandType.READSTATUS);
// add new command to queue // add new command to queue
add(new CommandReadStatus(reason, callback)); add(new CommandReadStatus(reason, callback));

View file

@ -59,7 +59,7 @@ public class QueueThread extends Thread {
} }
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) { if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
MainApp.bus().post(new EventDismissBolusprogressIfRunning(new PumpEnactResult())); MainApp.bus().post(new EventDismissBolusprogressIfRunning(null));
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout))); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
log.debug("QUEUE: timed out"); log.debug("QUEUE: timed out");
pump.stopConnecting(); pump.stopConnecting();
@ -79,7 +79,7 @@ public class QueueThread extends Thread {
mBluetoothAdapter.enable(); mBluetoothAdapter.enable();
SystemClock.sleep(1000); SystemClock.sleep(1000);
//start over again once after watchdog barked //start over again once after watchdog barked
connectionStartTime = System.currentTimeMillis(); connectionStartTime = lastCommandTime = System.currentTimeMillis();
} else { } else {
queue.clear(); queue.clear();
return; return;

View file

@ -18,17 +18,19 @@ public class CommandTempBasalPercent extends Command {
int durationInMinutes; int durationInMinutes;
int percent; int percent;
boolean enforceNew;
public CommandTempBasalPercent(int percent, int durationInMinutes, Callback callback) { public CommandTempBasalPercent(int percent, int durationInMinutes, boolean enforceNew, Callback callback) {
commandType = CommandType.TEMPBASAL; commandType = CommandType.TEMPBASAL;
this.percent = percent; this.percent = percent;
this.durationInMinutes = durationInMinutes; this.durationInMinutes = durationInMinutes;
this.enforceNew = enforceNew;
this.callback = callback; this.callback = callback;
} }
@Override @Override
public void execute() { public void execute() {
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes); PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes, enforceNew);
if (Config.logCongigBuilderActions) if (Config.logCongigBuilderActions)
log.debug("setTempBasalPercent percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted); log.debug("setTempBasalPercent percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
if (callback != null) if (callback != null)

View file

@ -14,15 +14,15 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
public class BolusWizard { public class BolusWizard {
// Inputs // Inputs
Profile specificProfile = null; private Profile specificProfile = null;
TempTarget tempTarget; private TempTarget tempTarget;
public Integer carbs = 0; public Integer carbs = 0;
Double bg = 0d; private Double bg = 0d;
Double correction; private Double correction;
Boolean includeBolusIOB = true; private Boolean includeBolusIOB = true;
Boolean includeBasalIOB = true; private Boolean includeBasalIOB = true;
Boolean superBolus = false; public Boolean superBolus = false;
Boolean trend = false; private Boolean trend = false;
// Intermediate // Intermediate
public Double sens = 0d; public Double sens = 0d;
@ -71,7 +71,9 @@ public class BolusWizard {
targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, specificProfile.getUnits()); targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, specificProfile.getUnits());
targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, specificProfile.getUnits()); targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, specificProfile.getUnits());
} }
if (bg <= targetBGLow) { if (bg >= targetBGLow && bg <= targetBGHigh) {
bgDiff = 0d;
} else if (bg <= targetBGLow) {
bgDiff = bg - targetBGLow; bgDiff = bg - targetBGLow;
} else { } else {
bgDiff = bg - targetBGHigh; bgDiff = bg - targetBGHigh;

View file

@ -2,10 +2,12 @@ package info.nightscout.utils;
import android.support.v4.util.LongSparseArray; import android.support.v4.util.LongSparseArray;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.util.SparseIntArray;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -27,9 +29,7 @@ public class DateUtil {
/** /**
* The date format in iso. * The date format in iso.
*/ */
private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ssZ"; private static String FORMAT_DATE_ISO_OUT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
private static String FORMAT_DATE_ISO_MSEC_UTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
/** /**
* Takes in an ISO date string of the following format: * Takes in an ISO date string of the following format:
@ -41,33 +41,10 @@ public class DateUtil {
*/ */
public static Date fromISODateString(String isoDateString) public static Date fromISODateString(String isoDateString)
throws Exception { throws Exception {
SimpleDateFormat f = new SimpleDateFormat(FORMAT_DATE_ISO, Locale.getDefault());
Date date;
f.setTimeZone(TimeZone.getTimeZone("UTC")); DateTimeFormatter parser = ISODateTimeFormat.dateTimeParser();
try { DateTime dateTime = DateTime.parse(isoDateString, parser);
date = f.parse(isoDateString); return dateTime.toDate();
return date;
} catch (ParseException e) {
}
f = new SimpleDateFormat(FORMAT_DATE_ISO_MSEC, Locale.getDefault());
f.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
date = f.parse(isoDateString);
return date;
} catch (ParseException e) {
}
f = new SimpleDateFormat(FORMAT_DATE_ISO_MSEC_UTC, Locale.getDefault());
f.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
date = f.parse(isoDateString);
return date;
} catch (ParseException e) {
}
throw new ParseException("Unparseable date: " + isoDateString, 0);
} }
/** /**
@ -79,7 +56,7 @@ public class DateUtil {
* @return the iso-formatted date string * @return the iso-formatted date string
*/ */
public static String toISOString(Date date, String format, TimeZone tz) { public static String toISOString(Date date, String format, TimeZone tz) {
if (format == null) format = FORMAT_DATE_ISO; if (format == null) format = FORMAT_DATE_ISO_OUT;
if (tz == null) tz = TimeZone.getDefault(); if (tz == null) tz = TimeZone.getDefault();
DateFormat f = new SimpleDateFormat(format, Locale.getDefault()); DateFormat f = new SimpleDateFormat(format, Locale.getDefault());
f.setTimeZone(tz); f.setTimeZone(tz);
@ -87,21 +64,18 @@ public class DateUtil {
} }
public static String toISOString(Date date) { public static String toISOString(Date date) {
return toISOString(date, FORMAT_DATE_ISO, TimeZone.getTimeZone("UTC")); return toISOString(date, FORMAT_DATE_ISO_OUT, TimeZone.getTimeZone("UTC"));
} }
public static String toISOString(long date) { public static String toISOString(long date) {
return toISOString(new Date(date), FORMAT_DATE_ISO, TimeZone.getTimeZone("UTC")); return toISOString(new Date(date), FORMAT_DATE_ISO_OUT, TimeZone.getTimeZone("UTC"));
} }
public static Date toDate(Integer seconds) { public static Date toDate(Integer seconds) {
Calendar calendar = new GregorianCalendar(); Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.HOUR_OF_DAY, seconds / 60 / 60); calendar.set(Calendar.HOUR_OF_DAY, seconds / 60 / 60);
String a = calendar.getTime().toString();
calendar.set(Calendar.MINUTE, (seconds / 60) % 60); calendar.set(Calendar.MINUTE, (seconds / 60) % 60);
String b = calendar.getTime().toString();
calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.SECOND, 0);
String c = calendar.getTime().toString();
return calendar.getTime(); return calendar.getTime();
} }

View file

@ -0,0 +1,21 @@
package info.nightscout.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by mike on 22.12.2017.
*/
public class PercentageSplitter {
public static String pureName(String name) {
String newName = name;
String s = "(.*)\\((\\d+)\\%\\)";
Pattern r = Pattern.compile(s);
Matcher m = r.matcher(name);
if (m.find()) {
newName = m.group(1);
}
return newName;
}
}

View file

@ -0,0 +1,67 @@
package info.nightscout.utils;
import android.app.Activity;
import android.content.Context;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 22.12.2017.
*/
public class SingleClickButton extends android.support.v7.widget.AppCompatButton implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(SingleClickButton.class);
Context context;
OnClickListener listener = null;
public SingleClickButton(Context context) {
super(context);
this.context = context;
super.setOnClickListener(this);
}
public SingleClickButton(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
super.setOnClickListener(this);
}
public SingleClickButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
super.setOnClickListener(this);
}
@Override
public void setOnClickListener(@Nullable OnClickListener l) {
listener = l;
}
@Override
public void onClick(final View v) {
setEnabled(false);
new Thread(new Runnable() {
@Override
public void run() {
SystemClock.sleep(3000);
Activity activity = (Activity) context;
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
setEnabled(true);
log.debug("Button enabled");
}
});
}
}).start();
if (listener != null)
listener.onClick(v);
}
}

View file

@ -52,6 +52,8 @@ public class TimeListEdit {
private JSONArray data1; private JSONArray data1;
private JSONArray data2; private JSONArray data2;
private double step; private double step;
private double min;
private double max;
private NumberFormat formatter; private NumberFormat formatter;
private Runnable save; private Runnable save;
private LinearLayout layout; private LinearLayout layout;
@ -59,7 +61,7 @@ public class TimeListEdit {
private int inflatedUntil = -1; private int inflatedUntil = -1;
public TimeListEdit(Context context, View view, int resLayoutId, String label, JSONArray data1, JSONArray data2, double step, NumberFormat formatter, Runnable save) { public TimeListEdit(Context context, View view, int resLayoutId, String label, JSONArray data1, JSONArray data2, double min, double max, double step, NumberFormat formatter, Runnable save) {
this.context = context; this.context = context;
this.view = view; this.view = view;
this.resLayoutId = resLayoutId; this.resLayoutId = resLayoutId;
@ -67,6 +69,8 @@ public class TimeListEdit {
this.data1 = data1; this.data1 = data1;
this.data2 = data2; this.data2 = data2;
this.step = step; this.step = step;
this.min = min;
this.max = max;
this.formatter = formatter; this.formatter = formatter;
this.save = save; this.save = save;
buildView(); buildView();
@ -239,8 +243,8 @@ public class TimeListEdit {
if (i == 0) next = ONEHOURINSECONDS; if (i == 0) next = ONEHOURINSECONDS;
fillSpinner(timeSpinner, secondFromMidnight(i), previous, next); fillSpinner(timeSpinner, secondFromMidnight(i), previous, next);
editText1.setParams(value1(i), 0.1d, 100d, step, formatter, false); editText1.setParams(value1(i), min, max, step, formatter, false);
editText2.setParams(value2(i), 0.1d, 100d, step, formatter, false); editText2.setParams(value2(i), min, max, step, formatter, false);
if (data2 == null) { if (data2 == null) {
editText2.setVisibility(View.GONE); editText2.setVisibility(View.GONE);

View file

@ -13,7 +13,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/actions_profileswitch" android:id="@+id/actions_profileswitch"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -26,7 +26,7 @@
android:drawableTop="@drawable/icon_actions_profileswitch" android:drawableTop="@drawable/icon_actions_profileswitch"
android:text="@string/careportal_profileswitch" /> android:text="@string/careportal_profileswitch" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/actions_temptarget" android:id="@+id/actions_temptarget"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -39,7 +39,7 @@
android:drawableTop="@drawable/icon_actions_temptarget" android:drawableTop="@drawable/icon_actions_temptarget"
android:text="@string/careportal_temporarytarget" /> android:text="@string/careportal_temporarytarget" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/actions_settempbasal" android:id="@+id/actions_settempbasal"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -52,7 +52,7 @@
android:drawableTop="@drawable/icon_actions_starttempbasal" android:drawableTop="@drawable/icon_actions_starttempbasal"
android:text="@string/overview_tempbasal_button" /> android:text="@string/overview_tempbasal_button" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/actions_canceltempbasal" android:id="@+id/actions_canceltempbasal"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -65,7 +65,7 @@
android:drawableTop="@drawable/icon_cancelbasal" android:drawableTop="@drawable/icon_cancelbasal"
android:text="Cancel temp basal" /> android:text="Cancel temp basal" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/actions_extendedbolus" android:id="@+id/actions_extendedbolus"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -78,7 +78,7 @@
android:drawableTop="@drawable/icon_actions_startextbolus" android:drawableTop="@drawable/icon_actions_startextbolus"
android:text="@string/overview_extendedbolus_button" /> android:text="@string/overview_extendedbolus_button" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/actions_extendedbolus_cancel" android:id="@+id/actions_extendedbolus_cancel"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -91,7 +91,7 @@
android:drawableTop="@drawable/icon_actions_cancelextbolus" android:drawableTop="@drawable/icon_actions_cancelextbolus"
android:text="@string/overview_extendedbolus_cancel_button" /> android:text="@string/overview_extendedbolus_cancel_button" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/actions_fill" android:id="@+id/actions_fill"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View file

@ -51,7 +51,7 @@
android:padding="10dip" android:padding="10dip"
app:columnCount="3"> app:columnCount="3">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_bgcheck" android:id="@+id/careportal_bgcheck"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0px" android:layout_width="0px"
@ -66,7 +66,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="0" /> app:layout_row="0" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_exercise" android:id="@+id/careportal_exercise"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -80,7 +80,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="0" /> app:layout_row="0" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_temporarytarget" android:id="@+id/careportal_temporarytarget"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -111,7 +111,7 @@
android:padding="10dip" android:padding="10dip"
app:columnCount="3"> app:columnCount="3">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_snackbolus" android:id="@+id/careportal_snackbolus"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -125,7 +125,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="1" /> app:layout_row="1" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_mealbolus" android:id="@+id/careportal_mealbolus"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -139,7 +139,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="1" /> app:layout_row="1" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_correctionbolus" android:id="@+id/careportal_correctionbolus"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -153,7 +153,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="1" /> app:layout_row="1" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_carbscorrection" android:id="@+id/careportal_carbscorrection"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -167,7 +167,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="2" /> app:layout_row="2" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_combobolus" android:id="@+id/careportal_combobolus"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -181,7 +181,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="2" /> app:layout_row="2" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_tempbasalstart" android:id="@+id/careportal_tempbasalstart"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -195,7 +195,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="2" /> app:layout_row="2" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_tempbasalend" android:id="@+id/careportal_tempbasalend"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -225,7 +225,7 @@
android:padding="10dip" android:padding="10dip"
app:columnCount="3"> app:columnCount="3">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_cgmsensorstart" android:id="@+id/careportal_cgmsensorstart"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -240,7 +240,7 @@
app:layout_row="1" /> app:layout_row="1" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_cgmsensorinsert" android:id="@+id/careportal_cgmsensorinsert"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -255,7 +255,7 @@
app:layout_row="1" /> app:layout_row="1" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_openapsoffline" android:id="@+id/careportal_openapsoffline"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -270,7 +270,7 @@
app:layout_row="1" /> app:layout_row="1" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_announcement" android:id="@+id/careportal_announcement"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -284,7 +284,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="4" /> app:layout_row="4" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_question" android:id="@+id/careportal_question"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -298,7 +298,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="4" /> app:layout_row="4" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_note" android:id="@+id/careportal_note"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -328,7 +328,7 @@
android:padding="10dip" android:padding="10dip"
app:columnCount="3"> app:columnCount="3">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_pumpsitechange" android:id="@+id/careportal_pumpsitechange"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -342,7 +342,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="0" /> app:layout_row="0" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_insulincartridgechange" android:id="@+id/careportal_insulincartridgechange"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -356,7 +356,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="0" /> app:layout_row="0" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_profileswitch" android:id="@+id/careportal_profileswitch"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"
@ -371,7 +371,7 @@
app:layout_row="0" /> app:layout_row="0" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_pumpbatterychange" android:id="@+id/careportal_pumpbatterychange"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="0dp" android:layout_width="0dp"

View file

@ -402,7 +402,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:drawableTop="@drawable/icon_bolus" android:drawableTop="@drawable/icon_danarhistory"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:visibility="gone" android:visibility="gone"

View file

@ -4,70 +4,157 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog"> tools:context="info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog">
<LinearLayout <ScrollView
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:layout_margin="15dp">
<TextView
android:text="@string/overview_editquickwizard_buttontext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:ems="10"
android:id="@+id/overview_editquickwizard_button_edit" />
<TextView
android:text="@string/overview_editquickwizard_carbs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/overview_editquickwizard_carbs_edit" />
<TextView
android:text="@string/overview_editquickwizard_valid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:layout_margin="15dp"
android:orientation="vertical">
<Spinner <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/overview_editquickwizard_from_spinner" android:text="@string/overview_editquickwizard_buttontext"
android:layout_weight="1" /> android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<Spinner <EditText
android:id="@+id/overview_editquickwizard_button_edit"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/overview_editquickwizard_to_spinner" android:ems="10"
android:layout_weight="1" /> android:inputType="text" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_carbs"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<EditText
android:id="@+id/overview_editquickwizard_carbs_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_valid"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Spinner
android:id="@+id/overview_editquickwizard_from_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Spinner
android:id="@+id/overview_editquickwizard_to_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_usebg"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<Spinner
android:id="@+id/overview_editquickwizard_usebg_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/quickWizardUseBGArray" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_usebolusiob"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<Spinner
android:id="@+id/overview_editquickwizard_usebolusiob_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/quickWizardUseBolusIOBArray" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_usebasaliob"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<Spinner
android:id="@+id/overview_editquickwizard_usebasaliob_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/quickWizardUseBasalOBArray" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_usecob"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<Spinner
android:id="@+id/overview_editquickwizard_usecob_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/quickWizardUseCOBArray" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_usetrend"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<Spinner
android:id="@+id/overview_editquickwizard_usetrend_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/quickWizardUseTrendArray" />
<TextView
android:id="@+id/overview_editquickwizard_usesuperbolus_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_usesuperbolus"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<Spinner
android:id="@+id/overview_editquickwizard_usesuperbolus_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/quickWizardUseSuperBolusArray" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/overview_editquickwizard_usetemptarget"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
<Spinner
android:id="@+id/overview_editquickwizard_usetemptarget_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/quickWizardUseTempTargetArray" />
<include layout="@layout/mdtp_done_button" />
</LinearLayout> </LinearLayout>
<Button </ScrollView>
android:text="@string/ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/overview_editquickwizard_ok_button"
android:layout_weight="1" />
</LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -381,7 +381,7 @@
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="gone"> android:visibility="gone">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_accepttempbutton" android:id="@+id/overview_accepttempbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -398,7 +398,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton" android:id="@+id/overview_treatmentbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -413,7 +413,7 @@
android:textSize="10sp" android:textSize="10sp"
android:visibility="gone" /> android:visibility="gone" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton" android:id="@+id/overview_wizardbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -428,7 +428,7 @@
android:textSize="10sp" android:textSize="10sp"
android:visibility="gone" /> android:visibility="gone" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_calibrationbutton" android:id="@+id/overview_calibrationbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -443,7 +443,7 @@
android:textSize="10sp" android:textSize="10sp"
android:visibility="gone" /> android:visibility="gone" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton" android:id="@+id/overview_quickwizardbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"

View file

@ -593,7 +593,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton" android:id="@+id/overview_treatmentbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -607,7 +607,7 @@
android:textColor="@color/colorTreatmentButton" android:textColor="@color/colorTreatmentButton"
android:textSize="10sp" /> android:textSize="10sp" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton" android:id="@+id/overview_wizardbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -622,7 +622,7 @@
android:textSize="10sp" android:textSize="10sp"
android:visibility="gone" /> android:visibility="gone" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton" android:id="@+id/overview_quickwizardbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"

View file

@ -691,7 +691,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton" android:id="@+id/overview_treatmentbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -705,7 +705,7 @@
android:textColor="@color/colorTreatmentButton" android:textColor="@color/colorTreatmentButton"
android:textSize="10sp" /> android:textSize="10sp" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton" android:id="@+id/overview_wizardbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -720,7 +720,7 @@
android:textSize="10sp" android:textSize="10sp"
android:visibility="gone" /> android:visibility="gone" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_calibrationbutton" android:id="@+id/overview_calibrationbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -735,7 +735,7 @@
android:textSize="10sp" android:textSize="10sp"
android:visibility="gone" /> android:visibility="gone" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton" android:id="@+id/overview_quickwizardbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"

View file

@ -360,7 +360,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_accepttempbutton" android:id="@+id/overview_accepttempbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -377,7 +377,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton" android:id="@+id/overview_treatmentbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -391,7 +391,7 @@
android:textColor="@color/colorTreatmentButton" android:textColor="@color/colorTreatmentButton"
android:textSize="10sp" /> android:textSize="10sp" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton" android:id="@+id/overview_wizardbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -406,7 +406,7 @@
android:textSize="10sp" android:textSize="10sp"
android:visibility="gone" /> android:visibility="gone" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_calibrationbutton" android:id="@+id/overview_calibrationbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"
@ -421,7 +421,7 @@
android:textSize="10sp" android:textSize="10sp"
android:visibility="gone" /> android:visibility="gone" />
<Button <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton" android:id="@+id/overview_quickwizardbutton"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"
android:layout_width="0px" android:layout_width="0px"

View file

@ -8,6 +8,14 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="10dp"> android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingBottom="10dp"
android:text="@string/virtualpump_extendedbolus_label"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout <LinearLayout
android:id="@+id/careportal_newnstreatment_insulin_layout" android:id="@+id/careportal_newnstreatment_insulin_layout"
android:layout_width="match_parent" android:layout_width="match_parent"

File diff suppressed because it is too large Load diff

View file

@ -59,4 +59,43 @@
<item>2</item> <item>2</item>
</string-array> </string-array>
<string-array name="quickWizardUseBGArray">
<item>@string/yes</item>
<item>@string/no</item>
</string-array>
<string-array name="quickWizardUseCOBArray">
<item>@string/yes</item>
<item>@string/no</item>
</string-array>
<string-array name="quickWizardUseBolusIOBArray">
<item>@string/yes</item>
<item>@string/no</item>
</string-array>
<string-array name="quickWizardUseBasalOBArray">
<item>@string/yes</item>
<item>@string/no</item>
<item>@string/positiveonly</item>
<item>@string/negativeonly</item>
</string-array>
<string-array name="quickWizardUseTrendArray">
<item>@string/no</item>
<item>@string/yes</item>
<item>@string/positiveonly</item>
<item>@string/negativeonly</item>
</string-array>
<string-array name="quickWizardUseSuperBolusArray">
<item>@string/no</item>
<item>@string/yes</item>
</string-array>
<string-array name="quickWizardUseTempTargetArray">
<item>@string/no</item>
<item>@string/yes</item>
</string-array>
</resources> </resources>

View file

@ -316,6 +316,7 @@
<string name="objectives_5_objective">Adjust basals and ratios if needed, and then enable auto-sens</string> <string name="objectives_5_objective">Adjust basals and ratios if needed, and then enable auto-sens</string>
<string name="objectives_5_gate">1 week successful daytime looping with regular carb entry</string> <string name="objectives_5_gate">1 week successful daytime looping with regular carb entry</string>
<string name="objectives_6_objective">Enabling additional features for daytime use, such as advanced meal assist</string> <string name="objectives_6_objective">Enabling additional features for daytime use, such as advanced meal assist</string>
<string name="objectives_7_objective">Enabling additional features for daytime use, such as SMB</string>
<string name="youareonallowedlimit">You reached allowed limit</string> <string name="youareonallowedlimit">You reached allowed limit</string>
<string name="noprofileselected">No profile selected</string> <string name="noprofileselected">No profile selected</string>
<string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string> <string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string>
@ -682,7 +683,6 @@
<string name="wear_overviewnotifications">Overview Notifications</string> <string name="wear_overviewnotifications">Overview Notifications</string>
<string name="wear_overviewnotifications_summary">Pass the Overview Notifications through as wear confirmation messages.</string> <string name="wear_overviewnotifications_summary">Pass the Overview Notifications through as wear confirmation messages.</string>
<string name="combopump" translatable="false">Accu-Chek Combo</string> <string name="combopump" translatable="false">Accu-Chek Combo</string>
<string name="combopump_settings">Accu-Chek Combo settings</string>
<string name="combopump_shortname" translatable="false">COMBO</string> <string name="combopump_shortname" translatable="false">COMBO</string>
<string name="ns_localbroadcasts">Enable broadcasts to other apps (like xDrip).</string> <string name="ns_localbroadcasts">Enable broadcasts to other apps (like xDrip).</string>
<string name="ns_localbroadcasts_title">Enable local Broadcasts.</string> <string name="ns_localbroadcasts_title">Enable local Broadcasts.</string>
@ -791,6 +791,23 @@
<string name="key_dexcomg5_xdripupload" translatable="false">dexcomg5_xdripupload</string> <string name="key_dexcomg5_xdripupload" translatable="false">dexcomg5_xdripupload</string>
<string name="dexcomg5_xdripupload_summary">In xDrip+ select 640g/Eversense data source</string> <string name="dexcomg5_xdripupload_summary">In xDrip+ select 640g/Eversense data source</string>
<string name="nsclientbg">NSClient BG</string> <string name="nsclientbg">NSClient BG</string>
<string name="minimalbasalvaluereplaced">Basal value replaced by minimal supported value</string>
<string name="overview_editquickwizard_usebg">BG calculation</string>
<string name="overview_editquickwizard_usebolusiob">Bolus IOB calculation</string>
<string name="overview_editquickwizard_usebasaliob">Basal IOB calculation</string>
<string name="overview_editquickwizard_usetrend">Trend calculation</string>
<string name="overview_editquickwizard_usesuperbolus">Superbolus calculation</string>
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="positiveonly">Positive only</string>
<string name="negativeonly">Negative only</string>
<string name="overview_editquickwizard_usecob">COB calculation</string>
<string name="overview_editquickwizard_usetemptarget">Temporary target calculation</string>
<string name="loopenabled">Loop enabled</string>
<string name="apsselected">APS selected</string>
<string name="nsclienthaswritepermission">NSClient has write permission</string>
<string name="closedmodeenabled">Closed mode enabled</string>
<string name="maxiobset">Maximal IOB set properly</string>
<string name="bolusstopping">Stopping bolus delivery</string> <string name="bolusstopping">Stopping bolus delivery</string>
<string name="bolusstopped">Bolus delivery stopped</string> <string name="bolusstopped">Bolus delivery stopped</string>
<string name="combo_programming_bolus">Programming pump for bolusing</string> <string name="combo_programming_bolus">Programming pump for bolusing</string>
@ -799,7 +816,6 @@
<string name="combo_pump_state_label">State</string> <string name="combo_pump_state_label">State</string>
<string name="combo_pump_activity_label">Activity</string> <string name="combo_pump_activity_label">Activity</string>
<string name="combo_no_pump_connection">No connection for %d min</string> <string name="combo_no_pump_connection">No connection for %d min</string>
<string name="combo_last_connection_time">%s</string>
<string name="combo_tbr_remaining">%d%% (%d min remaining)</string> <string name="combo_tbr_remaining">%d%% (%d min remaining)</string>
<string name="combo_last_bolus">%.1f U (%s, %s)</string> <string name="combo_last_bolus">%.1f U (%s, %s)</string>
<string name="combo_pump_action_initializing">Initializing</string> <string name="combo_pump_action_initializing">Initializing</string>
@ -807,7 +823,6 @@
<string name="combo_pump_state_suspended_due_to_error">Suspended due to error</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_suspended_by_user">Suspended by user</string>
<string name="combo_pump_state_running">Running</string> <string name="combo_pump_state_running">Running</string>
<string name="combo_pump_action_checking_history">Checking pump history</string>
<string name="combo_pump_action_cancelling_tbr">Cancelling TBR</string> <string name="combo_pump_action_cancelling_tbr">Cancelling TBR</string>
<string name="combo_pump_action_setting_tbr">Setting TBR (%d%% / %d min)</string> <string name="combo_pump_action_setting_tbr">Setting TBR (%d%% / %d min)</string>
<string name="combo_pump_action_bolusing">Bolusing (%.1f U)</string> <string name="combo_pump_action_bolusing">Bolusing (%.1f U)</string>
@ -816,7 +831,8 @@
<string name="raise_urgent_alarms_as_android_notification">Use system notifications for alerts</string> <string name="raise_urgent_alarms_as_android_notification">Use system notifications for alerts</string>
<string name="combo_pump_never_connected">Never</string> <string name="combo_pump_never_connected">Never</string>
<string name="combo_pump_unsupported_operation">Requested operation not supported by pump</string> <string name="combo_pump_unsupported_operation">Requested operation not supported by pump</string>
<string name="combo_force_disabled_notification">Unsafe usage: extended or multiwave boluses have been delivered within the last 6 hours or the selected basal rate is not 1. Loop mode has been set to low-suspend only until 6 hours after the last unsupported bolus or basal rate profile. Only normal boluses are supported in loop mode with basal rate profile 1.</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 minute. To prevent accidental double boluses and to guard against bugs this is disallowed.</string> <string name="bolus_frequency_exceeded">A bolus with the same amount was requested within the last minute. 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_pump_connected_now">Now</string>
<string name="combo_activity_reading_pump_history">Reading pump history</string> <string name="combo_activity_reading_pump_history">Reading pump history</string>
@ -825,7 +841,7 @@
<string name="combo_activity_setting_basal_profile">Setting basal profile</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_cartridge_low_warrning">Pump cartridge level is low</string>
<string name="combo_pump_battery_low_warrning">Pump battery is low</string> <string name="combo_pump_battery_low_warrning">Pump battery is low</string>
<string name="combo_is_in_error_state">Pump is in an error state, please check the pump</string> <string name="combo_is_in_error_state">The pump is showing the error E%d: %s</string>
<string name="combo_no_alert_data_note">To read the pump\'s error history, long press the ALERTS button\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided.</string> <string name="combo_no_alert_data_note">To read the pump\'s error history, long press the ALERTS button\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided.</string>
<string name="combo_no_tdd_data_note">To read the pump\'s TDD history, long press the TDDS button\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided.</string> <string name="combo_no_tdd_data_note">To read the pump\'s TDD history, long press the TDDS button\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided.</string>
<string name="key_sync_profile_to_pump">sync_profile_to_pump</string> <string name="key_sync_profile_to_pump">sync_profile_to_pump</string>
@ -843,7 +859,6 @@
<string name="combo_pump_tbr_cancelled_warrning">TBR CANCELLED warning was confirmed</string> <string name="combo_pump_tbr_cancelled_warrning">TBR CANCELLED warning was confirmed</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_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 %.2f U of the requested bolus of %.2f U was delivered due to an error. Please check the pump to verify this and take appropriate actions.</string> <string name="combo_error_partial_bolus_delivered">Only %.2f U of the requested bolus of %.2f U was delivered due to an error. Please check the pump to verify this and take appropriate actions.</string>
<string name="combo_activity_verifying_delivered_bolus">Verifying delivered bolus</string>
<string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump and manually create a bolus record using the Careportal tab if a bolus was delivered.</string> <string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump and manually create a bolus record using the Careportal tab if a bolus was delivered.</string>
<string name="combo_error_bolus_recovery_progress">Recovering from connection loss</string> <string name="combo_error_bolus_recovery_progress">Recovering from connection loss</string>
</resources> </resources>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="combopump"
android:title="@string/combopump_settings">
</PreferenceCategory>
</PreferenceScreen>

View file

@ -3,7 +3,9 @@ package info.nightscout.utils;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import java.util.Date;
import static org.junit.Assert.assertEquals;
/** /**
* Created by mike on 20.11.2017. * Created by mike on 20.11.2017.
@ -17,10 +19,15 @@ public class DateUtilTest {
@Test @Test
public void fromISODateStringTest() throws Exception { public void fromISODateStringTest() throws Exception {
assertEquals( 1511124634417L, DateUtil.fromISODateString("2017-11-19T22:50:34.417+0200").getTime()); assertEquals(1511124634417L, DateUtil.fromISODateString("2017-11-19T22:50:34.417+0200").getTime());
assertEquals( 1511124634000L, DateUtil.fromISODateString("2017-11-19T22:50:34+0200").getTime()); assertEquals(1511124634000L, DateUtil.fromISODateString("2017-11-19T22:50:34+0200").getTime());
assertEquals( 1512317365000L, DateUtil.fromISODateString("2017-12-03T16:09:25.000Z").getTime()); assertEquals(1512317365000L, DateUtil.fromISODateString("2017-12-03T16:09:25.000Z").getTime());
assertEquals(1513902750000L, DateUtil.fromISODateString("2017-12-22T00:32:30Z").getTime());
} }
@Test
public void toISOStringTest() throws Exception {
assertEquals("2017-12-22T00:32:30Z", DateUtil.toISOString(new Date(1513902750000L)));
}
} }

View file

@ -0,0 +1,20 @@
package info.nightscout.utils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by mike on 22.12.2017.
*/
public class PercentageSplitterTest {
public PercentageSplitterTest() {
super();
}
@Test
public void pureNameTest() throws Exception {
assertEquals("Fiasp", PercentageSplitter.pureName("Fiasp(101%)"));
}
}

View file

@ -1,10 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.jotomo.ruffy"> package="de.jotomo.ruffy">
<!--<application android:allowBackup="true" android:label="ruffy-spi"-->
<!--android:supportsRtl="true">-->
<!--</application>-->
</manifest> </manifest>

View file

@ -7,8 +7,7 @@ public interface BolusProgressReporter {
DELIVERED, DELIVERED,
STOPPING, STOPPING,
STOPPED, STOPPED,
RECOVERING, RECOVERING
FINISHED
} }
void report(State state, int percent, double delivered); void report(State state, int percent, double delivered);

View file

@ -30,8 +30,12 @@ public class PumpState {
public int insulinState = UNKNOWN; public int insulinState = UNKNOWN;
public int activeBasalProfileNumber; public int activeBasalProfileNumber;
public static final int SAFE_USAGE = 0;
public static final int UNSUPPORTED_BOLUS_TYPE = 1;
public static final int UNSUPPORTED_BASAL_RATE_PROFILE = 2;
/** True if use of an extended or multiwave bolus has been detected */ /** True if use of an extended or multiwave bolus has been detected */
public boolean unsafeUsageDetected; public int unsafeUsageDetected = SAFE_USAGE;
public PumpState menu(String menu) { public PumpState menu(String menu) {
this.menu = menu; this.menu = menu;

View file

@ -501,8 +501,10 @@ public class RuffyScripter implements RuffyCommands {
BolusType bolusType = (BolusType) menu.getAttribute(MenuAttribute.BOLUS_TYPE); BolusType bolusType = (BolusType) menu.getAttribute(MenuAttribute.BOLUS_TYPE);
Integer activeBasalRate = (Integer) menu.getAttribute(MenuAttribute.BASAL_SELECTED); Integer activeBasalRate = (Integer) menu.getAttribute(MenuAttribute.BASAL_SELECTED);
if (bolusType != null && bolusType != BolusType.NORMAL || !activeBasalRate.equals(1)) { if (!activeBasalRate.equals(1)) {
state.unsafeUsageDetected = true; state.unsafeUsageDetected = PumpState.UNSUPPORTED_BASAL_RATE_PROFILE;
} else if (bolusType != null && bolusType != BolusType.NORMAL) {
state.unsafeUsageDetected = PumpState.UNSUPPORTED_BOLUS_TYPE;
} else if (tbrPercentage != null && tbrPercentage != 100) { } else if (tbrPercentage != null && tbrPercentage != 100) {
state.tbrActive = true; state.tbrActive = true;
Double displayedTbr = (Double) menu.getAttribute(MenuAttribute.TBR); Double displayedTbr = (Double) menu.getAttribute(MenuAttribute.TBR);
@ -518,10 +520,16 @@ public class RuffyScripter implements RuffyCommands {
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE)); state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
} }
if (menu.attributes().contains(MenuAttribute.TIME)) { if (menu.attributes().contains(MenuAttribute.TIME)) {
MenuTime time = (MenuTime) menu.getAttribute(MenuAttribute.TIME); MenuTime pumpTime = (MenuTime) menu.getAttribute(MenuAttribute.TIME);
Date date = new Date(); Date date = new Date();
date.setHours(time.getHour()); // infer yesterday as the pump's date if midnight just passed, but the pump is
date.setMinutes(time.getMinute()); // a bit behind
if (date.getHours() == 0 && date.getMinutes() <= 5
&& pumpTime.getHour() == 23 && pumpTime.getMinute() >= 55) {
date.setTime(date.getTime() - 24 * 60 * 60 * 1000);
}
date.setHours(pumpTime.getHour());
date.setMinutes(pumpTime.getMinute());
date.setSeconds(0); date.setSeconds(0);
state.pumpTime = date.getTime() - date.getTime() % 1000; state.pumpTime = date.getTime() - date.getTime() % 1000;
} }

View file

@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffy.spi.BasalProfile;
import de.jotomo.ruffy.spi.PumpState;
public class ReadBasalProfileCommand extends BaseCommand { public class ReadBasalProfileCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(ReadBasalProfileCommand.class); private static final Logger log = LoggerFactory.getLogger(ReadBasalProfileCommand.class);
@ -17,6 +18,9 @@ public class ReadBasalProfileCommand extends BaseCommand {
@Override @Override
public void execute() { public void execute() {
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
if (scripter.readPumpStateInternal().unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
throw new CommandException("Active basal rate profile != 1");
}
scripter.navigateToMenu(MenuType.BASAL_1_MENU); scripter.navigateToMenu(MenuType.BASAL_1_MENU);
scripter.verifyMenuIsDisplayed(MenuType.BASAL_1_MENU); scripter.verifyMenuIsDisplayed(MenuType.BASAL_1_MENU);
scripter.pressCheckKey(); scripter.pressCheckKey();

View file

@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffy.spi.BasalProfile;
import de.jotomo.ruffy.spi.PumpState;
public class SetBasalProfileCommand extends BaseCommand { public class SetBasalProfileCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(SetBasalProfileCommand.class); private static final Logger log = LoggerFactory.getLogger(SetBasalProfileCommand.class);
@ -26,6 +27,9 @@ public class SetBasalProfileCommand extends BaseCommand {
@Override @Override
public void execute() { public void execute() {
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU); scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
if (scripter.readPumpStateInternal().unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
throw new CommandException("Active basal rate profile != 1");
}
scripter.navigateToMenu(MenuType.BASAL_1_MENU); scripter.navigateToMenu(MenuType.BASAL_1_MENU);
scripter.verifyMenuIsDisplayed(MenuType.BASAL_1_MENU); scripter.verifyMenuIsDisplayed(MenuType.BASAL_1_MENU);
scripter.pressCheckKey(); scripter.pressCheckKey();

View file

@ -61,7 +61,8 @@ allprojects {
dependencies { dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
//compile 'com.ustwo.android:clockwise-wearable:1.0.2' //compile 'com.ustwo.android:clockwise-wearable:1.0.2'
compile 'com.google.android.support:wearable:1.4.0' provided 'com.google.android.wearable:wearable:2.0.1'
compile 'com.google.android.support:wearable:2.0.1'
compile 'com.google.android.gms:play-services-wearable:7.3.0' compile 'com.google.android.gms:play-services-wearable:7.3.0'
compile files('libs/hellocharts-library-1.5.5.jar') compile files('libs/hellocharts-library-1.5.5.jar')
compile(name:'ustwo-clockwise-debug', ext:'aar') compile(name:'ustwo-clockwise-debug', ext:'aar')

View file

@ -257,7 +257,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
if (layoutSet && bundle != null) { if (layoutSet && bundle != null) {
DataMap dataMap = DataMap.fromBundle(bundle); DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(50); wakeLock.acquire(50);
sBasalRate = dataMap.getString("tempBasal"); sBasalRate = dataMap.getString("currentBasal");
sUploaderBattery = dataMap.getString("battery"); sUploaderBattery = dataMap.getString("battery");
sRigBattery = dataMap.getString("rigBattery"); sRigBattery = dataMap.getString("rigBattery");
detailedIOB = dataMap.getBoolean("detailedIob"); detailedIOB = dataMap.getBoolean("detailedIob");