Browse Source

blocks:variable setter, flowgraphs:RDS-play (9x noskip),ausarbeitung: bilder, gliederung 2.0

master pre-refactor
Clemens Richter 9 years ago
parent
commit
af6319172f
  1. 3
      grc/CMakeLists.txt
  2. 12
      grc/crfa_qtgui_range.xml
  3. 12
      grc/crfa_rds_parser_table_qt.xml
  4. 59
      grc/crfa_variable_setter.xml
  5. 3
      python/CMakeLists.txt
  6. 1
      python/__init__.py
  7. 1
      python/max_freq.py
  8. 24
      python/qtgui_range.py
  9. 11
      python/rds_parser_table_qt.py
  10. 58
      python/variable_setter.py

3
grc/CMakeLists.txt

@ -30,5 +30,6 @@ install(FILES
crfa_diff_add_sync_decim.xml crfa_diff_add_sync_decim.xml
crfa_sync_decim.xml crfa_sync_decim.xml
crfa_rds_decoder_redsea.xml crfa_rds_decoder_redsea.xml
crfa_qtgui_range.xml DESTINATION share/gnuradio/grc/blocks crfa_qtgui_range.xml
crfa_variable_setter.xml DESTINATION share/gnuradio/grc/blocks
) )

12
grc/crfa_qtgui_range.xml

@ -15,9 +15,11 @@
$(range) = qtgui_range($start, $stop, $step, $value, $min_len) $(range) = qtgui_range($start, $stop, $step, $value, $min_len)
$(win) = RangeWidget($range, self.set_$(id), $label, "$widget", $rangeType) $(win) = RangeWidget($range, self.set_$(id), $label, "$widget", $rangeType)
$(gui_hint()($win))</make> $(gui_hint()($win))</make>
<callback>self.freq2_range.set_test($value);</callback> <!--<callback>self.freq2_range.set_test($value);</callback>-->
<callback>self.set_$(id)($value)</callback> <!-- <callback>self.set_$(id)($value)</callback> -->
<!-- <callback>set_test($(id));</callback> -->
<!-- <callback>self._$(id)_win.set_test($(id));</callback>-->
<param> <param>
<name>Label</name> <name>Label</name>
@ -116,7 +118,11 @@ $(gui_hint()($win))</make>
<check>$start &lt;= $value &lt;= $stop</check> <check>$start &lt;= $value &lt;= $stop</check>
<check>$start &lt; $stop</check> <check>$start &lt; $stop</check>
<!-- <sink>
<name>set</name>
<type>message</type>
<optional>1</optional>
</sink>-->
<doc> <doc>
This block creates a variable with a slider. \ This block creates a variable with a slider. \
Leave the label blank to use the variable id as the label. \ Leave the label blank to use the variable id as the label. \

12
grc/crfa_rds_parser_table_qt.xml

@ -136,8 +136,14 @@ check if pty list file exists
<optional>1</optional> <optional>1</optional>
</source> </source>
<doc>show RDS data from multiple stations in QT table <doc>show RDS data from multiple stations in QT table \
input: raw group data (array of ints) input: raw group data (array of ints) \
4x2 raw block data, 4x1 checksums, 1x1 number of valid blocks (of last 50)</doc> 4x2 raw block data, 4x1 offset chars, 1x1 number of valid blocks (of last 50) \
[block1_upper,block1_lower,block2_upper,block2_lower,...,offset1,offset2,offset3,offset4,numerrors]\\
The GUI hint can be used to position the widget within the application. \
The hint is of the form "tab_id@tab_index: row, col, row_span, col_span" \
Both the tab specification and the grid position are optional.
</doc>
</block> </block>

59
grc/crfa_variable_setter.xml

@ -0,0 +1,59 @@
<?xml version="1.0"?>
<block>
<name>variable_setter</name>
<key>crfa_variable_setter</key>
<category>[crfa]</category>
<import>import crfa</import>
<make>#set $block = 'self.%s'%$id
#set $varsetter = 'self.set_%s'%$varname
#set $guiupdater = 'self._%s_win.update_gui'%$varname
crfa.variable_setter("$varname",$varsetter,$guiupdater,$is_pair,$msgkey)</make>
<!--$(block) = crfa.variable_setter($varname,$varsetter) -->
<param>
<name>varname</name>
<key>varname</key>
<value></value>
<type>raw</type>
</param>
<param>
<name>Pair Mode</name>
<key>is_pair</key>
<value>False</value>
<type>enum</type>
<option>
<name>False</name>
<key>False</key>
</option>
<option>
<name>True</name>
<key>True</key>
</option>
</param>
<param>
<name>Key</name>
<key>msgkey</key>
<value></value>
<type>string</type>
<hide>#if $is_pair() == 'True' then 'none' else 'all'#</hide>
</param>
<!-- Make one 'sink' node per input. Sub-nodes:
* name (an identifier for the GUI)
* type
* vlen
* optional (set to 1 for optional inputs) -->
<sink>
<name>in</name>
<type>message</type>
</sink>
<!-- Make one 'source' node per output. Sub-nodes:
* name (an identifier for the GUI)
* type
* vlen
* optional (set to 1 for optional inputs) -->
<doc>
in pair mode this block only accepts PMT pairs that have a matching CAR
no pair mode: block accepts pmt symbols directly
</doc>
</block>

