summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreb2008-06-24 20:48:39 +0000
committereb2008-06-24 20:48:39 +0000
commit4d5e702b2a7d511f22b8e5dcce7da5ce77a2d322 (patch)
tree07818e507e305419d4a098e1a1d6366c098db4bc
parentab6cf111c1d00b22d9016524b31cfcc6b09ffdc7 (diff)
downloadgnuradio-4d5e702b2a7d511f22b8e5dcce7da5ce77a2d322.tar.gz
gnuradio-4d5e702b2a7d511f22b8e5dcce7da5ce77a2d322.tar.bz2
gnuradio-4d5e702b2a7d511f22b8e5dcce7da5ce77a2d322.zip
removed is_running method from gr_top_block
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8689 221aa14e-8319-0410-a670-987f0aec2ac5
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.cc6
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.h7
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.i3
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block_impl.cc13
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block_impl.h10
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block_impl_sts.cc2
-rwxr-xr-xgr-gpio/src/python/gpio_usrp_siggen.py39
-rwxr-xr-xgr-utils/src/python/usrp_siggen.py33
8 files changed, 51 insertions, 62 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.cc b/gnuradio-core/src/lib/runtime/gr_top_block.cc
index 473ea5883..339f3cb89 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.cc
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.cc
@@ -96,9 +96,3 @@ gr_top_block::dump()
{
d_impl->dump();
}
-
-bool
-gr_top_block::is_running()
-{
- return d_impl->is_running();
-}
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h
index 637a38468..b47ec019c 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -103,11 +103,6 @@ public:
* Displays flattened flowgraph edges and block connectivity
*/
void dump();
-
- /*!
- * Returns true if flowgraph is running
- */
- bool is_running();
};
#endif /* INCLUDED_GR_TOP_BLOCK_H */
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i
index d2e8e3b41..670e5b5e5 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.i
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -46,7 +46,6 @@ public:
void run();
void lock();
void unlock() throw (std::runtime_error);
- bool is_running();
void dump();
};
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
index 857e9fa2d..591437938 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
+++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
@@ -57,7 +57,10 @@ gr_top_block_impl::start()
std::cout << "start: entered " << this << std::endl;
if (d_running)
- throw std::runtime_error("top block already running or wait() not called after previous stop()");
+ throw std::runtime_error("top_block::start: top block already running or wait() not called after previous stop()");
+
+ if (d_lock_count > 0)
+ throw std::runtime_error("top_block::start: can't call start with flow graph locked");
// Create new flat flow graph by flattening hierarchy
d_ffg = d_owner->flatten();
@@ -68,6 +71,7 @@ gr_top_block_impl::start()
// Execute scheduler threads
start_threads();
+ d_running = true;
}
@@ -86,8 +90,10 @@ void
gr_top_block_impl::unlock()
{
omni_mutex_lock lock(d_reconf);
- if (d_lock_count <= 0)
+ if (d_lock_count <= 0){
+ d_lock_count = 0; // fix it, then complain
throw std::runtime_error("unpaired unlock() call");
+ }
d_lock_count--;
if (GR_TOP_BLOCK_IMPL_DEBUG)
@@ -107,7 +113,7 @@ gr_top_block_impl::restart()
std::cout << "restart: entered" << std::endl;
if (!d_running)
- throw std::runtime_error("top block is not running");
+ return; // nothing to do
// Stop scheduler threads and wait for completion
stop();
@@ -133,6 +139,7 @@ gr_top_block_impl::restart()
d_ffg = new_ffg;
start_threads();
+ d_running = true;
}
void
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h
index 003afec93..869f788ef 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h
+++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h
@@ -49,16 +49,13 @@ public:
virtual void wait() = 0;
// Lock the top block to allow reconfiguration
- virtual void lock();
+ void lock();
// Unlock the top block at end of reconfiguration
- virtual void unlock();
+ void unlock();
// Dump the flowgraph to stdout
void dump();
-
- // Return true if flowgraph is running
- bool is_running() const { return d_running; }
protected:
@@ -70,7 +67,6 @@ protected:
int d_lock_count;
virtual void start_threads() = 0;
- virtual void restart();
/*!
* Make a vector of gr_block from a vector of gr_basic_block
@@ -79,6 +75,8 @@ protected:
*/
static gr_block_vector_t make_gr_block_vector(gr_basic_block_vector_t blocks);
+private:
+ void restart();
};
#endif /* INCLUDED_GR_TOP_BLOCK_IMPL_H */
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl_sts.cc b/gnuradio-core/src/lib/runtime/gr_top_block_impl_sts.cc
index 39289ce5b..b3e9da627 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block_impl_sts.cc
+++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl_sts.cc
@@ -85,8 +85,6 @@ gr_top_block_impl_sts::start_threads()
std::cout << "start_threads: starting " << thread << std::endl;
thread->start();
}
-
- d_running = true;
}
/*
diff --git a/gr-gpio/src/python/gpio_usrp_siggen.py b/gr-gpio/src/python/gpio_usrp_siggen.py
index 0a0ea685b..0e483c35d 100755
--- a/gr-gpio/src/python/gpio_usrp_siggen.py
+++ b/gr-gpio/src/python/gpio_usrp_siggen.py
@@ -90,26 +90,25 @@ class my_top_block(gr.top_block):
# self.file_sink = gr.file_sink (gr.sizeof_gr_complex, "siggen.dat")
def _configure_graph (self, type):
- was_running = self.is_running ()
- if was_running:
- self.stop ()
- self.disconnect_all ()
- if type == gr.GR_SIN_WAVE:
- self.connect (self.siggen, self.u)
- # self.connect (self.siggen, self.file_sink)
- self.siggen.set_waveform (type)
- self.src = self.siggen
- elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN:
- self.connect (self.noisegen, self.u)
- self.noisegen.set_type (type)
- self.src = self.noisegen
- elif type == gr.GR_CONST_WAVE:
- self.connect (self.vecgen, self.u)
- self.src = self.vecgen
- else:
- raise ValueError, type
- if was_running:
- self.start ()
+ try:
+ self.lock()
+ self.disconnect_all ()
+ if type == gr.GR_SIN_WAVE:
+ self.connect (self.siggen, self.u)
+ # self.connect (self.siggen, self.file_sink)
+ self.siggen.set_waveform (type)
+ self.src = self.siggen
+ elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN:
+ self.connect (self.noisegen, self.u)
+ self.noisegen.set_type (type)
+ self.src = self.noisegen
+ elif type == gr.GR_CONST_WAVE:
+ self.connect (self.vecgen, self.u)
+ self.src = self.vecgen
+ else:
+ raise ValueError, type
+ finally:
+ self.unlock()
def set_freq(self, target_freq):
"""
diff --git a/gr-utils/src/python/usrp_siggen.py b/gr-utils/src/python/usrp_siggen.py
index f0a096e2d..add3888ba 100755
--- a/gr-utils/src/python/usrp_siggen.py
+++ b/gr-utils/src/python/usrp_siggen.py
@@ -69,23 +69,22 @@ class my_top_block(gr.top_block):
# self.file_sink = gr.file_sink (gr.sizeof_gr_complex, "siggen.dat")
def _configure_graph (self, type):
- was_running = self.is_running ()
- if was_running:
- self.stop ()
- self.disconnect_all ()
- if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE:
- self.connect (self.siggen, self.u)
- # self.connect (self.siggen, self.file_sink)
- self.siggen.set_waveform (type)
- self.src = self.siggen
- elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN:
- self.connect (self.noisegen, self.u)
- self.noisegen.set_type (type)
- self.src = self.noisegen
- else:
- raise ValueError, type
- if was_running:
- self.start ()
+ try:
+ self.lock()
+ self.disconnect_all ()
+ if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE:
+ self.connect (self.siggen, self.u)
+ # self.connect (self.siggen, self.file_sink)
+ self.siggen.set_waveform (type)
+ self.src = self.siggen
+ elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN:
+ self.connect (self.noisegen, self.u)
+ self.noisegen.set_type (type)
+ self.src = self.noisegen
+ else:
+ raise ValueError, type
+ finally:
+ self.unlock()
def set_freq(self, target_freq):
"""