From 1cf6448b0e37612de56463981bd1ca3bd696b77a Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 19 Jul 2017 13:29:02 +0200 Subject: [PATCH] Add CommandResult.completionTime field and set it in RuffyScripter when the command has finished executing. --- .../java/de/jotomo/ruffyscripter/RuffyScripter.java | 1 + .../jotomo/ruffyscripter/commands/CommandResult.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 7189db52bf..dff3fed01e 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -220,6 +220,7 @@ public class RuffyScripter { long cmdStartTime = System.currentTimeMillis(); returnable.cmdResult = cmd.execute(scripter, pumpState); long cmdEndTime = System.currentTimeMillis(); + returnable.cmdResult.completionTime = cmdEndTime; log.debug("Executing " + cmd + " took " + (cmdEndTime - cmdStartTime) + "ms"); } catch (CommandException e) { returnable.cmdResult = e.toCommandResult(); 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 c5125a5d86..5c5600293f 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java @@ -1,11 +1,15 @@ package de.jotomo.ruffyscripter.commands; +import java.util.Date; + import de.jotomo.ruffyscripter.History; import de.jotomo.ruffyscripter.PumpState; public class CommandResult { public boolean success; public boolean enacted; + // TODO not really happy with that name "time the command finished executing" + public long completionTime; public Exception exception; public String message; public PumpState state; @@ -24,6 +28,11 @@ public class CommandResult { return this; } + public CommandResult completionTime(long completionTime) { + this.completionTime = completionTime ; + return this; + } + public CommandResult exception(Exception exception) { this.exception = exception; return this; @@ -49,6 +58,7 @@ public class CommandResult { return "CommandResult{" + "success=" + success + ", enacted=" + enacted + + ", completienTime=" + completionTime + "(" + new Date(completionTime) + ")" + ", exception=" + exception + ", message='" + message + '\'' + ", state=" + state +