Browse Source

added pilot strength display to table

master
Clemens Richter 9 years ago
parent
commit
3593c7d4b6
  1. 17
      python/pilot_quality.py
  2. 21
      python/rds_parser_table_qt.py

17
python/pilot_quality.py

@ -21,7 +21,7 @@
import numpy as np import numpy as np
from gnuradio import gr from gnuradio import gr
import pmt,code import pmt,time
class pilot_quality(gr.sync_block): class pilot_quality(gr.sync_block):
@ -35,11 +35,13 @@ class pilot_quality(gr.sync_block):
out_sig=None) out_sig=None)
#self.carrier_width=1 #self.carrier_width=1
self.debug=debug self.debug=debug
self.msg_adr=msg_adr
self.message_port_register_out(pmt.intern('out')) self.message_port_register_out(pmt.intern('out'))
self.carrier_index=int(carrier_freq*fft_len/float(samp_rate)) self.carrier_index=int(carrier_freq*fft_len/float(samp_rate))
self.lowbound_index=int((carrier_freq-gap_width)*fft_len/float(samp_rate)) self.lowbound_index=int((carrier_freq-gap_width)*fft_len/float(samp_rate))
self.highbound_index=int((carrier_freq+gap_width)*fft_len/float(samp_rate)) self.highbound_index=int((carrier_freq+gap_width)*fft_len/float(samp_rate))
self.send_timer=time.time()
self.strength_list=[]
def work(self, input_items, output_items): def work(self, input_items, output_items):
in0 = input_items[0] in0 = input_items[0]
# <+signal processing here+> # <+signal processing here+>
@ -48,7 +50,16 @@ class pilot_quality(gr.sync_block):
carrier=np.mean(in_vec[self.carrier_index-1:self.carrier_index+1]) carrier=np.mean(in_vec[self.carrier_index-1:self.carrier_index+1])
#code.interact(local=locals()) #code.interact(local=locals())
strength=abs(carrier-surrounding) strength=abs(carrier-surrounding)
self.strength_list.append(strength)
#if self.debug:
# print("i:%i,strength: %f,carrier: %f, around:%f"%(i,strength,carrier,surrounding))
if time.time()-self.send_timer>0.1:#10 times per second
self.send_timer=time.time()
strength_mean=int(np.mean(self.strength_list))
self.strength_list=[]
send_pmt = pmt.cons(pmt.from_long(self.msg_adr),pmt.from_long(strength_mean))
self.message_port_pub(pmt.intern('out'), send_pmt)
if self.debug: if self.debug:
print("strength: %f,carrier: %f, around:%f"%(strength,carrier,surrounding)) print("mean:%i"%strength_mean)
return len(input_items[0]) return len(input_items[0])

21
python/rds_parser_table_qt.py

@ -92,7 +92,7 @@ class rds_parser_table_qt(gr.sync_block):#START
self.decoders.append({'synced':False,'freq':None,'PI':""}) self.decoders.append({'synced':False,'freq':None,'PI':""})
#self.decoder_synced={} #self.decoder_synced={}
#self.colorder=['ID','freq','name','PTY','AF','time','text','quality','buttons'] #self.colorder=['ID','freq','name','PTY','AF','time','text','quality','buttons']
self.colorder=['ID','freq','name','buttons','PTY','AF','time','text','quality','RT+'] self.colorder=['ID','freq','name','buttons','PTY','AF','time','text','quality','pilot_strength','RT+']
self.workdir=workdir self.workdir=workdir
self.PI_dict={}#contains PI:numpackets (string:integer) self.PI_dict={}#contains PI:numpackets (string:integer)
self.tmc_messages=tmc_dict() self.tmc_messages=tmc_dict()
@ -261,9 +261,10 @@ class rds_parser_table_qt(gr.sync_block):#START
self.RDS_data[PI]["wrong_block_ratio"]=wrong_block_ratio self.RDS_data[PI]["wrong_block_ratio"]=wrong_block_ratio
self.signals.DataUpdateEvent.emit({'PI':PI,'wrong_block_ratio':wrong_block_ratio,'dots':dots}) self.signals.DataUpdateEvent.emit({'PI':PI,'wrong_block_ratio':wrong_block_ratio,'dots':dots})
elif pmt.to_long(pmt.car(msg))==3L: #carrier quality message elif pmt.to_long(pmt.car(msg))==3L: #carrier quality message
data=pmt.to_python(pmt.cdr(msg)) pilot_strength=pmt.to_long(pmt.cdr(msg))
if self.debug: PI=self.decoders[port]['PI']
print(data) if self.RDS_data.has_key(PI):
self.signals.DataUpdateEvent.emit({'PI':PI,'pilot_strength':pilot_strength})
else: #elif pmt.to_long(pmt.car(msg))==0L else: #elif pmt.to_long(pmt.car(msg))==0L
array=pmt.to_python(msg)[1] array=pmt.to_python(msg)[1]
@ -1056,11 +1057,12 @@ class rds_parser_table_qt_Widget(QtGui.QWidget):
self.table=QtGui.QTableWidget(self) self.table=QtGui.QTableWidget(self)
rowcount=0 rowcount=0
self.table.setRowCount(rowcount) self.table.setRowCount(rowcount)
self.table.setColumnCount(10)
self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) #disallow editing
#self.colorder=['ID','freq','name','buttons','PTY','AF','time','text','quality'] #self.colorder=['ID','freq','name','buttons','PTY','AF','time','text','quality']
self.colorder=tableobj.colorder self.colorder=tableobj.colorder
self.table.setColumnCount(len(self.colorder))
self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) #disallow editing
##button.clicked.connect(self.getDetails) ##button.clicked.connect(self.getDetails)
layout.addWidget(self.table) layout.addWidget(self.table)
@ -1149,7 +1151,10 @@ class rds_parser_table_qt_Widget(QtGui.QWidget):
row=self.PI_to_row[PI] row=self.PI_to_row[PI]
PIcol=self.colorder.index('ID') PIcol=self.colorder.index('ID')
self.table.cellWidget(row,PIcol).setText(PI) self.table.cellWidget(row,PIcol).setText(PI)
if event.has_key('pilot_strength'):
col=self.colorder.index('pilot_strength')
item=self.table.cellWidget(row,col)
item.setText("%i dB"%event['pilot_strength'])
if event.has_key('freq'): if event.has_key('freq'):
freqcol=self.colorder.index('freq') freqcol=self.colorder.index('freq')
item=self.table.cellWidget(row,freqcol) item=self.table.cellWidget(row,freqcol)

Loading…
Cancel
Save