This commit is contained in:
Thierry Fredrich 2025-06-11 10:00:47 +02:00 committed by GitHub
commit de8769005e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 336 additions and 166 deletions

View file

@ -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

137
module/multicast.py Normal file
View file

@ -0,0 +1,137 @@
#!/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'
def onLoad(self):
"""!Called by import of the plugin
Remove if not implemented"""
logging.debug("starting multicast module")
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))
logging.debug("multicastAlarm_delimiterRic is: %i" % self.delimiterRic)
logging.debug("multicastAlarm_delimiterSubric is: %i" % self.delimiterSubric)
logging.debug("multicastAlarm_ignore_time is: %i" % self.ignoreTime)
logging.debug("multicastAlarm_textRics is: %s" % self.textRics)
self.initStorage()
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")
return False
'''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

View file

@ -1,136 +1,155 @@
# Testdata for the BOSWatch Test Mode function
# Data in Multimon-NG Raw Format
# Data is alternately passed to the decoder to simulate an used Radio-Frequency
#
# POCSAG
# ------
#
# The following settings in config.ini are expected for POCSAG
#
# [BOSWatch]
# useDescription = 1
# doubleFilter_ignore_entries = 10
# doubleFilter_check_msg = 1
#
# [POC]
# deny_ric = 7777777
# filter_range_start = 0000005
# filter_range_end = 8999999
# idDescribed = 1
#
# bitrate
POCSAG512: Address: 1000512 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay
POCSAG1200: Address: 1001200 Function: 1 Alpha: BOSWatch-Test: okay
POCSAG2400: Address: 1002400 Function: 1 Alpha: BOSWatch-Test: okay
# function-code
POCSAG512: Address: 1000000 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 1000001 Function: 1 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 1000002 Function: 2 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 1000003 Function: 3 Alpha: BOSWatch-Test: okay
# german special sign
POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay
POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test öäü: okay
# with csv
POCSAG512: Address: 1234567 Function: 1 Alpha: BOSWatch-Test: with csv
# without csv
POCSAG1200: Address: 2345678 Function: 2 Alpha: BOSWatch-Test: without csv
POCSAG2400: Address: 3456789 Function: 3 Alpha: BOSWatch-Test: without csv
# OHNE TEXT????
POCSAG1200: Address: 1100000 Function: 0
POCSAG1200: Address: 1100000 Function: 1
POCSAG1200: Address: 1100000 Function: 2
POCSAG1200: Address: 1100000 Function: 3
# duplicate with same and other msg
POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Testing: okay
# duplicate in different order
POCSAG1200: Address: 2100000 Function: 2
POCSAG1200: Address: 2100001 Function: 2
POCSAG1200: Address: 2100002 Function: 2
POCSAG1200: Address: 2100000 Function: 2
POCSAG1200: Address: 2100001 Function: 2
POCSAG1200: Address: 2100002 Function: 2
POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
# invalid
POCSAG512: Address: 3 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 33 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 3333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 33333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 333333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 3333333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 333333F Function: 0 Alpha: BOSWatch-Test: invalid
POCSAG512: Address: 333333F Function: 1 Alpha: BOSWatch-Test: invalid
POCSAG512: Address: 3333333 Function: 4 Alpha: BOSWatch-Test: invalid
# denied
POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied
# out of filter Range
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?
#
# FMS
# ---
#
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) CRC correct
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct
#
# ZVEI
# ----
#
#with csv description
ZVEI1: 12345
#without csv description
ZVEI1: 56789
#duplicate
ZVEI1: 56789
#with repeat Tone
ZVEI1: 1F2E3
#in case of invalid id
ZVEI1: 135
#in case of a double-tone for siren n-'D's are sended
# ZVEI1: DDD
# ZVEI1: DDDDD
# Testdata for the BOSWatch Test Mode function
# Data in Multimon-NG Raw Format
# Data is alternately passed to the decoder to simulate an used Radio-Frequency
#
# POCSAG
# ------
#
# The following settings in config.ini are expected for POCSAG
#
# [BOSWatch]
# useDescription = 1
# doubleFilter_ignore_entries = 10
# doubleFilter_check_msg = 1
#
# [POC]
# deny_ric = 7777777
# filter_range_start = 0000005
# filter_range_end = 8999999
# idDescribed = 1
#
# bitrate
POCSAG512: Address: 1000512 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay
POCSAG1200: Address: 1001200 Function: 1 Alpha: BOSWatch-Test: okay
POCSAG2400: Address: 1002400 Function: 1 Alpha: BOSWatch-Test: okay
# function-code
POCSAG512: Address: 1000000 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 1000001 Function: 1 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 1000002 Function: 2 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 1000003 Function: 3 Alpha: BOSWatch-Test: okay
# german special sign
POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay
POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test öäü: okay
# with csv
POCSAG512: Address: 1234567 Function: 1 Alpha: BOSWatch-Test: with csv
# without csv
POCSAG1200: Address: 2345678 Function: 2 Alpha: BOSWatch-Test: without csv
POCSAG2400: Address: 3456789 Function: 3 Alpha: BOSWatch-Test: without csv
# OHNE TEXT????
POCSAG1200: Address: 1100000 Function: 0
POCSAG1200: Address: 1100000 Function: 1
POCSAG1200: Address: 1100000 Function: 2
POCSAG1200: Address: 1100000 Function: 3
# duplicate with same and other msg
POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Testing: okay
# duplicate in different order
POCSAG1200: Address: 2100000 Function: 2
POCSAG1200: Address: 2100001 Function: 2
POCSAG1200: Address: 2100002 Function: 2
POCSAG1200: Address: 2100000 Function: 2
POCSAG1200: Address: 2100001 Function: 2
POCSAG1200: Address: 2100002 Function: 2
POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate
# invalid
POCSAG512: Address: 3 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 33 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 3333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 33333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 333333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 3333333 Function: 0 Alpha: BOSWatch-Test: okay
POCSAG512: Address: 333333F Function: 0 Alpha: BOSWatch-Test: invalid
POCSAG512: Address: 333333F Function: 1 Alpha: BOSWatch-Test: invalid
POCSAG512: Address: 3333333 Function: 4 Alpha: BOSWatch-Test: invalid
# denied
POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied
# out of filter Range
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?
#
# FMS
# ---
#
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) CRC correct
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct
FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct
#
# ZVEI
# ----
#
#with csv description
ZVEI1: 12345
#without csv description
ZVEI1: 56789
#duplicate
ZVEI1: 56789
#with repeat Tone
ZVEI1: 1F2E3
#in case of invalid id
ZVEI1: 135
#in case of a double-tone for siren n-'D's are sended
# ZVEI1: DDD
# ZVEI1: DDDDD
# [multicast]
# this part test the multicast module
POCSAG1200: Address: 2145000 Function: 2 Alpha: alarm ric #not in multicast regex filter
## you are required to define:
# multicastAlarm_textRics: 2100002,210001
# multicastAlarm_ignore_time: 10
# multicastAlarm_delimiterRic: 2100003
# multicastAlarm_delimiterSubric: 0
# @ your server.yaml
## Function corresponds to subric here
POCSAG1200: Address: 2100003 Function: 0 Alpha: delimiter
POCSAG1200: Address: 2100000 Function: 1 Alpha: alarm ric
POCSAG1200: Address: 2100002 Function: 2 Alpha: text ric says: fire in the hole
POCSAG1200: Address: 2100003 Function: 0 Alpha: delimiter
POCSAG1200: Address: 2100003 Function: 0 Alpha: delimiter
POCSAG1200: Address: 2100000 Function: 1 Alpha: alarm ric
POCSAG1200: Address: 2100002 Function: 2 Alpha: text ric says: again fire in the hole
POCSAG1200: Address: 2100003 Function: 0 Alpha: delimiter