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;
blocks_counter++;
/* 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;
if (wrong_blocks_counter>14) {//reduced from 35
if (wrong_blocks_counter>21) {//reduced from 35
lout << "@@@@@ Lost Sync (Got " << wrong_blocks_counter
<< " bad blocks on " << blocks_counter
<< " 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
//lout<<noutput_items<<std::endl;
/*SYNC:*/
/*synchronize:*/
if(mode==COPY and dosync_counter==SYNC_COUNTER_MAX){
dosync_counter=0;
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})
elif (groupType == "3A"):#ODA announcements (contain application ID "AID")
AID=(array[6]<<8)|(array[7])#combine 2 bytes into 1 block
app_data=(array[4]<<8)|(array[5])#content defined by ODA-app
app_group_raw=array[3]&0x1f #group type in which this app is sent
AID=int((array[6]<<8)|(array[7]))#combine 2 bytes into 1 block
app_data=int((array[4]<<8)|(array[5]))#content defined by ODA-app
app_group_raw=int(array[3]&0x1f) #group type in which this app is sent
if (app_group_raw&0x1 == 0):
app_group=str(app_group_raw >> 1)+"A"
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
elif self.debug:
print("unknown variant %i in TMC 3A group"%variant)
send_pmt = pmt.pmt_to_python.pmt_from_dict({
"type":"3A_meta",
"PI":PI,
"data":self.RDS_data[PI]["AID_list"][AID]})
self.message_port_pub(pmt.intern('tmc_raw'), send_pmt)
if self.RDS_data[PI]["AID_list"].has_key(52550):
try:
send_pmt = pmt.pmt_to_python.pmt_from_dict({
"type":"3A_meta",
"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
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")
@ -646,15 +652,16 @@ class rds_parser_table_qt(gr.sync_block):#START
datestring=date.strftime("%d.%m.%Y")
ctcol=self.colorder.index('time')
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"]["datestring"]=datestring
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:
print("ERROR: could not interpret time or date:")
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
"""In House Data:
{'130A': {'1E1077FFFF': {'count': 1,
@ -689,10 +696,10 @@ class rds_parser_table_qt(gr.sync_block):#START
"PI":PI,
"PSN":psn,
"datetime_str":datetime_str,
"TMC_X":tmc_x,
"TMC_Y":tmc_y,
"TMC_Z":tmc_z
})
"TMC_X":int(tmc_x),
"TMC_Y":int(tmc_y),
"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)
#~ 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.cb.clear(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):
if (e.modifiers() & QtCore.Qt.ControlModifier) and len(self.table.selectedRanges())>0:
selected = self.table.selectedRanges().pop()

46
python/tmc_classes.py

@ -285,7 +285,10 @@ class tmc_dict:
message.event.name="no message to cancel"
self.messages[lcn][updateClass]=message
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))
except AttributeError:
print("ERROR, not adding: "+str(message))
@ -459,7 +462,11 @@ class tmc_message:
#def db_string(self):
# return str(self.location)+": "+str(self.event.updateClass)+": "+self.events_string()+"; "+self.info_str()
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):
return self.location.get_extent_location(self.location,self.tmc_extent,self.tmc_dir)
def location_text(self):
@ -517,36 +524,43 @@ class tmc_message:
return self.datetime_received.strftime("%H:%M")
else:
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
#self.psn=tableobj.RDS_data[PI]["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
try:
msg_ltn=ltn#tableobj.RDS_data[PI]["AID_list"][52550]["LTN"]
table_ltn=1#german table
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:
if tableobj.debug:
print("no LTN found")
print("no LTN found")
#self.time_received=time_received
self.datetime_received=datetime_received
if self.datetime_received==None:
self.hastime=False
else:
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:
self.tmc_D=Y15 #diversion bit(Y15)

8
python/tmc_parser.py

@ -60,10 +60,10 @@ class tmc_parser(gr.sync_block):
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(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,
locstr text,eventstr text,multistr text,infostr text,
PRIMARY KEY (lcn, updateclass,PI))''')
PRIMARY KEY (lcn, updateclass,hash))''')
db.commit()
except sqlite3.OperationalError as e:
@ -105,11 +105,11 @@ class tmc_parser(gr.sync_block):
def print_tmc_msg(self,tmc_msg):
if self.writeDB and tmc_msg.event.is_cancellation == False:
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),
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"))
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:
if self.log or self.debug:
print("error during db insert msg:%s"%tmc_msg.log_string())

Loading…
Cancel
Save