diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt
index 59e19f5..cfde701 100644
--- a/grc/CMakeLists.txt
+++ b/grc/CMakeLists.txt
@@ -30,5 +30,6 @@ install(FILES
crfa_diff_add_sync_decim.xml
crfa_sync_decim.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
)
diff --git a/grc/crfa_qtgui_range.xml b/grc/crfa_qtgui_range.xml
index 42691dd..d9cb2f3 100644
--- a/grc/crfa_qtgui_range.xml
+++ b/grc/crfa_qtgui_range.xml
@@ -15,10 +15,12 @@
$(range) = qtgui_range($start, $stop, $step, $value, $min_len)
$(win) = RangeWidget($range, self.set_$(id), $label, "$widget", $rangeType)
$(gui_hint()($win))
- self.freq2_range.set_test($value);
- self.set_$(id)($value)
-
+
+
+
+
+
Labellabel
@@ -116,7 +118,11 @@ $(gui_hint()($win))
$start <= $value <= $stop$start < $stop
-
+
This block creates a variable with a slider. \
Leave the label blank to use the variable id as the label. \
diff --git a/grc/crfa_rds_parser_table_qt.xml b/grc/crfa_rds_parser_table_qt.xml
index c0e45b6..8f0d1c7 100644
--- a/grc/crfa_rds_parser_table_qt.xml
+++ b/grc/crfa_rds_parser_table_qt.xml
@@ -136,8 +136,14 @@ check if pty list file exists
1
- show RDS data from multiple stations in QT table
- input: raw group data (array of ints)
- 4x2 raw block data, 4x1 checksums, 1x1 number of valid blocks (of last 50)
+ show RDS data from multiple stations in QT table \
+ input: raw group data (array of ints) \
+ 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.
+
diff --git a/grc/crfa_variable_setter.xml b/grc/crfa_variable_setter.xml
new file mode 100644
index 0000000..008704a
--- /dev/null
+++ b/grc/crfa_variable_setter.xml
@@ -0,0 +1,59 @@
+
+
+ variable_setter
+ crfa_variable_setter
+ [crfa]
+ import crfa
+ #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)
+
+
+ varname
+ varname
+
+ raw
+
+
+ Pair Mode
+ is_pair
+ False
+ enum
+
+
+
+
+ Key
+ msgkey
+
+ string
+ #if $is_pair() == 'True' then 'none' else 'all'#
+
+
+
+ in
+ message
+
+
+
+
+ in pair mode this block only accepts PMT pairs that have a matching CAR
+ no pair mode: block accepts pmt symbols directly
+
+
+
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 6c8ac50..ba95f3d 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -41,7 +41,8 @@ GR_PYTHON_INSTALL(
stream_selector.py
vector_cutter.py
decoder_compare.py
- qtgui_range.py DESTINATION ${GR_PYTHON_DIR}/crfa
+ qtgui_range.py
+ variable_setter.py DESTINATION ${GR_PYTHON_DIR}/crfa
)
########################################################################
diff --git a/python/__init__.py b/python/__init__.py
index 7cb96be..a08616d 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -42,4 +42,5 @@ from stream_selector import stream_selector
from vector_cutter import vector_cutter
from decoder_compare import decoder_compare
from qtgui_range import qtgui_range
+from variable_setter import variable_setter
#
diff --git a/python/max_freq.py b/python/max_freq.py
index ce67e0d..bffa029 100644
--- a/python/max_freq.py
+++ b/python/max_freq.py
@@ -53,7 +53,6 @@ class max_freq(gr.sync_block):
return index
def index_to_freq(self,index):
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
return freq
diff --git a/python/qtgui_range.py b/python/qtgui_range.py
index 1a0bc1d..0399bba 100644
--- a/python/qtgui_range.py
+++ b/python/qtgui_range.py
@@ -22,13 +22,18 @@
#
from PyQt4 import Qt, QtCore, QtGui
+import pmt
+from gnuradio import gr
-
-class qtgui_range(object):
+class qtgui_range(gr.basic_block):
def set_test(self,value):
print("test callback invoked")
print(value)
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.max = float(maxv)
self.step = float(step)
@@ -36,7 +41,6 @@ class qtgui_range(object):
self.min_length = min_length
self.find_precision()
self.find_nsteps()
-
def find_precision(self):
# Get the decimal part of the step
temp = str(float(self.step) - int(self.step))[2:]
@@ -67,15 +71,22 @@ class qtgui_range(object):
class RangeWidget(QtGui.QWidget):
- def set_test(value):
- print("test callback invoked on widget")
- print(value)
+ def update_gui(self,value):
+ #print("update_gui called on widget %s"%self.label)
+ #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):
""" Creates the QT Range widget """
QtGui.QWidget.__init__(self)
-
+
self.range = ranges
self.style = style
+ self.label=label
# rangeType tells the block how to return the value as a standard
self.rangeType = rangeType
@@ -161,7 +172,6 @@ class RangeWidget(QtGui.QWidget):
def changed(self, value):
""" Handle the valueChanged signal and map the value into the correct range """
- print("gui changed")
val = self.range.map_range(value)
self.notifyChanged(self.rangeType(val))
diff --git a/python/rds_parser_table_qt.py b/python/rds_parser_table_qt.py
index 4e90299..31558b2 100644
--- a/python/rds_parser_table_qt.py
+++ b/python/rds_parser_table_qt.py
@@ -455,7 +455,7 @@ 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 ''%self.multi_str()+str(self.event.updateClass)+": "+self.getTime()+": "+self.events_string()+self.info_str()+"; "+self.psn.encode("utf-8")+""
+ return ''%self.getDate()+str(self.event.updateClass)+": "+self.getTime()+''%self.multi_str()+": "+self.events_string()+self.info_str()+"; "+self.psn.encode("utf-8")+""
def end_loc(self):
return self.location.get_extent_location(self.location,self.tmc_extent,self.tmc_dir)
def location_text(self):
@@ -503,6 +503,11 @@ class tmc_message:
#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"])
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
if self.hastime:
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]
self.RDS_data[PI]["ECC"]=extended_country_code
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:
TMC_info=SLC
elif variant==2:
@@ -1697,7 +1702,7 @@ class rds_parser_table_qt(gr.sync_block):#START
0b1100:u"ÁÀÉÈÍÌÓÒÚÙŘČŠŽĐĿ",
0b1101: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)
return_string=""
diff --git a/python/variable_setter.py b/python/variable_setter.py
new file mode 100644
index 0000000..9c3aeed
--- /dev/null
+++ b/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)
\ No newline at end of file