mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-08 17:40:07 +01:00
Merge branch 'develop' of https://github.com/Schrolli91/BOSWatch into develop
Conflicts: includes/decoder.py
This commit is contained in:
commit
f53552781b
|
|
@ -131,8 +131,8 @@ try:
|
|||
else:
|
||||
|
||||
#load plugins
|
||||
from includes import pluginHandler
|
||||
pluginHandler.loadPlugins()
|
||||
from includes import pluginloader
|
||||
pluginloader.loadPlugins()
|
||||
|
||||
try:
|
||||
#start rtl_fm
|
||||
|
|
|
|||
14
includes/alarmHandler.py
Normal file
14
includes/alarmHandler.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from includes import globals # Global variables
|
||||
from includes import pluginloader
|
||||
|
||||
def processAlarm(typ,freq,data):
|
||||
logging.debug("[ ALARM ]")
|
||||
for name, plugin in globals.pluginList.items():
|
||||
logging.debug("call Plugin: %s", name)
|
||||
plugin.run(typ,freq,data)
|
||||
logging.debug("[END ALARM]")
|
||||
|
|
@ -9,15 +9,66 @@ def decode(freq, decoded):
|
|||
#check FMS: -> check CRC -> validate -> check double alarm -> log
|
||||
if "FMS:" in decoded:
|
||||
logging.debug("recieved FMS")
|
||||
<<<<<<< HEAD
|
||||
from includes.decoders import fms
|
||||
fms.decode(freq, decoded)
|
||||
=======
|
||||
|
||||
fms_service = decoded[19] #Organisation
|
||||
fms_country = decoded[36] #Bundesland
|
||||
fms_location = decoded[65:67] #Ort
|
||||
fms_vehicle = decoded[72:76] #Fahrzeug
|
||||
fms_status = decoded[84] #Status
|
||||
fms_direction = decoded[101] #Richtung
|
||||
fms_tsi = decoded[114:117] #Taktische Kruzinformation
|
||||
|
||||
if "CRC correct" in decoded: #check CRC is correct
|
||||
fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction #build FMS id
|
||||
if re.search("[0-9a-f]{8}[0-9a-f]{1}[01]{1}", fms_id): #if FMS is valid
|
||||
if fms_id == globals.fms_id_old and timestamp < globals.fms_time_old + globals.config.getint("BOSWatch", "fms_double_ignore_time"): #check for double alarm
|
||||
logging.info("FMS double alarm: %s within %s second(s)", globals.fms_id_old, timestamp-globals.fms_time_old)
|
||||
globals.fms_time_old = timestamp #in case of double alarm, fms_double_ignore_time set new
|
||||
else:
|
||||
logging.info("FMS:%s Status:%s Richtung:%s TKI:%s", fms_id[0:8], fms_status, fms_direction, fms_tsi)
|
||||
data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "tsi":fms_tsi}
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarm("FMS",freq,data)
|
||||
|
||||
globals.fms_id_old = fms_id #save last id
|
||||
globals.fms_time_old = timestamp #save last time
|
||||
else:
|
||||
logging.warning("No valid FMS: %s", fms_id)
|
||||
else:
|
||||
logging.warning("FMS CRC incorrect")
|
||||
|
||||
>>>>>>> 26c9e23db8c6f82247b772859d35e35f0ac3f919
|
||||
|
||||
#ZVEI Decoder Section
|
||||
#check ZVEI: -> validate -> check double alarm -> log
|
||||
if "ZVEI2:" in decoded:
|
||||
logging.debug("recieved ZVEI")
|
||||
<<<<<<< HEAD
|
||||
from includes.decoders import zvei
|
||||
zvei.decode(freq, decoded)
|
||||
=======
|
||||
|
||||
zvei_id = decoded[7:12] #ZVEI Code
|
||||
if re.search("[0-9F]{5}", zvei_id): #if ZVEI is valid
|
||||
if zvei_id == globals.zvei_id_old and timestamp < globals.zvei_time_old + globals.config.getint("BOSWatch", "zvei_double_ignore_time"): #check for double alarm
|
||||
logging.info("ZVEI double alarm: %s within %s second(s)", globals.zvei_id_old, timestamp-globals.zvei_time_old)
|
||||
globals.zvei_time_old = timestamp #in case of double alarm, zvei_double_ignore_time set new
|
||||
else:
|
||||
logging.info("5-Ton: %s", zvei_id)
|
||||
data = {"zvei":zvei_id}
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarm("ZVEI",freq,data)
|
||||
|
||||
globals.zvei_id_old = zvei_id #save last id
|
||||
globals.zvei_time_old = timestamp #save last time
|
||||
else:
|
||||
logging.warning("No valid ZVEI: %s", zvei_id)
|
||||
|
||||
>>>>>>> 26c9e23db8c6f82247b772859d35e35f0ac3f919
|
||||
|
||||
#POCSAG Decoder Section
|
||||
#check POCSAG -> validate -> check double alarm -> log
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ def decode(freq, decoded):
|
|||
else:
|
||||
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}
|
||||
from includes import pluginHandler
|
||||
pluginHandler.throwAlarm("POC",freq,data)
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarm("POC",freq,data)
|
||||
|
||||
globals.poc_id_old = poc_id #save last id
|
||||
globals.poc_time_old = timestamp #save last time
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from includes import globals # Global variables
|
||||
from includes import pluginloader
|
||||
|
||||
def throwAlarm(typ,freq,data):
|
||||
logging.debug("[ ALARM ]")
|
||||
for name, plugin in globals.pluginList.items():
|
||||
logging.debug("call Plugin: %s", name)
|
||||
plugin.run(typ,freq,data)
|
||||
logging.debug("[END ALARM]")
|
||||
|
||||
|
||||
def loadPlugins():
|
||||
try:
|
||||
#load plugins
|
||||
logging.debug("loading plugins")
|
||||
for i in pluginloader.getPlugins():
|
||||
plugin = pluginloader.loadPlugin(i)
|
||||
globals.pluginList[i["name"]] = plugin
|
||||
|
||||
except:
|
||||
logging.exception("cannot load Plugins")
|
||||
|
|
@ -7,6 +7,15 @@ import os
|
|||
|
||||
from includes import globals # Global variables
|
||||
|
||||
def loadPlugins():
|
||||
try:
|
||||
logging.debug("loading plugins")
|
||||
for i in getPlugins():
|
||||
plugin = loadPlugin(i)
|
||||
globals.pluginList[i["name"]] = plugin
|
||||
except:
|
||||
logging.exception("cannot load Plugins")
|
||||
|
||||
|
||||
def getPlugins():
|
||||
try:
|
||||
|
|
@ -34,6 +43,7 @@ def getPlugins():
|
|||
|
||||
return plugins
|
||||
|
||||
|
||||
def loadPlugin(plugin):
|
||||
try:
|
||||
logging.debug("load Plugin: %s", plugin["name"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue