mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
Merge branch 'pr/20' into develop
Conflicts: boswatch.py Merge branch 'pr/20' into develop Conflicts: boswatch.py
This commit is contained in:
commit
5a405e1ddb
|
|
@ -236,7 +236,7 @@ try:
|
|||
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, "tki":fms_tsi}
|
||||
data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "tsi":fms_tsi}
|
||||
throwAlarm("FMS",data)
|
||||
|
||||
fms_id_old = fms_id #save last id
|
||||
|
|
@ -283,7 +283,7 @@ try:
|
|||
|
||||
if re.search("[0-9]{7}", poc_id): #if POC is valid
|
||||
if poc_id >= globals.config.getint("BOSWatch", "poc_filter_range_start"):
|
||||
if poc_id <= globals.config.getint("BOSWatch", "poc_filter_range_end"):
|
||||
if poc_id <= globals.config.getint("BOSWatch", "poc_filter_range_end"):
|
||||
if poc_id == poc_id_old and timestamp < poc_time_old + globals.config.getint("BOSWatch", "poc_double_ignore_time"): #check for double alarm
|
||||
logging.warning("POC512 double alarm: %s within %s second(s)", poc_id_old, timestamp-poc_time_old)
|
||||
poc_time_old = timestamp #in case of double alarm, poc_double_ignore_time set new
|
||||
|
|
@ -295,9 +295,9 @@ try:
|
|||
poc_id_old = poc_id #save last id
|
||||
poc_time_old = timestamp #save last time
|
||||
else:
|
||||
logging.warning("POCSAG512: %s out of filter range", poc_id)
|
||||
logging.warning("POCSAG512: %s out of filter range (high)", poc_id)
|
||||
else:
|
||||
logging.warning("POCSAG512: %s out of filter range", poc_id)
|
||||
logging.warning("POCSAG512: %s out of filter range (low)", poc_id)
|
||||
else:
|
||||
logging.warning("No valid POCSAG512: %s", poc_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
import logging # Global logger
|
||||
import globals # Global variables
|
||||
import mysql
|
||||
import mysql.connector
|
||||
|
||||
def run(typ,freq,data):
|
||||
try:
|
||||
|
|
@ -13,18 +15,33 @@ def run(typ,freq,data):
|
|||
logging.debug(" - %s = %s", key, val)
|
||||
except:
|
||||
logging.exception("cannot read config file")
|
||||
|
||||
if typ == "FMS":
|
||||
#logging.debug("FMS: %s Status: %s Dir: %s", data["fms"], data["status"], data["direction"])
|
||||
logging.debug("FMS")
|
||||
elif typ == "ZVEI":
|
||||
#logging.debug("ZVEI: %s", data["zvei"])
|
||||
logging.debug("ZVEI")
|
||||
elif typ == "POC":
|
||||
#logging.debug("POC: %s/%s - %s", data["ric"], data["function"], data["msg"])
|
||||
logging.debug("POC")
|
||||
else:
|
||||
logging.warning(typ + " not supportet")
|
||||
|
||||
#open DB-Connection
|
||||
try:
|
||||
connection = mysql.connector.connect(host = globals.config.get("MySQL","dbserver"), user = globals.config.get("MySQL","dbuser"), passwd = globals.config.get("MySQL","dbpassword"), db = globals.config.get("MySQL","database"))
|
||||
cursor = connection.cursor()
|
||||
|
||||
if typ == "FMS":
|
||||
#data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "tsi":fms_tsi}
|
||||
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableFMS")+" (time,fms,status,direction,tsi) VALUES (NOW(),%s,%s,%s,%s)",(data["fms"],data["status"],data["direction"],data["tsi"]))
|
||||
|
||||
elif typ == "ZVEI":
|
||||
#data = {"zvei":zvei_id}
|
||||
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableZVEI")+" (time,zvei) VALUES (NOW(),"+data["zvei"]+")")
|
||||
|
||||
elif typ == "POC":
|
||||
#data = {"ric":poc_id, "function":poc_sub, "msg":poc_text}
|
||||
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tablePOC")+" (time,ric,funktion,text) VALUES (NOW(),%s,%s,%s)",(data["ric"],data["function"],data["msg"]))
|
||||
|
||||
else:
|
||||
logging.warning(typ + " not supportet")
|
||||
return
|
||||
|
||||
cursor.close()
|
||||
connection.commit()
|
||||
except:
|
||||
logging.exception("%s to MySQL failed", typ)
|
||||
finally:
|
||||
connection.close() #Close connection in every case
|
||||
except:
|
||||
logging.exception("unknown error")
|
||||
|
|
@ -14,7 +14,7 @@ FMS:
|
|||
- fms
|
||||
- status
|
||||
- direction
|
||||
- tki
|
||||
- tsi
|
||||
|
||||
POCSAG:
|
||||
- ric
|
||||
|
|
|
|||
Loading…
Reference in a new issue