[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4475 - in gnuradio/branches/developers/jcorgan/ticket
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r4475 - in gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src: lib/runtime python/gnuradio/gr |
Date: |
Tue, 13 Feb 2007 14:35:36 -0700 (MST) |
Author: jcorgan
Date: 2007-02-13 14:35:35 -0700 (Tue, 13 Feb 2007)
New Revision: 4475
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.h
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.i
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime.cc
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime.h
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime_impl.h
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
Log:
Work in progress. Added disconnect method to gr_hier_block2, no runtime impact
yet.
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
2007-02-13 21:35:35 UTC (rev 4475)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -61,3 +61,10 @@
{
d_detail->connect(src_name, src_port, dst_name, dst_port);
}
+
+void
+gr_hier_block2::disconnect(const std::string &src_name, int src_port,
+ const std::string &dst_name, int dst_port)
+{
+ d_detail->disconnect(src_name, src_port, dst_name, dst_port);
+}
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.h
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.h
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.h
2007-02-13 21:35:35 UTC (rev 4475)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -62,6 +62,8 @@
void define_component(const std::string &name, gr_basic_block_sptr
basic_block);
void connect(const std::string &src_name, int src_port,
const std::string &dst_name, int dst_port);
+ void disconnect(const std::string &src_name, int src_port,
+ const std::string &dst_name, int dst_port);
};
#endif /* INCLUDED_GR_HIER_BLOCK2_H */
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.i
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.i
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2.i
2007-02-13 21:35:35 UTC (rev 4475)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005 Free Software Foundation, Inc.
+ * Copyright 2005,2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -49,4 +49,7 @@
void connect(const std::string &src_name, int src_port,
const std::string &dst_name, int dst_port)
throw (std::invalid_argument);
+ void disconnect(const std::string &src_name, int src_port,
+ const std::string &dst_name, int dst_port)
+ throw (std::invalid_argument);
};
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
2007-02-13 21:35:35 UTC (rev 4475)
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -29,6 +29,8 @@
#include <stdexcept>
#include <iostream>
+#define GR_HIER_BLOCK2_DETAIL_DEBUG 1
+
gr_hier_block2_detail::gr_hier_block2_detail(gr_hier_block2 *owner) :
d_owner(owner)
{
@@ -107,6 +109,23 @@
}
void
+gr_hier_block2_detail::disconnect(const std::string &src_name, int src_port,
+ const std::string &dst_name, int dst_port)
+{
+ for (gr_edge_viter_t p = d_edges.begin(); p != d_edges.end(); p++) {
+ if (((*p)->src_name() == src_name) &&
+ ((*p)->src_port() == src_port) &&
+ ((*p)->dst_name() == dst_name) &&
+ ((*p)->dst_port() == dst_port)) {
+ d_edges.erase(p);
+ return;
+ }
+ }
+
+ throw std::invalid_argument("edge to disconnect not found");
+}
+
+void
gr_hier_block2_detail::check_valid_port(gr_io_signature_sptr sig, int port)
{
if (port < 0)
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h
2007-02-13 21:35:35 UTC (rev 4475)
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -47,6 +47,8 @@
gr_basic_block_sptr lookup_block(const std::string &name);
void connect(const std::string &src_name, int src_port,
const std::string &dst_name, int dst_port);
+ void disconnect(const std::string &src_name, int src_port,
+ const std::string &dst_name, int dst_port);
void check_valid_port(gr_io_signature_sptr sig, int port);
void check_dst_not_used(const std::string name, int port);
void check_type_match(gr_io_signature_sptr src_sig, int src_port,
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime.cc
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime.cc
2007-02-13 21:35:35 UTC (rev 4475)
@@ -53,7 +53,6 @@
static void
runtime_sigint_handler(int signum)
{
-
if (s_runtime)
s_runtime->stop();
}
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime.h
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime.h
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime.h
2007-02-13 21:35:35 UTC (rev 4475)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -29,6 +29,14 @@
gr_runtime_sptr gr_make_runtime(gr_hier_block2_sptr top_block);
+/*!
+ *\brief Runtime object that controls simple flow graph operation
+ *
+ * This class is instantiated with a top-level gr_hier_block2. The
+ * runtime then flattens the hierarchical block into a gr_simple_flowgraph,
+ * and allows control through start(), stop(), wait(), and run().
+ *
+ */
class gr_runtime
{
private:
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime_impl.h
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime_impl.h
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/lib/runtime/gr_runtime_impl.h
2007-02-13 21:35:35 UTC (rev 4475)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -33,6 +33,15 @@
typedef std::vector<gr_scheduler_thread *> gr_scheduler_thread_vector_t;
typedef gr_scheduler_thread_vector_t::iterator gr_scheduler_thread_viter_t;
+/*!
+ *\brief A single thread of execution for the scheduler
+ *
+ * This class implements a single thread that runs undetached, and
+ * invokes the single-threaded block scheduler. The runtime makes
+ * one of these for each distinct partition of a flowgraph and runs
+ * them in parallel.
+ *
+ */
class gr_scheduler_thread : public omni_thread
{
private:
@@ -47,6 +56,13 @@
void stop();
};
+/*!
+ *\brief Implementation details of gr_runtime
+ *
+ * The actual implementation of gr_runtime. Separate class allows
+ * decoupling of changes from dependent classes.
+ *
+ */
class gr_runtime_impl
{
private:
Modified:
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
===================================================================
---
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
2007-02-13 17:42:30 UTC (rev 4474)
+++
gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
2007-02-13 21:35:35 UTC (rev 4475)
@@ -146,93 +146,26 @@
gr.io_signature(0,0,gr.sizeof_int),
gr.io_signature(0,0,gr.sizeof_int))
hblock.check_topology(0, 0);
- """
- def test_019_validate(self):
- hblock = gr.hier_block2("test_block",
- gr.io_signature(0,0,gr.sizeof_int),
- gr.io_signature(0,0,gr.sizeof_int))
- runtime = gr.runtime(hblock)
- runtime.validate()
-
- def test_020_validate_1(self):
- hblock = gr.hier_block2("test_block",
- gr.io_signature(0,0,gr.sizeof_int),
- gr.io_signature(0,0,gr.sizeof_int))
- hblock.define_component("src", gr.null_source(gr.sizeof_int))
- hblock.define_component("dst1", gr.null_sink(gr.sizeof_int))
- hblock.define_component("dst2", gr.null_sink(gr.sizeof_int))
- hblock.connect("src", 0, "dst1", 0)
- hblock.connect("src", 0, "dst2", 0)
- runtime = gr.runtime(hblock)
- runtime.validate()
- def test_021_validate_2(self):
+ def test_019_disconnect(self):
hblock = gr.hier_block2("test_block",
- gr.io_signature(0,0,gr.sizeof_int),
- gr.io_signature(0,0,gr.sizeof_int))
- hblock.define_component("src1", gr.null_source(gr.sizeof_int))
+ gr.io_signature(1,1,gr.sizeof_int),
+ gr.io_signature(1,1,gr.sizeof_int))
hblock.define_component("nop1", gr.nop(gr.sizeof_int))
- hblock.define_component("dst1", gr.null_sink(gr.sizeof_int))
- hblock.define_component("dst2", gr.null_sink(gr.sizeof_int))
- hblock.connect("src1", 0, "nop1", 0)
- hblock.connect("src1", 0, "nop1", 1)
- hblock.connect("nop1", 0, "dst1", 0)
- hblock.connect("nop1", 1, "dst2", 0)
- runtime = gr.runtime(hblock)
- runtime.validate()
-
- def test_022_validate_3(self):
+ hblock.define_component("nop2", gr.nop(gr.sizeof_int))
+ hblock.connect("nop1", 0, "nop2", 0)
+ hblock.disconnect("nop1", 0, "nop2", 0)
+
+ def test_020_disconnect_unknown(self):
hblock = gr.hier_block2("test_block",
- gr.io_signature(0,0,gr.sizeof_int),
- gr.io_signature(0,0,gr.sizeof_int))
- hblock.define_component("src1", gr.null_source(gr.sizeof_int))
+ gr.io_signature(1,1,gr.sizeof_int),
+ gr.io_signature(1,1,gr.sizeof_int))
hblock.define_component("nop1", gr.nop(gr.sizeof_int))
- hblock.define_component("dst1", gr.null_sink(gr.sizeof_int))
- hblock.define_component("dst2", gr.null_sink(gr.sizeof_int))
- hblock.connect("src1", 0, "nop1", 0)
- hblock.connect("src1", 0, "nop1", 2)
- hblock.connect("nop1", 0, "dst1", 0)
- hblock.connect("nop1", 1, "dst2", 0)
- runtime = gr.runtime(hblock)
- self.assertRaises(RuntimeError,
- lambda: runtime.validate())
+ hblock.define_component("nop2", gr.nop(gr.sizeof_int))
+ hblock.connect("nop1", 0, "nop2", 0)
+ self.assertRaises(ValueError,
+ lambda: hblock.disconnect("nop1", 0, "foo", 0))
- def test_023_validate_4(self):
- hblock = gr.hier_block2("test_block",
- gr.io_signature(0,0,gr.sizeof_int),
- gr.io_signature(0,0,gr.sizeof_int))
- hblock.define_component("src1", gr.null_source(gr.sizeof_int))
- hblock.define_component("nop1", gr.nop(gr.sizeof_int))
- hblock.define_component("dst1", gr.null_sink(gr.sizeof_int))
- hblock.define_component("dst2", gr.null_sink(gr.sizeof_int))
- hblock.connect("src1", 0, "nop1", 0)
- hblock.connect("src1", 0, "nop1", 1)
- hblock.connect("nop1", 0, "dst1", 0)
- hblock.connect("nop1", 2, "dst2", 0)
- runtime = gr.runtime(hblock)
- self.assertRaises(RuntimeError,
- lambda: runtime.validate())
- def test_024_validate_5(self):
- hblock = gr.hier_block2("test_block",
- gr.io_signature(0,0,gr.sizeof_int),
- gr.io_signature(0,0,gr.sizeof_int))
- hblock.define_component("src1", gr.null_source(gr.sizeof_int))
- hblock.define_component("nop1", gr.nop(gr.sizeof_int))
- hblock.define_component("dst1", gr.null_sink(gr.sizeof_int))
- hblock.define_component("dst2", gr.null_sink(gr.sizeof_int))
- hblock.connect("src1", 0, "nop1", 0)
- hblock.connect("src1", 0, "nop1", 1)
- hblock.connect("nop1", 0, "dst1", 0)
- hblock.connect("nop1", 1, "dst2", 0)
- runtime = gr.runtime(hblock)
- runtime.validate()
- # Pending implementation of disconnect
- # hblock.disconnect("src1", 0, "nop1", 1)
- # runtime.validate()
- # self.assertRaises(ValueError,
- # lambda: hblock.disconnect("src1", 0, "nop1", 1))
- """
-
if __name__ == "__main__":
gr_unittest.main()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4475 - in gnuradio/branches/developers/jcorgan/ticket-129/gnuradio-core/src: lib/runtime python/gnuradio/gr,
jcorgan <=