From f5ef66606171849a1751d9bc31728a39740f1177 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 15 Jul 2017 13:56:31 +0200 Subject: [PATCH] Add timestamp to State and rename to PumpState. --- .../ruffyscripter/commands/CommandResult.java | 4 ++-- .../commands/{State.java => PumpState.java} | 20 +++++++++++-------- .../commands/ReadStateCommand.java | 2 +- .../plugins/PumpCombo/ComboPlugin.java | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) rename app/src/main/java/de/jotomo/ruffyscripter/commands/{State.java => PumpState.java} (65%) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java index f76d00c763..999eaf36b8 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java @@ -5,7 +5,7 @@ public class CommandResult { public boolean enacted; public Exception exception; public String message; - public State state; + public PumpState state; public History history; public CommandResult() { @@ -31,7 +31,7 @@ public class CommandResult { return this; } - public CommandResult state(State state) { + public CommandResult state(PumpState state) { this.state = state; return this; } diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/State.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/PumpState.java similarity index 65% rename from app/src/main/java/de/jotomo/ruffyscripter/commands/State.java rename to app/src/main/java/de/jotomo/ruffyscripter/commands/PumpState.java index e2bc75a58f..767f22b19a 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/State.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/PumpState.java @@ -1,48 +1,52 @@ package de.jotomo.ruffyscripter.commands; +import java.util.Date; + /** - * State represeting the state of the MAIN_MENU + * State representing the state of the MAIN_MENU. */ -public class State { +public class PumpState { + public Date timestamp = new Date(); public boolean tbrActive = false; public int tbrPercent = -1; public int tbrRemainingDuration = -1; public boolean isErrorOrWarning = false; public int errorCode = -1; - public State tbrActive(boolean tbrActive) { + public PumpState tbrActive(boolean tbrActive) { this.tbrActive = tbrActive; return this; } - public State tbrPercent(int tbrPercent) { + public PumpState tbrPercent(int tbrPercent) { this.tbrPercent = tbrPercent; return this; } - public State tbrRemainingDuration(int tbrRemainingDuration) { + public PumpState tbrRemainingDuration(int tbrRemainingDuration) { this.tbrRemainingDuration = tbrRemainingDuration; return this; } - public State isErrorOrWarning(boolean isErrorOrWarning) { + public PumpState isErrorOrWarning(boolean isErrorOrWarning) { this.isErrorOrWarning = isErrorOrWarning; return this; } - public State errorCode(int errorCode) { + public PumpState errorCode(int errorCode) { this.errorCode = errorCode; return this; } @Override public String toString() { - return "State{" + + return "PumpState{" + "tbrActive=" + tbrActive + ", tbrPercent=" + tbrPercent + ", tbrRemainingDuration=" + tbrRemainingDuration + ", isErrorOrWarning=" + isErrorOrWarning + ", errorCode=" + errorCode + + ", timestamp=" + timestamp + '}'; } } diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadStateCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadStateCommand.java index 7d07079ab3..ac77dee602 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadStateCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadStateCommand.java @@ -15,7 +15,7 @@ public class ReadStateCommand implements Command { @Override public CommandResult execute(RuffyScripter scripter) { try { - State state = new State(); + PumpState state = new PumpState(); Menu displayedMenu = scripter.currentMenu; MenuType displayedMenuType = displayedMenu.getType(); if (displayedMenuType == MenuType.MAIN_MENU) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 7cce074434..96b3630fb2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -25,7 +25,7 @@ import de.jotomo.ruffyscripter.commands.Command; import de.jotomo.ruffyscripter.commands.CommandResult; import de.jotomo.ruffyscripter.commands.ReadStateCommand; import de.jotomo.ruffyscripter.commands.SetTbrCommand; -import de.jotomo.ruffyscripter.commands.State; +import de.jotomo.ruffyscripter.commands.PumpState; import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; @@ -59,7 +59,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { private ServiceConnection mRuffyServiceConnection; @Nullable - private volatile State pumpState; + private volatile PumpState pumpState; private static PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult();