Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multicastAlarm added as function #307

Merged
merged 53 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f31532d
Add files via upload
f-kessler Sep 19, 2017
c52c76a
Delete expressAlarm.py
f-kessler Sep 19, 2017
5503ac0
Delete config.template.ini
f-kessler Sep 19, 2017
990ef0f
Delete poc.py
f-kessler Sep 19, 2017
3532a64
Delete testdata.txt
f-kessler Sep 19, 2017
e770937
Add files via upload
f-kessler Sep 19, 2017
fbc3e53
Delete testdata.txt
f-kessler Sep 19, 2017
9ffa872
Add files via upload
f-kessler Sep 19, 2017
81a146b
Add files via upload
f-kessler Sep 19, 2017
46a53dd
Add files via upload
f-kessler Sep 19, 2017
f171bda
Add files via upload
f-kessler Sep 19, 2017
70d7698
Update testdata.txt
f-kessler Sep 19, 2017
7fd88a4
Update config.template.ini
f-kessler Sep 19, 2017
55f5529
Update README.md
f-kessler Sep 19, 2017
4a89ed4
Merge branch 'develop' into dev-express-alarm
Schrolli91 Sep 19, 2017
f73e6f2
edit changelog
Schrolli91 Sep 19, 2017
6af6981
changes for codacy
Schrolli91 Sep 20, 2017
0ed8df0
add ExpressAlarm to logging
Schrolli91 Sep 20, 2017
ae03473
Update config.template.ini
f-kessler Sep 21, 2017
0fc12ab
Changed naming and description
f-kessler Sep 23, 2017
07f42e1
Changed naming
f-kessler Sep 23, 2017
d30eee5
Updated naming
f-kessler Sep 23, 2017
06d36b3
Changed EA to multicastAlarm
f-kessler Sep 23, 2017
bd733b6
changed logging to multicastAlarm
f-kessler Sep 24, 2017
736d0f9
Update CHANGELOG.md
Schrolli91 Sep 24, 2017
f6e4c8d
Update testdata.txt
Schrolli91 Sep 24, 2017
d45ff3b
Merge branch 'develop' into dev-express-alarm
Schrolli91 Sep 24, 2017
8069ded
enumerate() instead of range(len())
f-kessler Sep 25, 2017
00e4e52
Update multicastAlarm.py
f-kessler Sep 25, 2017
3aa0b38
edit changelog with link
Schrolli91 Sep 29, 2017
fed717a
Merge branch 'develop' into dev-express-alarm
Schrolli91 Oct 1, 2017
c54bd55
change to data-field at checks
Schrolli91 Oct 1, 2017
b6077d5
enumerate value correction
f-kessler Oct 2, 2017
166dd3e
changed data buffering and updating for alarms
f-kessler Oct 3, 2017
6bcba28
changed to send complete data to multicastAlarm for buffering
f-kessler Oct 3, 2017
9aa163d
text for multicastAlarm config updated
f-kessler Oct 3, 2017
b52d972
edit debug msg
Schrolli91 Oct 3, 2017
f701b6a
del typ and freq in adding routine
Schrolli91 Oct 3, 2017
9c446b0
del typ and freq in adding routine
Schrolli91 Oct 3, 2017
9aaa8aa
remove typ from adding
Schrolli91 Oct 3, 2017
3220088
update indexes after remove of typ from multiList
f-kessler Oct 3, 2017
63f2e58
edit multicastAlarm
Schrolli91 Oct 3, 2017
fa90ba1
Merge branch 'develop' into dev-express-alarm
Schrolli91 Oct 3, 2017
03cd002
Merge branch 'develop' into dev-express-alarm
Schrolli91 Oct 3, 2017
fca69b9
add placeholder (unused var)
Schrolli91 Oct 3, 2017
578750a
fix global definition issue
Schrolli91 Oct 3, 2017
bcdac6e
exclude netIdent_ric from multicastAlarm
f-kessler Oct 5, 2017
b7141d9
fixed remove of old RICs and replacement of data for calling alarmHan…
f-kessler Oct 9, 2017
fb82b18
edit CL
Schrolli91 Oct 21, 2017
3b22750
Merge branch 'develop' into dev-express-alarm
Schrolli91 Oct 21, 2017
59b78a4
multi delimiter and text RICs
f-kessler Oct 23, 2017
e9b7cf1
Merge branch 'develop' into dev-express-alarm
Schrolli91 Dec 18, 2017
568ead7
Merge branch 'develop' into dev-express-alarm
Schrolli91 Dec 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### __[v2.2.3]__ - unreleased
##### Added
- zuschaltbare POCSAG Multicast-Alarm Funktionalität
##### Changed
##### Deprecated
##### Removed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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 @@ -217,6 +217,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
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
19 changes: 19 additions & 0 deletions config/config.template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ ricd = Unwetter
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).
# The optimized transmission scheme sends a POCSAG telegram with each RIC that needs to be alarmed in a sequence. These telegrams are send without a text message. This sequence is directly followed by a telegram with a special RIC and the text message.
# A POCSAG pager (DME) can be configured to start an acoustic alarm if a specific RIC without text has been received. If afterwards the RIC with the text message will be received, the pager will show the message in it's display.
# multicastAlarm enables BOSwatch to forward the all received RIC 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
25 changes: 18 additions & 7 deletions includes/decoders/poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,24 @@ def decode(freq, decoded):
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)
# multicastAlarm processing if enabled and message without text ord delimiter RIC received
if globalVars.config.getint("multicastAlarm", "multicastAlarm") and (poc_text == "" or poc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")):
logging.debug("POCSAG%s: %s %s %s - multicastAlarm or delimiter RIC received - buffer until text received", bitrate, poc_id, poc_sub, poc_text)
from includes import multicastAlarm
multicastAlarm.newEntrymultiList("POC", poc_id, poc_sub, poc_text)
# multicastAlarm processing if enabled and alarm message has been received
elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and poc_text != "" and poc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"):
logging.debug("EA RIC with text message - POCSAG%s: %s %s %s", bitrate, poc_id, poc_sub, poc_text)
from includes import multicastAlarm
multicastAlarm.multicastAlarmExec("POC", 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
65 changes: 65 additions & 0 deletions includes/multicastAlarm.py
Original file line number Diff line number Diff line change
@@ -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,j in enumerate(multiList):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wieso hast du das "j" extra noch hinzugefügt, wenn es doch gar nicht benutzt wird?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das ist eine gute Frage. Leider hatte ich gestern nicht mehr genug Zeit mich damit auseinander zu setzen. Ich habe enumerate() so verstanden, dass es immer den Index und Wert zurück gibt. Den Wert brauche ich nicht, aber wenn ich keine variable zuweise erhalte ich eine Fehlermeldung. Ich hoffe, mich huete Abend nochmal damit beschäftigen zu können.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@f-kessler Dafür wird meist ein "Unterstrich" benutzt

for i, _ in enumerate(multilist):

oder

for i in range(len(multilist)):

Copy link
Owner

@Schrolli91 Schrolli91 Sep 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2teres hatte Codacy ja eben angemeckert, weil scheinbar schlechter Stil ;-)
siehe: 8069ded (enumerate() instead of range(len()))

# 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,j in enumerate(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)