Cell down alarm notification [Issue-Id: ODUHIGH-430]
[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
30 /*******************************************************************
31  *
32  * @brief Constructor
33  *
34  * @details
35  *
36  *    Function : VesEventHandler
37  *
38  *    Functionality:
39  *      - Constructor intialization
40  *
41  * @params[in] NULL
42  * @return None
43  ******************************************************************/
44 VesEventHandler::VesEventHandler() : mVesEvent(NULL)
45 {
46
47 }
48
49 /*******************************************************************
50  *
51  * @brief Destructor
52  *
53  * @details
54  *
55  *    Function : ~VesEventHandler
56  *
57  *    Functionality:
58  *      - Destructor
59  *
60  * @params[in] None
61  * @return None
62  ******************************************************************/
63 VesEventHandler::~VesEventHandler()
64 {
65    if( mVesEvent != NULL )
66       delete mVesEvent;
67 }
68
69 /*******************************************************************
70  *
71  * @brief Prepare VES Message
72  *
73  * @details
74  *
75  *    Function : prepare
76  *
77  *    Functionality:
78  *      - prepare VES event
79  *
80  * @params[in] void
81  * @return true     - success
82  *         false    - failure
83  *
84  * ****************************************************************/
85
86 bool VesEventHandler::prepare(VesEventType evtType, const Message* msg)
87 {
88    //check event type and call funtions accordingly
89    bool ret = true;
90    switch(evtType)
91    {
92       case VesEventType::PNF_REGISTRATION:
93       {
94          O1_LOG("\nO1 VesEventHandler : Preparing PNF registration");
95          mVesEvent = new PnfRegistrationEvent();
96          break;
97       }
98       case VesEventType::PM_SLICE:
99       {
100          mVesEvent = new SliceMeasurementEvent;
101          O1_LOG("\nO1 VesEventHandler : Preparing VES PM Slice");
102          break;
103       }
104       case VesEventType::FAULT_NOTIFICATION:
105       {
106          #ifdef StdDef
107          O1_LOG("\nO1 VesEventHandler : Preparing Standard VES fault notification");
108          mVesEvent = new CellStateChangeStdDef();
109          #else
110          O1_LOG("\nO1 VesEventHandler : Preparing VES fault notification");
111          mVesEvent = new CellStateChange();
112          #endif
113          break;
114       }
115
116       default:
117          O1_LOG("\nO1 VesEventHandler : VES message type does not exist ");
118          ret = false;
119          break;
120    }
121    mVesEvent->init();
122    if(!mVesEvent->prepare(msg)) {
123       O1_LOG("\nO1 VesEventHandler : Failed to prepare VES message");
124       ret = false;
125    }
126    return ret;
127 }
128
129 /*******************************************************************
130  *
131  * @brief Send Ves Message
132  *
133  * @details
134  *
135  *    Function : send
136  *
137  *    Functionality:
138  *      - Send VES event to SMO
139  *
140  * @params[in] void
141  * @return true     - success
142  *         false    - failure
143  *
144  * ****************************************************************/
145
146 bool VesEventHandler::send()
147 {
148    if (!mVesEvent->send()) {
149       O1_LOG("\nO1 VesEventHandler : Failed to send VES event");
150       return false;
151    }
152    return true;
153 }
154 /**********************************************************************
155   End of file
156  **********************************************************************/