[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8285 - in grc/trunk/src: grc grc_gnuradio/blks2 grc_g
From: |
jblum |
Subject: |
[Commit-gnuradio] r8285 - in grc/trunk/src: grc grc_gnuradio/blks2 grc_gnuradio/blocks/sources grc_gnuradio/data grc_gnuradio/wxgui |
Date: |
Sun, 27 Apr 2008 18:45:32 -0600 (MDT) |
Author: jblum
Date: 2008-04-27 18:45:31 -0600 (Sun, 27 Apr 2008)
New Revision: 8285
Added:
grc/trunk/src/grc_gnuradio/blocks/sources/random_source_x.xml
Modified:
grc/trunk/src/grc/Constants.py
grc/trunk/src/grc_gnuradio/blks2/__init__.py
grc/trunk/src/grc_gnuradio/data/block_tree.xml
grc/trunk/src/grc_gnuradio/wxgui/callback_controls.py
Log:
random source
Modified: grc/trunk/src/grc/Constants.py
===================================================================
--- grc/trunk/src/grc/Constants.py 2008-04-27 05:58:27 UTC (rev 8284)
+++ grc/trunk/src/grc/Constants.py 2008-04-28 00:45:31 UTC (rev 8285)
@@ -22,11 +22,12 @@
import os
import mutex
+import time
##mutex used when running a flow graph.
MUTEX = mutex.mutex()
def lock(mutex):
- while not mutex.testandset(): pass #try to lock repeatedly until
lock is aquired
+ while not mutex.testandset(): time.sleep(1e-4) #try to lock repeatedly
until lock is aquired
MUTEX.lock = lambda: lock(MUTEX)
######################################################################################################
Modified: grc/trunk/src/grc_gnuradio/blks2/__init__.py
===================================================================
--- grc/trunk/src/grc_gnuradio/blks2/__init__.py 2008-04-27 05:58:27 UTC
(rev 8284)
+++ grc/trunk/src/grc_gnuradio/blks2/__init__.py 2008-04-28 00:45:31 UTC
(rev 8285)
@@ -4,4 +4,3 @@
from packet import packet_mod, packet_demod
from packet import mod_pkts, demod_pkts
from error_rate import error_rate
-
Added: grc/trunk/src/grc_gnuradio/blocks/sources/random_source_x.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/sources/random_source_x.xml
(rev 0)
+++ grc/trunk/src/grc_gnuradio/blocks/sources/random_source_x.xml
2008-04-28 00:45:31 UTC (rev 8285)
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<!DOCTYPE block SYSTEM "../block.dtd">
+<!--
+###################################################
+##Random Source:
+## Custom block
+###################################################
+ -->
+<block>
+ <name>Random Source</name>
+ <key>random_source_x</key>
+ <import>from gnuradio import gr</import>
+ <import>import numpy</import>
+ <make>gr.vector_source_$(type.fcn)(numpy.random.randint($min, $max,
$num_samps), $repeat)</make>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:b</opt>
+ </option>
+ </param>
+ <param>
+ <name>Minimum</name>
+ <key>min</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Maximum</name>
+ <key>max</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Num Samples</name>
+ <key>num_samps</key>
+ <value>1000</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Repeat</name>
+ <key>repeat</key>
+ <value>True</value>
+ <type>enum</type>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ </param>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+ <doc>
+Generate num samples of random numbers of [min, max). Repeat samples if
specified.
+ </doc>
+</block>
Modified: grc/trunk/src/grc_gnuradio/data/block_tree.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/data/block_tree.xml 2008-04-27 05:58:27 UTC
(rev 8284)
+++ grc/trunk/src/grc_gnuradio/data/block_tree.xml 2008-04-28 00:45:31 UTC
(rev 8285)
@@ -10,6 +10,7 @@
<block>gr_sig_source_x</block>
<block>gr_noise_source_x</block>
<block>gr_vector_source_x</block>
+ <block>random_source_x</block>
<block>gr_glfsr_source_x</block>
<block>gr_null_source</block>
<block>gr_file_source</block>
Modified: grc/trunk/src/grc_gnuradio/wxgui/callback_controls.py
===================================================================
--- grc/trunk/src/grc_gnuradio/wxgui/callback_controls.py 2008-04-27
05:58:27 UTC (rev 8284)
+++ grc/trunk/src/grc_gnuradio/wxgui/callback_controls.py 2008-04-28
00:45:31 UTC (rev 8285)
@@ -172,16 +172,17 @@
sys.exit(-1)
slider.Bind(wx.EVT_SCROLL, self._handle_scroll) #bind the
scrolling event
self.Add(slider, 0, wx.ALIGN_CENTER)
- self._set_slider_value(value)#sets the slider's value
+ #init slider and text box
+ self._value = value
+ self._set_slider_value(self._value)#sets the slider's value
+ self.text_box.SetValue(str(self._value))
def get_value(self):
"""!
- Read the value from the slider and,
- translate the slider value into a real numerical value.
- @return the numeric representation of the slider
+ Get the current set value.
+ @return the value (float)
"""
- slider_value = self.slider.GetValue()
- return slider_value*(self.max - self.min)/self.num_steps +
self.min
+ return self._value
def _set_slider_value(self, real_value):
"""!
@@ -196,9 +197,10 @@
"""!
A scroll event is detected. Read the slider, call the callback.
"""
- new_value = str(self.get_value()) #the new value must be
a string!
- self._set_slider_value(new_value)
- self.text_box.SetValue(new_value)
+ slider_value = self.slider.GetValue()
+ new_value = slider_value*(self.max - self.min)/self.num_steps +
self.min
+ self.text_box.SetValue(str(new_value))
+ self._value = new_value
try: self.call()
except Exception: print >> sys.stderr, 'Error in exec callback
from handle scroll.'
@@ -206,9 +208,9 @@
"""!
An enter key was pressed. Read the text box, call the callback.
"""
- new_value = str(self.text_box.GetValue()) #the new value
must be a string!
+ new_value = float(self.text_box.GetValue())
self._set_slider_value(new_value)
- self.text_box.SetValue(new_value)
+ self._value = new_value
try: self.call()
except Exception: print >> sys.stderr, 'Error in exec callback
from handle enter.'
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8285 - in grc/trunk/src: grc grc_gnuradio/blks2 grc_gnuradio/blocks/sources grc_gnuradio/data grc_gnuradio/wxgui,
jblum <=