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();
90 char networkSliceId[7] = {0};
91 sprintf(networkSliceId,"%06X", sliceList[i].networkSliceIdentifier.sd);
96 else if (JsonHelper::addJsonNodeToArray(networkSliceArray, Slice) == 0)
101 else if (JsonHelper::addNodeToObject(Slice, \
102 "DRB.UEThpDl.SNSSAI", \
103 sliceList[i].DRB_UEThpDl_SNSSAI) == 0)
108 else if (JsonHelper::addNodeToObject(Slice, \
109 "DRB.UEThpUl.SNSSAI", \
110 sliceList[i].DRB_UEThpUl_SNSSAI) == 0)
114 else if (JsonHelper::addNodeToObject(Slice, \
115 "networkSliceIdentifier", \
116 networkSliceId) == 0)
123 if(JsonHelper::addNodeToObject(measurementFields, \
124 "measurementInterval", \
125 MEASUREMENT_INTERVAL) == 0)
133 /**********************************************************************
135 **********************************************************************/