Browse Source

ausarbeitung: systembeschreibung teil 1, neue grc screenshots , tmc: hash in db, num-confirmations, downloads: new RDS book pdf + reorganized stuff

master
Clemens Richter 9 years ago
parent
commit
669cecbfa1
  1. 4
      lib/rds_decoder_redsea_impl.cc
  2. 2
      lib/sync_decim_impl.cc
  3. 46
      python/rds_parser_table_qt.py
  4. 46
      python/tmc_classes.py
  5. 8
      python/tmc_parser.py

4
lib/rds_decoder_redsea_impl.cc

@ -316,9 +316,9 @@ int rds_decoder_redsea_impl::work (int noutput_items,
block_number=(block_number+1) % 4; block_number=(block_number+1) % 4;
blocks_counter++; blocks_counter++;
/* 1187.5 bps / 104 bits = 11.4 groups/sec, or 45.7 blocks/sec */ /* 1187.5 bps / 104 bits = 11.4 groups/sec, or 45.7 blocks/sec */
if (blocks_counter==20) {//reduced from 50 if (blocks_counter==30) {//reduced from 50
last_wrong_blocks_counter=wrong_blocks_counter; last_wrong_blocks_counter=wrong_blocks_counter;
if (wrong_blocks_counter>14) {//reduced from 35 if (wrong_blocks_counter>21) {//reduced from 35
lout << "@@@@@ Lost Sync (Got " << wrong_blocks_counter lout << "@@@@@ Lost Sync (Got " << wrong_blocks_counter
<< " bad blocks on " << blocks_counter << " bad blocks on " << blocks_counter
<< " total)" << std::endl; << " total)" << std::endl;

2
lib/sync_decim_impl.cc

@ -105,7 +105,7 @@ namespace gr {
last_input=in[(noutput_items-1)*DECIM+1];//to use for next iteration of work last_input=in[(noutput_items-1)*DECIM+1];//to use for next iteration of work
//lout<<noutput_items<<std::endl; //lout<<noutput_items<<std::endl;
/*SYNC:*/ /*synchronize:*/
if(mode==COPY and dosync_counter==SYNC_COUNTER_MAX){ if(mode==COPY and dosync_counter==SYNC_COUNTER_MAX){
dosync_counter=0; dosync_counter=0;
float out_noskip; float out_noskip;

46
python/rds_parser_table_qt.py

@ -565,9 +565,9 @@ class rds_parser_table_qt(gr.sync_block):#START
self.signals.DataUpdateEvent.emit({'col':rtcol,'row':port,'PI':PI,'string':formatted_text}) self.signals.DataUpdateEvent.emit({'col':rtcol,'row':port,'PI':PI,'string':formatted_text})
elif (groupType == "3A"):#ODA announcements (contain application ID "AID") elif (groupType == "3A"):#ODA announcements (contain application ID "AID")
AID=(array[6]<<8)|(array[7])#combine 2 bytes into 1 block AID=int((array[6]<<8)|(array[7]))#combine 2 bytes into 1 block
app_data=(array[4]<<8)|(array[5])#content defined by ODA-app app_data=int((array[4]<<8)|(array[5]))#content defined by ODA-app
app_group_raw=array[3]&0x1f #group type in which this app is sent app_group_raw=int(array[3]&0x1f) #group type in which this app is sent
if (app_group_raw&0x1 == 0): if (app_group_raw&0x1 == 0):
app_group=str(app_group_raw >> 1)+"A" app_group=str(app_group_raw >> 1)+"A"
else: else:
@ -618,11 +618,17 @@ class rds_parser_table_qt(gr.sync_block):#START
self.RDS_data[PI]["AID_list"][AID]["delay_time"]=(app_data>>0)&0x3 self.RDS_data[PI]["AID_list"][AID]["delay_time"]=(app_data>>0)&0x3
elif self.debug: elif self.debug:
print("unknown variant %i in TMC 3A group"%variant) print("unknown variant %i in TMC 3A group"%variant)
send_pmt = pmt.pmt_to_python.pmt_from_dict({ if self.RDS_data[PI]["AID_list"].has_key(52550):
"type":"3A_meta", try:
"PI":PI, send_pmt = pmt.pmt_to_python.pmt_from_dict({
"data":self.RDS_data[PI]["AID_list"][AID]}) "type":"3A_meta",
self.message_port_pub(pmt.intern('tmc_raw'), send_pmt) "PI":PI,
"data":self.RDS_data[PI]["AID_list"][52550]})
self.message_port_pub(pmt.intern('tmc_raw'), send_pmt)
except TypeError as e:
print(e)
print("this gnuradio instance doesnt seem to be able to convert from numpy.int64 to pmt")
code.interact(local=locals())
elif (groupType == "4A"):#CT clock time elif (groupType == "4A"):#CT clock time
bits=BitArray('uint:8=%i,uint:8=%i,uint:8=%i,uint:8=%i,uint:8=%i'%tuple(array[3:8])) bits=BitArray('uint:8=%i,uint:8=%i,uint:8=%i,uint:8=%i,uint:8=%i'%tuple(array[3:8]))
spare,datecode,hours,minutes,offsetdir,local_time_offset = bits.unpack("uint:6,uint:17,uint:5,uint:6,uint:1,uint:5") spare,datecode,hours,minutes,offsetdir,local_time_offset = bits.unpack("uint:6,uint:17,uint:5,uint:6,uint:1,uint:5")
@ -646,15 +652,16 @@ class rds_parser_table_qt(gr.sync_block):#START
datestring=date.strftime("%d.%m.%Y") datestring=date.strftime("%d.%m.%Y")
ctcol=self.colorder.index('time') ctcol=self.colorder.index('time')
self.signals.DataUpdateEvent.emit({'col':ctcol,'row':port,'PI':PI,'string':timestring,'tooltip':datestring}) self.signals.DataUpdateEvent.emit({'col':ctcol,'row':port,'PI':PI,'string':timestring,'tooltip':datestring})
t=(str(datetime.now()),PI,self.RDS_data[PI]["PSN"],"CT",datestring+" "+timestring+"; datecode(MJD):"+str(datecode))
self.RDS_data[PI]["time"]["timestring"]=timestring self.RDS_data[PI]["time"]["timestring"]=timestring
self.RDS_data[PI]["time"]["datestring"]=datestring self.RDS_data[PI]["time"]["datestring"]=datestring
self.RDS_data[PI]["time"]["datetime"]=datetime(date.year,date.month,date.day,hours,minutes)+timedelta(hours=local_time_offset) self.RDS_data[PI]["time"]["datetime"]=datetime(date.year,date.month,date.day,hours,minutes)+timedelta(hours=local_time_offset)
if self.writeDB:
t=(str(datetime.now()),PI,self.RDS_data[PI]["PSN"],"CT",datestring+" "+timestring+"; datecode(MJD):"+str(datecode))
db.execute("INSERT INTO data (time,PI,PSN,dataType,data) VALUES (?,?,?,?,?)",t)
except ValueError as e: except ValueError as e:
print("ERROR: could not interpret time or date:") print("ERROR: could not interpret time or date:")
print(e) print(e)
if self.writeDB:
db.execute("INSERT INTO data (time,PI,PSN,dataType,data) VALUES (?,?,?,?,?)",t)
elif (groupType == "6A"):#IH inhouse data -> save for analysis elif (groupType == "6A"):#IH inhouse data -> save for analysis
"""In House Data: """In House Data:
{'130A': {'1E1077FFFF': {'count': 1, {'130A': {'1E1077FFFF': {'count': 1,
@ -689,10 +696,10 @@ class rds_parser_table_qt(gr.sync_block):#START
"PI":PI, "PI":PI,
"PSN":psn, "PSN":psn,
"datetime_str":datetime_str, "datetime_str":datetime_str,
"TMC_X":tmc_x, "TMC_X":int(tmc_x),
"TMC_Y":tmc_y, "TMC_Y":int(tmc_y),
"TMC_Z":tmc_z "TMC_Z":int(tmc_z)
}) })#this gnuradio instance doesnt seem to be able to convert from numpy.int64 to pmt
self.message_port_pub(pmt.intern('tmc_raw'), send_pmt) self.message_port_pub(pmt.intern('tmc_raw'), send_pmt)
#~ tmc_hash=md5.new(str([PI,tmc_x,tmc_y,tmc_z])).hexdigest() #~ tmc_hash=md5.new(str([PI,tmc_x,tmc_y,tmc_z])).hexdigest()
@ -1069,15 +1076,6 @@ class rds_parser_table_qt_Widget(QtGui.QWidget):
self.clip = QtGui.QApplication.clipboard() self.clip = QtGui.QApplication.clipboard()
#self.cb.clear(mode=cb.Clipboard ) #self.cb.clear(mode=cb.Clipboard )
#self.cb.setText("Clipboard Text", mode=cb.Clipboard) #self.cb.setText("Clipboard Text", mode=cb.Clipboard)
def filterChanged(self):
print("filter changed")
ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower()
lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower()
self.logOutput.clear()
#filters=[{"type":"location", "str":u"Baden-Württemberg"}]
filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}]
self.logOutput.append(Qt.QString.fromUtf8(self.tableobj.tmc_messages.getLogString(filters)))
#self.logOutput.append(Qt.QString.fromUtf8(self.tableobj.tmc_messages.getLogString([])))
def keyPressEvent(self, e): def keyPressEvent(self, e):
if (e.modifiers() & QtCore.Qt.ControlModifier) and len(self.table.selectedRanges())>0: if (e.modifiers() & QtCore.Qt.ControlModifier) and len(self.table.selectedRanges())>0:
selected = self.table.selectedRanges().pop() selected = self.table.selectedRanges().pop()

46
python/tmc_classes.py

@ -285,7 +285,10 @@ class tmc_dict:
message.event.name="no message to cancel" message.event.name="no message to cancel"
self.messages[lcn][updateClass]=message self.messages[lcn][updateClass]=message
else: else:
self.messages[lcn][updateClass]=message if self.messages[lcn].has_key(updateClass) and self.messages[lcn][updateClass].tmc_hash ==message.tmc_hash:#if same message -> add confirmation
self.messages[lcn][updateClass].add_confirmation(message)
else:#(over)write message
self.messages[lcn][updateClass]=message
#print("added message: "+str(message)) #print("added message: "+str(message))
except AttributeError: except AttributeError:
print("ERROR, not adding: "+str(message)) print("ERROR, not adding: "+str(message))
@ -459,7 +462,11 @@ class tmc_message:
#def db_string(self): #def db_string(self):
# return str(self.location)+": "+str(self.event.updateClass)+": "+self.events_string()+"; "+self.info_str() # return str(self.location)+": "+str(self.event.updateClass)+": "+self.events_string()+"; "+self.info_str()
def map_string(self): def map_string(self):
return '<span title="%s">'%self.getDate()+str(self.event.updateClass)+": "+self.getTime()+'</span><span title="%s">'%self.multi_str()+": "+self.events_string()+self.info_str()+"; "+self.psn+"</span>" retstr='<span title="%s">'%self.getDate()+str(self.event.updateClass)+": "+self.getTime()+'</span>'
retstr+='<span title="%s">'%self.multi_str()+": "+self.events_string()+self.info_str()+"; "+"</span>"
retstr+='<span title="%i">'%self.confirmations+str(list(self.psns)).replace("'", '"')+"</span>"
return retstr
def end_loc(self): def end_loc(self):
return self.location.get_extent_location(self.location,self.tmc_extent,self.tmc_dir) return self.location.get_extent_location(self.location,self.tmc_extent,self.tmc_dir)
def location_text(self): def location_text(self):
@ -517,36 +524,43 @@ class tmc_message:
return self.datetime_received.strftime("%H:%M") return self.datetime_received.strftime("%H:%M")
else: else:
return "88:88" return "88:88"
def add_confirmation(self,tmc_msg):
self.PIs.add(tmc_msg.PI)
self.psns.add(tmc_msg.psn)
self.confirmations+=1
def __init__(self,PI,psn,ltn,tmc_x,tmc_y,tmc_z,datetime_received,tableobj):#TODO handle out of sequence data def __init__(self,PI,psn,ltn,tmc_x,tmc_y,tmc_z,datetime_received,tableobj):#TODO handle out of sequence data
#self.psn=tableobj.RDS_data[PI]["PSN"] #self.psn=tableobj.RDS_data[PI]["PSN"]
self.psn=psn self.psn=psn
self.psns=set([psn])
self.PI=PI
self.PIs=set([PI])
self.confirmations=1
self.debug_data=""
self.tableobj=tableobj
#self.isCancelled=False
self.cancellation_time=None
self.tmc_hash=hash((tmc_x,tmc_y,tmc_z))
tmc_T=tmc_x>>4 #0:TMC-message 1:tuning info/service provider name
assert tmc_T==0, "this is tuning info and no alert_c message"
Y15=int(tmc_y>>15)
tmc_F=int((tmc_x>>3)&0x1) #identifies the message as a Single Group (F = 1) or Multi Group (F = 0)
self.is_single=(tmc_F==1)
self.is_multi=(tmc_F==0)
#check LTN #check LTN
try: try:
msg_ltn=ltn#tableobj.RDS_data[PI]["AID_list"][52550]["LTN"] msg_ltn=ltn#tableobj.RDS_data[PI]["AID_list"][52550]["LTN"]
table_ltn=1#german table table_ltn=1#german table
if msg_ltn != table_ltn and tableobj.debug and False:#disabled, spams log if msg_ltn != table_ltn and tableobj.debug and False:#disabled, spams log
print("msg_ltn:%i does not match expected table (1) on station: %s"%(msg_ltn,self.psn)) print("msg_ltn:%i does not match expected table (1) on station: %s"%(msg_ltn,self.psn))
except KeyError: except KeyError:
if tableobj.debug: if tableobj.debug:
print("no LTN found") print("no LTN found")
#self.time_received=time_received #self.time_received=time_received
self.datetime_received=datetime_received self.datetime_received=datetime_received
if self.datetime_received==None: if self.datetime_received==None:
self.hastime=False self.hastime=False
else: else:
self.hastime=True self.hastime=True
self.debug_data=""
self.tableobj=tableobj
self.PI=PI
#self.isCancelled=False
self.cancellation_time=None
self.tmc_hash=hash((PI,tmc_x,tmc_y,tmc_z))
tmc_T=tmc_x>>4 #0:TMC-message 1:tuning info/service provider name
assert tmc_T==0, "this is tuning info and no alert_c message"
Y15=int(tmc_y>>15)
tmc_F=int((tmc_x>>3)&0x1) #identifies the message as a Single Group (F = 1) or Multi Group (F = 0)
self.is_single=(tmc_F==1)
self.is_multi=(tmc_F==0)
if self.is_single or (self.is_multi and Y15==1):#single group or 1st group of multigroup if self.is_single or (self.is_multi and Y15==1):#single group or 1st group of multigroup
if self.is_single: if self.is_single:
self.tmc_D=Y15 #diversion bit(Y15) self.tmc_D=Y15 #diversion bit(Y15)

8
python/tmc_parser.py

@ -60,10 +60,10 @@ class tmc_parser(gr.sync_block):
try: try:
#db.execute('CREATE TABLE TMC(hash text PRIMARY KEY UNIQUE,time text,PI text, F integer,event integer,location integer,DP integer,div integer,dir integer,extent integer,text text,multi text,rawmgm text)') #db.execute('CREATE TABLE TMC(hash text PRIMARY KEY UNIQUE,time text,PI text, F integer,event integer,location integer,DP integer,div integer,dir integer,extent integer,text text,multi text,rawmgm text)')
db.execute('''CREATE TABLE TMC(lcn integer,updateclass integer, db.execute('''CREATE TABLE TMC(lcn integer,updateclass integer,hash int,
PI text,time text,ecn integer, isSingle integer,DP integer,div integer,dir integer,extent integer, PI text,time text,ecn integer, isSingle integer,DP integer,div integer,dir integer,extent integer,
locstr text,eventstr text,multistr text,infostr text, locstr text,eventstr text,multistr text,infostr text,
PRIMARY KEY (lcn, updateclass,PI))''') PRIMARY KEY (lcn, updateclass,hash))''')
db.commit() db.commit()
except sqlite3.OperationalError as e: except sqlite3.OperationalError as e:
@ -105,11 +105,11 @@ class tmc_parser(gr.sync_block):
def print_tmc_msg(self,tmc_msg): def print_tmc_msg(self,tmc_msg):
if self.writeDB and tmc_msg.event.is_cancellation == False: if self.writeDB and tmc_msg.event.is_cancellation == False:
try: try:
t=(int(tmc_msg.location.lcn),int(tmc_msg.event.updateClass),tmc_msg.PI, t=(int(tmc_msg.location.lcn),int(tmc_msg.event.updateClass),tmc_msg.PI,tmc_msg.tmc_hash,
tmc_msg.getTime(),int(tmc_msg.event.ecn),int(tmc_msg.is_single), tmc_msg.getTime(),int(tmc_msg.event.ecn),int(tmc_msg.is_single),
int(tmc_msg.tmc_DP),int(tmc_msg.tmc_D),int(tmc_msg.tmc_dir),int(tmc_msg.tmc_extent), int(tmc_msg.tmc_DP),int(tmc_msg.tmc_D),int(tmc_msg.tmc_dir),int(tmc_msg.tmc_extent),
tmc_msg.location_text().decode("utf-8"),tmc_msg.events_string().decode("utf-8"),tmc_msg.info_str().decode("utf-8"),tmc_msg.multi_str().decode("utf-8")) tmc_msg.location_text().decode("utf-8"),tmc_msg.events_string().decode("utf-8"),tmc_msg.info_str().decode("utf-8"),tmc_msg.multi_str().decode("utf-8"))
self.db.execute("REPLACE INTO TMC (lcn,updateclass,PI,time,ecn,isSingle,DP,div,dir,extent,locstr,eventstr,infostr,multistr) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)",t) self.db.execute("REPLACE INTO TMC (lcn,updateclass,hash,PI,time,ecn,isSingle,DP,div,dir,extent,locstr,eventstr,infostr,multistr) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",t)
except Exception as e: except Exception as e:
if self.log or self.debug: if self.log or self.debug:
print("error during db insert msg:%s"%tmc_msg.log_string()) print("error during db insert msg:%s"%tmc_msg.log_string())

Loading…
Cancel
Save