diff --git a/std-udp-recv/include/FrameStats.hpp b/std-udp-recv/include/FrameStats.hpp index da2d000..c144845 100644 --- a/std-udp-recv/include/FrameStats.hpp +++ b/std-udp-recv/include/FrameStats.hpp @@ -8,28 +8,24 @@ class FrameStats { const std::string detector_name_; - const int n_modules_; const int module_id_; - const int bit_depth_; const int n_packets_per_frame_; - size_t stats_time_; + const size_t stats_time_; int frames_counter_; int n_missed_packets_; int n_corrupted_frames_; - int n_corrupted_pulse_id_; std::chrono::time_point stats_interval_start_; void reset_counters(); void print_stats(); -public:////config.detector_name, n_receivers, module_id, bit_depth, STATS_TIME - FrameStats(const std::string &detector_name, - const int n_modules, +public: + FrameStats(std::string detector_name, const int module_id, - const int bit_depth, + const int n_packets_per_frame, const size_t stats_time); - void record_stats(const ModuleFrame &meta, const bool bad_pulse_id); + void record_stats(const ModuleFrame &meta); }; diff --git a/std-udp-recv/src/FrameStats.cpp b/std-udp-recv/src/FrameStats.cpp index 46bc8a7..c78f052 100644 --- a/std-udp-recv/src/FrameStats.cpp +++ b/std-udp-recv/src/FrameStats.cpp @@ -1,20 +1,18 @@ #include +#include #include "FrameStats.hpp" #include "date.h" using namespace std; using namespace chrono; FrameStats::FrameStats( - const std::string &detector_name, - const int n_modules, + string detector_name, const int module_id, - const int bit_depth, + const int n_packets_per_frame, const size_t stats_time) : - detector_name_(detector_name), - n_modules_(n_modules), + detector_name_(move(detector_name)), module_id_(module_id), - bit_depth_(bit_depth), - n_packets_per_frame_(bit_depth_ * MODULE_N_PIXELS / 8 / DATA_BYTES_PER_PACKET / n_modules), + n_packets_per_frame_(n_packets_per_frame), stats_time_(stats_time) { reset_counters(); @@ -25,36 +23,31 @@ void FrameStats::reset_counters() frames_counter_ = 0; n_missed_packets_ = 0; n_corrupted_frames_ = 0; - n_corrupted_pulse_id_ = 0; stats_interval_start_ = steady_clock::now(); } -void FrameStats::record_stats(const ModuleFrame &meta, const bool bad_pulse_id) +void FrameStats::record_stats(const ModuleFrame &meta) { - if (bad_pulse_id) { - n_corrupted_pulse_id_++; - } - if (meta.n_recv_packets < n_packets_per_frame_) { n_missed_packets_ += n_packets_per_frame_ - meta.n_recv_packets; n_corrupted_frames_++; + #ifdef DEBUG_OUTPUT using namespace date; - cout << " [" << std::chrono::system_clock::now(); - cout << "] [FrameStats::record_stats] :"; - cout << " meta.frame "<< meta.frame_index; + cout << " [" << std::chrono::system_clock::now() << "]"; + cout << " [FrameStats::record_stats] :"; + cout << " meta.pulse_id "<< meta.pulse_id; + cout << " meta.frame_index "<< meta.frame_index; cout << " || meta.n_recv_packets " << meta.n_recv_packets; cout << " || n_missed_packets_ " << n_missed_packets_; cout << endl; #endif - - } frames_counter_++; - auto time_passed = duration_cast( + const auto time_passed = duration_cast( steady_clock::now()-stats_interval_start_).count(); if (time_passed >= stats_time_*1000) { @@ -75,12 +68,11 @@ void FrameStats::print_stats() // Output in InfluxDB line protocol cout << "jf_udp_recv"; cout << ",detector_name=" << detector_name_; - cout << ",module_name=M" << module_id_; + cout << ",module_id=" << module_id_; cout << " "; cout << "n_missed_packets=" << n_missed_packets_ << "i"; cout << ",n_corrupted_frames=" << n_corrupted_frames_ << "i"; cout << ",repetition_rate=" << rep_rate << "i"; - cout << ",n_corrupted_pulse_ids=" << n_corrupted_pulse_id_ << "i"; cout << " "; cout << timestamp; cout << endl;