Removed metrics period from listener

master
Ismael Gomez 7 years ago
parent 3de86ca521
commit 9c04bf2848

@ -24,7 +24,7 @@ template<typename metrics_t>
class metrics_listener class metrics_listener
{ {
public: public:
virtual void set_metrics(metrics_t &m, float report_period_secs=1.0) = 0; virtual void set_metrics(metrics_t &m) = 0;
}; };
template<typename metrics_t> template<typename metrics_t>
@ -57,7 +57,7 @@ private:
bzero(&metric, sizeof(metrics_t)); bzero(&metric, sizeof(metrics_t));
m->get_metrics(metric); m->get_metrics(metric);
for (uint32_t i=0;i<listeners.size();i++) { for (uint32_t i=0;i<listeners.size();i++) {
listeners[i]->set_metrics(metric, report_period_secs); listeners[i]->set_metrics(metric);
} }
} }
} }

@ -48,12 +48,14 @@ class metrics_csv : public srslte::metrics_listener<ue_metrics_t>
public: public:
metrics_csv(std::string filename); metrics_csv(std::string filename);
void set_metrics(ue_metrics_t &m, float report_period_secs); void set_periodicity(float metrics_report_period_sec);
void set_metrics(ue_metrics_t &m);
void set_ue_handle(ue_metrics_interface *ue_); void set_ue_handle(ue_metrics_interface *ue_);
private: private:
std::string float_to_string(float f, int digits, bool add_semicolon = true); std::string float_to_string(float f, int digits, bool add_semicolon = true);
float metrics_report_period;
std::ofstream file; std::ofstream file;
ue_metrics_interface* ue; ue_metrics_interface* ue;
uint32_t n_reports; uint32_t n_reports;

@ -46,8 +46,9 @@ class metrics_stdout : public srslte::metrics_listener<ue_metrics_t>
public: public:
metrics_stdout(); metrics_stdout();
void set_periodicity(float metrics_report_period_sec);
void toggle_print(bool b); void toggle_print(bool b);
void set_metrics(ue_metrics_t &m, float report_period_secs); void set_metrics(ue_metrics_t &m);
void set_ue_handle(ue_metrics_interface *ue_); void set_ue_handle(ue_metrics_interface *ue_);
private: private:
@ -55,6 +56,7 @@ private:
std::string float_to_eng_string(float f, int digits); std::string float_to_eng_string(float f, int digits);
std::string int_to_eng_string(int f, int digits); std::string int_to_eng_string(int f, int digits);
float metrics_report_period;
bool do_print; bool do_print;
uint8_t n_reports; uint8_t n_reports;
ue_metrics_interface* ue; ue_metrics_interface* ue;

@ -386,11 +386,13 @@ int main(int argc, char *argv[])
metricshub.init(ue, args.expert.metrics_period_secs); metricshub.init(ue, args.expert.metrics_period_secs);
metricshub.add_listener(&metrics_screen); metricshub.add_listener(&metrics_screen);
metrics_screen.set_ue_handle(ue); metrics_screen.set_ue_handle(ue);
metrics_screen.set_periodicity(args.expert.metrics_period_secs);
metrics_csv metrics_file(args.expert.metrics_csv_filename); metrics_csv metrics_file(args.expert.metrics_csv_filename);
if (args.expert.metrics_csv_enable) { if (args.expert.metrics_csv_enable) {
metricshub.add_listener(&metrics_file); metricshub.add_listener(&metrics_file);
metrics_file.set_ue_handle(ue); metrics_file.set_ue_handle(ue);
metrics_file.set_periodicity(args.expert.metrics_period_secs);
} }
pthread_t input; pthread_t input;

@ -43,6 +43,7 @@ namespace srsue{
metrics_csv::metrics_csv(std::string filename) metrics_csv::metrics_csv(std::string filename)
:n_reports(0) :n_reports(0)
,metrics_report_period(1.0)
,ue(NULL) ,ue(NULL)
{ {
file.open(filename.c_str()); file.open(filename.c_str());
@ -53,7 +54,11 @@ void metrics_csv::set_ue_handle(ue_metrics_interface *ue_)
ue = ue_; ue = ue_;
} }
void metrics_csv::set_metrics(ue_metrics_t &metrics, float metrics_report_period) void metrics_csv::set_periodicity(float metrics_report_period_sec) {
this->metrics_report_period = metrics_report_period_sec;
}
void metrics_csv::set_metrics(ue_metrics_t &metrics)
{ {
if (file.is_open() && ue != NULL) { if (file.is_open() && ue != NULL) {
if(n_reports == 0) { if(n_reports == 0) {
@ -75,7 +80,7 @@ void metrics_csv::set_metrics(ue_metrics_t &metrics, float metrics_report_period
file << float_to_string(metrics.phy.ul.mcs, 2); file << float_to_string(metrics.phy.ul.mcs, 2);
file << float_to_string((float) metrics.mac.ul_buffer, 2); file << float_to_string((float) metrics.mac.ul_buffer, 2);
file << float_to_string((float) metrics.mac.tx_brate/metrics_report_period, 2); file << float_to_string((float) metrics.mac.tx_brate/metrics_report_period, 2);
if (metrics.mac.tx_pkts > 0) { if (metrics.mac.tx_pkts > 0) {
file << float_to_string((float) 100*metrics.mac.tx_errors/metrics.mac.tx_pkts, 1); file << float_to_string((float) 100*metrics.mac.tx_errors/metrics.mac.tx_pkts, 1);
} else { } else {
file << float_to_string(0, 2); file << float_to_string(0, 2);

@ -50,6 +50,7 @@ char const * const prefixes[2][9] =
metrics_stdout::metrics_stdout() metrics_stdout::metrics_stdout()
:do_print(false) :do_print(false)
,n_reports(10) ,n_reports(10)
,metrics_report_period(1.0)
,ue(NULL) ,ue(NULL)
{ {
} }
@ -64,8 +65,11 @@ void metrics_stdout::toggle_print(bool b)
do_print = b; do_print = b;
} }
void metrics_stdout::set_periodicity(float metrics_report_period_sec) {
this->metrics_report_period = metrics_report_period_sec;
}
void metrics_stdout::set_metrics(ue_metrics_t &metrics, float metrics_report_period) void metrics_stdout::set_metrics(ue_metrics_t &metrics)
{ {
if(!do_print || ue == NULL) if(!do_print || ue == NULL)
return; return;

Loading…
Cancel
Save