aboutsummaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/models')
-rw-r--r--src/models/counter.cpp18
-rw-r--r--src/models/counter.hpp1
-rw-r--r--src/models/timer.cpp20
-rw-r--r--src/models/timer.hpp2
4 files changed, 41 insertions, 0 deletions
diff --git a/src/models/counter.cpp b/src/models/counter.cpp
index 1b6315d..a80515e 100644
--- a/src/models/counter.cpp
+++ b/src/models/counter.cpp
@@ -1,4 +1,5 @@
#include "models/counter.hpp"
+#include "utils/utils.hpp"
double FreqCounter::rate() const {
uint64_t ms = _timer->total_duration_ms();
@@ -23,6 +24,23 @@ std::string FreqCounter::display_value() const {
return std::to_string(_overtime_cnt);
}
+std::string FreqCounter::rate_display() const {
+ double rate = this->rate();
+
+ std::string rate_display_val;
+ format_rate(rate_display_val, rate);
+
+ if(_timer->overtime()) {
+ std::string rate_overtime;
+ format_rate(rate_overtime, overtime_rate());
+
+ rate_display_val.append(", ");
+ rate_display_val.append(rate_overtime);
+ }
+
+ return rate_display_val;
+}
+
void FreqCounter::inc() {
if(_overtime_cnt != UINT32_MAX)
diff --git a/src/models/counter.hpp b/src/models/counter.hpp
index fa9e1c5..74f4e46 100644
--- a/src/models/counter.hpp
+++ b/src/models/counter.hpp
@@ -26,6 +26,7 @@ class FreqCounter {
[[nodiscard]] std::string display_value() const;
+ [[nodiscard]] std::string rate_display() const;
private:
diff --git a/src/models/timer.cpp b/src/models/timer.cpp
index a05e8c1..8ab3c23 100644
--- a/src/models/timer.cpp
+++ b/src/models/timer.cpp
@@ -1,6 +1,9 @@
#include "timer.hpp"
+
#include <cinttypes>
+#include "utils/utils.hpp"
+
#ifdef EMSCRIPTEN
#include <emscripten/html5.h>
#endif
@@ -73,6 +76,23 @@ std::string FreqTimer::counter_display_value() const {
return display_val;
}
+std::string FreqTimer::record_floor_display() const {
+ double record_floor = this->record_floor();
+
+ std::string record_floor_label;
+ format_rate(record_floor_label, record_floor);
+
+ if(overtime()) {
+ std::string rec_floor_overtime;
+ format_rate(rec_floor_overtime, overtime_record_floor());
+
+ record_floor_label.append(", ");
+ record_floor_label.append(rec_floor_overtime);
+ }
+
+ return record_floor_label;
+}
+
void FreqTimer::increment_preset_ms(uint64_t amount_ms) {
if(_state != State::SETTING) {
clear();
diff --git a/src/models/timer.hpp b/src/models/timer.hpp
index 0b0a978..fcaec1a 100644
--- a/src/models/timer.hpp
+++ b/src/models/timer.hpp
@@ -47,6 +47,8 @@ class FreqTimer {
[[nodiscard]] std::string counter_display_value() const;
+ [[nodiscard]] std::string record_floor_display() const;
+
/*
* Lowest frequency which can be measured
* in the interval (as measured in events/min