/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
*******************************************************************************/
/* This file contains AlarmManager singleton class which is responsible for
- storing and managing alarms.
-*/
+ storing and managing alarms.
+*/
#include <iostream>
#include "AlarmManager.hpp"
using std::pair;
+
/* Default constructor */
AlarmManager::AlarmManager()
{
}
+/*******************************************************************
+ *
+ * @brief Read the data from the connected client application
+ *
+ * @details
+ *
+ * Function : update
+ *
+ * Functionality:
+ * - Reads the data from the connected client application
+ *
+ *
+ * @params[in] char*
+ * @return void
+ ******************************************************************/
+
+void AlarmManager::update(char* recvBuf)
+{
+ O1_LOG("\nO1 AlarmManager update received");
+ AlarmRecord *alrmRec = NULL;
+ Alarm alrm;
+ MsgHeader *msgHdr = (MsgHeader*)recvBuf;
+ O1_LOG("\nO1 AlarmManager: MsgType %d",msgHdr->msgType);
+
+
+ if ( msgHdr->msgType == ALARM ){
+ uint16_t alrmId;
+ alrmRec = (AlarmRecord*) recvBuf;
+ O1_LOG("\nO1 AlarmManager:Alarm info\n"
+ " Action %d\n"
+ " Alarm ID %s\n"
+ " Severity %d\n"
+ " Additional Text %s\n"
+ " Specific Problem %s\n"
+ " Additional Info %s\n"
+ " Alarm Raise Time %s\n",
+ alrmRec->msgHeader.action,
+ alrmRec->alarmId,
+ alrmRec->perceivedSeverity,
+ alrmRec->additionalText,
+ alrmRec->specificProblem,
+ alrmRec->additionalInfo,
+ alrmRec->alarmRaiseTime
+ );
+
+ /*Fill the alarm structure */
+ sscanf(alrmRec->alarmId,"%hu",&alrmId);
+ alrm.setAlarmId(alrmId);
+ alrm.setPerceivedSeverity(alrmRec->perceivedSeverity);
+ alrm.setAdditionalText(alrmRec->additionalText);
+ alrm.setEventType(alrmRec->eventType);
+ alrm.setSpecificProblem(alrmRec->specificProblem);
+ alrm.setAdditionalInfo(alrmRec->additionalInfo);
+ }
+
+ switch(msgHdr->action)
+ {
+ case RAISE_ALARM:
+
+ if(raiseAlarm(alrm))
+ {
+ VesEventHandler vesEventHandler;
+ if (!vesEventHandler.prepare(VesEventType::FAULT_NOTIFICATION, &alrm))
+ return ;//O1::FAILURE;
+
+ O1_LOG("\nO1 AlarmManager : Sending Alarm Data");
+ if ( !vesEventHandler.send() )
+ return ;//O1::FAILURE;
+
+ O1_LOG("\nO1 AlarmManager : "
+ "Alarm raised for alarm Id %s",
+ alrmRec->alarmId);
+ }
+
+ else
+ {
+ O1_LOG("\nO1 AlarmManager : "
+ "Error in raising alarm for alrm Id %s",
+ alrmRec->alarmId);
+ }
+ break;
+
+ case CLEAR_ALARM:
+ if(clearAlarm(alrm))
+ {
+ O1_LOG("\nO1 AlarmManager : "
+ "Alarm cleared for alarm Id %s",
+ alrmRec->alarmId);
+
+ }
+ else
+ {
+ O1_LOG("\nO1 AlarmManager : "
+ "Error in clearing alarm for alarm Id %s",
+ alrmRec->alarmId);
+ }
+ break;
+ default:
+ O1_LOG("\nO1 AlarmManager : No action performed");
+ break;
+ }
+
+}
+
-/**********************************************************************
+/**********************************************************************
Description : Raise an Alarm and store it in alarm list
Params[In] : Alarm
Return : true - insert in map successful
- false - insert in map unsuccessful
+ false - insert in map unsuccessful
**********************************************************************/
bool AlarmManager::raiseAlarm(const Alarm& alarm)
{
ret = mAlarmList.insert(pair<uint16_t,Alarm>(alarm.getAlarmId(),alarm));
return ret.second;
-
+
}
-/**********************************************************************
- Description : Clear an Alarm and delete it from alarm list
+/**********************************************************************
+ Description : Clear an Alarm and delete it from alarm list
Params[In] : Alarm instance
Return : true - delete successful
- false - delete unsuccessful
+ false - delete unsuccessful
**********************************************************************/
bool AlarmManager::clearAlarm(const Alarm& alarm)
{
{
mAlarmList.erase(it);
ret = true;
- }
+ }
return ret;
}
-/**********************************************************************
+
+/**********************************************************************
Description : Clear an Alarm and delete it from alarm list with
- alarmId
+ alarmId
Params[In] : Alarm Id
Return : true - delete successful
- false - delete unsuccessful
+ false - delete unsuccessful
**********************************************************************/
bool AlarmManager::clearAlarm(const uint16_t& alarmId)
{
}
-/**********************************************************************
+/**********************************************************************
Description : Return the list of active alarms
Params[In] : None
Return : constant reference to the map<int, Alarm>
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
#include "PnfRegistrationThread.hpp"
#include "VesUtils.hpp"
#include "VesEventHandler.hpp"
+#include "Observer.hpp"
using std::map;
-
-class AlarmManager : public Singleton<AlarmManager>
+class AlarmManager : public Singleton<AlarmManager> ,public Observer
{
friend Singleton<AlarmManager>;
private:
- map<uint16_t,Alarm> mAlarmList;
+ map<uint16_t,Alarm> mAlarmList;
protected:
- AlarmManager();
+ AlarmManager();
~AlarmManager();
public:
+
+ void update(char* recvBuf);
bool raiseAlarm(const Alarm& alarm);
bool clearAlarm(const uint16_t& alarmId);
bool clearAlarm(const Alarm& alarm );
/*******************************************************************
*
- * @brief Runs the O1 modules as a thread
+ * @brief Runs the O1 modules as a thread
*
* @details
*
{
if( !sessHdlr.init() )
{
- O1_LOG("\nO1 O1App : SessionHandler initialization failed ");
+ O1_LOG("\nO1 O1App : SessionHandler initialization failed ");
return false;
}
}
- catch( const std::exception& e )
+ catch( const std::exception& e )
{
O1_LOG("\nO1 O1App : Exception : %s", e.what());
return false;
}
-
+
/* Start the Unix Socket Server to listen for alarm messages */
+ AlarmManager::instance().subscribe(&mUxSocketServer);
if( mUxSocketServer.start() )
- {
-
+ {
+
if(mUxSocketServer.setAffinity(O1::CPU_CORE))
{
O1_LOG("\nO1 O1App : CPU affinity set for UnixSocketServer thread to " );
mUxSocketServer.printAffinity();
}
-
+
sleep(SLEEP_INTERVAL);
- if( mUxSocketServer.isRunning() )
+ if( mUxSocketServer.isRunning() )
{
mStartupStatus = true;
O1_LOG("\nO1 O1App : Unix Socket server started");
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#include "Observer.hpp"
+#include "GlobalDefs.hpp"
+#include "Subject.hpp"
+
+/* Default Constructor*/
+Observer::Observer()
+{
+
+}
+
+/* Default destructor*/
+Observer::~Observer()
+{
+
+}
+
+/**********************************************************************
+ Description : Getting message from Subject
+ Params[In] : char*
+ Return : void
+**********************************************************************/
+
+void Observer::update(char* message) {
+ this->mMessage = message;
+
+}
+
+/**********************************************************************
+ Description : Subscribe Observer to Subject
+ Params[In] : Subject
+ Return : void
+**********************************************************************/
+
+void Observer::subscribe(Subject *subject)
+{
+ this->mSubject = subject;
+ this->mSubject->registerObserver(this);
+}
+
+/**********************************************************************
+ Description : Unsubscribe observer from Subject
+ Params[In] : void
+ Return : void
+**********************************************************************/
+
+void Observer::unsubscribe() {
+ this->mSubject->unregisterObserver(this);
+}
+
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#ifndef __OBSERVER_HPP__
+#define __OBSERVER_HPP__
+
+#include <stdio.h>
+
+class Subject;
+class Observer
+{
+ public:
+ Observer();
+ ~Observer();
+ virtual void update(char* message);
+ virtual void unsubscribe();
+ virtual void subscribe(Subject *subject);
+
+ protected:
+ char* mMessage;
+ Subject *mSubject;
+};
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#include <iostream>
+#include "Subject.hpp"
+#include "GlobalDefs.hpp"
+
+/* Constructor*/
+Subject::Subject() {
+ mMessage=NULL;
+}
+
+/* Default destructor*/
+Subject::~Subject() {
+
+}
+
+/**********************************************************************
+ Description : Register an Observer
+ Params[In] : Observer
+ Return : void
+**********************************************************************/
+void Subject::registerObserver(Observer *observer)
+{
+ mObserversList.push_back(observer);
+}
+
+/**********************************************************************
+ Description : Unregister an Observer
+ Params[In] : Observer
+ Return : void
+**********************************************************************/
+void Subject::unregisterObserver(Observer *observer)
+{
+ mObserversList.remove(observer);
+}
+
+/**********************************************************************
+ Description : Notify all observers on new message
+ Params[In] : void
+ Return : void
+**********************************************************************/
+void Subject::notifyObservers()
+{
+ std::list<Observer *>::iterator iterator = mObserversList.begin();
+ while (iterator != mObserversList.end())
+ {
+ (*iterator)->update(mMessage);
+ iterator++;
+ }
+}
+
+/**********************************************************************
+ Description : Accept a message
+ Params[In] : Message
+ Return : void
+**********************************************************************/
+void Subject::createMessage(char* message )
+{
+ mMessage = message;
+ notifyObservers();
+}
+
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2021] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#ifndef __SUBJECT_HPP__
+#define __SUBJECT_HPP__
+
+
+#include <stdio.h>
+#include <list>
+#include "Observer.hpp"
+
+
+class Subject
+{
+ public:
+
+ Subject() ;
+ ~Subject() ;
+
+ virtual void registerObserver(Observer *observer);
+ virtual void unregisterObserver(Observer *observer);
+ virtual void notifyObservers();
+ virtual void createMessage(char* message );
+ protected:
+ std::list<Observer *> mObserversList;
+ char* mMessage;
+};
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
################################################################################
*******************************************************************************/
-/* This file contains UnixSocketServer class that listens for Netconf Alarm
+/* This file contains UnixSocketServer class that listens for Netconf Alarm
messages on a Unix socket from ODU. It calls the AlarmManager functions
- for raising or clearing the alarms based on the actions received
-*/
+ for raising or clearing the alarms based on the actions received */
#include "UnixSocketServer.hpp"
#include "Alarm.hpp"
-#include "AlarmManager.hpp"
#include "CmInterface.h"
#include "GlobalDefs.hpp"
#include <iostream>
******************************************************************/
UnixSocketServer::UnixSocketServer(const string& sockPath)
: mSockPath(sockPath),
- mIsRunning(false)
+ mIsRunning(false)
{
-}
-
+}
+
/*******************************************************************
*
* @brief Destructor
******************************************************************/
int UnixSocketServer::readMessage(int fd)
{
- AlarmRecord *alrmRec = NULL;
char recvBuf[BUFLEN];
- Alarm alrm;
bzero(&recvBuf,sizeof(recvBuf));
-
+
int nbytes = read (fd, &recvBuf, sizeof(recvBuf));
-
+
if (nbytes > 0)
{
- MsgHeader *msgHdr = (MsgHeader*)recvBuf;
-
- O1_LOG("\nO1 UnixSocketServer :\nMsgType %d",msgHdr->msgType);
-
- if ( msgHdr->msgType == ALARM ){
- uint16_t alrmId;
- alrmRec = (AlarmRecord*) recvBuf;
- O1_LOG("\nO1 UnixSocketServer :\n"
- "Action %d\n"
- "Alarm ID %s\n"
- "Severity %d\n"
- "Additional Text %s\n"
- "Specific Problem %s\n"
- "Additional Info %s\n"
- "Alarm Raise Time %s\n",
- alrmRec->msgHeader.action,
- alrmRec->alarmId,
- alrmRec->perceivedSeverity,
- alrmRec->additionalText,
- alrmRec->specificProblem,
- alrmRec->additionalInfo,
- alrmRec->alarmRaiseTime
- );
-
- /*Fill the alarm structure */
- sscanf(alrmRec->alarmId,"%hu",&alrmId);
- alrm.setAlarmId(alrmId);
- alrm.setPerceivedSeverity(alrmRec->perceivedSeverity);
- alrm.setAdditionalText(alrmRec->additionalText);
- alrm.setEventType(alrmRec->eventType);
- alrm.setSpecificProblem(alrmRec->specificProblem);
- alrm.setAdditionalInfo(alrmRec->additionalInfo);
- }
-
- switch(msgHdr->action)
- {
- case RAISE_ALARM:
-
- if(AlarmManager::instance().raiseAlarm(alrm))
- {
- O1_LOG("\nO1 UnixSocketServer : "
- "Alarm raised for alarm Id %s",
- alrmRec->alarmId);
- }
-
- else
- {
- O1_LOG("\nO1 UnixSocketServer : "
- "Error in raising alarm for alrm Id %s",
- alrmRec->alarmId);
- }
- break;
-
- case CLEAR_ALARM:
- if(AlarmManager::instance().clearAlarm(alrm))
- {
- O1_LOG("\nO1 UnixSocketServer : "
- "Alarm cleared for alarm Id %s",
- alrmRec->alarmId);
-
- }
- else
- {
- O1_LOG("\nO1 UnixSocketServer : "
- "Error in clearing alarm for alarm Id %s",
- alrmRec->alarmId);
- }
- break;
- default:
- O1_LOG("\nO1 UnixSocketServer : No action performed");
- break;
- }
+ /* sending message to all Unix Socket Server subscribers */
+ createMessage(recvBuf);
}
+
return nbytes;
}
* O1:FAILURE - failure
******************************************************************/
-int UnixSocketServer::makeSocket()
+int UnixSocketServer::makeSocket()
{
struct sockaddr_un name;
/* Create the socket. */
bzero(&name, sizeof(name));
name.sun_family = AF_UNIX;
- /* Remove the socket file if it already exists */
+ /* Remove the socket file if it already exists */
if ( unlink(mSockPath.c_str()) == 0)
{
O1_LOG("\nO1 UnixSocketServer : "
"Removing the existing socket path %s",
mSockPath.c_str());
- }
+ }
strcpy(name.sun_path, mSockPath.c_str());
if (bind (mSock, (struct sockaddr *) &name, sizeof (name)) < 0)
{
* Function : run
*
* Functionality:
- * - A Unix server to handle multiple connection
+ * - A Unix server to handle multiple connection
* Uses select multiplexing
*
* @params[in] void
}
O1_LOG("\nO1 UnixSocketServer : Connected from client\n");
FD_SET (newFd, &active_fd_set);
- }
+ }
else
{
/* Data arriving on an already-connected socket. */
FD_CLR (i, &active_fd_set);
}
}
- }
- }/* for loop ends */
+ }
+ }/* for loop ends */
} /* while(1) ends */
} /* else ends */
} /* outer if ends */
*******************************************************************************/
/* This file contains UnixSocketServer class that listens for Netconf Alarm messages
- on a Unix socket from ODU. It calls the AlarmManager functions for raising
- or clearing the alarms based on the actions received
+ on a Unix socket from ODU. It calls the AlarmManager functions for raising
+ or clearing the alarms based on the actions received
*/
#ifndef __UNIX_SOCKET_SERVER_HPP__
#include <string>
#include <pthread.h>
#include "Thread.hpp"
+#include "Subject.hpp"
using std::string;
#define BUFLEN 512
-class UnixSocketServer : public Thread
+class UnixSocketServer : public Thread , public Subject
{
private:
string mSockPath;
int readMessage(int);
int makeSocket();
-
+
protected:
bool run();
bool mIsRunning;
public:
- UnixSocketServer(const string& sockPath);
+ UnixSocketServer(const string& sockPath);
~UnixSocketServer();
- bool isRunning() const;
+ bool isRunning() const;
virtual void cleanUp(void);
};
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#include <iostream>
+#include <chrono>
+#include <iomanip>
+#include <sstream>
+#include "CellStateChange.hpp"
+#include "JsonHelper.hpp"
+
+/* Default constructor*/
+CellStateChange::CellStateChange() : Notification(VesEventType::FAULT_NOTIFICATION)
+{
+
+}
+
+/* Default Destructor*/
+CellStateChange::~CellStateChange()
+{
+
+}
+
+/*******************************************************************
+ *
+ * @brief Returns ISO time String
+ *
+ * @details
+ *
+ * Function :getISOEventTime
+ *
+ * Functionality:
+ * - Returns ISO time String
+ *
+ * @params[in] IN - void
+ * @return value of string - success
+ * empty string - failure
+ *
+ * ****************************************************************/
+
+std::string CellStateChange::getISOEventTime() {
+ auto now = std::chrono::system_clock::now();
+ auto itt = std::chrono::system_clock::to_time_t(now);
+ std::ostringstream os;
+ os << std::put_time(gmtime(&itt), "%FT%TZ");
+ return os.str();
+}
+
+/*******************************************************************
+ *
+ * @brief prepare CellStateChange Fields
+ *
+ * @details
+ *
+ * Function : prepareCellStateChangeEventFields
+ *
+ * Functionality:
+ * - prepare CellStateChange Fields in json format
+ *
+ * @params[in] IN - pointer to pnfFields
+ * @return true - success
+ * false - failure
+ *
+ * ****************************************************************/
+
+bool CellStateChange::prepareEventFields(const Message* msg) {
+ const Alarm* alrm = dynamic_cast<const Alarm*> (msg);
+ if(!alrm) {
+ O1_LOG("\nO1 CellStateChange : Casting failed in prepareEventFields");
+ return false;
+ }
+ bool ret = true;
+
+
+ cJSON* faultFields = this->mVesEventFields;
+
+ if(JsonHelper::addNodeToObject(faultFields, "faultFieldsVersion", FAULT_FIELDS_VERSION) == 0) {
+ ret = false;
+ }
+ if(JsonHelper::addNodeToObject(faultFields, "alarmCondition", ALARM_CONDITION) == 0) {
+ ret = false;
+ }
+ if(JsonHelper::addNodeToObject(faultFields, "alarmInterfaceA", ALARM_INTERFACE_A) == 0) {
+ ret = false;
+ }
+ if(JsonHelper::addNodeToObject(faultFields, "eventSourceType", EVENT_SOURCE_TYPE) == 0) {
+ ret = false;
+ }
+ if(JsonHelper::addNodeToObject(faultFields, "specificProblem", SPECIFIC_PROBLEM) == 0) {
+ ret = false;
+ }
+ if(JsonHelper::addNodeToObject(faultFields, "eventSeverity", EVENT_SEVERITY) == 0) {
+ ret = false;
+ }
+ if(JsonHelper::addNodeToObject(faultFields, "vfStatus", VF_STATUS) == 0) {
+ ret = false;
+ }
+
+ cJSON* alarmAdditionalInformation = JsonHelper::createNode();
+ if(alarmAdditionalInformation == 0) {
+ O1_LOG("\nO1 CellStateChange : could not create alarmAdditionalInformation JSON object");
+ return false;
+ }
+ else if(JsonHelper::addJsonNodeToObject(faultFields, "alarmAdditionalInformation", \
+ alarmAdditionalInformation ) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(alarmAdditionalInformation, "eventTime", getISOEventTime().c_str()) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(alarmAdditionalInformation, "equipType", EQUIP_TYPE) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(alarmAdditionalInformation, "vendor", VENDOR) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(alarmAdditionalInformation, "model", MODEL) == 0) {
+ ret = false;
+ }
+
+
+ return ret;
+}
+
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#ifndef __CELL_STATE_CHANGE_HPP__
+#define __CELL_STATE_CHANGE_HPP__
+
+
+#include <iostream>
+
+#include "VesEvent.hpp"
+#include "AlarmMessages.h"
+#include "Alarm.hpp"
+#include "AlarmManager.hpp"
+#include "Message.hpp"
+#include "Notification.hpp"
+
+using namespace std;
+
+//macros
+#define FAULT_FIELDS_VERSION "4.0"
+#define ALARM_CONDITION "CELL Down"
+#define ALARM_INTERFACE_A "Slot-0-CELL-1"
+#define EVENT_SOURCE_TYPE "O_RAN_COMPONENT"
+#define SPECIFIC_PROBLEM "CELL 1 Down"
+#define EVENT_SEVERITY "MAJOR"
+#define VF_STATUS "Active"
+#define EQUIP_TYPE "O-RAN-DU"
+#define VENDOR "Melacon"
+#define MODEL "ODU Device"
+
+class CellStateChange : public Notification
+{
+
+ public:
+ CellStateChange();
+ ~CellStateChange();
+
+ std::string getISOEventTime();
+
+ protected:
+ bool prepareEventFields(const Message* msg = NULL);
+
+};
+
+
+#endif
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#include <iostream>
+#include <chrono>
+#include <iomanip>
+#include <sstream>
+#include "CellStateChangeStdDef.hpp"
+#include "JsonHelper.hpp"
+/* Default constructor*/
+CellStateChangeStdDef::CellStateChangeStdDef() : Notification(VesEventType::FAULT_NOTIFICATION)
+{
+
+}
+
+/* Default Destructor*/
+CellStateChangeStdDef::~CellStateChangeStdDef()
+{
+
+}
+
+
+/*******************************************************************
+ *
+ * @brief Returns ISO time String
+ *
+ * @details
+ *
+ * Function :getISOEventTime
+ *
+ * Functionality:
+ * - Returns ISO time String
+ *
+ * @params[in] IN - void
+ * @return value of string - success
+ * empty string - failure
+ *
+ * ****************************************************************/
+
+std::string CellStateChangeStdDef::getISOEventTime() {
+ auto now = std::chrono::system_clock::now();
+ auto itt = std::chrono::system_clock::to_time_t(now);
+ std::ostringstream os;
+ os << std::put_time(gmtime(&itt), "%FT%TZ");
+ return os.str();
+}
+
+/*******************************************************************
+ *
+ * @brief prepare CellStateChangeStdDef Fields
+ *
+ * @details
+ *
+ * Function : prepareCellStateChangeStdDefEventFields
+ *
+ * Functionality:
+ * - prepare CellStateChangeStdDef Fields in json format
+ *
+ * @params[in] IN - pointer to pnfFields
+ * @return true - success
+ * false - failure
+ *
+ * ****************************************************************/
+
+bool CellStateChangeStdDef::prepareEventFields(const Message* msg) {
+ const Alarm* alrm = dynamic_cast<const Alarm*> (msg);
+ if(!alrm) {
+ O1_LOG("\nO1 CellStateChangeStdDef : Casting failed in prepareEventFields");
+ return false;
+ }
+ bool ret = true;
+
+
+ cJSON* stndDefinedFields = this->mVesEventFields;
+
+ if(JsonHelper::addNodeToObject(stndDefinedFields, "schemaReference", FAULT_SCHEMA) == 0) {
+ ret = false;
+ }
+
+ cJSON* data = JsonHelper::createNode();
+ if(data == 0) {
+ O1_LOG("\nO1 CellStateChangeStdDef : could not create data JSON object");
+ return false;
+ }
+ else if(JsonHelper::addJsonNodeToObject(stndDefinedFields, "data", \
+ data) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "href", HREF) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "uri", URI) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "notificationId", NOTIFICATION_ID) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "notificationType", NOTIFICATION_TYPE) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "eventTime", getISOEventTime().c_str()) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "systemDN", "") == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "probableCause", PROBABLE_CAUSE) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "perceivedSeverity",PERCEIVED_SEVERITY) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "rootCauseIndicator", (bool)false ) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "specificProblem", "") == 0) {
+ ret = false;
+ }
+
+ cJSON* correlatedNotificationsArr= cJSON_CreateArray();
+ if (correlatedNotificationsArr == NULL)
+ {
+ ret = false;
+ }
+ cJSON_AddItemToObject(data, "correlatedNotifications", correlatedNotificationsArr);
+
+ if(JsonHelper::addNodeToObject(data, "backedUpStatus", (bool)true) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "backUpObject", "") == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "trendIndication", TRND_INDICATION) == 0) {
+ ret = false;
+ }
+
+ cJSON* thresholdInfo = JsonHelper::createNode();
+ if(thresholdInfo == 0) {
+ O1_LOG("\nO1 CellStateChange : could not create thresholdInfo JSON object");
+ return false;
+ }
+ else if(JsonHelper::addJsonNodeToObject(data, "thresholdInfo", \
+ thresholdInfo ) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(thresholdInfo, "observedMeasurement", OBSRVED_MEASUREMENT) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(thresholdInfo, "observedValue", OBSERVED_VALUE) == 0) {
+ ret = false;
+ }
+
+ cJSON* stateChangeDefinitionArr= cJSON_CreateArray();
+ if (stateChangeDefinitionArr == NULL)
+ {
+ ret = false;
+ }
+ cJSON_AddItemToObject(data, "stateChangeDefinition", stateChangeDefinitionArr);
+
+ cJSON* monitoredAttributes = JsonHelper::createNode();
+ if( monitoredAttributes == 0) {
+ O1_LOG("\nO1 CellStateChange : could not create monitoredAttributes JSON object");
+ return false;
+ }
+ else if(JsonHelper::addJsonNodeToObject(data , "monitoredAttributes", \
+ monitoredAttributes ) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(monitoredAttributes, "newAtt", NEW_ATT) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "proposedRepairActions", PROPOSED_REPAIR_ACTION) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data, "additionalText", ADDITIONAL_TEXT) == 0) {
+ ret = false;
+ }
+
+ cJSON* additionalInformation = JsonHelper::createNode();
+ if(additionalInformation == 0) {
+ O1_LOG("\nO1 CellStateChangeStdDef : could not create additionalInformation JSON object");
+ return false;
+ }
+ else if(JsonHelper::addJsonNodeToObject(data , "additionalInformation", \
+ additionalInformation ) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject( additionalInformation, "addInfo", ADD_INFO) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data , "alarmId", ALARM_ID) == 0) {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(data , "alarmType",ALRAM_TYPE ) == 0) {
+ ret = false;
+ }
+
+ else if(JsonHelper::addNodeToObject(stndDefinedFields, "stndDefinedFieldsVersion", STND_DEFINED_FEILD_VERSION) == 0) {
+ ret = false;
+ }
+
+
+
+ return ret;
+}
+
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#ifndef __CELL_STATE_CHANGE_STD_DEF_HPP__
+#define __CELL_STATE_CHANGE_STD_DEF_HPP__
+
+
+#include <iostream>
+
+#include "VesEvent.hpp"
+#include "AlarmMessages.h"
+#include "Alarm.hpp"
+#include "AlarmManager.hpp"
+#include "Message.hpp"
+#include "Notification.hpp"
+
+using namespace std;
+
+#define FAULT_SCHEMA "https://forge.3gpp.org/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm"
+#define HREF "1"
+#define URI "1"
+#define NOTIFICATION_ID 1.0
+#define NOTIFICATION_TYPE "notifyNewAlarm"
+#define PROBABLE_CAUSE "real-issue"
+#define TRND_INDICATION "MORE_SEVERE"
+#define OBSRVED_MEASUREMENT "new"
+#define OBSERVED_VALUE 123.2
+#define NEW_ATT "new"
+#define ADD_INFO "new"
+#define ALARM_ID "1"
+#define ALRAM_TYPE "COMMUNICATIONS_ALARM"
+#define STND_DEFINED_FEILD_VERSION "1.0"
+#define PERCEIVED_SEVERITY "INDETERMINATE"
+#define PROPOSED_REPAIR_ACTION "Call the police!"
+#define ADDITIONAL_TEXT "O-RAN Software Community"
+
+
+class CellStateChangeStdDef : public Notification
+{
+
+ public:
+ CellStateChangeStdDef();
+ ~CellStateChangeStdDef();
+
+ std::string getISOEventTime();
+
+ protected:
+ bool prepareEventFields(const Message* msg = NULL);
+
+
+};
+
+
+#endif
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
}
+/*******************************************************************
+ *
+ * @brief wraps cJSON_AddNumberToObject cJSON library function
+ *
+ * @details
+ *
+ * Function : addNodeToObject
+ *
+ * Functionality:
+ * - wraps cJSON_AddNumberToObject cJSON library function
+ *
+ * @params[in] cJSON * parent, const char * nodeName, bool value
+ * @return pointer to cJSON object - success
+ * NULL - failure
+ *
+ * ****************************************************************/
+
+cJSON* JsonHelper::addNodeToObject(cJSON * parent, \
+ const char * nodeName, bool value)
+{
+ return cJSON_AddBoolToObject(parent, nodeName, (bool) value);
+}
+
/*******************************************************************
*
* @brief wraps cJSON_AddItemToObject cJSON library function
return cJSON_AddItemToObject(parent, nodeName, node);
}
+
/*******************************************************************
*
* @brief wraps cJSON_Delete cJSON library function
const char* value);
static cJSON* addNodeToObject(cJSON * parent, \
const char * nodeName, double value);
-
+ static cJSON* addNodeToObject(cJSON * parent, \
+ const char * nodeName, bool value);
static void deleteNode(cJSON * node);
static cJSON_bool addJsonNodeToObject(cJSON * parent, \
const char * nodeName, cJSON * node);
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#include "Notification.hpp"
+
+/* Default constructor*/
+Notification::Notification(VesEventType eventType)
+ :VesEvent(eventType)
+{
+
+}
+
+/* Default Destructor*/
+Notification::~Notification()
+{
+
+}
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2022] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+#ifndef __NOTIFICATION__
+#define __NOTIFICATION__
+
+#include "VesEvent.hpp"
+
+class Notification : public VesEvent {
+
+public:
+ Notification(VesEventType eventType);
+ ~Notification();
+};
+
+#endif
+/**********************************************************************
+ End of file
+ **********************************************************************/
#include "JsonHelper.hpp"
#include "PmInterface.h"
-#define MEASUREMENT_INTERVAL 60
+#define MEASUREMENT_INTERVAL 60.0
#define MEASUREMENT_FIELDS_VERSION "4.0"
/* Constructor*/
#include <sstream>
#include "JsonHelper.hpp"
#include "VesCommonHeader.hpp"
+#include "VesUtils.hpp"
-static uint16_t seqNo = 0;
+static double seqNo = 0;
#define MAX_TIME_STR 35
*
* ****************************************************************/
-uint16_t VesCommonHeader::nextSequenceNo()
+double VesCommonHeader::nextSequenceNo()
{
return seqNo++;
}
*
* ****************************************************************/
-uint16_t VesCommonHeader::getSequenceNo()
+double VesCommonHeader::getSequenceNo()
{
return seqNo;
}
str = "pnfRegistration";
break;
case VesEventType::FAULT_NOTIFICATION:
- str = "faultNotification";
+ #ifdef StdDef
+ str = "stndDefined";
+ #else
+ str = "fault";
+ #endif
break;
case VesEventType::PM_NOTIFICATION:
str = "pmNotification";
evntId = "_" + stringEpochTime + "_" + "PM1min";
break;
case VesEventType::FAULT_NOTIFICATION:
- evntId = getSourceName() + "_" + MODEL_NUMBER_007_DEV;
+ #ifdef StdDef
+ evntId = FAULT_EVENTID;
+ #else
+ evntId ="O_RAN_COMPONENT_Alarms-61";
+ #endif
break;
default:
O1_LOG("\nO1 VesCommonHeader : this VES msg Type support in getEventId is \
/*******************************************************************
*
- * @brief create Ves Event Type
+ * @brief create Ves Event Type from Ves Event type
*
* @details
*
* Function : getEventType
*
* Functionality:
- * - create Ves Event Type
+ * - create Ves Event Type from Ves Event type
*
* @params[in] IN - void
* @return value of string - success
evntType = EVENT_TYPE_ORAN_COMPONENT_PM;
break;
case VesEventType::FAULT_NOTIFICATION:
- evntType = EVENT_TYPE_5G;
+ evntType = FAULT_TYPE;
break;
default:
O1_LOG("\nO1 VesCommonHeader : this VES msg Type support in getEvenType is \
evntName = getEventTypeToStr() + "_" + EVENT_TYPE_ORAN_COMPONENT_PM;
break;
case VesEventType::FAULT_NOTIFICATION:
- evntName = getEventTypeToStr() + "_" + EVENT_TYPE_5G;
+ #ifdef StdDef
+ evntName = FAULT_EVENT_NAME;
+ #else
+ evntName ="O_RAN_COMPONENT_Alarms";
+ #endif
break;
default:
O1_LOG("\nO1 VesCommonHeader : This VES msg Type support in getEventName is \
*
* @details
*
- * Function : getReportingEntityName
+ * Function : getReportingEntityId
*
* Functionality:
* - create Ves Event Name from Ves Event type
* empty string - failure
* ****************************************************************/
-string VesCommonHeader::getReportingEntityName()
+string VesCommonHeader::getReportingEntityId()
{
- /*Currently PNF_REGISTRATION and PM_SLICE are only supported.
+ /*Currently PNF_REGISTRATION and PM_SLICE are only supported.
This function must be updated in later releases*/
+ string evntName = "";
+ switch(mEventType)
+ {
+ case VesEventType::PNF_REGISTRATION:
+ evntName = ODU_HIGH;
+ break;
+
+ case VesEventType::FAULT_NOTIFICATION:
+ evntName = ODU_HIGH;
+ break;
+ default:
+ break;
+ }
+ return evntName;
+}
+
+/*******************************************************************
+ *
+ * @brief create Reporting Entity Name from Ves Event type
+ *
+ * @details
+ *
+ * Function : getReportingEntityName
+ *
+ * Functionality:
+ * - create Reporting Entity Name from Ves Event type
+ *
+ * @params[in] IN - void
+ * @return value of string - success
+ * empty string - failure
+ * ****************************************************************/
+
+string VesCommonHeader::getReportingEntityName()
+{
string evntName = "";
switch(mEventType)
{
evntName = PM_REPORTING_ENTITY;
break;
case VesEventType::FAULT_NOTIFICATION:
- evntName = getSourceName();
+ evntName = ODU_HIGH;
break;
default:
O1_LOG("\nO1 VesCommonHeader : This VES msg Type support in \
/*******************************************************************
*
- * @brief create Ves Event Name from Ves Event type
+ * @brief create Source Name from Ves Event type
*
* @details
*
- * Function : getReportingEntityName
+ * Function : getSourceName
*
* Functionality:
- * - create Ves Event Name from Ves Event type
+ * - create Source Name from Ves Event type
*
* @params[in] IN - void
* @return value of string - success
string VesCommonHeader::getSourceName()
{
- return ODU_HIGH;
+ string sourceName = "";
+ switch(mEventType)
+
+ {
+ case VesEventType::PNF_REGISTRATION:
+ sourceName = ODU_HIGH;
+ break;
+ case VesEventType::FAULT_NOTIFICATION:
+ sourceName = ODU_HIGH;
+ break;
+ default:
+ break;
+ }
+ return sourceName;
+}
+
+/*******************************************************************
+ *
+ * @brief create Ves Event SourceId from Ves Event type
+ *
+ * @details
+ *
+ * Function : getSourceId
+ *
+ * Functionality:
+ * - create Ves Event SourceId from Ves Event type
+ *
+ * @params[in] IN - void
+ * @return value of string - success
+ * empty string - failure
+ * ****************************************************************/
+string VesCommonHeader::getSourceId()
+{
+ string sourceId = "";
+ switch(mEventType)
+ {
+ case VesEventType::FAULT_NOTIFICATION:
+ sourceId = SOURCE_ID;
+ break;
+ default:
+ break;
+ }
+ return sourceId;
+}
+
+/*******************************************************************
+ *
+ * @brief create Ves Event Name from Ves Event type
+ *
+ * @details
+ *
+ * Function : getnfcNamingCode
+ *
+ * Functionality: create Ves Event nfc naming code
+ *
+ * @params[in] IN - void
+ * @return value of string - success
+ * empty string - failure
+ * ****************************************************************/
+
+string VesCommonHeader::getnfcNamingCode()
+{
+ string name = "";
+ switch(mEventType)
+ {
+ case VesEventType::FAULT_NOTIFICATION:
+ name = NFC_NAMING_CODE;
+ break;
+ default:
+ break;
+ }
+ return name;
}
/*******************************************************************
string VesCommonHeader::getNamingCode()
{
- return NAMING_CODE_ODU;
+
+ string nammingcdoe = "";
+ switch(mEventType)
+ {
+ case VesEventType::PNF_REGISTRATION:
+ nammingcdoe = NAMING_CODE_ODU;
+ break;
+ case VesEventType::PM_SLICE:
+ break;
+ case VesEventType::FAULT_NOTIFICATION:
+ nammingcdoe = NAMING_CODE_ODU;
+ break;
+ default:
+ O1_LOG("\nO1 VesCommonHeader : This VES msg Type support in \
+ getReportingEntityName is not available");
+ break;
+ }
+ return nammingcdoe;
}
*
* ****************************************************************/
-uint64_t VesCommonHeader::getEpochTime()
+double VesCommonHeader::getEpochTime()
{
- uint64_t epochTimeInMicrosec = std::chrono::duration_cast \
+ double epochTimeInMicrosec = std::chrono::duration_cast \
<std::chrono::microseconds> \
(std::chrono::system_clock::now().time_since_epoch()).count();
return epochTimeInMicrosec;
return oss.str();
}
+
/*******************************************************************
*
- * @brief create Ves Event Name from Ves Event type
+ * @brief create Ves stndDefinedNamespace from Ves Event type
*
* @details
*
- * Function : getEventName
+ * Function : getstndDefinedNamespace
+ *
+ * Functionality: create Ves tndDefinedNamespace
+ *
+ * @params[in] IN - void
+ * @return value of string - success
+ * empty string - failure
+ * ****************************************************************/
+
+string VesCommonHeader::getstndDefinedNamespace()
+{
+ string stndDefinedNamespace="";
+ switch(mEventType)
+ {
+ case VesEventType::FAULT_NOTIFICATION:
+ stndDefinedNamespace = STND_DEFINED_NAMESPACE;
+ break;
+ default:
+ break;
+ }
+ return stndDefinedNamespace;
+
+}
+
+/*******************************************************************
+ *
+ * @brief Prepare VES Message
+ *
+ * @details
+ *
+ * Function : prepare
*
* Functionality:
- * - create Ves Event Name from Ves Event type
+ * - prepare VES event
*
- * @params[in] IN - VesEventType , OUT - Ves Event Name
- * @return ture - success
+ * @params[in] void
+ * @return true - success
* false - failure
*
* ****************************************************************/
+
bool VesCommonHeader::prepare(cJSON *commonHeader, \
VesEventType type)
{
//local utility variables:
time_t intervalStartTime = getCurrentTime();
time_t intervalEndTime = intervalStartTime+60; /*adding 1 min to system time*/
- uint64_t startEpochTime = getEpochTime();
+ double startEpochTime = getEpochTime();
mLastEpochTime = startEpochTime+60*100000; /*adding 1 min to epoch time*/
if(JsonHelper::addNodeToObject(commonHeader, "domain", \
{
ret = false;
}
- else if(JsonHelper::addNodeToObject(commonHeader, "nfcNamingCode", \
- "") == 0)
- {
- ret = false;
- }
- else if(JsonHelper::addNodeToObject(commonHeader, "stndDefinedNamespace", \
- "") == 0)
- {
- ret = false;
- }
}
-
+
if (mEventType == VesEventType::PNF_REGISTRATION)
{
ret = false;
}
else if(JsonHelper::addNodeToObject(commonHeader, "reportingEntityId", \
- "") == 0)
+ getReportingEntityId().c_str() ) == 0)
{
ret = false;
}
ret = false;
}
else if(JsonHelper::addNodeToObject(commonHeader, "sourceId", \
- "") == 0)
+ getSourceId().c_str() ) == 0)
{
ret = false;
}
ret = false;
}
else if(JsonHelper::addNodeToObject(commonHeader, "startEpochMicrosec", \
- (double)startEpochTime) == 0)
+ startEpochTime) == 0)
{
ret = false;
}
else if(JsonHelper::addNodeToObject(commonHeader, "lastEpochMicrosec", \
- (double)mLastEpochTime) == 0)
+ mLastEpochTime) == 0)
{
ret = false;
}
else if(JsonHelper::addNodeToObject(commonHeader, "nfNamingCode", \
- (type==VesEventType::PNF_REGISTRATION) ? \
- getNamingCode().c_str() : "") == 0)
+ getNamingCode().c_str() ) == 0)
{
ret = false;
}
else if(JsonHelper::addNodeToObject(commonHeader, "nfVendorName", \
- "") == 0)
+ "POC") == 0)
+ {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(commonHeader, "nfcNamingCode", \
+ getnfcNamingCode().c_str() ) == 0)
{
ret = false;
}
ret = false;
}
}
- else
+ else
{
if(JsonHelper::addNodeToObject(commonHeader, "version", \
- VERSION_4_0_1) == 0)
+ COMMON_HEADER_VERSION) == 0)
{
ret = false;
}
}
-
+ if(JsonHelper::addNodeToObject(commonHeader, "stndDefinedNamespace", \
+ getstndDefinedNamespace().c_str())== 0)
+ {
+ ret = false;
+ }
if(JsonHelper::addNodeToObject(commonHeader, "vesEventListenerVersion", \
- VES_EVENT_LISTENER_7_2_1) == 0)
+ VES_EVENT_LISNERT_VERSION) == 0)
{
ret = false;
}
bool prepare(cJSON *node, VesEventType type);
private:
- uint16_t getSequenceNo();
- uint16_t nextSequenceNo();
+ double getSequenceNo();
+ double nextSequenceNo();
string getEventTypeToStr();
string getEventType();
string getEventId();
string getPriority();
string getEventName();
+ string getSourceId();
+ string getReportingEntityId();
string getReportingEntityName();
string getSourceName();
string getNamingCode();
- uint64_t getEpochTime();
+ string getnfcNamingCode();
+ string getstndDefinedNamespace();
+ double getEpochTime();
time_t getCurrentTime();
string formatTime(time_t);
- uint64_t mLastEpochTime;
+ double mLastEpochTime;
VesEventType mEventType;
};
* @return string : Ves Event Name
******************************************************************/
-string VesEvent::getEventFieldName()
+string VesEvent::getEventFieldName()
{
switch(mVesEventType)
}
case VesEventType::FAULT_NOTIFICATION:
{
+ #ifdef StdDef
+ return "stndDefinedFields";
+ #else
return "faultFields";
+ #endif
}
case VesEventType::PM_SLICE:
{
#include "PnfRegistrationEvent.hpp"
#include "SliceMeasurementEvent.hpp"
#include "Message.hpp"
+#include "CellStateChange.hpp"
+#include "CellStateChangeStdDef.hpp"
/*******************************************************************
*
O1_LOG("\nO1 VesEventHandler : Preparing VES PM Slice");
break;
}
+ case VesEventType::FAULT_NOTIFICATION:
+ {
+ #ifdef StdDef
+ O1_LOG("\nO1 VesEventHandler : Preparing Standard VES fault notification");
+ mVesEvent = new CellStateChangeStdDef();
+ #else
+ O1_LOG("\nO1 VesEventHandler : Preparing VES fault notification");
+ mVesEvent = new CellStateChange();
+ #endif
+ break;
+ }
default:
O1_LOG("\nO1 VesEventHandler : VES message type does not exist ");
#include <iostream>
#include "GlobalDefs.hpp"
+#define StdDef 1
//config file path
#define NETCONF_CONFIG "config/netconfConfig.json"
#define OAM_VES_CONFIG "config/oamVesConfig.json"
#define SMO_VES_CONFIG "config/smoVesConfig.json"
//Common Header Macros
+#define STND_DEFINED_NAMESPACE "3GPP-FaultSupervision"
+#define COMMON_HEADER_VERSION "4.0.1"
+#define VES_EVENT_LISNERT_VERSION "7.2.1"
//Event Type
#define EVENT_TYPE_5G "EventType5G"
//Source Name
#define ODU_HIGH "ODU-High"
+#define SOURCE_ID "device_id_cc305d54-75b4-431b-adb2-eb6b9e541234"
-//Naming Code
+//Naming Code
#define NAMING_CODE_ODU "7odu"
+#define NFC_NAMING_CODE "NFC"
//Timezone Offset
#define TIME_ZONE_00_00 "+00:00"
#define PM_REPORTING_ENTITY "ORAN-DEV"
#define EVENT_TYPE_ORAN_COMPONENT_PM "O_RAN_COMPONENT_PM1min"
+//NOTIFICATION Macros
+#define FAULT_EVENTID "Alarm000000001"
+#define FAULT_TYPE "alarm"
+#define FAULT_EVENT_NAME "COMMUNICATIONS_ALARM"
+
enum class VesEventType
-{
+{
PNF_REGISTRATION,
FAULT_NOTIFICATION,
PM_NOTIFICATION,