Changeset 8689
- Timestamp:
- 06/24/08 14:48:39
- Files:
-
- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block.cc (modified) (1 diff)
- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block.h (modified) (2 diffs)
- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block.i (modified) (2 diffs)
- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc (modified) (5 diffs)
- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block_impl.h (modified) (3 diffs)
- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block_impl_sts.cc (modified) (1 diff)
- gnuradio/trunk/gr-gpio/src/python/gpio_usrp_siggen.py (modified) (1 diff)
- gnuradio/trunk/gr-utils/src/python/usrp_siggen.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block.cc
r8665 r8689 97 97 d_impl->dump(); 98 98 } 99 100 bool101 gr_top_block::is_running()102 {103 return d_impl->is_running();104 }gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block.h
r8466 r8689 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 2007 Free Software Foundation, Inc.3 * Copyright 2007,2008 Free Software Foundation, Inc. 4 4 * 5 5 * This file is part of GNU Radio … … 104 104 */ 105 105 void dump(); 106 107 /*!108 * Returns true if flowgraph is running109 */110 bool is_running();111 106 }; 112 107 gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block.i
r8466 r8689 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 2007 Free Software Foundation, Inc.3 * Copyright 2007,2008 Free Software Foundation, Inc. 4 4 * 5 5 * This file is part of GNU Radio … … 47 47 void lock(); 48 48 void unlock() throw (std::runtime_error); 49 bool is_running();50 49 void dump(); 51 50 }; gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
r8665 r8689 58 58 59 59 if (d_running) 60 throw std::runtime_error("top block already running or wait() not called after previous stop()"); 60 throw std::runtime_error("top_block::start: top block already running or wait() not called after previous stop()"); 61 62 if (d_lock_count > 0) 63 throw std::runtime_error("top_block::start: can't call start with flow graph locked"); 61 64 62 65 // Create new flat flow graph by flattening hierarchy … … 69 72 // Execute scheduler threads 70 73 start_threads(); 74 d_running = true; 71 75 } 72 76 … … 87 91 { 88 92 omni_mutex_lock lock(d_reconf); 89 if (d_lock_count <= 0) 93 if (d_lock_count <= 0){ 94 d_lock_count = 0; // fix it, then complain 90 95 throw std::runtime_error("unpaired unlock() call"); 96 } 91 97 92 98 d_lock_count--; … … 108 114 109 115 if (!d_running) 110 throw std::runtime_error("top block is not running");116 return; // nothing to do 111 117 112 118 // Stop scheduler threads and wait for completion … … 134 140 135 141 start_threads(); 142 d_running = true; 136 143 } 137 144 gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block_impl.h
r8665 r8689 50 50 51 51 // Lock the top block to allow reconfiguration 52 v irtual void lock();52 void lock(); 53 53 54 54 // Unlock the top block at end of reconfiguration 55 v irtual void unlock();55 void unlock(); 56 56 57 57 // Dump the flowgraph to stdout 58 58 void dump(); 59 60 // Return true if flowgraph is running61 bool is_running() const { return d_running; }62 59 63 60 protected: … … 71 68 72 69 virtual void start_threads() = 0; 73 virtual void restart();74 70 75 71 /*! … … 80 76 static gr_block_vector_t make_gr_block_vector(gr_basic_block_vector_t blocks); 81 77 78 private: 79 void restart(); 82 80 }; 83 81 gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_top_block_impl_sts.cc
r8665 r8689 86 86 thread->start(); 87 87 } 88 89 d_running = true;90 88 } 91 89 gnuradio/trunk/gr-gpio/src/python/gpio_usrp_siggen.py
r7618 r8689 91 91 92 92 def _configure_graph (self, type): 93 was_running = self.is_running () 94 if was_running: 95 self.stop () 96 self.disconnect_all () 97 if type == gr.GR_SIN_WAVE: 98 self.connect (self.siggen, self.u) 99 # self.connect (self.siggen, self.file_sink) 100 self.siggen.set_waveform (type) 101 self.src = self.siggen 102 elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN: 103 self.connect (self.noisegen, self.u) 104 self.noisegen.set_type (type) 105 self.src = self.noisegen 106 elif type == gr.GR_CONST_WAVE: 107 self.connect (self.vecgen, self.u) 108 self.src = self.vecgen 109 else: 110 raise ValueError, type 111 if was_running: 112 self.start () 93 try: 94 self.lock() 95 self.disconnect_all () 96 if type == gr.GR_SIN_WAVE: 97 self.connect (self.siggen, self.u) 98 # self.connect (self.siggen, self.file_sink) 99 self.siggen.set_waveform (type) 100 self.src = self.siggen 101 elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN: 102 self.connect (self.noisegen, self.u) 103 self.noisegen.set_type (type) 104 self.src = self.noisegen 105 elif type == gr.GR_CONST_WAVE: 106 self.connect (self.vecgen, self.u) 107 self.src = self.vecgen 108 else: 109 raise ValueError, type 110 finally: 111 self.unlock() 113 112 114 113 def set_freq(self, target_freq): gnuradio/trunk/gr-utils/src/python/usrp_siggen.py
r6477 r8689 70 70 71 71 def _configure_graph (self, type): 72 was_running = self.is_running () 73 if was_running: 74 self.stop () 75 self.disconnect_all () 76 if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE: 77 self.connect (self.siggen, self.u) 78 # self.connect (self.siggen, self.file_sink) 79 self.siggen.set_waveform (type) 80 self.src = self.siggen 81 elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN: 82 self.connect (self.noisegen, self.u) 83 self.noisegen.set_type (type) 84 self.src = self.noisegen 85 else: 86 raise ValueError, type 87 if was_running: 88 self.start () 72 try: 73 self.lock() 74 self.disconnect_all () 75 if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE: 76 self.connect (self.siggen, self.u) 77 # self.connect (self.siggen, self.file_sink) 78 self.siggen.set_waveform (type) 79 self.src = self.siggen 80 elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN: 81 self.connect (self.noisegen, self.u) 82 self.noisegen.set_type (type) 83 self.src = self.noisegen 84 else: 85 raise ValueError, type 86 finally: 87 self.unlock() 89 88 90 89 def set_freq(self, target_freq):
