Skip to content

Commit

Permalink
Merge pull request #341 from Schrolli91/new_version
Browse files Browse the repository at this point in the history
Prepare for new Version
  • Loading branch information
Schrolli91 authored Dec 22, 2017
2 parents 493624e + cc81c30 commit 25365b0
Show file tree
Hide file tree
Showing 16 changed files with 218 additions and 39 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
*.log
config.ini
log/

\.project

\.pydevproject

\.settings/
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ sudo: required
branches:
only:
- master
- beta
- develop

before_script:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog


### __[2.3]__ - 22.12.2017
##### 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)
##### Removed
- Beta Branch aus Readme, Installer und Travis-CI entfernt [#324](https://github.com/Schrolli91/BOSWatch/pull/324)
##### Fixed
- Bug in httpRequest Plugin (data Field wurde überschrieben) [#337](https://github.com/Schrolli91/BOSWatch/pull/337)
- Kommentar für FirEmergency Einstellung angepasst [#338](https://github.com/Schrolli91/BOSWatch/pull/338)


### __[v2.2.2]__ - 21.10.2017
##### Added
- Installations Script für Services [#316](https://github.com/Schrolli91/BOSWatch/pull/316)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
|Branch|Code Qualität|CI-Build|
|---|---|---|
|master|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/master.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=3763821)|[![Build Status](https://travis-ci.org/Schrolli91/BOSWatch.svg?branch=master)](https://travis-ci.org/Schrolli91/BOSWatch)|
|beta|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/beta.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=4213030)|[![Build Status](https://travis-ci.org/Schrolli91/BOSWatch.svg?branch=beta)](https://travis-ci.org/Schrolli91/BOSWatch)|
|develop|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/develop.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=3763820)|[![Build Status](https://travis-ci.org/Schrolli91/BOSWatch.svg?branch=develop)](https://travis-ci.org/Schrolli91/BOSWatch)|


Expand Down Expand Up @@ -52,6 +51,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
Expand Down
2 changes: 2 additions & 0 deletions boswatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@
# 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")
Expand Down
20 changes: 20 additions & 0 deletions citest/config.httpRequest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ ricd = Unwetter
# Usually sent periodically, separated by comma
netIdent_ric = 0174760, 1398098


[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
Expand Down
20 changes: 20 additions & 0 deletions citest/config.mysql.ini
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ ricd = Unwetter
# Usually sent periodically, separated by comma
netIdent_ric = 0174760, 1398098


[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
Expand Down
18 changes: 17 additions & 1 deletion citest/testdata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?


Expand Down
21 changes: 21 additions & 0 deletions config/config.template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ ricd = Unwetter
# RIC for net identification
# Usually sent periodically, separated by comma
netIdent_ric = 0174760, 1398098
# you can hold one entry per netIdent_ric [0] or the whole history [1]
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]
Expand Down
35 changes: 26 additions & 9 deletions includes/decoders/poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions includes/globalVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"""

# version info
versionNr = "2.2.2"
versionNr = "2.3"
branch = "master"
buildDate = "21.10.2017"
buildDate = "22/12/2017"


# Global variables
Expand Down
63 changes: 63 additions & 0 deletions includes/multicastAlarm.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 0 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ for (( i=1; i<=$#; i=$i+2 )); do
-b|--branch)
case $arg2 in
dev|develop) echo " !!! WARNING: you are using the DEV BRANCH !!! "; branch=dev ;;
beta) echo " !!! WARNING: you are using the BETA BRANCH !!! "; branch=beta ;;
*) branch=master ;;
esac ;;

Expand Down
39 changes: 21 additions & 18 deletions plugins/MySQL/MySQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
from includes.helper import configHandler

def isSignal(poc_id):
"""
@type poc_id: string
@param poc_id: POCSAG Ric
"""
@type poc_id: string
@param poc_id: POCSAG Ric
@requires: Configuration has to be set in the config.ini
@requires: Configuration has to be set in the config.ini
@return: True if the Ric is Signal, other False
@exception: none
"""
# If RIC is Signal return True, else False
if globalVars.config.get("POC", "netIdent_ric"):
if poc_id in globalVars.config.get("POC", "netIdent_ric"):
logging.info("RIC %s is net ident", poc_id)
return True
else:
logging.info("RIC %s is no net ident", poc_id)
return False
@return: True if the Ric is Signal, other False
@exception: none
"""
# If RIC is Signal return True, else False
if globalVars.config.get("POC", "netIdent_ric"):
if poc_id in globalVars.config.get("POC", "netIdent_ric"):
logging.info("RIC %s is net ident", poc_id)
return True
else:
logging.info("RIC %s is no net ident", poc_id)
return False


##
Expand Down Expand Up @@ -111,11 +111,14 @@ def run(typ,freq,data):

elif typ == "POC":
if isSignal(data["ric"]):
cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = '"+data["ric"]+"';")
if cursor.rowcount == 0:
if globalVars.config.getint("POC","netIdent_histry"):
cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');")
else:
cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = '"+data["ric"]+"';")
if cursor.rowcount == 0:
cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');")
else:
cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (time, ric, function, functionChar, msg, bitrate, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"]))
cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (time, ric, function, functionChar, msg, bitrate, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"]))

else:
logging.warning("Invalid Typ: %s", typ)
Expand Down
2 changes: 1 addition & 1 deletion plugins/firEmergency/firEmergency.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
firEmergency-Plugin to dispatch ZVEI- and POCSAG - messages to firEmergency
firEmergency configuration:
- set input to "FMS32" at Port 5555
- set input to "Standartschnittstelle" at Port 5555
@autor: Smith-fms
Expand Down
Loading

0 comments on commit 25365b0

Please sign in to comment.