mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
Merge pull request #307 from f-kessler/dev-express-alarm
multicastAlarm added as function
This commit is contained in:
commit
4811477656
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
### __[2.x]__ - unreleased
|
||||
##### Added
|
||||
- zuschaltbare POCSAG Multicast-Alarm Funktionalität [#307](https://github.com/Schrolli91/BOSWatch/pull/307)
|
||||
- Flag in Config um nur letzte Net Ident oder gesamte Historie zu speichern [#317](https://github.com/Schrolli91/BOSWatch/pull/317)
|
||||
##### Changed
|
||||
##### Deprecated
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ unless you are developer you can use the develop-Branch - may be unstable!
|
|||
- Ready for use BOSWatch as daemon
|
||||
- possibility to start plugins asynchron
|
||||
- NMA Error Handler
|
||||
- multicastAlarm for transmission optimized networks
|
||||
|
||||
|
||||
### Plugins
|
||||
|
|
|
|||
|
|
@ -220,6 +220,8 @@ try:
|
|||
# if given loglevel is debug:
|
||||
if globalVars.config.getint("BOSWatch","loglevel") == 10:
|
||||
configHandler.checkConfig("BOSWatch")
|
||||
configHandler.checkConfig("multicastAlarm")
|
||||
configHandler.checkConfig("Filters")
|
||||
configHandler.checkConfig("FMS")
|
||||
configHandler.checkConfig("ZVEI")
|
||||
configHandler.checkConfig("POC")
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ POCSAG512: Address: 1000003 Function: 3 Alpha: BOSWatch-Test: okay
|
|||
POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay
|
||||
POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test öäü: okay
|
||||
|
||||
# witch csv
|
||||
# with csv
|
||||
POCSAG512: Address: 1234567 Function: 1 Alpha: BOSWatch-Test: with csv
|
||||
|
||||
# without csv
|
||||
|
|
@ -86,6 +86,22 @@ POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied
|
|||
POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start
|
||||
POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end
|
||||
|
||||
#Probealram
|
||||
POCSAG1200: Address: 0871004 Function: 1 Alpha: Dies ist ein Probealarm!
|
||||
## Multicast Alarm
|
||||
POCSAG1200: Address: 0871002 Function: 0 Alpha: <EOT><FF>
|
||||
POCSAG1200: Address: 0860001 Function: 0
|
||||
POCSAG1200: Address: 0860002 Function: 0
|
||||
POCSAG1200: Address: 0860003 Function: 0
|
||||
POCSAG1200: Address: 0860004 Function: 0
|
||||
POCSAG1200: Address: 0860005 Function: 0
|
||||
POCSAG1200: Address: 0860006 Function: 0
|
||||
POCSAG1200: Address: 0860007 Function: 0
|
||||
POCSAG1200: Address: 0860008 Function: 0
|
||||
POCSAG1200: Address: 0860009 Function: 0
|
||||
POCSAG1200: Address: 0860010 Function: 0
|
||||
POCSAG1200: Address: 0871003 Function: 0 Alpha: B2 Feuer Gebäude Pers in Gefahr. bla bla bla<NUL>
|
||||
|
||||
# regEx-Filter?
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,25 @@ netIdent_ric = 0174760, 1398098
|
|||
netIdent_history = 0
|
||||
|
||||
|
||||
[multicastAlarm]
|
||||
# Configure multicastAlarm if your POCSAG network uses an optimized transmission scheme for alarms with more than one RIC (often found in Swissphone networks).
|
||||
# In this optimized transmission scheme, a POCSAG telegram with each RIC that needs to be alarmed will be send in a sequence. These telegrams are send without a text message. This sequence is directly followed by a telegram with a specific RIC and the text message that belongs to the sequnece send right before.
|
||||
# A POCSAG pager (DME) can be configured to start an acoustic alarm if a specific RIC without text has been received. If afterwards the specific RIC with the text message will be received, the pager will show the message in it's display.
|
||||
# multicastAlarm enables BOSwatch to process the all received RICs joined with the text message.
|
||||
#
|
||||
# enable multicastAlarm (0 - off | 1 - on)
|
||||
multicastAlarm = 0
|
||||
|
||||
# time limit for alarms that do not belong to the multicastAlarm sequence in seconds
|
||||
multicastAlarm_ignore_time = 15
|
||||
|
||||
# multicastAlarm delimiter RIC (usually used as a starting point for a alarm sequence) (can be empty)
|
||||
multicastAlarm_delimiter_ric =
|
||||
|
||||
# multicastAlarm RIC that is used to send the text message
|
||||
multicastAlarm_ric =
|
||||
|
||||
|
||||
[Filters]
|
||||
# RegEX Filter Configuration
|
||||
# http://www.regexr.com/ - RegEX Test Tool an Documentation
|
||||
|
|
|
|||
|
|
@ -117,23 +117,40 @@ def decode(freq, decoded):
|
|||
|
||||
if re.search("[0-9]{7}", poc_id) and re.search("[1-4]{1}", poc_sub): #if POC is valid
|
||||
if isAllowed(poc_id):
|
||||
|
||||
# check for double alarm
|
||||
if doubleFilter.checkID("POC", poc_id+poc_sub, poc_text):
|
||||
logging.info("POCSAG%s: %s %s %s ", bitrate, poc_id, poc_sub, poc_text)
|
||||
data = {"ric":poc_id, "function":poc_sub, "msg":poc_text, "bitrate":bitrate, "description":poc_id}
|
||||
# Add function as character a-d to dataset
|
||||
data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
|
||||
|
||||
logging.info("POCSAG%s: %s %s %s ", data["bitrate"], data["ric"], data["function"], data["msg"])
|
||||
|
||||
# If enabled, look up description
|
||||
if globalVars.config.getint("POC", "idDescribed"):
|
||||
from includes import descriptionList
|
||||
data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"])
|
||||
# processing the alarm
|
||||
try:
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarmHandler("POC", freq, data)
|
||||
except:
|
||||
logging.error("processing alarm failed")
|
||||
logging.debug("processing alarm failed", exc_info=True)
|
||||
data["description"] = descriptionList.getDescription("POC", data["ric"]+data["functionChar"])
|
||||
|
||||
# multicastAlarm processing if enabled and a message without text or delimiter RIC or netIdent_ric received
|
||||
if globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["ric"] != globalVars.config.get("POC", "netIdent_ric") and (data["msg"] == "" or data["ric"] in globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")):
|
||||
logging.debug(" - multicastAlarm without msg")
|
||||
from includes import multicastAlarm
|
||||
multicastAlarm.newEntrymultiList(data)
|
||||
|
||||
# multicastAlarm processing if enabled and alarm message has been received
|
||||
elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["msg"] != "" and data["ric"] in globalVars.config.get("multicastAlarm", "multicastAlarm_ric"):
|
||||
logging.debug(" - multicastAlarm with message")
|
||||
from includes import multicastAlarm
|
||||
multicastAlarm.multicastAlarmExec(freq, data)
|
||||
|
||||
else:
|
||||
# processing the alarm
|
||||
try:
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarmHandler("POC", freq, data)
|
||||
except:
|
||||
logging.error("processing alarm failed")
|
||||
logging.debug("processing alarm failed", exc_info=True)
|
||||
# in every time save old data for double alarm
|
||||
doubleFilter.newEntry(poc_id+poc_sub, poc_text)
|
||||
else:
|
||||
|
|
|
|||
63
includes/multicastAlarm.py
Normal file
63
includes/multicastAlarm.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
multicastAlarm is the function to enable BOSwatch to work in 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
|
||||
|
||||
#
|
||||
# ListStructure [0..n] = (Data, TimeStamp)
|
||||
#
|
||||
multiList = []
|
||||
|
||||
def newEntrymultiList(data):
|
||||
"""
|
||||
add entry to multi alarm list and remove old entries
|
||||
|
||||
@return: nothing
|
||||
"""
|
||||
global multiList
|
||||
timestamp = int(time.time())
|
||||
# multicastAlarm processing if enabled and delimiter RIC has been received
|
||||
if data['ric'] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"):
|
||||
multiList = []
|
||||
logging.debug("delimiter RIC received - buffer cleared")
|
||||
else:
|
||||
multiList.append([data, timestamp])
|
||||
logging.debug("Added %s to multiList", data['ric'])
|
||||
# check for old entries in multiList
|
||||
for (xData, xTimestamp) in multiList[:]:
|
||||
if xTimestamp < timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"):
|
||||
multiList.remove([xData, xTimestamp])
|
||||
logging.debug("RIC %s removed - %s sec. older than current timestamp", xData['ric'], xTimestamp-timestamp)
|
||||
|
||||
|
||||
def multicastAlarmExec(freq, data):
|
||||
"""
|
||||
call alarmHandler for every entry in multiList
|
||||
|
||||
@return: nothing
|
||||
"""
|
||||
logging.debug("data before update from multiList: %s", data)
|
||||
for (xData, _) in multiList:
|
||||
#update data with values multiList
|
||||
data['ric'] = xData['ric']
|
||||
data['function'] = xData['function']
|
||||
data['functionChar'] = xData['functionChar']
|
||||
data['description'] = xData['description']
|
||||
logging.debug("data after update from multiList: %s", data)
|
||||
try:
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarmHandler("POC", freq, data)
|
||||
except:
|
||||
logging.error("processing alarm failed")
|
||||
logging.debug("processing alarm failed", exc_info=True)
|
||||
Loading…
Reference in a new issue