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
{
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>
@ -57,7 +57,7 @@ private:
bzero(&metric, sizeof(metrics_t));
m->get_metrics(metric);
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:
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_);
private:
std::string float_to_string(float f, int digits, bool add_semicolon = true);
float metrics_report_period;
std::ofstream file;
ue_metrics_interface* ue;
uint32_t n_reports;

@ -46,8 +46,9 @@ class metrics_stdout : public srslte::metrics_listener<ue_metrics_t>
public:
metrics_stdout();
void set_periodicity(float metrics_report_period_sec);
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_);
private:
@ -55,6 +56,7 @@ private:
std::string float_to_eng_string(float f, int digits);
std::string int_to_eng_string(int f, int digits);
float metrics_report_period;
bool do_print;
uint8_t n_reports;
ue_metrics_interface* ue;

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

@ -43,6 +43,7 @@ namespace srsue{
metrics_csv::metrics_csv(std::string filename)
:n_reports(0)
,metrics_report_period(1.0)
,ue(NULL)
{
file.open(filename.c_str());
@ -53,7 +54,11 @@ void metrics_csv::set_ue_handle(ue_metrics_interface *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(n_reports == 0) {

@ -50,6 +50,7 @@ char const * const prefixes[2][9] =
metrics_stdout::metrics_stdout()
:do_print(false)
,n_reports(10)
,metrics_report_period(1.0)
,ue(NULL)
{
}
@ -64,8 +65,11 @@ void metrics_stdout::toggle_print(bool 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)
return;

Loading…
Cancel
Save