From b01beb379773c30878d5cc6fa628ef98b52ef317 Mon Sep 17 00:00:00 2001 From: csrichter Date: Mon, 24 Apr 2017 13:30:33 +0200 Subject: [PATCH] added (WIP) stream router --- .gitignore | 1 + grc/multirds_stream_router.xml | 54 ++++++++++++++++++++++++ include/multirds/stream_router.h | 56 +++++++++++++++++++++++++ lib/stream_router_impl.cc | 70 ++++++++++++++++++++++++++++++++ lib/stream_router_impl.h | 48 ++++++++++++++++++++++ 5 files changed, 229 insertions(+) create mode 100644 grc/multirds_stream_router.xml create mode 100644 include/multirds/stream_router.h create mode 100644 lib/stream_router_impl.cc create mode 100644 lib/stream_router_impl.h diff --git a/.gitignore b/.gitignore index c81954f..ba24cc2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ python/cache apps/*.py apps/*.pyc build-manlap +*.bak diff --git a/grc/multirds_stream_router.xml b/grc/multirds_stream_router.xml new file mode 100644 index 0000000..3b29719 --- /dev/null +++ b/grc/multirds_stream_router.xml @@ -0,0 +1,54 @@ + + + stream_router + multirds_stream_router + [multirds] + import multirds + multirds.stream_router($ninputs, $noutputs) + + + Type + type + float + enum + + + + + Number of inputs + ninputs + 9 + int + + + Number of outputs + noutputs + 3 + int + + + + + in + $type + $ninputs + + + ctrl + message + + + + out + $type + $noutputs + + diff --git a/include/multirds/stream_router.h b/include/multirds/stream_router.h new file mode 100644 index 0000000..02d33c4 --- /dev/null +++ b/include/multirds/stream_router.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2017 <+YOU OR YOUR COMPANY+>. + * + * This 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, or (at your option) + * any later version. + * + * This software 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + + +#ifndef INCLUDED_MULTIRDS_STREAM_ROUTER_H +#define INCLUDED_MULTIRDS_STREAM_ROUTER_H + +#include +#include + +namespace gr { + namespace multirds { + + /*! + * \brief <+description of block+> + * \ingroup multirds + * + */ + class MULTIRDS_API stream_router : virtual public gr::sync_block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of multirds::stream_router. + * + * To avoid accidental use of raw pointers, multirds::stream_router's + * constructor is in a private implementation + * class. multirds::stream_router::make is the public interface for + * creating new instances. + */ + static sptr make(int ninputs,int noutputs); + }; + + } // namespace multirds +} // namespace gr + +#endif /* INCLUDED_MULTIRDS_STREAM_ROUTER_H */ + diff --git a/lib/stream_router_impl.cc b/lib/stream_router_impl.cc new file mode 100644 index 0000000..01ef6a3 --- /dev/null +++ b/lib/stream_router_impl.cc @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2017 <+YOU OR YOUR COMPANY+>. + * + * This 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, or (at your option) + * any later version. + * + * This software 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "stream_router_impl.h" + +namespace gr { + namespace multirds { + + stream_router::sptr + stream_router::make(int ninputs,int noutputs) + { + return gnuradio::get_initial_sptr + (new stream_router_impl(ninputs, noutputs)); + } + + /* + * The private constructor + */ + stream_router_impl::stream_router_impl(int ninputs,int noutputs) + : gr::sync_block("stream_router", + gr::io_signature::make(1, 1, sizeof(float)), + gr::io_signature::make(1, 1, sizeof(float))) + {} + + /* + * Our virtual destructor. + */ + stream_router_impl::~stream_router_impl() + { + } + + int + stream_router_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + // Do <+signal processing+> + + // Tell runtime system how many output items we produced. + return noutput_items; + } + + } /* namespace multirds */ +} /* namespace gr */ + diff --git a/lib/stream_router_impl.h b/lib/stream_router_impl.h new file mode 100644 index 0000000..4ec443a --- /dev/null +++ b/lib/stream_router_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2017 <+YOU OR YOUR COMPANY+>. + * + * This 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, or (at your option) + * any later version. + * + * This software 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_MULTIRDS_STREAM_ROUTER_IMPL_H +#define INCLUDED_MULTIRDS_STREAM_ROUTER_IMPL_H + +#include + +namespace gr { + namespace multirds { + + class stream_router_impl : public stream_router + { + private: + // Nothing to declare in this block. + + public: + stream_router_impl(int ninputs,int noutputs); + ~stream_router_impl(); + + // Where all the action really happens + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace multirds +} // namespace gr + +#endif /* INCLUDED_MULTIRDS_STREAM_ROUTER_IMPL_H */ +