small changes in documentation

This commit is contained in:
JHCD 2015-06-14 20:21:21 +02:00
parent 16865b2c57
commit 97e87fcae2
11 changed files with 140 additions and 128 deletions

View file

@ -9,15 +9,15 @@ FMS Decoder
@requires: Configuration has to be set in the config.ini
"""
import logging
import time #timestamp for doublealarm
import re #Regex for validation
import logging # Global logger
import time # timestamp for doublealarm
import re # Regex for validation
from includes import globals # Global variables
##
#
# FMS Decoder Function
# FMS decoder function
# validate -> check double alarm -> log
#
def decode(freq, decoded):
@ -34,23 +34,26 @@ def decode(freq, decoded):
@return: nothing
@exception: Exception if FMS decode failed
"""
timestamp = int(time.time())#Get Timestamp
timestamp = int(time.time()) # Get Timestamp
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_directionText = decoded[103:110] #Richtung (Text)
fms_tsi = decoded[114:117] #Taktische Kruzinformation
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_directionText = decoded[103:110] # Richtung (Text)
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("FMS", "double_ignore_time"): #check for double alarm
fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction # build FMS id
# if FMS is valid
if re.search("[0-9a-f]{8}[0-9a-f]{1}[01]{1}", fms_id):
# check for double alarm
if fms_id == globals.fms_id_old and timestamp < globals.fms_time_old + globals.config.getint("FMS", "double_ignore_time"):
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
# in case of double alarm, fms_double_ignore_time set new
globals.fms_time_old = timestamp
else:
logging.info("FMS:%s Status:%s Richtung:%s TSI:%s", fms_id[0:8], fms_status, fms_direction, fms_tsi)
data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "directionText":fms_directionText, "tsi":fms_tsi, "description":fms_id[0:8]}