Add timestamp to State and rename to PumpState.
This commit is contained in:
parent
f28a27a93f
commit
f5ef666061
4 changed files with 17 additions and 13 deletions
|
@ -5,7 +5,7 @@ public class CommandResult {
|
||||||
public boolean enacted;
|
public boolean enacted;
|
||||||
public Exception exception;
|
public Exception exception;
|
||||||
public String message;
|
public String message;
|
||||||
public State state;
|
public PumpState state;
|
||||||
public History history;
|
public History history;
|
||||||
|
|
||||||
public CommandResult() {
|
public CommandResult() {
|
||||||
|
@ -31,7 +31,7 @@ public class CommandResult {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandResult state(State state) {
|
public CommandResult state(PumpState state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,52 @@
|
||||||
package de.jotomo.ruffyscripter.commands;
|
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 boolean tbrActive = false;
|
||||||
public int tbrPercent = -1;
|
public int tbrPercent = -1;
|
||||||
public int tbrRemainingDuration = -1;
|
public int tbrRemainingDuration = -1;
|
||||||
public boolean isErrorOrWarning = false;
|
public boolean isErrorOrWarning = false;
|
||||||
public int errorCode = -1;
|
public int errorCode = -1;
|
||||||
|
|
||||||
public State tbrActive(boolean tbrActive) {
|
public PumpState tbrActive(boolean tbrActive) {
|
||||||
this.tbrActive = tbrActive;
|
this.tbrActive = tbrActive;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public State tbrPercent(int tbrPercent) {
|
public PumpState tbrPercent(int tbrPercent) {
|
||||||
this.tbrPercent = tbrPercent;
|
this.tbrPercent = tbrPercent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public State tbrRemainingDuration(int tbrRemainingDuration) {
|
public PumpState tbrRemainingDuration(int tbrRemainingDuration) {
|
||||||
this.tbrRemainingDuration = tbrRemainingDuration;
|
this.tbrRemainingDuration = tbrRemainingDuration;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public State isErrorOrWarning(boolean isErrorOrWarning) {
|
public PumpState isErrorOrWarning(boolean isErrorOrWarning) {
|
||||||
this.isErrorOrWarning = isErrorOrWarning;
|
this.isErrorOrWarning = isErrorOrWarning;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public State errorCode(int errorCode) {
|
public PumpState errorCode(int errorCode) {
|
||||||
this.errorCode = errorCode;
|
this.errorCode = errorCode;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "State{" +
|
return "PumpState{" +
|
||||||
"tbrActive=" + tbrActive +
|
"tbrActive=" + tbrActive +
|
||||||
", tbrPercent=" + tbrPercent +
|
", tbrPercent=" + tbrPercent +
|
||||||
", tbrRemainingDuration=" + tbrRemainingDuration +
|
", tbrRemainingDuration=" + tbrRemainingDuration +
|
||||||
", isErrorOrWarning=" + isErrorOrWarning +
|
", isErrorOrWarning=" + isErrorOrWarning +
|
||||||
", errorCode=" + errorCode +
|
", errorCode=" + errorCode +
|
||||||
|
", timestamp=" + timestamp +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ public class ReadStateCommand implements Command {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(RuffyScripter scripter) {
|
public CommandResult execute(RuffyScripter scripter) {
|
||||||
try {
|
try {
|
||||||
State state = new State();
|
PumpState state = new PumpState();
|
||||||
Menu displayedMenu = scripter.currentMenu;
|
Menu displayedMenu = scripter.currentMenu;
|
||||||
MenuType displayedMenuType = displayedMenu.getType();
|
MenuType displayedMenuType = displayedMenu.getType();
|
||||||
if (displayedMenuType == MenuType.MAIN_MENU) {
|
if (displayedMenuType == MenuType.MAIN_MENU) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import de.jotomo.ruffyscripter.commands.Command;
|
||||||
import de.jotomo.ruffyscripter.commands.CommandResult;
|
import de.jotomo.ruffyscripter.commands.CommandResult;
|
||||||
import de.jotomo.ruffyscripter.commands.ReadStateCommand;
|
import de.jotomo.ruffyscripter.commands.ReadStateCommand;
|
||||||
import de.jotomo.ruffyscripter.commands.SetTbrCommand;
|
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.BuildConfig;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -59,7 +59,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
private ServiceConnection mRuffyServiceConnection;
|
private ServiceConnection mRuffyServiceConnection;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private volatile State pumpState;
|
private volatile PumpState pumpState;
|
||||||
|
|
||||||
private static PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult();
|
private static PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue