1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020-2021] [HCL Technologies Ltd.] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file contains SliceMeasurementEvent class for preparing the
20 Slice Measurement VES Event*/
22 #include "SliceMeasurementEvent.hpp"
23 #include "JsonHelper.hpp"
24 #include "PmInterface.h"
26 #define MEASUREMENT_INTERVAL 60
27 #define MEASUREMENT_FIELDS_VERSION 4.0
30 SliceMeasurementEvent::SliceMeasurementEvent()
31 : PerfMeasurementEvent(VesEventType::PM_SLICE)
34 /* Default destructor*/
35 SliceMeasurementEvent::~SliceMeasurementEvent()
39 /*******************************************************************
41 * @brief prepare Slice Measurement Fields
45 * Function : prepareEventFields
48 * - prepare Slice Measurement Fields in json format
50 * @params[in] IN - const pointer of Message type
51 * @return true - success
54 * ****************************************************************/
56 bool SliceMeasurementEvent::prepareEventFields(const Message* msg)
59 const SliceMetrics* sliceMetrics = dynamic_cast<const SliceMetrics*> (msg);
62 cJSON *measurementFields = this->mVesEventFields;
64 if(JsonHelper::addNodeToObject(measurementFields, \
65 "measurementFieldsVersion", \
66 MEASUREMENT_FIELDS_VERSION) == 0)
71 cJSON *networkSliceArray = JsonHelper::createArray();
73 if(networkSliceArray == 0)
78 else if (JsonHelper::addJsonNodeToObject(measurementFields, \
79 "networkSliceArray", \
80 networkSliceArray) == 0)
86 const vector<SliceMetricRecord>& sliceList = sliceMetrics->getSliceMetrics();
87 for (size_t i{0}; i < sliceList.size(); i++)
89 cJSON *Slice = JsonHelper::createNode();
91 sprintf(networkId,"%d%x\n", sliceList[i].networkSliceIdentifier.sst,sliceList[i].networkSliceIdentifier.sd);
92 //O1_LOG("sliceList[i].networkSliceIdentifier %s",networkId);
97 else if (JsonHelper::addJsonNodeToArray(networkSliceArray, Slice) == 0)
102 else if (JsonHelper::addNodeToObject(Slice, \
103 "DRB.UEThpDl.SNSSAI", \
104 sliceList[i].DRB_UEThpDl_SNSSAI) == 0)
109 else if (JsonHelper::addNodeToObject(Slice, \
110 "DRB.UEThpUl.SNSSAI", \
111 sliceList[i].DRB_UEThpUl_SNSSAI) == 0)
115 else if (JsonHelper::addNodeToObject(Slice, \
116 "networkSliceIdentifier", \
124 if(JsonHelper::addNodeToObject(measurementFields, \
125 "measurementInterval", \
126 MEASUREMENT_INTERVAL) == 0)
134 /**********************************************************************
136 **********************************************************************/