periodic_msg_source: outsource class definition
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <foo/periodic_msg_source.h>
|
#include "periodic_msg_source_impl.h"
|
||||||
|
|
||||||
#include <gnuradio/io_signature.h>
|
#include <gnuradio/io_signature.h>
|
||||||
#include <gnuradio/block_detail.h>
|
#include <gnuradio/block_detail.h>
|
||||||
@@ -22,13 +22,10 @@
|
|||||||
|
|
||||||
using namespace gr::foo;
|
using namespace gr::foo;
|
||||||
|
|
||||||
class periodic_msg_source_impl : public periodic_msg_source {
|
|
||||||
|
|
||||||
#define dout d_debug && std::cout
|
#define dout d_debug && std::cout
|
||||||
|
|
||||||
public:
|
periodic_msg_source_impl::periodic_msg_source_impl(pmt::pmt_t msg,
|
||||||
|
float interval, int num_msg, bool debug) :
|
||||||
periodic_msg_source_impl(pmt::pmt_t msg, float interval, int num_msg, bool debug) :
|
|
||||||
block("periodic_msg_source",
|
block("periodic_msg_source",
|
||||||
gr::io_signature::make(0, 0, 0),
|
gr::io_signature::make(0, 0, 0),
|
||||||
gr::io_signature::make(0, 0, 0)),
|
gr::io_signature::make(0, 0, 0)),
|
||||||
@@ -42,14 +39,15 @@ periodic_msg_source_impl(pmt::pmt_t msg, float interval, int num_msg, bool debug
|
|||||||
d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&periodic_msg_source_impl::run, this, this)));
|
d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&periodic_msg_source_impl::run, this, this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
~periodic_msg_source_impl() {
|
periodic_msg_source_impl::~periodic_msg_source_impl() {
|
||||||
d_finished = true;
|
d_finished = true;
|
||||||
d_thread->interrupt();
|
d_thread->interrupt();
|
||||||
d_thread->join();
|
d_thread->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void run(periodic_msg_source_impl *instance) {
|
void
|
||||||
|
periodic_msg_source_impl::run(periodic_msg_source_impl *instance) {
|
||||||
|
|
||||||
// flow graph startup delay
|
// flow graph startup delay
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(500));
|
boost::this_thread::sleep(boost::posix_time::milliseconds(500));
|
||||||
@@ -75,16 +73,6 @@ void run(periodic_msg_source_impl *instance) {
|
|||||||
message_port_pub(pmt::mp("out"), pmt::PMT_EOF);
|
message_port_pub(pmt::mp("out"), pmt::PMT_EOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
int d_num_msg;
|
|
||||||
bool d_debug;
|
|
||||||
bool d_finished;
|
|
||||||
float d_interval;
|
|
||||||
pmt::pmt_t d_msg;
|
|
||||||
boost::shared_ptr<boost::thread> d_thread;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
periodic_msg_source::sptr
|
periodic_msg_source::sptr
|
||||||
periodic_msg_source::make(pmt::pmt_t msg, float interval, int num_msg, bool debug) {
|
periodic_msg_source::make(pmt::pmt_t msg, float interval, int num_msg, bool debug) {
|
||||||
return gnuradio::get_initial_sptr(new periodic_msg_source_impl(msg, interval, num_msg, debug));
|
return gnuradio::get_initial_sptr(new periodic_msg_source_impl(msg, interval, num_msg, debug));
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_FOO_PERIODIC_MSG_SOURCE_IMPL_H
|
||||||
|
#define INCLUDED_FOO_PERIODIC_MSG_SOURCE_IMPLH
|
||||||
|
|
||||||
|
#include <foo/periodic_msg_source.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace foo {
|
||||||
|
|
||||||
|
class periodic_msg_source_impl : public periodic_msg_source {
|
||||||
|
private:
|
||||||
|
void run(periodic_msg_source_impl *instance);
|
||||||
|
|
||||||
|
int d_num_msg;
|
||||||
|
bool d_debug;
|
||||||
|
bool d_finished;
|
||||||
|
float d_interval;
|
||||||
|
pmt::pmt_t d_msg;
|
||||||
|
boost::shared_ptr<boost::thread> d_thread;
|
||||||
|
|
||||||
|
public:
|
||||||
|
periodic_msg_source_impl(pmt::pmt_t msg,
|
||||||
|
float interval, int num_msg, bool debug);
|
||||||
|
virtual ~periodic_msg_source_impl();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace foo
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_FOO_PERIODIC_MSG_SOURCE_IMPL_H */
|
||||||
Reference in New Issue
Block a user