Skip to content
Snippets Groups Projects
Commit 28363487 authored by Christian Meyer's avatar Christian Meyer
Browse files

ZmtSimState.java: added createStatusMessage method

parent de19e789
No related branches found
Tags 0.17.0
No related merge requests found
......@@ -3,6 +3,7 @@ package sim.engine;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.NumberFormat;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -27,10 +28,34 @@ public abstract class ZmtSimState extends SimState {
/** Default directory to write simulation output. */
public static final Path DEFAULT_OUTPUT_DIR = Paths.get("output");
/** {@link NumberFormat} for simulation step rates. */
private static final NumberFormat RATE_FORMAT;
static {
RATE_FORMAT = NumberFormat.getInstance();
RATE_FORMAT.setMaximumFractionDigits(5);
RATE_FORMAT.setMinimumIntegerDigits(1);
}
public ZmtSimState(long seed) {
super(seed);
}
/**
* Creates a message to inform about the current status of the running
* simulation. The default contains steps, time and rate. Can be called by
* the simulation runner. Child classes may override the method to create
* their own version.
*
* @param stepRatePerS
* the rate of steps per second measured by the simulation runner
* @return the created status message
*/
public String createStatusMessage(double stepRatePerS) {
return "Steps: " + schedule.getSteps() + " Time: " + schedule.getTimestamp("At Start", "Done") + " Rate: "
+ RATE_FORMAT.format(stepRatePerS) + " steps/s";
}
/**
* Gets the output object of this simulation. Defaults to an empty
* {@link Optional}, can be overridden in sub classes. The returned object
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment