From 842db2eeea3da3b1d2eed766376f886a62b4c415 Mon Sep 17 00:00:00 2001 From: Bastian Bloessl Date: Sat, 23 Apr 2016 11:07:52 +0200 Subject: [PATCH] some clean up --- grc/CMakeLists.txt | 13 ++------ grc/foo_random_periodic_msg_source.xml | 4 +-- include/foo/CMakeLists.txt | 5 ++-- lib/CMakeLists.txt | 6 ++-- lib/periodic_msg_source_impl.cc | 5 ++-- lib/random_periodic_msg_source_impl.cc | 41 +++++++++++++------------- lib/random_periodic_msg_source_impl.h | 12 ++++---- swig/foo_swig.i | 12 ++++---- 8 files changed, 45 insertions(+), 53 deletions(-) diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index dc56521..75e9863 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -17,13 +17,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -install(FILES - foo_burst_tagger.xml - foo_packet_dropper.xml - foo_packet_pad.xml - foo_packet_pad2.xml - foo_periodic_msg_source.xml - foo_rtt_measure.xml - foo_wireshark_connector.xml - foo_random_periodic_msg_source.xml DESTINATION share/gnuradio/grc/blocks -) +file(GLOB xml_files "*.xml") + +install(FILES ${xml_files} DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/foo_random_periodic_msg_source.xml b/grc/foo_random_periodic_msg_source.xml index 15e2ce9..1f66960 100644 --- a/grc/foo_random_periodic_msg_source.xml +++ b/grc/foo_random_periodic_msg_source.xml @@ -52,8 +52,8 @@ num 1 int - - + + Random Seed seed 1 diff --git a/include/foo/CMakeLists.txt b/include/foo/CMakeLists.txt index ef576d2..de9b3ca 100644 --- a/include/foo/CMakeLists.txt +++ b/include/foo/CMakeLists.txt @@ -27,7 +27,8 @@ install(FILES packet_pad.h packet_pad2.h periodic_msg_source.h - wireshark_connector.h + random_periodic_msg_source.h rtt_measure.h - random_periodic_msg_source.h DESTINATION include/foo + wireshark_connector.h + DESTINATION include/foo ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d6b8e5c..f978d58 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -34,12 +34,12 @@ link_directories( list(APPEND foo_sources burst_tagger_impl.cc packet_dropper_impl.cc - packet_pad_impl.cc packet_pad2.cc + packet_pad_impl.cc periodic_msg_source_impl.cc - wireshark_connector_impl.cc - rtt_measure_impl.cc random_periodic_msg_source_impl.cc + rtt_measure_impl.cc + wireshark_connector_impl.cc ) set(PACKAGE_FIND_VERSION_MAJOR 0) diff --git a/lib/periodic_msg_source_impl.cc b/lib/periodic_msg_source_impl.cc index 3d6293e..e27fb5d 100644 --- a/lib/periodic_msg_source_impl.cc +++ b/lib/periodic_msg_source_impl.cc @@ -80,11 +80,11 @@ periodic_msg_source_impl::run(periodic_msg_source_impl *instance) { if(d_nmsg_left > 0) { d_nmsg_left--; } - + delay = d_interval; } boost::this_thread::sleep(boost::posix_time::milliseconds(delay)); - } + } } catch(boost::thread_interrupted) { gr::thread::scoped_lock(d_mutex); @@ -151,4 +151,3 @@ periodic_msg_source::sptr periodic_msg_source::make(pmt::pmt_t msg, float interval, int num_msg, bool quit, bool debug) { return gnuradio::get_initial_sptr(new periodic_msg_source_impl(msg, interval, num_msg, quit, debug)); } - diff --git a/lib/random_periodic_msg_source_impl.cc b/lib/random_periodic_msg_source_impl.cc index 3689b14..5201d3f 100644 --- a/lib/random_periodic_msg_source_impl.cc +++ b/lib/random_periodic_msg_source_impl.cc @@ -38,10 +38,10 @@ random_periodic_msg_source_impl::random_periodic_msg_source_impl(int msg_len, d_debug(debug), d_finished(false), d_quit(quit), - d_seed(static_cast(seed)), - d_brange(0,255), - d_rng(seed), - d_randbytes(d_rng,d_brange) + d_seed(static_cast(seed)), + d_brange(0,255), + d_rng(seed), + d_randbytes(d_rng,d_brange) { message_port_register_out(pmt::mp("out")); @@ -79,18 +79,18 @@ random_periodic_msg_source_impl::run(random_periodic_msg_source_impl *instance) } dout << "PMS: number of messages left: " << d_nmsg_left << std::endl; - // Generate a random message - pmt::pmt_t msg = generate_msg(); + // Generate a random message + pmt::pmt_t msg = generate_msg(); message_port_pub( pmt::mp("out"), msg); if(d_nmsg_left > 0) { d_nmsg_left--; } - + delay = d_interval; } boost::this_thread::sleep(boost::posix_time::milliseconds(delay)); - } + } } catch(boost::thread_interrupted) { gr::thread::scoped_lock(d_mutex); @@ -105,17 +105,17 @@ random_periodic_msg_source_impl::run(random_periodic_msg_source_impl *instance) } // Generate a random message -pmt::pmt_t -random_periodic_msg_source_impl::generate_msg(){ - // Construct random vector of specified length - std::vector vec(d_msg_len); - // Fill w/random bytes - for( int i=0; i vec(d_msg_len); + // Fill w/random bytes + for( int i=0; i d_brange; - boost::variate_generator< boost::mt19937, boost::uniform_int<> > d_randbytes; + boost::mt19937 d_rng; + boost::variate_generator< boost::mt19937, boost::uniform_int<> > d_randbytes; + boost::uniform_int<> d_brange; public: random_periodic_msg_source_impl(int msg_len, @@ -56,7 +56,7 @@ namespace foo { void start_tx(); void stop_tx(); - pmt::pmt_t generate_msg(); + pmt::pmt_t generate_msg(); bool is_running(); }; diff --git a/swig/foo_swig.i b/swig/foo_swig.i index 4841b67..6919196 100644 --- a/swig/foo_swig.i +++ b/swig/foo_swig.i @@ -11,9 +11,9 @@ #include "foo/packet_pad.h" #include "foo/packet_pad2.h" #include "foo/periodic_msg_source.h" -#include "foo/wireshark_connector.h" -#include "foo/rtt_measure.h" #include "foo/random_periodic_msg_source.h" +#include "foo/rtt_measure.h" +#include "foo/wireshark_connector.h" %} @@ -22,15 +22,15 @@ %include "foo/packet_pad.h" %include "foo/packet_pad2.h" %include "foo/periodic_msg_source.h" -%include "foo/wireshark_connector.h" -%include "foo/rtt_measure.h" %include "foo/random_periodic_msg_source.h" +%include "foo/rtt_measure.h" +%include "foo/wireshark_connector.h" GR_SWIG_BLOCK_MAGIC2(foo, burst_tagger); GR_SWIG_BLOCK_MAGIC2(foo, packet_dropper); GR_SWIG_BLOCK_MAGIC2(foo, packet_pad); GR_SWIG_BLOCK_MAGIC2(foo, packet_pad2); GR_SWIG_BLOCK_MAGIC2(foo, periodic_msg_source); -GR_SWIG_BLOCK_MAGIC2(foo, wireshark_connector); -GR_SWIG_BLOCK_MAGIC2(foo, rtt_measure); GR_SWIG_BLOCK_MAGIC2(foo, random_periodic_msg_source); +GR_SWIG_BLOCK_MAGIC2(foo, rtt_measure); +GR_SWIG_BLOCK_MAGIC2(foo, wireshark_connector);