GNU Radio 3.6.5 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2012 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_GR_RANDOM_PDU_H 00024 #define INCLUDED_GR_RANDOM_PDU_H 00025 00026 #include <gr_core_api.h> 00027 #include <gr_block.h> 00028 #include <gr_message.h> 00029 #include <gr_msg_queue.h> 00030 00031 #include <boost/random.hpp> 00032 #include <boost/generator_iterator.hpp> 00033 00034 class gr_random_pdu; 00035 typedef boost::shared_ptr<gr_random_pdu> gr_random_pdu_sptr; 00036 00037 GR_CORE_API gr_random_pdu_sptr gr_make_random_pdu (int mintime, int maxtime); 00038 00039 /*! 00040 * \brief Send message at defined interval 00041 */ 00042 class GR_CORE_API gr_random_pdu : public gr_block 00043 { 00044 private: 00045 friend GR_CORE_API gr_random_pdu_sptr 00046 gr_make_random_pdu(int mintime, int maxtime); 00047 00048 void output_random(); 00049 00050 boost::mt19937 rng; 00051 boost::uniform_int<> urange; 00052 boost::uniform_int<> brange; 00053 boost::variate_generator< boost::mt19937, boost::uniform_int<> > rvar; // pdu length 00054 boost::variate_generator< boost::mt19937, boost::uniform_int<> > bvar; // pdu contents 00055 00056 public: 00057 gr_random_pdu (int, int); 00058 bool start(); 00059 void generate_pdu(pmt::pmt_t msg){ output_random(); } 00060 void generate_pdu(){ output_random(); } 00061 }; 00062 00063 #endif /* INCLUDED_GR_RANDOM_PDU_H */