From dee26d1c3360303a1d9db6941d214ae443399eb5 Mon Sep 17 00:00:00 2001 From: eb Date: Thu, 17 Aug 2006 01:10:20 +0000 Subject: [PATCH] merged in mblock work-in-progress git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3331 221aa14e-8319-0410-a670-987f0aec2ac5 --- Makefile.common | 3 ++ config/Makefile.am | 1 + config/grc_mblock.m4 | 34 ++++++++++++ configure.ac | 1 + mblock/AUTHORS | 1 + mblock/ChangeLog | 20 +++++++ mblock/Makefile.am | 25 +++++++++ mblock/README | 22 ++++++++ mblock/doc/Makefile.am | 43 +++++++++++++++ mblock/src/Makefile.am | 22 ++++++++ mblock/src/lib/Makefile.am | 82 +++++++++++++++++++++++++++++ mblock/src/lib/mb_common.h | 29 ++++++++++ mblock/src/lib/mb_mblock.h | 26 +++++++++ mblock/src/lib/mb_message.cc | 41 +++++++++++++++ mblock/src/lib/mb_message.h | 66 +++++++++++++++++++++++ mblock/src/lib/mb_protocol_class.cc | 44 ++++++++++++++++ mblock/src/lib/mb_protocol_class.h | 62 ++++++++++++++++++++++ 17 files changed, 522 insertions(+) create mode 100644 config/grc_mblock.m4 create mode 100644 mblock/AUTHORS create mode 100644 mblock/ChangeLog create mode 100644 mblock/Makefile.am create mode 100644 mblock/README create mode 100644 mblock/doc/Makefile.am create mode 100644 mblock/src/Makefile.am create mode 100644 mblock/src/lib/Makefile.am create mode 100644 mblock/src/lib/mb_common.h create mode 100644 mblock/src/lib/mb_mblock.h create mode 100644 mblock/src/lib/mb_message.cc create mode 100644 mblock/src/lib/mb_message.h create mode 100644 mblock/src/lib/mb_protocol_class.cc create mode 100644 mblock/src/lib/mb_protocol_class.h diff --git a/Makefile.common b/Makefile.common index 3bf752f9..4ce123be 100644 --- a/Makefile.common +++ b/Makefile.common @@ -68,6 +68,9 @@ USRP_INCLUDES = -I$(top_srcdir)/usrp/host/lib \ USRP_LIBS = -L$(top_builddir)/usrp/host/lib \ -lusrp +PMT_INCLUDES = -I$(top_srcdir)/pmt/src/lib +PMT_LIBS = -L$(top_builddir)/pmt/src/lib -lpmt + # This used to be set in configure.ac but is now defined here for all # Makefiles when this fragment is included. STD_DEFINES_AND_INCLUDES=$(DEFINES) $(GNURADIO_INCLUDES) $(BOOST_CFLAGS) diff --git a/config/Makefile.am b/config/Makefile.am index 53d80708..f2ad470e 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -49,6 +49,7 @@ m4macros = \ grc_gr_usrp.m4 \ grc_gr_video_sdl.m4 \ grc_gr_wxgui.m4 \ + grc_mblock.m4 \ gr_check_createfilemapping.m4 \ gr_check_mc4020.m4 \ gr_check_shm_open.m4 \ diff --git a/config/grc_mblock.m4 b/config/grc_mblock.m4 new file mode 100644 index 00000000..b98fb790 --- /dev/null +++ b/config/grc_mblock.m4 @@ -0,0 +1,34 @@ +dnl Copyright 2001,2002,2003,2004,2005,2006 Free Software Foundation, Inc. +dnl +dnl This file is part of GNU Radio +dnl +dnl GNU Radio is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2, or (at your option) +dnl any later version. +dnl +dnl GNU Radio is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with GNU Radio; see the file COPYING. If not, write to +dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +dnl Boston, MA 02111-1307, USA. + +AC_DEFUN([GRC_MBLOCK],[ + AC_CONFIG_SRCDIR([mblock/src/lib/mb_mblock.h]) + + AC_CONFIG_FILES([\ + mblock/Makefile \ + mblock/doc/Makefile \ + mblock/src/Makefile \ + mblock/src/lib/Makefile + ]) + + dnl run_tests is created from run_tests.in. Make it executable. + dnl AC_CONFIG_COMMANDS([run_tests_mblock], [chmod +x mblock/src/python/run_tests]) + + subdirs="$subdirs mblock" +]) diff --git a/configure.ac b/configure.ac index 4af5d06d..3e3a0e16 100644 --- a/configure.ac +++ b/configure.ac @@ -169,6 +169,7 @@ GRC_GR_RADIO_ASTRONOMY GRC_GR_VIDEO_SDL GRC_GR_WXGUI GRC_PMT +GRC_MBLOCK dnl this must come after GRC_PMT GRC_GR_TRELLIS dnl GRC_EZDOP dnl disable until grc_ezdop.m4 fixed dnl GRC_GR_EZDOP dnl this must come after GRC_EZDOP diff --git a/mblock/AUTHORS b/mblock/AUTHORS new file mode 100644 index 00000000..ee4560a5 --- /dev/null +++ b/mblock/AUTHORS @@ -0,0 +1 @@ +Eric Blossom diff --git a/mblock/ChangeLog b/mblock/ChangeLog new file mode 100644 index 00000000..385dbc6d --- /dev/null +++ b/mblock/ChangeLog @@ -0,0 +1,20 @@ +# +# Copyright 2006 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 2, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# diff --git a/mblock/Makefile.am b/mblock/Makefile.am new file mode 100644 index 00000000..d16c4691 --- /dev/null +++ b/mblock/Makefile.am @@ -0,0 +1,25 @@ +# +# Copyright 2004 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 2, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = src +DIST_SUBDIRS = src doc diff --git a/mblock/README b/mblock/README new file mode 100644 index 00000000..cfb0beb7 --- /dev/null +++ b/mblock/README @@ -0,0 +1,22 @@ +# +# Copyright 2006 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 2, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +The "Message block" implementation. diff --git a/mblock/doc/Makefile.am b/mblock/doc/Makefile.am new file mode 100644 index 00000000..2774a844 --- /dev/null +++ b/mblock/doc/Makefile.am @@ -0,0 +1,43 @@ +# +# Copyright 2004,2005,2006 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 2, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +TARGETS = + + +# To avoid build problems for folks who don't have xmlto installed, we +# don't build the docs by default. + +# html: $(TARGETS) +all: $(TARGETS) + + +EXTRA_DIST = + +BUILT_XML_FILES = + + +# ---------------------------------------------------------------- + +clean: + -rm -f $(TARGETS) $(BUILT_XML_FILES) + +%.html : %.xml + xmlto html-nochunks $< diff --git a/mblock/src/Makefile.am b/mblock/src/Makefile.am new file mode 100644 index 00000000..8b32a223 --- /dev/null +++ b/mblock/src/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2004,2006 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 2, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +SUBDIRS = lib diff --git a/mblock/src/lib/Makefile.am b/mblock/src/lib/Makefile.am new file mode 100644 index 00000000..74f1311c --- /dev/null +++ b/mblock/src/lib/Makefile.am @@ -0,0 +1,82 @@ +# +# Copyright 2006 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 2, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +include $(top_srcdir)/Makefile.common + +INCLUDES = $(PMT_INCLUDES) $(BOOST_CFLAGS) $(CPPUNIT_INCLUDES) + +# TESTS = test_mblock + +lib_LTLIBRARIES = libmblock.la libmblock-qa.la + +EXTRA_DIST = + + +# These are the source files that go into the mblock shared library +libmblock_la_SOURCES = \ + mb_message.cc \ + mb_protocol_class.cc + + +# magic flags +libmblock_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version + +# link the library against the c++ standard library +libmblock_la_LIBADD = \ + $(PMT_LIBS) \ + -lstdc++ + +include_HEADERS = \ + mb_mblock.h \ + mb_common.h \ + mb_message.h \ + mb_protocol_class.h + +noinst_HEADERS = + + +# Build the qa code into its own library + +libmblock_qa_la_SOURCES = + + +# magic flags +libmblock_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version + +# link the library against the c++ standard library +libmblock_qa_la_LIBADD = \ + libmblock.la \ + $(CPPUNIT_LIBS) \ + -lstdc++ + + +#noinst_PROGRAMS = \ +# test_mblock + + +LIBMBLOCK = libmblock.la +LIBMBLOCKQA = libmblock-qa.la $(LIBMBLOCK) + +#test_mblock_SOURCES = test_mblock.cc +#test_mblock_LDADD = $(LIBMBLOCKQA) + + +CLEANFILES = $(BUILT_SOURCES) *.pyc diff --git a/mblock/src/lib/mb_common.h b/mblock/src/lib/mb_common.h new file mode 100644 index 00000000..abeb0657 --- /dev/null +++ b/mblock/src/lib/mb_common.h @@ -0,0 +1,29 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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 2, or (at your option) + * any later version. + * + * GNU Radio 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_MB_COMMON_H +#define INCLUDED_MB_COMMON_H + +#include + +typedef unsigned int mb_pri_t; +static const mb_pri_t MB_PRI_DEFAULT = 5; + +#endif /* INCLUDED_MB_COMMON_H */ diff --git a/mblock/src/lib/mb_mblock.h b/mblock/src/lib/mb_mblock.h new file mode 100644 index 00000000..db9d0a33 --- /dev/null +++ b/mblock/src/lib/mb_mblock.h @@ -0,0 +1,26 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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 2, or (at your option) + * any later version. + * + * GNU Radio 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_MB_MBLOCK_H +#define INCLUDED_MB_MBLOCK_H + +#include + +#endif /* INCLUDED_MB_MBLOCK_H */ diff --git a/mblock/src/lib/mb_message.cc b/mblock/src/lib/mb_message.cc new file mode 100644 index 00000000..f494201a --- /dev/null +++ b/mblock/src/lib/mb_message.cc @@ -0,0 +1,41 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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 2, or (at your option) + * any later version. + * + * GNU Radio 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include + +mb_message_sptr +mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority) +{ + return mb_message_sptr(new mb_message(signal, data, metadata, priority)); +} + +mb_message::mb_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority) + : d_signal(signal), d_data(data), d_metadata(metadata), d_priority(priority) +{ +} + +mb_message::~mb_message() +{ + // NOP +} diff --git a/mblock/src/lib/mb_message.h b/mblock/src/lib/mb_message.h new file mode 100644 index 00000000..ee88d79f --- /dev/null +++ b/mblock/src/lib/mb_message.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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 2, or (at your option) + * any later version. + * + * GNU Radio 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_MB_MESSAGE_H +#define INCLUDED_MB_MESSAGE_H + +#include + +class mb_message; +typedef boost::shared_ptr mb_message_sptr; + +/*! + * \brief construct a message and return boost::shared_ptr + * + * \param signal identifier of the message + * \param data the data to be operated on + * \param metadata information about the data + * \param priority urgency + */ +mb_message_sptr +mb_make_message(pmt_t signal, + pmt_t data = PMT_NIL, + pmt_t metadata = PMT_NIL, + mb_pri_t priority = MB_PRI_DEFAULT); + +class mb_message { + pmt_t d_signal; + pmt_t d_data; + pmt_t d_metadata; + mb_pri_t d_priority; + // foo d_rcvd_port_id; + + friend mb_message_sptr + mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority); + + // private constructor + mb_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority); + +public: + ~mb_message(); + + pmt_t signal() const { return d_signal; } + pmt_t data() const { return d_data; } + pmt_t metadata() const { return d_metadata; } + mb_pri_t priority() const { return d_priority; } + // foo rcvd_port_id const { return d_rcvd_port_id; } +}; + +#endif /* INCLUDED_MB_MESSAGE_H */ diff --git a/mblock/src/lib/mb_protocol_class.cc b/mblock/src/lib/mb_protocol_class.cc new file mode 100644 index 00000000..a34f073d --- /dev/null +++ b/mblock/src/lib/mb_protocol_class.cc @@ -0,0 +1,44 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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 2, or (at your option) + * any later version. + * + * GNU Radio 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + + +mb_protocol_class_sptr +mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing) +{ + return mb_protocol_class_sptr(new mb_protocol_class(name, incoming, outgoing)); +} + +mb_protocol_class::mb_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing) + : d_name(name), d_incoming(incoming), d_outgoing(outgoing) +{ +} + +mb_protocol_class_sptr +mb_protocol_class::conj() const +{ + return mb_make_protocol_class(name(), outgoing(), incoming()); +} diff --git a/mblock/src/lib/mb_protocol_class.h b/mblock/src/lib/mb_protocol_class.h new file mode 100644 index 00000000..771a63e0 --- /dev/null +++ b/mblock/src/lib/mb_protocol_class.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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 2, or (at your option) + * any later version. + * + * GNU Radio 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_MB_PROTOCOL_CLASS_H +#define INCLUDED_MB_PROTOCOL_CLASS_H + +#include + +// FIXME maybe this should just be a pmt_t aggregate??? + +class mb_protocol_class; +typedef boost::shared_ptr mb_protocol_class_sptr; + +/*! + * \brief construct a protocol_class and return boost::shared_ptr + * + * \param name the name of the class (symbol) + * \param incoming incoming message set (dict: keys are message types) + * \param outgoing outgoing message set (dict: keys are message types) + */ +mb_protocol_class_sptr +mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing); + +class mb_protocol_class { + pmt_t d_name; + pmt_t d_incoming; + pmt_t d_outgoing; + + friend mb_protocol_class_sptr + mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing); + + // private constructor + mb_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing); + +public: + ~mb_protocol_class(); + + pmt_t name() const { return d_name; } + pmt_t incoming() const { return d_incoming; } + pmt_t outgoing() const { return d_outgoing; } + + mb_protocol_class_sptr conj() const; // return the conjugate of this protocol class +}; + +#endif /* INCLUDED_MB_PROTOCOL_CLASS_H */ -- 2.30.2