3
python/CMakeLists.txt

@ -41,7 +41,8 @@ GR_PYTHON_INSTALL(
stream_selector.py stream_selector.py
vector_cutter.py vector_cutter.py
decoder_compare.py decoder_compare.py
qtgui_range.py DESTINATION ${GR_PYTHON_DIR}/crfa qtgui_range.py
variable_setter.py DESTINATION ${GR_PYTHON_DIR}/crfa
) )
######################################################################## ########################################################################

1
python/__init__.py

@ -42,4 +42,5 @@ from stream_selector import stream_selector
from vector_cutter import vector_cutter from vector_cutter import vector_cutter
from decoder_compare import decoder_compare from decoder_compare import decoder_compare
from qtgui_range import qtgui_range from qtgui_range import qtgui_range
from variable_setter import variable_setter
# #

1
python/max_freq.py

@ -53,7 +53,6 @@ class max_freq(gr.sync_block):
return index return index
def index_to_freq(self,index): def index_to_freq(self,index):
startfreq=self.center_freq-self.samp_rate/2 startfreq=self.center_freq-self.samp_rate/2
index=(freq-startfreq)*self.fft_len/self.samp_rate
freq=index*self.samp_rate/self.fft_len+startfreq freq=index*self.samp_rate/self.fft_len+startfreq
return freq return freq

24
python/qtgui_range.py

@ -22,13 +22,18 @@
# #
from PyQt4 import Qt, QtCore, QtGui from PyQt4 import Qt, QtCore, QtGui
import pmt
from gnuradio import gr
class qtgui_range(gr.basic_block):
class qtgui_range(object):
def set_test(self,value): def set_test(self,value):
print("test callback invoked") print("test callback invoked")
print(value) print(value)
def __init__(self, minv, maxv, step, default, min_length): def __init__(self, minv, maxv, step, default, min_length):
gr.basic_block.__init__(self,
name="qtgui_range",
in_sig=None,
out_sig=None)
self.min = float(minv) self.min = float(minv)
self.max = float(maxv) self.max = float(maxv)
self.step = float(step) self.step = float(step)
@ -36,7 +41,6 @@ class qtgui_range(object):
self.min_length = min_length self.min_length = min_length
self.find_precision() self.find_precision()
self.find_nsteps() self.find_nsteps()
def find_precision(self): def find_precision(self):
# Get the decimal part of the step # Get the decimal part of the step
temp = str(float(self.step) - int(self.step))[2:] temp = str(float(self.step) - int(self.step))[2:]
@ -67,15 +71,22 @@ class qtgui_range(object):
class RangeWidget(QtGui.QWidget): class RangeWidget(QtGui.QWidget):
def set_test(value): def update_gui(self,value):
print("test callback invoked on widget") #print("update_gui called on widget %s"%self.label)
print(value) #print(value)
#self.d_widget.slider.setValue(value)
if self.style=="counter_slider":
self.d_widget.counter.setValue(value)
else:
self.d_widget.setValue(value)
#self.notifyChanged(self.rangeType(value))
def __init__(self, ranges, slot, label, style, rangeType=float): def __init__(self, ranges, slot, label, style, rangeType=float):
""" Creates the QT Range widget """ """ Creates the QT Range widget """
QtGui.QWidget.__init__(self) QtGui.QWidget.__init__(self)
self.range = ranges self.range = ranges
self.style = style self.style = style
self.label=label
# rangeType tells the block how to return the value as a standard # rangeType tells the block how to return the value as a standard
self.rangeType = rangeType self.rangeType = rangeType
@ -161,7 +172,6 @@ class RangeWidget(QtGui.QWidget):
def changed(self, value): def changed(self, value):
""" Handle the valueChanged signal and map the value into the correct range """ """ Handle the valueChanged signal and map the value into the correct range """
print("gui changed")
val = self.range.map_range(value) val = self.range.map_range(value)
self.notifyChanged(self.rangeType(val)) self.notifyChanged(self.rangeType(val))

