Slice PM Counters VES Standard defined
[o-du/l2.git] / src / o1 / ves / VesEventHandler.cpp
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /* This file contains functions to support the preparation of Common Header part
20    of VES Event*/
21
22
23 #include "VesEventHandler.hpp"
24 #include "PnfRegistrationEvent.hpp"
25 #include "SliceMeasurementEvent.hpp"
26 #include "Message.hpp"
27 #include "CellStateChange.hpp"
28 #include "CellStateChangeStdDef.hpp"
29 #include "SliceMeasurementEventStdDef.hpp"
30
31 /*******************************************************************
32  *
33  * @brief Constructor
34  *
35  * @details
36  *
37  *    Function : VesEventHandler
38  *
39  *    Functionality:
40  *      - Constructor intialization
41  *
42  * @params[in] NULL
43  * @return None
44  ******************************************************************/
45 VesEventHandler::VesEventHandler() : mVesEvent(NULL)
46 {
47
48 }
49
50 /*******************************************************************
51  *
52  * @brief Destructor
53  *
54  * @details
55  *
56  *    Function : ~VesEventHandler
57  *
58  *    Functionality:
59  *      - Destructor
60  *
61  * @params[in] None
62  * @return None
63  ******************************************************************/
64 VesEventHandler::~VesEventHandler()
65 {
66    if( mVesEvent != NULL )
67       delete mVesEvent;
68 }
69
70 /*******************************************************************
71  *
72  * @brief Prepare VES Message
73  *
74  * @details
75  *
76  *    Function : prepare
77  *
78  *    Functionality:
79  *      - prepare VES event
80  *
81  * @params[in] void
82  * @return true     - success
83  *         false    - failure
84  *
85  * ****************************************************************/
86
87 bool VesEventHandler::prepare(VesEventType evtType, const Message* msg)
88 {
89    //check event type and call funtions accordingly
90    bool ret = true;
91    switch(evtType)
92    {
93       case VesEventType::PNF_REGISTRATION:
94       {
95          O1_LOG("\nO1 VesEventHandler : Preparing PNF registration");
96          mVesEvent = new PnfRegistrationEvent();
97          break;
98       }
99       case VesEventType::PM_SLICE:
100       {
101          #ifdef StdDef
102          mVesEvent = new SliceMeasurementEventStdDef;
103          O1_LOG("\nO1 VesEventHandler : Preparing Standard VES PM Slice");
104          #else
105          mVesEvent = new SliceMeasurementEvent;
106          O1_LOG("\nO1 VesEventHandler : Preparing VES PM Slice");
107          #endif
108          break;
109       }
110       case VesEventType::FAULT_NOTIFICATION:
111       {
112          #ifdef StdDef
113          O1_LOG("\nO1 VesEventHandler : Preparing Standard VES fault notification");
114          mVesEvent = new CellStateChangeStdDef();
115          #else
116          O1_LOG("\nO1 VesEventHandler : Preparing VES fault notification");
117          mVesEvent = new CellStateChange();
118          #endif
119          break;
120       }
121
122       default:
123          O1_LOG("\nO1 VesEventHandler : VES message type does not exist ");
124          ret = false;
125          break;
126    }
127    mVesEvent->init();
128    if(!mVesEvent->prepare(msg)) {
129       O1_LOG("\nO1 VesEventHandler : Failed to prepare VES message");
130       ret = false;
131    }
132    return ret;
133 }
134
135 /*******************************************************************
136  *
137  * @brief Send Ves Message
138  *
139  * @details
140  *
141  *    Function : send
142  *
143  *    Functionality:
144  *      - Send VES event to SMO
145  *
146  * @params[in] void
147  * @return true     - success
148  *         false    - failure
149  *
150  * ****************************************************************/
151
152 bool VesEventHandler::send()
153 {
154    if (!mVesEvent->send()) {
155       O1_LOG("\nO1 VesEventHandler : Failed to send VES event");
156       return false;
157    }
158    return true;
159 }
160 /**********************************************************************
161   End of file
162  **********************************************************************/