[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5802 - in grc/branches/jblum_work: examples notes src
From: |
jblum |
Subject: |
[Commit-gnuradio] r5802 - in grc/branches/jblum_work: examples notes src src/Elements src/Graphics src/SignalBlockDefs |
Date: |
Tue, 19 Jun 2007 23:02:38 -0600 (MDT) |
Author: jblum
Date: 2007-06-19 23:02:37 -0600 (Tue, 19 Jun 2007)
New Revision: 5802
Modified:
grc/branches/jblum_work/examples/valve.grc.xml
grc/branches/jblum_work/notes/notes.txt
grc/branches/jblum_work/src/Constants.py
grc/branches/jblum_work/src/DataTypes.py
grc/branches/jblum_work/src/Elements/GraphicalParam.py
grc/branches/jblum_work/src/Elements/Param.py
grc/branches/jblum_work/src/Graphics/Dialogs.py
grc/branches/jblum_work/src/Graphics/SignalBlockParamsDialog.py
grc/branches/jblum_work/src/Graphics/USRPDiagnostics.py
grc/branches/jblum_work/src/SignalBlockDefs/Conversions.py
grc/branches/jblum_work/src/SignalBlockDefs/Misc.py
grc/branches/jblum_work/src/SignalBlockDefs/Operators.py
grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockConstants.py
grc/branches/jblum_work/src/SignalBlockDefs/USRP.py
Log:
external callbacks for graphica params, fixed bug in nlog10 block, fixed open
usage in valve
Modified: grc/branches/jblum_work/examples/valve.grc.xml
===================================================================
--- grc/branches/jblum_work/examples/valve.grc.xml 2007-06-20 01:45:21 UTC
(rev 5801)
+++ grc/branches/jblum_work/examples/valve.grc.xml 2007-06-20 05:02:37 UTC
(rev 5802)
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<flow_graph>
- <timestamp>1182223556.24</timestamp>
+ <timestamp>1182271498.47</timestamp>
<hostname>tiggle</hostname>
<version>0.70 alpha</version>
<valid>True</valid>
@@ -37,7 +37,7 @@
</var>
<var>
<key>open</key>
- <value>0</value>
+ <value>1</value>
<min>0</min>
<max>1</max>
<step>1</step>
@@ -86,16 +86,6 @@
</params>
</signal_block>
<signal_block>
- <tag>Note</tag>
- <id>Note0</id>
- <x_coordinate>255</x_coordinate>
- <y_coordinate>42</y_coordinate>
- <rotation>0</rotation>
- <params>
- <param>The valve is open and the data flow is stopped when open is
1.</param>
- </params>
- </signal_block>
- <signal_block>
<tag>Valve</tag>
<id>Valve0</id>
<x_coordinate>270</x_coordinate>
@@ -108,6 +98,16 @@
<param>1</param>
</params>
</signal_block>
+ <signal_block>
+ <tag>Note</tag>
+ <id>Note0</id>
+ <x_coordinate>255</x_coordinate>
+ <y_coordinate>42</y_coordinate>
+ <rotation>0</rotation>
+ <params>
+ <param>The valve is open and the data flow is allowed when open is
1.</param>
+ </params>
+ </signal_block>
</signal_blocks>
<connections>
<connection>
Modified: grc/branches/jblum_work/notes/notes.txt
===================================================================
--- grc/branches/jblum_work/notes/notes.txt 2007-06-20 01:45:21 UTC (rev
5801)
+++ grc/branches/jblum_work/notes/notes.txt 2007-06-20 05:02:37 UTC (rev
5802)
@@ -4,7 +4,6 @@
-usrp dual and quad souce
-blks blocks, add filesave for logging
-combine add/mult with add/mult vector
--selector blocks
############ Known Problems: ####################
-in vars window, stop_editing doesnt work
@@ -13,7 +12,6 @@
-socket controllers should be intelligent on shrinkage
-the nested data variables should indicate that they are nested data ->
variable_data
-rearanging variables doesnt have a handler
--changing an enum doesnt call update for params with variable datatypes
############ Features to Add: ####################
-save settings after close (working directory)
Modified: grc/branches/jblum_work/src/Constants.py
===================================================================
--- grc/branches/jblum_work/src/Constants.py 2007-06-20 01:45:21 UTC (rev
5801)
+++ grc/branches/jblum_work/src/Constants.py 2007-06-20 05:02:37 UTC (rev
5802)
@@ -146,9 +146,6 @@
##When the window has to be scrolled, move it this distance in the required
direction.
SCROLL_DISTANCE = 15
-##Do not draw more than this many sockets on one side of a signal block.
-MAX_NUM_SOCKETS = 20
-
##The redrawing sensitivity, how many motion detection events must occur
before a redraw?
MOTION_DETECT_REDRAWING_SENSITIVITY = 3
address@hidden
Modified: grc/branches/jblum_work/src/DataTypes.py
===================================================================
--- grc/branches/jblum_work/src/DataTypes.py 2007-06-20 01:45:21 UTC (rev
5801)
+++ grc/branches/jblum_work/src/DataTypes.py 2007-06-20 05:02:37 UTC (rev
5802)
@@ -283,7 +283,7 @@
DataType.__init__(self, data, min, max)
self.enum_data_type = enum_data_type
self.index = index
- def parse_enum_data_type(self):
+ def _parse_enum_data_type(self):
"""!
Parse the selected data type.
If there is an index, get the data type from a tuple instead.
@@ -296,25 +296,25 @@
Get the type from the enumerated data type.
@return the type
"""
- return self.parse_enum_data_type().get_type()
+ return self._parse_enum_data_type().get_type()
def get_base_type(self):
"""!
Get the base type from the enumerated data type.
@return the base type
"""
- return self.parse_enum_data_type().get_base_type()
+ return self._parse_enum_data_type().get_base_type()
def get_num_bytes(self):
"""!
Get the number of bytes from the enumerated data type.
@return the number of bytes.
"""
- return self.parse_enum_data_type().get_num_bytes()
+ return self._parse_enum_data_type().get_num_bytes()
def parse(self):
"""!
Use the parser from the enumerated data type.
@return the parsed data
"""
- data_type = self.parse_enum_data_type()
+ data_type = self._parse_enum_data_type()
data_type.set_data(self.get_data())
return data_type.parse()
Modified: grc/branches/jblum_work/src/Elements/GraphicalParam.py
===================================================================
--- grc/branches/jblum_work/src/Elements/GraphicalParam.py 2007-06-20
01:45:21 UTC (rev 5801)
+++ grc/branches/jblum_work/src/Elements/GraphicalParam.py 2007-06-20
05:02:37 UTC (rev 5802)
@@ -36,11 +36,11 @@
class InputParam(gtk.HBox):
""" The base class for an input parameter inside the input parameters
dialog. """
- def __init__(self, data_type, handle_changed):
+ def __init__(self, data_type, _handle_changed):
gtk.HBox.__init__(self)
self.show()
self.data_type = data_type
- self.handle_changed = handle_changed
+ self._handle_changed = _handle_changed
self.label = gtk.Label('') #no label, markup is added by
set_markup
self.label.set_size_request(140,-1)
self.label.show()
@@ -55,7 +55,7 @@
self.entry = input = gtk.Entry()
input.set_size_request(250,-1)
input.set_text(self.data_type.get_data())
- input.connect("changed", self.handle_changed)
+ input.connect("changed", self._handle_changed)
input.show()
self.pack_start(input, False)
self.get_text = input.get_text
@@ -93,7 +93,7 @@
if gtk.RESPONSE_OK == file_dialog.run(): #run the dialog
file_path = file_dialog.get_filename() #get the file
path
self.entry.set_text(file_path)
- self.handle_changed()
+ self._handle_changed()
file_dialog.destroy() #destroy the dialog
class EnumParam(InputParam):
@@ -107,7 +107,7 @@
for cname in self.data_type.get_cnames_list():
input.append_text(cname)
input.set_active(int(self.data_type.get_data()))
input.show()
- input.connect("changed", self.handle_changed)
+ input.connect("changed", self._handle_changed)
self.pack_start(input, False)
self.get_text = lambda: str(input.get_active()) #the get text
parses the selected index to a string
@@ -116,27 +116,36 @@
######################################################################################################
class GraphicalParam(Param.Param):
- """The graphical parameter."""
- def get_input_object(self):
+ """The graphical parameter."""
+
+ def update(self):
+ """Called when an external change occurs.
+ Update the graphical input by calling the change handler."""
+ if self.input: self._handle_changed()
+
+ def get_input_object(self, callback=None):
"""!
Get the graphical gtk class to represent this parameter.
Create the input object with this data type and the handle
changed method.
+ @param callback a function of one argument(this param) to be
called from the change handler
@return gtk input object
"""
+ self.callback=callback
if self.get_data_type().get_base_type() ==
Enum().get_base_type(): input = EnumParam
elif self.get_data_type().get_base_type() ==
File().get_base_type(): input = FileParam
else: input = EntryParam
- self.input = input(self.get_data_type(), self.handle_changed)
- self.handle_changed()
+ self.input = input(self.get_data_type(), self._handle_changed)
+ self._handle_changed()
return self.input
- def handle_changed(self, widget=None):
- """When the input changes, write the inputs to the data type."""
+ def _handle_changed(self, widget=None):
+ """When the input changes, write the inputs to the data type.
+ Finish by calling the exteral callback."""
data_type = self.get_data_type()
new_data = self.input.get_text()
old_data = data_type.get_data()
if old_data != new_data: data_type.set_data(new_data)
- # Set the markup on the label, red for errors in
cooresponding data type. #
+ # Set the markup on the label, red for errors in
corresponding data type. #
cname = self.get_cname()
if not data_type.is_valid():
self.input.set_markup('<span
foreground="red"><b>'+cname+'</b></span>')
@@ -144,6 +153,8 @@
else:
self.input.set_markup(cname)
if self.input.tp:
self.input.tp.set_tip(self.input.entry, str(data_type.parse()))
+ # execute the external callback #
+ if self.callback: self.callback(self)
def get_markup(self):
"""!
Modified: grc/branches/jblum_work/src/Elements/Param.py
===================================================================
--- grc/branches/jblum_work/src/Elements/Param.py 2007-06-20 01:45:21 UTC
(rev 5801)
+++ grc/branches/jblum_work/src/Elements/Param.py 2007-06-20 05:02:37 UTC
(rev 5802)
@@ -30,7 +30,8 @@
"""
self.cname = cname
self.data_type = data_type
- self.input = None
+ ##the graphical input object
+ self.input = None
def get_cname(self):
"""!
Modified: grc/branches/jblum_work/src/Graphics/Dialogs.py
===================================================================
--- grc/branches/jblum_work/src/Graphics/Dialogs.py 2007-06-20 01:45:21 UTC
(rev 5801)
+++ grc/branches/jblum_work/src/Graphics/Dialogs.py 2007-06-20 05:02:37 UTC
(rev 5802)
@@ -267,28 +267,24 @@
label.show()
self.vbox.pack_start(label, False)
self.set_size_request(800, 600)
- # create the entry box and connect it to a new handler #
- self.param = GraphicalParam('Expression', RawExpr(''))
- self.input_obj = self.param.get_input_object()
- self.input_obj.entry.connect("changed", self._handle_changed)
- self.vbox.pack_start(self.input_obj, False)
# create a text box for parser output #
self.text_box = TextDisplay()
self.text_box.set_text('')
+ # create the entry box and give it the change handler #
+ self.param = GraphicalParam('Expression', RawExpr(''))
+ self.input_obj =
self.param.get_input_object(self._handle_changed)
+ self.vbox.pack_start(self.input_obj, False)
# add the scrolled window for the text box #
scrolled_window = gtk.ScrolledWindow()
scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
scrolled_window.add_with_viewport(self.text_box)
scrolled_window.show()
self.vbox.pack_start(scrolled_window, True)
- self._handle_changed() #initial display
self.run()
self.destroy()
- def _handle_changed(self, widget=None):
- """Handle changed in the param's entry box.
- Call the default change handler and then update the text box."""
- self.param.handle_changed()
+ def _handle_changed(self, param=None):
+ """Handle changed in the param's entry box by updating the text
box."""
if self.param.get_data_type().is_valid():
text = str(self.param.get_data_type().parse())
else: text = self.param.get_data_type().msg
Modified: grc/branches/jblum_work/src/Graphics/SignalBlockParamsDialog.py
===================================================================
--- grc/branches/jblum_work/src/Graphics/SignalBlockParamsDialog.py
2007-06-20 01:45:21 UTC (rev 5801)
+++ grc/branches/jblum_work/src/Graphics/SignalBlockParamsDialog.py
2007-06-20 05:02:37 UTC (rev 5802)
@@ -54,7 +54,7 @@
# Add all the parameters #
for param in self.signal_block.get_params():
self.original_data.append(param.get_data_type().get_data())
- vbox.pack_start(param.get_input_object(), False)
+
vbox.pack_start(param.get_input_object(self._handle_changed), False)
# Done adding parameters #
if self.signal_block.get_docs():
# Create the title label #
@@ -64,6 +64,17 @@
vbox.pack_start(label, False)
# Create the text box to display notes about the
block #
vbox.pack_start(TextDisplay(self.signal_block.get_docs()), False)
+
+ def _handle_changed(self, param):
+ """!
+ A change occured, update any dependent parameters:
+ The enum inside the variable type may have changed and,
+ the variable param will need an external update.
+ @param param the graphical parameter that initiated the
callback
+ """
+ for p in self.signal_block.get_params():
+ if hasattr(p.get_data_type(), 'enum_data_type') and \
+ param.get_data_type() ==
getattr(p.get_data_type(), 'enum_data_type'): p.update()
def run(self):
"""!
Modified: grc/branches/jblum_work/src/Graphics/USRPDiagnostics.py
===================================================================
--- grc/branches/jblum_work/src/Graphics/USRPDiagnostics.py 2007-06-20
01:45:21 UTC (rev 5801)
+++ grc/branches/jblum_work/src/Graphics/USRPDiagnostics.py 2007-06-20
05:02:37 UTC (rev 5802)
@@ -46,10 +46,12 @@
self.set_title('USRP Diagnostics')
self.USRP_number = Int(0, min=0)
self.USRP_type = Enum([('Receive', 'rx'), ('Transmit', 'tx'),])
- self.USRP_subdev = Enum([('Side A:0', (0, 0)),
-
('Side B:0', (1, 0)),
-
('Side A:1', (0, 1)),
-
('Side B:1', (1, 1)),])
+ self.USRP_subdev = Enum([
+ ('Side A:0', (0, 0)),
+ ('Side B:0', (1, 0)),
+ ('Side A:1', (0, 1)),
+ ('Side B:1', (1, 1)),
+ ])
self.vbox.pack_start(GraphicalParam('Unit Number',
self.USRP_number).get_input_object(), False)
self.vbox.pack_start(GraphicalParam('Transmit/Receive',
self.USRP_type).get_input_object(), False)
self.vbox.pack_start(GraphicalParam('Side:Subdevice',
self.USRP_subdev).get_input_object(), False)
Modified: grc/branches/jblum_work/src/SignalBlockDefs/Conversions.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Conversions.py 2007-06-20
01:45:21 UTC (rev 5801)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Conversions.py 2007-06-20
05:02:37 UTC (rev 5802)
@@ -22,8 +22,7 @@
from DataTypes import *
from gnuradio import gr
-from SignalBlockConstants import
all_choices,all_vector_choices,default_samp_rate
-from Constants import MAX_NUM_SOCKETS
+from SignalBlockConstants import
all_choices,all_vector_choices,default_samp_rate,MAX_NUM_SOCKETS
def ComplexComponents(sb):
vlen = Int(1, min=1)
Modified: grc/branches/jblum_work/src/SignalBlockDefs/Misc.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Misc.py 2007-06-20 01:45:21 UTC
(rev 5801)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Misc.py 2007-06-20 05:02:37 UTC
(rev 5802)
@@ -24,7 +24,6 @@
from DataTypes import *
from gnuradio import gr,blks
from SignalBlockConstants import
default_samp_rate,all_choices,DEFAULT_QUEUE_LIMIT,ThrottleHelper
-from Constants import MAX_NUM_SOCKETS
def Throttle(sb):
fcn = gr.throttle
@@ -106,8 +105,8 @@
"""In an endless while loop: read the msgq_out and write to the
msgq_in when closed."""
while True:
msg = self.valve_helper.msgq_out.delete_head()
#blocking read of message queue
- if self.valve_helper.open: del msg #delete the
message
- else: self.valve_helper.msgq_in.insert_tail(msg)
#forward message
+ if self.valve_helper.open:
self.valve_helper.msgq_in.insert_tail(msg) #forward message
+ else: del msg #delete the message
class ValveHelper(gr.hier_block):
"""A hier block used to intercept data from a message sink,
@@ -144,10 +143,10 @@
sb.add_output_socket('out', Variable(type), vlen=vlen)
sb.add_param('Type', type, False, type=True)
sb.add_param('Sampling Rate', Float(default_samp_rate))
- sb.add_param('Open', Int(0))
+ sb.add_param('Open', Int(1))
sb.add_param('Vector Length', vlen)
sb.set_docs('''\
-When open is 1, the valve will not forward data.
+When open is 1, the valve will forward data.
The valve has a throttle automatically attatched to it at runtime to save the
CPU.
''')
def make(fg, type, samp_rate, open, vlen):
Modified: grc/branches/jblum_work/src/SignalBlockDefs/Operators.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Operators.py 2007-06-20
01:45:21 UTC (rev 5801)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Operators.py 2007-06-20
05:02:37 UTC (rev 5802)
@@ -22,7 +22,7 @@
from DataTypes import *
from gnuradio import gr
-from Constants import *
+from SignalBlockConstants import MAX_NUM_SOCKETS
variable_inputs_doc_string = '''2 <= Num Inputs <= %d.'''%MAX_NUM_SOCKETS
@@ -64,7 +64,7 @@
sb.add_param('Constant', Variable(type, 1, index=1))
def make(fg, type, constant):
block = type.parse()[0](constant.parse())
- if fg != None: fg.add_callback(block.set_k, constant)
+ fg.add_callback(block.set_k, constant)
return block
return sb, make
@@ -79,7 +79,7 @@
sb.add_param('Constant', Variable(type, 1, index=1))
def make(fg, type, constant):
block = type.parse()[0](constant.parse())
- if fg != None: fg.add_callback(block.set_k, constant)
+ fg.add_callback(block.set_k, constant)
return block
return sb, make
@@ -121,7 +121,7 @@
sb.add_param('Constant', Variable(type, 1, index=1))
def make(fg, type, constant):
block = type.parse()[0](constant.parse())
- if fg != None: fg.add_callback(block.set_k, constant)
+ fg.add_callback(block.set_k, constant)
return block
return sb, make
@@ -136,7 +136,7 @@
sb.add_param('Constant', Variable(type, 1, index=1))
def make(fg, type, constant):
block = type.parse()[0](constant.parse())
- if fg != None: fg.add_callback(block.set_k, constant)
+ fg.add_callback(block.set_k, constant)
return block
return sb, make
@@ -176,5 +176,5 @@
sb.add_param('k', Float(0))
sb.add_param('Vector Length', vlen)
sb.set_docs('''output = n*log10(input) + k''')
- return sb, lambda fg, n, k, vlen: gr.nlog10_ff(n.parse(), vlen,
k.parse())
+ return sb, lambda fg, n, k, vlen: gr.nlog10_ff(n.parse(), vlen.parse(),
k.parse())
\ No newline at end of file
Modified: grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockConstants.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockConstants.py
2007-06-20 01:45:21 UTC (rev 5801)
+++ grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockConstants.py
2007-06-20 05:02:37 UTC (rev 5802)
@@ -44,6 +44,9 @@
fg.connect(block, throttle)
gr.hier_block.__init__(self, fg, input, output)
+##max number of sockets to draw on one side of a signal block.
+MAX_NUM_SOCKETS = 20
+
##default message queue limit
DEFAULT_QUEUE_LIMIT = 1
Modified: grc/branches/jblum_work/src/SignalBlockDefs/USRP.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/USRP.py 2007-06-20 01:45:21 UTC
(rev 5801)
+++ grc/branches/jblum_work/src/SignalBlockDefs/USRP.py 2007-06-20 05:02:37 UTC
(rev 5802)
@@ -24,8 +24,13 @@
from gnuradio import gr
def set_freq(u, which, subdev, freq, verbose=False):
- """ Set the center frequency for the given subdevice.
- The which paramater specifies which DDC/DUC to use """
+ """!
+ Set the carrier frequency for the given subdevice.
+ @param u the usrp source/sink
+ @param which specifies the DDC/DUC number
+ @param freq the carrier frequency in Hz
+ @param verbose if true, print usrp tuning information
+ """
r = u.tune(which, subdev, freq)
if verbose:
if r:
@@ -34,26 +39,21 @@
print " r.dxc_freq =", r.dxc_freq
print " r.residual_freq =", r.residual_freq
print " r.inverted =", r.inverted
- else:
- print " Failed!"
+ else: print " Failed!"
-usrp_rx_choices = [('Auto', None),
- ('Side A:0', (0, 0)),
- ('Side B:0', (1, 0)),
- ('Side A:1', (0, 1)),
- ('Side B:1', (1, 1)),]
-
-usrp_tx_choices = [('Auto', None),
- ('Side A', (0, 0)),
- ('Side B', (1, 0)),]
-
def USRPSource(sb):
from gnuradio import usrp
type = Enum([('Complex', (usrp.source_c, Complex())), ('IShort',
(usrp.source_s, Short()))])
sb.add_output_socket('out', Variable(type, index=1))
sb.add_param('Output Type', type, False, type=True)
sb.add_param('Unit Number', Int(0, min=0))
- sb.add_param('Side:Subdevice', Enum(usrp_rx_choices))
+ sb.add_param('Side:Subdevice', Enum([
+ ('Auto', None),
+ ('Side A:0', (0, 0)),
+ ('Side B:0', (1, 0)),
+ ('Side A:1', (0, 1)),
+ ('Side B:1', (1, 1)),
+ ]))
sb.add_param('Frequency', Float())
sb.add_param('Decimation', Int(200, min=1))
sb.add_param('Gain', Float(100))
@@ -86,7 +86,11 @@
sb.add_input_socket('in', Variable(type, index=1))
sb.add_param('Input Type', type, False, type=True)
sb.add_param('Unit Number', Int(0, min=0))
- sb.add_param('Side', Enum(usrp_tx_choices))
+ sb.add_param('Side', Enum([
+ ('Auto', None),
+ ('Side A', (0, 0)),
+ ('Side B', (1, 0)),
+ ]))
sb.add_param('Frequency', Float())
sb.add_param('Interpolation', Int(200, min=1))
sb.add_param('Gain', Float(0))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5802 - in grc/branches/jblum_work: examples notes src src/Elements src/Graphics src/SignalBlockDefs,
jblum <=