-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
implemented multicast alarms #88
base: develop
Are you sure you want to change the base?
Changes from 1 commit
d8fb629
2aa714f
51cc6a0
c1f2ab0
ee6095c
44402c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
# ____ ____ ______ __ __ __ _____ | ||
# / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / | ||
# / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ < | ||
# / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / | ||
#/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/ | ||
# German BOS Information Script | ||
# by Bastian Schroll | ||
|
||
server: | ||
port: 8080 | ||
name: BW3 Server # name of the BW3 Server instance | ||
useBroadcast: no # serve server ip on broadcast request | ||
|
||
alarmRouter: | ||
- Router 1 | ||
|
||
router: | ||
- name: Router 1 | ||
route: | ||
- type: module | ||
res: filter.modeFilter | ||
name: Filter Fms/Zvei | ||
config: | ||
allowed: | ||
- fms | ||
- zvei | ||
- type: plugin | ||
name: test plugin | ||
res: template_plugin | ||
# -*- coding: utf-8 -*- | ||
# ____ ____ ______ __ __ __ _____ | ||
# / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / | ||
# / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ < | ||
# / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / | ||
#/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/ | ||
# German BOS Information Script | ||
# by Bastian Schroll | ||
|
||
server: | ||
port: 8080 | ||
name: BW3 Server # name of the BW3 Server instance | ||
useBroadcast: no # serve server ip on broadcast request | ||
|
||
alarmRouter: | ||
- Alarm_multicast | ||
|
||
router: | ||
- name: Alarm_multicast | ||
route: | ||
- type: module | ||
res: filter.regexFilter | ||
config: | ||
- name: "valid multicast rics" | ||
checks: | ||
- field: ric | ||
regex: 210000|210002|210003 | ||
- type: module | ||
res: filter.doubleFilter | ||
name: Filter double | ||
config: | ||
ignoreTime: 10 | ||
maxEntry: 10 | ||
pocsagFields: | ||
- ric | ||
- subric | ||
- type: module | ||
res: multicast | ||
name: Find the multicast message infos | ||
config: | ||
multicastAlarm_textRics: 2100002,210001 | ||
multicastAlarm_ignore_time: 10 | ||
multicastAlarm_delimiterRic: 2100003 | ||
multicastAlarm_delimiterSubric: 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
"""! | ||
____ ____ ______ __ __ __ _____ | ||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / | ||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ < | ||
/ /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / | ||
/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/ | ||
German BOS Information Script | ||
by Bastian Schroll | ||
|
||
@file: multicast.py | ||
@date: 02.05.2021 | ||
@author: Thierry Fredrich | ||
@description: Implements multicast alarms | ||
|
||
structure of a multicast alarm | ||
# 1 ) network delimiter without text | ||
# 2 ) alarm ric without text | ||
# 3 ) text ric with message | ||
# 4 ) network delimiter ric message <BS> | ||
""" | ||
import logging | ||
from module.moduleBase import ModuleBase | ||
|
||
|
||
logging.debug("- %s loaded", __name__) | ||
|
||
|
||
class BoswatchModule(ModuleBase): | ||
"""!Description of the Module""" | ||
# initializing with empty list | ||
|
||
textRics = [] | ||
delimiterRic = 42 | ||
delimiterSubric = 42 | ||
ignoreTime = 42 | ||
### to be cleared | ||
receivedAlarmRic = 42 | ||
receivedAlarmSubric = 42 | ||
bufferListFormingAMulticastAlarm = [] | ||
initialDelimiterReceived = False | ||
alarmReceived = False | ||
textRicReceived = False | ||
textRicMessage = '' | ||
def initStorage(self): | ||
self.receivedAlarmRic = 42 | ||
self.receivedAlarmSubric = 42 | ||
self.bufferListFormingAMulticastAlarm = [] | ||
self.initialDelimiterReceived = False | ||
self.alarmReceived = False | ||
self.textRicReceived = False | ||
self.textRicMessage = '' | ||
|
||
def __init__(self, config): | ||
"""!Do not change anything here!""" | ||
super().__init__(__name__, config) # you can access the config class on 'self.config' | ||
logging.debug("starting multicast module") | ||
logging.debug("multicastAlarm_delimiterRic is: %i" % self.config.get("multicastAlarm_delimiterRic")) | ||
logging.debug("multicastAlarm_delimiterSubric is: %i" % self.config.get("multicastAlarm_delimiterSubric")) | ||
logging.debug("multicastAlarm_ignore_time is: %i" % self.config.get("multicastAlarm_ignore_time")) | ||
logging.debug("multicastAlarm_textRics is: %s" % self.config.get("multicastAlarm_textRics")) | ||
self.delimiterRic = int(self.config.get("multicastAlarm_delimiterRic")) | ||
self.delimiterSubric = int(self.config.get("multicastAlarm_delimiterSubric")) | ||
self.ignoreTime = int(self.config.get("multicastAlarm_ignore_time")) | ||
for aTextRic in self.config.get("multicastAlarm_textRics").split(','): | ||
self.textRics.append(int(aTextRic)) | ||
self.initStorage() | ||
|
||
def onLoad(self): | ||
"""!Called by import of the plugin | ||
Remove if not implemented""" | ||
pass | ||
|
||
def doWork(self, bwPacket): | ||
"""!start an run of the module. | ||
|
||
@param bwPacket: A BOSWatch packet instance""" | ||
thisRic = int(bwPacket.get("ric")) | ||
thisSubric = int(bwPacket.get("subric"))-1 | ||
thisMessage = bwPacket.get("message") | ||
if bwPacket.get("mode") == "pocsag": | ||
pass | ||
else: | ||
logging.error("multicast module only works with pocsag") | ||
raise NameError('multicast module only works with pocsag') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please respect the defined return values for the modules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A module should return either of these: bwPacket, False, None According to the manual, "False" simply stops the Router. In the above situation, everything should stop because the user demands something impossible? Is raising an error a problem for the rest of the logic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm currently not sure where this exception will be caught, but I think it will kill the entire server application. So it is possible that I want to send ZVEI and POCSAG via a single pipeline (e.g. send by Telegram), but only the POCSAG files should be modified by this module. |
||
|
||
'''delimiter received''' | ||
if self.delimiterRic == thisRic and self.delimiterSubric == thisSubric: | ||
''' is it the initial delimiter?''' | ||
if not self.initialDelimiterReceived and \ | ||
not self.alarmReceived and \ | ||
not self.textRicReceived: | ||
self.bufferListFormingAMulticastAlarm.append(bwPacket) | ||
self.initialDelimiterReceived = True | ||
return False | ||
''' is it the closeing delimiter?''' | ||
if self.initialDelimiterReceived and \ | ||
self.alarmReceived and self.textRicReceived: | ||
self.bufferListFormingAMulticastAlarm.append(bwPacket) # deliting list here? | ||
logging.debug("modify bwPacket" ) | ||
bwPacket.set('message',self.textRicMessage) | ||
#bwPacket.update({'message':'bla'}) | ||
logging.debug("multicast completed... clearing storage") | ||
self.initStorage() | ||
return bwPacket | ||
|
||
'''alarm ric recceived''' | ||
if thisRic != self.delimiterRic and thisRic not in self.textRics: | ||
if self.initialDelimiterReceived: | ||
self.bufferListFormingAMulticastAlarm.append(bwPacket) | ||
self.receivedAlarmRic = thisRic | ||
self.receivedAlarmSubric = thisSubric | ||
logging.debug("hoping %i is a valid alarm ric" % thisRic) | ||
logging.debug("with subric %i " % thisSubric) | ||
self.alarmReceived = True | ||
return False | ||
|
||
'''text ric received''' | ||
if thisRic in self.textRics: | ||
if self.initialDelimiterReceived and self.alarmReceived: | ||
self.bufferListFormingAMulticastAlarm.append(bwPacket) | ||
self.textRicReceived = True | ||
self.textRicMessage = thisMessage | ||
logging.debug("multicast text is: %s" % thisMessage ) | ||
return False | ||
return False | ||
|
||
def onUnload(self): | ||
"""!Called by destruction of the plugin | ||
Remove if not implemented""" | ||
pass | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done in the
onLoad()
method below.The Init must not be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I will change that accordingly.