diff options
-rw-r--r-- | .gitmodules | 10 | ||||
m--------- | PMC | 0 | ||||
m--------- | gnuradio | 0 | ||||
m--------- | grextras | 0 | ||||
-rw-r--r-- | include/gras/detail/chrono.hpp | 2 | ||||
-rw-r--r-- | lib/element.cpp | 11 | ||||
-rw-r--r-- | lib/gras_impl/debug.hpp | 1 | ||||
-rw-r--r-- | lib/gras_impl/output_buffer_queues.hpp | 2 | ||||
-rw-r--r-- | lib/pmc_to_ptree.cpp | 72 | ||||
-rw-r--r-- | lib/task_done.cpp | 2 | ||||
-rw-r--r-- | lib/top_block.cpp | 10 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/chrono_time_test.cpp | 28 |
13 files changed, 85 insertions, 54 deletions
diff --git a/.gitmodules b/.gitmodules index 8d7a78e..1268fcd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,15 @@ [submodule "Theron"] path = Theron - url = https://github.com/guruofquality/Theron.git + url = http://github.com/guruofquality/Theron.git [submodule "Apology"] path = Apology - url = https://github.com/guruofquality/Apology.git + url = http://github.com/guruofquality/Apology.git [submodule "PMC"] path = PMC - url = https://github.com/guruofquality/PMC.git + url = http://github.com/guruofquality/PMC.git [submodule "gnuradio"] path = gnuradio - url = https://github.com/guruofquality/gnuradio.git + url = http://github.com/guruofquality/gnuradio.git [submodule "grextras"] path = grextras - url = https://github.com/guruofquality/grextras.git + url = http://github.com/guruofquality/grextras.git diff --git a/PMC b/PMC -Subproject c21cb504317db1bd3ac2bb75092284b7edd649a +Subproject 0549723e8fb17311c5d89ec596896105357ce89 diff --git a/gnuradio b/gnuradio -Subproject f4fc952e58ce318298258926f7382ed28b92bfa +Subproject 53223d7e7c60974bd56ec3287fdc184ea910087 diff --git a/grextras b/grextras -Subproject 1ab1184268fc64d7711e285b31e5a48507a3493 +Subproject 4c67fcccdde1cd8c8ff33d28d48ac92a411b17d diff --git a/include/gras/detail/chrono.hpp b/include/gras/detail/chrono.hpp index bd247e5..6225e55 100644 --- a/include/gras/detail/chrono.hpp +++ b/include/gras/detail/chrono.hpp @@ -37,7 +37,7 @@ namespace gras { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec*1000000000UL + ts.tv_nsec; + return ts.tv_sec*time_tps() + ts.tv_nsec; } GRAS_FORCE_INLINE time_ticks_t time_tps(void) diff --git a/lib/element.cpp b/lib/element.cpp index 2de0ffb..008027c 100644 --- a/lib/element.cpp +++ b/lib/element.cpp @@ -34,7 +34,11 @@ Element::Element(const std::string &name) } (*this)->repr = str(boost::format("%s (%u)") % name % which); - if (GENESIS) std::cerr << "New element: " << to_string() << std::endl; + if (GENESIS) std::cerr + << "===================================================\n" + << "== Element Created: " << to_string() << "\n" + << "===================================================\n" + << std::flush; } Element::~Element(void) @@ -57,6 +61,11 @@ ElementImpl::~ElementImpl(void) if (this->executor) this->top_block_cleanup(); if (this->topology) this->hier_block_cleanup(); if (this->worker) this->block_cleanup(); + if (ARMAGEDDON) std::cerr + << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" + << "xx Element Destroyed: " << name << "\n" + << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" + << std::flush; } void Element::set_container(WeakContainer *container) diff --git a/lib/gras_impl/debug.hpp b/lib/gras_impl/debug.hpp index eb09090..d356987 100644 --- a/lib/gras_impl/debug.hpp +++ b/lib/gras_impl/debug.hpp @@ -20,6 +20,7 @@ extern void *operator new(std::size_t n) throw (std::bad_alloc); //---------------------------------------------------------------------- #define GENESIS 0 #define ARMAGEDDON 0 +#define DONE_PRINTS 0 //---------------------------------------------------------------------- //-- define to enable these debugs: diff --git a/lib/gras_impl/output_buffer_queues.hpp b/lib/gras_impl/output_buffer_queues.hpp index 48d54de..540a5c2 100644 --- a/lib/gras_impl/output_buffer_queues.hpp +++ b/lib/gras_impl/output_buffer_queues.hpp @@ -127,7 +127,7 @@ struct OutputBufferQueues if (_queues[i] and not _queues[i]->empty()) { const SBuffer &front = _queues[i]->front(); - const size_t avail = front.get_actual_length() - front.offset - front.length; + const size_t avail = front.get_actual_length() - front.offset - front.length; _bitset.set(i, avail >= _reserve_bytes[i]); } else diff --git a/lib/pmc_to_ptree.cpp b/lib/pmc_to_ptree.cpp index 6565fa6..a53261d 100644 --- a/lib/pmc_to_ptree.cpp +++ b/lib/pmc_to_ptree.cpp @@ -8,7 +8,6 @@ #include <boost/foreach.hpp> #include <vector> #include <complex> -#include <sstream> using namespace boost::property_tree; @@ -34,13 +33,16 @@ PMCC gras::ptree_to_pmc(const ptree &value, const std::type_info &hint) //array else { - //TODO more if statements - w/ define - return ptree_to_pmc(value, typeid(std::vector<double>)); + try{return ptree_to_pmc(value, typeid(std::vector<std::complex<double> >));} + catch(...){} + + try{return ptree_to_pmc(value, typeid(std::vector<double>));} + catch(...){} } } #define ptree_to_pmc_try(type) \ - if (hint == typeid(type)) return PMC_M(value.get_value<type>()); + if (hint == typeid(type)) return PMC_M(value.get_value<type >()); //determine number ptree_to_pmc_try(char); @@ -56,28 +58,38 @@ PMCC gras::ptree_to_pmc(const ptree &value, const std::type_info &hint) ptree_to_pmc_try(unsigned long long); ptree_to_pmc_try(float); ptree_to_pmc_try(double); - - //complex number - std::istringstream ss(value.get_value<std::string>()); - if (hint == typeid(std::complex<double>)) - { - std::complex<double> c; ss >> c; return PMC_M(c); - } - if (hint == typeid(std::complex<float>)) - { - std::complex<float> c; ss >> c; return PMC_M(c); - } + ptree_to_pmc_try(std::complex<float>); + ptree_to_pmc_try(std::complex<double>); //string ptree_to_pmc_try(std::string); //determine number vector - std::vector<long> vec; - BOOST_FOREACH(const ptree::value_type &elem, value) - { - vec.push_back(elem.second.get_value<long>()); + #define ptree_to_pmc_tryv(type) \ + if (hint == typeid(std::vector<type >)) \ + { \ + std::vector<type > vec; \ + BOOST_FOREACH(const ptree::value_type &elem, value) \ + { \ + vec.push_back(elem.second.get_value<type >()); \ + } \ + return PMC_M(vec); \ } - return PMC_M(vec); + ptree_to_pmc_tryv(char); + ptree_to_pmc_tryv(signed char); + ptree_to_pmc_tryv(unsigned char); + ptree_to_pmc_tryv(signed short); + ptree_to_pmc_tryv(unsigned short); + ptree_to_pmc_tryv(signed int); + ptree_to_pmc_tryv(unsigned int); + ptree_to_pmc_tryv(signed long); + ptree_to_pmc_tryv(unsigned long); + ptree_to_pmc_tryv(signed long long); + ptree_to_pmc_tryv(unsigned long long); + ptree_to_pmc_tryv(float); + ptree_to_pmc_tryv(double); + ptree_to_pmc_tryv(std::complex<float>); + ptree_to_pmc_tryv(std::complex<double>); //otherwise null -- will crap out return PMC(); @@ -87,7 +99,7 @@ ptree gras::pmc_to_ptree(const PMCC &value) { ptree v; #define pmc_to_ptree_try(type) \ - if (value.is<type>()) {v.put_value(value.as<type>()); return v;} + if (value.is<type >()) {v.put_value(value.as<type >()); return v;} //determine number pmc_to_ptree_try(char); @@ -103,20 +115,8 @@ ptree gras::pmc_to_ptree(const PMCC &value) pmc_to_ptree_try(unsigned long long); pmc_to_ptree_try(float); pmc_to_ptree_try(double); - - //derermine complex - if (value.is<std::complex<double> >()) - { - std::ostringstream oss; - oss << value.as<std::complex<double> >(); - v.put_value(oss.str()); return v; - } - if (value.is<std::complex<float> >()) - { - std::ostringstream oss; - oss << value.as<std::complex<float> >(); - v.put_value(oss.str()); return v; - } + pmc_to_ptree_try(std::complex<float>); + pmc_to_ptree_try(std::complex<double>); //determine string pmc_to_ptree_try(std::string); @@ -144,6 +144,8 @@ ptree gras::pmc_to_ptree(const PMCC &value) pmc_to_ptree_tryv(unsigned long long); pmc_to_ptree_tryv(float); pmc_to_ptree_tryv(double); + pmc_to_ptree_tryv(std::complex<float>); + pmc_to_ptree_tryv(std::complex<double>); return v; } diff --git a/lib/task_done.cpp b/lib/task_done.cpp index f25810e..87129ea 100644 --- a/lib/task_done.cpp +++ b/lib/task_done.cpp @@ -62,7 +62,7 @@ void BlockActor::mark_done(void) worker->post_downstream(i, InputCheckMessage()); } - if (ARMAGEDDON) std::cerr + if (DONE_PRINTS) std::cerr << "==================================================\n" << "== The " << name << " is done...\n" << "==================================================\n" diff --git a/lib/top_block.cpp b/lib/top_block.cpp index 240f417..cf0fdaa 100644 --- a/lib/top_block.cpp +++ b/lib/top_block.cpp @@ -17,11 +17,6 @@ TopBlock::TopBlock(const std::string &name): (*this)->executor.reset(new Apology::Executor((*this)->topology.get())); (*this)->token = Token::make(); (*this)->thread_group = SharedThreadGroup(new boost::thread_group()); - if (GENESIS) std::cerr - << "===================================================\n" - << "== Top Block Created: " << name << "\n" - << "===================================================\n" - << std::flush; } TopBlock::~TopBlock(void) @@ -34,11 +29,6 @@ void ElementImpl::top_block_cleanup(void) this->bcast_prio_msg(TopInertMessage()); this->topology->clear_all(); this->executor->commit(); - if (ARMAGEDDON) std::cerr - << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" - << "xx Top Block Destroyed: " << name << "\n" - << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" - << std::flush; } const GlobalBlockConfig &TopBlock::global_config(void) const diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 797f858..761239e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,6 +14,7 @@ if (NOT Boost_FOUND) endif() set(test_sources + chrono_time_test.cpp block_props_test.cpp serialize_tags_test.cpp ) diff --git a/tests/chrono_time_test.cpp b/tests/chrono_time_test.cpp new file mode 100644 index 0000000..d7f76ad --- /dev/null +++ b/tests/chrono_time_test.cpp @@ -0,0 +1,28 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#include <boost/test/unit_test.hpp> +#include <iostream> + +#include <gras/chrono.hpp> +#include <boost/thread/thread.hpp> //sleep + +BOOST_AUTO_TEST_CASE(test_chrono_time) +{ + for (size_t trial_i = 0; trial_i < 100; trial_i++) + { + const double sleep_secs = 0.01 + trial_i*0.0001; + gras::time_ticks_t t0 = gras::time_now(); + boost::this_thread::sleep(boost::posix_time::milliseconds(long(sleep_secs*1000))); + gras::time_ticks_t t1 = gras::time_now(); + + std::cout << "t0 " << t0 << std::endl; + std::cout << "t1 " << t1 << std::endl; + BOOST_CHECK(t1 > t0); + + const double delta_time = double(t1-t0)/gras::time_tps(); + std::cout << "delta_time " << delta_time << std::endl; + const double low_margin = sleep_secs - sleep_secs/2; + const double high_margin = sleep_secs + sleep_secs/2; + BOOST_CHECK(delta_time < high_margin and delta_time > low_margin); + } +} |