1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020-2022] [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 *******************************************************************************/
23 #include "CellStateChange.hpp"
24 #include "JsonHelper.hpp"
26 /* Default constructor*/
27 CellStateChange::CellStateChange() : Notification(VesEventType::FAULT_NOTIFICATION)
32 /* Default Destructor*/
33 CellStateChange::~CellStateChange()
38 /*******************************************************************
40 * @brief Returns ISO time String
44 * Function :getISOEventTime
47 * - Returns ISO time String
49 * @params[in] IN - void
50 * @return value of string - success
51 * empty string - failure
53 * ****************************************************************/
55 std::string CellStateChange::getISOEventTime() {
56 auto now = std::chrono::system_clock::now();
57 auto itt = std::chrono::system_clock::to_time_t(now);
58 std::ostringstream os;
59 os << std::put_time(gmtime(&itt), "%FT%TZ");
63 /*******************************************************************
65 * @brief prepare CellStateChange Fields
69 * Function : prepareCellStateChangeEventFields
72 * - prepare CellStateChange Fields in json format
74 * @params[in] IN - pointer to pnfFields
75 * @return true - success
78 * ****************************************************************/
80 bool CellStateChange::prepareEventFields(const Message* msg) {
81 const Alarm* alrm = dynamic_cast<const Alarm*> (msg);
83 O1_LOG("\nO1 CellStateChange : Casting failed in prepareEventFields");
89 cJSON* faultFields = this->mVesEventFields;
91 if(JsonHelper::addNodeToObject(faultFields, "faultFieldsVersion", FAULT_FIELDS_VERSION) == 0) {
94 if(JsonHelper::addNodeToObject(faultFields, "alarmCondition", ALARM_CONDITION) == 0) {
97 if(JsonHelper::addNodeToObject(faultFields, "alarmInterfaceA", ALARM_INTERFACE_A) == 0) {
100 if(JsonHelper::addNodeToObject(faultFields, "eventSourceType", EVENT_SOURCE_TYPE) == 0) {
103 if(JsonHelper::addNodeToObject(faultFields, "specificProblem", SPECIFIC_PROBLEM) == 0) {
106 if(JsonHelper::addNodeToObject(faultFields, "eventSeverity", EVENT_SEVERITY) == 0) {
109 if(JsonHelper::addNodeToObject(faultFields, "vfStatus", VF_STATUS) == 0) {
113 cJSON* alarmAdditionalInformation = JsonHelper::createNode();
114 if(alarmAdditionalInformation == 0) {
115 O1_LOG("\nO1 CellStateChange : could not create alarmAdditionalInformation JSON object");
118 else if(JsonHelper::addJsonNodeToObject(faultFields, "alarmAdditionalInformation", \
119 alarmAdditionalInformation ) == 0) {
122 else if(JsonHelper::addNodeToObject(alarmAdditionalInformation, "eventTime", getISOEventTime().c_str()) == 0) {
125 else if(JsonHelper::addNodeToObject(alarmAdditionalInformation, "equipType", EQUIP_TYPE) == 0) {
128 else if(JsonHelper::addNodeToObject(alarmAdditionalInformation, "vendor", VENDOR) == 0) {
131 else if(JsonHelper::addNodeToObject(alarmAdditionalInformation, "model", MODEL) == 0) {
140 /**********************************************************************
142 **********************************************************************/