From 1de06da14e0a686f623dfebd4f4ccacc39dd9ec5 Mon Sep 17 00:00:00 2001 From: Ron Shacham Date: Tue, 8 Dec 2020 13:20:20 -0500 Subject: [PATCH] Changes to SDL read to support new keys used by KPIMON Issue-ID: RICAPP-96 Signed-off-by: Ron Shacham Change-Id: Ie27af412756b0aa813dfbb89c59c8c7981ae381a --- container-tag.yaml | 2 +- docs/rel-notes.rst | 9 ++++++ src/ts_xapp/ts_xapp.cpp | 75 +++++++++++++++++++++++++++++---------------- xapp-descriptor/config.json | 2 +- 4 files changed, 59 insertions(+), 29 deletions(-) diff --git a/container-tag.yaml b/container-tag.yaml index eece839..ff04743 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -1,3 +1,3 @@ # this is used by CI jobs to apply a tag when it builds the image --- -tag: '1.0.12' +tag: '1.0.13' diff --git a/docs/rel-notes.rst b/docs/rel-notes.rst index 26bd814..f8c430b 100644 --- a/docs/rel-notes.rst +++ b/docs/rel-notes.rst @@ -9,6 +9,15 @@ Traffic Steering xAPP ===================== +2020 Dec 8 Version 1.0.13 +------------------------- + Small changes to integrate with RAN data written by KPIMON xApp + +2020 Dec 7 Version 1.0.12 +------------------------- + Change by HCL to support AD xapp + + 2020 June 11 Version 1.0.11 ---------------------------- Removed extraneous logging messages diff --git a/src/ts_xapp/ts_xapp.cpp b/src/ts_xapp/ts_xapp.cpp index 8194b15..ca0cd6c 100644 --- a/src/ts_xapp/ts_xapp.cpp +++ b/src/ts_xapp/ts_xapp.cpp @@ -210,33 +210,36 @@ struct UEDataHandler : public BaseReaderHandler, UEDataHandler> { bool in_serving_array = false; int rf_meas_index = 0; + bool in_serving_report_object = false; + string curr_key = ""; string curr_value = ""; bool Null() { return true; } bool Bool(bool b) { return true; } bool Int(int i) { - if (in_serving_array) { + return true; + } + + bool Uint(unsigned i) { - switch(rf_meas_index) { - case 0: + if (in_serving_report_object) { + if (curr_key.compare("rsrp") == 0) { serving_cell_rsrp = i; - break; - case 1: + } else if (curr_key.compare("rsrq") == 0) { serving_cell_rsrq = i; - break; - case 2: + } else if (curr_key.compare("rssinr") == 0) { serving_cell_sinr = i; - break; } - rf_meas_index++; - } - return true; - } - bool Uint(unsigned u) { + } + + return true; } + bool Int64(int64_t i) { + + return true; } + bool Uint64(uint64_t i) { + return true; } - bool Int64(int64_t i) { return true; } - bool Uint64(uint64_t u) { return true; } bool Double(double d) { return true; } bool String(const char* str, SizeType length, bool copy) { @@ -246,13 +249,22 @@ struct UEDataHandler : public BaseReaderHandler, UEDataHandler> { return true; } - bool StartObject() { return true; } + bool StartObject() { + if (curr_key.compare("ServingCellRF") == 0) { + in_serving_report_object = true; + } + + return true; } bool Key(const char* str, SizeType length, bool copy) { curr_key = str; return true; } - bool EndObject(SizeType memberCount) { return true; } + bool EndObject(SizeType memberCount) { + if (curr_key.compare("ServingCellRF") == 0) { + in_serving_report_object = false; + } + return true; } bool StartArray() { if (curr_key.compare("ServingCellRF") == 0) { @@ -280,7 +292,7 @@ unordered_map get_sdl_ue_data() { unordered_map return_ue_data_map; - std::string prefix3="12"; + std::string prefix3=""; Keys K2 = sdl->findKeys(nsu, prefix3); DataMap Dk2 = sdl->get(nsu, K2); @@ -323,12 +335,12 @@ void policy_callback( Message& mbuf, int mtype, int subid, int len, Msg_componen int rmtype; // received message type - cout << "Policy Callback got a message, type=" << mtype << " , length=" << len << endl; - cout << "payload is " << payload.get() << endl; - + fprintf(stderr, "Policy Callback got a message, type=%d, length=%d\n", mtype, len); const char *arg = (const char*)payload.get(); + fprintf(stderr, "payload is %s\n", payload.get()); + PolicyHandler handler; Reader reader; StringStream ss(arg); @@ -337,7 +349,7 @@ void policy_callback( Message& mbuf, int mtype, int subid, int len, Msg_componen //Set the threshold value if (handler.found_threshold) { - cout << "Setting RSRP Threshold to A1-P value: " << handler.threshold << endl; + fprintf(stderr, "Setting RSRP Threshold to A1-P value: %d\n", handler.threshold); rsrp_threshold = handler.threshold; } @@ -371,7 +383,7 @@ void send_prediction_request(vector ues_to_predict) { for (int i = 0; i < ues_to_predict.size(); i++) { if (i == ues_to_predict.size() - 1) { - ues_list = ues_list + " \"" + ues_to_predict.at(i) + "\""; + ues_list = ues_list + " \"" + ues_to_predict.at(i) + "\"]"; } else { ues_list = ues_list + " \"" + ues_to_predict.at(i) + "\"" + ","; } @@ -385,8 +397,8 @@ void send_prediction_request(vector ues_to_predict) { send_payload = msg->Get_payload(); // direct access to payload // snprintf( (char *) send_payload.get(), 2048, '{"UEPredictionSet" : ["12345"]}', 1 ); - // snprintf( (char *) send_payload.get(), 2048, body); - snprintf( (char *) send_payload.get(), 2048, "{\"UEPredictionSet\": [\"12345\"]}"); + snprintf( (char *) send_payload.get(), 2048, body); + //snprintf( (char *) send_payload.get(), 2048, "{\"UEPredictionSet\": [\"12345\"]}"); fprintf(stderr, "message body %s\n", send_payload.get()); fprintf(stderr, "payload length %d\n", strlen( (char *) send_payload.get() )); @@ -510,20 +522,29 @@ void run_loop() { unordered_map uemap; - vector prediction_ues; - while (1) { uemap = get_sdl_ue_data(); + vector prediction_ues; + for (auto map_iter = uemap.begin(); map_iter != uemap.end(); map_iter++) { string ueid = map_iter->first; + fprintf(stderr,"found a ueid %s\n", ueid.c_str()); UEData data = map_iter->second; + + fprintf(stderr, "current rsrp is %d\n", data.serving_cell_rsrp); + if (data.serving_cell_rsrp < rsrp_threshold) { + fprintf(stderr,"it is less than the rsrp threshold\n"); prediction_ues.push_back(ueid); + } else { + fprintf(stderr,"it is not less than the rsrp threshold\n"); } } + fprintf(stderr, "the size of pred ues is %d\n", prediction_ues.size()); + if (prediction_ues.size() > 0) { send_prediction_request(prediction_ues); } diff --git a/xapp-descriptor/config.json b/xapp-descriptor/config.json index 218cf5f..a00dd37 100644 --- a/xapp-descriptor/config.json +++ b/xapp-descriptor/config.json @@ -7,7 +7,7 @@ "image": { "registry": "nexus3.o-ran-sc.org:10002", "name": "o-ran-sc/ric-app-ts", - "tag": "1.0.12" + "tag": "1.0.13" } } ], -- 2.16.6