Add CommandResult.completionTime field and set it in RuffyScripter when the command has finished executing.

This commit is contained in:
Johannes Mockenhaupt 2017-07-19 13:29:02 +02:00
parent 97733848e7
commit 1cf6448b0e
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 11 additions and 0 deletions

View file

@ -220,6 +220,7 @@ public class RuffyScripter {
long cmdStartTime = System.currentTimeMillis(); long cmdStartTime = System.currentTimeMillis();
returnable.cmdResult = cmd.execute(scripter, pumpState); returnable.cmdResult = cmd.execute(scripter, pumpState);
long cmdEndTime = System.currentTimeMillis(); long cmdEndTime = System.currentTimeMillis();
returnable.cmdResult.completionTime = cmdEndTime;
log.debug("Executing " + cmd + " took " + (cmdEndTime - cmdStartTime) + "ms"); log.debug("Executing " + cmd + " took " + (cmdEndTime - cmdStartTime) + "ms");
} catch (CommandException e) { } catch (CommandException e) {
returnable.cmdResult = e.toCommandResult(); returnable.cmdResult = e.toCommandResult();

View file

@ -1,11 +1,15 @@
package de.jotomo.ruffyscripter.commands; package de.jotomo.ruffyscripter.commands;
import java.util.Date;
import de.jotomo.ruffyscripter.History; import de.jotomo.ruffyscripter.History;
import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.PumpState;
public class CommandResult { public class CommandResult {
public boolean success; public boolean success;
public boolean enacted; public boolean enacted;
// TODO not really happy with that name "time the command finished executing"
public long completionTime;
public Exception exception; public Exception exception;
public String message; public String message;
public PumpState state; public PumpState state;
@ -24,6 +28,11 @@ public class CommandResult {
return this; return this;
} }
public CommandResult completionTime(long completionTime) {
this.completionTime = completionTime ;
return this;
}
public CommandResult exception(Exception exception) { public CommandResult exception(Exception exception) {
this.exception = exception; this.exception = exception;
return this; return this;
@ -49,6 +58,7 @@ public class CommandResult {
return "CommandResult{" + return "CommandResult{" +
"success=" + success + "success=" + success +
", enacted=" + enacted + ", enacted=" + enacted +
", completienTime=" + completionTime + "(" + new Date(completionTime) + ")" +
", exception=" + exception + ", exception=" + exception +
", message='" + message + '\'' + ", message='" + message + '\'' +
", state=" + state + ", state=" + state +