Merge pull request #271 from jbollacke/feature/subric_description

New feature: 
SubRIC is now used for a detailed description.
Remember that you have to have an entry of the main RIC - it is used as fallback.

The SubRICs are set as sufficix to the main description
This commit is contained in:
Florian 2017-05-01 10:08:32 +02:00 committed by GitHub
commit daddd02279
2 changed files with 7 additions and 5 deletions

View file

@ -126,7 +126,7 @@ def decode(freq, decoded):
# If enabled, look up description
if globalVars.config.getint("POC", "idDescribed"):
from includes import descriptionList
data["description"] = descriptionList.getDescription("POC", poc_id)
data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"])
# processing the alarm
try:
from includes import alarmHandler

View file

@ -11,6 +11,7 @@ Function to expand the dataset with a description.
import logging # Global logger
import csv # for loading the description files
import re # for matching IDs with a regular expression
from includes import globalVars # Global variables
from includes.helper import stringConverter
@ -41,10 +42,10 @@ def loadCSV(typ, idField):
reader = csv.DictReader(csvfile)
for row in reader:
logging.debug(row)
# only import rows with an integer as id
if row[idField].isdigit() == True:
# only import rows with an integer as id, allow subrics though
if re.match("^[0-9]+[A-D]?$", row[idField], re.IGNORECASE):
try:
resultList[row[idField]] = stringConverter.convertToUTF8(row['description'])
resultList[row[idField].lower()] = stringConverter.convertToUTF8(row['description'])
except:
# skip entry in case of an exception
pass
@ -112,7 +113,8 @@ def getDescription(typ, data):
resultStr = zveiDescribtionList[data]
elif typ == "POC":
global ricDescribtionList
resultStr = ricDescribtionList[data]
resultStr = ricDescribtionList[data[:-1]] # MainRIC
resultStr += " " + ricDescribtionList[data] # SubRIC
else:
logging.warning("Invalid Typ: %s", typ)