srs-control 0.2.2
Loading...
Searching...
No Matches
DataMonitor.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <asio/awaitable.hpp>
6#include <asio/steady_timer.hpp>
7#include <atomic>
8#include <chrono>
9#include <cstdint>
10#include <gsl/gsl-lite.hpp>
11#include <memory>
12#include <spdlog/logger.h>
13#include <string>
14
15namespace srs::sink
16{
18}
19
20namespace srs::workflow
21{
22 class AnalysisHandle;
23
25 {
26 public:
27 explicit DataMonitor(AnalysisHandle* analysis_handle, io_context_type* io_context);
28 void show_data_speed(bool val = true) { is_shown_ = val; }
29 void set_display_period(std::chrono::milliseconds duration) { period_ = duration; }
30 void start();
31 void stop();
32 // void update(const StructData& data_struct) {}
34
35 // getters:
36 [[nodiscard]] auto get_received_bytes_MBps() const -> double { return current_received_bytes_MBps_; }
37 [[nodiscard]] auto get_processed_hit_rate() const -> double { return current_hits_ps_; }
38
39 private:
40 bool is_shown_ = true;
41 std::atomic<bool> is_cancelled_ = false;
42 gsl::not_null<AnalysisHandle*> analysis_handle_;
43 gsl::not_null<io_context_type*> io_context_;
44 std::shared_ptr<spdlog::logger> console_;
45 asio::steady_timer clock_;
46 std::chrono::time_point<std::chrono::steady_clock> last_print_time_ = std::chrono::steady_clock::now();
47 std::chrono::milliseconds period_ = common::DEFAULT_DISPLAY_PERIOD;
52 uint64_t last_frame_counts_ = 0;
56 double current_hits_ps_ = 0.;
57 std::string read_speed_string_;
59 std::string drop_speed_string_;
60 std::string unit_string_;
61
62 void set_speed_string();
63 auto print_cycle() -> asio::awaitable<void>;
64 };
65} // namespace srs::workflow
void set_display_period(std::chrono::milliseconds duration)
std::chrono::milliseconds period_
DataMonitor(AnalysisHandle *analysis_handle, io_context_type *io_context)
std::chrono::time_point< std::chrono::steady_clock > last_print_time_
asio::steady_timer clock_
auto get_processed_hit_rate() const -> double
gsl::not_null< AnalysisHandle * > analysis_handle_
void show_data_speed(bool val=true)
std::shared_ptr< spdlog::logger > console_
auto print_cycle() -> asio::awaitable< void >
auto get_received_bytes_MBps() const -> double
gsl::not_null< io_context_type * > io_context_
std::atomic< bool > is_cancelled_
constexpr auto DEFAULT_DISPLAY_PERIOD
asio::thread_pool io_context_type