fix a few more displaying issue in the stdout metrics

master
Andre Puschmann 5 years ago
parent 4217dba7e0
commit 764c912977

@ -92,8 +92,8 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe
if (++n_reports > 10) {
n_reports = 0;
cout << endl;
cout << "------DL--------------------------------UL-------------------------------------" << endl;
cout << "rnti cqi ri mcs brate ok nok (%) snr phr mcs brate ok nok (%) bsr" << endl;
cout << "------DL--------------------------------UL------------------------------------" << endl;
cout << "rnti cqi ri mcs brate ok nok (%) snr phr mcs brate ok nok (%) bsr" << endl;
}
for (int i = 0; i < metrics.stack.rrc.n_ues; i++) {
@ -113,9 +113,9 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe
cout << float_to_string(0, 2, 4);
}
if (metrics.stack.mac[i].tx_brate > 0) {
cout << float_to_eng_string(SRSLTE_MAX(0.1, (float)metrics.stack.mac[i].tx_brate / period_usec * 1e6), 2);
cout << float_to_eng_string(SRSLTE_MAX(0.1, (float)metrics.stack.mac[i].tx_brate / period_usec * 1e6), 1);
} else {
cout << float_to_string(0, 2, 5) << "";
cout << float_to_string(0, 1, 6) << "";
}
cout << std::setw(5) << metrics.stack.mac[i].tx_pkts;
cout << std::setw(5) << metrics.stack.mac[i].tx_errors;
@ -124,7 +124,7 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe
SRSLTE_MAX(0.1, (float)100 * metrics.stack.mac[i].tx_errors / metrics.stack.mac[i].tx_pkts), 1, 4)
<< "%";
} else {
cout << float_to_string(0, 1) << "%";
cout << float_to_string(0, 1, 4) << "%";
}
cout << " ";
@ -141,9 +141,9 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe
cout << float_to_string(0, 1, 4);
}
if (metrics.stack.mac[i].rx_brate > 0) {
cout << float_to_eng_string(SRSLTE_MAX(0.1, (float)metrics.stack.mac[i].rx_brate / period_usec * 1e6), 2);
cout << float_to_eng_string(SRSLTE_MAX(0.1, (float)metrics.stack.mac[i].rx_brate / period_usec * 1e6), 1);
} else {
cout << float_to_string(0, 2) << "";
cout << float_to_string(0, 1) << "";
}
cout << std::setw(5) << metrics.stack.mac[i].rx_pkts;
cout << std::setw(5) << metrics.stack.mac[i].rx_errors;
@ -172,6 +172,9 @@ std::string metrics_stdout::float_to_string(float f, int digits, int field_width
} else {
precision = digits - (int)(log10f(fabs(f)) - 2 * DBL_EPSILON);
}
if (precision == -1) {
precision = 0;
}
os << std::setw(field_width) << std::fixed << std::setprecision(precision) << f;
return os.str();
}
@ -202,7 +205,7 @@ std::string metrics_stdout::float_to_eng_string(float f, int digits)
if (degree != 0) {
return float_to_string(scaled, digits, 5) + factor;
} else {
return " " + float_to_string(scaled, digits) + factor;
return " " + float_to_string(scaled, digits, 5 - factor.length()) + factor;
}
}

@ -36,7 +36,7 @@ namespace srsenb {
char* csv_file_name = NULL;
#define NUM_METRICS 2
#define NUM_METRICS (3)
// fake classes
class enb_dummy : public enb_metrics_interface
@ -50,10 +50,10 @@ public:
metrics[0].stack.mac[0].rnti = 0x46;
metrics[0].stack.mac[0].tx_pkts = 1000;
metrics[0].stack.mac[0].tx_errors = 1000;
metrics[0].stack.mac[0].tx_brate = 1e6;
metrics[0].stack.mac[0].tx_brate = 0;
metrics[0].stack.mac[0].rx_pkts = 50;
metrics[0].stack.mac[0].rx_errors = 10;
metrics[0].stack.mac[0].rx_brate = 1e3;
metrics[0].stack.mac[0].rx_errors = 49;
metrics[0].stack.mac[0].rx_brate = 2;
metrics[0].stack.mac[0].ul_buffer = 100;
metrics[0].stack.mac[0].dl_buffer = 200;
metrics[0].stack.mac[0].dl_cqi = 15.9;
@ -69,7 +69,7 @@ public:
metrics[1].stack.rrc.n_ues = 1;
metrics[1].stack.mac[0].rnti = 0xffff;
metrics[1].stack.mac[0].tx_pkts = 100;
metrics[1].stack.mac[0].tx_errors = 54;
metrics[1].stack.mac[0].tx_errors = 0;
metrics[1].stack.mac[0].tx_brate = 1e6;
metrics[1].stack.mac[0].rx_pkts = 50;
metrics[1].stack.mac[0].rx_errors = 10;
@ -83,6 +83,26 @@ public:
metrics[1].phy->dl.mcs = 6.2;
metrics[1].phy->ul.mcs = 28.0;
metrics[1].phy->ul.sinr = 22.2;
// third entry
metrics[2].rf.rf_o = 10;
metrics[2].stack.rrc.n_ues = 1;
metrics[2].stack.mac[0].rnti = 0x1;
metrics[2].stack.mac[0].tx_pkts = 9999;
metrics[2].stack.mac[0].tx_errors = 1;
metrics[2].stack.mac[0].tx_brate = 776;
metrics[2].stack.mac[0].rx_pkts = 50;
metrics[2].stack.mac[0].rx_errors = 0;
metrics[2].stack.mac[0].rx_brate = 1e3;
metrics[2].stack.mac[0].ul_buffer = 100;
metrics[2].stack.mac[0].dl_buffer = 200;
metrics[2].stack.mac[0].dl_cqi = 15.9;
metrics[2].stack.mac[0].dl_ri = 1.5;
metrics[2].stack.mac[0].dl_pmi = 1.0;
metrics[2].stack.mac[0].phr = 12.0;
metrics[2].phy->dl.mcs = 28.0;
metrics[2].phy->ul.mcs = 20.2;
metrics[2].phy->ul.sinr = 14.2;
}
bool get_metrics(enb_metrics_t* m)
@ -94,8 +114,8 @@ public:
}
private:
int counter = 0;
enb_metrics_t metrics[2] = {};
int counter = 0;
enb_metrics_t metrics[NUM_METRICS] = {};
};
} // namespace srsenb
@ -155,7 +175,7 @@ int main(int argc, char** argv)
metrics_screen.toggle_print(true);
std::cout << "Running for 2 seconds .." << std::endl;
usleep(2e6);
usleep(4e6);
metricshub.stop();
return 0;

Loading…
Cancel
Save