diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt index e7dbacb891..5625fd978f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt @@ -77,8 +77,11 @@ class LoopFragment : Fragment() { loop_source?.text = it.source ?: "" loop_lastrun?.text = it.lastAPSRun?.let { lastRun -> DateUtil.dateAndTimeString(lastRun.time) } ?: "" - loop_lastenact?.text = it.lastAPSRun?.let { lastEnact -> DateUtil.dateAndTimeString(lastEnact.time) } - ?: "" + loop_smbrequest_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastSMBRequest) + loop_smbexecution_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastSMBEnact) + loop_tbrrequest_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest) + loop_tbrexecution_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastTBREnact) + loop_tbrsetbypump?.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) } ?: "" loop_smbsetbypump?.text = it.smbSetByPump?.let { smbSetByPump -> HtmlHelper.fromHtml(smbSetByPump.toHtml()) } @@ -102,7 +105,10 @@ class LoopFragment : Fragment() { loop_constraintsprocessed?.text = "" loop_source?.text = "" loop_lastrun?.text = "" - loop_lastenact?.text = "" + loop_smbrequest_time?.text = "" + loop_smbexecution_time?.text = "" + loop_tbrrequest_time?.text = "" + loop_tbrexecution_time?.text = "" loop_tbrsetbypump?.text = "" loop_smbsetbypump?.text = "" } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index 7492dc64dd..b0d6f89065 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -57,6 +57,7 @@ import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.commands.Command; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.T; @@ -84,9 +85,9 @@ public class LoopPlugin extends PluginBase { return loopPlugin; } - private long loopSuspendedTill = 0L; // end of manual loop suspend - private boolean isSuperBolus = false; - private boolean isDisconnected = false; + private long loopSuspendedTill; // end of manual loop suspend + private boolean isSuperBolus; + private boolean isDisconnected; public class LastRun { public APSResult request = null; @@ -95,8 +96,11 @@ public class LoopPlugin extends PluginBase { public PumpEnactResult smbSetByPump = null; public String source = null; public Date lastAPSRun = null; - public Date lastEnact = null; - public Date lastOpenModeAccept; + public long lastTBREnact = 0; + public long lastSMBEnact = 0; + public long lastTBRRequest = 0; + public long lastSMBRequest = 0; + public long lastOpenModeAccept; } static public LastRun lastRun = null; @@ -342,6 +346,10 @@ public class LoopPlugin extends PluginBase { lastRun.source = ((PluginBase) usedAPS).getName(); lastRun.tbrSetByPump = null; lastRun.smbSetByPump = null; + lastRun.lastTBREnact = 0; + lastRun.lastTBRRequest = 0; + lastRun.lastSMBEnact = 0; + lastRun.lastSMBRequest = 0; NSUpload.uploadDeviceStatus(); @@ -378,14 +386,17 @@ public class LoopPlugin extends PluginBase { public void run() { if (result.enacted || result.success) { lastRun.tbrSetByPump = result; - lastRun.lastEnact = lastRun.lastAPSRun; + lastRun.lastTBRRequest = lastRun.lastAPSRun.getTime(); + lastRun.lastTBREnact = DateUtil.now(); + RxBus.INSTANCE.send(new EventLoopUpdateGui()); applySMBRequest(resultAfterConstraints, new Callback() { @Override public void run() { //Callback is only called if a bolus was acutally requested if (result.enacted || result.success) { lastRun.smbSetByPump = result; - lastRun.lastEnact = lastRun.lastAPSRun; + lastRun.lastSMBRequest = lastRun.lastAPSRun.getTime(); + lastRun.lastSMBEnact = DateUtil.now(); } else { new Thread(() -> { SystemClock.sleep(1000); @@ -465,8 +476,9 @@ public class LoopPlugin extends PluginBase { public void run() { if (result.enacted) { lastRun.tbrSetByPump = result; - lastRun.lastEnact = new Date(); - lastRun.lastOpenModeAccept = new Date(); + lastRun.lastTBRRequest = lastRun.lastAPSRun.getTime(); + lastRun.lastTBREnact = DateUtil.now(); + lastRun.lastOpenModeAccept = DateUtil.now(); NSUpload.uploadDeviceStatus(); SP.incInt(R.string.key_ObjectivesmanualEnacts); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java index dcce040759..be963d7a9a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java @@ -1113,7 +1113,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (acceptTempButton != null) { boolean showAcceptButton = !closedLoopEnabled.value(); // Open mode needed showAcceptButton = showAcceptButton && finalLastRun != null && finalLastRun.lastAPSRun != null; // aps result must exist - showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result + showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == 0 || finalLastRun.lastOpenModeAccept < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.isChangeRequested(); // change is requested if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.java index cae9817a55..0fd820a4da 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.java @@ -502,8 +502,8 @@ public class ActionStringHandler { if (LoopPlugin.lastRun.lastAPSRun != null) ret += "\nLast Run: " + DateUtil.timeString(LoopPlugin.lastRun.lastAPSRun); - if (LoopPlugin.lastRun.lastEnact != null) - ret += "\nLast Enact: " + DateUtil.timeString(LoopPlugin.lastRun.lastEnact); + if (LoopPlugin.lastRun.lastTBREnact != 0) + ret += "\nLast Enact: " + DateUtil.timeString(LoopPlugin.lastRun.lastTBREnact); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java index 39676f17b4..2293473338 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java @@ -735,7 +735,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog //OpenAPS status if (Config.APS) { //we are AndroidAPS - openApsStatus = LoopPlugin.lastRun != null && LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.getTime() : -1; + openApsStatus = LoopPlugin.lastRun != null && LoopPlugin.lastRun.lastTBREnact != 0 ? LoopPlugin.lastRun.lastTBREnact : -1; } else { //NSClient or remote openApsStatus = NSDeviceStatus.getOpenApsTimestamp(); diff --git a/app/src/main/java/info/nightscout/androidaps/utils/DateUtil.java b/app/src/main/java/info/nightscout/androidaps/utils/DateUtil.java index b03d8cb43f..aa228b96ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/DateUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/DateUtil.java @@ -141,6 +141,14 @@ public class DateUtil { return new DateTime(mills).toString(DateTimeFormat.forPattern(format)); } + public static String timeStringWithSeconds(long mills) { + String format = "hh:mm:ssa"; + if (android.text.format.DateFormat.is24HourFormat(MainApp.instance())) { + format = "HH:mm:ss"; + } + return new DateTime(mills).toString(DateTimeFormat.forPattern(format)); + } + public static String timeFullString(long mills) { return new DateTime(mills).toString(DateTimeFormat.fullTime()); } @@ -158,6 +166,11 @@ public class DateUtil { return dateString(mills) + " " + timeString(mills); } + public static String dateAndTimeAndSecondsString(long mills) { + if (mills == 0) return ""; + return dateString(mills) + " " + timeStringWithSeconds(mills); + } + public static String dateAndTimeFullString(long mills) { return dateString(mills) + " " + timeFullString(mills); } diff --git a/app/src/main/res/layout/loop_fragment.xml b/app/src/main/res/layout/loop_fragment.xml index ef24280345..3b5066e533 100644 --- a/app/src/main/res/layout/loop_fragment.xml +++ b/app/src/main/res/layout/loop_fragment.xml @@ -57,51 +57,6 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \"PhoneChecker\" Chart menu AS + SMB request time + SMB execution time + Temp basal request time + Temp basal execution time