From d844c4f06dc10c8499eb2b8f1cb5b55f55a5b48d Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Tue, 9 Mar 2010 12:40:43 -0800
Subject: added a right click context menu for the flow graph elements
---
grc/gui/DrawingArea.py | 12 +++++++-----
grc/gui/FlowGraph.py | 41 ++++++++++++++++++++++++++++++++++-------
2 files changed, 41 insertions(+), 12 deletions(-)
(limited to 'grc')
diff --git a/grc/gui/DrawingArea.py b/grc/gui/DrawingArea.py
index b70468ed0..790df7c3f 100644
--- a/grc/gui/DrawingArea.py
+++ b/grc/gui/DrawingArea.py
@@ -1,5 +1,5 @@
"""
-Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -82,19 +82,21 @@ class DrawingArea(gtk.DrawingArea):
Forward button click information to the flow graph.
"""
self.ctrl_mask = event.state & gtk.gdk.CONTROL_MASK
- self._flow_graph.handle_mouse_button_press(
- left_click=(event.button == 1),
+ if event.button == 1: self._flow_graph.handle_mouse_selector_press(
double_click=(event.type == gtk.gdk._2BUTTON_PRESS),
coordinate=(event.x, event.y),
)
+ if event.button == 3: self._flow_graph.handle_mouse_context_press(
+ coordinate=(event.x, event.y),
+ event=event,
+ )
def _handle_mouse_button_release(self, widget, event):
"""
Forward button release information to the flow graph.
"""
self.ctrl_mask = event.state & gtk.gdk.CONTROL_MASK
- self._flow_graph.handle_mouse_button_release(
- left_click=(event.button == 1),
+ if event.button == 1: self._flow_graph.handle_mouse_selector_release(
coordinate=(event.x, event.y),
)
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 5adecccc1..897145a1d 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -1,5 +1,5 @@
"""
-Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -51,6 +51,19 @@ class FlowGraph(Element):
#selected ports
self._old_selected_port = None
self._new_selected_port = None
+ #context menu
+ self._context_menu = gtk.Menu()
+ for action in [
+ Actions.BLOCK_CUT,
+ Actions.BLOCK_COPY,
+ Actions.BLOCK_PASTE,
+ Actions.ELEMENT_DELETE,
+ Actions.BLOCK_ROTATE_CCW,
+ Actions.BLOCK_ROTATE_CW,
+ Actions.BLOCK_ENABLE,
+ Actions.BLOCK_DISABLE,
+ Actions.BLOCK_PARAM_MODIFY,
+ ]: self._context_menu.append(action.create_menu_item())
###########################################################################
# Access Drawing Area
@@ -425,14 +438,27 @@ class FlowGraph(Element):
##########################################################################
## Event Handlers
##########################################################################
- def handle_mouse_button_press(self, left_click, double_click, coordinate):
+ def handle_mouse_context_press(self, coordinate, event):
"""
- A mouse button is pressed, only respond to left clicks.
+ The context mouse button was pressed:
+ If no elements were selected, perform re-selection at this coordinate.
+ Then, show the context menu at the mouse click location.
+ """
+ selections = self.what_is_selected(coordinate)
+ if not set(selections).intersection(self.get_selected_elements()):
+ self.set_coordinate(coordinate)
+ self.mouse_pressed = True
+ self.update_selected_elements()
+ self.mouse_pressed = False
+ self._context_menu.popup(None, None, None, event.button, event.time)
+
+ def handle_mouse_selector_press(self, double_click, coordinate):
+ """
+ The selector mouse button was pressed:
Find the selected element. Attempt a new connection if possible.
Open the block params window on a double click.
Update the selection state of the flow graph.
"""
- if not left_click: return
self.press_coor = coordinate
self.set_coordinate(coordinate)
self.time = 0
@@ -444,11 +470,12 @@ class FlowGraph(Element):
self.mouse_pressed = False
Actions.BLOCK_PARAM_MODIFY()
- def handle_mouse_button_release(self, left_click, coordinate):
+ def handle_mouse_selector_release(self, coordinate):
"""
- A mouse button is released, record the state.
+ The selector mouse button was released:
+ Update the state, handle motion (dragging).
+ And update the selected flowgraph elements.
"""
- if not left_click: return
self.set_coordinate(coordinate)
self.time = 0
self.mouse_pressed = False
--
cgit
From 645768d1b067fe83ccc65f4a834ee384ea4560d9 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Wed, 10 Mar 2010 00:12:47 -0800
Subject: Trial feature for different source sides for usrp dual source.
---
grc/blocks/usrp_dual_source_x.xml | 36 +++++++++++++++++++++++++++++++++++-
grc/grc_gnuradio/usrp/dual_usrp.py | 8 ++++----
2 files changed, 39 insertions(+), 5 deletions(-)
(limited to 'grc')
diff --git a/grc/blocks/usrp_dual_source_x.xml b/grc/blocks/usrp_dual_source_x.xml
index ad9a860ac..07d3174bb 100644
--- a/grc/blocks/usrp_dual_source_x.xml
+++ b/grc/blocks/usrp_dual_source_x.xml
@@ -8,7 +8,11 @@
USRP Dual Source
usrp_dual_source_x
from grc_gnuradio import usrp as grc_usrp
- grc_usrp.dual_source_$(type.fcn)(which=$which, rx_ant_a=$rx_ant_a, rx_ant_b=$rx_ant_b)
+ grc_usrp.dual_source_$(type.fcn)(
+ which=$which,
+ rx_ant_a=$rx_ant_a, rx_ant_b=$rx_ant_b,
+ rx_source_a=$rx_source_a, rx_source_b=$rx_source_b,
+)
#if $format()
self.$(id).set_format(width=$format.width, shift=$format.shift)
#end if
@@ -189,6 +193,36 @@ self.$(id).set_gain_b($gain_b)
RX2
+
+ RX Source A
+ rx_source_a
+ A
+ string
+ #if $rx_source_a() == 'A' then 'part' else 'none'#
+
+
+
+
+ RX Source B
+ rx_source_b
+ B
+ string
+ #if $rx_source_b() == 'B' then 'part' else 'none'#
+
+
+
Aout
$type
diff --git a/grc/grc_gnuradio/usrp/dual_usrp.py b/grc/grc_gnuradio/usrp/dual_usrp.py
index b26dbddd4..66b76b2df 100644
--- a/grc/grc_gnuradio/usrp/dual_usrp.py
+++ b/grc/grc_gnuradio/usrp/dual_usrp.py
@@ -1,4 +1,4 @@
-# Copyright 2009 Free Software Foundation, Inc.
+# Copyright 2009, 2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -27,7 +27,7 @@ from gnuradio import gr
class _dual_source(gr.hier_block2):
"""A dual usrp source of IO type short or complex."""
- def __init__(self, which, rx_ant_a='RXA', rx_ant_b='RXA'):
+ def __init__(self, which, rx_ant_a='RXA', rx_ant_b='RXA', rx_source_a='A', rx_source_b='B'):
"""
USRP dual source contructor.
@param which the unit number
@@ -42,8 +42,8 @@ class _dual_source(gr.hier_block2):
)
#create usrp object
self._make_usrp(which=which, nchan=2)
- subdev_spec_a = common.to_spec('A', rx_ant_a)
- subdev_spec_b = common.to_spec('B', rx_ant_b)
+ subdev_spec_a = common.to_spec(rx_source_a, rx_ant_a)
+ subdev_spec_b = common.to_spec(rx_source_b, rx_ant_b)
self._get_u().set_mux(self._get_u().determine_rx_mux_value(subdev_spec_a, subdev_spec_b))
self._subdev_a = self._get_u().selected_subdev(subdev_spec_a)
self._subdev_b = self._get_u().selected_subdev(subdev_spec_b)
--
cgit
From 1ae689ff9238dcffbf65881b8ca03aa8df3844aa Mon Sep 17 00:00:00 2001
From: Johnathan Corgan
Date: Sun, 21 Mar 2010 16:17:15 -0700
Subject: Add new block gr.additive_scrambler_bb()
This block performs scrambling by XORing the input sequence with
the output of an LFSR. Repeating this operation restores the original
sequence.
(This differs from gr.scrambler_bb(), which convolves the input sequence
with the LFSR output.)
The additive scrambler allows an optional bit count after which the LFSR
is reset to its initial seed. This allows use with, e.g., packetized
fixed length payloads.
---
grc/blocks/Makefile.am | 1 +
grc/blocks/block_tree.xml | 1 +
grc/blocks/gr_additive_scrambler_bb.xml | 44 +++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
create mode 100644 grc/blocks/gr_additive_scrambler_bb.xml
(limited to 'grc')
diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am
index a284d6d85..4e3839d27 100644
--- a/grc/blocks/Makefile.am
+++ b/grc/blocks/Makefile.am
@@ -67,6 +67,7 @@ dist_ourdata_DATA = \
const_source_x.xml \
gr_add_const_vxx.xml \
gr_add_xx.xml \
+ gr_additive_scrambler_bb.xml \
gr_agc2_xx.xml \
gr_agc_xx.xml \
gr_and_xx.xml \
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index ba597756f..04568e19a 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -259,6 +259,7 @@
Line Coding
gr_scrambler_bb
gr_descrambler_bb
+ gr_additive_scrambler_bb
Vocoders
diff --git a/grc/blocks/gr_additive_scrambler_bb.xml b/grc/blocks/gr_additive_scrambler_bb.xml
new file mode 100644
index 000000000..a15d6eefb
--- /dev/null
+++ b/grc/blocks/gr_additive_scrambler_bb.xml
@@ -0,0 +1,44 @@
+
+
+
+ Additive Scrambler
+ gr_additive_scrambler_bb
+ from gnuradio import gr
+ gr.additive_scrambler_bb($mask, $seed, $len, $count)
+
+ Mask
+ mask
+ 0x8A
+ hex
+
+
+ Seed
+ seed
+ 0x7F
+ hex
+
+
+ Length
+ len
+ 7
+ int
+
+
+ Count
+ count
+ 0
+ int
+
+
+ in
+ byte
+
+
+ out
+ byte
+
+
--
cgit