From 14c1ed97d37f715b73220f45669ce5ed3e9b3152 Mon Sep 17 00:00:00 2001 From: Piotr Gawlowicz Date: Tue, 4 Apr 2023 11:34:25 +0200 Subject: [PATCH] e2sm_kpm: simplify metric collection in e2sm_kpm_report_service --- srsgnb/hdr/stack/ric/e2sm_kpm.h | 3 +- srsgnb/src/stack/ric/e2sm_kpm.cc | 35 +++++++++---------- .../src/stack/ric/e2sm_kpm_report_service.cc | 15 +++----- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/srsgnb/hdr/stack/ric/e2sm_kpm.h b/srsgnb/hdr/stack/ric/e2sm_kpm.h index 0a535fa1d..79b80bf24 100644 --- a/srsgnb/hdr/stack/ric/e2sm_kpm.h +++ b/srsgnb/hdr/stack/ric/e2sm_kpm.h @@ -58,8 +58,7 @@ private: bool _get_meas_definition(std::string meas_name, E2SM_KPM_metric_t& def); std::vector _get_supported_meas(uint32_t level_mask); - bool _collect_integer_type_meas_value(E2SM_KPM_meas_def_t& meas_value, meas_record_item_c& item); - bool _collect_real_type_meas_value(E2SM_KPM_meas_def_t& meas_value, meas_record_item_c& item); + bool _collect_type_meas_value(E2SM_KPM_meas_def_t& meas_value, meas_record_item_c& item); bool _extract_integer_type_meas_value(E2SM_KPM_meas_def_t& meas_value, const enb_metrics_t& enb_metrics, uint32_t& value); bool _extract_real_type_meas_value(E2SM_KPM_meas_def_t& meas_value, const enb_metrics_t& enb_metrics, float& value); diff --git a/srsgnb/src/stack/ric/e2sm_kpm.cc b/srsgnb/src/stack/ric/e2sm_kpm.cc index adfd19860..49358b116 100644 --- a/srsgnb/src/stack/ric/e2sm_kpm.cc +++ b/srsgnb/src/stack/ric/e2sm_kpm.cc @@ -336,28 +336,27 @@ void e2sm_kpm::receive_e2_metrics_callback(const enb_metrics_t& m) logger.debug("e2sm_kpm received new enb metrics, CPU0 Load: %.1f", last_enb_metrics.sys.cpu_load[0]); } -bool e2sm_kpm::_collect_integer_type_meas_value(E2SM_KPM_meas_def_t& meas_value, meas_record_item_c& item) +bool e2sm_kpm::_collect_type_meas_value(E2SM_KPM_meas_def_t& meas_value, meas_record_item_c& item) { // here we implement logic of measurement data collection, currently we only read from enb_metrics - uint32_t value; - if (_extract_integer_type_meas_value(meas_value, last_enb_metrics, value)) { - item.set_integer() = value; - return true; + if (meas_value.data_type == meas_record_item_c::types::options::integer) { + uint32_t value; + if (_extract_integer_type_meas_value(meas_value, last_enb_metrics, value)) { + item.set_integer() = value; + return true; + } + } else { + // data_type == meas_record_item_c::types::options::real; + float value; + if (_extract_real_type_meas_value(meas_value, last_enb_metrics, value)) { + real_s real_value; + // TODO: real value seems to be not supported in asn1??? + // real_value.value = value; + item.set_real() = real_value; + return true; + } } - return false; -} -bool e2sm_kpm::_collect_real_type_meas_value(E2SM_KPM_meas_def_t& meas_value, meas_record_item_c& item) -{ - // here we implement logic of measurement data collection, currently we only read from enb_metrics - float value; - if (_extract_real_type_meas_value(meas_value, last_enb_metrics, value)) { - real_s real_value; - // TODO: real value seems to be not supported in asn1??? - // real_value.value = value; - item.set_real() = real_value; - return true; - } return false; } diff --git a/srsgnb/src/stack/ric/e2sm_kpm_report_service.cc b/srsgnb/src/stack/ric/e2sm_kpm_report_service.cc index 554893ed4..aa065c5ed 100644 --- a/srsgnb/src/stack/ric/e2sm_kpm_report_service.cc +++ b/srsgnb/src/stack/ric/e2sm_kpm_report_service.cc @@ -380,18 +380,11 @@ bool e2sm_kpm_report_service_style1::_collect_meas_data() meas_value.data_type = data_type; meas_record_item_c item; - if (meas_value.data_type == meas_record_item_c::types::options::integer) { - if (not parent->_collect_integer_type_meas_value(meas_value, item)) { - parent->logger.info("Cannot extract value \"%s\" label: %i", meas_name.c_str(), label); - return false; - } - } else { - // data_type == meas_record_item_c::types::options::real; - if (not parent->_collect_real_type_meas_value(meas_value, item)) { - parent->logger.info("Cannot extract value \"%s\" label %i", meas_name.c_str(), label); - return false; - } + if (not parent->_collect_type_meas_value(meas_value, item)) { + parent->logger.info("Cannot extract value \"%s\" label: %i", meas_name.c_str(), label); + return false; } + // save meas value in the proper record list meas_data_item.meas_record.push_back(item); }