2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2017-09-23 13:24:37 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2017-09-23 13:24:37 -07:00
|
|
|
*
|
2021-03-19 03:45:56 -07:00
|
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
2017-09-23 13:24:37 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* By using this file, you agree to the terms and conditions set
|
|
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
|
|
* the distribution.
|
2017-09-23 13:24:37 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* File: metrics_csv.h
|
|
|
|
* Description: Metrics class writing to CSV file.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSUE_METRICS_CSV_H
|
|
|
|
#define SRSUE_METRICS_CSV_H
|
2017-09-23 13:24:37 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
2020-03-13 15:06:10 -07:00
|
|
|
#include <mutex>
|
2017-09-23 13:24:37 -07:00
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#include "srsran/common/metrics_hub.h"
|
2017-09-23 13:24:37 -07:00
|
|
|
#include "ue_metrics_interface.h"
|
|
|
|
|
|
|
|
namespace srsue {
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
class metrics_csv : public srsran::metrics_listener<ue_metrics_t>
|
2017-09-23 13:24:37 -07:00
|
|
|
{
|
|
|
|
public:
|
2020-03-13 05:27:48 -07:00
|
|
|
metrics_csv(std::string filename, bool append = false);
|
2018-01-26 01:40:48 -08:00
|
|
|
~metrics_csv();
|
2017-09-23 13:24:37 -07:00
|
|
|
|
2020-01-13 04:14:46 -08:00
|
|
|
void set_metrics(const ue_metrics_t& m, const uint32_t period_usec);
|
2019-12-16 07:04:22 -08:00
|
|
|
void set_ue_handle(ue_metrics_interface* ue_);
|
2020-03-12 16:11:03 -07:00
|
|
|
void set_flush_period(const uint32_t flush_period_sec);
|
2018-01-26 04:20:18 -08:00
|
|
|
void stop();
|
2017-09-23 13:24:37 -07:00
|
|
|
|
|
|
|
private:
|
2021-04-23 03:07:12 -07:00
|
|
|
void set_metrics_helper(const srsran::rf_metrics_t& rf,
|
|
|
|
const srsran::sys_metrics_t& sys,
|
|
|
|
const phy_metrics_t& phy,
|
|
|
|
const mac_metrics_t mac[SRSRAN_MAX_CARRIERS],
|
|
|
|
const rrc_metrics_t& rrc,
|
|
|
|
const uint32_t cc,
|
|
|
|
const uint32_t r);
|
2021-04-07 12:03:19 -07:00
|
|
|
|
2017-09-23 13:24:37 -07:00
|
|
|
std::string float_to_string(float f, int digits, bool add_semicolon = true);
|
|
|
|
|
|
|
|
std::ofstream file;
|
2020-03-13 15:06:10 -07:00
|
|
|
ue_metrics_interface* ue = nullptr;
|
|
|
|
uint32_t n_reports = 0;
|
|
|
|
std::mutex mutex = {};
|
2020-03-12 16:11:03 -07:00
|
|
|
uint32_t flush_period_sec = 0;
|
2020-03-13 15:06:10 -07:00
|
|
|
uint32_t flush_time_ms = 0;
|
|
|
|
uint64_t time_ms = 0;
|
|
|
|
bool file_exists = false;
|
2017-09-23 13:24:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace srsue
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSUE_METRICS_CSV_H
|