commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11541 - in gnuradio/trunk/gnuradio-core/src: lib/io p


From: jcorgan
Subject: [Commit-gnuradio] r11541 - in gnuradio/trunk/gnuradio-core/src: lib/io python/gnuradio/gr
Date: Thu, 6 Aug 2009 17:21:39 -0600 (MDT)

Author: jcorgan
Date: 2009-08-06 17:21:38 -0600 (Thu, 06 Aug 2009)
New Revision: 11541

Modified:
   gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.cc
   gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.h
   gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.i
   gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_message.py
Log:
Adds constructor for gr.message_source that takes existing msgq.

A gr.message_source object can now be created in one of two ways:

blk = gr.message_source(itemsize, limit)

msgq = gr.msg_queue(limit)
blk = gr.message_source(itemsize, msgq)

Modified: gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.cc        
2009-08-06 20:48:41 UTC (rev 11540)
+++ gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.cc        
2009-08-06 23:21:38 UTC (rev 11541)
@@ -43,6 +43,13 @@
   return gr_message_source_sptr(new gr_message_source(itemsize, msgq_limit));
 }
 
+// public constructor that takes existing message queue
+gr_message_source_sptr
+gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq)
+{
+  return gr_message_source_sptr(new gr_message_source(itemsize, msgq));
+}
+
 gr_message_source::gr_message_source (size_t itemsize, int msgq_limit)
   : gr_sync_block("message_source",
                  gr_make_io_signature(0, 0, 0),
@@ -51,6 +58,14 @@
 {
 }
 
+gr_message_source::gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq)
+  : gr_sync_block("message_source",
+                 gr_make_io_signature(0, 0, 0),
+                 gr_make_io_signature(1, 1, itemsize)),
+    d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false)
+{
+}
+
 gr_message_source::~gr_message_source()
 {
 }

Modified: gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.h
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.h 2009-08-06 
20:48:41 UTC (rev 11540)
+++ gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.h 2009-08-06 
23:21:38 UTC (rev 11541)
@@ -31,6 +31,7 @@
 typedef boost::shared_ptr<gr_message_source> gr_message_source_sptr;
 
 gr_message_source_sptr gr_make_message_source (size_t itemsize, int 
msgq_limit=0);
+gr_message_source_sptr gr_make_message_source (size_t itemsize, 
gr_msg_queue_sptr msgq);
 
 /*!
  * \brief Turn received messages into a stream
@@ -47,9 +48,12 @@
 
   friend gr_message_source_sptr
   gr_make_message_source(size_t itemsize, int msgq_limit);
+  friend gr_message_source_sptr
+  gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq);
 
  protected:
   gr_message_source (size_t itemsize, int msgq_limit);
+  gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
 
  public:
   ~gr_message_source ();

Modified: gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.i
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.i 2009-08-06 
20:48:41 UTC (rev 11540)
+++ gnuradio/trunk/gnuradio-core/src/lib/io/gr_message_source.i 2009-08-06 
23:21:38 UTC (rev 11541)
@@ -23,11 +23,13 @@
 GR_SWIG_BLOCK_MAGIC(gr,message_source);
 
 gr_message_source_sptr gr_make_message_source (size_t itemsize, int 
msgq_limit=0);
+gr_message_source_sptr gr_make_message_source (size_t itemsize, 
gr_msg_queue_sptr msgq);
 
 class gr_message_source : public gr_sync_block
 {
  protected:
   gr_message_source (size_t itemsize, int msgq_limit);
+  gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
 
  public:
   ~gr_message_source ();

Modified: gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_message.py
===================================================================
--- gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_message.py   
2009-08-06 20:48:41 UTC (rev 11540)
+++ gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_message.py   
2009-08-06 23:21:38 UTC (rev 11541)
@@ -99,6 +99,7 @@
         self.assertEquals(input_data, dst.data())
 
     def test_301(self):
+        # Use itemsize, limit constructor
         src = gr.message_source(gr.sizeof_char)
         dst = gr.vector_sink_b()
        tb = gr.top_block()
@@ -111,6 +112,20 @@
         tb.run()
         self.assertEquals(tuple(map(ord, '0123456789')), dst.data())
         
+    def test_302(self):
+        # Use itemsize, msgq constructor
+        msgq = gr.msg_queue()
+        src = gr.message_source(gr.sizeof_char, msgq)
+        dst = gr.vector_sink_b()
+       tb = gr.top_block()
+        tb.connect(src, dst)
+        src.msgq().insert_tail(gr.message_from_string('01234'))
+        src.msgq().insert_tail(gr.message_from_string('5'))
+        src.msgq().insert_tail(gr.message_from_string(''))
+        src.msgq().insert_tail(gr.message_from_string('6789'))
+        src.msgq().insert_tail(gr.message(1))                  # send EOF
+        tb.run()
+        self.assertEquals(tuple(map(ord, '0123456789')), dst.data())
 
 if __name__ == '__main__':
     gr_unittest.main ()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]