11
python/rds_parser_table_qt.py

@ -455,7 +455,7 @@ 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.multi_str()+str(self.event.updateClass)+": "+self.getTime()+": "+self.events_string()+self.info_str()+"; "+self.psn.encode("utf-8")+"</span>" 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.encode("utf-8")+"</span>"
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):
@ -503,6 +503,11 @@ class tmc_message:
#event_name=self.ecl_dict[self.tmc_event][1] #event_name=self.ecl_dict[self.tmc_event][1]
#message_string="TMC-message,event:%s location:%i,reflocs:%s, station:%s"%(event_name,self.tmc_location,self.ref_locs(self.tmc_location,""),self.RDS_data[PI]["PSN"]) #message_string="TMC-message,event:%s location:%i,reflocs:%s, station:%s"%(event_name,self.tmc_location,self.ref_locs(self.tmc_location,""),self.RDS_data[PI]["PSN"])
return "single:%i,complete:%i,event:%i location:%s"%(self.is_single,self.is_complete,self.event.ecn,self.location) return "single:%i,complete:%i,event:%i location:%s"%(self.is_single,self.is_complete,self.event.ecn,self.location)
def getDate(self):
if self.hastime:
return self.datetime_received.strftime("%Y-%m-%d")
else:
return "no valid date"
def getTime(self):#always returns string def getTime(self):#always returns string
if self.hastime: if self.hastime:
return self.datetime_received.strftime("%H:%M") return self.datetime_received.strftime("%H:%M")
@ -1168,7 +1173,7 @@ class rds_parser_table_qt(gr.sync_block):#START
extended_country_code=array[5] extended_country_code=array[5]
self.RDS_data[PI]["ECC"]=extended_country_code self.RDS_data[PI]["ECC"]=extended_country_code
if self.debug: if self.debug:
print("PI:%s PSN:%s,ECC:%s"%(PI,self.RDS_data[PI]["PSN"],hex(extended_country_code))) print("1A variant 0: PI:%s PSN:%s,ECC:%s"%(PI,self.RDS_data[PI]["PSN"],hex(extended_country_code)))
elif variant==1: elif variant==1:
TMC_info=SLC TMC_info=SLC
elif variant==2: elif variant==2:
@ -1697,7 +1702,7 @@ class rds_parser_table_qt(gr.sync_block):#START
0b1100:u"ÁÀÉÈÍÌÓÒÚÙŘČŠŽĐĿ", 0b1100:u"ÁÀÉÈÍÌÓÒÚÙŘČŠŽĐĿ",
0b1101:u"ÂÄÊËÎÏÔÖÛÜřčšžđŀ", 0b1101:u"ÂÄÊËÎÏÔÖÛÜřčšžđŀ",
0b1110:u"ÃÅÆŒŷÝÕØÞŊŔĆŚŹŦð", 0b1110:u"ÃÅÆŒŷÝÕØÞŊŔĆŚŹŦð",
0b1111:u"ãåæœŵýõøþŋŕćśźŧ"}#0xff should not occur (not in standard) 0b1111:u"ãåæœŵýõøþŋŕćśźŧ "}#0xff should not occur (not in standard) (but occured 2017-03-04-9:18 , probably transmission error)
#charlist=list(charstring) #charlist=list(charstring)
return_string="" return_string=""

58
python/variable_setter.py

@ -0,0 +1,58 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2017 <+YOU OR YOUR COMPANY+>.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
import numpy
from gnuradio import gr
import pmt
class variable_setter(gr.sync_block):
"""
docstring for block variable_setter
"""
def __init__(self, varname,varsetter,guiupdater,is_pair,key):
gr.sync_block.__init__(self,
name="variable_setter",
in_sig=None,
out_sig=None)
self.varname=varname
self.setvar=varsetter
self.updateGui=guiupdater
self.is_pair=is_pair
self.key=int(key)
self.message_port_register_in(pmt.intern('in'))
self.set_msg_handler(pmt.intern('in'), self.handle_msg)
def handle_msg(self,msg):
#if self.is_pair:
#msgkey=pmt.to_python(pmt.car(msg))
#data=pmt.to_python(pmt.cdr(msg))
#print("key:%s, data: %s"%(msgkey,data))
#else:
#msgkey=self.key#accept all messages in non-pair mode
#data= pmt.to_python(msg)
m = pmt.symbol_to_string(msg)
msgkey=int(m.split()[0])
data=float(m.split()[1])
#print("key:%s, data: %s"%(msgkey,data))
if self.key==msgkey:
#print(data)
self.setvar(data)
self.updateGui(data)
#print("calling setter on %s"%self.varname)
Loading…
Cancel
Save