From 07f42e15d8d1eb1fba7fe1ed0f6409848470741c Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sat, 23 Sep 2017 09:25:08 +0200 Subject: [PATCH] Changed naming --- includes/expressAlarm.py | 65 -------------------------------------- includes/multicastAlarm.py | 65 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 includes/expressAlarm.py create mode 100644 includes/multicastAlarm.py diff --git a/includes/expressAlarm.py b/includes/expressAlarm.py deleted file mode 100644 index 5b1c308..0000000 --- a/includes/expressAlarm.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -""" -expressAlarm is the function to enable BOSwatch to deal with Swissfone Express-Alarm - -@author: Fabian Kessler - -@requires: Configuration has to be set in the config.ini -""" - -import logging # Global logger -import time # timestamp for expressAlarm - -from includes import globalVars # Global variables - -expressList = [] - -def newEntryExpressList(eatyp, eapoc_id, eapoc_sub, eapoc_text): - """ - add entry to express alarm list and remove old entries - - @return: nothing - """ - global expressList - tmpexpressList = [] - timestamp = int(time.time()) - # Express-Alarm processing if enabled and delimiter RIC has been received - if eapoc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric"): - expressList = [] - logging.debug("Express-Alarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) - else: - expressList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) - logging.debug("Added %s %s %s to expressList", eapoc_id, eapoc_sub, eapoc_text) - # check for old entries in expressList - for i, exList in enumerate(expressList): - # we have to remove entries older than timestamp - ignore time - if int(exList[i][4]) > timestamp-globalVars.config.getint("ExpressAlarm", "expressAlarm_ignore_time"): - tmpexpressList.append(exList[i]) - expressList = tmpexpressList - - -def expressAlarmExec(typ, freq, data): - """ - call alarmHandler for every entry in expressList - - @return: nothing - """ - logging.debug("data before update from expressList: %s", data) - for i, exList in enumerate(expressList): - #update with eapoc_id (RIC) - data['ric'] = exList[i][1] - #update with eapoc_sub (Sub RIC) - data['function'] = exList[i][2] - # Add function as character a-d to dataset (reused from includes/poc.py) - data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") - #update with eapoc_id (RIC) - data['description'] = exList[i][1] - logging.debug("data after update from expressList: %s", data) - try: - from includes import alarmHandler - alarmHandler.processAlarmHandler(typ, freq, data) - except: - logging.error("processing alarm failed") - logging.debug("processing alarm failed", exc_info=True) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py new file mode 100644 index 0000000..9d00e23 --- /dev/null +++ b/includes/multicastAlarm.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +multicastAlarm is the function to enable BOSwatch to deal networks that optimise the transmission of POCSAG telegrams + +@author: Fabian Kessler + +@requires: Configuration has to be set in the config.ini +""" + +import logging # Global logger +import time # timestamp for multicastAlarm + +from includes import globalVars # Global variables + +multiList = [] + +def newEntrymultiList(eatyp, eapoc_id, eapoc_sub, eapoc_text): + """ + add entry to multi alarm list and remove old entries + + @return: nothing + """ + global multiList + tmpmultiList = [] + timestamp = int(time.time()) + # multicastAlarm processing if enabled and delimiter RIC has been received + if eapoc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"): + multiList = [] + logging.debug("multicastAlarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) + else: + multiList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) + logging.debug("Added %s %s %s to multiList", eapoc_id, eapoc_sub, eapoc_text) + # check for old entries in multiList + for i in range(len(multiList)): + # we have to remove entries older than timestamp - ignore time + if int(multiList[i][4]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): + tmpmultiList.append(multiList[i]) + multiList = tmpmultiList + + +def multicastAlarmExec(typ, freq, data): + """ + call alarmHandler for every entry in multiList + + @return: nothing + """ + logging.debug("data before update from multiList: %s", data) + for i in range(len(multiList)): + #update with eapoc_id (RIC) + data['ric'] = multiList[i][1] + #update with eapoc_sub (Sub RIC) + data['function'] = multiList[i][2] + # Add function as character a-d to dataset (reused from includes/poc.py) + data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") + #update with eapoc_id (RIC) + data['description'] = multiList[i][1] + logging.debug("data after update from multiList: %s", data) + try: + from includes import alarmHandler + alarmHandler.processAlarmHandler(typ, freq, data) + except: + logging.error("processing alarm failed") + logging.debug("processing alarm failed", exc_info=True)