diff --git a/apps/fft-multi-decoder_fixed_rtlsdr.grc b/apps/fft-multi-decoder_fixed_rtlsdr.grc
index ad7f2f7..d1a5b13 100644
--- a/apps/fft-multi-decoder_fixed_rtlsdr.grc
+++ b/apps/fft-multi-decoder_fixed_rtlsdr.grc
@@ -2289,6 +2289,65 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in
False
+
+ multirds_tmc_parser
+
+ alias
+
+
+
+ comment
+
+
+
+ affinity
+
+
+
+ debug
+ False
+
+
+ _enabled
+ True
+
+
+ _coordinate
+ (1896, 460)
+
+
+ gui_hint
+
+
+
+ _rotation
+ 0
+
+
+ id
+ multirds_tmc_parser_0
+
+
+ label
+
+
+
+ log
+ False
+
+
+ maxheight
+ 160
+
+
+ workdir
+ /media/clemens/intdaten/uni_bulk/forschungsarbeit/data/
+
+
+ writeDB
+ False
+
+
osmosdr_source
@@ -6672,6 +6731,12 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in
rds
in2
+
+ multirds_rds_parser_table_qt_0_0
+ multirds_tmc_parser_0
+ tmc_raw
+ in
+
osmosdr_source_0
blocks_stream_to_vector_0
diff --git a/python/tmc_classes.py b/python/tmc_classes.py
index 7a4955a..069c285 100644
--- a/python/tmc_classes.py
+++ b/python/tmc_classes.py
@@ -52,6 +52,7 @@ class lcl:
self.segments=self.dat_to_dict(lcldir+'SEGMENTS.DAT','ISO 8859-15','LCD')
self.allocated_codes=self.dat_to_dict(lcldir+'LOCATIONCODES.DAT','ISO 8859-15','LCD')
self.areas=self.dat_to_dict(lcldir+'ADMINISTRATIVEAREA.DAT','ISO 8859-15','LCD')
+ #code.interact(local=locals())
def lcn_allocated(self,LCN):
return bool(self.allocated_codes[LCN]["ALLOCATED"])
def get_poffsets(self,LCD):
@@ -192,7 +193,30 @@ class tmc_event:
else:
return("invalid event, ecn:%i"%self.ecn)
def __repr__(self):
- return "ecn:%i"%self.ecn
+ return "ecn:%i"%self.ecn
+class tmc_segment:
+ def __init__(self,lcn,tableobj):
+ self.lcn=lcn
+ self.tableobj=tableobj
+ self.lcl_obj=tableobj.lcl_obj
+ self.roadnumber=""
+ self.roadname=""
+ self.first_name=""
+ self.second_name=""
+ if self.lcl_obj.lcn_allocated(lcn):
+ try:
+ self.loc_dict=self.lcl_obj.get_segment(lcn)
+ self.roadnumber=self.loc_dict['ROADNUMBER']
+ if not self.loc_dict['RNID']==u"":
+ self.roadname=self.lcl_obj.get_name(int(self.loc_dict['RNID']))
+ if not self.loc_dict['N1ID']==u"":
+ self.first_name=self.lcl_obj.get_name(int(self.loc_dict['N1ID']))
+ if not self.loc_dict['N2ID']==u"":
+ self.second_name=self.lcl_obj.get_name(int(self.loc_dict['N2ID']))
+ except KeyError:
+ print("segment '%i' not found"%lcn)
+ elif self.tableobj.log or self.tableobj.debug:
+ print("lcn not allocated %i"%lcn)
class tmc_location:
def __ref_locs(self,lcn,name_string=""):
if(lcn==34196):#europe
@@ -200,17 +224,20 @@ class tmc_location:
else:
try:
loc_dict=self.lcl_obj.get_area(lcn)
- aref=int(loc_dict[u'POL_LCD'])
loc_name=self.lcl_obj.get_name(int(self.loc_dict['N1ID']))
+ aref=int(loc_dict[u'POL_LCD'])
return(self.__ref_locs(aref,name_string+","+loc_name))
- except KeyError:
+ except KeyError:#no area with lcn
return(name_string)
+ except ValueError:#POL_LCD was empty (no int)
+ return(name_string+loc_name)
def __getitem__(self,item):
return self.loc_dict[item]
- def __init__(self,lcn,lcl_obj):
+ def __init__(self,lcn,tableobj):
self.lcn=lcn
- self.lcl_obj=lcl_obj
- self.reflocs=self.__ref_locs(lcn)
+ self.tableobj=tableobj
+ self.lcl_obj=tableobj.lcl_obj
+ self.reflocs=""
self.is_valid=False
self.loc_dict={}
self.has_koord=False
@@ -218,21 +245,31 @@ class tmc_location:
if self.lcl_obj.lcn_allocated(lcn):
try:
self.loc_dict=self.lcl_obj.get_point(lcn)
- self.is_valid=True
+ self.reflocs=self.__ref_locs(lcn)
+
self.ltype=self.loc_dict[u'CLASS']+self.loc_dict[u'TCD']
try:
self.subtype=int(self.loc_dict[u'STCD'])
except ValueError:#should not happen, all rows have int
self.subtype=0
print("location subtype %s is invalid in location %i"%(self.loc_dict[u'STCD'],lcn))
- self.roadnumber=""
- self.roadname=self.lcl_obj.get_name(int(self.loc_dict['RNID']))
- self.first_name=self.lcl_obj.get_name(int(self.loc_dict['N1ID']))
- self.second_name=self.lcl_obj.get_name(int(self.loc_dict['N2ID']))
+ if not self.loc_dict['RNID']==u"":
+ self.roadname=self.lcl_obj.get_name(int(self.loc_dict['RNID']))
+ else:
+ self.roadname=""
+ if not self.loc_dict['N1ID']==u"":
+ self.first_name=self.lcl_obj.get_name(int(self.loc_dict['N1ID']))
+ else:
+ self.first_name=""
+ if not self.loc_dict['N2ID']==u"":
+ self.second_name=self.lcl_obj.get_name(int(self.loc_dict['N2ID']))
+ else:
+ self.second_name=""
+
if not self.loc_dict['ROA_LCD']==u"":
- self.linRef=tmc_location(int(self.loc_dict['ROA_LCD']),tableobj)
- self.negative_offset=int(self.lcl_obj.get_poffsets(lcd)[u"NEG_OFF_LCD"])
- self.positive_offset=int(self.lcl_obj.get_poffsets(lcd)[u"POS_OFF_LCD"])
+ self.linRef=tmc_segment(int(self.loc_dict['ROA_LCD']),tableobj)
+ self.negative_offset=self.lcl_obj.get_poffsets(lcn)[u"NEG_OFF_LCD"]
+ self.positive_offset=self.lcl_obj.get_poffsets(lcn)[u"POS_OFF_LCD"]
try:
#koords stored in WGS84 format with decimal degrees multiplied with 10^5
self.xkoord=int(self.loc_dict[u"XCOORD"])/100000.0
@@ -244,7 +281,7 @@ class tmc_location:
except ValueError:
self.has_koord=False
self.is_valid=True
- if not lcn==34196:#Europe does not have an area reference
+ if not self.loc_dict['POL_LCD']=="":#Europe (lcn==34196) does not have an area reference
self.aref=tmc_location(int(self.loc_dict['POL_LCD']),tableobj)
except KeyError:
print("point '%i' not found"%lcn)
@@ -262,6 +299,8 @@ class tmc_location:
#return __recursion_get_extent_location(offset_loc,extent-1,direction)
return offset_loc.get_extent_location(offset_loc,extent-1,direction)
def __str__(self):
+ return unicode(self).encode('utf-8')
+ def __unicode__(self):
if not self.is_valid:
return "invalid lcn:%i"%(self.lcn)
elif self.ltype=="P1" and self.subtype==1:#autobahnkreuz TODO:only add if name does not already contain "Kreuz"
@@ -430,7 +469,9 @@ class tmc_dict:
def matchFilter(self,msg,filters):
if not msg.location.is_valid:
return True#always show invalid messages
- loc_str=str(msg.location)+str(msg.location.reflocs)+str(msg.location.roadnumber)
+ loc_str=str(msg.location)+str(msg.location.reflocs)
+ if not msg.location.linRef==None:
+ loc_str+=str(msg.location.linRef.roadnumber)
for f in filters:#filters is list of dicts {"type":"event","str":"Stau"}
@@ -605,7 +646,7 @@ class tmc_message:
def end_loc(self):
return self.location.get_extent_location(self.location,self.tmc_extent,self.tmc_dir)
def location_text(self):
- text=str(self.location)#use __str__ of location if no location_text implemented
+ text=unicode(self.location)#use __str__ of location if no location_text implemented
#TODO add "dreieck" for P1.2 -> done in tmc_message.__str__
if not self.location.linRef==None:#test
#self.tmc_extent and self.tmc_dir are ints
@@ -617,12 +658,12 @@ class tmc_message:
else:
print(offset_loc)
offset_loc_name="###INVALID###"
- templates={"de_1":"{A}, {B} in Richtung {C}"#coding handbook: zwischen {D} und {E}, sprachdurchsagen(manchmal): zwischen {E} und {D} TODO: swap D and E if offset-dir negative
- ,"de_2a":", zwischen {D} und {E}"
- ,"de_2b":", bei {D}"#extent==0
- ,"en_1":"{A}, {B} {C}"
- ,"en_2a":", between {D} and {E}"
- ,"en_2b":", at {D}"}#extent==0
+ templates={"de_1":u"{A}, {B} in Richtung {C}"#coding handbook: zwischen {D} und {E}, sprachdurchsagen(manchmal): zwischen {E} und {D} TODO: swap D and E if offset-dir negative
+ ,"de_2a":u", zwischen {D} und {E}"
+ ,"de_2b":u", bei {D}"#extent==0
+ ,"en_1":u"{A}, {B} {C}"
+ ,"en_2a":u", between {D} and {E}"
+ ,"en_2b":u", at {D}"}#extent==0
text=templates[language+"_1"].format(A=self.location.linRef.roadnumber, B=self.location.linRef.second_name,C=self.location.linRef.first_name)
if self.location.first_name==offset_loc_name:#similar to self.tmc_extent==0 (but some similar location have same same name)
text+=templates[language+"_2b"].format(D=self.location.first_name)
@@ -642,7 +683,7 @@ class tmc_message:
#EventCode: EventText
#F
#return unicode(text,encoding="utf-8")
- return text
+ return text.encode('utf-8')
def __str__(self):
return str(self.event.updateClass)+": "+self.getTime()+": "+self.events_string()+"; "+self.multi_str()
def __repr__(self):
diff --git a/python/tmc_parser.py b/python/tmc_parser.py
index f59f787..f4697c5 100644
--- a/python/tmc_parser.py
+++ b/python/tmc_parser.py
@@ -25,7 +25,7 @@ import pmt
from PyQt4 import Qt, QtCore, QtGui
import code,time,csv,sqlite3,atexit
from bitstring import BitArray
-from multirds.tmc_classes import tmc_dict,tmc_message,language
+from multirds.tmc_classes import tmc_dict,tmc_message,language,lcl
from datetime import datetime
from datetime import timedelta