get rid of Date.class
This commit is contained in:
parent
15e69a478e
commit
1d67f124fc
|
@ -1,7 +1,5 @@
|
|||
package info.nightscout.androidaps.interfaces;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
|
||||
/**
|
||||
|
@ -9,7 +7,7 @@ import info.nightscout.androidaps.plugins.Loop.APSResult;
|
|||
*/
|
||||
public interface APSInterface {
|
||||
public APSResult getLastAPSResult();
|
||||
public Date getLastAPSRun();
|
||||
public long getLastAPSRun();
|
||||
|
||||
public void invoke(String initiator, boolean tempBasalFallback);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package info.nightscout.androidaps.interfaces;
|
|||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
|
@ -29,7 +27,7 @@ public interface PumpInterface {
|
|||
PumpEnactResult setNewBasalProfile(Profile profile);
|
||||
boolean isThisProfileSet(Profile profile);
|
||||
|
||||
Date lastDataTime();
|
||||
long lastDataTime();
|
||||
|
||||
double getBaseBasalRate(); // base basal rate, not temp basal
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
|
@ -324,7 +323,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia)));
|
||||
if (getBGDataFrom == oldestDataAvailable)
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
|
||||
log.debug("Limiting data to oldest available temps: " + DateUtil.dateAndTimeFullString(oldestDataAvailable));
|
||||
} else
|
||||
getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia));
|
||||
return getBGDataFrom;
|
||||
|
@ -685,11 +684,11 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
// clear up 5 min back for proper COB calculation
|
||||
long time = ev.time - 5 * 60 * 1000L;
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Invalidating cached data to: " + new Date(time).toLocaleString());
|
||||
log.debug("Invalidating cached data to: " + DateUtil.dateAndTimeFullString(time));
|
||||
for (int index = iobTable.size() - 1; index >= 0; index--) {
|
||||
if (iobTable.keyAt(index) > time) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Removing from iobTable: " + new Date(iobTable.keyAt(index)).toLocaleString());
|
||||
log.debug("Removing from iobTable: " + DateUtil.dateAndTimeFullString(iobTable.keyAt(index)));
|
||||
iobTable.removeAt(index);
|
||||
} else {
|
||||
break;
|
||||
|
@ -698,7 +697,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
for (int index = autosensDataTable.size() - 1; index >= 0; index--) {
|
||||
if (autosensDataTable.keyAt(index) > time) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Removing from autosensDataTable: " + new Date(autosensDataTable.keyAt(index)).toLocaleString());
|
||||
log.debug("Removing from autosensDataTable: " + DateUtil.dateAndTimeFullString(autosensDataTable.keyAt(index)));
|
||||
autosensDataTable.removeAt(index);
|
||||
} else {
|
||||
break;
|
||||
|
@ -707,7 +706,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
for (int index = basalDataTable.size() - 1; index >= 0; index--) {
|
||||
if (basalDataTable.keyAt(index) > time) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Removing from basalDataTable: " + new Date(basalDataTable.keyAt(index)).toLocaleString());
|
||||
log.debug("Removing from basalDataTable: " + DateUtil.dateAndTimeFullString(basalDataTable.keyAt(index)));
|
||||
basalDataTable.removeAt(index);
|
||||
} else {
|
||||
break;
|
||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.logging.L;
|
|||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.JSONFormatter;
|
||||
|
||||
|
@ -108,8 +109,8 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
|
|||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
|
||||
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
|
||||
}
|
||||
if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != null) {
|
||||
lastRunView.setText(OpenAPSAMAPlugin.getPlugin().lastAPSRun.toLocaleString());
|
||||
if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != 0) {
|
||||
lastRunView.setText(DateUtil.dateAndTimeFullString(OpenAPSAMAPlugin.getPlugin().lastAPSRun));
|
||||
}
|
||||
if (OpenAPSAMAPlugin.getPlugin().lastAutosensResult != null) {
|
||||
autosensDataView.setText(JSONFormatter.format(OpenAPSAMAPlugin.getPlugin().lastAutosensResult.json()));
|
||||
|
|
|
@ -4,8 +4,6 @@ import org.json.JSONException;
|
|||
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.data.GlucoseStatus;
|
||||
|
@ -52,11 +50,11 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
// last values
|
||||
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
|
||||
Date lastAPSRun = null;
|
||||
long lastAPSRun = 0;
|
||||
DetermineBasalResultAMA lastAPSResult = null;
|
||||
AutosensResult lastAutosensResult = null;
|
||||
|
||||
public OpenAPSAMAPlugin() {
|
||||
private OpenAPSAMAPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.APS)
|
||||
.fragmentClass(OpenAPSAMAFragment.class.getName())
|
||||
|
@ -85,7 +83,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date getLastAPSRun() {
|
||||
public long getLastAPSRun() {
|
||||
return lastAPSRun;
|
||||
}
|
||||
|
||||
|
@ -132,13 +130,13 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
minBg = Round.roundTo(minBg, 0.1d);
|
||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||
|
||||
Date start = new Date();
|
||||
Date startPart = new Date();
|
||||
long start = System.currentTimeMillis();
|
||||
long startPart = System.currentTimeMillis();
|
||||
IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayInDia(profile);
|
||||
if (L.isEnabled(L.APS))
|
||||
Profiler.log(log, "calculateIobArrayInDia()", startPart);
|
||||
|
||||
startPart = new Date();
|
||||
startPart = System.currentTimeMillis();
|
||||
MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
|
||||
if (L.isEnabled(L.APS))
|
||||
Profiler.log(log, "getMealData()", startPart);
|
||||
|
@ -170,7 +168,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
if (!HardLimits.checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, HardLimits.maxBasal()))
|
||||
return;
|
||||
|
||||
startPart = new Date();
|
||||
startPart = System.currentTimeMillis();
|
||||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin");
|
||||
if (autosensData == null) {
|
||||
|
@ -187,7 +185,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
if (L.isEnabled(L.APS))
|
||||
Profiler.log(log, "AMA data gathering", start);
|
||||
|
||||
start = new Date();
|
||||
start = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||
|
@ -219,7 +217,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
determineBasalResultAMA.iob = iobArray[0];
|
||||
|
||||
Date now = new Date();
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
determineBasalResultAMA.json.put("timestamp", DateUtil.toISOString(now));
|
||||
|
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.JSONFormatter;
|
||||
|
||||
|
@ -94,8 +95,8 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
|
|||
profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
|
||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
|
||||
}
|
||||
if (OpenAPSMAPlugin.getPlugin().lastAPSRun != null) {
|
||||
lastRunView.setText(OpenAPSMAPlugin.getPlugin().lastAPSRun.toLocaleString());
|
||||
if (OpenAPSMAPlugin.getPlugin().lastAPSRun != 0) {
|
||||
lastRunView.setText(DateUtil.dateAndTimeFullString(OpenAPSMAPlugin.getPlugin().lastAPSRun));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import org.json.JSONException;
|
|||
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.data.GlucoseStatus;
|
||||
|
@ -52,10 +50,10 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
// last values
|
||||
DetermineBasalAdapterMAJS lastDetermineBasalAdapterMAJS = null;
|
||||
Date lastAPSRun = null;
|
||||
long lastAPSRun = 0;
|
||||
DetermineBasalResultMA lastAPSResult = null;
|
||||
|
||||
public OpenAPSMAPlugin() {
|
||||
private OpenAPSMAPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.APS)
|
||||
.fragmentClass(OpenAPSMAFragment.class.getName())
|
||||
|
@ -84,7 +82,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date getLastAPSRun() {
|
||||
public long getLastAPSRun() {
|
||||
return lastAPSRun;
|
||||
}
|
||||
|
||||
|
@ -93,7 +91,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
if (L.isEnabled(L.APS))
|
||||
log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
|
||||
lastAPSResult = null;
|
||||
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = null;
|
||||
DetermineBasalAdapterMAJS determineBasalAdapterMAJS;
|
||||
determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
|
||||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
|
@ -132,7 +130,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
minBg = Round.roundTo(minBg, 0.1d);
|
||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||
|
||||
Date start = new Date();
|
||||
long start = System.currentTimeMillis();
|
||||
TreatmentsPlugin.getPlugin().updateTotalIOBTreatments();
|
||||
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
||||
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments();
|
||||
|
@ -159,7 +157,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
if (!checkOnlyHardLimits(profile.getDia(), "dia", HardLimits.MINDIA, HardLimits.MAXDIA))
|
||||
return;
|
||||
if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
||||
if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
||||
return;
|
||||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", HardLimits.MINISF, HardLimits.MAXISF))
|
||||
return;
|
||||
|
@ -168,7 +166,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, HardLimits.maxBasal()))
|
||||
return;
|
||||
|
||||
start = new Date();
|
||||
start = System.currentTimeMillis();
|
||||
try {
|
||||
determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobTotal, glucoseStatus, mealData);
|
||||
} catch (JSONException e) {
|
||||
|
@ -205,7 +203,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
lastDetermineBasalAdapterMAJS = determineBasalAdapterMAJS;
|
||||
lastAPSResult = determineBasalResultMA;
|
||||
lastAPSRun = new Date(now);
|
||||
lastAPSRun = now;
|
||||
MainApp.bus().post(new EventOpenAPSUpdateGui());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.logging.L;
|
|||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.JSONFormatter;
|
||||
|
||||
|
@ -111,8 +112,8 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
|
|||
if (lastAPSResult != null && lastAPSResult.inputConstraints != null)
|
||||
constraintsView.setText(lastAPSResult.inputConstraints.getReasons().trim());
|
||||
}
|
||||
if (plugin.lastAPSRun != null) {
|
||||
lastRunView.setText(plugin.lastAPSRun.toLocaleString().trim());
|
||||
if (plugin.lastAPSRun != 0) {
|
||||
lastRunView.setText(DateUtil.dateAndTimeFullString(plugin.lastAPSRun));
|
||||
}
|
||||
if (plugin.lastAutosensResult != null) {
|
||||
autosensDataView.setText(JSONFormatter.format(plugin.lastAutosensResult.json()).toString().trim());
|
||||
|
|
|
@ -55,7 +55,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
// last values
|
||||
DetermineBasalAdapterSMBJS lastDetermineBasalAdapterSMBJS = null;
|
||||
Date lastAPSRun = null;
|
||||
long lastAPSRun = 0;
|
||||
DetermineBasalResultSMB lastAPSResult = null;
|
||||
AutosensResult lastAutosensResult = null;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date getLastAPSRun() {
|
||||
public long getLastAPSRun() {
|
||||
return lastAPSRun;
|
||||
}
|
||||
|
||||
|
@ -139,13 +139,13 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
minBg = Round.roundTo(minBg, 0.1d);
|
||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||
|
||||
Date start = new Date();
|
||||
Date startPart = new Date();
|
||||
long start = System.currentTimeMillis();
|
||||
long startPart = System.currentTimeMillis();
|
||||
IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayForSMB(profile);
|
||||
if (L.isEnabled(L.APS))
|
||||
Profiler.log(log, "calculateIobArrayInDia()", startPart);
|
||||
|
||||
startPart = new Date();
|
||||
startPart = System.currentTimeMillis();
|
||||
MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
|
||||
if (L.isEnabled(L.APS))
|
||||
Profiler.log(log, "getMealData()", startPart);
|
||||
|
@ -177,7 +177,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, HardLimits.maxBasal()))
|
||||
return;
|
||||
|
||||
startPart = new Date();
|
||||
startPart = System.currentTimeMillis();
|
||||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin");
|
||||
if (autosensData == null) {
|
||||
|
@ -203,7 +203,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
if (L.isEnabled(L.APS))
|
||||
Profiler.log(log, "SMB data gathering", start);
|
||||
|
||||
start = new Date();
|
||||
start = System.currentTimeMillis();
|
||||
try {
|
||||
determineBasalAdapterSMBJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||
lastAutosensResult.ratio, //autosensDataRatio
|
||||
|
@ -248,7 +248,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
lastDetermineBasalAdapterSMBJS = determineBasalAdapterSMBJS;
|
||||
lastAPSResult = determineBasalResultSMB;
|
||||
lastAPSRun = new Date(now);
|
||||
lastAPSRun = now;
|
||||
MainApp.bus().post(new EventOpenAPSUpdateGui());
|
||||
|
||||
//deviceStatus.suggested = determineBasalResultAMA.json;
|
||||
|
|
|
@ -66,6 +66,7 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange;
|
||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
|
@ -86,7 +87,6 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
|
|||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
|
@ -95,6 +95,7 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalcul
|
|||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
|
@ -111,14 +112,12 @@ import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
|||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog;
|
||||
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
|
||||
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.BolusWizard;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.DefaultValueHelper;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.utils.OKDialog;
|
||||
import info.nightscout.utils.Profiler;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -189,8 +188,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
Handler sLoopHandler = new Handler();
|
||||
Runnable sRefreshLoop = null;
|
||||
|
||||
final Object updateSync = new Object();
|
||||
|
||||
public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN, DEVSLOPE}
|
||||
|
||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
||||
|
@ -320,15 +317,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
|
||||
|
||||
bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
rangeToDisplay += 6;
|
||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||
SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
|
||||
updateGUI("rangeChange");
|
||||
return false;
|
||||
}
|
||||
bgGraph.setOnLongClickListener(v -> {
|
||||
rangeToDisplay += 6;
|
||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||
SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
|
||||
updateGUI("rangeChange");
|
||||
return false;
|
||||
});
|
||||
|
||||
setupChartMenu(view);
|
||||
|
@ -338,114 +332,111 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
private void setupChartMenu(View view) {
|
||||
chartButton = (ImageButton) view.findViewById(R.id.overview_chartMenuButton);
|
||||
chartButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||
boolean predictionsAvailable;
|
||||
if (Config.APS)
|
||||
predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions;
|
||||
else if (Config.NSCLIENT)
|
||||
predictionsAvailable = true;
|
||||
else
|
||||
predictionsAvailable = false;
|
||||
chartButton.setOnClickListener(v -> {
|
||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||
boolean predictionsAvailable;
|
||||
if (Config.APS)
|
||||
predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions;
|
||||
else if (Config.NSCLIENT)
|
||||
predictionsAvailable = true;
|
||||
else
|
||||
predictionsAvailable = false;
|
||||
|
||||
MenuItem item;
|
||||
CharSequence title;
|
||||
SpannableString s;
|
||||
PopupMenu popup = new PopupMenu(v.getContext(), v);
|
||||
MenuItem item;
|
||||
CharSequence title;
|
||||
SpannableString s;
|
||||
PopupMenu popup = new PopupMenu(v.getContext(), v);
|
||||
|
||||
if (predictionsAvailable) {
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.PRE.ordinal(), Menu.NONE, "Predictions");
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.prediction, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showprediction", true));
|
||||
}
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.BAS.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_basals));
|
||||
if (predictionsAvailable) {
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.PRE.ordinal(), Menu.NONE, "Predictions");
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.basal, null)), 0, s.length(), 0);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.prediction, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showbasals", true));
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.IOB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_iob));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.iob, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showiob", true));
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.COB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_cob));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.cob, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showcob", true));
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.DEV.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_deviations));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.deviations, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showdeviations", false));
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.SEN.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_sensitivity));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.ratio, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showratios", false));
|
||||
|
||||
if (MainApp.devBranch) {
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope");
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showdevslope", false));
|
||||
}
|
||||
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == CHARTTYPE.PRE.ordinal()) {
|
||||
SP.putBoolean("showprediction", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.BAS.ordinal()) {
|
||||
SP.putBoolean("showbasals", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.IOB.ordinal()) {
|
||||
SP.putBoolean("showiob", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.COB.ordinal()) {
|
||||
SP.putBoolean("showcob", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.DEV.ordinal()) {
|
||||
SP.putBoolean("showdeviations", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.SEN.ordinal()) {
|
||||
SP.putBoolean("showratios", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.DEVSLOPE.ordinal()) {
|
||||
SP.putBoolean("showdevslope", !item.isChecked());
|
||||
}
|
||||
scheduleUpdateGUI("onGraphCheckboxesCheckedChanged");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
chartButton.setImageResource(R.drawable.ic_arrow_drop_up_white_24dp);
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
chartButton.setImageResource(R.drawable.ic_arrow_drop_down_white_24dp);
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
item.setChecked(SP.getBoolean("showprediction", true));
|
||||
}
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.BAS.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_basals));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.basal, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showbasals", true));
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.IOB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_iob));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.iob, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showiob", true));
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.COB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_cob));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.cob, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showcob", true));
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.DEV.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_deviations));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.deviations, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showdeviations", false));
|
||||
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.SEN.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_sensitivity));
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.ratio, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showratios", false));
|
||||
|
||||
if (MainApp.devBranch) {
|
||||
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope");
|
||||
title = item.getTitle();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
item.setCheckable(true);
|
||||
item.setChecked(SP.getBoolean("showdevslope", false));
|
||||
}
|
||||
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == CHARTTYPE.PRE.ordinal()) {
|
||||
SP.putBoolean("showprediction", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.BAS.ordinal()) {
|
||||
SP.putBoolean("showbasals", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.IOB.ordinal()) {
|
||||
SP.putBoolean("showiob", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.COB.ordinal()) {
|
||||
SP.putBoolean("showcob", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.DEV.ordinal()) {
|
||||
SP.putBoolean("showdeviations", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.SEN.ordinal()) {
|
||||
SP.putBoolean("showratios", !item.isChecked());
|
||||
} else if (item.getItemId() == CHARTTYPE.DEVSLOPE.ordinal()) {
|
||||
SP.putBoolean("showdevslope", !item.isChecked());
|
||||
}
|
||||
scheduleUpdateGUI("onGraphCheckboxesCheckedChanged");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
chartButton.setImageResource(R.drawable.ic_arrow_drop_up_white_24dp);
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
chartButton.setImageResource(R.drawable.ic_arrow_drop_down_white_24dp);
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -638,8 +629,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean xdrip = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginType.BGSOURCE);
|
||||
boolean g5 = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginType.BGSOURCE);
|
||||
boolean xdrip = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||
boolean g5 = SourceDexcomG5Plugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
|
||||
FragmentManager manager = getFragmentManager();
|
||||
|
@ -1027,7 +1018,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
public void updateGUI(final String from) {
|
||||
if (L.isEnabled(L.OVERVIEW))
|
||||
log.debug("updateGUI entered from: " + from);
|
||||
final Date updateGUIStart = new Date();
|
||||
final long updateGUIStart = System.currentTimeMillis();
|
||||
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
|
|
|
@ -355,8 +355,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
|
||||
@NonNull
|
||||
@Override
|
||||
public Date lastDataTime() {
|
||||
return new Date(pump.lastSuccessfulCmdTime);
|
||||
public long lastDataTime() {
|
||||
return pump.lastSuccessfulCmdTime;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,8 +143,8 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date lastDataTime() {
|
||||
return new Date(DanaRPump.getInstance().lastConnection);
|
||||
public long lastDataTime() {
|
||||
return DanaRPump.getInstance().lastConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -333,8 +333,8 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
|||
status.put("timestamp", DateUtil.toISOString(pump.lastConnection));
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
extended.put("PumpIOB", pump.iob);
|
||||
if (pump.lastBolusTime.getTime() != 0) {
|
||||
extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
|
||||
if (pump.lastBolusTime != 0) {
|
||||
extended.put("LastBolus", DateUtil.dateAndTimeFullString(pump.lastBolusTime));
|
||||
extended.put("LastBolusAmount", pump.lastBolusAmount);
|
||||
}
|
||||
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(now);
|
||||
|
@ -441,7 +441,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
|||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||
ret += "LastConn: " + agoMin + " minago\n";
|
||||
}
|
||||
if (pump.lastBolusTime.getTime() != 0) {
|
||||
if (pump.lastBolusTime != 0) {
|
||||
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
|
||||
}
|
||||
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
@ -27,6 +26,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.TDDStatsActivity;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
|
@ -157,27 +157,24 @@ public class DanaRFragment extends SubscriberFragment {
|
|||
final String status = c.textStatus();
|
||||
if (activity != null) {
|
||||
activity.runOnUiThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (DanaRFragment.this) {
|
||||
() -> {
|
||||
synchronized (DanaRFragment.this) {
|
||||
|
||||
if (btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null)
|
||||
return;
|
||||
if (btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null)
|
||||
return;
|
||||
|
||||
if (c.sStatus == EventPumpStatusChanged.CONNECTING)
|
||||
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
||||
else if (c.sStatus == EventPumpStatusChanged.CONNECTED)
|
||||
btConnectionView.setText("{fa-bluetooth}");
|
||||
else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED)
|
||||
btConnectionView.setText("{fa-bluetooth-b}");
|
||||
if (c.sStatus == EventPumpStatusChanged.CONNECTING)
|
||||
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
||||
else if (c.sStatus == EventPumpStatusChanged.CONNECTED)
|
||||
btConnectionView.setText("{fa-bluetooth}");
|
||||
else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED)
|
||||
btConnectionView.setText("{fa-bluetooth-b}");
|
||||
|
||||
if (!status.equals("")) {
|
||||
pumpStatusView.setText(status);
|
||||
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
pumpStatusLayout.setVisibility(View.GONE);
|
||||
}
|
||||
if (!status.equals("")) {
|
||||
pumpStatusView.setText(status);
|
||||
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
pumpStatusLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,80 +207,77 @@ public class DanaRFragment extends SubscriberFragment {
|
|||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && basaBasalRateView != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (DanaRFragment.this) {
|
||||
if (!isBound()) return;
|
||||
activity.runOnUiThread(() -> {
|
||||
synchronized (DanaRFragment.this) {
|
||||
if (!isBound()) return;
|
||||
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
if (pump.lastConnection != 0) {
|
||||
Long agoMsec = System.currentTimeMillis() - pump.lastConnection;
|
||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.gs(R.string.minago), agoMin) + ")");
|
||||
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
|
||||
}
|
||||
if (pump.lastBolusTime.getTime() != 0) {
|
||||
Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime();
|
||||
double agoHours = agoMsec / 60d / 60d / 1000d;
|
||||
if (agoHours < 6) // max 6h back
|
||||
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime.getTime()) + " " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
|
||||
else lastBolusView.setText("");
|
||||
}
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
if (pump.lastConnection != 0) {
|
||||
Long agoMsec = System.currentTimeMillis() - pump.lastConnection;
|
||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.gs(R.string.minago), agoMin) + ")");
|
||||
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
|
||||
}
|
||||
if (pump.lastBolusTime != 0) {
|
||||
Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime;
|
||||
double agoHours = agoMsec / 60d / 60d / 1000d;
|
||||
if (agoHours < 6) // max 6h back
|
||||
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime) + " " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
|
||||
else lastBolusView.setText("");
|
||||
}
|
||||
|
||||
dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
|
||||
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
||||
// DanaRPlugin, DanaRKoreanPlugin
|
||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||
tempBasalView.setText(TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
|
||||
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
||||
// DanaRPlugin, DanaRKoreanPlugin
|
||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||
tempBasalView.setText(TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
// v2 plugin
|
||||
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||
tempBasalView.setText(TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (activeExtendedBolus != null) {
|
||||
extendedBolusView.setText(activeExtendedBolus.toString());
|
||||
} else {
|
||||
// v2 plugin
|
||||
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (tb != null) {
|
||||
tempBasalView.setText(tb.toStringFull());
|
||||
} else {
|
||||
extendedBolusView.setText("");
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
reservoirView.setText(DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + " / 300 U");
|
||||
SetWarnColor.setColorInverse(reservoirView, pump.reservoirRemainingUnits, 50d, 20d);
|
||||
batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}");
|
||||
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
|
||||
iobView.setText(pump.iob + " U");
|
||||
if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) {
|
||||
firmwareView.setText(String.format(MainApp.gs(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
|
||||
}
|
||||
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (activeExtendedBolus != null) {
|
||||
extendedBolusView.setText(activeExtendedBolus.toString());
|
||||
} else {
|
||||
extendedBolusView.setText("");
|
||||
}
|
||||
reservoirView.setText(DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + " / 300 U");
|
||||
SetWarnColor.setColorInverse(reservoirView, pump.reservoirRemainingUnits, 50d, 20d);
|
||||
batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}");
|
||||
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
|
||||
iobView.setText(pump.iob + " U");
|
||||
if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) {
|
||||
firmwareView.setText(String.format(MainApp.gs(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
|
||||
} else {
|
||||
firmwareView.setText("OLD");
|
||||
}
|
||||
basalStepView.setText("" + pump.basalStep);
|
||||
bolusStepView.setText("" + pump.bolusStep);
|
||||
serialNumberView.setText("" + pump.serialNumber);
|
||||
if (queueView != null) {
|
||||
Spanned status = ConfigBuilderPlugin.getCommandQueue().spannedStatus();
|
||||
if (status.toString().equals("")) {
|
||||
queueView.setVisibility(View.GONE);
|
||||
} else {
|
||||
firmwareView.setText("OLD");
|
||||
}
|
||||
basalStepView.setText("" + pump.basalStep);
|
||||
bolusStepView.setText("" + pump.bolusStep);
|
||||
serialNumberView.setText("" + pump.serialNumber);
|
||||
if (queueView != null) {
|
||||
Spanned status = ConfigBuilderPlugin.getCommandQueue().spannedStatus();
|
||||
if (status.toString().equals("")) {
|
||||
queueView.setVisibility(View.GONE);
|
||||
} else {
|
||||
queueView.setVisibility(View.VISIBLE);
|
||||
queueView.setText(status);
|
||||
}
|
||||
}
|
||||
//hide user options button if not an RS pump
|
||||
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP);
|
||||
if (isKorean) {
|
||||
danar_user_options.setVisibility(View.GONE);
|
||||
queueView.setVisibility(View.VISIBLE);
|
||||
queueView.setText(status);
|
||||
}
|
||||
}
|
||||
//hide user options button if not an RS pump
|
||||
boolean isKorean = DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||
if (isKorean) {
|
||||
danar_user_options.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -65,11 +65,11 @@ public class DanaRPump {
|
|||
|
||||
// Info
|
||||
public String serialNumber = "";
|
||||
public Date shippingDate = new Date(0);
|
||||
public long shippingDate = 0;
|
||||
public String shippingCountry = "";
|
||||
public boolean isNewPump = true;
|
||||
public int password = -1;
|
||||
public Date pumpTime = new Date(0);
|
||||
public long pumpTime = 0;
|
||||
|
||||
public static final int DOMESTIC_MODEL = 0x01;
|
||||
public static final int EXPORT_MODEL = 0x03;
|
||||
|
@ -98,7 +98,7 @@ public class DanaRPump {
|
|||
public int batteryRemaining;
|
||||
|
||||
public boolean bolusBlocked;
|
||||
public Date lastBolusTime = new Date(0);
|
||||
public long lastBolusTime = 0;
|
||||
public double lastBolusAmount;
|
||||
|
||||
public double currentBasal;
|
||||
|
@ -107,7 +107,7 @@ public class DanaRPump {
|
|||
public int tempBasalPercent;
|
||||
public int tempBasalRemainingMin;
|
||||
public int tempBasalTotalSec;
|
||||
public Date tempBasalStart;
|
||||
public long tempBasalStart;
|
||||
|
||||
public boolean isDualBolusInProgress;
|
||||
public boolean isExtendedInProgress;
|
||||
|
@ -115,7 +115,7 @@ public class DanaRPump {
|
|||
public double extendedBolusAmount;
|
||||
public double extendedBolusAbsoluteRate;
|
||||
public int extendedBolusSoFarInMinutes;
|
||||
public Date extendedBolusStart;
|
||||
public long extendedBolusStart;
|
||||
public int extendedBolusRemainingMinutes;
|
||||
public double extendedBolusDeliveredSoFar; //RS only
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.Dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -10,22 +8,12 @@ import android.view.ViewGroup;
|
|||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
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.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileGraph;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
|
|
|
@ -129,8 +129,8 @@ public class MessageBase {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static Date dateTimeFromBuff(byte[] buff, int offset) {
|
||||
Date date =
|
||||
public static long dateTimeFromBuff(byte[] buff, int offset) {
|
||||
return
|
||||
new Date(
|
||||
100 + intFromBuff(buff, offset, 1),
|
||||
intFromBuff(buff, offset + 1, 1) - 1,
|
||||
|
@ -138,8 +138,7 @@ public class MessageBase {
|
|||
intFromBuff(buff, offset + 3, 1),
|
||||
intFromBuff(buff, offset + 4, 1),
|
||||
0
|
||||
);
|
||||
return date;
|
||||
).getTime();
|
||||
}
|
||||
|
||||
public static synchronized long dateTimeSecFromBuff(byte[] buff, int offset) {
|
||||
|
@ -154,14 +153,13 @@ public class MessageBase {
|
|||
).getTime();
|
||||
}
|
||||
|
||||
public static Date dateFromBuff(byte[] buff, int offset) {
|
||||
Date date =
|
||||
public static long dateFromBuff(byte[] buff, int offset) {
|
||||
return
|
||||
new Date(
|
||||
100 + intFromBuff(buff, offset, 1),
|
||||
intFromBuff(buff, offset + 1, 1) - 1,
|
||||
intFromBuff(buff, offset + 2, 1)
|
||||
);
|
||||
return date;
|
||||
).getTime();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
|
|
|
@ -23,8 +23,8 @@ public class MsgHistoryAll extends MessageBase {
|
|||
@Override
|
||||
public void handleMessage(byte[] bytes) {
|
||||
byte recordCode = (byte) intFromBuff(bytes, 0, 1);
|
||||
Date date = dateFromBuff(bytes, 1); // 3 bytes
|
||||
Date datetime = dateTimeFromBuff(bytes, 1); // 5 bytes
|
||||
long date = dateFromBuff(bytes, 1); // 3 bytes
|
||||
long datetime = dateTimeFromBuff(bytes, 1); // 5 bytes
|
||||
long datetimewihtsec = dateTimeSecFromBuff(bytes, 1); // 6 bytes
|
||||
|
||||
double dailyBasal = intFromBuff(bytes, 4, 2) * 0.01d;
|
||||
|
@ -46,7 +46,7 @@ public class MsgHistoryAll extends MessageBase {
|
|||
|
||||
switch (recordCode) {
|
||||
case RecordTypes.RECORD_TYPE_BOLUS:
|
||||
danaRHistoryRecord.recordDate = datetime.getTime();
|
||||
danaRHistoryRecord.recordDate = datetime;
|
||||
switch (0xF0 & paramByte8) {
|
||||
case 0xA0:
|
||||
danaRHistoryRecord.bolusType = "DS";
|
||||
|
@ -73,7 +73,7 @@ public class MsgHistoryAll extends MessageBase {
|
|||
break;
|
||||
case RecordTypes.RECORD_TYPE_DAILY:
|
||||
messageType += "dailyinsulin";
|
||||
danaRHistoryRecord.recordDate = date.getTime();
|
||||
danaRHistoryRecord.recordDate = date;
|
||||
danaRHistoryRecord.recordDailyBasal = dailyBasal;
|
||||
danaRHistoryRecord.recordDailyBolus = dailyBolus;
|
||||
break;
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Date;
|
|||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class MsgSettingPumpTime extends MessageBase {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
@ -18,7 +19,7 @@ public class MsgSettingPumpTime extends MessageBase {
|
|||
}
|
||||
|
||||
public void handleMessage(byte[] bytes) {
|
||||
Date time =
|
||||
long time =
|
||||
new Date(
|
||||
100 + intFromBuff(bytes, 5, 1),
|
||||
intFromBuff(bytes, 4, 1) - 1,
|
||||
|
@ -26,10 +27,10 @@ public class MsgSettingPumpTime extends MessageBase {
|
|||
intFromBuff(bytes, 2, 1),
|
||||
intFromBuff(bytes, 1, 1),
|
||||
intFromBuff(bytes, 0, 1)
|
||||
);
|
||||
).getTime();
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Pump time: " + time + " Phone time: " + new Date());
|
||||
log.debug("Pump time: " + DateUtil.dateAndTimeFullString(time) + " Phone time: " + new Date());
|
||||
|
||||
DanaRPump.getInstance().pumpTime = time;
|
||||
}
|
||||
|
|
|
@ -5,14 +5,13 @@ import android.support.annotation.NonNull;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class MsgStatusBolusExtended extends MessageBase {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
@ -36,7 +35,7 @@ public class MsgStatusBolusExtended extends MessageBase {
|
|||
|
||||
int extendedBolusSoFarInMinutes = extendedBolusSoFarInSecs / 60;
|
||||
double extendedBolusAbsoluteRate = isExtendedInProgress ? extendedBolusAmount / extendedBolusMinutes * 60 : 0d;
|
||||
Date extendedBolusStart = isExtendedInProgress ? getDateFromSecAgo(extendedBolusSoFarInSecs) : new Date(0);
|
||||
long extendedBolusStart = isExtendedInProgress ? getDateFromSecAgo(extendedBolusSoFarInSecs) : 0;
|
||||
int extendedBolusRemainingMinutes = extendedBolusMinutes - extendedBolusSoFarInMinutes;
|
||||
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
@ -56,14 +55,14 @@ public class MsgStatusBolusExtended extends MessageBase {
|
|||
log.debug("Extended bolus amount: " + extendedBolusAmount);
|
||||
log.debug("Extended bolus so far in minutes: " + extendedBolusSoFarInMinutes);
|
||||
log.debug("Extended bolus absolute rate: " + extendedBolusAbsoluteRate);
|
||||
log.debug("Extended bolus start: " + extendedBolusStart);
|
||||
log.debug("Extended bolus start: " + DateUtil.dateAndTimeFullString(extendedBolusStart));
|
||||
log.debug("Extended bolus remaining minutes: " + extendedBolusRemainingMinutes);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Date getDateFromSecAgo(int tempBasalAgoSecs) {
|
||||
return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
|
||||
private long getDateFromSecAgo(int tempBasalAgoSecs) {
|
||||
return (long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000;
|
||||
}
|
||||
|
||||
public static void updateExtendedBolusInDB() {
|
||||
|
@ -76,12 +75,12 @@ public class MsgStatusBolusExtended extends MessageBase {
|
|||
if (pump.isExtendedInProgress) {
|
||||
if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) {
|
||||
// Close current extended
|
||||
ExtendedBolus exStop = new ExtendedBolus(pump.extendedBolusStart.getTime() - 1000);
|
||||
ExtendedBolus exStop = new ExtendedBolus(pump.extendedBolusStart - 1000);
|
||||
exStop.source = Source.USER;
|
||||
treatmentsInterface.addToHistoryExtendedBolus(exStop);
|
||||
// Create new
|
||||
ExtendedBolus newExtended = new ExtendedBolus();
|
||||
newExtended.date = pump.extendedBolusStart.getTime();
|
||||
newExtended.date = pump.extendedBolusStart;
|
||||
newExtended.insulin = pump.extendedBolusAmount;
|
||||
newExtended.durationInMinutes = pump.extendedBolusMinutes;
|
||||
newExtended.source = Source.USER;
|
||||
|
@ -97,7 +96,7 @@ public class MsgStatusBolusExtended extends MessageBase {
|
|||
if (pump.isExtendedInProgress) {
|
||||
// Create new
|
||||
ExtendedBolus newExtended = new ExtendedBolus();
|
||||
newExtended.date = pump.extendedBolusStart.getTime();
|
||||
newExtended.date = pump.extendedBolusStart;
|
||||
newExtended.insulin = pump.extendedBolusAmount;
|
||||
newExtended.durationInMinutes = pump.extendedBolusMinutes;
|
||||
newExtended.source = Source.USER;
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.support.annotation.NonNull;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
@ -33,7 +31,7 @@ public class MsgStatusTempBasal extends MessageBase {
|
|||
else tempBasalTotalSec = intFromBuff(bytes, 2, 1) * 60 * 60;
|
||||
int tempBasalRunningSeconds = intFromBuff(bytes, 3, 3);
|
||||
int tempBasalRemainingMin = (tempBasalTotalSec - tempBasalRunningSeconds) / 60;
|
||||
Date tempBasalStart = isTempBasalInProgress ? getDateFromTempBasalSecAgo(tempBasalRunningSeconds) : new Date(0);
|
||||
long tempBasalStart = isTempBasalInProgress ? getDateFromTempBasalSecAgo(tempBasalRunningSeconds) : 0;
|
||||
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.isTempBasalInProgress = isTempBasalInProgress;
|
||||
|
@ -55,8 +53,8 @@ public class MsgStatusTempBasal extends MessageBase {
|
|||
}
|
||||
|
||||
@NonNull
|
||||
private Date getDateFromTempBasalSecAgo(int tempBasalAgoSecs) {
|
||||
return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
|
||||
private long getDateFromTempBasalSecAgo(int tempBasalAgoSecs) {
|
||||
return (long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000;
|
||||
}
|
||||
|
||||
public static void updateTempBasalInDB() {
|
||||
|
@ -68,11 +66,11 @@ public class MsgStatusTempBasal extends MessageBase {
|
|||
if (danaRPump.isTempBasalInProgress) {
|
||||
if (tempBasal.percentRate != danaRPump.tempBasalPercent) {
|
||||
// Close current temp basal
|
||||
TemporaryBasal tempStop = new TemporaryBasal().date(danaRPump.tempBasalStart.getTime() - 1000).source(Source.USER);
|
||||
TemporaryBasal tempStop = new TemporaryBasal().date(danaRPump.tempBasalStart - 1000).source(Source.USER);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||
// Create new
|
||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
||||
.date(danaRPump.tempBasalStart.getTime())
|
||||
.date(danaRPump.tempBasalStart)
|
||||
.percent(danaRPump.tempBasalPercent)
|
||||
.duration(danaRPump.tempBasalTotalSec / 60)
|
||||
.source(Source.USER);
|
||||
|
@ -87,7 +85,7 @@ public class MsgStatusTempBasal extends MessageBase {
|
|||
if (danaRPump.isTempBasalInProgress) {
|
||||
// Create new
|
||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
||||
.date(danaRPump.tempBasalStart.getTime())
|
||||
.date(danaRPump.tempBasalStart)
|
||||
.percent(danaRPump.tempBasalPercent)
|
||||
.duration(danaRPump.tempBasalTotalSec / 60)
|
||||
.source(Source.USER);
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
|
@ -63,7 +64,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
|||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.queue.commands.Command;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||
|
@ -109,35 +110,32 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
if (mConnectionInProgress)
|
||||
return;
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mConnectionInProgress = true;
|
||||
getBTSocketForSelectedPump();
|
||||
if (mRfcommSocket == null || mBTDevice == null) {
|
||||
mConnectionInProgress = false;
|
||||
return; // Device not found
|
||||
}
|
||||
|
||||
try {
|
||||
mRfcommSocket.connect();
|
||||
} catch (IOException e) {
|
||||
//log.error("Unhandled exception", e);
|
||||
if (e.getMessage().contains("socket closed")) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (isConnected()) {
|
||||
if (mSerialIOThread != null) {
|
||||
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
||||
}
|
||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
mConnectionInProgress = true;
|
||||
getBTSocketForSelectedPump();
|
||||
if (mRfcommSocket == null || mBTDevice == null) {
|
||||
mConnectionInProgress = false;
|
||||
return; // Device not found
|
||||
}
|
||||
|
||||
try {
|
||||
mRfcommSocket.connect();
|
||||
} catch (IOException e) {
|
||||
//log.error("Unhandled exception", e);
|
||||
if (e.getMessage().contains("socket closed")) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (isConnected()) {
|
||||
if (mSerialIOThread != null) {
|
||||
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
||||
}
|
||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
|
||||
}
|
||||
|
||||
mConnectionInProgress = false;
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
@ -193,13 +191,13 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
long timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
if (Math.abs(timeDiff) > 10) {
|
||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
}
|
||||
|
@ -344,13 +342,13 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
ConfigBuilderPlugin.getCommandQueue().independentConnect("bolusingInterrupted", new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mDanaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
|
||||
if (mDanaRPump.lastBolusTime > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
|
||||
t.insulin = mDanaRPump.lastBolusAmount;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount);
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString());
|
||||
log.debug("Bolus amount in history too old: " + DateUtil.dateAndTimeFullString(mDanaRPump.lastBolusTime));
|
||||
}
|
||||
synchronized (o) {
|
||||
o.notify();
|
||||
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm;
|
|||
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.events.EventRefreshGui;
|
||||
|
|
|
@ -191,13 +191,13 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
long timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
if (Math.abs(timeDiff) > 10) {
|
||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
}
|
||||
|
@ -282,7 +282,6 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
if (amount > 0) {
|
||||
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
|
||||
long bolusStart = System.currentTimeMillis();
|
||||
|
||||
if (!stop.stopped) {
|
||||
mSerialIOThread.sendMessage(start);
|
||||
|
|
|
@ -16,8 +16,6 @@ import org.json.JSONObject;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
@ -380,8 +378,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date lastDataTime() {
|
||||
return new Date(DanaRPump.getInstance().lastConnection);
|
||||
public long lastDataTime() {
|
||||
return DanaRPump.getInstance().lastConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -725,8 +723,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
status.put("timestamp", DateUtil.toISOString(pump.lastConnection));
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
extended.put("PumpIOB", pump.iob);
|
||||
if (pump.lastBolusTime.getTime() != 0) {
|
||||
extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
|
||||
if (pump.lastBolusTime != 0) {
|
||||
extended.put("LastBolus", DateUtil.dateAndTimeFullString(pump.lastBolusTime));
|
||||
extended.put("LastBolusAmount", pump.lastBolusAmount);
|
||||
}
|
||||
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||
|
@ -777,7 +775,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||
ret += "LastConn: " + agoMin + " minago\n";
|
||||
}
|
||||
if (pump.lastBolusTime.getTime() != 0) {
|
||||
if (pump.lastBolusTime != 0) {
|
||||
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
|
||||
}
|
||||
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||
|
|
|
@ -142,14 +142,13 @@ public class DanaRS_Packet {
|
|||
return new String(strbuff, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static Date dateFromBuff(byte[] buff, int offset) {
|
||||
Date date =
|
||||
public static long dateFromBuff(byte[] buff, int offset) {
|
||||
return
|
||||
new Date(
|
||||
100 + byteArrayToInt(getBytes(buff, offset, 1)),
|
||||
byteArrayToInt(getBytes(buff, offset + 1, 1)) - 1,
|
||||
byteArrayToInt(getBytes(buff, offset + 2, 1))
|
||||
);
|
||||
return date;
|
||||
).getTime();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
|
|
|
@ -7,10 +7,9 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
@ -55,7 +54,7 @@ public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet
|
|||
dataSize = 2;
|
||||
int runningMin = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
int tempBasalRemainingMin = (pump.tempBasalTotalSec - runningMin * 60) / 60;
|
||||
Date tempBasalStart = pump.isTempBasalInProgress ? getDateFromTempBasalSecAgo(runningMin * 60) : new Date(0);
|
||||
long tempBasalStart = pump.isTempBasalInProgress ? getDateFromTempBasalSecAgo(runningMin * 60) : 0;
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Error code: " + error);
|
||||
|
@ -64,7 +63,7 @@ public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet
|
|||
log.debug("Current temp basal percent: " + pump.tempBasalPercent);
|
||||
log.debug("Current temp basal remaining min: " + tempBasalRemainingMin);
|
||||
log.debug("Current temp basal total sec: " + pump.tempBasalTotalSec);
|
||||
log.debug("Current temp basal start: " + tempBasalStart);
|
||||
log.debug("Current temp basal start: " + DateUtil.dateAndTimeFullString(tempBasalStart));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,8 +73,8 @@ public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet
|
|||
}
|
||||
|
||||
@NonNull
|
||||
private Date getDateFromTempBasalSecAgo(int tempBasalAgoSecs) {
|
||||
return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
|
||||
private long getDateFromTempBasalSecAgo(int tempBasalAgoSecs) {
|
||||
return (long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Date;
|
|||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packet {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
@ -36,14 +37,16 @@ public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packe
|
|||
dataSize = 2;
|
||||
pump.initialBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
|
||||
pump.lastBolusTime = new Date(); // it doesn't provide day only hour+min, workaround: expecting today
|
||||
Date lbt = new Date(); // it doesn't provide day only hour+min, workaround: expecting today
|
||||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
pump.lastBolusTime.setHours(byteArrayToInt(getBytes(data, dataIndex, dataSize)));
|
||||
lbt.setHours(byteArrayToInt(getBytes(data, dataIndex, dataSize)));
|
||||
|
||||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
pump.lastBolusTime.setMinutes(byteArrayToInt(getBytes(data, dataIndex, dataSize)));
|
||||
lbt.setMinutes(byteArrayToInt(getBytes(data, dataIndex, dataSize)));
|
||||
|
||||
pump.lastBolusTime = lbt.getTime();
|
||||
|
||||
dataIndex += dataSize;
|
||||
dataSize = 2;
|
||||
|
@ -56,13 +59,13 @@ public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packe
|
|||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
if ( error != 0)
|
||||
if (error != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
log.debug("BolusType: " + bolusType);
|
||||
log.debug("Initial bolus amount: " + pump.initialBolusAmount + " U");
|
||||
log.debug("Last bolus time: " + pump.lastBolusTime.toLocaleString());
|
||||
log.debug("Last bolus time: " + DateUtil.dateAndTimeFullString(pump.lastBolusTime));
|
||||
log.debug("Last bolus amount: " + pump.lastBolusAmount);
|
||||
log.debug("Max bolus: " + pump.maxBolus + " U");
|
||||
log.debug("Bolus step: " + pump.bolusStep + " U");
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class DanaRS_Packet_General_Get_Shipping_Information extends DanaRS_Packet {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
@ -20,7 +21,7 @@ public class DanaRS_Packet_General_Get_Shipping_Information extends DanaRS_Packe
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
if (data.length < 18){
|
||||
if (data.length < 18) {
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ public class DanaRS_Packet_General_Get_Shipping_Information extends DanaRS_Packe
|
|||
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Serial number: " + pump.serialNumber);
|
||||
log.debug("Shipping date: " + pump.shippingDate);
|
||||
log.debug("Shipping date: " + DateUtil.dateAndTimeString(pump.shippingDate));
|
||||
log.debug("Shipping country: " + pump.shippingCountry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
|
|||
totalCount = 0;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_(Date from) {
|
||||
public DanaRS_Packet_History_(long from) {
|
||||
this();
|
||||
GregorianCalendar cal = new GregorianCalendar();
|
||||
if (from.getTime() != 0)
|
||||
cal.setTime(from);
|
||||
if (from != 0)
|
||||
cal.setTimeInMillis(from);
|
||||
else
|
||||
cal.set(2000, 0, 1, 0, 0, 0);
|
||||
year = cal.get(Calendar.YEAR) - 1900 - 100;
|
||||
|
|
|
@ -17,7 +17,7 @@ public class DanaRS_Packet_History_Alarm extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Alarm(Date from) {
|
||||
public DanaRS_Packet_History_Alarm(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_All_History extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_All_History extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_All_History(Date from) {
|
||||
public DanaRS_Packet_History_All_History(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Basal extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Basal extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Basal(Date from) {
|
||||
public DanaRS_Packet_History_Basal(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Blood_Glucose extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Blood_Glucose extends DanaRS_Packet_History_
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Blood_Glucose(Date from) {
|
||||
public DanaRS_Packet_History_Blood_Glucose(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Bolus extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Bolus extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Bolus(Date from) {
|
||||
public DanaRS_Packet_History_Bolus(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Carbohydrate extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Carbohydrate extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Carbohydrate(Date from) {
|
||||
public DanaRS_Packet_History_Carbohydrate(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Daily extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Daily extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Daily(Date from) {
|
||||
public DanaRS_Packet_History_Daily(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Prime extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Prime extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Prime(Date from) {
|
||||
public DanaRS_Packet_History_Prime(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Refill extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Refill extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Refill(Date from) {
|
||||
public DanaRS_Packet_History_Refill(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Suspend extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Suspend extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Suspend(Date from) {
|
||||
public DanaRS_Packet_History_Suspend(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.cozmo.danar.util.BleCommandUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class DanaRS_Packet_History_Temporary extends DanaRS_Packet_History_ {
|
||||
|
@ -17,7 +15,7 @@ public class DanaRS_Packet_History_Temporary extends DanaRS_Packet_History_ {
|
|||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY;
|
||||
}
|
||||
|
||||
public DanaRS_Packet_History_Temporary(Date from) {
|
||||
public DanaRS_Packet_History_Temporary(long from) {
|
||||
super(from);
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
|
|
@ -48,7 +48,7 @@ public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet {
|
|||
int sec = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
|
||||
Date time = new Date(100 + year, month - 1, day, hour, min, sec);
|
||||
DanaRPump.getInstance().pumpTime = time;
|
||||
DanaRPump.getInstance().pumpTime = time.getTime();
|
||||
|
||||
if ( year == month && month == day && day == hour && hour == min && min == sec && sec == 1)
|
||||
failed = true;
|
||||
|
|
|
@ -156,7 +156,7 @@ public class DanaRSService extends Service {
|
|||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
||||
|
||||
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
if (Math.abs(timeDiff) > 3) {
|
||||
|
@ -181,7 +181,7 @@ public class DanaRSService extends Service {
|
|||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
||||
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public class DanaRSService extends Service {
|
|||
} else {
|
||||
msg = new DanaRS_Packet_APS_History_Events(lastHistoryFetched);
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString());
|
||||
log.debug("Loading event history from: " +DateUtil.dateAndTimeFullString(lastHistoryFetched));
|
||||
}
|
||||
bleComm.sendMessage(msg);
|
||||
while (!msg.done && bleComm.isConnected()) {
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.support.annotation.NonNull;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
||||
|
@ -33,7 +31,7 @@ public class MsgStatusBolusExtended_v2 extends MessageBase {
|
|||
|
||||
int extendedBolusSoFarInMinutes = extendedBolusSoFarInSecs / 60;
|
||||
double extendedBolusAbsoluteRate = isExtendedInProgress ? extendedBolusAmount / extendedBolusMinutes * 60 : 0d;
|
||||
Date extendedBolusStart = isExtendedInProgress ? getDateFromSecAgo(extendedBolusSoFarInSecs) : new Date(0);
|
||||
long extendedBolusStart = isExtendedInProgress ? getDateFromSecAgo(extendedBolusSoFarInSecs) : 0;
|
||||
int extendedBolusRemainingMinutes = extendedBolusMinutes - extendedBolusSoFarInMinutes;
|
||||
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
@ -57,8 +55,8 @@ public class MsgStatusBolusExtended_v2 extends MessageBase {
|
|||
}
|
||||
|
||||
@NonNull
|
||||
private Date getDateFromSecAgo(int tempBasalAgoSecs) {
|
||||
return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
|
||||
private long getDateFromSecAgo(int tempBasalAgoSecs) {
|
||||
return (long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,10 @@ import android.support.annotation.NonNull;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class MsgStatusTempBasal_v2 extends MessageBase {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
@ -31,7 +30,7 @@ public class MsgStatusTempBasal_v2 extends MessageBase {
|
|||
else tempBasalTotalSec = intFromBuff(bytes, 2, 1) * 60 * 60;
|
||||
int tempBasalRunningSeconds = intFromBuff(bytes, 3, 3);
|
||||
int tempBasalRemainingMin = (tempBasalTotalSec - tempBasalRunningSeconds) / 60;
|
||||
Date tempBasalStart = isTempBasalInProgress ? getDateFromTempBasalSecAgo(tempBasalRunningSeconds) : new Date(0);
|
||||
long tempBasalStart = isTempBasalInProgress ? getDateFromTempBasalSecAgo(tempBasalRunningSeconds) : 0;
|
||||
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.isTempBasalInProgress = isTempBasalInProgress;
|
||||
|
@ -46,13 +45,13 @@ public class MsgStatusTempBasal_v2 extends MessageBase {
|
|||
log.debug("Current temp basal percent: " + tempBasalPercent);
|
||||
log.debug("Current temp basal remaining min: " + tempBasalRemainingMin);
|
||||
log.debug("Current temp basal total sec: " + tempBasalTotalSec);
|
||||
log.debug("Current temp basal start: " + tempBasalStart);
|
||||
log.debug("Current temp basal start: " + DateUtil.dateAndTimeFullString(tempBasalStart));
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Date getDateFromTempBasalSecAgo(int tempBasalAgoSecs) {
|
||||
return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
|
||||
private long getDateFromTempBasalSecAgo(int tempBasalAgoSecs) {
|
||||
return (long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -133,35 +133,32 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
if (mConnectionInProgress)
|
||||
return;
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mConnectionInProgress = true;
|
||||
getBTSocketForSelectedPump();
|
||||
if (mRfcommSocket == null || mBTDevice == null) {
|
||||
mConnectionInProgress = false;
|
||||
return; // Device not found
|
||||
}
|
||||
|
||||
try {
|
||||
mRfcommSocket.connect();
|
||||
} catch (IOException e) {
|
||||
//log.error("Unhandled exception", e);
|
||||
if (e.getMessage().contains("socket closed")) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (isConnected()) {
|
||||
if (mSerialIOThread != null) {
|
||||
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
||||
}
|
||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
mConnectionInProgress = true;
|
||||
getBTSocketForSelectedPump();
|
||||
if (mRfcommSocket == null || mBTDevice == null) {
|
||||
mConnectionInProgress = false;
|
||||
return; // Device not found
|
||||
}
|
||||
|
||||
try {
|
||||
mRfcommSocket.connect();
|
||||
} catch (IOException e) {
|
||||
//log.error("Unhandled exception", e);
|
||||
if (e.getMessage().contains("socket closed")) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (isConnected()) {
|
||||
if (mSerialIOThread != null) {
|
||||
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
||||
}
|
||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
|
||||
}
|
||||
|
||||
mConnectionInProgress = false;
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
@ -203,7 +200,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
long timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
if (Math.abs(timeDiff) > 3) {
|
||||
|
@ -228,7 +225,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
}
|
||||
|
@ -269,7 +266,6 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean tempBasal(int percent, int durationInHours) {
|
||||
|
@ -479,7 +475,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
} else {
|
||||
msg = new MsgHistoryEvents_v2(lastHistoryFetched);
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString());
|
||||
log.debug("Loading event history from: " + DateUtil.dateAndTimeFullString(lastHistoryFetched));
|
||||
}
|
||||
mSerialIOThread.sendMessage(msg);
|
||||
while (!msg.done && mRfcommSocket.isConnected()) {
|
||||
|
|
|
@ -103,7 +103,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
private static Logger log = LoggerFactory.getLogger(InsightPlugin.class);
|
||||
private StatusTaskRunner.Result statusResult;
|
||||
private long statusResultTime = -1;
|
||||
private Date lastDataTime = new Date(0);
|
||||
private long lastDataTime = 0;
|
||||
private boolean fauxTBRcancel = true;
|
||||
private PumpDescription pumpDescription = new PumpDescription();
|
||||
private double basalRate = 0;
|
||||
|
@ -407,7 +407,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date lastDataTime() {
|
||||
public long lastDataTime() {
|
||||
return lastDataTime;
|
||||
}
|
||||
|
||||
|
@ -877,7 +877,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
private <T> T fetchTaskRunner(TaskRunner taskRunner, Class<T> resultType) throws Exception {
|
||||
try {
|
||||
T result = (T) taskRunner.fetchAndWaitUsingLatch(BUSY_WAIT_TIME);
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log("Error while fetching " + taskRunner.getClass().getSimpleName() + ": " + e.getClass().getSimpleName());
|
||||
|
@ -888,7 +888,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
private <T extends AppLayerMessage> T fetchSingleMessage(AppLayerMessage message, Class<T> resultType) throws Exception {
|
||||
try {
|
||||
T result = (T) new SingleMessageTaskRunner(connector.getServiceConnector(), message).fetchAndWaitUsingLatch(BUSY_WAIT_TIME);
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log("Error while fetching " + message.getClass().getSimpleName() + ": " + e.getClass().getSimpleName());
|
||||
|
|
|
@ -5,8 +5,6 @@ import org.json.JSONObject;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
@ -120,8 +118,8 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date lastDataTime() {
|
||||
return new Date();
|
||||
public long lastDataTime() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,8 +7,6 @@ import org.json.JSONObject;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
@ -53,7 +51,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
static Integer batteryPercent = 50;
|
||||
static Integer reservoirInUnits = 50;
|
||||
|
||||
private Date lastDataTime = new Date(0);
|
||||
private long lastDataTime = 0;
|
||||
|
||||
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
||||
|
||||
|
@ -153,7 +151,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
public void connect(String reason) {
|
||||
if (!Config.NSCLIENT)
|
||||
NSUpload.uploadDeviceStatus();
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,12 +164,12 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
|
||||
@Override
|
||||
public void getPumpStatus() {
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = true;
|
||||
|
@ -186,7 +184,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date lastDataTime() {
|
||||
public long lastDataTime() {
|
||||
return lastDataTime;
|
||||
}
|
||||
|
||||
|
@ -227,7 +225,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
return result;
|
||||
}
|
||||
|
@ -255,7 +253,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Setting temp basal absolute: " + result);
|
||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -283,7 +281,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Settings temp basal percent: " + result);
|
||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -307,7 +305,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Setting extended bolus: " + result);
|
||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -326,7 +324,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
log.debug("Canceling temp basal: " + result);
|
||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||
}
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -345,7 +343,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Canceling extended bolus: " + result);
|
||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||
lastDataTime = new Date();
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class SmsCommunicatorFragment extends SubscriberFragment {
|
|||
public void run() {
|
||||
class CustomComparator implements Comparator<SmsCommunicatorPlugin.Sms> {
|
||||
public int compare(SmsCommunicatorPlugin.Sms object1, SmsCommunicatorPlugin.Sms object2) {
|
||||
return (int) (object1.date.getTime() - object2.date.getTime());
|
||||
return (int) (object1.date - object2.date);
|
||||
}
|
||||
}
|
||||
Collections.sort(SmsCommunicatorPlugin.getPlugin().messages, new CustomComparator());
|
||||
|
|
|
@ -73,7 +73,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
class Sms {
|
||||
String phoneNumber;
|
||||
String text;
|
||||
Date date;
|
||||
long date;
|
||||
boolean received = false;
|
||||
boolean sent = false;
|
||||
boolean processed = false;
|
||||
|
@ -87,18 +87,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
Sms(SmsMessage message) {
|
||||
phoneNumber = message.getOriginatingAddress();
|
||||
text = message.getMessageBody();
|
||||
date = new Date(message.getTimestampMillis());
|
||||
date = message.getTimestampMillis();
|
||||
received = true;
|
||||
}
|
||||
|
||||
Sms(String phoneNumber, String text, Date date) {
|
||||
Sms(String phoneNumber, String text, long date) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.text = text;
|
||||
this.date = date;
|
||||
sent = true;
|
||||
}
|
||||
|
||||
Sms(String phoneNumber, String text, Date date, String confirmCode) {
|
||||
Sms(String phoneNumber, String text, long date, String confirmCode) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.text = text;
|
||||
this.date = date;
|
||||
|
@ -230,7 +230,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
+ MainApp.gs(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
||||
+ MainApp.gs(R.string.sms_basal) + " " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
|
||||
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
receivedSms.processed = true;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Bg"));
|
||||
break;
|
||||
|
@ -248,7 +248,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
|
||||
String reply = MainApp.gs(R.string.smscommunicator_loophasbeendisabled) + " " +
|
||||
MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||
reply = MainApp.gs(R.string.smscommunicator_loophasbeenenabled);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START"));
|
||||
}
|
||||
receivedSms.processed = true;
|
||||
|
@ -278,7 +278,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
} else {
|
||||
reply = MainApp.gs(R.string.smscommunicator_loopisdisabled);
|
||||
}
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
receivedSms.processed = true;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Status"));
|
||||
|
@ -288,7 +288,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_RESUME"));
|
||||
NSUpload.uploadOpenAPSOffline(0);
|
||||
reply = MainApp.gs(R.string.smscommunicator_loopresumed);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Resume"));
|
||||
break;
|
||||
case "SUSPEND":
|
||||
|
@ -298,18 +298,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
duration = Math.min(180, duration);
|
||||
if (duration == 0) {
|
||||
reply = MainApp.gs(R.string.smscommunicator_wrongduration);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else if (remoteCommandsAllowed) {
|
||||
passCode = generatePasscode();
|
||||
reply = String.format(MainApp.gs(R.string.smscommunicator_suspendreplywithcode), duration, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(suspendWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
sendSMS(suspendWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis(), passCode));
|
||||
suspendWaitingForConfirmation.duration = duration;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Suspend"));
|
||||
} else {
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotecommandnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
||||
List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(restartNSClient, 0);
|
||||
reply = "TERATMENTS REFRESH " + q.size() + " receivers";
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
receivedSms.processed = true;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Treatments_Refresh"));
|
||||
break;
|
||||
|
@ -337,7 +337,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
||||
List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(restartNSClient, 0);
|
||||
reply = "NSCLIENT RESTART " + q.size() + " receivers";
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
receivedSms.processed = true;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Nsclient_Restart"));
|
||||
break;
|
||||
|
@ -352,11 +352,11 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
if (result.success) {
|
||||
if (pump != null) {
|
||||
String reply = pump.shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
} else {
|
||||
String reply = MainApp.gs(R.string.readstatusfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -371,18 +371,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
reply = String.format(MainApp.gs(R.string.smscommunicator_basalstopreplywithcode), passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(cancelTempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
sendSMS(cancelTempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis(), passCode));
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Basal"));
|
||||
} else {
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotebasalnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
} else {
|
||||
tempBasal = SafeParse.stringToDouble(splited[1]);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
reply = MainApp.gs(R.string.noprofile);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else {
|
||||
tempBasal = MainApp.getConstraintChecker().applyBasalConstraints(new Constraint<>(tempBasal), profile).value();
|
||||
if (remoteCommandsAllowed) {
|
||||
|
@ -390,12 +390,12 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
reply = String.format(MainApp.gs(R.string.smscommunicator_basalreplywithcode), tempBasal, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(tempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
sendSMS(tempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis(), passCode));
|
||||
tempBasalWaitingForConfirmation.tempBasal = tempBasal;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Basal"));
|
||||
} else {
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotebasalnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -404,10 +404,10 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
case "BOLUS":
|
||||
if (System.currentTimeMillis() - lastRemoteBolusTime.getTime() < Constants.remoteBolusMinDistance) {
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotebolusnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else if (ConfigBuilderPlugin.getActivePump().isSuspended()) {
|
||||
reply = MainApp.gs(R.string.pumpsuspended);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else if (splited.length > 1) {
|
||||
amount = SafeParse.stringToDouble(splited[1]);
|
||||
amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
|
||||
|
@ -416,12 +416,12 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
reply = String.format(MainApp.gs(R.string.smscommunicator_bolusreplywithcode), amount, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(bolusWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
sendSMS(bolusWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis(), passCode));
|
||||
bolusWaitingForConfirmation.bolusRequested = amount;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Bolus"));
|
||||
} else {
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotebolusnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -433,18 +433,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
reply = String.format(MainApp.gs(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(calibrationWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
sendSMS(calibrationWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis(), passCode));
|
||||
calibrationWaitingForConfirmation.calibrationRequested = amount;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Cal"));
|
||||
} else {
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotecalibrationnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: // expect passCode here
|
||||
if (bolusWaitingForConfirmation != null && !bolusWaitingForConfirmation.processed &&
|
||||
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - bolusWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - bolusWaitingForConfirmation.date < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
bolusWaitingForConfirmation.processed = true;
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = bolusWaitingForConfirmation.bolusRequested;
|
||||
|
@ -459,18 +459,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
if (pump != null)
|
||||
reply += "\n" + pump.shortStatus(true);
|
||||
lastRemoteBolusTime = new Date();
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else {
|
||||
SystemClock.sleep(T.secs(60).msecs()); // wait some time to get history
|
||||
String reply = MainApp.gs(R.string.smscommunicator_bolusfailed);
|
||||
if (pump != null)
|
||||
reply += "\n" + pump.shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (tempBasalWaitingForConfirmation != null && !tempBasalWaitingForConfirmation.processed &&
|
||||
tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - tempBasalWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - tempBasalWaitingForConfirmation.date < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
tempBasalWaitingForConfirmation.processed = true;
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile != null)
|
||||
|
@ -480,16 +480,16 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
if (result.success) {
|
||||
String reply = String.format(MainApp.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else {
|
||||
String reply = MainApp.gs(R.string.smscommunicator_tempbasalfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (cancelTempBasalWaitingForConfirmation != null && !cancelTempBasalWaitingForConfirmation.processed &&
|
||||
cancelTempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - cancelTempBasalWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
cancelTempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - cancelTempBasalWaitingForConfirmation.date < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
cancelTempBasalWaitingForConfirmation.processed = true;
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
|
@ -497,27 +497,27 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
if (result.success) {
|
||||
String reply = MainApp.gs(R.string.smscommunicator_tempbasalcanceled);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else {
|
||||
String reply = MainApp.gs(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (calibrationWaitingForConfirmation != null && !calibrationWaitingForConfirmation.processed &&
|
||||
calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - calibrationWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - calibrationWaitingForConfirmation.date < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
calibrationWaitingForConfirmation.processed = true;
|
||||
boolean result = XdripCalibrations.sendIntent(calibrationWaitingForConfirmation.calibrationRequested);
|
||||
if (result) {
|
||||
reply = MainApp.gs(R.string.smscommunicator_calibrationsent);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else {
|
||||
reply = MainApp.gs(R.string.smscommunicator_calibrationfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
} else if (suspendWaitingForConfirmation != null && !suspendWaitingForConfirmation.processed &&
|
||||
suspendWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - suspendWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
suspendWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - suspendWaitingForConfirmation.date < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
suspendWaitingForConfirmation.processed = true;
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
|
@ -528,16 +528,16 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
||||
String reply = MainApp.gs(R.string.smscommunicator_loopsuspended) + " " +
|
||||
MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
} else {
|
||||
String reply = MainApp.gs(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.gs(R.string.smscommunicator_unknowncommand), new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.gs(R.string.smscommunicator_unknowncommand), System.currentTimeMillis()));
|
||||
}
|
||||
resetWaitingMessages();
|
||||
break;
|
||||
|
@ -549,7 +549,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
|
||||
public void sendNotificationToAllNumbers(String text) {
|
||||
for (int i = 0; i < allowedNumbers.size(); i++) {
|
||||
Sms sms = new Sms(allowedNumbers.get(i), text, new Date());
|
||||
Sms sms = new Sms(allowedNumbers.get(i), text, System.currentTimeMillis());
|
||||
sendSMS(sms);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ import com.crashlytics.android.answers.CustomEvent;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -65,8 +63,8 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
|||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (pump != null && profile != null) {
|
||||
Date lastConnection = pump.lastDataTime();
|
||||
boolean isStatusOutdated = lastConnection.getTime() + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis();
|
||||
long lastConnection = pump.lastDataTime();
|
||||
boolean isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis();
|
||||
boolean isBasalOutdated = Math.abs(profile.getBasal() - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep;
|
||||
|
||||
if (L.isEnabled(L.CORE))
|
||||
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.utils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
@ -35,8 +33,8 @@ public class LocalAlertUtils {
|
|||
return T.mins(SP.getInt(MainApp.gs(R.string.key_pump_unreachable_threshold), 30)).msecs();
|
||||
}
|
||||
|
||||
public static void checkPumpUnreachableAlarm(Date lastConnection, boolean isStatusOutdated) {
|
||||
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
|
||||
public static void checkPumpUnreachableAlarm(long lastConnection, boolean isStatusOutdated) {
|
||||
boolean alarmTimeoutExpired = lastConnection + pumpUnreachableThreshold() < System.currentTimeMillis();
|
||||
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis();
|
||||
|
||||
if (Config.APS && SP.getBoolean(MainApp.gs(R.string.key_enable_pump_unreachable_alert), true)
|
||||
|
@ -83,8 +81,8 @@ public class LocalAlertUtils {
|
|||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (pump != null && profile != null) {
|
||||
Date lastConnection = pump.lastDataTime();
|
||||
long earliestAlarmTime = lastConnection.getTime() + pumpUnreachableThreshold();
|
||||
long lastConnection = pump.lastDataTime();
|
||||
long earliestAlarmTime = lastConnection + pumpUnreachableThreshold();
|
||||
if (SP.getLong("nextPumpDisconnectedAlarm", 0l) < earliestAlarmTime) {
|
||||
SP.putLong("nextPumpDisconnectedAlarm", earliestAlarmTime);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package info.nightscout.utils;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by mike on 29.01.2017.
|
||||
*/
|
||||
|
@ -11,8 +9,8 @@ import java.util.Date;
|
|||
public class Profiler {
|
||||
public Profiler(){}
|
||||
|
||||
static public void log(Logger log, String function, Date start) {
|
||||
long msec = System.currentTimeMillis() - start.getTime();
|
||||
static public void log(Logger log, String function, long start) {
|
||||
long msec = System.currentTimeMillis() - start;
|
||||
log.debug(">>> " + function + " <<< executed in " + msec + " miliseconds");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue