Step 7: Show summary statistics updated in real time
Update indicators
Let’s use the 'Summary statistics' tab to show the Service level and overall expenses.
Go to the SimulationStatisticsPart
class (in the '…application' bundle, in the '…parts.simulation' package).
Replace its onShowModel()
method with the following:
protected void onShowModel(Model model) {
if (model != null) {
List<Indicator> data = List.of(
new Indicator("Service level", () -> model.getStatistics().getServiceLevel(),
Formats.getDefaultFormats()::percent, false),
new Indicator("Expenses", () -> model.getStatistics().getExpenses(),
Formats.getDefaultFormats()::dollarTwoDecimals, false));
tableView.setData(data);
} else {
tableView.setData(Collections.emptyList());
}
}
Entities shown in the summary statistics tab are called indicators. Initially, there were two indicators (for the number for nodes and arcs). We add another two, for SL and expenses.
Although we call Here is how it works:
|