From 3593c7d4b631d3c3416811238a534166a115f0ba Mon Sep 17 00:00:00 2001 From: csrichter Date: Mon, 17 Apr 2017 20:24:33 +0200 Subject: [PATCH] added pilot strength display to table --- python/pilot_quality.py | 17 ++++++++++++++--- python/rds_parser_table_qt.py | 21 +++++++++++++-------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/python/pilot_quality.py b/python/pilot_quality.py index 5cdd87b..263711f 100644 --- a/python/pilot_quality.py +++ b/python/pilot_quality.py @@ -21,7 +21,7 @@ import numpy as np from gnuradio import gr -import pmt,code +import pmt,time class pilot_quality(gr.sync_block): @@ -35,11 +35,13 @@ class pilot_quality(gr.sync_block): out_sig=None) #self.carrier_width=1 self.debug=debug + self.msg_adr=msg_adr self.message_port_register_out(pmt.intern('out')) 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.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): in0 = input_items[0] # <+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]) #code.interact(local=locals()) 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: - print("strength: %f,carrier: %f, around:%f"%(strength,carrier,surrounding)) + print("mean:%i"%strength_mean) return len(input_items[0]) diff --git a/python/rds_parser_table_qt.py b/python/rds_parser_table_qt.py index 7e90c32..a469a86 100644 --- a/python/rds_parser_table_qt.py +++ b/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.decoder_synced={} #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.PI_dict={}#contains PI:numpackets (string:integer) 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.signals.DataUpdateEvent.emit({'PI':PI,'wrong_block_ratio':wrong_block_ratio,'dots':dots}) elif pmt.to_long(pmt.car(msg))==3L: #carrier quality message - data=pmt.to_python(pmt.cdr(msg)) - if self.debug: - print(data) + pilot_strength=pmt.to_long(pmt.cdr(msg)) + PI=self.decoders[port]['PI'] + 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 array=pmt.to_python(msg)[1] @@ -1056,11 +1057,12 @@ class rds_parser_table_qt_Widget(QtGui.QWidget): self.table=QtGui.QTableWidget(self) rowcount=0 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=tableobj.colorder + self.table.setColumnCount(len(self.colorder)) + self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) #disallow editing + + ##button.clicked.connect(self.getDetails) layout.addWidget(self.table) @@ -1149,7 +1151,10 @@ class rds_parser_table_qt_Widget(QtGui.QWidget): row=self.PI_to_row[PI] PIcol=self.colorder.index('ID') 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'): freqcol=self.colorder.index('freq') item=self.table.cellWidget(row,freqcol)