fix csv output with newline instead of endl to avoid forced flush

master
Andre Puschmann 7 years ago
parent 44e9a5bd11
commit 253e7502e8

@ -47,6 +47,7 @@ class metrics_csv : public srslte::metrics_listener<ue_metrics_t>
{ {
public: public:
metrics_csv(std::string filename); metrics_csv(std::string filename);
~metrics_csv();
void set_periodicity(float metrics_report_period_sec); void set_periodicity(float metrics_report_period_sec);
void set_metrics(ue_metrics_t &m); void set_metrics(ue_metrics_t &m);

@ -404,7 +404,7 @@ void *input_loop(void *m) {
while (running) { while (running) {
cin >> key; cin >> key;
if (cin.eof() || cin.bad()) { if (cin.eof() || cin.bad()) {
cout << "Closing stdin thread\n" << endl; cout << "Closing stdin thread." << endl;
break; break;
} else { } else {
if ('t' == key) { if ('t' == key) {

@ -46,7 +46,16 @@ metrics_csv::metrics_csv(std::string filename)
,metrics_report_period(1.0) ,metrics_report_period(1.0)
,ue(NULL) ,ue(NULL)
{ {
file.open(filename.c_str()); file.open(filename.c_str(), std::ios_base::out);
}
metrics_csv::~metrics_csv()
{
if (file.is_open()) {
file << "#eof\n";
file.flush();
file.close();
}
} }
void metrics_csv::set_ue_handle(ue_metrics_interface *ue_) void metrics_csv::set_ue_handle(ue_metrics_interface *ue_)
@ -62,7 +71,7 @@ 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) {
file << "time;rsrp;pl;cfo;dl_mcs;dl_snr;dl_turbo;dl_brate;dl_bler;ul_mcs;ul_buff;ul_brate;ul_bler;rf_o;rf_u;rf_l;is_attached" << endl; file << "time;rsrp;pl;cfo;dl_mcs;dl_snr;dl_turbo;dl_brate;dl_bler;ul_mcs;ul_buff;ul_brate;ul_bler;rf_o;rf_u;rf_l;is_attached\n";
} }
file << (metrics_report_period*n_reports) << ";"; file << (metrics_report_period*n_reports) << ";";
file << float_to_string(metrics.phy.dl.rsrp, 2); file << float_to_string(metrics.phy.dl.rsrp, 2);
@ -89,7 +98,7 @@ void metrics_csv::set_metrics(ue_metrics_t &metrics)
file << float_to_string(metrics.rf.rf_u, 2); file << float_to_string(metrics.rf.rf_u, 2);
file << float_to_string(metrics.rf.rf_l, 2); file << float_to_string(metrics.rf.rf_l, 2);
file << (ue->is_attached() ? "1.0" : "0.0"); file << (ue->is_attached() ? "1.0" : "0.0");
file << endl; file << "\n";
n_reports++; n_reports++;
} else { } else {

Loading…
Cancel
Save