Feature: add timestamp information to text UIs (#241)
This commit is contained in:
@@ -21,7 +21,6 @@ package com.sheepit.client.standalone;
|
||||
|
||||
import com.sheepit.client.Client;
|
||||
import com.sheepit.client.Gui;
|
||||
import com.sheepit.client.Job;
|
||||
import com.sheepit.client.Log;
|
||||
import com.sheepit.client.Stats;
|
||||
import com.sheepit.client.standalone.text.CLIInputActionHandler;
|
||||
@@ -30,20 +29,25 @@ import com.sheepit.client.standalone.text.CLIInputObserver;
|
||||
import sun.misc.Signal;
|
||||
import sun.misc.SignalHandler;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class GuiText implements Gui {
|
||||
public static final String type = "text";
|
||||
|
||||
private int framesRendered;
|
||||
|
||||
private int sigIntCount = 0;
|
||||
|
||||
private Log log;
|
||||
private DateFormat df;
|
||||
|
||||
private Client client;
|
||||
|
||||
public GuiText() {
|
||||
this.framesRendered = 0;
|
||||
this.log = Log.getInstance(null);
|
||||
this.df = new SimpleDateFormat("MMM dd HH:mm:ss");
|
||||
}
|
||||
|
||||
@Override public void start() {
|
||||
@@ -98,47 +102,47 @@ public class GuiText implements Gui {
|
||||
|
||||
if (client != null && client.isSuspended()) {
|
||||
if (overwriteSuspendedMsg) {
|
||||
System.out.println(msg_);
|
||||
System.out.println(String.format("%s %s", this.df.format(new Date()), msg_));
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.println(msg_);
|
||||
System.out.println(String.format("%s %s", this.df.format(new Date()), msg_));
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void error(String err_) {
|
||||
System.out.println("Error " + err_);
|
||||
System.out.println(String.format("ERROR: %s %s", this.df.format(new Date()), err_));
|
||||
log.error("Error " + err_);
|
||||
}
|
||||
|
||||
@Override public void AddFrameRendered() {
|
||||
this.framesRendered += 1;
|
||||
System.out.println("Frames rendered: " + this.framesRendered);
|
||||
System.out.println(String.format("%s Frames rendered: %d", this.df.format(new Date()), this.framesRendered));
|
||||
}
|
||||
|
||||
@Override public void displayStats(Stats stats) {
|
||||
System.out.println("Frames remaining: " + stats.getRemainingFrame());
|
||||
System.out.println("Credits earned: " + stats.getCreditsEarnedDuringSession());
|
||||
System.out.println(String.format("%s Frames remaining: %d", this.df.format(new Date()), stats.getRemainingFrame()));
|
||||
System.out.println(String.format("%s Credits earned: %d", this.df.format(new Date()), stats.getCreditsEarnedDuringSession()));
|
||||
}
|
||||
|
||||
@Override public void displayUploadQueueStats(int queueSize, long queueVolume) {
|
||||
// No need to check if the queue is not empty to show the volume bc this line is always shown at the end
|
||||
// of the render process in text GUI (unless an error occurred, where the file is uploaded synchronously)
|
||||
System.out.println(String.format("Queued uploads: %d (%.2fMB)", queueSize, (queueVolume / 1024.0 / 1024.0)));
|
||||
System.out.println(String.format("%s Queued uploads: %d (%.2fMB)", this.df.format(new Date()), queueSize, (queueVolume / 1024.0 / 1024.0)));
|
||||
}
|
||||
|
||||
@Override public void setRenderingProjectName(String name_) {
|
||||
if (name_ != null && name_.isEmpty() == false) {
|
||||
System.out.println("Rendering project \"" + name_ + "\"");
|
||||
System.out.println(String.format("%s Rendering project \"%s\"", this.df.format(new Date()), name_));
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void setRemainingTime(String time_) {
|
||||
System.out.println("Rendering (remaining " + time_ + ")");
|
||||
System.out.println(String.format("%s Rendering (remaining %s)", this.df.format(new Date()), time_));
|
||||
}
|
||||
|
||||
@Override public void setRenderingTime(String time_) {
|
||||
System.out.println("Rendering " + time_);
|
||||
System.out.println(String.format("%s Rendering %s", this.df.format(new Date()), time_));
|
||||
}
|
||||
|
||||
@Override public void setClient(Client cli) {
|
||||
@@ -146,7 +150,7 @@ public class GuiText implements Gui {
|
||||
}
|
||||
|
||||
@Override public void setComputeMethod(String computeMethod) {
|
||||
System.out.println("Compute method: " + computeMethod);
|
||||
System.out.println(String.format("%s Compute method: %s", this.df.format(new Date()), computeMethod));
|
||||
}
|
||||
|
||||
@Override public Client getClient() {
|
||||
|
||||
@@ -21,7 +21,6 @@ package com.sheepit.client.standalone;
|
||||
|
||||
import com.sheepit.client.Client;
|
||||
import com.sheepit.client.Gui;
|
||||
import com.sheepit.client.Job;
|
||||
import com.sheepit.client.Stats;
|
||||
import com.sheepit.client.standalone.text.CLIInputActionHandler;
|
||||
import com.sheepit.client.standalone.text.CLIInputObserver;
|
||||
@@ -29,6 +28,10 @@ import com.sheepit.client.standalone.text.CLIInputObserver;
|
||||
import sun.misc.Signal;
|
||||
import sun.misc.SignalHandler;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class GuiTextOneLine implements Gui {
|
||||
public static final String type = "oneLine";
|
||||
|
||||
@@ -37,6 +40,7 @@ public class GuiTextOneLine implements Gui {
|
||||
private int remaining;
|
||||
private String creditsEarned;
|
||||
private int sigIntCount = 0;
|
||||
private DateFormat df;
|
||||
|
||||
private String computeMethod;
|
||||
private String status;
|
||||
@@ -59,6 +63,7 @@ public class GuiTextOneLine implements Gui {
|
||||
line = "";
|
||||
uploadQueueSize = 0;
|
||||
uploadQueueVolume = 0;
|
||||
df = new SimpleDateFormat("MMM dd HH:mm:ss");
|
||||
}
|
||||
|
||||
@Override public void start() {
|
||||
@@ -179,9 +184,10 @@ public class GuiTextOneLine implements Gui {
|
||||
|
||||
System.out.print("\r");
|
||||
|
||||
line = String.format("Frames: %d Points: %s | Queued uploads: %d%s | %s %s %s", rendered, creditsEarned != null ? creditsEarned : "unknown",
|
||||
this.uploadQueueSize, (this.uploadQueueSize > 0 ? String.format(" (%.2fMB)", (this.uploadQueueVolume / 1024.0 / 1024.0)) : ""), project,
|
||||
computeMethod, status + (exiting ? " (Exiting after all frames are uploaded)" : ""));
|
||||
line = String.format("%s Frames: %d Points: %s | Queued uploads: %d%s | %s %s %s", df.format(new Date()), rendered,
|
||||
creditsEarned != null ? creditsEarned : "unknown", this.uploadQueueSize,
|
||||
(this.uploadQueueSize > 0 ? String.format(" (%.2fMB)", (this.uploadQueueVolume / 1024.0 / 1024.0)) : ""), project, computeMethod,
|
||||
status + (exiting ? " (Exiting after all frames are uploaded)" : ""));
|
||||
|
||||
System.out.print(line);
|
||||
for (int i = line.length(); i <= charToRemove; i++) {
|
||||
|
||||
Reference in New Issue
Block a user