return functionality of faking by extended boluses

This commit is contained in:
Milos Kozak 2017-05-25 17:26:05 +02:00
parent 86af9eab3d
commit 87993c6163
20 changed files with 130 additions and 88 deletions

View file

@ -53,7 +53,7 @@ import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpFragment;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.TreatmentsFromHistoryFragment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
import info.nightscout.androidaps.plugins.Wear.WearFragment;
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslineFragment;
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
@ -110,7 +110,7 @@ public class MainApp extends Application {
if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
if (Config.OTHERPROFILES)
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
pluginsList.add(TreatmentsFromHistoryFragment.getPlugin());
pluginsList.add(TreatmentsFragment.getPlugin());
if (Config.SAFETY) pluginsList.add(SafetyFragment.getPlugin());
if (Config.APS) pluginsList.add(ObjectivesFragment.getPlugin());
pluginsList.add(SourceXdripFragment.getPlugin());

View file

@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.interfaces.InsulinInterface;
@ -48,13 +49,16 @@ public class TemporaryBasal implements Interval {
public TemporaryBasal() {}
public TemporaryBasal(ExtendedBolus extendedBolus) {
double basal = 0d;
if (ConfigBuilderPlugin.getActiveProfile() != null && ConfigBuilderPlugin.getActiveProfile().getProfile() != null)
basal = ConfigBuilderPlugin.getActiveProfile().getProfile().getBasal(NSProfile.secondsFromMidnight(extendedBolus.date));
this.date = extendedBolus.date;
this.isValid = extendedBolus.isValid;
this.source = extendedBolus.source;
this._id = extendedBolus._id;
this.durationInMinutes = extendedBolus.durationInMinutes;
this.isAbsolute = true;
this.absoluteRate = extendedBolus.absoluteRate();
this.absoluteRate = basal + extendedBolus.absoluteRate();
}
// -------- Interval interface ---------

View file

@ -50,4 +50,6 @@ public interface PumpInterface {
// Enforced Treatment plugin
String treatmentPlugin();
boolean isFakingTempsByExtendedBoluses();
}

View file

@ -709,6 +709,11 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
}
@Override
public boolean isFakingTempsByExtendedBoluses() {
return activePump.isFakingTempsByExtendedBoluses();
}
/**
* Constraints interface
**/

View file

@ -4,9 +4,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import com.squareup.otto.Subscribe;
@ -43,10 +41,11 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.TreatmentsFromHistoryPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round;
import info.nightscout.utils.SP;
/**
* Created by mike on 05.08.2016.
@ -76,8 +75,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
public DanaRPlugin() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false);
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRExecutionService.class);
@ -135,8 +133,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
public void onStatusEvent(final EventPreferenceChange s) {
if (isEnabled(PUMP)) {
boolean previousValue = useExtendedBoluses;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false);
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
pumpDescription.highTempBasalStyle = useExtendedBoluses ? PumpDescription.EXTENDED : PumpDescription.PERCENT;
@ -221,7 +218,12 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override
public String treatmentPlugin() {
return TreatmentsFromHistoryPlugin.class.getName();
return TreatmentsPlugin.class.getName();
}
@Override
public boolean isFakingTempsByExtendedBoluses() {
return useExtendedBoluses;
}
@Override
@ -366,7 +368,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return cancelExtendedBolus();
}
// If temp in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal();
@ -399,7 +401,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
}
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
// Correct basal already set ?
if (MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).percentRate == percentRate) {
result.success = true;
@ -430,7 +432,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
if (doExtendedTemp) {
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal();
@ -581,9 +583,9 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override
public PumpEnactResult cancelTempBasal() {
if (MainApp.getConfigBuilder().isTempBasalInProgress())
if (MainApp.getConfigBuilder().isRealTempBasalInProgress())
return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress())
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses)
return cancelExtendedBolus();
PumpEnactResult result = new PumpEnactResult();
result.success = true;
@ -671,7 +673,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
extended.put("PumpIOB", getDanaRPump().iob);
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime());
if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
@ -804,7 +806,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
ret += "LastBolus: " + DecimalFormatter.to2Decimal(getDanaRPump().lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", getDanaRPump().lastBolusTime) + "\n";
}
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString() + "\n";
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString() + "\n";
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString() + "\n";

View file

@ -62,8 +62,8 @@ public class MsgStatusTempBasal extends MessageBase {
DanaRPump danaRPump = DanaRPump.getInstance();
long now = new Date().getTime();
if (treatmentsInterface.isTempBasalInProgress()) {
TemporaryBasal tempBasal = treatmentsInterface.getTempBasal(new Date().getTime());
if (treatmentsInterface.isRealTempBasalInProgress()) {
TemporaryBasal tempBasal = treatmentsInterface.getRealTempBasal(new Date().getTime());
if (danaRPump.isTempBasalInProgress) {
if (tempBasal.percentRate != danaRPump.tempBasalPercent) {
// Close current temp basal

View file

@ -4,9 +4,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import com.squareup.otto.Subscribe;
@ -44,10 +42,11 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.TreatmentsFromHistoryPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round;
import info.nightscout.utils.SP;
/**
* Created by mike on 05.08.2016.
@ -75,8 +74,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
String textStatus = "";
public DanaRKoreanPlugin() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false);
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRKoreanExecutionService.class);
@ -134,8 +132,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
public void onStatusEvent(final EventPreferenceChange s) {
if (isEnabled(PUMP)) {
boolean previousValue = useExtendedBoluses;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false);
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
pumpDescription.highTempBasalStyle = useExtendedBoluses ? PumpDescription.EXTENDED : PumpDescription.PERCENT;
@ -220,7 +217,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
@Override
public String treatmentPlugin() {
return TreatmentsFromHistoryPlugin.class.getName();
return TreatmentsPlugin.class.getName();
}
@Override
public boolean isFakingTempsByExtendedBoluses() {
return useExtendedBoluses;
}
@Override
@ -378,7 +380,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
return cancelExtendedBolus();
}
// If temp in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal();
@ -411,9 +413,9 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
}
}
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
// Correct basal already set ?
if (MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).percentRate == percentRate) {
if (MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).percentRate == percentRate) {
result.success = true;
result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate();
@ -442,7 +444,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
}
if (doExtendedTemp) {
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal();
@ -594,9 +596,9 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
@Override
public PumpEnactResult cancelTempBasal() {
if (MainApp.getConfigBuilder().isTempBasalInProgress())
if (MainApp.getConfigBuilder().isRealTempBasalInProgress())
return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress())
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses)
return cancelExtendedBolus();
PumpEnactResult result = new PumpEnactResult();
result.success = true;
@ -684,7 +686,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
extended.put("PumpIOB", pump.iob);
// extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
// extended.put("LastBolusAmount", pump.lastBolusAmount);
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime());
if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
@ -817,7 +819,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
// ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
// }
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString() + "\n";
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString() + "\n";
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString() + "\n";

View file

@ -43,7 +43,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.TreatmentsFromHistoryPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round;
@ -204,7 +204,12 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
@Override
public String treatmentPlugin() {
return TreatmentsFromHistoryPlugin.class.getName();
return TreatmentsPlugin.class.getName();
}
@Override
public boolean isFakingTempsByExtendedBoluses() {
return false;
}
@Override

View file

@ -19,7 +19,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.TreatmentsFromHistoryPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
/**
@ -119,7 +119,12 @@ public class MDIPlugin implements PluginBase, PumpInterface {
@Override
public String treatmentPlugin() {
return TreatmentsFromHistoryPlugin.class.getName();
return TreatmentsPlugin.class.getName();
}
@Override
public boolean isFakingTempsByExtendedBoluses() {
return false;
}
@Override

View file

@ -27,7 +27,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.TreatmentsFromHistoryPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
/**
@ -139,7 +139,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public String treatmentPlugin() {
return TreatmentsFromHistoryPlugin.class.getName();
return TreatmentsPlugin.class.getName();
}
@Override
public boolean isFakingTempsByExtendedBoluses() {
return false;
}
@Override

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.TreatmentsFromHistory;
package info.nightscout.androidaps.plugins.Treatments;
import android.content.Context;
import android.os.Bundle;
@ -13,17 +13,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments.TreatmentsBolusFragment;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments.TreatmentsExtendedBolusesFragment;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments.TreatmentsTempTargetFragment;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments.TreatmentsTemporaryBasalsFragment;
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsBolusFragment;
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsExtendedBolusesFragment;
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTempTargetFragment;
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTemporaryBasalsFragment;
public class TreatmentsFromHistoryFragment extends Fragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(TreatmentsFromHistoryFragment.class);
public class TreatmentsFragment extends Fragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
private static TreatmentsFromHistoryPlugin treatmentsPlugin = new TreatmentsFromHistoryPlugin();
private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin();
public static TreatmentsFromHistoryPlugin getPlugin() {
public static TreatmentsPlugin getPlugin() {
return treatmentsPlugin;
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.TreatmentsFromHistory;
package info.nightscout.androidaps.plugins.Treatments;
import android.support.annotation.Nullable;
@ -38,8 +38,8 @@ import info.nightscout.utils.SP;
/**
* Created by mike on 05.08.2016.
*/
public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterface {
private static Logger log = LoggerFactory.getLogger(TreatmentsFromHistoryPlugin.class);
public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
private static Logger log = LoggerFactory.getLogger(TreatmentsPlugin.class);
public static IobTotal lastTreatmentCalculation;
public static IobTotal lastTempBasalsCalculation;
@ -52,20 +52,20 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
private static boolean fragmentEnabled = true;
private static boolean fragmentVisible = true;
private static TreatmentsFromHistoryPlugin treatmentsPlugin = new TreatmentsFromHistoryPlugin();
private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin();
public static TreatmentsFromHistoryPlugin getPlugin() {
public static TreatmentsPlugin getPlugin() {
return treatmentsPlugin;
}
@Override
public String getFragmentClass() {
return TreatmentsFromHistoryFragment.class.getName();
return TreatmentsFragment.class.getName();
}
@Override
public String getName() {
return MainApp.instance().getString(R.string.treatments) + "FromHistory"; // TODO: remove later
return MainApp.instance().getString(R.string.treatments);
}
@Override
@ -121,7 +121,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
return PluginBase.TREATMENT;
}
public TreatmentsFromHistoryPlugin() {
public TreatmentsPlugin() {
MainApp.bus().register(this);
initializeTempBasalData();
initializeTreatmentData();
@ -129,7 +129,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
initializeTempTargetData();
}
public static void initializeTreatmentData() {
public static void initializeTreatmentData() {
// Treatments
double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder().getActiveProfile() != null && MainApp.getConfigBuilder().getActiveProfile().getProfile() != null)
@ -139,7 +139,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false);
}
public static void initializeTempBasalData() {
public static void initializeTempBasalData() {
// Treatments
double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder().getActiveProfile() != null && MainApp.getConfigBuilder().getActiveProfile().getProfile() != null)
@ -150,7 +150,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
}
public static void initializeExtendedBolusData() {
public static void initializeExtendedBolusData() {
// Treatments
double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder().getActiveProfile() != null && MainApp.getConfigBuilder().getActiveProfile().getProfile() != null)
@ -193,12 +193,13 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
total.bolussnooze += bIOB.iobContrib;
}
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
ExtendedBolus e = extendedBoluses.get(pos);
if (e.date > time) continue;
IobTotal calc = e.iobCalc(time);
total.plus(calc);
}
if (!MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
ExtendedBolus e = extendedBoluses.get(pos);
if (e.date > time) continue;
IobTotal calc = e.iobCalc(time);
total.plus(calc);
}
return total;
}
@ -256,12 +257,12 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
@Override
public boolean isRealTempBasalInProgress() {
return false;
return getRealTempBasal(new Date().getTime()) != null;
}
@Override
public TemporaryBasal getRealTempBasal(long time) {
return null;
return (TemporaryBasal) tempBasals.getValueByInterval(time);
}
@Override
@ -307,6 +308,13 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
total.plus(calc);
}
if (MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
ExtendedBolus e = extendedBoluses.get(pos);
if (e.date > time) continue;
IobTotal calc = e.iobCalc(time);
total.plus(calc);
}
return total;
}
@ -320,7 +328,13 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
@Nullable
@Override
public TemporaryBasal getTempBasal(long time) {
return (TemporaryBasal) tempBasals.getValueByInterval(time);
TemporaryBasal tb = getRealTempBasal(time);
if (tb != null)
return tb;
ExtendedBolus eb = getExtendedBolus(time);
if (eb != null && MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
return new TemporaryBasal(eb);
return null;
}
@Override

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments;
package info.nightscout.androidaps.plugins.Treatments.fragments;
import android.app.Activity;
import android.content.Context;
@ -37,11 +37,10 @@ import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.TreatmentsFromHistory.TreatmentsFromHistoryPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
public class TreatmentsBolusFragment extends Fragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(TreatmentsBolusFragment.class);
@ -161,7 +160,7 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsFromHistoryPlugin.treatments);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.treatments);
recyclerView.setAdapter(adapter);
iobTotal = (TextView) view.findViewById(R.id.treatments_iobtotal);
@ -232,11 +231,11 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsFromHistoryPlugin.treatments), false);
if (TreatmentsFromHistoryPlugin.lastTreatmentCalculation != null)
iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsFromHistoryPlugin.lastTreatmentCalculation.iob) + " U");
if (TreatmentsFromHistoryPlugin.lastTreatmentCalculation != null)
activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsFromHistoryPlugin.lastTreatmentCalculation.activity) + " U");
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.treatments), false);
if (TreatmentsPlugin.lastTreatmentCalculation != null)
iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.lastTreatmentCalculation.iob) + " U");
if (TreatmentsPlugin.lastTreatmentCalculation != null)
activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.lastTreatmentCalculation.activity) + " U");
}
});
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments;
package info.nightscout.androidaps.plugins.Treatments.fragments;
import android.app.Activity;
import android.content.Context;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments;
package info.nightscout.androidaps.plugins.Treatments.fragments;
import android.app.Activity;
import android.content.Context;
@ -16,7 +16,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.squareup.otto.Subscribe;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments;
package info.nightscout.androidaps.plugins.Treatments.fragments;
import android.app.Activity;
import android.content.Context;

View file

@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".plugins.TreatmentsFromHistory.fragments.TreatmentsBolusFragment">
tools:context=".plugins.Treatments.fragments.TreatmentsBolusFragment">
<LinearLayout
android:layout_width="match_parent"

View file

@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments.TreatmentsExtendedBolusesFragment">
tools:context="info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsExtendedBolusesFragment">
<LinearLayout
android:layout_width="match_parent"

View file

@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments.TreatmentsTemporaryBasalsFragment">
tools:context="info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTemporaryBasalsFragment">
<LinearLayout
android:layout_width="match_parent"

View file

@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.nightscout.androidaps.plugins.TreatmentsFromHistory.fragments.TreatmentsTempTargetFragment">
tools:context="info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTempTargetFragment">
<LinearLayout
android:layout_width="match_parent"