commit
5b17eee586
33 changed files with 74 additions and 95 deletions
|
@ -263,8 +263,6 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static InsulinInterface getInsulinIterfaceById(int id) {
|
public static InsulinInterface getInsulinIterfaceById(int id) {
|
||||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
|
||||||
|
|
||||||
if (pluginsList != null) {
|
if (pluginsList != null) {
|
||||||
for (PluginBase p : pluginsList) {
|
for (PluginBase p : pluginsList) {
|
||||||
if (p.getType() == PluginBase.INSULIN && ((InsulinInterface) p).getId() == id)
|
if (p.getType() == PluginBase.INSULIN && ((InsulinInterface) p).getId() == id)
|
||||||
|
@ -321,11 +319,11 @@ public class MainApp extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static PluginBase getSpecificPlugin(Class pluginClass) {
|
public static <T extends PluginBase> T getSpecificPlugin(Class<T> pluginClass) {
|
||||||
if (pluginsList != null) {
|
if (pluginsList != null) {
|
||||||
for (PluginBase p : pluginsList) {
|
for (PluginBase p : pluginsList) {
|
||||||
if (p.getClass() == pluginClass)
|
if (pluginClass.isAssignableFrom(p.getClass()))
|
||||||
return p;
|
return (T) p;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("pluginsList=null");
|
log.error("pluginsList=null");
|
||||||
|
|
|
@ -123,9 +123,9 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResource(R.xml.pref_profile);
|
addPreferencesFromResource(R.xml.pref_profile);
|
||||||
}
|
}
|
||||||
if (Config.DANAR) {
|
if (Config.DANAR) {
|
||||||
DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
DanaRPlugin danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||||
DanaRKoreanPlugin danaRKoreanPlugin = (DanaRKoreanPlugin) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
DanaRKoreanPlugin danaRKoreanPlugin = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||||
DanaRv2Plugin danaRv2Plugin = (DanaRv2Plugin) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
DanaRv2Plugin danaRv2Plugin = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||||
if (danaRPlugin.isEnabled(PluginBase.PUMP) || danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) {
|
if (danaRPlugin.isEnabled(PluginBase.PUMP) || danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) {
|
||||||
addPreferencesFromResource(R.xml.pref_danar);
|
addPreferencesFromResource(R.xml.pref_danar);
|
||||||
}
|
}
|
||||||
|
@ -136,16 +136,16 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResource(R.xml.pref_danarprofile);
|
addPreferencesFromResource(R.xml.pref_danarprofile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VirtualPumpPlugin virtualPumpPlugin = (VirtualPumpPlugin) MainApp.getSpecificPlugin(VirtualPumpPlugin.class);
|
VirtualPumpPlugin virtualPumpPlugin = MainApp.getSpecificPlugin(VirtualPumpPlugin.class);
|
||||||
if (virtualPumpPlugin != null && virtualPumpPlugin.isEnabled(PluginBase.PUMP)) {
|
if (virtualPumpPlugin != null && virtualPumpPlugin.isEnabled(PluginBase.PUMP)) {
|
||||||
addPreferencesFromResource(R.xml.pref_virtualpump);
|
addPreferencesFromResource(R.xml.pref_virtualpump);
|
||||||
}
|
}
|
||||||
InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin = (InsulinOrefFreePeakPlugin) MainApp.getSpecificPlugin(InsulinOrefFreePeakPlugin.class);
|
InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin = MainApp.getSpecificPlugin(InsulinOrefFreePeakPlugin.class);
|
||||||
if(insulinOrefFreePeakPlugin.isEnabled(PluginBase.INSULIN)){
|
if(insulinOrefFreePeakPlugin.isEnabled(PluginBase.INSULIN)){
|
||||||
addPreferencesFromResource(R.xml.pref_insulinoreffreepeak);
|
addPreferencesFromResource(R.xml.pref_insulinoreffreepeak);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSClientInternalPlugin nsClientInternalPlugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
NSClientInternalPlugin nsClientInternalPlugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
||||||
if (nsClientInternalPlugin != null && nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
|
if (nsClientInternalPlugin != null && nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
addPreferencesFromResource(R.xml.pref_nsclientinternal);
|
addPreferencesFromResource(R.xml.pref_nsclientinternal);
|
||||||
}
|
}
|
||||||
|
@ -157,13 +157,13 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResource(R.xml.pref_advanced);
|
addPreferencesFromResource(R.xml.pref_advanced);
|
||||||
|
|
||||||
if (Config.WEAR) {
|
if (Config.WEAR) {
|
||||||
WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
|
WearPlugin wearPlugin = MainApp.getSpecificPlugin(WearPlugin.class);
|
||||||
if (wearPlugin != null && wearPlugin.isEnabled(PluginBase.GENERAL)) {
|
if (wearPlugin != null && wearPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
addPreferencesFromResource(R.xml.pref_wear);
|
addPreferencesFromResource(R.xml.pref_wear);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StatuslinePlugin statuslinePlugin = (StatuslinePlugin) MainApp.getSpecificPlugin(StatuslinePlugin.class);
|
StatuslinePlugin statuslinePlugin = MainApp.getSpecificPlugin(StatuslinePlugin.class);
|
||||||
if (statuslinePlugin != null && statuslinePlugin.isEnabled(PluginBase.GENERAL)) {
|
if (statuslinePlugin != null && statuslinePlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
addPreferencesFromResource(R.xml.pref_xdripstatus);
|
addPreferencesFromResource(R.xml.pref_xdripstatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
|
|
||||||
public class DetailedBolusInfo {
|
public class DetailedBolusInfo {
|
||||||
public long date = System.currentTimeMillis();
|
public long date = System.currentTimeMillis();
|
||||||
public InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin();
|
|
||||||
public String eventType = CareportalEvent.MEALBOLUS;
|
public String eventType = CareportalEvent.MEALBOLUS;
|
||||||
public double insulin = 0;
|
public double insulin = 0;
|
||||||
public double carbs = 0;
|
public double carbs = 0;
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
if (calcdate > dia_ago && calcdate <= time) {
|
if (calcdate > dia_ago && calcdate <= time) {
|
||||||
double tempBolusSize = absoluteRate() * spacing / 60d;
|
double tempBolusSize = absoluteRate() * spacing / 60d;
|
||||||
|
|
||||||
Treatment tempBolusPart = new Treatment(insulinInterface, dia);
|
Treatment tempBolusPart = new Treatment();
|
||||||
tempBolusPart.insulin = tempBolusSize;
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
tempBolusPart.date = calcdate;
|
tempBolusPart.date = calcdate;
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ public class TemporaryBasal implements Interval {
|
||||||
double tempBolusSize = netBasalRate * tempBolusSpacing / 60d;
|
double tempBolusSize = netBasalRate * tempBolusSpacing / 60d;
|
||||||
netBasalAmount += tempBolusSize;
|
netBasalAmount += tempBolusSize;
|
||||||
|
|
||||||
Treatment tempBolusPart = new Treatment(insulinInterface, dia);
|
Treatment tempBolusPart = new Treatment();
|
||||||
tempBolusPart.insulin = tempBolusSize;
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
tempBolusPart.date = calcdate;
|
tempBolusPart.date = calcdate;
|
||||||
|
|
||||||
|
|
|
@ -51,31 +51,13 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
public boolean isSMB = false;
|
public boolean isSMB = false;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public int insulinInterfaceID = InsulinInterface.FASTACTINGINSULIN;
|
public int insulinInterfaceID = InsulinInterface.FASTACTINGINSULIN; // currently unused, will be used in the future
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double dia = Constants.defaultDIA;
|
public double dia = Constants.defaultDIA; // currently unused, will be used in the future
|
||||||
|
|
||||||
public Treatment() {
|
public Treatment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Treatment(long date) {
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Treatment(InsulinInterface insulin) {
|
|
||||||
insulinInterfaceID = insulin.getId();
|
|
||||||
dia = insulin.getDia();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Treatment(InsulinInterface insulin, double dia) {
|
|
||||||
insulinInterfaceID = insulin.getId();
|
|
||||||
this.dia = dia;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMillisecondsFromStart() {
|
|
||||||
return System.currentTimeMillis() - date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Treatment{" +
|
return "Treatment{" +
|
||||||
"date= " + date +
|
"date= " + date +
|
||||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.ConstraintsSafety;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
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;
|
||||||
|
@ -161,17 +163,17 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
Double origRate = absoluteRate;
|
Double origRate = absoluteRate;
|
||||||
if (absoluteRate > maxBasal) {
|
if (absoluteRate > maxBasal) {
|
||||||
absoluteRate = maxBasal;
|
absoluteRate = maxBasal;
|
||||||
if (Config.logConstraintsChanges && origPercentRate != Constants.basalPercentOnlyForCheckLimit)
|
if (Config.logConstraintsChanges && !Objects.equals(origPercentRate, Constants.basalPercentOnlyForCheckLimit))
|
||||||
log.debug("Limiting rate " + origRate + " by maxBasal preference to " + absoluteRate + "U/h");
|
log.debug("Limiting rate " + origRate + " by maxBasal preference to " + absoluteRate + "U/h");
|
||||||
}
|
}
|
||||||
if (absoluteRate > maxBasalMult * profile.getBasal()) {
|
if (absoluteRate > maxBasalMult * profile.getBasal()) {
|
||||||
absoluteRate = Math.floor(maxBasalMult * profile.getBasal() * 100) / 100;
|
absoluteRate = Math.floor(maxBasalMult * profile.getBasal() * 100) / 100;
|
||||||
if (Config.logConstraintsChanges && origPercentRate != Constants.basalPercentOnlyForCheckLimit)
|
if (Config.logConstraintsChanges && !Objects.equals(origPercentRate, Constants.basalPercentOnlyForCheckLimit))
|
||||||
log.debug("Limiting rate " + origRate + " by maxBasalMult to " + absoluteRate + "U/h");
|
log.debug("Limiting rate " + origRate + " by maxBasalMult to " + absoluteRate + "U/h");
|
||||||
}
|
}
|
||||||
if (absoluteRate > profile.getMaxDailyBasal() * maxBasalFromDaily) {
|
if (absoluteRate > profile.getMaxDailyBasal() * maxBasalFromDaily) {
|
||||||
absoluteRate = profile.getMaxDailyBasal() * maxBasalFromDaily;
|
absoluteRate = profile.getMaxDailyBasal() * maxBasalFromDaily;
|
||||||
if (Config.logConstraintsChanges && origPercentRate != Constants.basalPercentOnlyForCheckLimit)
|
if (Config.logConstraintsChanges && !Objects.equals(origPercentRate, Constants.basalPercentOnlyForCheckLimit))
|
||||||
log.debug("Limiting rate " + origRate + " by 3 * maxDailyBasal to " + absoluteRate + "U/h");
|
log.debug("Limiting rate " + origRate + " by 3 * maxDailyBasal to " + absoluteRate + "U/h");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +182,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
percentRateAfterConst = Round.ceilTo((double) percentRateAfterConst, 10d).intValue();
|
percentRateAfterConst = Round.ceilTo((double) percentRateAfterConst, 10d).intValue();
|
||||||
else percentRateAfterConst = Round.floorTo((double) percentRateAfterConst, 10d).intValue();
|
else percentRateAfterConst = Round.floorTo((double) percentRateAfterConst, 10d).intValue();
|
||||||
|
|
||||||
if (Config.logConstraintsChanges && origPercentRate != Constants.basalPercentOnlyForCheckLimit)
|
if (Config.logConstraintsChanges && !Objects.equals(origPercentRate, Constants.basalPercentOnlyForCheckLimit))
|
||||||
log.debug("Recalculated percent rate " + percentRate + "% to " + percentRateAfterConst + "%");
|
log.debug("Recalculated percent rate " + percentRate + "% to " + percentRateAfterConst + "%");
|
||||||
return percentRateAfterConst;
|
return percentRateAfterConst;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.jjoe64.graphview.series.DataPoint;
|
||||||
import com.jjoe64.graphview.series.LineGraphSeries;
|
import com.jjoe64.graphview.series.LineGraphSeries;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
@ -39,14 +38,14 @@ public class ActivityGraph extends GraphView {
|
||||||
double dia = insulin.getDia();
|
double dia = insulin.getDia();
|
||||||
int hours = (int) Math.floor(dia + 1);
|
int hours = (int) Math.floor(dia + 1);
|
||||||
|
|
||||||
Treatment t = new Treatment(insulin, dia);
|
Treatment t = new Treatment();
|
||||||
t.date = 0;
|
t.date = 0;
|
||||||
t.insulin = 1d;
|
t.insulin = 1d;
|
||||||
|
|
||||||
LineGraphSeries<DataPoint> activitySeries = null;
|
LineGraphSeries<DataPoint> activitySeries = null;
|
||||||
LineGraphSeries<DataPoint> iobSeries = null;
|
LineGraphSeries<DataPoint> iobSeries = null;
|
||||||
List<DataPoint> activityArray = new ArrayList<DataPoint>();
|
List<DataPoint> activityArray = new ArrayList<>();
|
||||||
List<DataPoint> iobArray = new ArrayList<DataPoint>();
|
List<DataPoint> iobArray = new ArrayList<>();
|
||||||
|
|
||||||
for (long time = 0; time <= hours * 60 * 60 * 1000; time += 5 * 60 * 1000L) {
|
for (long time = 0; time <= hours * 60 * 60 * 1000; time += 5 * 60 * 1000L) {
|
||||||
Iob iob = t.iobCalc(time, dia);
|
Iob iob = t.iobCalc(time, dia);
|
||||||
|
@ -56,7 +55,7 @@ public class ActivityGraph extends GraphView {
|
||||||
|
|
||||||
DataPoint[] activityDataPoints = new DataPoint[activityArray.size()];
|
DataPoint[] activityDataPoints = new DataPoint[activityArray.size()];
|
||||||
activityDataPoints = activityArray.toArray(activityDataPoints);
|
activityDataPoints = activityArray.toArray(activityDataPoints);
|
||||||
addSeries(activitySeries = new LineGraphSeries<DataPoint>(activityDataPoints));
|
addSeries(activitySeries = new LineGraphSeries<>(activityDataPoints));
|
||||||
activitySeries.setThickness(8);
|
activitySeries.setThickness(8);
|
||||||
|
|
||||||
getViewport().setXAxisBoundsManual(true);
|
getViewport().setXAxisBoundsManual(true);
|
||||||
|
@ -68,7 +67,7 @@ public class ActivityGraph extends GraphView {
|
||||||
|
|
||||||
DataPoint[] iobDataPoints = new DataPoint[iobArray.size()];
|
DataPoint[] iobDataPoints = new DataPoint[iobArray.size()];
|
||||||
iobDataPoints = iobArray.toArray(iobDataPoints);
|
iobDataPoints = iobArray.toArray(iobDataPoints);
|
||||||
getSecondScale().addSeries(iobSeries = new LineGraphSeries<DataPoint>(iobDataPoints));
|
getSecondScale().addSeries(iobSeries = new LineGraphSeries<>(iobDataPoints));
|
||||||
iobSeries.setDrawBackground(true);
|
iobSeries.setDrawBackground(true);
|
||||||
iobSeries.setColor(Color.MAGENTA);
|
iobSeries.setColor(Color.MAGENTA);
|
||||||
iobSeries.setBackgroundColor(Color.argb(70, 255, 0, 255));
|
iobSeries.setBackgroundColor(Color.argb(70, 255, 0, 255));
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class InsulinFastactingFragment extends Fragment {
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
insulinName.setText(insulinFastactingPlugin.getFriendlyName());
|
insulinName.setText(insulinFastactingPlugin.getFriendlyName());
|
||||||
insulinComment.setText(insulinFastactingPlugin.getComment());
|
insulinComment.setText(insulinFastactingPlugin.getComment());
|
||||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingPlugin.getDia()).toString() + "h");
|
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(insulinFastactingPlugin.getDia()) + "h");
|
||||||
insulinGraph.show(insulinFastactingPlugin);
|
insulinGraph.show(insulinFastactingPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class InsulinFastactingProlongedFragment extends Fragment {
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
|
insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
|
||||||
insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
|
insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
|
||||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingProlongedPlugin.getDia()).toString() + "h");
|
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(insulinFastactingProlongedPlugin.getDia()) + "h");
|
||||||
insulinGraph.show(insulinFastactingProlongedPlugin);
|
insulinGraph.show(insulinFastactingProlongedPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class InsulinOrefFreePeakFragment extends Fragment {
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
insulinName.setText(insulinPlugin.getFriendlyName());
|
insulinName.setText(insulinPlugin.getFriendlyName());
|
||||||
insulinComment.setText(insulinPlugin.getComment());
|
insulinComment.setText(insulinPlugin.getComment());
|
||||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinPlugin.getDia()).toString() + "h");
|
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(insulinPlugin.getDia()) + "h");
|
||||||
insulinGraph.show(insulinPlugin);
|
insulinGraph.show(insulinPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class InsulinOrefRapidActingFragment extends Fragment {
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
insulinName.setText(insulinPlugin.getFriendlyName());
|
insulinName.setText(insulinPlugin.getFriendlyName());
|
||||||
insulinComment.setText(insulinPlugin.getComment());
|
insulinComment.setText(insulinPlugin.getComment());
|
||||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinPlugin.getDia()).toString() + "h");
|
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(insulinPlugin.getDia()) + "h");
|
||||||
insulinGraph.show(insulinPlugin);
|
insulinGraph.show(insulinPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class InsulinOrefUltraRapidActingFragment extends Fragment {
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
insulinName.setText(insulinPlugin.getFriendlyName());
|
insulinName.setText(insulinPlugin.getFriendlyName());
|
||||||
insulinComment.setText(insulinPlugin.getComment());
|
insulinComment.setText(insulinPlugin.getComment());
|
||||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinPlugin.getDia()).toString() + "h");
|
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(insulinPlugin.getDia()) + "h");
|
||||||
insulinGraph.show(insulinPlugin);
|
insulinGraph.show(insulinPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class UploadQueue {
|
||||||
public void run() {
|
public void run() {
|
||||||
log.debug("QUEUE adding: " + dbr.data);
|
log.debug("QUEUE adding: " + dbr.data);
|
||||||
MainApp.getDbHelper().create(dbr);
|
MainApp.getDbHelper().create(dbr);
|
||||||
NSClientInternalPlugin plugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
NSClientInternalPlugin plugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
plugin.resend("newdata");
|
plugin.resend("newdata");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
|
@ -188,7 +189,7 @@ public class NSSettingsStatus {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settingsO.has("alarmTimeagoWarnMins") && what == "alarmTimeagoWarnMins"){
|
if (settingsO.has("alarmTimeagoWarnMins") && Objects.equals(what, "alarmTimeagoWarnMins")){
|
||||||
Double result = settingsO.getDouble(what);
|
Double result = settingsO.getDouble(what);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class AckAlarmReceiver 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,
|
||||||
AckAlarmReceiver.class.getSimpleName());
|
AckAlarmReceiver.class.getSimpleName());
|
||||||
NSClientInternalPlugin nsClientInternalPlugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
NSClientInternalPlugin nsClientInternalPlugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
||||||
if (!nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
|
if (!nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ 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 = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
NSClientInternalPlugin nsClientInternalPlugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
||||||
if (!nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
|
if (!nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ public class NSClientService extends Service {
|
||||||
nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString();
|
nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString();
|
||||||
|
|
||||||
MainApp.bus().post(new EventNSClientStatus("Initializing"));
|
MainApp.bus().post(new EventNSClientStatus("Initializing"));
|
||||||
if (((NSClientInternalPlugin)MainApp.getSpecificPlugin(NSClientInternalPlugin.class)).paused) {
|
if (MainApp.getSpecificPlugin(NSClientInternalPlugin.class).paused) {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "paused"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "paused"));
|
||||||
MainApp.bus().post(new EventNSClientStatus("Paused"));
|
MainApp.bus().post(new EventNSClientStatus("Paused"));
|
||||||
} else if (!nsEnabled) {
|
} else if (!nsEnabled) {
|
||||||
|
@ -421,7 +421,7 @@ public class NSClientService extends Service {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("DATA", "Data packet #" + dataCounter++ + (isDelta ? " delta" : " full")));
|
MainApp.bus().post(new EventNSClientNewLog("DATA", "Data packet #" + dataCounter++ + (isDelta ? " delta" : " full")));
|
||||||
|
|
||||||
if (data.has("profiles")) {
|
if (data.has("profiles")) {
|
||||||
JSONArray profiles = (JSONArray) data.getJSONArray("profiles");
|
JSONArray profiles = data.getJSONArray("profiles");
|
||||||
if (profiles.length() > 0) {
|
if (profiles.length() > 0) {
|
||||||
JSONObject profile = (JSONObject) profiles.get(profiles.length() - 1);
|
JSONObject profile = (JSONObject) profiles.get(profiles.length() - 1);
|
||||||
profileStore = new ProfileStore(profile);
|
profileStore = new ProfileStore(profile);
|
||||||
|
|
|
@ -29,7 +29,7 @@ import info.nightscout.utils.SafeParse;
|
||||||
public class EditQuickWizardDialog extends DialogFragment implements View.OnClickListener {
|
public class EditQuickWizardDialog extends DialogFragment implements View.OnClickListener {
|
||||||
|
|
||||||
QuickWizard.QuickWizardEntry entry = new QuickWizard().newEmptyItem();
|
QuickWizard.QuickWizardEntry entry = new QuickWizard().newEmptyItem();
|
||||||
QuickWizard quickWizard = ((OverviewPlugin) MainApp.getSpecificPlugin(OverviewPlugin.class)).quickWizard;
|
QuickWizard quickWizard = MainApp.getSpecificPlugin(OverviewPlugin.class).quickWizard;
|
||||||
|
|
||||||
EditText buttonEdit;
|
EditText buttonEdit;
|
||||||
EditText carbsEdit;
|
EditText carbsEdit;
|
||||||
|
|
|
@ -20,6 +20,7 @@ import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -86,7 +87,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
|
|
||||||
confirmMessage += getString(R.string.bolus) + ": " + insulinAfterConstraints + "U";
|
confirmMessage += getString(R.string.bolus) + ": " + insulinAfterConstraints + "U";
|
||||||
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||||
if (insulinAfterConstraints - insulin != 0 || carbsAfterConstraints != carbs)
|
if (insulinAfterConstraints - insulin != 0 || !Objects.equals(carbsAfterConstraints, carbs))
|
||||||
confirmMessage += "\n" + getString(R.string.constraintapllied);
|
confirmMessage += "\n" + getString(R.string.constraintapllied);
|
||||||
|
|
||||||
final double finalInsulinAfterConstraints = insulinAfterConstraints;
|
final double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class NotificationStore {
|
||||||
}
|
}
|
||||||
store.add(n);
|
store.add(n);
|
||||||
|
|
||||||
WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
|
WearPlugin wearPlugin = MainApp.getSpecificPlugin(WearPlugin.class);
|
||||||
if(wearPlugin!= null && wearPlugin.isEnabled()) {
|
if(wearPlugin!= null && wearPlugin.isEnabled()) {
|
||||||
wearPlugin.overviewNotification(n.id, "OverviewNotification:\n" + n.text);
|
wearPlugin.overviewNotification(n.id, "OverviewNotification:\n" + n.text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
@ -615,7 +616,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
finalLastRun.lastEnact = new Date();
|
finalLastRun.lastEnact = new Date();
|
||||||
finalLastRun.lastOpenModeAccept = new Date();
|
finalLastRun.lastOpenModeAccept = new Date();
|
||||||
NSUpload.uploadDeviceStatus();
|
NSUpload.uploadDeviceStatus();
|
||||||
ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class);
|
ObjectivesPlugin objectivesPlugin = MainApp.getSpecificPlugin(ObjectivesPlugin.class);
|
||||||
if (objectivesPlugin != null) {
|
if (objectivesPlugin != null) {
|
||||||
ObjectivesPlugin.manualEnacts++;
|
ObjectivesPlugin.manualEnacts++;
|
||||||
ObjectivesPlugin.saveProgress();
|
ObjectivesPlugin.saveProgress();
|
||||||
|
@ -1740,7 +1741,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onBindViewHolder(NotificationsViewHolder holder, int position) {
|
public void onBindViewHolder(NotificationsViewHolder holder, int position) {
|
||||||
Notification notification = notificationsList.get(position);
|
Notification notification = notificationsList.get(position);
|
||||||
holder.dismiss.setTag(notification);
|
holder.dismiss.setTag(notification);
|
||||||
if(notification.text == MainApp.sResources.getString(R.string.nsalarm_staledata))
|
if(Objects.equals(notification.text, MainApp.sResources.getString(R.string.nsalarm_staledata)))
|
||||||
holder.dismiss.setText("snooze");
|
holder.dismiss.setText("snooze");
|
||||||
holder.text.setText(notification.text);
|
holder.text.setText(notification.text);
|
||||||
holder.time.setText(DateUtil.timeString(notification.date));
|
holder.time.setText(DateUtil.timeString(notification.date));
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class QuickWizardListActivity extends AppCompatActivity implements View.O
|
||||||
llm = new LinearLayoutManager(this);
|
llm = new LinearLayoutManager(this);
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(((OverviewPlugin) MainApp.getSpecificPlugin(OverviewPlugin.class)).quickWizard, getSupportFragmentManager());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getSpecificPlugin(OverviewPlugin.class).quickWizard, getSupportFragmentManager());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
adButton = (Button) findViewById(R.id.overview_quickwizardactivity_add_button);
|
adButton = (Button) findViewById(R.id.overview_quickwizardactivity_add_button);
|
||||||
|
@ -164,7 +164,7 @@ public class QuickWizardListActivity extends AppCompatActivity implements View.O
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(((OverviewPlugin) MainApp.getSpecificPlugin(OverviewPlugin.class)).quickWizard, getSupportFragmentManager());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getSpecificPlugin(OverviewPlugin.class).quickWizard, getSupportFragmentManager());
|
||||||
recyclerView.swapAdapter(adapter, false);
|
recyclerView.swapAdapter(adapter, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
if (SP.getBoolean("syncprofiletopump", false)) {
|
if (SP.getBoolean("syncprofiletopump", false)) {
|
||||||
if (pump.setNewBasalProfile(MainApp.getConfigBuilder().getProfile()) == PumpInterface.SUCCESS) {
|
if (pump.setNewBasalProfile(MainApp.getConfigBuilder().getProfile()) == PumpInterface.SUCCESS) {
|
||||||
SmsCommunicatorPlugin smsCommunicatorPlugin = (SmsCommunicatorPlugin) MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
pumpDescription.isRefillingCapable = true;
|
pumpDescription.isRefillingCapable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
log.debug("Service is disconnected");
|
log.debug("Service is disconnected");
|
||||||
|
@ -298,7 +298,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||||
Treatment t = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment t = new Treatment();
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
|
|
@ -318,7 +318,7 @@ public class DanaRExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
if (danaRPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime() || !((DanaRPlugin)MainApp.getSpecificPlugin(DanaRPlugin.class)).isInitialized()) {
|
if (danaRPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime() || !MainApp.getSpecificPlugin(DanaRPlugin.class).isInitialized()) {
|
||||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
||||||
|
|
|
@ -72,8 +72,6 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
|
|
||||||
public static PumpDescription pumpDescription = new PumpDescription();
|
public static PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
String textStatus = "";
|
|
||||||
|
|
||||||
public DanaRKoreanPlugin() {
|
public DanaRKoreanPlugin() {
|
||||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||||
|
|
||||||
|
@ -107,7 +105,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
pumpDescription.isRefillingCapable = true;
|
pumpDescription.isRefillingCapable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
log.debug("Service is disconnected");
|
log.debug("Service is disconnected");
|
||||||
|
@ -301,7 +299,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||||
Treatment t = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment t = new Treatment();
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
||||||
|
|
|
@ -315,7 +315,7 @@ public class DanaRKoreanExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
if (danaRPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime() || !((DanaRKoreanPlugin)MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).isInitialized()) {
|
if (danaRPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime() || !MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isInitialized()) {
|
||||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingBasal_k());
|
mSerialIOThread.sendMessage(new MsgSettingBasal_k());
|
||||||
|
|
|
@ -73,8 +73,6 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
public static PumpDescription pumpDescription = new PumpDescription();
|
public static PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
public DanaRv2Plugin() {
|
public DanaRv2Plugin() {
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
|
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
@ -105,7 +103,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
pumpDescription.isRefillingCapable = true;
|
pumpDescription.isRefillingCapable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
log.debug("Service is disconnected");
|
log.debug("Service is disconnected");
|
||||||
|
@ -288,7 +286,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||||
DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
|
DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
|
||||||
Treatment t = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment t = new Treatment();
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, System.currentTimeMillis() + detailedBolusInfo.carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different
|
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, System.currentTimeMillis() + detailedBolusInfo.carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different
|
||||||
|
|
|
@ -289,7 +289,7 @@ public class DanaRv2ExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
if (danaRPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime() || !((DanaRv2Plugin)MainApp.getSpecificPlugin(DanaRv2Plugin.class)).isInitialized()) {
|
if (danaRPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime() || !MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) {
|
||||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
||||||
|
|
|
@ -269,7 +269,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
switch (splited[1].toUpperCase()) {
|
switch (splited[1].toUpperCase()) {
|
||||||
case "DISABLE":
|
case "DISABLE":
|
||||||
case "STOP":
|
case "STOP":
|
||||||
LoopPlugin loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class);
|
LoopPlugin loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||||
if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) {
|
if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) {
|
||||||
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
|
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
|
||||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||||
|
@ -283,7 +283,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
break;
|
break;
|
||||||
case "ENABLE":
|
case "ENABLE":
|
||||||
case "START":
|
case "START":
|
||||||
loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class);
|
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||||
if (loopPlugin != null && !loopPlugin.isEnabled(PluginBase.LOOP)) {
|
if (loopPlugin != null && !loopPlugin.isEnabled(PluginBase.LOOP)) {
|
||||||
loopPlugin.setFragmentEnabled(PluginBase.LOOP, true);
|
loopPlugin.setFragmentEnabled(PluginBase.LOOP, true);
|
||||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeenenabled);
|
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeenenabled);
|
||||||
|
@ -294,7 +294,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Start"));
|
Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Start"));
|
||||||
break;
|
break;
|
||||||
case "STATUS":
|
case "STATUS":
|
||||||
loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class);
|
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||||
if (loopPlugin != null) {
|
if (loopPlugin != null) {
|
||||||
if (loopPlugin.isEnabled(PluginBase.LOOP)) {
|
if (loopPlugin.isEnabled(PluginBase.LOOP)) {
|
||||||
if (loopPlugin.isSuspended())
|
if (loopPlugin.isSuspended())
|
||||||
|
@ -371,12 +371,12 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "DANAR":
|
case "DANAR":
|
||||||
DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
DanaRPlugin danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||||
if (danaRPlugin != null && danaRPlugin.isEnabled(PluginBase.PUMP)) {
|
if (danaRPlugin != null && danaRPlugin.isEnabled(PluginBase.PUMP)) {
|
||||||
reply = danaRPlugin.shortStatus(true);
|
reply = danaRPlugin.shortStatus(true);
|
||||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||||
}
|
}
|
||||||
DanaRKoreanPlugin danaRKoreanPlugin = (DanaRKoreanPlugin) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
DanaRKoreanPlugin danaRKoreanPlugin = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||||
if (danaRKoreanPlugin != null && danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) {
|
if (danaRKoreanPlugin != null && danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) {
|
||||||
reply = danaRKoreanPlugin.shortStatus(true);
|
reply = danaRKoreanPlugin.shortStatus(true);
|
||||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||||
|
@ -463,7 +463,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
bolusWaitingForConfirmation.processed = true;
|
bolusWaitingForConfirmation.processed = true;
|
||||||
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
||||||
if (pumpInterface != null) {
|
if (pumpInterface != null) {
|
||||||
danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
detailedBolusInfo.insulin = bolusWaitingForConfirmation.bolusRequested;
|
detailedBolusInfo.insulin = bolusWaitingForConfirmation.bolusRequested;
|
||||||
detailedBolusInfo.source = Source.USER;
|
detailedBolusInfo.source = Source.USER;
|
||||||
|
@ -486,7 +486,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
tempBasalWaitingForConfirmation.processed = true;
|
tempBasalWaitingForConfirmation.processed = true;
|
||||||
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
||||||
if (pumpInterface != null) {
|
if (pumpInterface != null) {
|
||||||
danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||||
PumpEnactResult result = pumpInterface.setTempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30, false);
|
PumpEnactResult result = pumpInterface.setTempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30, false);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
|
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
|
||||||
|
@ -505,7 +505,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
cancelTempBasalWaitingForConfirmation.processed = true;
|
cancelTempBasalWaitingForConfirmation.processed = true;
|
||||||
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
||||||
if (pumpInterface != null) {
|
if (pumpInterface != null) {
|
||||||
danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||||
PumpEnactResult result = pumpInterface.cancelTempBasal(true);
|
PumpEnactResult result = pumpInterface.cancelTempBasal(true);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled);
|
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled);
|
||||||
|
|
|
@ -413,7 +413,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
Treatment treatment = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment treatment = new Treatment();
|
||||||
treatment.date = detailedBolusInfo.date;
|
treatment.date = detailedBolusInfo.date;
|
||||||
treatment.source = detailedBolusInfo.source;
|
treatment.source = detailedBolusInfo.source;
|
||||||
treatment.pumpId = detailedBolusInfo.pumpId;
|
treatment.pumpId = detailedBolusInfo.pumpId;
|
||||||
|
@ -427,7 +427,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(treatment);
|
boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(treatment);
|
||||||
//log.debug("Adding new Treatment record" + treatment.toString());
|
//log.debug("Adding new Treatment record" + treatment.toString());
|
||||||
if (detailedBolusInfo.carbTime != 0) {
|
if (detailedBolusInfo.carbTime != 0) {
|
||||||
Treatment carbsTreatment = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment carbsTreatment = new Treatment();
|
||||||
carbsTreatment.source = detailedBolusInfo.source;
|
carbsTreatment.source = detailedBolusInfo.source;
|
||||||
carbsTreatment.pumpId = detailedBolusInfo.pumpId; // but this should never happen
|
carbsTreatment.pumpId = detailedBolusInfo.pumpId; // but this should never happen
|
||||||
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
||||||
|
|
|
@ -242,7 +242,7 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
} else if("opencpp".equals(act[0])){
|
} else if("opencpp".equals(act[0])){
|
||||||
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
CircadianPercentageProfilePlugin cpp = MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
sendError("CPP not activated!");
|
sendError("CPP not activated!");
|
||||||
|
@ -256,7 +256,7 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
} else if("cppset".equals(act[0])){
|
} else if("cppset".equals(act[0])){
|
||||||
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
CircadianPercentageProfilePlugin cpp = MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
sendError("CPP not activated!");
|
sendError("CPP not activated!");
|
||||||
|
@ -271,9 +271,9 @@ 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 = (PumpInterface) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||||
PumpInterface danaV2 = (PumpInterface) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||||
PumpInterface danaKorean = (PumpInterface) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||||
|
|
||||||
|
|
||||||
if((dana == null || dana != activePump) &&
|
if((dana == null || dana != activePump) &&
|
||||||
|
@ -336,7 +336,7 @@ public class ActionStringHandler {
|
||||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
String message = "";
|
String message = "";
|
||||||
|
|
||||||
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
CircadianPercentageProfilePlugin cpp = MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
boolean isCPP = (cpp!= null && cpp.isEnabled(PluginBase.PROFILE));
|
boolean isCPP = (cpp!= null && cpp.isEnabled(PluginBase.PROFILE));
|
||||||
double refTDD = 100;
|
double refTDD = 100;
|
||||||
if(isCPP) refTDD = cpp.baseBasalSum()*2;
|
if(isCPP) refTDD = cpp.baseBasalSum()*2;
|
||||||
|
@ -572,7 +572,7 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
private static void setCPP(int percentage, int timeshift) {
|
private static void setCPP(int percentage, int timeshift) {
|
||||||
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
CircadianPercentageProfilePlugin cpp = MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
sendError("CPP not activated!");
|
sendError("CPP not activated!");
|
||||||
|
|
Loading…
Reference in a new issue