├── AUTHORS ├── apps ├── .gitignore └── burst_view.py ├── grc ├── .gitignore ├── CMakeLists.txt ├── es_arb.xml ├── es_handler_passthrough.xml ├── es_emit_event.xml ├── es_handler_print.xml ├── es_handler_pdu.xml ├── es_handler_file.xml ├── es_trigger_timer.xml ├── es_patterned_interleaver.xml ├── patterned_interleaver.xml ├── variable_es_init.xml ├── es_trigger_sample_timer.xml ├── es_trigger_edge_f.xml ├── variable_es_evt.xml ├── es_source.xml └── es_sink.xml ├── include ├── .gitignore └── es │ ├── .gitignore │ ├── es_exceptions.h │ ├── es_event.h │ ├── es_event_acceptor.h │ ├── es_handler_python.h │ ├── es_eh_pair.hh │ ├── es_handler_insert_vector.h │ ├── es_handler_passthrough.h │ ├── es.h │ ├── es_gen_vector.h │ ├── es_handler_pdu.h │ ├── es_handler_print.h │ ├── es_handler_file.h │ ├── es_handler.h │ ├── es_handler_flowgraph.h │ ├── es_patterned_interleaver.h │ ├── es_vector_sink.hh │ ├── es_trigger_edge_f.h │ ├── es_vector_source.hh │ ├── es_source_thread.hh │ ├── es_trigger_sample_timer.h │ ├── es_event_loop_thread.hh │ ├── es_trigger.h │ ├── es_source.h │ ├── es_common.h │ ├── es_pyhandler_def.h │ └── es_queue.h ├── swig ├── es_trigger.i ├── .gitignore ├── es_event.i ├── es_handler.i ├── es_patterned_interleaver.i ├── es_trigger_edge_f.i ├── es_source.i ├── es_trigger_sample_timer.i ├── es_vector_sink.i ├── es_sink.i ├── CMakeLists.txt ├── es_vector_source.i ├── es_handlers.i ├── __init__.py ├── es_swig.i └── es_common.i ├── version.sh ├── python ├── .gitignore ├── CMakeLists.txt ├── util.py ├── qa_es_vector_sink.py ├── qa_es_vector_source.py ├── es_trigger_keyboard.py ├── __init__.py ├── run_tests.in ├── qa_es_pyhandler_def.py ├── es_trigger_timer.py ├── patterned_interleaver.py ├── test1.py └── qa_es_handler_flowgraph.py ├── lib ├── qa_es_source_t2_output.dat ├── .gitignore ├── es_exceptions.cc ├── es_vector_source.xml ├── qa_es_sink.h ├── qa_es_common.h ├── qa_es_handler.h ├── qa_es_trigger.h ├── qa_es_source.h ├── es_vector_source.i ├── test_all.cc ├── qa_es.h ├── es_handler_python.cc ├── es_handler_passthrough.cc ├── qa_es.cc ├── es_eh_pair.cc ├── qa_es_handler.cc ├── es_event.cc ├── es_patterned_interleaver.cc ├── qa_es_common.cc ├── es_handler_print.cc ├── es_handler_pdu.cc ├── es_gen_vector.cc ├── es_handler_file.cc ├── es_trigger.cc ├── qa_es_trigger.cc ├── qa_es_sink.cc ├── CMakeLists.txt ├── es_vector_sink.cc ├── es_event_loop_thread.cc ├── es_vector_source.cc ├── es_handler.cc └── es_trigger_sample_timer.cc ├── eventstream.pc.in ├── .gitignore ├── CHANGES ├── cmake └── Modules │ ├── FindLog4Cpp.cmake │ ├── FindCppUnit.cmake │ ├── GrPlatform.cmake │ ├── GnuradioEventstreamConfig.cmake │ ├── GrBoost.cmake │ ├── FindICE-3.5.cmake │ ├── GrVersion.cmake │ └── FindICE.cmake ├── README └── MANIFEST.md /AUTHORS: -------------------------------------------------------------------------------- 1 | Tim O'Shea 2 | -------------------------------------------------------------------------------- /apps/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | -------------------------------------------------------------------------------- /grc/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | -------------------------------------------------------------------------------- /include/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | 4 | -------------------------------------------------------------------------------- /include/es/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | 4 | -------------------------------------------------------------------------------- /swig/es_trigger.i: -------------------------------------------------------------------------------- 1 | 2 | class es_trigger : public gr::sync_block { 3 | 4 | }; 5 | -------------------------------------------------------------------------------- /version.sh: -------------------------------------------------------------------------------- 1 | MAJOR_VERSION=3 2 | API_COMPAT=3 3 | MINOR_VERSION=0-rc0 4 | MAINT_VERSION=0 5 | -------------------------------------------------------------------------------- /swig/.gitignore: -------------------------------------------------------------------------------- 1 | /.deps 2 | /.libs 3 | /Makefile.in 4 | /Makefile 5 | /es_swig.cc 6 | /es_swig.py 7 | /*.lo 8 | /*.la 9 | -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /.deps 4 | /.libs 5 | /*.la 6 | /*.lo 7 | /*.pyc 8 | /*.pyo 9 | /run_tests 10 | -------------------------------------------------------------------------------- /lib/qa_es_source_t2_output.dat: -------------------------------------------------------------------------------- 1 | 0.000000 2 | 0.000000 3 | 0.000000 4 | 1.000000 5 | 0.750000 6 | 0.500000 7 | 0.250000 8 | 0.000000 9 | 0.000000 10 | 0.000000 11 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /.la 4 | /.lo 5 | /.deps 6 | /.libs 7 | /*.la 8 | /*.lo 9 | /*.pyc 10 | /*.o 11 | /es.cc 12 | /es.py 13 | /test_all 14 | -------------------------------------------------------------------------------- /lib/es_exceptions.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | EarlyEventException::EarlyEventException(const std::string m) : msg(m) {} 4 | EarlyEventException::~EarlyEventException(){} 5 | -------------------------------------------------------------------------------- /grc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB xml_files "*.xml") 2 | set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) 3 | install(FILES ${xml_files} 4 | es_patterned_interleaver.xml DESTINATION ${grcdir} COMPONENT "eventstream_grc") 5 | 6 | -------------------------------------------------------------------------------- /eventstream.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: es 7 | Description: GR Event Stream Interface 8 | Requires: 9 | Version: @VERSION@ 10 | Libs: -L${libdir} -lwfcontrol @BOOST_LDFLAGS@ @BOOST_REGEX_LIB@ 11 | Cflags: @BOOST_CPPFLAGS@ -I${includedir} 12 | 13 | -------------------------------------------------------------------------------- /lib/es_vector_source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ####SHORT#### 4 | ####FULL#### 5 | ####MODULE#### 6 | import ####MODULE#### 7 | ####MODULE####.####SHORT####() 8 | 9 | ####XMLSINKLIST#### 10 | 11 | ####XMLSOURCELIST#### 12 | 13 | 14 | -------------------------------------------------------------------------------- /lib/qa_es_sink.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_QA_EVENTSTREAM_SINK_H 2 | #define INCLUDED_QA_EVENTSTREAM_SINK_H 3 | 4 | #include 5 | #include 6 | 7 | class qa_es_sink : public CppUnit::TestCase { 8 | 9 | CPPUNIT_TEST_SUITE (qa_es_sink); 10 | CPPUNIT_TEST (t1); 11 | CPPUNIT_TEST_SUITE_END (); 12 | 13 | private: 14 | void t1 (); 15 | }; 16 | 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /aclocal.m4 4 | /configure 5 | /config.h.in 6 | /stamp-h.in 7 | /libtool 8 | /config.log 9 | /config.h 10 | /config.cache 11 | /config.status 12 | /missing 13 | /stamp-h 14 | /stamp-h1 15 | /.deps 16 | /.libs 17 | /*.la 18 | /*.lo 19 | /autom4te.cache 20 | /*.cache 21 | /missing 22 | /make.log 23 | /py-compile 24 | /depcomp 25 | /ltmain.sh 26 | /install-sh 27 | *.pc 28 | .svn 29 | build 30 | -------------------------------------------------------------------------------- /lib/qa_es_common.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_QA_EVENTSTREAM_COMMON_h 2 | #define INCLUDED_QA_EVENTSTREAM_COMMON_h 3 | 4 | #include 5 | #include 6 | 7 | class qa_es_common : public CppUnit::TestCase { 8 | 9 | CPPUNIT_TEST_SUITE (qa_es_common); 10 | CPPUNIT_TEST (t1); 11 | CPPUNIT_TEST_SUITE_END (); 12 | 13 | private: 14 | void t1 (); 15 | }; 16 | 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /lib/qa_es_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_QA_EVENTSTREAM_HANDLER_H 2 | #define INCLUDED_QA_EVENTSTREAM_HANDLER_H 3 | 4 | #include 5 | #include 6 | 7 | class qa_es_handler : public CppUnit::TestCase { 8 | 9 | CPPUNIT_TEST_SUITE (qa_es_handler); 10 | CPPUNIT_TEST (t1); 11 | CPPUNIT_TEST_SUITE_END (); 12 | 13 | private: 14 | void t1 (); 15 | }; 16 | 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /lib/qa_es_trigger.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_QA_EVENTSTREAM_TRIGGER_H 2 | #define INCLUDED_QA_EVENTSTREAM_TRIGGER_H 3 | 4 | #include 5 | #include 6 | 7 | class qa_es_trigger : public CppUnit::TestCase { 8 | 9 | CPPUNIT_TEST_SUITE (qa_es_trigger); 10 | CPPUNIT_TEST (t1); 11 | CPPUNIT_TEST_SUITE_END (); 12 | 13 | private: 14 | void t1 (); 15 | }; 16 | 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /include/es/es_exceptions.h: -------------------------------------------------------------------------------- 1 | #ifndef ES_EXCEPTIONS_H 2 | #define ES_EXCEPTIONS_H 3 | 4 | #include 5 | #include 6 | 7 | class EarlyEventException { 8 | public: 9 | EarlyEventException(const std::string m = "early event exception!"); 10 | ~EarlyEventException(); 11 | const char* what(){ return msg.c_str();} 12 | private: 13 | std::string msg; 14 | }; 15 | 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/qa_es_source.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_QA_EVENTSTREAM_SOURCE_H 2 | #define INCLUDED_QA_EVENTSTREAM_SOURCE_H 3 | 4 | #include 5 | #include 6 | 7 | class qa_es_source : public CppUnit::TestCase { 8 | 9 | CPPUNIT_TEST_SUITE (qa_es_source); 10 | CPPUNIT_TEST (t1); 11 | CPPUNIT_TEST (t2); 12 | CPPUNIT_TEST (t3); 13 | CPPUNIT_TEST_SUITE_END (); 14 | 15 | private: 16 | void t1 (); 17 | void t2 (); 18 | void t3 (); 19 | }; 20 | 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /lib/es_vector_source.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | 3 | %include "gnuradio.i" 4 | %include "typemaps.i" 5 | 6 | %{ 7 | #include "es_vector_source.hh" 8 | %} 9 | 10 | // ---------------------------------------------------------------- 11 | GR_SWIG_BLOCK_MAGIC(es,vector_source); 12 | es_vector_source_sptr es_make_vector_source (int ); 13 | class es_vector_source : public gr::sync_block 14 | { 15 | private: 16 | es_vector_source(int ); 17 | public: 18 | 19 | }; 20 | // ---------------------------------------------------------------- 21 | 22 | 23 | -------------------------------------------------------------------------------- /grc/es_arb.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | EventStream Arbiter 4 | variable_es_arb 5 | EVENTSTREAM 6 | import es 7 | self.$(id) = $(id) = es.es_make_arbiter() 8 | 9 | 10 | value 11 | value 12 | ARB OK 13 | string 14 | 15 | 16 | initial hash 17 | hash 18 | {'someval':1, 'someval2':2} 19 | raw 20 | 21 | 22 | -------------------------------------------------------------------------------- /python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(SWIG) 2 | FIND_PACKAGE(PythonLibs) 3 | IF(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) 4 | RETURN() 5 | ENDIF() 6 | INCLUDE(GrSwig) 7 | INCLUDE(GrPython) 8 | 9 | GR_PYTHON_INSTALL( 10 | FILES 11 | es_trigger_keyboard.py 12 | es_trigger_timer.py 13 | #patterned_interleaver.py 14 | util.py 15 | DESTINATION ${GR_PYTHON_DIR}/es 16 | COMPONENT "es_py" 17 | ) 18 | 19 | # this is only here for debugging purposes 20 | # useful for grabbing segfaults under ctest 21 | #add_test(run_xterm xterm) 22 | 23 | GR_ADD_TEST(qa_es ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_es.py) 24 | -------------------------------------------------------------------------------- /grc/es_handler_passthrough.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Handler Passthrough 4 | es_handler_passthrough 5 | EVENTSTREAM 6 | import es 7 | es.es_make_handler_passthrough() 8 | 9 | 10 | handle_event 11 | message 12 | 1 13 | 14 | 15 | 16 | events_out 17 | message 18 | 1 19 | 20 | 21 | 22 | This handler passes an event pmt through to the next block. 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /grc/es_emit_event.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hier Stream Event - Emitted Event 4 | es_hier_event_emit 5 | EVENTSTREAM 6 | import es; 7 | import pmt; 8 | self.$(id) = $(id) = $evtname 9 | 10 | 11 | Event Symbol Key 12 | evtname 13 | EMITTED_EVENT_1 14 | string 15 | 16 | 17 | 18 | This block may be placed inside a Hierarchical Stream Event 19 | It indicates that the stream event may emit an event of the given type 20 | Typically the event queue to post the new event to is passed as a parameter 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /grc/es_handler_print.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Handler Print 4 | es_handler_print 5 | EVENTSTREAM 6 | import es 7 | es.es_make_handler_print($dt) 8 | 9 | 10 | Data Type 11 | dt 12 | enum 13 | 17 | 21 | 22 | 23 | 24 | handle_event 25 | message 26 | 1 27 | 28 | 29 | 30 | This handler simply prints events to STDOUT 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /swig/es_event.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | -------------------------------------------------------------------------------- /grc/es_handler_pdu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Handler to PDU 4 | es_handler_pdu 5 | EVENTSTREAM 6 | import es 7 | es.es_make_handler_pdu($dt) 8 | 9 | 10 | Data Type 11 | dt 12 | enum 13 | 17 | 21 | 22 | 23 | 24 | handle_event 25 | message 26 | 1 27 | 28 | 29 | 30 | pdus_out 31 | message 32 | 1 33 | 34 | 35 | 36 | This handler converts stream events into PDUs 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | 2 | 3 | May 14, 2014 4 | 5 | 1. es_trigger no longer inherits from es_handler, but directly from sync_block ( blocks that do both need to inherit from both now) 6 | 2. es_trigger, es_handler and es_event_acceptor are now all virtual base classes of sync block 7 | they all now take no required arguments in their constructors 8 | AND 9 | the virtual base class (sync_block) *must* be initialized directly by the class inhertiing from them 10 | i.e. class handler_foo : public es_handler { . } 11 | must implement handler_foo::handler_foo(...) : gr::sync_block("foo", iosig,iosig), ... in initializer list 12 | this change has been made in all in-tree handlers and trigger blocks, but will need to be made in any OOT modules using eventstream as well. 13 | - this change was neccisary to allow es_sink to also be an es_handler since both require access to methods in the block interface 14 | 3. there is now QA that does a bit of sanity checking on "make test" 15 | -------------------------------------------------------------------------------- /cmake/Modules/FindLog4Cpp.cmake: -------------------------------------------------------------------------------- 1 | # Locate log4cpp include paths and libraries 2 | # log4cpp can be found at http://log4cpp.sourceforge.net/ 3 | # Written by Manfred Ulz, manfred.ulz_at_tugraz.at 4 | 5 | # This module defines 6 | # LOG4CPP_INCLUDE_DIR, where to find ptlib.h, etc. 7 | # LOG4CPP_LIBRARIES, the libraries to link against to use pwlib. 8 | # LOG4CPP_FOUND, If false, don't try to use pwlib. 9 | 10 | FIND_PATH(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh 11 | PATHS 12 | "$ENV{LOG4CPP}/include" 13 | /usr/local/include 14 | /usr/include 15 | ) 16 | 17 | FIND_LIBRARY(LOG4CPP_LIBRARIES log4cpp 18 | PATHS 19 | "$ENV{LOG4CPP}/lib" 20 | /usr/local/lib 21 | /usr/lib 22 | ) 23 | 24 | SET(LOG4CPP_FOUND 0) 25 | IF(LOG4CPP_INCLUDE_DIR) 26 | IF(LOG4CPP_LIBRARIES) 27 | SET(LOG4CPP_FOUND 1) 28 | MESSAGE(STATUS "Found Log4CPP") 29 | ENDIF(LOG4CPP_LIBRARIES) 30 | ENDIF(LOG4CPP_INCLUDE_DIR) 31 | 32 | MARK_AS_ADVANCED( 33 | LOG4CPP_INCLUDE_DIR 34 | LOG4CPP_LIBRARIES 35 | ) 36 | -------------------------------------------------------------------------------- /swig/es_handler.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | %include 24 | 25 | %{ 26 | #include 27 | %} 28 | %include 29 | %template(es_handler_sptr) boost::shared_ptr; 30 | 31 | -------------------------------------------------------------------------------- /grc/es_handler_file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Handler File 4 | es_handler_file 5 | EVENTSTREAM 6 | import es 7 | es.es_make_handler_file($dt, $path, $desc) 8 | 9 | 10 | Data Type 11 | dt 12 | enum 13 | 17 | 21 | 22 | 23 | 24 | Base Path 25 | path 26 | /tmp 27 | string 28 | 29 | 30 | 31 | Descrption 32 | desc 33 | burst 34 | string 35 | 36 | 37 | 38 | handle_event 39 | message 40 | 1 41 | 42 | 43 | 44 | This handler saves event data to files 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /include/es/es_event.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | 24 | #ifndef EVENTSTREAM_EVENT_H 25 | #define EVENTSTREAM_EVENT_H 26 | 27 | #include 28 | #include 29 | 30 | using namespace pmt; 31 | 32 | #include 33 | 34 | // event is a pmt 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /cmake/Modules/FindCppUnit.cmake: -------------------------------------------------------------------------------- 1 | # http://www.cmake.org/pipermail/cmake/2006-October/011446.html 2 | # Modified to use pkg config and use standard var names 3 | 4 | # 5 | # Find the CppUnit includes and library 6 | # 7 | # This module defines 8 | # CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc. 9 | # CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit. 10 | # CPPUNIT_FOUND, If false, do not try to use CppUnit. 11 | 12 | INCLUDE(FindPkgConfig) 13 | PKG_CHECK_MODULES(PC_CPPUNIT "cppunit") 14 | 15 | FIND_PATH(CPPUNIT_INCLUDE_DIRS 16 | NAMES cppunit/TestCase.h 17 | ${PC_CPPUNIT_INCLUDE_DIR} 18 | ${CMAKE_INSTALL_PREFIX}/include 19 | PATHS 20 | /usr/local/include 21 | /usr/include 22 | ) 23 | 24 | FIND_LIBRARY(CPPUNIT_LIBRARIES 25 | NAMES cppunit 26 | HINTS ${PC_CPPUNIT_LIBDIR} 27 | ${CMAKE_INSTALL_PREFIX}/lib 28 | ${CMAKE_INSTALL_PREFIX}/lib64 29 | PATHS 30 | ${CPPUNIT_INCLUDE_DIRS}/../lib 31 | /usr/local/lib 32 | /usr/lib 33 | ) 34 | 35 | LIST(APPEND CPPUNIT_LIBRARIES ${CMAKE_DL_LIBS}) 36 | 37 | INCLUDE(FindPackageHandleStandardArgs) 38 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) 39 | MARK_AS_ADVANCED(CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) 40 | -------------------------------------------------------------------------------- /lib/test_all.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | 25 | #include 26 | 27 | int 28 | main (int argc, char **argv) 29 | { 30 | 31 | CppUnit::TextTestRunner runner; 32 | 33 | runner.addTest(qa_es::suite ()); 34 | 35 | bool was_successful = runner.run("", false); 36 | 37 | return was_successful ? 0 : 1; 38 | } 39 | -------------------------------------------------------------------------------- /grc/es_trigger_timer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Trigger System-Timer Event 4 | es_timer_trigger 5 | EVENTSTREAM 6 | import es 7 | #slurp 8 | es.es_trigger_timer("TIMER_EXPIRED_EVENT", $length, $delay, $iterations); 9 | 10 | 11 | Event Length 12 | length 13 | 5000 14 | int 15 | 16 | 17 | 18 | Delay Seconds 19 | delay 20 | 1.0 21 | real 22 | 23 | 24 | 25 | Num Iterations 26 | iterations 27 | -1 28 | int 29 | 30 | 31 | 32 | which_stream 33 | message 34 | 1 35 | 36 | 37 | 38 | timer_event 39 | message 40 | 1 41 | 42 | 43 | 44 | This block generates events on timer expiration 45 | 46 | delay - float, time in seconds 47 | 48 | iterations - number of iterations before stopping, -1 for infinite 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /lib/qa_es.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2009 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Example Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Example Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Example Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef INCLUDED_QA_EVENTSTREAM_H 24 | #define INCLUDED_QA_EVENTSTREAM_H 25 | 26 | #include 27 | 28 | //! collect all the tests for the example directory 29 | 30 | class qa_es { 31 | public: 32 | //! return suite of tests for all of example directory 33 | static CppUnit::TestSuite *suite (); 34 | }; 35 | 36 | #endif /* INCLUDED_QA_EVENTSTREAM_H */ 37 | -------------------------------------------------------------------------------- /python/util.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy; 3 | import es; 4 | from gnuradio import gr; 5 | 6 | def int_list_to_string(l1): 7 | l2 = ""; 8 | for v in l1: 9 | l2 = l2 + chr(v); 10 | return l2; 11 | 12 | 13 | 14 | def mod_bits_qpsk(strbits, syms=[0,1,3,2], pts=[-1,1j,1,-1j]): 15 | src = gr.vector_source_b(es.string_to_vector(strbits)); 16 | unpack = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST); 17 | pack = gr.pack_k_bits_bb(2); 18 | bts = gr.map_bb((syms)); 19 | mapper = gr.chunks_to_symbols_bc(pts, 1); 20 | rrc_taps = gr.firdes.root_raised_cosine(1.0, 2.0, 1.0, 0.35, 91); 21 | interp = gr.interp_fir_filter_ccc(2, (rrc_taps)) 22 | sink = gr.vector_sink_c(); 23 | tb=gr.top_block(); 24 | tb.connect(src,unpack,pack,bts,mapper,interp,sink); 25 | tb.run(); 26 | return sink.data(); 27 | 28 | 29 | def list_reverse(l1): 30 | l1 = list(l1); 31 | l1.reverse(); 32 | return l1; 33 | 34 | def list_conj_reverse(l1): 35 | l1 = list(l1); 36 | l1.reverse(); 37 | l2 = numpy.array(l1); 38 | l2.conjugate(); 39 | return l2; 40 | 41 | 42 | 43 | if __name__ == '__main__': 44 | a = [0x00, 0x01, 0x02, 0x0A, 0xFF]; 45 | b = int_list_to_string(a); 46 | c = mod_bits_qpsk(b); 47 | print c; 48 | 49 | -------------------------------------------------------------------------------- /grc/es_patterned_interleaver.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | patterned_interleaver 4 | es_patterned_interleaver 5 | es 6 | import es 7 | es.patterned_interleaver(items, itemsize, pattern) 8 | 13 | 14 | ... 15 | ... 16 | ... 17 | 18 | 19 | 24 | 25 | in 26 | 27 | 28 | 29 | 34 | 35 | out 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /include/es/es_event_acceptor.h: -------------------------------------------------------------------------------- 1 | #ifndef ES_EVENT_ACCEPTOR_H 2 | #define ES_EVENT_ACCEPTOR_H 3 | 4 | #include 5 | #include 6 | 7 | class es_event_acceptor : public virtual gr::sync_block { 8 | public: 9 | es_queue_sptr event_queue; 10 | es_event_acceptor(enum es_queue_early_behaviors eb= DISCARD, 11 | enum es_search_behaviors sb = SEARCH_BINARY) 12 | { 13 | event_acceptor_setup(eb, sb); 14 | } 15 | 16 | void event_acceptor_setup(enum es_queue_early_behaviors eb= DISCARD, 17 | enum es_search_behaviors sb = SEARCH_BINARY) 18 | { 19 | // set up event queue 20 | event_queue = es_make_queue(eb, sb); 21 | 22 | // listen for events 23 | message_port_register_in(pmt::mp("schedule_event")); 24 | set_msg_handler(pmt::mp("schedule_event"), 25 | boost::bind(&es_event_acceptor::schedule_event, this, _1)); 26 | } 27 | 28 | // handle pmt msgs in... 29 | void schedule_event(pmt::pmt_t m); 30 | 31 | // register a new event handler based on a recieved registration message 32 | void add_handlers(pmt::pmt_t h); 33 | }; 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/es/es_handler_python.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef EVENTSTREAM_HANDLER_PYTHON_H 23 | #define EVENTSTREAM_HANDLER_PYTHON_H 24 | 25 | #include 26 | #include 27 | 28 | using namespace pmt; 29 | 30 | #include 31 | 32 | class es_handler_python : public es_handler { 33 | public: 34 | es_handler_insert_vector(); 35 | void handler( pmt_t msg, gr_vector_void_star buf ); 36 | }; 37 | 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /swig/es_patterned_interleaver.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | GR_SWIG_BLOCK_MAGIC(es,patterned_interleaver); 23 | 24 | %include "std_string.i" 25 | %include "std_vector.i" 26 | 27 | es_patterned_interleaver_sptr es_make_patterned_interleaver (int items, int itemsize, std::vector pattern); 28 | 29 | class es_patterned_interleaver : public gr::sync_block 30 | { 31 | es_patterned_interleaver (int items, int itemsize, std::vector pattern); // private constructor 32 | }; 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017 Tim O'Shea 3 | # 4 | 5 | This directory contains the GNU Radio Eventstream Out-of-Tree Synchronous Stream-Event Scheduler 6 | 7 | These blocks are intended to help improve the translation of 8 | streams of data items into scheduled-finite length events 9 | occurring in the data streams in both directions. 10 | 11 | * es.sink provides the translation from stream to events 12 | * es.source provides the translation from events to streams 13 | 14 | * triggers cause events to be scheduled in es.source 15 | and es.sink block event queues. 16 | 17 | Some examples of specific triggers included are, 18 | - es_trigger_edge_f: cause an event when float stream rises 19 | above a fixed threshold value 20 | - es_trigger_sample_timer: cause an event to occur on 21 | a periodic sample increment in the stream 22 | 23 | * handlers consume events and do some ammount of signal 24 | processing on them 25 | 26 | Some example of specific handlers included are, 27 | - es_handler_print: print the event to STDOUT 28 | - es_handler_pdu: convert the event to a PDU and send 29 | it out a message port 30 | - es_handler_insert_vector: a source handler which 31 | populates an event window from a PMT vector 32 | - es_handler_file: a sink handler which writes event 33 | contents out to a file 34 | 35 | 36 | -------------------------------------------------------------------------------- /swig/es_trigger_edge_f.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | GR_SWIG_BLOCK_MAGIC(es,trigger_edge_f); 24 | 25 | 26 | es_trigger_edge_f_sptr es_make_trigger_edge_f (float thresh, int length, int lookback, int itemsize, int guard); 27 | 28 | class es_trigger_edge_f : public es_trigger 29 | { 30 | private: 31 | es_trigger_edge_f (float thresh, int length, int lookback, int itemsize, int guard); // private constructor 32 | 33 | public: 34 | void set_thresh(float thresh); 35 | 36 | float d_thresh; 37 | float d_lastval; 38 | }; 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /include/es/es_eh_pair.hh: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef ES_EH_PAIR_HH 23 | #define ES_EH_PAIR_HH 24 | 25 | #include 26 | #include 27 | using namespace pmt; 28 | 29 | class es_eh_pair { 30 | 31 | public: 32 | es_eh_pair(pmt_t event, pmt_t handler); 33 | pmt_t event; 34 | pmt_t handler; 35 | 36 | void run(); 37 | unsigned long long time(); 38 | unsigned long long length(); 39 | ~es_eh_pair(); 40 | 41 | private: 42 | es_eh_pair() {}; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/es/es_handler_insert_vector.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef EVENTSTREAM_HANDLER_INSERT_VECTOR_H 23 | #define EVENTSTREAM_HANDLER_INSERT_VECTOR_H 24 | 25 | #include 26 | #include 27 | 28 | using namespace pmt; 29 | 30 | #include 31 | 32 | es_handler_sptr es_make_handler_insert_vector(); 33 | 34 | class es_handler_insert_vector : public es_handler { 35 | public: 36 | es_handler_insert_vector(); 37 | void handler( pmt_t msg, gr_vector_void_star buf ); 38 | }; 39 | 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /lib/es_handler_python.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | es_pyhandler_def* default_handler(int index, void* clientdata){ 29 | printf("DEFAULT HANDLER CALLED (index = %d)!\n",index); 30 | es_pyhandler_def* hd = new es_pyhandler_def(); 31 | return hd; 32 | } 33 | 34 | es_handler_python::es_handler_python( ){ 35 | } 36 | 37 | //void es_handler_insert_vector::handler( pmt_t msg, void* buf ){ 38 | void es_handler_python::handler( pmt_t msg, gr_vector_void_star buf ){ 39 | } 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /swig/es_source.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | GR_SWIG_BLOCK_MAGIC(es,source); 24 | %include "std_string.i" 25 | %include "std_vector.i" 26 | 27 | 28 | 29 | es_source_sptr es_make_source ( std::vector out_sig, int nthreads, enum es_queue_early_behaviors eb = DISCARD, enum es_source_merge_behavior = MEMCPY); 30 | 31 | class es_source : public gr::sync_block 32 | { 33 | public: 34 | void set_max(unsigned long long maxlen); 35 | unsigned long long time(); 36 | 37 | private: 38 | es_source ( std::vector out_sig, int nthreads, enum es_queue_early_behaviors eb = DISCARD); 39 | }; 40 | -------------------------------------------------------------------------------- /python/qa_es_vector_sink.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright 2011 Free Software Foundation, Inc. 3 | # 4 | # This file is part of gr-eventstream 5 | # 6 | # gr-eventstream is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # gr-eventstream is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with gr-eventstream; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | 21 | 22 | from gnuradio import gr; 23 | import es; 24 | import numpy; 25 | 26 | 27 | src = gr.vector_source_b([0,1,2,3,4,5,6,7,8,9]); 28 | s2v = gr.stream_to_vector(1,2); 29 | sink = es.vector_sink( [1, 2] ); 30 | 31 | tb = gr.top_block(); 32 | 33 | tb.connect(src, (sink,0)); 34 | tb.connect(src, s2v, (sink,1)); 35 | 36 | tb.run(); 37 | 38 | data = sink.strvec(); 39 | 40 | 41 | types = [ numpy.byte, numpy.int16 ]; 42 | for i in range(0, len(data)): 43 | d = data[i]; 44 | t = types[i]; 45 | v = numpy.fromstring( d, dtype=t ); 46 | print v; 47 | print len(v); 48 | 49 | -------------------------------------------------------------------------------- /include/es/es_handler_passthrough.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef EVENTSTREAM_HANDLER_PASSTHROUGH_H 23 | #define EVENTSTREAM_HANDLER_PASSTHROUGH_H 24 | 25 | #include 26 | #include 27 | 28 | 29 | 30 | using namespace pmt; 31 | 32 | #include 33 | 34 | 35 | class es_handler_passthrough : public es_handler { 36 | public: 37 | es_handler_passthrough(); 38 | //void handler( pmt_t msg, void* buf ); 39 | 40 | void handler( pmt_t msg, gr_vector_void_star buf ); 41 | }; 42 | 43 | es_handler_sptr es_make_handler_passthrough(); 44 | 45 | #endif 46 | 47 | 48 | -------------------------------------------------------------------------------- /include/es/es.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef EVENTSTREAM_H 24 | #define EVENTSTREAM_H 25 | 26 | 27 | #include 28 | #include 29 | //#include 30 | #include 31 | #include 32 | //#include 33 | #include 34 | 35 | #include 36 | #include 37 | //#include 38 | //#include 39 | 40 | #include 41 | #include 42 | 43 | #include 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /python/qa_es_vector_source.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright 2011 Free Software Foundation, Inc. 3 | # 4 | # This file is part of gr-eventstream 5 | # 6 | # gr-eventstream is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # gr-eventstream is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with gr-eventstream; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | 21 | 22 | from gnuradio import gr; 23 | import es; 24 | import numpy; 25 | 26 | 27 | src = es.vector_source( [1,2] ); 28 | 29 | sink1 = gr.vector_sink_b(); 30 | sink2 = gr.vector_sink_s(); 31 | 32 | tb = gr.top_block(); 33 | 34 | tb.connect( (src,0), (sink1,0) ); 35 | tb.connect( (src,1), (sink2,0) ); 36 | 37 | tb.run(); 38 | print sink1.data(); 39 | print sink2.data(); 40 | 41 | d1 = numpy.arange(0,30,3,numpy.byte); 42 | d2 = numpy.arange(0,20,2,numpy.int16); 43 | 44 | s1 = d1.tostring(); 45 | s2 = d2.tostring(); 46 | 47 | src.set_data( es.StrVector( [s1,s2] ) , 10 ); 48 | 49 | tb.run(); 50 | print sink1.data(); 51 | print sink2.data(); 52 | 53 | -------------------------------------------------------------------------------- /swig/es_trigger_sample_timer.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | GR_SWIG_BLOCK_MAGIC(es,trigger_sample_timer); 24 | 25 | 26 | es_trigger_sample_timer_sptr es_make_trigger_sample_timer ( int itemsize, int period, int shift, int sched_dist, int event_length); 27 | 28 | class es_trigger_sample_timer : public gr::sync_block 29 | { 30 | private: 31 | es_trigger_sample_timer ( int itemsize, int period, int shift, int sched_dist, int event_length); 32 | public: 33 | int d_period; 34 | int d_itemsize; 35 | int d_shift; 36 | int d_sched_dist; 37 | int d_evt_len; 38 | uint64_t d_evt_time; 39 | uint64_t d_time; 40 | bool d_enabled; 41 | }; 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /python/es_trigger_keyboard.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from gnuradio import gr; 4 | import es; 5 | import threading; 6 | import time; 7 | import pmt; 8 | import sys; 9 | 10 | class es_trigger_keyboard(threading.Thread): 11 | def __init__(self, queue, evt_type, evt_length): 12 | threading.Thread.__init__(self); 13 | import Tkinter as tk 14 | self.d_type = evt_type; 15 | self.key_sym = pmt.intern("key"); 16 | self.queue = queue; 17 | self.evt_length = evt_length; 18 | try: 19 | self.queue.register_event_type( pmt.intern( self.d_type ) ); 20 | except: 21 | print "queue must be a valid es.queue !" 22 | sys.exit(-1); 23 | 24 | def run(self): 25 | print "running"; 26 | root = tk.Tk(); 27 | frame = tk.Frame(root,width=100,height=100); 28 | frame.bind("", self.keypress); 29 | frame.pack(); 30 | frame.focus_set(); 31 | root.mainloop(); 32 | 33 | def keypress(self, event): 34 | x = event.char; 35 | print "KEYPRESS!: %s"%(x); 36 | key_evt = es.event_create(self.d_type, 0, self.evt_length); 37 | key_evt = es.event_args_add( key_evt, self.key_sym, pmt.intern(str(x)) ); 38 | self.queue.add_event( key_evt ); 39 | 40 | 41 | if __name__ == '__main__': 42 | queue = es.queue(); 43 | queue.set_early_behavior(1); 44 | a = es_trigger_keyboard(queue, "TYPE1"); 45 | a.start(); 46 | print "Start returned waiting for main thread to join ... " 47 | a.join(); 48 | 49 | 50 | -------------------------------------------------------------------------------- /lib/es_handler_passthrough.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | es_handler_sptr es_make_handler_passthrough(){ 28 | return es_handler_sptr(new es_handler_passthrough()); 29 | } 30 | 31 | es_handler_passthrough::es_handler_passthrough() : 32 | gr::sync_block ("es_handler_passthrough", 33 | gr::io_signature::make(0,0,0), 34 | gr::io_signature::make(0,0,0)) 35 | { 36 | message_port_register_out(pmt::mp("events_out")); 37 | } 38 | 39 | void es_handler_passthrough::handler( pmt_t msg, gr_vector_void_star buf ){ 40 | message_port_pub(pmt::mp("events_out"), msg); 41 | } 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /lib/qa_es.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | /* 24 | * This class gathers together all the test cases for the example 25 | * directory into a single test suite. As you create new test cases, 26 | * add them here. 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | //#include 35 | 36 | CppUnit::TestSuite * 37 | qa_es::suite() 38 | { 39 | CppUnit::TestSuite *s = new CppUnit::TestSuite("es"); 40 | 41 | s->addTest(qa_es_source::suite()); 42 | s->addTest(qa_es_sink::suite()); 43 | s->addTest(qa_es_common::suite()); 44 | s->addTest(qa_es_trigger::suite()); 45 | return s; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /swig/es_vector_sink.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | %include "gnuradio.i" 24 | %include "typemaps.i" 25 | %include "std_string.i" 26 | %include "std_vector.i" 27 | 28 | %{ 29 | #include 30 | %} 31 | 32 | 33 | // ---------------------------------------------------------------- 34 | GR_SWIG_BLOCK_MAGIC(es,vector_sink); 35 | es_vector_sink_sptr es_make_vector_sink ( const std::vector &io_def ); 36 | class es_vector_sink : public gr::sync_block 37 | { 38 | private: 39 | es_vector_sink(const std::vector &io_def ); 40 | public: 41 | void clear(); 42 | void resize(uint64_t n_items); 43 | std::vector strvec(); 44 | }; 45 | // ---------------------------------------------------------------- 46 | 47 | 48 | -------------------------------------------------------------------------------- /include/es/es_gen_vector.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef ES_GEN_VECTOR_F 24 | #define ES_GEN_VECTOR_F 25 | 26 | #include 27 | 28 | pmt_t pmt_float_vector( std::vector< float > ); 29 | pmt_t pmt_complex_vector( std::vector< gr_complex > vec ); 30 | 31 | pmt_t event_create_gen_vector_f ( unsigned long long time, pmt_t float_list ); 32 | pmt_t event_create_gen_vector_c ( unsigned long long time, pmt_t cpx_list ); 33 | pmt_t event_create_gen_vector_b ( unsigned long long time, pmt_t u8_list, int itemsize ); 34 | pmt_t event_create_gen_vector( unsigned long long time, pmt_t vectors, gr::io_signature::sptr _sig ); 35 | 36 | //pmt_t event_create_gen_vector_b ( unsigned long long time, pmt_t u8_list, int itemsize ); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/es/es_handler_pdu.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef EVENTSTREAM_HANDLER_PDU_H 23 | #define EVENTSTREAM_HANDLER_PDU_H 24 | 25 | #include 26 | #include 27 | 28 | 29 | 30 | using namespace pmt; 31 | 32 | #include 33 | 34 | 35 | class es_handler_pdu : public es_handler { 36 | public: 37 | enum DATATYPE { 38 | TYPE_F32, 39 | TYPE_C32 40 | }; 41 | 42 | es_handler_pdu( DATATYPE type ); 43 | //void handler( pmt_t msg, void* buf ); 44 | 45 | void handler( pmt_t msg, gr_vector_void_star buf ); 46 | DATATYPE d_type; 47 | }; 48 | 49 | es_handler_sptr es_make_handler_pdu(es_handler_pdu::DATATYPE type); 50 | 51 | #endif 52 | 53 | 54 | -------------------------------------------------------------------------------- /include/es/es_handler_print.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef EVENTSTREAM_HANDLER_PRINT_H 23 | #define EVENTSTREAM_HANDLER_PRINT_H 24 | 25 | #include 26 | #include 27 | 28 | 29 | 30 | using namespace pmt; 31 | 32 | #include 33 | 34 | 35 | class es_handler_print : public es_handler { 36 | public: 37 | enum DATATYPE { 38 | TYPE_F32, 39 | TYPE_C32 40 | }; 41 | 42 | es_handler_print( DATATYPE type ); 43 | //void handler( pmt_t msg, void* buf ); 44 | 45 | void handler( pmt_t msg, gr_vector_void_star buf ); 46 | DATATYPE d_type; 47 | }; 48 | 49 | es_handler_sptr es_make_handler_print(es_handler_print::DATATYPE type); 50 | 51 | #endif 52 | 53 | 54 | -------------------------------------------------------------------------------- /lib/es_eh_pair.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | es_eh_pair::es_eh_pair(pmt_t _event, pmt_t _handler) : 29 | handler(_handler), 30 | event(_event) 31 | { 32 | 33 | } 34 | 35 | void es_eh_pair::run(){ 36 | 37 | // new style handler call 38 | es_handler* h = boost::any_cast< es_handler* >(pmt::any_ref(handler)); 39 | h->handler_helper( event ); 40 | 41 | } 42 | 43 | 44 | unsigned long long es_eh_pair::time(){ 45 | return event_time( event ); 46 | } 47 | 48 | unsigned long long es_eh_pair::length(){ 49 | return event_length( event ); 50 | } 51 | 52 | es_eh_pair::~es_eh_pair(){ 53 | // printf("es_eh_pair::destructor running.\n"); 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /swig/es_sink.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | GR_SWIG_BLOCK_MAGIC(es,sink); 23 | 24 | %include "std_string.i" 25 | %include "std_vector.i" 26 | 27 | es_sink_sptr es_make_sink (std::vector insig, int n_threads, int sample_history_in_kilosamples=64, enum es_queue_early_behaviors eb = DISCARD, enum es_search_behaviors sb = SEARCH_BINARY, enum es_congestion_behaviors = DROP); 28 | 29 | class es_sink : public gr::sync_block 30 | { 31 | es_sink (std::vector insig, int n_threads, int sample_history_in_kilosamples=64, enum es_queue_early_behaviors eb = DISCARD, enum es_search_behaviors sb = SEARCH_BINARY, enum es_congestion_behaviors = DROP); // private constructor 32 | 33 | es_queue_sptr event_queue; 34 | unsigned long long d_time; 35 | unsigned int d_history; 36 | 37 | public: 38 | void wait_events(); 39 | }; 40 | -------------------------------------------------------------------------------- /include/es/es_handler_file.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef EVENTSTREAM_HANDLER_FILE_H 23 | #define EVENTSTREAM_HANDLER_FILE_H 24 | 25 | #include 26 | #include 27 | 28 | using namespace pmt; 29 | 30 | #include 31 | 32 | 33 | class es_handler_file : public es_handler { 34 | public: 35 | enum DATATYPE { 36 | TYPE_F32, 37 | TYPE_C32 38 | }; 39 | std::string d_path, d_desc; 40 | es_handler_file( DATATYPE type, std::string path, std::string desc ); 41 | void handler( pmt_t msg, gr_vector_void_star buf ); 42 | DATATYPE d_type; 43 | }; 44 | 45 | es_handler_sptr es_make_handler_file(es_handler_file::DATATYPE type, std::string path, std::string desc); 46 | 47 | #endif 48 | 49 | 50 | -------------------------------------------------------------------------------- /MANIFEST.md: -------------------------------------------------------------------------------- 1 | title: gr-eventstream 2 | brief: The event stream scheduler 3 | tags: 4 | - scheduler 5 | - streams 6 | - bursty 7 | author: 8 | - Tim O'Shea 9 | copyright_owner: 10 | - Tim O'Shea 11 | dependencies: 12 | - gnuradio (>= 3.7.0) 13 | repo: https://github.com/osh/gr-eventstream.git 14 | stable_release: HEAD 15 | icon: https://raw.githubusercontent.com/gnuradio/pybombs/master/img/gr-eventstream.png 16 | --- 17 | 18 | These blocks are intended to help improve the translation of 19 | streams of data items into scheduled-finite length events 20 | occurring in the data streams in both directions. 21 | 22 | * es.sink provides the translation from stream to events 23 | * es.source provides the translation from events to streams 24 | 25 | * triggers cause events to be scheduled in es.source 26 | and es.sink block event queues. 27 | 28 | Some examples of specific triggers included are, 29 | - es_trigger_edge_f: cause an event when float stream rises 30 | above a fixed threshold value 31 | - es_trigger_sample_timer: cause an event to occur on 32 | a periodic sample increment in the stream 33 | 34 | * handlers consume events and do some ammount of signal 35 | processing on them 36 | 37 | Some example of specific handlers included are, 38 | - es_handler_print: print the event to STDOUT 39 | - es_handler_pdu: convert the event to a PDU and send 40 | it out a message port 41 | - es_handler_insert_vector: a source handler which 42 | populates an event window from a PMT vector 43 | - es_handler_file: a sink handler which writes event 44 | contents out to a file 45 | -------------------------------------------------------------------------------- /swig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(SWIG) 2 | FIND_PACKAGE(PythonLibs) 3 | IF(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) 4 | RETURN() 5 | ENDIF() 6 | INCLUDE(GrSwig) 7 | INCLUDE(GrPython) 8 | 9 | include_directories( 10 | ${EVENTSTREAM_INCLUDE_DIRS} 11 | ${GNURADIO_PMT_INCLUDE_DIRS} 12 | ${GNURADIO_RUNTIME_INCLUDE_DIRS} 13 | ${GNURADIO_BLOCKS_INCLUDE_DIRS} 14 | ${PYTHON_INCLUDE_DIRS} 15 | ${BOOST_INCLUDE_DIRS} 16 | ) 17 | 18 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include) 19 | FOREACH(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) 20 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}) 21 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) 22 | ENDFOREACH(incdir) 23 | FOREACH(incdir ${PMT_INCLUDE_DIRS}) 24 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}) 25 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/pmt) 26 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/pmt/swig) 27 | ENDFOREACH(incdir) 28 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${EVENTSTREAM_INCLUDE_DIRS}) 29 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${BOOST_INCLUDE_DIRS}) 30 | LIST(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include/es) 31 | 32 | link_directories(${EVENTSTREAM_LIBRARY_DIRS}) 33 | set(GR_SWIG_LIBRARIES eventstream ${LOG4CPP_LIBRARIES}) 34 | 35 | GR_SWIG_MAKE(es_swig es_swig.i) 36 | 37 | GR_SWIG_INSTALL( 38 | TARGETS es_swig 39 | DESTINATION ${GR_PYTHON_DIR}/es/ 40 | COMPONENT "es_python" 41 | ) 42 | 43 | 44 | GR_PYTHON_INSTALL( 45 | FILES __init__.py 46 | DESTINATION ${GR_PYTHON_DIR}/es/ 47 | COMPONENT "es_python" 48 | ) 49 | 50 | install( 51 | DIRECTORY ${CMAKE_SOURCE_DIR}/swig/ 52 | DESTINATION include/es/swig COMPONENT "eventstream_devel" 53 | FILES_MATCHING 54 | PATTERN "*.i" 55 | ) 56 | 57 | 58 | -------------------------------------------------------------------------------- /include/es/es_handler.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef EVENTSTREAM_HANDLER_H 23 | #define EVENTSTREAM_HANDLER_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace pmt; 30 | 31 | 32 | class es_handler; 33 | 34 | typedef boost::shared_ptr es_handler_sptr; 35 | 36 | class es_handler : public virtual gr::sync_block 37 | { 38 | public: 39 | es_handler(); 40 | gr_vector_void_star get_buffer_ptr(pmt_t buffer_pmt); 41 | void handler_helper( pmt_t msg ); 42 | virtual void handler(pmt_t msg, gr_vector_void_star buf); 43 | ~es_handler(); 44 | virtual int work (int noutput_items, 45 | gr_vector_const_void_star &input_items, 46 | gr_vector_void_star &output_items); 47 | 48 | }; 49 | 50 | #endif 51 | 52 | 53 | -------------------------------------------------------------------------------- /swig/es_vector_source.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | /* -*- c++ -*- */ 23 | 24 | %include "gnuradio.i" 25 | %include "typemaps.i" 26 | %include "std_string.i" 27 | %include "std_vector.i" 28 | 29 | %{ 30 | #include 31 | %} 32 | 33 | 34 | // ---------------------------------------------------------------- 35 | GR_SWIG_BLOCK_MAGIC(es,vector_source); 36 | es_vector_source_sptr es_make_vector_source ( const std::vector &io_def ); 37 | class es_vector_source : public gr::sync_block 38 | { 39 | private: 40 | es_vector_source(const std::vector &io_def ); 41 | public: 42 | /* void set_data(std::vector &data, int n_items, bool dealloc); */ 43 | void set_data(std::vector &data, int n_items); 44 | void rewind(); 45 | void clear(); 46 | gr_vector_const_void_star data(); 47 | }; 48 | // ---------------------------------------------------------------- 49 | 50 | 51 | -------------------------------------------------------------------------------- /include/es/es_handler_flowgraph.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef EVENTSTREAM_HANDLER_FLOWGRAPH_H 24 | #define EVENTSTREAM_HANDLER_FLOWGRAPH_H 25 | 26 | #include 27 | #include 28 | 29 | 30 | 31 | using namespace pmt; 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | class es_handler_flowgraph : public es_handler { 38 | public: 39 | 40 | es_handler_flowgraph( es_pyhandler_def* _pyhd, int pool_size ); 41 | ~es_handler_flowgraph(); 42 | void handler(pmt_t msg, gr_vector_void_star buf); 43 | 44 | es_pyhandler_def* pyhd; 45 | 46 | std::vector< es_pyhandler* > d_pyhandlers; 47 | boost::lockfree::queue d_free_pyhandlers; 48 | 49 | }; 50 | 51 | es_handler_sptr es_make_handler_flowgraph(es_pyhandler_def* _pyhd, int pool_size); 52 | 53 | #endif 54 | 55 | 56 | -------------------------------------------------------------------------------- /cmake/Modules/GrPlatform.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_PLATFORM_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_PLATFORM_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Setup additional defines for OS types 27 | ######################################################################## 28 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 29 | set(LINUX TRUE) 30 | endif() 31 | 32 | if(LINUX AND EXISTS "/etc/debian_version") 33 | set(DEBIAN TRUE) 34 | endif() 35 | 36 | if(LINUX AND EXISTS "/etc/redhat-release") 37 | set(REDHAT TRUE) 38 | endif() 39 | 40 | ######################################################################## 41 | # when the library suffix should be 64 (applies to redhat linux family) 42 | ######################################################################## 43 | if(NOT DEFINED LIB_SUFFIX AND REDHAT AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$") 44 | set(LIB_SUFFIX 64) 45 | endif() 46 | set(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix") 47 | -------------------------------------------------------------------------------- /python/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2008,2009 Free Software Foundation, Inc. 3 | # 4 | # This application is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 3, or (at your option) 7 | # any later version. 8 | # 9 | # This application is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | # 18 | 19 | # The presence of this file turns this directory into a Python package 20 | 21 | # ---------------------------------------------------------------- 22 | # Temporary workaround for ticket:181 (swig+python problem) 23 | import sys 24 | _RTLD_GLOBAL = 0 25 | try: 26 | from dl import RTLD_GLOBAL as _RTLD_GLOBAL 27 | except ImportError: 28 | try: 29 | from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL 30 | except ImportError: 31 | pass 32 | 33 | if _RTLD_GLOBAL != 0: 34 | _dlopenflags = sys.getdlopenflags() 35 | sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) 36 | # ---------------------------------------------------------------- 37 | 38 | 39 | # import swig generated symbols into the es namespace 40 | from es_swig import * 41 | 42 | # import any pure python here 43 | # 44 | 45 | # ---------------------------------------------------------------- 46 | # Tail of workaround 47 | if _RTLD_GLOBAL != 0: 48 | sys.setdlopenflags(_dlopenflags) # Restore original flags 49 | # ---------------------------------------------------------------- 50 | -------------------------------------------------------------------------------- /lib/qa_es_handler.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | // Test event generation, queue insertion, handler binding, general non gr-runtime operation 30 | void 31 | qa_es_handler::t1() 32 | { 33 | printf("t1\n"); 34 | es_queue_sptr q = es_make_queue(); 35 | pmt_t arb = es_make_arbiter(); 36 | es_source_sptr s = es_make_source(arb,q,sizeof(float)); 37 | std::vector const_ramp; 38 | const_ramp.push_back(1.0); 39 | const_ramp.push_back(0.75); 40 | const_ramp.push_back(0.5); 41 | const_ramp.push_back(0.25); 42 | es_event_sptr e1 = es_event_sptr(new event_gen_vector_f( arb, const_ramp )); 43 | e1->set_time(100); 44 | es_handler* h1 = new es_handler_print(); 45 | es_handler_sptr h1s( h1 ); 46 | q->register_event_type(e1->type()); 47 | q->bind_handler( e1->type(), h1s ); 48 | q->add_event(e1); 49 | q->print(); 50 | } 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /include/es/es_patterned_interleaver.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 <+YOU OR YOUR COMPANY+>. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef INCLUDED_ES_PATTERNED_INTERLEAVER_H 22 | #define INCLUDED_ES_PATTERNED_INTERLEAVER_H 23 | 24 | #include 25 | 26 | class es_patterned_interleaver; 27 | typedef boost::shared_ptr es_patterned_interleaver_sptr; 28 | 29 | es_patterned_interleaver_sptr es_make_patterned_interleaver (int items, int itemsize, std::vector pattern); 30 | 31 | /*! 32 | * \brief <+description+> 33 | * 34 | */ 35 | class es_patterned_interleaver : public gr::block 36 | { 37 | friend es_patterned_interleaver_sptr es_make_patterned_interleaver (int items, int itemsize, std::vector pattern); 38 | 39 | es_patterned_interleaver (int items, int itemsize, std::vector pattern); 40 | 41 | public: 42 | ~es_patterned_interleaver (); 43 | 44 | 45 | int general_work (int noutput_items, 46 | gr_vector_int &ninput_items, 47 | gr_vector_const_void_star &input_items, 48 | gr_vector_void_star &output_items); 49 | }; 50 | 51 | #endif /* INCLUDED_ES_PATTERNED_INTERLEAVER_H */ 52 | 53 | -------------------------------------------------------------------------------- /swig/es_handlers.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | %include 24 | // %template(es_handler_sptr) boost::shared_ptr; 25 | 26 | pmt_t pmt_float_vector( std::vector< float > vec ); 27 | pmt_t pmt_complex_vector( std::vector< gr_complex > vec ); 28 | 29 | pmt_t event_create_gen_vector_f ( unsigned long long time, pmt_t float_list ); 30 | pmt_t event_create_gen_vector_c ( unsigned long long time, pmt_t cpx_list ); 31 | 32 | class es_handler_insert_vector : public es_handler { 33 | public: 34 | es_handler_insert_vector(); 35 | void handler( pmt_t msg, gr_vector_void_star buf ); 36 | }; 37 | 38 | %include 39 | %include 40 | 41 | es_handler_sptr es_make_handler_flowgraph(es_pyhandler_def* _pyhd, int pool_size); 42 | class es_handler_flowgraph : public es_handler { 43 | public: 44 | es_handler_flowgraph( es_pyhandler_def* _pyhd, int pool_size ); 45 | void handler( pmt_t msg, gr_vector_void_star buf ); 46 | }; 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /lib/es_event.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | es_event_sptr es_make_event(pmt_t arb){ 28 | return es_event_sptr(new es_event(arb)); 29 | } 30 | 31 | es_event::es_event(pmt_t arb){ 32 | args = pmt::make_dict(); 33 | d_time = ULLONG_MAX; 34 | d_max_length = 0; 35 | d_name = "EVENT_BASE"; 36 | } 37 | 38 | void es_event::set_time(unsigned long long time){ 39 | d_time = time; 40 | } 41 | 42 | void es_event::print(){ 43 | printf("EVENT(d_time=%llu, d_name=%s)\n", d_time, d_name.c_str()); 44 | printf(" * ARGS :: \n"); 45 | 46 | // std::string out = pmt_write_string(args); 47 | // printf("RAW = %s\n", out.c_str()); 48 | 49 | pmt_t keys = pmt::dict_keys(args); 50 | for(int i=0; i 26 | #include 27 | 28 | class es_vector_sink; 29 | 30 | typedef boost::shared_ptr es_vector_sink_sptr; 31 | 32 | es_vector_sink_sptr es_make_vector_sink( const gr_vector_int &io_def ); 33 | 34 | class es_vector_sink : public gr::sync_block 35 | { 36 | private: 37 | friend es_vector_sink_sptr es_make_vector_sink (const gr_vector_int &io_def ); 38 | es_vector_sink ( const gr_vector_int &io_def ); 39 | 40 | uint64_t d_nitems; 41 | gr_vector_int d_io_def; 42 | std::vector< std::vector< char > > d_data; 43 | 44 | public: 45 | ~es_vector_sink (); 46 | int work (int noutput_items, 47 | gr_vector_const_void_star &input_items, 48 | gr_vector_void_star &output_items); 49 | void resize(uint64_t n_items); 50 | void clear(); 51 | std::vector strvec(); 52 | gr_vector_const_void_star data(); 53 | int data_len_items(); 54 | gr_vector_int shape(){ return d_io_def; } 55 | 56 | }; 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /cmake/Modules/GnuradioEventstreamConfig.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE(FindPkgConfig) 2 | PKG_CHECK_MODULES(PC_GNURADIO_EVENSTREAM eventstream) 3 | 4 | 5 | 6 | FIND_PATH( 7 | GNURADIO_EVENTSTREAM_INCLUDE_DIRS 8 | NAMES es/es.h 9 | HINTS $ENV{GNURADIO_EVENTSTREAM_DIR}/include 10 | ${PC_GNURADIO_EVENTSTREAM_INCLUDEDIR} 11 | PATHS ${CMAKE_INSTALL_PREFIX}/include/ 12 | /usr/local/include/ 13 | /usr/include/ 14 | ) 15 | 16 | if (${GNURADIO_EVENTSTREAM_INCLUDE_DIRS} STREQUAL GNURADIO_EVENTSTREAM_INCLUDE_DIRS-NOTFOUND) 17 | FIND_PATH( 18 | GNURADIO_EVENTSTREAM_INCLUDE_DIRS 19 | NAMES es/es.h 20 | HINTS $ENV{GNURADIO_EVENTSTREAM_DIR}/include 21 | ${PC_GNURADIO_EVENTSTREAM_INCLUDEDIR} 22 | PATHS ${CMAKE_INSTALL_PREFIX}/include/ 23 | /usr/local/include/ 24 | /usr/include/ 25 | 26 | NO_CMAKE_FIND_ROOT_PATH 27 | ) 28 | endif() 29 | 30 | 31 | 32 | FIND_LIBRARY( 33 | GNURADIO_EVENTSTREAM_LIBRARIES 34 | NAMES eventstream 35 | HINTS $ENV{GNURADIO_RUNTIME_DIR}/lib 36 | ${PC_GNURADIO_RUNTIME_LIBDIR} 37 | PATHS ${CMAKE_INSTALL_PREFIX}/lib64 38 | ${CMAKE_INSTALL_PREFIX}/lib 39 | /usr/local/lib 40 | /usr/local/lib64 41 | /usr/lib 42 | /usr/lib64 43 | ) 44 | 45 | if (${GNURADIO_EVENTSTREAM_LIBRARIES} STREQUAL GNURADIO_EVENTSTREAM_LIBRARIES-NOTFOUND) 46 | FIND_LIBRARY( 47 | GNURADIO_EVENTSTREAM_LIBRARIES 48 | NAMES eventstream 49 | HINTS $ENV{GNURADIO_RUNTIME_DIR}/lib 50 | ${PC_GNURADIO_RUNTIME_LIBDIR} 51 | PATHS ${CMAKE_INSTALL_PREFIX}/lib64 52 | ${CMAKE_INSTALL_PREFIX}/lib 53 | /usr/local/lib 54 | /usr/local/lib64 55 | /usr/lib 56 | /usr/lib64 57 | NO_CMAKE_FIND_ROOT_PATH 58 | ) 59 | endif() 60 | 61 | 62 | 63 | INCLUDE(FindPackageHandleStandardArgs) 64 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_EVENTSTREAM DEFAULT_MSG GNURADIO_EVENTSTREAM_LIBRARIES GNURADIO_EVENTSTREAM_INCLUDE_DIRS) 65 | MARK_AS_ADVANCED(GNURADIO_EVENTSTREAM_LIBRARIES GNURADIO_EVENTSTREAM_INCLUDE_DIRS) 66 | -------------------------------------------------------------------------------- /python/run_tests.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # All this strange PYTHONPATH manipulation is required to run our 4 | # tests using our just built shared library and swig-generated python 5 | # code prior to installation. 6 | 7 | # build tree == src tree unless you're doing a VPATH build. 8 | # If you don't know what a VPATH build is, you're not doing one. Relax... 9 | 10 | prefix=@prefix@ 11 | exec_prefix=@exec_prefix@ 12 | 13 | # Where to look in the build tree for our shared library 14 | libbld=@abs_top_builddir@/lib 15 | # Where to look in the build tree for swig generated python code 16 | libswig=@abs_top_builddir@/swig 17 | # Where to look in the src tree for hand written python code 18 | py=@abs_top_srcdir@/python 19 | 20 | # Where to look for installed GNU Radio python modules 21 | # FIXME this is wrong on a distcheck. We really need to ask gnuradio-core 22 | # where it put its python files. 23 | installed_pythondir=@pythondir@ 24 | installed_pyexecdir=@pyexecdir@ 25 | 26 | PYTHONPATH="$libbld:$libbld/.libs:$libswig:$libswig/.libs:$py:$installed_pythondir:$installed_pyexecdir:$PYTHONPATH" 27 | echo $PYTHONPATH 28 | 29 | export PYTHONPATH 30 | 31 | case "@host_os@" in 32 | darwin*) 33 | # FIXME: Code for Darwin guessed but not tested 34 | # Special Code for executing on Darwin / Mac OS X only 35 | if [ "$DYLD_LIBRARY_PATH" = "" ] 36 | then 37 | DYLD_LIBRARY_PATH=$libbld/.libs 38 | else 39 | DYLD_LIBRARY_PATH=$libbld/.libs:$DYLD_LIBRARY_PATH 40 | fi 41 | export DYLD_LIBRARY_PATH 42 | ;; 43 | cygwin*|win*|mingw*) 44 | # Special Code for executing on Win32 variants only 45 | if [ "$PATH" = "" ] 46 | then 47 | PATH=$libbld/.libs 48 | else 49 | PATH=$libbld/.libs:$PATH 50 | fi 51 | export PATH 52 | ;; 53 | esac 54 | 55 | # 56 | # This is the simple part... 57 | # Run everything that matches qa_*.py and return the final result. 58 | # 59 | 60 | ok=yes 61 | for file in @srcdir@/qa_*.py 62 | do 63 | if ! $file 64 | then 65 | ok=no 66 | fi 67 | done 68 | 69 | if [ $ok = yes ] 70 | then 71 | exit 0 72 | else 73 | exit 1 74 | fi 75 | -------------------------------------------------------------------------------- /grc/patterned_interleaver.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Patterned Interleaver 4 | patterned_interlaver 5 | Stream Conversions 6 | import es, numpy 7 | es.patterned_interleaver($type.np, $ninputs, $pattern) 8 | 9 | 10 | IO Type 11 | type 12 | enum 13 | 19 | 25 | 31 | 37 | 43 | 44 | 45 | 46 | 47 | Input Streams 48 | ninputs 49 | 2 50 | int 51 | 52 | 53 | 54 | Select Pattern 55 | pattern 56 | [0,0,1,1] 57 | int_vector 58 | 59 | 60 | 61 | in 62 | $type 63 | 1 64 | $ninputs 65 | 66 | 67 | 68 | out 69 | $type 70 | 1 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /lib/es_patterned_interleaver.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 <+YOU OR YOUR COMPANY+>. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | #include 27 | 28 | 29 | es_patterned_interleaver_sptr 30 | es_make_patterned_interleaver (int items, int itemsize, std::vector pattern) 31 | { 32 | return es_patterned_interleaver_sptr (new es_patterned_interleaver (items, itemsize, pattern)); 33 | } 34 | 35 | 36 | es_patterned_interleaver::es_patterned_interleaver (int items, int itemsize, std::vector pattern) 37 | : gr::block ("patterned_interleaver", 38 | gr::io_signature::make (1, items, itemsize), 39 | gr::io_signature::make (1, 1, itemsize)) 40 | { 41 | } 42 | 43 | 44 | es_patterned_interleaver::~es_patterned_interleaver () 45 | { 46 | } 47 | 48 | 49 | int 50 | es_patterned_interleaver::general_work (int noutput_items, 51 | gr_vector_int &ninput_items, 52 | gr_vector_const_void_star &input_items, 53 | gr_vector_void_star &output_items) 54 | { 55 | const float *in = (const float *) input_items[0]; 56 | float *out = (float *) output_items[0]; 57 | 58 | // Do <+signal processing+> 59 | 60 | // Tell runtime system how many output items we produced. 61 | return noutput_items; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /swig/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2008 Free Software Foundation, Inc. 3 | # 4 | # This file is part of GNU Radio 5 | # 6 | # GNU Radio is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # GNU Radio is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | # The presence of this file turns this directory into a Python package 22 | 23 | # ---------------------------------------------------------------- 24 | # Temporary workaround for ticket:181 (swig+python problem) 25 | import sys 26 | _RTLD_GLOBAL = 0 27 | try: 28 | from dl import RTLD_GLOBAL as _RTLD_GLOBAL 29 | except ImportError: 30 | try: 31 | from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL 32 | except ImportError: 33 | pass 34 | 35 | if _RTLD_GLOBAL != 0: 36 | _dlopenflags = sys.getdlopenflags() 37 | sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) 38 | # ---------------------------------------------------------------- 39 | 40 | 41 | # import swig generated symbols into the es namespace 42 | from es_swig import * 43 | from es.es_trigger_keyboard import *; 44 | from es.es_trigger_timer import *; 45 | #from es.patterned_interleaver import *; 46 | from es.util import *; 47 | 48 | # import any pure python here 49 | # from es_foo import bar 50 | # from es_baz import * 51 | 52 | 53 | # ---------------------------------------------------------------- 54 | # Tail of workaround 55 | if _RTLD_GLOBAL != 0: 56 | sys.setdlopenflags(_dlopenflags) # Restore original flags 57 | # ---------------------------------------------------------------- 58 | -------------------------------------------------------------------------------- /python/qa_es_pyhandler_def.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright 2011 Free Software Foundation, Inc. 3 | # 4 | # This file is part of gr-eventstream 5 | # 6 | # gr-eventstream is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # gr-eventstream is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with gr-eventstream; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | 21 | from gnuradio import gr; 22 | import es; 23 | import pmt; 24 | 25 | def test_factory_cb(index): 26 | print "test_factory_cb called with index = %d"%(index); 27 | r = es.es_pyhandler(); 28 | r.set_b2( {} ); 29 | return r; 30 | 31 | 32 | def test_hook_cb(val): 33 | print "TEST HOOK CB Called with %s :: %s"%(type(val), str(val)); 34 | print val.bufs; 35 | print val.msg; 36 | print val.handler.pb2(); 37 | r = es.es_hook_rval(); 38 | return r; 39 | 40 | 41 | ph = es.es_pyhandler_def(); 42 | 43 | # dont run with default handler, 44 | # this should assert(0) 45 | #ph.run_factory(); 46 | 47 | ph.set_pyfactory_cb(test_factory_cb); 48 | h = ph.run_factory(); 49 | 50 | ph.set_pyfactory_cb(test_factory_cb); 51 | ph.run_factory(); 52 | 53 | ph.set_pyfactory_cb(test_factory_cb); 54 | ph.run_factory(); 55 | 56 | ph.set_pyfactory_cb(test_factory_cb); 57 | ph.run_factory(); 58 | 59 | a = ph.empty_vec(); 60 | b = pmt.intern("test"); 61 | c = es.stdMapStringBlock(); 62 | 63 | ph.set_pypre_hook_cb(test_hook_cb); 64 | ph.set_pypost_hook_cb(test_hook_cb); 65 | 66 | 67 | ph.run_pre_hook(a,b,h); 68 | print "pre hook ran" 69 | 70 | ph.run_post_hook(a,b,h); 71 | print "post hook ran" 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /include/es/es_trigger_edge_f.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef INCLUDED_EVENTSTREAM_TRIGGER_EDGE_F_H 23 | #define INCLUDED_EVENTSTREAM_TRIGGER_EDGE_F_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class es_trigger_edge_f; 31 | using namespace pmt; 32 | 33 | typedef boost::shared_ptr es_trigger_edge_f_sptr; 34 | 35 | es_trigger_edge_f_sptr es_make_trigger_edge_f (float thresh, int length, int lookback, int itemsize, int guard=1); 36 | 37 | class es_trigger_edge_f : public es_trigger 38 | { 39 | private: 40 | friend es_trigger_edge_f_sptr es_make_trigger_edge_f (float thresh, int length, int lookback, int itemsize, int guard); 41 | 42 | es_trigger_edge_f (float thresh, int length, int lookback, int itemsize, int guard=1); // private constructor 43 | int d_guard; 44 | uint64_t d_lasttrigger; 45 | 46 | public: 47 | ~es_trigger_edge_f (); // public destructor 48 | int work (int noutput_items, 49 | gr_vector_const_void_star &input_items, 50 | gr_vector_void_star &output_items); 51 | 52 | void set_thresh(float thresh); 53 | 54 | float d_thresh; 55 | float d_lastval; 56 | }; 57 | 58 | #endif /* INCLUDED_EVENTSTREAM_TRIGGER_EDGE_F_H */ 59 | -------------------------------------------------------------------------------- /grc/variable_es_init.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | EVENTSTREAM Init Parameter 9 | parameter_es_init 10 | self.$(id) = $(id) 11 | $value 12 | 13 | Label 14 | label 15 | 16 | string 17 | #if $label() then 'none' else 'part'# 18 | 19 | 20 | Value 21 | value 22 | 0 23 | $type.type 24 | 25 | 26 | Type 27 | type 28 | 29 | enum 30 | #if $type() then 'none' else 'part'# 31 | 36 | 41 | 46 | 51 | 56 | 61 | 68 | 69 | 70 | Short ID 71 | short_id 72 | 73 | string 74 | #if not $type() 75 | all#slurp 76 | #elif $short_id() 77 | none#slurp 78 | #else 79 | part#slurp 80 | #end if 81 | 82 | len($short_id) in (0, 1) 83 | $short_id == '' or $(short_id).isalpha() 84 | 85 | ES Init Parameters may be used to parameterize components within the underlying event. 86 | They are set once at start up. 87 | 88 | 89 | -------------------------------------------------------------------------------- /include/es/es_vector_source.hh: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef ES_VECTOR_SOURCE_H 23 | #define ES_VECTOR_SOURCE_H 24 | 25 | #include 26 | #include 27 | 28 | class es_vector_source; 29 | 30 | typedef boost::shared_ptr es_vector_source_sptr; 31 | 32 | es_vector_source_sptr es_make_vector_source( const gr_vector_int &io_def ); 33 | 34 | class es_vector_source : public gr::sync_block 35 | { 36 | private: 37 | friend es_vector_source_sptr es_make_vector_source (const gr_vector_int &io_def ); 38 | es_vector_source ( const gr_vector_int &io_def ); 39 | 40 | gr_vector_int d_io_def; 41 | gr_vector_const_void_star d_data; 42 | uint64_t d_nitems; 43 | uint64_t d_item_offset; 44 | uint64_t items_remain(){ return d_nitems - d_item_offset; } 45 | bool d_dealloc; 46 | 47 | public: 48 | // es_vector_source ( ); 49 | ~es_vector_source (); 50 | int work (int noutput_items, 51 | gr_vector_const_void_star &input_items, 52 | gr_vector_void_star &output_items); 53 | 54 | void set_data(gr_vector_const_void_star &data, int n_items, bool dealloc); 55 | void set_data(std::vector data, int n_items); 56 | void rewind(); 57 | void clear(); 58 | gr_vector_int shape(){ return d_io_def; } 59 | gr_vector_const_void_star data(); 60 | 61 | }; 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /python/es_trigger_timer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from gnuradio import gr; 4 | import es; 5 | import threading; 6 | import time; 7 | import pmt; 8 | import sys; 9 | import time; 10 | 11 | 12 | class es_trigger_timer(gr.sync_block): 13 | def __init__(self, evt_type, evt_length, delay, count=-1): 14 | gr.sync_block.__init__(self,"timer_event",[],[]) 15 | 16 | self.message_port_register_out(pmt.intern("timer_event")); 17 | self.message_port_register_out(pmt.intern("which_stream")); 18 | 19 | self.count_init = count; 20 | self.d_type = pmt.intern("timer_event"); 21 | self.count = count; 22 | self.delay = delay; 23 | self.evt_length = evt_length; 24 | self.thread = threading.Thread(target=self.run); 25 | 26 | 27 | def start(self): 28 | self.count = self.count_init; 29 | self.thread.start(); 30 | reg = pmt.cons(pmt.intern("timer_event"), self.message_subscribers(pmt.intern("timer_event"))); 31 | reg_msg = pmt.cons(pmt.intern("ES_REGISTER_HANDLER"), reg); 32 | print "subscribers: %s"%(str(self.message_subscribers(pmt.intern("timer_event")))); 33 | print "registration message: %s"%(str(reg_msg)) 34 | self.message_port_pub(pmt.intern("which_stream"), reg_msg); 35 | 36 | def stop(self): 37 | self.count = 0; 38 | self.thread.join(); 39 | 40 | def run(self): 41 | while(self.count == -1 or self.count > 0): 42 | time.sleep(self.delay); 43 | timer_evt = es.event_create(self.d_type, 0, self.evt_length); 44 | timer_evt = es.event_args_add( timer_evt, pmt.intern("timer_counter"), pmt.from_long(self.count)); 45 | try: 46 | self.message_port_pub(pmt.intern("which_stream"), timer_evt); 47 | except: 48 | return 49 | 50 | if(self.count > 0): 51 | self.count = self.count - 1; 52 | 53 | def work(self, input_items, output_items): 54 | pass 55 | 56 | 57 | 58 | if __name__ == '__main__': 59 | queue = es.queue(); 60 | queue.set_early_behavior(1); 61 | a = es_trigger_timer(queue, "TYPE1", 0.1, 10); 62 | a.start(); 63 | print "Start returned waiting for main thread to join ... " 64 | a.join(); 65 | 66 | 67 | -------------------------------------------------------------------------------- /include/es/es_source_thread.hh: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | using namespace pmt; 33 | 34 | class es_source_thread { 35 | 36 | public: 37 | 38 | //es_source_thread(); 39 | es_source_thread(pmt_t _arb, es_queue_sptr _queue, boost::lockfree::queue *qq, boost::mutex *_lin_mut, std::vector *_readylist, boost::condition *qq_cond, gr_vector_int out_sig); 40 | void start(); 41 | void stop(); 42 | void do_work(); 43 | 44 | std::vector zerobuf; 45 | 46 | private: 47 | pmt_t arb; 48 | es_queue_sptr queue; 49 | 50 | bool finished; 51 | boost::shared_ptr d_thread; 52 | gr_vector_int out_sig; 53 | 54 | //boost::lockfree::queue *qq; 55 | 56 | boost::condition *qq_cond; 57 | 58 | boost::mutex *lin_mut; 59 | std::vector *readylist; 60 | boost::lockfree::queue *qq; 61 | // boost::lockfree::queue *dq; 62 | 63 | void eh_run(pmt_t eh); 64 | sem_t* thread_notify_sem; 65 | 66 | }; 67 | 68 | 69 | -------------------------------------------------------------------------------- /include/es/es_trigger_sample_timer.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef INCLUDED_EVENTSTREAM_TRIGGER_SAMPLE_TIMER_H 23 | #define INCLUDED_EVENTSTREAM_TRIGGER_SAMPLE_TIMER_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | using namespace pmt; 31 | 32 | class es_trigger_sample_timer; 33 | 34 | typedef boost::shared_ptr es_trigger_sample_timer_sptr; 35 | 36 | es_trigger_sample_timer_sptr es_make_trigger_sample_timer ( int itemsize, int period, int shift, int sched_dist, int event_length); 37 | 38 | class es_trigger_sample_timer : public es_trigger 39 | { 40 | private: 41 | friend es_trigger_sample_timer_sptr es_make_trigger_sample_timer (int itemsize, int period, int shift, int sched_dist, int event_length); 42 | 43 | es_trigger_sample_timer (int itemsize, int period, int shift, int sched_dist, int event_length); 44 | 45 | public: 46 | ~es_trigger_sample_timer (); // public destructor 47 | int work (int noutput_items, 48 | gr_vector_const_void_star &input_items, 49 | gr_vector_void_star &output_items); 50 | 51 | int d_period; 52 | int d_itemsize; 53 | int d_shift; 54 | int d_sched_dist; 55 | pmt_t d_evt_type; 56 | int d_evt_len; 57 | uint64_t d_evt_time; 58 | uint64_t d_time; 59 | bool d_enabled; 60 | 61 | }; 62 | 63 | #endif /* INCLUDED_EVENTSTREAM_SQUARE2_FF_H */ 64 | -------------------------------------------------------------------------------- /lib/qa_es_common.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | // Test event generation, queue insertion, handler binding, general non gr-runtime operation 30 | void 31 | qa_es_common::t1() 32 | { 33 | printf("t1\n"); 34 | es_queue_sptr q = es_make_queue(); 35 | pmt_t arb = es_make_arbiter(); 36 | 37 | pmt_t evt1 = event_create( es::event_type_1, 1, 4 ); 38 | pmt_t evt2 = event_create( es::event_type_1, 100, 10 ); 39 | pmt_t evt3 = event_create( "custom_evt", 200, 10 ); 40 | event_print (evt1 ); 41 | std::cout << "event time = " << event_time( evt1 ) << "\n"; 42 | printf("event type = %s\n", event_type( evt2 ).c_str()); 43 | printf("event type = %s\n", event_type( evt3 ).c_str()); 44 | 45 | q->register_event_type( event_type( evt1 ) ); 46 | q->register_event_type( event_type( evt2 ) ); 47 | q->register_event_type( event_type( evt3 ) ); 48 | 49 | es_handler_sptr h1( es_make_handler_print(es_handler_print::TYPE_F32) ); 50 | es_handler_sptr h2( es_make_handler_print(es_handler_print::TYPE_C32) ); 51 | 52 | q->bind_handler( event_type(evt1), h1 ); 53 | q->bind_handler( event_type(evt3), h2 ); 54 | 55 | q->add_event(evt1); 56 | q->add_event(evt2); 57 | q->add_event(evt3); 58 | 59 | q->print_queue(); 60 | 61 | } 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /swig/es_swig.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | %include "runtime_swig.i" // the common stuff 24 | %include "pmt_swig.i" 25 | 26 | namespace std { 27 | %template(StrVector) vector; 28 | }; 29 | 30 | %{ 31 | #include "es/es_event.h" 32 | #include "es/es_queue.h" 33 | #include "es/es_source.h" 34 | #include "es/es_sink.h" 35 | #include "es/es_common.h" 36 | #include "es/es_gen_vector.h" 37 | #include "es/es_handler.h" 38 | #include "es/es_handler_insert_vector.h" 39 | #include "es/es_handler_print.h" 40 | #include "es/es_handler_file.h" 41 | #include "es/es_handler_pdu.h" 42 | #include "es/es_handler_passthrough.h" 43 | #include "es/es_handler_flowgraph.h" 44 | #include "es/es_trigger.h" 45 | #include "es/es_trigger_edge_f.h" 46 | #include "es/es_trigger_sample_timer.h" 47 | #include "es/es_pyhandler_def.h" 48 | #include "es/es_vector_source.hh" 49 | #include "es/es_vector_sink.hh" 50 | #include "es/es_patterned_interleaver.h" 51 | %} 52 | 53 | 54 | %include "es/es_handler_pdu.h" 55 | %include "es/es_handler_passthrough.h" 56 | %include "es_handler.i" 57 | %include "es_event.i" 58 | %include "es_source.i" 59 | %include "es_sink.i" 60 | %include "es_common.i" 61 | %include "es_handlers.i" 62 | %include "es_trigger.i" 63 | %include "es_trigger_edge_f.i" 64 | %include "es_trigger_sample_timer.i" 65 | %include "es_vector_source.i" 66 | %include "es_vector_sink.i" 67 | %include "es_pyhandler_def.i" 68 | %include "es_patterned_interleaver.i" 69 | -------------------------------------------------------------------------------- /grc/es_trigger_sample_timer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Trigger Sample-Timer Event 4 | es_trigger_sample_timer 5 | EVENTSTREAM 6 | import es 7 | es.trigger_sample_timer($type.size, $period, $shift, $sched_dist, $length ) 8 | 9 | 10 | Event Length (samples) 11 | length 12 | 100 13 | int 14 | 15 | 16 | Event Periodicity (samples) 17 | period 18 | 10000 19 | int 20 | 21 | 22 | Periodic Event Offset From 0 (samples) 23 | shift 24 | 5000 25 | int 26 | 27 | 28 | Schedule-Ahead Distance 29 | sched_dist 30 | 25000 31 | int 32 | 33 | 34 | 35 | Passthrough Data Type 36 | type 37 | enum 38 | 43 | 48 | 53 | 58 | 63 | 64 | 65 | 66 | in 67 | $type 68 | 1 69 | 70 | 71 | 72 | out 73 | $type 74 | 1 75 | 76 | 77 | 78 | which_stream 79 | message 80 | 1 81 | 82 | 83 | 84 | sample_timer_event 85 | message 86 | 1 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /include/es/es_event_loop_thread.hh: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | using namespace pmt; 34 | 35 | class es_event_loop_thread { 36 | 37 | public: 38 | 39 | //es_event_loop_thread(); 40 | es_event_loop_thread( 41 | pmt_t _arb, 42 | es_queue_sptr _queue, 43 | boost::lockfree::queue *qq, 44 | boost::lockfree::queue *dq, 45 | boost::condition *qq_cond, 46 | boost::atomic *nevents, 47 | boost::atomic *num_running_handlers); 48 | void start(); 49 | void stop(); 50 | void do_work(); 51 | boost::atomic *d_nevents; 52 | boost::atomic *d_num_running_handlers; 53 | 54 | private: 55 | pmt_t arb; 56 | es_queue_sptr queue; 57 | 58 | bool finished; 59 | boost::shared_ptr d_thread; 60 | 61 | //boost::lockfree::queue *qq; 62 | 63 | boost::condition *qq_cond; 64 | 65 | boost::lockfree::queue *qq; 66 | boost::lockfree::queue *dq; 67 | 68 | void eh_run(pmt_t eh); 69 | sem_t* thread_notify_sem; 70 | 71 | }; 72 | -------------------------------------------------------------------------------- /lib/es_handler_print.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | //#include 25 | #include 26 | 27 | es_handler_sptr es_make_handler_print(es_handler_print::DATATYPE type){ 28 | return es_handler_sptr(new es_handler_print(type)); 29 | } 30 | 31 | es_handler_print::es_handler_print( DATATYPE type ) 32 | : gr::sync_block("es_handler_file", 33 | gr::io_signature::make(0,0,0), 34 | gr::io_signature::make(0,0,0)) 35 | { 36 | d_type = type; 37 | } 38 | 39 | //void es_handler_print::handler( pmt_t msg, void* buf ){ 40 | void es_handler_print::handler( pmt_t msg, gr_vector_void_star buf ){ 41 | event_print(msg); 42 | switch(d_type){ 43 | case TYPE_F32: 44 | { 45 | printf(" vector_contents = ["); 46 | float* fbuf = (float*) buf[0]; 47 | for(int i=0; i 24 | #include 25 | #include 26 | 27 | es_handler_sptr es_make_handler_pdu(es_handler_pdu::DATATYPE type){ 28 | return es_handler_sptr(new es_handler_pdu(type)); 29 | } 30 | 31 | es_handler_pdu::es_handler_pdu( DATATYPE type ) : 32 | gr::sync_block ("es_handler_pdu", 33 | gr::io_signature::make(0,0,0), 34 | gr::io_signature::make(0,0,0)) 35 | { 36 | message_port_register_out(pmt::mp("pdus_out")); 37 | d_type = type; 38 | } 39 | 40 | void es_handler_pdu::handler( pmt_t msg, gr_vector_void_star buf ){ 41 | if(!is_event(msg)) 42 | throw std::runtime_error("input to es_handler_pdu::handler(msg ...) msg must be an event!"); 43 | pmt::pmt_t meta = pmt::tuple_ref(msg,1); 44 | switch(d_type){ 45 | case TYPE_F32: 46 | { 47 | float* fbuf = (float*) buf[0]; 48 | pmt::pmt_t vec = pmt::init_f32vector( event_length(msg), fbuf ); 49 | pmt::pmt_t pdu = pmt::cons( meta, vec ); 50 | message_port_pub(pmt::mp("pdus_out"), pdu); 51 | break; 52 | } 53 | case TYPE_C32: 54 | { 55 | gr_complex* cbuf = (gr_complex*) buf[0]; 56 | pmt::pmt_t vec = pmt::init_c32vector( event_length(msg), cbuf ); 57 | pmt::pmt_t pdu = pmt::cons( meta, vec ); 58 | message_port_pub(pmt::mp("pdus_out"), pdu); 59 | break; 60 | } 61 | default: 62 | printf("unknown vector content type.\n"); 63 | } 64 | } 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /grc/es_trigger_edge_f.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Trigger Rising Edge Event 4 | es_trigger_edge_f 5 | EVENTSTREAM 6 | import es 7 | es.trigger_edge_f($thresh,$length,$lookback,$type.size,$guard) 8 | 9 | self.$(id).set_thresh($thresh) 10 | 11 | 12 | Trigger Threshold 13 | thresh 14 | 1.0 15 | real 16 | 17 | 18 | Event Length (samples) 19 | length 20 | 100 21 | int 22 | 23 | 24 | Event Lookback (samples) 25 | lookback 26 | 0 27 | int 28 | 29 | 30 | Minimum Trigger Distance (samples) 31 | guard 32 | 300 33 | int 34 | 35 | 36 | 37 | Passthrough Data Type 38 | type 39 | enum 40 | 45 | 50 | 55 | 60 | 65 | 66 | 67 | $lookback >= 0 68 | 69 | 70 | thresh_input 71 | float 72 | 73 | 74 | 75 | passthru_in 76 | $type 77 | 1 78 | 79 | 80 | 81 | passthru_out 82 | $type 83 | 1 84 | 85 | 86 | 87 | which_stream 88 | message 89 | 1 90 | 91 | 92 | 93 | edge_event 94 | message 95 | 1 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /grc/variable_es_evt.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Event-Time Parameter 9 | variable_es_evt 10 | EVENTSTREAM 11 | self.$(id) = $(id) = $value 12 | 13 | 14 | Label 15 | label 16 | 17 | string 18 | #if $label() then 'none' else 'part'# 19 | 20 | 21 | Default Value 22 | value 23 | 0 24 | $type.type 25 | 26 | 27 | Type 28 | type 29 | 30 | enum 31 | #if $type() then 'none' else 'part'# 32 | 37 | 42 | 47 | 52 | 57 | 62 | 63 | 64 | Event Param Required 65 | req 66 | 67 | enum 68 | 72 | 76 | 77 | 94 | 95 | ES Event Parameters are parameters passed to an event when it occurs, 96 | If they are undefined in the event instance a default may be specified or an assertion behavior may be throw. 97 | 98 | 99 | -------------------------------------------------------------------------------- /swig/es_common.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | %include 24 | using namespace pmt; 25 | 26 | pmt_t es_make_arbiter(); 27 | 28 | class es { 29 | public: 30 | 31 | // global tuple type for es events 32 | static pmt_t type_es_event; 33 | 34 | // event type values within tuple 35 | // static pmt_t event_vector_created; 36 | 37 | // common hash keys 38 | static pmt_t event_type; 39 | static pmt_t event_time; 40 | static pmt_t event_length; 41 | static pmt_t event_buffer; 42 | 43 | // common event types 44 | static pmt_t event_type_1; 45 | static pmt_t event_type_gen_vector_f; 46 | static pmt_t event_type_gen_vector_c; 47 | static pmt_t event_type_gen_vector_b; 48 | 49 | }; 50 | 51 | 52 | 53 | bool is_event( pmt_t event ); 54 | void event_print( pmt_t event ); 55 | pmt_t event_create( pmt_t es_event_type, unsigned long long time, unsigned long long max_len ); 56 | pmt_t event_create( std::string es_event_type, unsigned long long time, unsigned long long max_len ); 57 | pmt_t event_field( pmt_t event, pmt_t field ); 58 | bool event_has_field( pmt_t event, pmt_t field ); 59 | 60 | 61 | std::string event_type( pmt_t event ); 62 | bool event_type_compare( pmt_t event, pmt_t evt_type ); 63 | uint64_t event_time( pmt_t event ); 64 | uint64_t event_length( pmt_t event ); 65 | 66 | 67 | pmt_t event_args_add( pmt_t evt, pmt_t arg_key, pmt_t arg_val ); 68 | 69 | pmt_t eh_pair_event( pmt_t eh_pair ); 70 | pmt_t eh_pair_handler( pmt_t eh_pair ); 71 | 72 | //void register_buffer( pmt_t event, gr_vector_void_star buf ); 73 | 74 | std::vector string_to_vector(std::string); 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /python/patterned_interleaver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from gnuradio import gr; 3 | import numpy; 4 | class patterned_interleaver(gr.basic_block): 5 | def __init__(self,itemsize, in_ports, pattern): 6 | gr.basic_block.__init__(self, name="patterned_interleaver", 7 | in_sig=in_ports*[itemsize], 8 | out_sig=[itemsize]); 9 | self.pattern = pattern; 10 | self.pat_len = len(pattern); 11 | self.in_ports = in_ports; 12 | self.ptr = 0; 13 | self.last_empty = 0; 14 | self.set_output_multiple(self.pat_len); 15 | 16 | self.input_count = list(numpy.zeros(self.in_ports,dtype=numpy.int32)); 17 | for i in range(0,in_ports): 18 | for v in self.pattern: 19 | if( v == i ): 20 | self.input_count[i] = self.input_count[i] + 1; 21 | 22 | def forecast(self, noutput_items, ninput_items_required): 23 | for i in range(0,len(ninput_items_required)): 24 | ninput_items_required[i] = int(self.input_count[i] * noutput_items/self.pat_len); 25 | return; 26 | 27 | def general_work(self, input_items, output_items): 28 | out = output_items[0]; 29 | 30 | blocks = len(out)/self.pat_len; 31 | for i in range(0,self.in_ports): 32 | blocks = min(blocks, len(input_items[i])/self.input_count[i]); 33 | 34 | 35 | for i in range(0,blocks): 36 | inptrs = list(numpy.zeros(self.in_ports,dtype=numpy.int32)); 37 | for j in range(0,self.pat_len): 38 | sel = self.pattern[j]; 39 | out[i*self.pat_len + j] = input_items[sel][i*self.input_count[sel] + inptrs[sel]] 40 | inptrs[sel] = inptrs[sel] + 1; 41 | 42 | if blocks == 0: 43 | if(self.last_empty > 2): 44 | return -1; 45 | else: 46 | self.last_empty = self.last_empty + 1; 47 | else: 48 | self.last_empty = 0; 49 | for i in range(0, self.in_ports): 50 | self.consume(i, int(blocks * self.input_count[i])); 51 | 52 | return int(blocks*self.pat_len); 53 | 54 | def reset(self): 55 | #self.ptr = 0; 56 | self.last_empty = False; 57 | 58 | if __name__ == '__main__': 59 | a = gr.vector_source_c([0,0,0,0,0]); 60 | b = gr.vector_source_c([1,1,1,1,1]); 61 | c = patterned_interleaver( numpy.complex64, 2, [0,1] ); 62 | d = gr.vector_sink_c(); 63 | tb = gr.top_block(); 64 | tb.connect(a,c,d); 65 | tb.connect( (b,0), (c,1) ); 66 | tb.run(); 67 | print d.data(); 68 | 69 | 70 | -------------------------------------------------------------------------------- /lib/es_gen_vector.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #include 23 | #include 24 | #include 25 | 26 | pmt_t event_create_gen_vector_f ( unsigned long long time, pmt_t float_list ){ 27 | assert(pmt::is_f32vector(float_list)); 28 | int len = pmt::length(float_list); 29 | pmt_t evt = event_create( es::event_type_gen_vector_f, time, (uint64_t)len); 30 | return event_args_add( evt, pmt::intern("vector"), float_list ); 31 | } 32 | 33 | pmt_t event_create_gen_vector_c ( unsigned long long time, pmt_t cpx_list ){ 34 | assert(pmt::is_c32vector(cpx_list)); 35 | int len = pmt::length(cpx_list); 36 | pmt_t evt = event_create( es::event_type_gen_vector_c, time, (uint64_t)len); 37 | return event_args_add( evt, pmt::intern("vector"), cpx_list ); 38 | } 39 | 40 | pmt_t event_create_gen_vector_b ( unsigned long long time, pmt_t u8_list, int itemsize ){ 41 | assert(pmt::is_u8vector(u8_list)); 42 | int len = pmt::length(u8_list)/itemsize; 43 | pmt_t evt = event_create( es::event_type_gen_vector_b, time, (uint64_t)len); 44 | return event_args_add( evt, pmt::intern("vector"), u8_list ); 45 | } 46 | 47 | 48 | pmt_t event_create_gen_vector( unsigned long long time, pmt_t vectors, gr::io_signature::sptr _sig ){ 49 | 50 | pmt_t buf0 = pmt::nth( 0, vectors ); 51 | assert(pmt::is_u8vector(buf0)); 52 | 53 | gr::io_signature* sig = &(*_sig); 54 | int len = pmt::length(buf0)/((_sig)->sizeof_stream_item(0)); 55 | 56 | pmt_t evt = event_create( es::event_type_gen_vector, time, (uint64_t)len); 57 | //return event_args_add( evt, pmt_intern("vectors"), vectors ); 58 | return event_args_add( evt, pmt::intern("vector"), vectors ); 59 | 60 | } 61 | 62 | -------------------------------------------------------------------------------- /include/es/es_trigger.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef INCLUDED_EVENTSTREAM_TRIGGER_H 23 | #define INCLUDED_EVENTSTREAM_TRIGGER_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | class es_trigger; 32 | using namespace pmt; 33 | 34 | class es_trigger : public virtual gr::sync_block 35 | { 36 | protected: 37 | es_trigger (); // private constructor 38 | 39 | 40 | public: 41 | ~es_trigger (); // public destructor 42 | 43 | virtual int work (int noutput_items, 44 | gr_vector_const_void_star &input_items, 45 | gr_vector_void_star &output_items); 46 | 47 | 48 | void register_handler(std::string name){ 49 | // std::cout << "Register_handler: " << name << "\n"; 50 | event_types.push_back(pmt::mp(name)); 51 | message_port_register_out(pmt::intern(name)); 52 | } 53 | 54 | virtual bool start(){ 55 | // std::cout << "es_trigger::start() << " << name() << "\n"; 56 | for(int i=0; i< event_types.size(); i++){ 57 | pmt::pmt_t reg = pmt::cons(event_types[i], message_subscribers(event_types[i])); 58 | reg = pmt::cons(pmt::mp("ES_REGISTER_HANDLER"), reg); 59 | message_port_pub(pmt::mp("which_stream"), reg); 60 | // std::cout << "sent registeration message: " << reg << "\n"; 61 | } 62 | return 0; 63 | } 64 | 65 | std::vector event_types; 66 | pmt_t event_type(int idx); 67 | pmt_t arb; 68 | es_queue_sptr event_queue; 69 | unsigned long long d_time; 70 | 71 | // event sizing parameters around the trigger moment 72 | unsigned int d_length; 73 | unsigned int d_lookback; 74 | }; 75 | 76 | #endif /* INCLUDED_EVENTSTREAM_SQUARE2_FF_H */ 77 | -------------------------------------------------------------------------------- /python/test1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2004,2007 Free Software Foundation, Inc. 4 | # 5 | # This file is part of GNU Radio 6 | # 7 | # GNU Radio is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 3, or (at your option) 10 | # any later version. 11 | # 12 | # GNU Radio is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with GNU Radio; see the file COPYING. If not, write to 19 | # the Free Software Foundation, Inc., 51 Franklin Street, 20 | # Boston, MA 02110-1301, USA. 21 | # 22 | 23 | from gnuradio import gr, gr_unittest 24 | import es; 25 | import random; 26 | 27 | 28 | class qa_es (gr_unittest.TestCase): 29 | 30 | def setUp (self): 31 | self.tb = gr.top_block () 32 | 33 | def tearDown (self): 34 | self.tb = None 35 | 36 | def test_001_square_ff (self): 37 | print "ok" 38 | #print dir(es); 39 | 40 | def test_002_es_source (self): 41 | 42 | tb = gr.top_block(); 43 | 44 | # create the arbiter shared memory space 45 | arb = es.es_make_arbiter(); 46 | 47 | # create the source event queue 48 | queue = es.queue(); 49 | 50 | # create the source block and set a max stream length on it 51 | src = es.source( arb, queue, [gr.sizeof_float] ); 52 | src.set_max(20); 53 | 54 | # add a singular event 55 | vec = es.pmt_float_vector([1,2,3,4]); 56 | e1 = es.event_create_gen_vector_f( 3, vec ); 57 | h1 = es.es_handler_insert_vector(); 58 | h1p = es.make_handler_pmt( h1 ); 59 | 60 | #e1 = es.es_make_event_gen_vector_f(arb, [1,2,3,4]); 61 | #e1.set_time(13) 62 | 63 | #print dir(es) 64 | #e1 = es.event_create( "test_event", 13, 4 ); 65 | #e1 = es.event_create( "test_event", 13, 4 ); 66 | queue.register_event_type( es.event_type( e1 ) ); 67 | queue.bind_handler( es.event_type( e1 ), h1p ); 68 | queue.add_event(e1); 69 | 70 | # set up a vector sink for printing 71 | snk = gr.vector_sink_f(); 72 | tb.connect(src, snk); 73 | 74 | # run the graph to completion and print output stream 75 | tb.run(); 76 | print snk.data(); 77 | 78 | 79 | if __name__ == '__main__': 80 | gr_unittest.main () 81 | 82 | -------------------------------------------------------------------------------- /lib/es_handler_file.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | es_handler_sptr es_make_handler_file(es_handler_file::DATATYPE type, std::string path, std::string desc){ 28 | return es_handler_sptr(new es_handler_file(type, path, desc)); 29 | } 30 | 31 | es_handler_file::es_handler_file( DATATYPE type, std::string path, std::string desc) : 32 | gr::sync_block("es_handler_file", 33 | gr::io_signature::make(0,0,0), 34 | gr::io_signature::make(0,0,0)) 35 | { 36 | d_type = type; 37 | d_path = path; 38 | d_desc = desc; 39 | } 40 | 41 | //void es_handler_file::handler( pmt_t msg, void* buf ){ 42 | void es_handler_file::handler( pmt_t msg, gr_vector_void_star buf ){ 43 | event_print(msg); 44 | switch(d_type){ 45 | case TYPE_F32: 46 | { 47 | std::string filename = (boost::format("%s/%s_%lu.f32.dat")%d_path%d_desc%event_time(msg)).str(); 48 | FILE* f = fopen( filename.c_str(), "w"); 49 | fwrite(buf[0], sizeof(float), event_length(msg), f); 50 | fclose(f); 51 | std::cout << "Wrote file: " << filename << "\n"; 52 | break; 53 | } 54 | case TYPE_C32: 55 | { 56 | std::string filename = (boost::format("%s/%s_%lu.c32.dat")%d_path%d_desc%event_time(msg)).str(); 57 | FILE* f = fopen( filename.c_str(), "w"); 58 | fwrite(buf[0], sizeof(gr_complex), event_length(msg), f); 59 | fclose(f); 60 | std::cout << "Wrote file: " << filename << "\n"; 61 | break; 62 | } 63 | default: 64 | printf("unknown vector content type.\n"); 65 | } 66 | 67 | } 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /cmake/Modules/GrBoost.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2010-2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_BOOST_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_BOOST_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Setup Boost and handle some system specific things 27 | ######################################################################## 28 | 29 | set(BOOST_REQUIRED_COMPONENTS 30 | date_time 31 | program_options 32 | filesystem 33 | system 34 | thread 35 | ) 36 | 37 | if(UNIX AND EXISTS "/usr/lib64") 38 | list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix 39 | endif(UNIX AND EXISTS "/usr/lib64") 40 | 41 | if(MSVC) 42 | if (NOT DEFINED BOOST_ALL_DYN_LINK) 43 | set(BOOST_ALL_DYN_LINK TRUE) 44 | endif() 45 | set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking") 46 | if(BOOST_ALL_DYN_LINK) 47 | add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc 48 | else(BOOST_ALL_DYN_LINK) 49 | unset(BOOST_REQUIRED_COMPONENTS) #empty components list for static link 50 | endif(BOOST_ALL_DYN_LINK) 51 | endif(MSVC) 52 | 53 | set(Boost_ADDITIONAL_VERSIONS 54 | "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" 55 | "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" 56 | "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" 57 | "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" 58 | "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" 59 | "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" 60 | "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" 61 | ) 62 | find_package(Boost "1.35" COMPONENTS ${BOOST_REQUIRED_COMPONENTS}) 63 | -------------------------------------------------------------------------------- /python/qa_es_handler_flowgraph.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright 2011 Free Software Foundation, Inc. 3 | # 4 | # This file is part of gr-eventstream 5 | # 6 | # gr-eventstream is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # gr-eventstream is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with gr-eventstream; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | 21 | from gnuradio import gr; 22 | import es; 23 | import pmt; 24 | 25 | # Create out flowgraph, define the event's sources and/or sinks 26 | def factory_cb(index): 27 | print "FACTORY CALLED index = %d"%(index); 28 | r = es.es_pyhandler(); 29 | src = gr.vector_source_b([10,20,30]); 30 | r.sink = es.vector_sink([1]); 31 | tb = gr.top_block(); 32 | tb.connect(src, r.sink); 33 | 34 | r.tb = tb.to_top_block(); 35 | r.blocks["src"] = src.to_basic_block(); 36 | return r; 37 | 38 | # Create our hook callback to be run before and after event flowgraph execution 39 | def hook_cb(args): 40 | print "TEST HOOK CB Called with %s :: %s"%(type(args), str(args)); 41 | print args.bufs; 42 | print args.msg; 43 | print args.blocks.keys(); 44 | r = es.es_hook_rval(); 45 | return r; 46 | 47 | ph = es.es_pyhandler_def(); 48 | ph.set_pyfactory_cb(factory_cb); 49 | #ph.set_pypre_hook_cb(hook_cb); 50 | #ph.set_pypost_hook_cb(hook_cb); 51 | 52 | fgh = es.es_handler_flowgraph( ph, 1 ); 53 | 54 | arb = es.es_make_arbiter(); 55 | queue = es.queue(); 56 | 57 | tb = gr.top_block(); 58 | src = es.source( arb, queue, [1] ); 59 | sink = gr.vector_sink_b(); 60 | 61 | src.set_max(20); 62 | tb.connect(src,sink); 63 | 64 | e1 = es.event_create("fg-event", 2, 3); 65 | e2 = es.event_create("fg-event", 8, 3); 66 | e3 = es.event_create("fg-event", 12, 3); 67 | 68 | queue.register_event_type( es.event_type( e1 ) ); 69 | queue.bind_handler( es.event_type( e1 ), es.make_handler_pmt(fgh) ); 70 | 71 | print "--------calling queue.add_event(e1)-------------"; 72 | queue.add_event( e1 ); 73 | queue.add_event( e2 ); 74 | queue.add_event( e3 ); 75 | 76 | print "--------calling tb.run()-------------"; 77 | tb.run(); 78 | print "python: tb.run() returned" 79 | print "sink.data() = %s"%(str( sink.data() )); 80 | -------------------------------------------------------------------------------- /lib/es_trigger.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | /* 24 | * config.h is generated by configure. It contains the results 25 | * of probing for features, options etc. It should be the first 26 | * file included in your .cc file. 27 | */ 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | /* 38 | * Create a new instance of es_trigger and return 39 | * a boost shared_ptr. This is effectively the public constructor. 40 | */ 41 | /*"es_trigger_sptr 42 | es_make_trigger (pmt_t arb, es_queue_sptr queue, int itemsize, std::string blkname) 43 | { 44 | return es_trigger_sptr (new es_trigger (arb,queue,itemsize,blkname)); 45 | }*/ 46 | 47 | /* 48 | * Specify constraints on number of input and output streams. 49 | * This info is used to construct the input and output signatures 50 | * (2nd & 3rd args to gr::block's constructor). The input and 51 | * output signatures are used by the runtime system to 52 | * check that a valid number and type of inputs and outputs 53 | * are connected to this block. In this case, we accept 54 | * only 1 input and 1 output. 55 | */ 56 | es_trigger::es_trigger () 57 | : d_time(0), d_length(1), d_lookback(0) 58 | { 59 | message_port_register_out(pmt::intern("which_stream")); 60 | } 61 | 62 | es_trigger::~es_trigger () 63 | { 64 | } 65 | 66 | int 67 | es_trigger::work (int noutput_items, 68 | gr_vector_const_void_star &input_items, 69 | gr_vector_void_star &output_items) 70 | { 71 | // never call the base class directly 72 | throw std::runtime_error("es_trigger::general_work() accessed directly, please override!\n"); 73 | } 74 | 75 | pmt_t es_trigger::event_type(int idx){ 76 | assert(event_types.size()>idx); 77 | return event_types[idx]; 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /include/es/es_source.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef INCLUDED_EVENTSTREAM_SOURCE_H 23 | #define INCLUDED_EVENTSTREAM_SOURCE_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | enum es_source_merge_behavior { 35 | MEMCPY, 36 | ADD_INT8S, 37 | ADD_INT16S, 38 | ADD_FLOATS, 39 | }; 40 | 41 | class es_source; 42 | using namespace pmt; 43 | 44 | typedef boost::shared_ptr es_source_sptr; 45 | 46 | es_source_sptr es_make_source (gr_vector_int out_sig, int nthreads=1, enum es_queue_early_behaviors = DISCARD, enum es_source_merge_behavior = MEMCPY); 47 | 48 | class es_source : public virtual gr::sync_block, public virtual es_event_acceptor 49 | { 50 | private: 51 | friend es_source_sptr es_make_source (gr_vector_int out_sig, int nthreads, enum es_queue_early_behaviors, enum es_source_merge_behavior); 52 | 53 | es_source (gr_vector_int out_sig, int nthreads=1, enum es_queue_early_behaviors = DISCARD, enum es_source_merge_behavior = MEMCPY); // private constructor 54 | 55 | es_handler_sptr ih; 56 | 57 | public: 58 | ~es_source (); // public destructor 59 | 60 | int work (int noutput_items, 61 | gr_vector_const_void_star &input_items, 62 | gr_vector_void_star &output_items); 63 | 64 | es_source_merge_behavior d_merge_mode; 65 | 66 | void set_max(unsigned long long maxlen); 67 | 68 | boost::condition qq_cond; 69 | 70 | boost::lockfree::queue qq; // work items to start 71 | boost::lockfree::queue dq; // finished time indexes 72 | 73 | boost::mutex lin_mut; 74 | std::vector readylist; 75 | 76 | std::vector > threadpool; 77 | 78 | bool cb(es_eh_pair** eh); 79 | 80 | int n_threads; 81 | 82 | unsigned long long d_maxlen; 83 | unsigned long long d_time; 84 | unsigned int d_history; 85 | 86 | unsigned long long time(); 87 | }; 88 | 89 | #endif /* INCLUDED_EVENTSTREAM_SQUARE_FF_H */ 90 | -------------------------------------------------------------------------------- /lib/qa_es_trigger.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | 30 | #include 31 | #include 32 | 33 | // Test gr-runtime operation of single event item 34 | void 35 | qa_es_trigger::t1() 36 | { 37 | printf(" *** BEGIN QA_ES_TRIGGER_T1\n"); 38 | 39 | // build input test vector 40 | std::vector vec; 41 | vec.push_back(0); 42 | vec.push_back(0); 43 | vec.push_back(0); 44 | vec.push_back(4); 45 | vec.push_back(3); 46 | vec.push_back(2); 47 | vec.push_back(1); 48 | vec.push_back(0); 49 | vec.push_back(0); 50 | vec.push_back(0); 51 | vec.push_back(0); 52 | 53 | // create eventstream control objects 54 | pmt_t arb = es_make_arb(); 55 | es_queue_sptr queue = es_make_queue(); 56 | 57 | // build gnu radio blocks 58 | gr::top_block_sptr tb = gr::make_top_block("qa_es_trigger_t1_top"); 59 | gr::blocks::vector_source_f::sptr src = gr::blocks::vector_source_f::make(vec); 60 | 61 | gr_vector_int insig(1); 62 | insig[0] = sizeof(float); 63 | es_sink_sptr snk = es_make_sink( insig, 1 ); 64 | 65 | // es_trigger_edge_f_sptr trig = es_make_trigger_edge_f(0.1, 4, 1, sizeof(char),1, "EDGE_TRIGGER_EVENT"); 66 | 67 | // connect traditional flowgraph portion 68 | // tb->connect( src, 0, trig, 0 ); 69 | // tb->connect( trig, 0, snk, 0 ); 70 | 71 | // create the event handler, just a print handler in this case 72 | //pmt_t h1 = make_handler_pmt( new es_handler_print(es_handler_print::TYPE_F32) ); 73 | // es_handler_sptr h1 = es_make_handler_print(es_handler_print::TYPE_F32); 74 | 75 | // register the trigger blocks event type as a known event type handled by this queue 76 | // queue->register_event_type( trig->event_type(0) ); 77 | 78 | // bind a handler to the trigger block's first output event type 79 | // queue->bind_handler( trig->event_type(0), h1 ); 80 | 81 | // run the waveform 82 | // tb->run(); 83 | 84 | printf(" *** END QA_ES_TRIGGER_T1\n"); 85 | } 86 | 87 | 88 | -------------------------------------------------------------------------------- /lib/qa_es_sink.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | 30 | #include 31 | #include 32 | 33 | // Test gr-runtime operation of single event item 34 | void 35 | qa_es_sink::t1() 36 | { 37 | printf(" *** BEGIN QA_ES_SINK_T1\n"); 38 | 39 | // build input test vector 40 | std::vector vec; 41 | vec.push_back(0); 42 | vec.push_back(0); 43 | vec.push_back(0); 44 | vec.push_back(4); 45 | vec.push_back(3); 46 | vec.push_back(2); 47 | vec.push_back(1); 48 | vec.push_back(0); 49 | vec.push_back(0); 50 | vec.push_back(0); 51 | vec.push_back(0); 52 | 53 | // create eventstream control objects 54 | 55 | // build gnu radio blocks 56 | gr::top_block_sptr tb = gr::make_top_block("qa_es_sink_t1_top"); 57 | gr::blocks::vector_source_f::sptr src = gr::blocks::vector_source_f::make(vec); 58 | 59 | gr_vector_int insig(1); 60 | insig[0] = sizeof(float); 61 | es_sink_sptr snk = es_make_sink( insig, 1 ); 62 | 63 | // connect traditional flowgraph portion 64 | tb->connect( src, 0, snk, 0 ); 65 | 66 | pmt_t evt1 = event_create("NEW_EVT_TYPE_3_4", 3, 4); 67 | pmt_t evt2 = event_create("NEW_EVT_TYPE_5_4", 5, 4); 68 | 69 | //pmt_t h1 = make_handler_pmt( new es_handler_print(es_handler_print::TYPE_F32) ); 70 | es_handler_sptr h1 = es_make_handler_print(es_handler_print::TYPE_F32); 71 | 72 | // register the NEW_EVT_TYPE as a known event type handled by this queue 73 | // queue->register_event_type( event_type( evt1 ) ); 74 | 75 | // bind a handler to the NEW_EVT_TYPE 76 | // queue->bind_handler( event_type( evt1 ), h1 ); 77 | 78 | // to define this event type and not discard it run ... 79 | // queue->register_event_type( event_type( evt2 ) ); 80 | // queue->bind_handler( event_type( evt2 ), h1 ); 81 | 82 | // add the two events to the queue 83 | // queue->add_event(evt1); 84 | // queue->add_event(evt2); 85 | 86 | printf("tb->run()\n"); 87 | 88 | // run the waveform 89 | tb->run(); 90 | 91 | printf(" *** END QA_ES_SINK_T1\n"); 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /apps/burst_view.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ################################################## 3 | # Gnuradio Python Flow Graph 4 | # Title: Burst View 5 | # Generated: Thu Sep 13 11:16:15 2012 6 | ################################################## 7 | 8 | from PyQt4 import Qt 9 | from gnuradio import eng_notation 10 | from gnuradio import gr 11 | from gnuradio import qtgui 12 | from gnuradio.eng_option import eng_option 13 | from gnuradio.gr import firdes 14 | from optparse import OptionParser 15 | import sip 16 | import sys 17 | 18 | class burst_view(gr.top_block, Qt.QWidget): 19 | 20 | def __init__(self): 21 | gr.top_block.__init__(self, "Burst View") 22 | Qt.QWidget.__init__(self) 23 | self.setWindowTitle("Burst View") 24 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 25 | self.top_scroll_layout = Qt.QVBoxLayout() 26 | self.setLayout(self.top_scroll_layout) 27 | self.top_scroll = Qt.QScrollArea() 28 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) 29 | self.top_scroll_layout.addWidget(self.top_scroll) 30 | self.top_scroll.setWidgetResizable(True) 31 | self.top_widget = Qt.QWidget() 32 | self.top_scroll.setWidget(self.top_widget) 33 | self.top_layout = Qt.QVBoxLayout(self.top_widget) 34 | self.top_grid_layout = Qt.QGridLayout() 35 | self.top_layout.addLayout(self.top_grid_layout) 36 | 37 | 38 | 39 | ################################################## 40 | # Variables 41 | ################################################## 42 | self.samp_rate = samp_rate = 1e6 43 | 44 | ################################################## 45 | # Blocks 46 | ################################################## 47 | self.qtgui_sink_x_0 = qtgui.sink_c( 48 | 1024, #fftsize 49 | firdes.WIN_BLACKMAN_hARRIS, #wintype 50 | 0, #fc 51 | samp_rate, #bw 52 | "QT GUI Plot", #name 53 | True, #plotfreq 54 | True, #plotwaterfall 55 | True, #plottime 56 | True, #plotconst 57 | ) 58 | self.qtgui_sink_x_0.set_update_time(1.0/10) 59 | self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) 60 | self.top_layout.addWidget(self._qtgui_sink_x_0_win) 61 | 62 | 63 | self.gr_udp_source_0 = gr.udp_source(gr.sizeof_gr_complex*1, "127.0.0.1", 12345, 1472, True, True) 64 | 65 | ################################################## 66 | # Connections 67 | ################################################## 68 | 69 | self.connect((self.gr_udp_source_0, 0), (self.qtgui_sink_x_0, 0)) 70 | 71 | 72 | 73 | def get_samp_rate(self): 74 | return self.samp_rate 75 | 76 | def set_samp_rate(self, samp_rate): 77 | self.samp_rate = samp_rate 78 | self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate) 79 | 80 | if __name__ == '__main__': 81 | parser = OptionParser(option_class=eng_option, usage="%prog: [options]") 82 | (options, args) = parser.parse_args() 83 | qapp = Qt.QApplication(sys.argv) 84 | tb = burst_view() 85 | tb.start() 86 | tb.show() 87 | qapp.exec_() 88 | tb.stop() 89 | 90 | -------------------------------------------------------------------------------- /include/es/es_common.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef EVENTSTREAM_COMMON_H 23 | #define EVENTSTREAM_COMMON_H 24 | 25 | #include 26 | #include 27 | // mode_t is defined in logger.h for MS 28 | #ifdef _MSC_VER 29 | #define HAVE_MODE_T 30 | #endif 31 | 32 | using namespace pmt; 33 | 34 | #define es_make_arb es_make_arbiter 35 | pmt_t es_make_arbiter(); 36 | 37 | class es { 38 | public: 39 | 40 | // global tuple type for es events 41 | static pmt_t type_es_event; 42 | 43 | // event type values within tuple 44 | // static pmt_t event_vector_created; 45 | 46 | // common hash keys 47 | static pmt_t event_type; 48 | static pmt_t event_time; 49 | static pmt_t event_length; 50 | static pmt_t event_buffer; 51 | 52 | // common event types 53 | static pmt_t event_type_1; 54 | static pmt_t event_type_gen_vector_f; 55 | static pmt_t event_type_gen_vector_c; 56 | static pmt_t event_type_gen_vector_b; 57 | static pmt_t event_type_gen_vector; 58 | 59 | }; 60 | 61 | enum es_search_behaviors { 62 | SEARCH_FORWARD, 63 | SEARCH_REVERSE, 64 | SEARCH_BINARY 65 | }; 66 | 67 | bool is_event( pmt_t event ); 68 | void event_print( pmt_t event ); 69 | pmt_t event_create( pmt_t es_event_type, unsigned long long time, unsigned long long max_len ); 70 | pmt_t event_create( std::string es_event_type, unsigned long long time, unsigned long long max_len ); 71 | pmt_t event_field( pmt_t event, pmt_t field ); 72 | bool event_has_field( pmt_t event, pmt_t field ); 73 | 74 | pmt_t event_type_pmt( pmt_t event ); 75 | std::string event_type( pmt_t event ); 76 | bool event_type_compare( pmt_t event, pmt_t evt_type ); 77 | uint64_t event_time( pmt_t event ); 78 | uint64_t event_length( pmt_t event ); 79 | 80 | pmt_t event_args_add( pmt_t evt, pmt_t arg_key, pmt_t arg_val ); 81 | 82 | pmt_t eh_pair_event( pmt_t eh_pair ); 83 | pmt_t eh_pair_handler( pmt_t eh_pair ); 84 | 85 | pmt_t register_buffer( pmt_t event, pmt_t bufs); 86 | pmt_t register_buffer( pmt_t event, gr_vector_void_star buf, gr_vector_int &sig); 87 | //pmt_t register_buffer( pmt_t event, gr_vector_const_void_star buf, gr_vector_int &sig); 88 | 89 | 90 | gr::io_signature::sptr es_make_io_signature( int min, const std::vector &sizes ); 91 | 92 | std::vector string_to_vector(std::string); 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Set up CFLAGS 3 | include_directories( 4 | ${EVENTSTREAM_INCLUDE_DIRS} 5 | ${GNURADIO_PMT_INCLUDE_DIRS} 6 | ${GNURADIO_RUNTIME_INCLUDE_DIRS} 7 | ${GNURADIO_BLOCKS_INCLUDE_DIRS} 8 | ${PYTHON_INCLUDE_DIRS} 9 | ${BOOST_INCLUDE_DIRS} 10 | ) 11 | 12 | # Set up LDFLAGS 13 | list(APPEND eventstream_libs 14 | ${CPPUNIT_LIBRARIES} 15 | ${PMT_LIBRARIES} 16 | ${Boost_LIBRARIES} 17 | ${GNURADIO_RUNTIME_LIBRARIES} 18 | ${GNURADIO_BLOCKS_LIBRARIES} 19 | ${GNURADIO_PMT_LIBRARIES} 20 | ${PYTHON_LIBRARIES} 21 | ) 22 | 23 | list(APPEND eventstream_sources 24 | es_common.cc 25 | es_eh_pair.cc 26 | es_event_loop_thread.cc 27 | es_source_thread.cc 28 | es_handler.cc 29 | es_handler_flowgraph.cc 30 | es_handler_print.cc 31 | es_handler_file.cc 32 | es_handler_pdu.cc 33 | es_handler_passthrough.cc 34 | es_queue.cc 35 | es_sink.cc 36 | es_source.cc 37 | es_vector_source.cc 38 | es_vector_sink.cc 39 | es_gen_vector.cc 40 | es_handler_insert_vector.cc 41 | es_trigger.cc 42 | es_trigger_edge_f.cc 43 | es_trigger_sample_timer.cc 44 | es_pyhandler_def.cc 45 | es_patterned_interleaver.cc 46 | es_exceptions.cc 47 | es_event_acceptor.cc 48 | ) 49 | 50 | list(APPEND test_eventstream_sources 51 | qa_es.cc 52 | qa_es_common.cc 53 | qa_es_source.cc 54 | qa_es_sink.cc 55 | qa_es_trigger.cc 56 | ) 57 | 58 | add_library(eventstream SHARED ${eventstream_sources}) 59 | target_link_libraries(eventstream ${eventstream_libs}) 60 | 61 | add_executable(test_eventstream ${test_eventstream_sources} test_all.cc) 62 | target_link_libraries(test_eventstream eventstream ${CPPUNIT_LIBRARIES}) 63 | 64 | 65 | 66 | ######################################################################## 67 | # Install built library files 68 | ######################################################################## 69 | INSTALL(TARGETS eventstream 70 | LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file 71 | ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file 72 | RUNTIME DESTINATION bin # .dll file 73 | ) 74 | 75 | 76 | ####################################################### 77 | # STATIC LIB BUILD 78 | ####################################################### 79 | if(ENABLE_STATIC_LIBS) 80 | 81 | add_library(eventstream_static STATIC ${eventstream_sources}) 82 | 83 | set_target_properties(eventstream_static PROPERTIES OUTPUT_NAME eventstream) 84 | install(TARGETS eventstream_static 85 | LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file 86 | ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file 87 | RUNTIME DESTINATION bin # .dll file 88 | ) 89 | 90 | endif() 91 | 92 | 93 | 94 | ######################################################################## 95 | # Build and register unit test 96 | ######################################################################## 97 | FIND_PACKAGE(Boost COMPONENTS unit_test_framework) 98 | 99 | INCLUDE(GrTest) 100 | SET(GR_TEST_TARGET_DEPS eventstream) 101 | #turn each test cpp file into an executable with an int main() function 102 | ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) 103 | 104 | -------------------------------------------------------------------------------- /lib/es_vector_sink.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifdef HAVE_CONFIG_H 24 | #include "config.h" 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | es_vector_sink_sptr 32 | es_make_vector_sink (const gr_vector_int &io_def ) 33 | { 34 | return es_vector_sink_sptr (new es_vector_sink (io_def )); 35 | } 36 | 37 | es_vector_sink::es_vector_sink ( const gr_vector_int &io_def ) 38 | : gr::sync_block ("vector_sink", 39 | es_make_io_signature(0, io_def ), 40 | gr::io_signature::make(0, 0, 0 )), 41 | d_io_def(io_def) 42 | { 43 | for(int i=0; i() ); 45 | } 46 | clear(); 47 | } 48 | 49 | es_vector_sink::~es_vector_sink () 50 | { 51 | } 52 | 53 | 54 | int es_vector_sink::work (int noutput_items, 55 | gr_vector_const_void_star &input_items, 56 | gr_vector_void_star &output_items) 57 | { 58 | if(d_nitems + noutput_items > (d_data[0].size()/d_io_def[0]) ){ 59 | resize(d_nitems + noutput_items); 60 | } 61 | for(int i=0; i= d_nitems ); 77 | for(int i=0; i es_vector_sink::strvec(){ 96 | std::vector strvec; 97 | for(int i=0; i 24 | #include 25 | #include 26 | 27 | /* 28 | * Constructor function, sets up parameters 29 | */ 30 | es_event_loop_thread::es_event_loop_thread(pmt_t _arb, es_queue_sptr _queue, boost::lockfree::queue *_qq, boost::lockfree::queue *_dq, boost::condition *_qq_cond, boost::atomic *nevents, boost::atomic *num_running_handlers) : 31 | arb(_arb), 32 | queue(_queue), 33 | qq(_qq), 34 | dq(_dq), 35 | qq_cond(_qq_cond), 36 | finished(false), 37 | d_nevents(nevents), 38 | d_num_running_handlers(num_running_handlers) 39 | { 40 | start(); 41 | } 42 | 43 | /* 44 | * kick off a thread running the do_work() main loop function 45 | */ 46 | void es_event_loop_thread::start(){ 47 | d_thread = boost::shared_ptr(new boost::thread(boost::bind(&es_event_loop_thread::do_work, this))); 48 | } 49 | 50 | /* 51 | * Shut down all the running threads and join them. 52 | * Called by es_sink destructor 53 | */ 54 | void es_event_loop_thread::stop(){ 55 | finished = true; 56 | qq_cond->notify_all(); 57 | d_thread->interrupt(); 58 | d_thread->join(); 59 | } 60 | 61 | 62 | /* 63 | * Main event loop thread work function, 64 | * constantly receives and services event/handler pairs 65 | * then queues the live_times for deletion. 66 | */ 67 | void es_event_loop_thread::do_work(){ 68 | 69 | // // used by boost::condition, has no scope outside of this thread, unneccisary 70 | boost::mutex access; 71 | boost::mutex::scoped_lock lock(access); 72 | 73 | // run the thread until we are told to shut down 74 | while(!finished){ 75 | es_eh_pair* eh = NULL; 76 | 77 | // wait for a signal to start looking in the queue 78 | qq_cond->wait(lock); 79 | (*d_num_running_handlers)++; 80 | 81 | // get events to handle as long as they are available 82 | while( (*qq).pop(eh) ){ 83 | 84 | //printf("dequeue returned.\n"); 85 | 86 | // run the event/handler pair 87 | eh->run(); 88 | 89 | // enqueue the time marker for deletion 90 | (*dq).push( eh->time() ); 91 | 92 | // decrement number of events 93 | int a = *d_nevents; 94 | (*d_nevents)--; 95 | 96 | // delete the reference 97 | delete eh; 98 | } 99 | (*d_num_running_handlers)--; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /grc/es_source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | EventStream Source 4 | es_source 5 | EVENTSTREAM 6 | import es 7 | es.source($num_streams*[$type.size], $nthreads, $eb.raw, $mm.raw) 8 | 9 | 10 | Handler Threads 11 | nthreads 12 | 1 13 | int 14 | 15 | 16 | 17 | IO Type 18 | type 19 | enum 20 | 25 | 30 | 35 | 40 | 45 | 46 | 47 | 48 | 49 | Num Streams 50 | num_streams 51 | 1 52 | int 53 | 54 | 55 | 56 | Early Behavior 57 | eb 58 | 59 | enum 60 | 65 | 70 | 75 | 80 | 81 | 82 | 83 | Merge Mode 84 | mm 85 | 86 | enum 87 | 92 | 97 | 102 | 107 | 108 | 109 | 110 | schedule_event 111 | message 112 | 1 113 | 114 | 115 | 116 | out 117 | $type 118 | 1 119 | $num_streams 120 | 121 | 122 | 123 | nproduced 124 | message 125 | 1 126 | 127 | 128 | 129 | events_scheduled 130 | message 131 | 1 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /lib/es_vector_source.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | es_vector_source_sptr 31 | es_make_vector_source (const gr_vector_int &io_def ) 32 | { 33 | return es_vector_source_sptr (new es_vector_source (io_def )); 34 | } 35 | 36 | es_vector_source::es_vector_source ( const gr_vector_int &io_def ) 37 | : gr::sync_block ("vector_source", 38 | gr::io_signature::make(0, 0, 0 ), 39 | es_make_io_signature(0, io_def)), 40 | d_io_def(io_def), 41 | d_data( gr_vector_const_void_star(io_def.size()) ), 42 | d_dealloc(false) 43 | { 44 | clear(); 45 | } 46 | 47 | es_vector_source::~es_vector_source () 48 | { 49 | clear(); 50 | } 51 | 52 | 53 | int es_vector_source::work (int noutput_items, 54 | gr_vector_const_void_star &input_items, 55 | gr_vector_void_star &output_items) 56 | { 57 | int num_coppied = std::min( (uint64_t)noutput_items, items_remain()); 58 | if(num_coppied > 0){ 59 | for(int i=0; i data, int n_items){ 95 | gr_vector_const_void_star d2(data.size()); 96 | for(int i=0; i 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | #include 33 | 34 | //typedef boost::shared_ptr es_pyhandler_sptr; 35 | 36 | // return values for factory function execution 37 | // returns a descriptor for the flow graph 38 | // contains a top block to run(), as well as 39 | // a list of sources, and sinks to be accessed 40 | class es_pyhandler { 41 | public: 42 | es_pyhandler(); 43 | ~es_pyhandler(); 44 | gr::top_block_sptr tb; 45 | es_vector_source_sptr source; 46 | es_vector_sink_sptr sink; 47 | std::map blocks; 48 | PyObject* b2; 49 | void set_b2(PyObject* _b2); 50 | PyObject* vars; 51 | void set_vars(PyObject* _vars); 52 | }; 53 | 54 | 55 | 56 | // return values from hook execution 57 | // returns a map of str=>str 58 | struct es_hook_rval { 59 | std::map map; 60 | }; 61 | 62 | class es_hook_args { 63 | private: 64 | es_hook_args() {}; 65 | public: 66 | es_hook_args(gr_vector_void_star *bufs, const pmt::pmt_t msg, es_pyhandler* handler); 67 | gr_vector_void_star *bufs; 68 | const pmt::pmt_t msg; 69 | es_pyhandler* handler; 70 | }; 71 | 72 | 73 | 74 | es_pyhandler* default_factory_cb( int index, void* _cb_data ); 75 | 76 | typedef es_pyhandler* (*FACTORYCBTYPE)(int index, void* _cb_data); 77 | 78 | es_hook_rval* default_hook_cb( struct es_hook_args*, void* _cb_data ); 79 | 80 | typedef es_hook_rval* (*HOOKCBTYPE)( struct es_hook_args*, void* _cb_data ); 81 | 82 | 83 | class es_pyhandler_def { 84 | 85 | public: 86 | 87 | es_pyhandler_def(); 88 | 89 | 90 | FACTORYCBTYPE factory_callback; 91 | void* factory_cb_data; 92 | 93 | 94 | HOOKCBTYPE pre_hook_cb; 95 | void* pre_hook_data; 96 | 97 | 98 | HOOKCBTYPE post_hook_cb; 99 | void* post_hook_data; 100 | 101 | 102 | void set_factory_cb(FACTORYCBTYPE fp, void* _cb_data); 103 | void set_pre_hook_cb(HOOKCBTYPE fp, void* _cb_data); 104 | void set_post_hook_cb(HOOKCBTYPE fp, void* _cb_data); 105 | 106 | int d_index; 107 | es_pyhandler* run_factory(); 108 | es_hook_rval* run_pre_hook(gr_vector_void_star &bufs, const pmt::pmt_t &msg, es_pyhandler* handler); 109 | es_hook_rval* run_post_hook(gr_vector_void_star &bufs, const pmt::pmt_t &msg, es_pyhandler* handler); 110 | 111 | }; 112 | 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /cmake/Modules/FindICE-3.5.cmake: -------------------------------------------------------------------------------- 1 | # Override the search path for ICE; useful for manually installed libs. 2 | # set(ICE_MANUAL_INSTALL_PATH /opt/Ice-3.5.0/) 3 | 4 | FIND_PACKAGE(PkgConfig) 5 | PKG_CHECK_MODULES(PC_ICE Ice-3.5 QUIET) 6 | 7 | if(NOT ICE_FOUND) 8 | # Maybe we don't have a .pc file for Ice. Check for Config.h. If 9 | # that exists, get the version string and parse it for the proper 10 | # version. 11 | FIND_PATH( 12 | ICE_CONFIG_INCLUDE_DIR 13 | NAMES IceUtil/Config.h 14 | HINTS ${ICE_MANUAL_INSTALL_PATH}/include/ ${CMAKE_INSTALL_PREFIX}/include/ 15 | ) 16 | if(ICE_CONFIG_INCLUDE_DIR) 17 | file(STRINGS "${ICE_CONFIG_INCLUDE_DIR}/IceUtil/Config.h" 18 | ICE_STRING_VERSION REGEX "ICE_STRING_VERSION") 19 | string(REGEX MATCH "3.5" ICE_FOUND ${ICE_STRING_VERSION}) 20 | if(ICE_FOUND) 21 | set(ICE_FOUND TRUE) 22 | endif(ICE_FOUND) 23 | endif(ICE_CONFIG_INCLUDE_DIR) 24 | endif(NOT ICE_FOUND) 25 | 26 | if(NOT ICE_FOUND) 27 | message(STATUS " package 'Ice-3.5' not found") 28 | endif(NOT ICE_FOUND) 29 | 30 | # Recheck if we found the right version of ICE and proceed if true. 31 | if(ICE_FOUND) 32 | 33 | # Prepare the path hint for the libraries based on the include 34 | # directory found. 35 | string(REGEX REPLACE "/include" "" ICE_PATH ${ICE_CONFIG_INCLUDE_DIR}) 36 | 37 | FIND_PATH( 38 | ICE_INCLUDE_DIR 39 | NAMES IceUtil/IceUtil.h Ice/Ice.h 40 | NO_DEFAULT_PATH 41 | HINTS ${ICE_PATH}/include 42 | ) 43 | 44 | set(ICE_LIBRARY ) 45 | 46 | if(APPLE) 47 | set(ICE_LIB_PREFIX "Zeroc") 48 | else() 49 | set(ICE_LIB_PREFIX "") 50 | endif(APPLE) 51 | 52 | FIND_LIBRARY( 53 | ICE_ICE ${ICE_LIB_PREFIX}Ice 54 | NO_DEFAULT_PATH 55 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 56 | ) 57 | FIND_LIBRARY( 58 | ICE_ICESTORM ${ICE_LIB_PREFIX}IceStorm 59 | NO_DEFAULT_PATH 60 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 61 | ) 62 | FIND_LIBRARY( 63 | ICE_ICEGRID ${ICE_LIB_PREFIX}IceGrid 64 | NO_DEFAULT_PATH 65 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 66 | ) 67 | FIND_LIBRARY( 68 | ICE_ICEUTIL ${ICE_LIB_PREFIX}IceUtil 69 | NO_DEFAULT_PATH 70 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 71 | ) 72 | FIND_LIBRARY( 73 | ICE_GLACIER2 Glacier2 74 | NO_DEFAULT_PATH 75 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 76 | ) 77 | 78 | FIND_LIBRARY( 79 | ICE_PTHREAD NAMES pthread pthread-2.13 80 | HINTS ${CMAKE_INSTALL_PREFIX}/lib64/ ${CMAKE_INSTALL_PREFIX}/lib/ 81 | HINTS ${PC_ICE_LIBDIR} ${PC_ICE_LIBRARY_DIRS} /lib/i386-linux-gnu /lib/x86_64-linux-gnu /usr/lib /lib /lib64 82 | ENV LD_LIBRARY_PATH 83 | ) 84 | 85 | set(ICE_FOUND FALSE) 86 | 87 | if(ICE_ICE AND ICE_ICEUTIL) 88 | list(APPEND ICE_LIBRARY 89 | ${ICE_ICE} 90 | ${ICE_ICEUTIL} 91 | ) 92 | 93 | FIND_PROGRAM(ICE_SLICE2CPP slice2cpp 94 | HINTS ${CMAKE_INSTALL_PREFIX}/bin ${ICE_MANUAL_INSTALL_PATH}/bin/) 95 | FIND_PROGRAM(ICE_SLICE2PY slice2py 96 | HINTS ${CMAKE_INSTALL_PREFIX}/bin ${ICE_MANUAL_INSTALL_PATH}/bin/) 97 | 98 | # Check that the ICE Python package is installed 99 | include(GrPython) 100 | GR_PYTHON_CHECK_MODULE("Ice >= 3.5" Ice "Ice.stringVersion() >= '3.5.0'" PYTHON_ICE_FOUND) 101 | if(PYTHON_ICE_FOUND) 102 | set(ICE_FOUND TRUE) 103 | endif(PYTHON_ICE_FOUND) 104 | 105 | if(ICE_FOUND) 106 | message(STATUS "Ice-3.5 found") 107 | 108 | set(ICE_LIBRARIES ${ICE_LIBRARY}) 109 | set(ICE_INCLUDE_DIRS ${ICE_INCLUDE_DIR}) 110 | 111 | include(FindPackageHandleStandardArgs) 112 | find_package_handle_standard_args(ICE DEFAULT_MSG ICE_LIBRARY ICE_INCLUDE_DIR) 113 | mark_as_advanced(ICE_INCLUDE_DIR ICE_LIBRARY) 114 | endif(ICE_FOUND) 115 | endif(ICE_ICE AND ICE_ICEUTIL) 116 | 117 | endif(ICE_FOUND) 118 | -------------------------------------------------------------------------------- /lib/es_handler.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | #include 23 | #include 24 | 25 | pmt_t pmt_float_vector( std::vector< float > vec ){ 26 | return pmt::init_f32vector(vec.size(), &vec[0]); 27 | } 28 | 29 | pmt_t pmt_complex_vector( std::vector< gr_complex > vec ){ 30 | return pmt::init_c32vector(vec.size(), &vec[0]); 31 | } 32 | 33 | es_handler::es_handler() 34 | { 35 | //printf("es_handler constructor running (this = %x)\n",this); 36 | message_port_register_in(pmt::mp("handle_event")); 37 | } 38 | 39 | void es_handler::handler_helper( pmt_t msg ){ 40 | // std::cout << "handler_helper\n"; 41 | // std::cout << "msg: "; 42 | // pmt::print(msg); 43 | 44 | pmt::pmt_t buf_arg = event_field(msg, es::event_buffer); 45 | 46 | // calling handler 47 | handler( msg, get_buffer_ptr(buf_arg) ); 48 | } 49 | 50 | es_handler::~es_handler(){ 51 | // printf("Handler Base Class destructing (%x)!\n",this); 52 | } 53 | 54 | // default work implementation -- 55 | int 56 | es_handler::work (int noutput_items, 57 | gr_vector_const_void_star &input_items, 58 | gr_vector_void_star &output_items) 59 | { 60 | // never call the base class directly 61 | throw std::runtime_error("es_handler::general_work() accessed directly, please override if using stream ports for anything!\n"); 62 | } 63 | 64 | 65 | gr_vector_void_star es_handler::get_buffer_ptr(pmt_t buffer_arg){ 66 | int nvec = pmt::length(buffer_arg); 67 | // std::cout << "es_handler::get_buffer_ptr - nvec = " << nvec << "\n"; 68 | gr_vector_void_star outvec(nvec); 69 | for(int i=0; i(ptr); 74 | } else if(pmt::is_u8vector( list_nth ) ) { 75 | size_t buf_len = 0; // this is set by return, input val not used? 76 | const uint8_t* dataptr = pmt::u8vector_elements(list_nth, buf_len); 77 | outvec[i] = (void*) dataptr; 78 | } else if(pmt::is_blob( list_nth) ){ 79 | //outvec[i] = pmt_blob_rw_data(list_nth); 80 | outvec[i] = (void*)pmt::blob_data(list_nth); 81 | } else { 82 | throw std::runtime_error("unknown pmt type in event buffer!"); 83 | } 84 | } 85 | return outvec; 86 | } 87 | 88 | /* 89 | * default implementation of handler() should never be called, 90 | * maybe we should make this an abstract/pure-virtual method... 91 | */ 92 | void es_handler::handler(pmt_t msg, gr_vector_void_star buf){ 93 | printf("es_handler::handler() this=%p (base class handler called!! not good)\n",this); 94 | throw std::runtime_error("base class handler called!! not good"); 95 | } 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /cmake/Modules/GrVersion.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_VERSION_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_VERSION_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Extract variables from version.sh 27 | ######################################################################## 28 | include(GrPython) 29 | message(STATUS "Extracting version information from version.sh...") 30 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "print open('${CMAKE_SOURCE_DIR}/version.sh').read().replace('=', ';').replace('\\n', ';')" 31 | OUTPUT_VARIABLE VERSION_INFO OUTPUT_STRIP_TRAILING_WHITESPACE 32 | ) 33 | include(CMakeParseArgumentsCopy) 34 | CMAKE_PARSE_ARGUMENTS(VERSION_INFO "" "MAJOR_VERSION;API_COMPAT;MINOR_VERSION;MAINT_VERSION" "" ${VERSION_INFO}) 35 | 36 | #eventually, replace version.sh and fill in the variables below 37 | set(MAJOR_VERSION ${VERSION_INFO_MAJOR_VERSION}) 38 | set(API_COMPAT ${VERSION_INFO_API_COMPAT}) 39 | set(MINOR_VERSION ${VERSION_INFO_MINOR_VERSION}) 40 | set(MAINT_VERSION ${VERSION_INFO_MAINT_VERSION}) 41 | 42 | ######################################################################## 43 | # Extract the version string from git describe. 44 | ######################################################################## 45 | find_package(Git) 46 | 47 | if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) 48 | message(STATUS "Extracting version information from git describe...") 49 | execute_process( 50 | COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=8 51 | OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE 52 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 53 | ) 54 | else() 55 | set(GIT_DESCRIBE "v${MAJOR_VERSION}.${API_COMPAT}.x-xxx-xunknown") 56 | endif() 57 | 58 | ######################################################################## 59 | # Use the logic below to set the version constants 60 | ######################################################################## 61 | if("${MINOR_VERSION}" STREQUAL "git") 62 | # VERSION: 3.3git-xxx-gxxxxxxxx 63 | # DOCVER: 3.3git 64 | # LIBVER: 3.3git 65 | set(VERSION "${GIT_DESCRIBE}") 66 | set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") 67 | set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") 68 | elseif("${MAINT_VERSION}" STREQUAL "git") 69 | # VERSION: 3.3.1git-xxx-gxxxxxxxx 70 | # DOCVER: 3.3.1git 71 | # LIBVER: 3.3.1git 72 | set(VERSION "${GIT_DESCRIBE}") 73 | set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") 74 | set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") 75 | else() 76 | # This is a numbered release. 77 | # VERSION: 3.3.1{.x} 78 | # DOCVER: 3.3.1{.x} 79 | # LIBVER: 3.3.1{.x} 80 | if("${MAINT_VERSION}" STREQUAL "0") 81 | set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}") 82 | else() 83 | set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}.${MAINT_VERSION}") 84 | endif() 85 | set(DOCVER "${VERSION}") 86 | set(LIBVER "${VERSION}") 87 | endif() 88 | -------------------------------------------------------------------------------- /lib/es_trigger_sample_timer.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | /* 24 | * config.h is generated by configure. It contains the results 25 | * of probing for features, options etc. It should be the first 26 | * file included in your .cc file. 27 | */ 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | /* 39 | * Create a new instance of es_trigger_sample_timer and return 40 | * a boost shared_ptr. This is effectively the public constructor. 41 | */ 42 | es_trigger_sample_timer_sptr 43 | es_make_trigger_sample_timer (int itemsize, int period, int shift, int sched_dist, int event_length){ 44 | return es_trigger_sample_timer_sptr (new es_trigger_sample_timer (itemsize,period,shift,sched_dist,event_length)); 45 | } 46 | 47 | /* 48 | * Specify constraints on number of input and output streams. 49 | * This info is used to construct the input and output signatures 50 | * (2nd & 3rd args to gr::block's constructor). The input and 51 | * output signatures are used by the runtime system to 52 | * check that a valid number and type of inputs and outputs 53 | * are connected to this block. In this case, we accept 54 | * only 1 input and 1 output. 55 | */ 56 | static const int MIN_IN = 1; // mininum number of input streams 57 | static const int MAX_IN = 1; // maximum number of input streams 58 | static const int MIN_OUT = 0; // minimum number of output streams 59 | static const int MAX_OUT = 1; // maximum number of output streams 60 | 61 | es_trigger_sample_timer::es_trigger_sample_timer (int itemsize, int period, int shift, int sched_dist, int event_length) 62 | : d_period(period), d_shift(shift), 63 | d_time(0), d_evt_time(shift), d_evt_len(event_length), d_sched_dist(sched_dist), 64 | d_enabled(true), d_itemsize(itemsize), 65 | gr::sync_block("es_trigger_sample_timer", 66 | gr::io_signature::make(MIN_IN, MAX_IN, itemsize), 67 | gr::io_signature::make(MIN_OUT,MAX_OUT, itemsize)) 68 | { 69 | register_handler("sample_timer_event"); 70 | } 71 | 72 | es_trigger_sample_timer::~es_trigger_sample_timer () 73 | { 74 | } 75 | 76 | int 77 | es_trigger_sample_timer::work (int noutput_items, 78 | gr_vector_const_void_star &input_items, 79 | gr_vector_void_star &output_items) 80 | { 81 | 82 | // if output port is connected copy all our outputs across 83 | // this may be used to rate limit things downstream 84 | if(output_items.size() > 0){ 85 | memcpy( output_items[0], input_items[0], d_itemsize * noutput_items); 86 | } 87 | 88 | // schedule new events as we step along ... 89 | while(d_evt_time < d_time + noutput_items + d_sched_dist){ 90 | d_evt_time += d_period; 91 | if(d_enabled){ 92 | pmt_t evt = event_create( pmt::mp("sample_timer_event"), d_evt_time, d_evt_len ); 93 | message_port_pub(pmt::mp("which_stream"), evt); 94 | } 95 | } 96 | 97 | 98 | // consume the current input items 99 | d_time += noutput_items; 100 | return noutput_items; 101 | 102 | } 103 | 104 | 105 | -------------------------------------------------------------------------------- /grc/es_sink.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | EventStream Sink 4 | es_sink 5 | EVENTSTREAM 6 | import es 7 | es.sink($num_streams*[$type.size],$nthreads,$samplehistory,$eb.raw,$ss.raw,$cb.raw) 8 | 9 | 10 | IO Type 11 | type 12 | enum 13 | 18 | 23 | 28 | 33 | 38 | 43 | 44 | 45 | 46 | 47 | Num Streams 48 | num_streams 49 | 1 50 | int 51 | 52 | 53 | 54 | Num Handler Threads 55 | nthreads 56 | 8 57 | int 58 | 59 | 60 | 61 | Size of Sample History Ksamples 62 | samplehistory 63 | 64 64 | int 65 | 66 | 67 | 68 | Thread Congestion Behavior 69 | cb 70 | drop 71 | enum 72 | 77 | 82 | 83 | 84 | 85 | Early Behavior 86 | eb 87 | 88 | enum 89 | 94 | 99 | 104 | 105 | 106 | 107 | Search Style 108 | ss 109 | binary 110 | enum 111 | part 112 | 117 | 122 | 127 | 128 | 129 | 130 | in 131 | $type 132 | 1 133 | $num_streams 134 | 135 | 136 | 137 | schedule_event 138 | message 139 | 1 140 | 141 | 142 | 143 | nconsumed 144 | message 145 | 1 146 | 147 | 148 | pdu_event 149 | message 150 | 1 151 | 152 | 153 | notify_handlers 154 | message 155 | 1 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /cmake/Modules/FindICE.cmake: -------------------------------------------------------------------------------- 1 | # Override the search path for ICE; useful for manually installed libs. 2 | # set(ICE_MANUAL_INSTALL_PATH /opt/Ice-3.4.2/) 3 | 4 | FIND_PACKAGE(PkgConfig) 5 | PKG_CHECK_MODULES(PC_ICE Ice-3.4 QUIET) 6 | 7 | if(NOT ICE_FOUND) 8 | # Maybe we don't have a .pc file for Ice. Check for Config.h. If 9 | # that exists, get the version string and parse it for the proper 10 | # version. 11 | FIND_PATH( 12 | ICE_CONFIG_INCLUDE_DIR 13 | NAMES IceUtil/Config.h 14 | HINTS ${ICE_MANUAL_INSTALL_PATH}/include/ ${CMAKE_INSTALL_PREFIX}/${HEADER_DIR} 15 | ) 16 | if(ICE_CONFIG_INCLUDE_DIR) 17 | file(STRINGS "${ICE_CONFIG_INCLUDE_DIR}/IceUtil/Config.h" 18 | ICE_STRING_VERSION REGEX "ICE_STRING_VERSION") 19 | string(REGEX MATCH "3.4" ICE_FOUND ${ICE_STRING_VERSION}) 20 | if(ICE_FOUND) 21 | set(ICE_FOUND TRUE) 22 | endif(ICE_FOUND) 23 | endif(ICE_CONFIG_INCLUDE_DIR) 24 | endif(NOT ICE_FOUND) 25 | 26 | if(NOT ICE_FOUND) 27 | message(STATUS " package 'Ice-3.4' not found") 28 | endif(NOT ICE_FOUND) 29 | 30 | 31 | # Recheck if we found the right version of ICE and proceed if true. 32 | if(ICE_FOUND) 33 | 34 | # Prepare the path hint for the libraries based on the include 35 | # directory found. 36 | string(REGEX REPLACE "/include" "" ICE_PATH ${ICE_CONFIG_INCLUDE_DIR}) 37 | 38 | FIND_PATH( 39 | ICE_INCLUDE_DIR 40 | NAMES IceUtil/IceUtil.h Ice/Ice.h 41 | NO_DEFAULT_PATH 42 | HINTS ${CMAKE_INSTALL_PREFIX}/include 43 | HINTS ${ICE_PATH}/include 44 | ) 45 | 46 | set(ICE_LIBRARY ) 47 | 48 | if(APPLE) 49 | set(ICE_LIB_PREFIX "Zeroc") 50 | else() 51 | set(ICE_LIB_PREFIX "") 52 | endif(APPLE) 53 | 54 | FIND_LIBRARY( 55 | ICE_ICE ${ICE_LIB_PREFIX}Ice 56 | NO_DEFAULT_PATH 57 | HINTS ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64 58 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 59 | ) 60 | FIND_LIBRARY( 61 | ICE_ICESTORM ${ICE_LIB_PREFIX}IceStorm 62 | NO_DEFAULT_PATH 63 | HINTS ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64 64 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 65 | ) 66 | FIND_LIBRARY( 67 | ICE_ICEGRID ${ICE_LIB_PREFIX}IceGrid 68 | NO_DEFAULT_PATH 69 | HINTS ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64 70 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 71 | ) 72 | FIND_LIBRARY( 73 | ICE_ICEUTIL ${ICE_LIB_PREFIX}IceUtil 74 | NO_DEFAULT_PATH 75 | HINTS ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64 76 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 77 | ) 78 | FIND_LIBRARY( 79 | ICE_GLACIER2 Glacier2 80 | NO_DEFAULT_PATH 81 | HINTS ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64 82 | HINTS ${ICE_PATH}/lib ${ICE_PATH}/lib64 83 | ) 84 | 85 | FIND_LIBRARY( 86 | ICE_PTHREAD NAMES pthread pthread-2.13 87 | HINTS ${CMAKE_INSTALL_PREFIX}/lib64/ ${CMAKE_INSTALL_PREFIX}/lib/ 88 | HINTS ${PC_ICE_LIBDIR} ${PC_ICE_LIBRARY_DIRS} /lib/i386-linux-gnu /lib/x86_64-linux-gnu /usr/lib /lib /lib64 89 | ENV LD_LIBRARY_PATH 90 | ) 91 | 92 | set(ICE_FOUND FALSE) 93 | 94 | if(ICE_ICE AND ICE_ICEUTIL) 95 | list(APPEND ICE_LIBRARY 96 | ${ICE_ICE} 97 | ${ICE_ICEUTIL} 98 | ) 99 | 100 | FIND_PROGRAM(ICE_SLICE2CPP slice2cpp 101 | HINTS ${CMAKE_INSTALL_PREFIX}/bin ${ICE_MANUAL_INSTALL_PATH}/bin/) 102 | FIND_PROGRAM(ICE_SLICE2PY slice2py 103 | HINTS ${CMAKE_INSTALL_PREFIX}/bin ${ICE_MANUAL_INSTALL_PATH}/bin/) 104 | 105 | # Check that the ICE Python package is installed 106 | include(GrPython) 107 | GR_PYTHON_CHECK_MODULE("Ice >= 3.4" Ice "Ice.stringVersion() >= '3.4.0'" PYTHON_ICE_FOUND) 108 | if(PYTHON_ICE_FOUND) 109 | set(ICE_FOUND TRUE) 110 | endif(PYTHON_ICE_FOUND) 111 | 112 | if(ICE_FOUND) 113 | message(STATUS "Ice-3.4 found") 114 | 115 | set(ICE_LIBRARIES ${ICE_LIBRARY}) 116 | set(ICE_INCLUDE_DIRS ${ICE_INCLUDE_DIR}) 117 | 118 | include(FindPackageHandleStandardArgs) 119 | find_package_handle_standard_args(ICE DEFAULT_MSG ICE_LIBRARY ICE_INCLUDE_DIR) 120 | mark_as_advanced(ICE_INCLUDE_DIR ICE_LIBRARY) 121 | endif(ICE_FOUND) 122 | endif(ICE_ICE AND ICE_ICEUTIL) 123 | 124 | endif(ICE_FOUND) 125 | -------------------------------------------------------------------------------- /include/es/es_queue.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2011 Free Software Foundation, Inc. 4 | * 5 | * This file is part of gr-eventstream 6 | * 7 | * gr-eventstream is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * gr-eventstream is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gr-eventstream; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef EVENTSTREAM_QUEUE_H 24 | #define EVENTSTREAM_QUEUE_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | class es_queue; 32 | typedef boost::shared_ptr es_queue_sptr; 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | enum es_queue_early_behaviors { 40 | DISCARD, 41 | BALK, 42 | ASAP, 43 | RNDF 44 | }; 45 | 46 | es_queue_sptr es_make_queue( 47 | enum es_queue_early_behaviors = DISCARD, 48 | enum es_search_behaviors sb = SEARCH_BINARY); 49 | 50 | class es_eh_queue; 51 | 52 | class es_queue { 53 | 54 | public: 55 | 56 | std::vector d_hvec; 57 | es_queue( 58 | enum es_queue_early_behaviors = DISCARD, 59 | enum es_search_behaviors = SEARCH_BINARY); 60 | int add_event(pmt_t evt); 61 | void print_queue(bool already_locked = false); 62 | int fetch_next_event(unsigned long long min, unsigned long long max, es_eh_pair **eh); 63 | int fetch_next_event2(unsigned long long min, unsigned long long max, es_eh_pair **eh); 64 | 65 | void bind_handler(std::string type, gr::basic_block_sptr handler); 66 | void bind_handler(std::string type, es_handler* handler); 67 | void bind_handler(pmt_t type, gr::basic_block_sptr handler); 68 | 69 | void protect_handler(es_handler_sptr h){ protected_handler.push_back(h); } 70 | 71 | int register_event_type(std::string type); 72 | int register_event_type(pmt_t type); 73 | 74 | int d_early_behavior; 75 | uint64_t d_num_asap, d_num_discarded, d_num_events_added, d_num_events_removed; 76 | uint64_t d_event_time, d_num_soon; 77 | int length(); 78 | 79 | // set behavior when an item exists before the requested region (BALK or ASAP) 80 | void set_early_behavior(enum es_queue_early_behaviors); 81 | 82 | // set a callback to be called when an eh pair is added 83 | void set_append_callback( boost::function _cb){ 84 | cb_list.push_back(_cb); 85 | } 86 | 87 | 88 | bool empty(){ return event_queue.empty(); } 89 | uint64_t min_time(){ return empty()?0: ::event_time(event_queue[0]->event); } 90 | 91 | private: 92 | std::vector event_queue; 93 | pmt_t bindings; 94 | boost::mutex queue_lock; 95 | 96 | std::vector< es_handler_sptr > protected_handler; 97 | std::vector< boost::function< bool (es_eh_pair**) > > cb_list; 98 | 99 | /** 100 | * @brief Configuration variable for selecting an insertion sort algorithm. 101 | */ 102 | es_search_behaviors d_search_behavior; 103 | int find_index(uint64_t evt_time); 104 | size_t find_forward(const uint64_t evt_time); 105 | size_t find_reverse(const uint64_t evt_time); 106 | size_t find_binary(const uint64_t evt_time); 107 | }; 108 | 109 | 110 | 111 | 112 | #endif 113 | --------------------------------------------------------------------------------