add console message when prenting metrics in RRC_IDLE

This commit is contained in:
Andre Puschmann 2017-09-22 15:00:07 +02:00
parent 0636aa289c
commit f92728ad6e
5 changed files with 19 additions and 4 deletions

View File

@ -48,14 +48,16 @@ public:
void toggle_print(bool b);
void set_metrics(ue_metrics_t &m, float report_period_secs);
void set_ue_handle(ue_metrics_interface *ue_);
private:
std::string float_to_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);
bool do_print;
uint8_t n_reports;
bool do_print;
uint8_t n_reports;
ue_metrics_interface* ue;
};
} // namespace srsue

View File

@ -57,6 +57,7 @@ class ue_metrics_interface : public srslte::metrics_interface<ue_metrics_t>
{
public:
virtual bool get_metrics(ue_metrics_t &m) = 0;
virtual bool is_attached() = 0;
};
} // namespace srsue

View File

@ -366,6 +366,7 @@ 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);
pthread_t input;
pthread_create(&input, NULL, &input_loop, &args);

View File

@ -50,9 +50,15 @@ char const * const prefixes[2][9] =
metrics_stdout::metrics_stdout()
:do_print(false)
,n_reports(10)
,ue(NULL)
{
}
void metrics_stdout::set_ue_handle(ue_metrics_interface *ue_)
{
ue = ue_;
}
void metrics_stdout::toggle_print(bool b)
{
do_print = b;
@ -61,9 +67,14 @@ void metrics_stdout::toggle_print(bool b)
void metrics_stdout::set_metrics(ue_metrics_t &metrics, float metrics_report_period)
{
if(!do_print)
if(!do_print || ue == NULL)
return;
if (!ue->is_attached()) {
cout << "--- disconnected ---" << endl;
return;
}
if(++n_reports > 10)
{
n_reports = 0;

View File

@ -247,7 +247,7 @@ void ue::stop()
bool ue::is_attached()
{
return (EMM_STATE_REGISTERED == nas.get_state());
return (RRC_STATE_CONNECTED == rrc.get_state());
}
void ue::start_plot() {