summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------gnuradio0
-rw-r--r--include/gras/block.hpp22
-rw-r--r--include/gras/top_block.hpp2
-rw-r--r--lib/block.cpp13
-rw-r--r--lib/top_block.cpp6
-rw-r--r--tests/demo_blocks.py4
6 files changed, 32 insertions, 15 deletions
diff --git a/gnuradio b/gnuradio
-Subproject 62fe77518c3466d646cd63ffb6450c6e06c633b
+Subproject e065aad8918d972377807c8296f4dd060f102f6
diff --git a/include/gras/block.hpp b/include/gras/block.hpp
index ec4941f..bde70b1 100644
--- a/include/gras/block.hpp
+++ b/include/gras/block.hpp
@@ -107,13 +107,13 @@ struct GRAS_API Block : Element
******************************************************************/
//! Get the configuration rules of an input port
- InputPortConfig input_config(const size_t which_input) const;
+ InputPortConfig get_input_config(const size_t which_input) const;
//! Set the configuration rules for an input port
void set_input_config(const size_t which_input, const InputPortConfig &config);
//! Get the configuration rules of an output port
- OutputPortConfig output_config(const size_t which_output) const;
+ OutputPortConfig get_output_config(const size_t which_output) const;
//! Set the configuration rules for an output port
void set_output_config(const size_t which_output, const OutputPortConfig &config);
@@ -129,10 +129,10 @@ struct GRAS_API Block : Element
void produce(const size_t num_items, const size_t which_output);
//! Get absolute count of all items consumed on the given input port
- item_index_t num_items_consumed(const size_t which_input);
+ item_index_t get_consumed(const size_t which_input);
//! Get absolute count of all items produced on the given output port
- item_index_t num_items_produced(const size_t which_output);
+ item_index_t get_produced(const size_t which_output);
/*******************************************************************
* Deal with tag handling and tag configuration
@@ -145,6 +145,18 @@ struct GRAS_API Block : Element
TagIter get_input_tags(const size_t which_input);
/*!
+ * Erase all tags on the given input port.
+ * This method may be called from the work() context
+ * to erase all of the queued up tags on the input.
+ * Once erased, messages cannot be propagated downstream.
+ * This method allows a user to treat an input port
+ * as an async message source without a data stream.
+ * In this case, after processing messages from get_input_tags(),
+ * the user should call erase_input_tags() before retuning from work().
+ */
+ void erase_input_tags(const size_t which_input);
+
+ /*!
* Overload me to implement tag propagation logic:
*
* Propagate tags will be given an iterator for all input tags
@@ -157,7 +169,7 @@ struct GRAS_API Block : Element
virtual void propagate_tags(const size_t which_input, const TagIter &iter);
/*******************************************************************
- * Work related routines from basic block
+ * Work related routines and fail states
******************************************************************/
//! Called when the flow graph is started, can overload
diff --git a/include/gras/top_block.hpp b/include/gras/top_block.hpp
index 6a14bdf..2f0dc87 100644
--- a/include/gras/top_block.hpp
+++ b/include/gras/top_block.hpp
@@ -37,7 +37,7 @@ struct GRAS_API TopBlock : HierBlock
TopBlock(const std::string &name);
//! Get the global block config settings
- GlobalBlockConfig global_config(void) const;
+ GlobalBlockConfig get_global_config(void) const;
//! Set the global block config settings
void set_global_config(const GlobalBlockConfig &config);
diff --git a/lib/block.cpp b/lib/block.cpp
index cc22508..ee7142c 100644
--- a/lib/block.cpp
+++ b/lib/block.cpp
@@ -63,7 +63,7 @@ typename V::value_type vector_get(const V &v, const size_t index)
return v[index];
}
-InputPortConfig Block::input_config(const size_t which_input) const
+InputPortConfig Block::get_input_config(const size_t which_input) const
{
return vector_get((*this)->block->input_configs, which_input);
}
@@ -75,7 +75,7 @@ void Block::set_input_config(const size_t which_input, const InputPortConfig &co
(*this)->block->Push(UpdateInputsMessage(), Theron::Address());
}
-OutputPortConfig Block::output_config(const size_t which_output) const
+OutputPortConfig Block::get_output_config(const size_t which_output) const
{
return vector_get((*this)->block->output_configs, which_output);
}
@@ -97,12 +97,12 @@ void Block::produce(const size_t which_output, const size_t num_items)
(*this)->block->produce(which_output, num_items);
}
-item_index_t Block::num_items_consumed(const size_t which_input)
+item_index_t Block::get_consumed(const size_t which_input)
{
return (*this)->block->items_consumed[which_input];
}
-item_index_t Block::num_items_produced(const size_t which_output)
+item_index_t Block::get_produced(const size_t which_output)
{
return (*this)->block->items_produced[which_output];
}
@@ -118,6 +118,11 @@ TagIter Block::get_input_tags(const size_t which_input)
return TagIter(input_tags.begin(), input_tags.end());
}
+void Block::erase_input_tags(const size_t which_input)
+{
+ (*this)->block->input_tags[which_input].clear();
+}
+
void Block::propagate_tags(const size_t, const TagIter &)
{
//NOP
diff --git a/lib/top_block.cpp b/lib/top_block.cpp
index ac1a1a7..345c46b 100644
--- a/lib/top_block.cpp
+++ b/lib/top_block.cpp
@@ -42,7 +42,7 @@ void ElementImpl::top_block_cleanup(void)
<< std::flush;
}
-GlobalBlockConfig TopBlock::global_config(void) const
+GlobalBlockConfig TopBlock::get_global_config(void) const
{
return (*this)->top_config;
}
@@ -147,12 +147,12 @@ void TopBlock::run(const size_t max_items)
int TopBlock::max_noutput_items(void) const
{
- return this->global_config().maximum_output_items;
+ return this->get_global_config().maximum_output_items;
}
void TopBlock::set_max_noutput_items(int max_items)
{
- gras::GlobalBlockConfig config = this->global_config();
+ gras::GlobalBlockConfig config = this->get_global_config();
config.maximum_output_items = max_items;
this->set_global_config(config);
}
diff --git a/tests/demo_blocks.py b/tests/demo_blocks.py
index 2b2d8dd..6aae136 100644
--- a/tests/demo_blocks.py
+++ b/tests/demo_blocks.py
@@ -67,7 +67,7 @@ class TagSource(gras.Block):
self._values = values
def work(self, ins, outs):
- offset = self.num_items_produced(0)
+ offset = self.get_produced(0)
tag = gras.Tag(offset, 'key', self._values[0])
self.post_output_tag(0, tag)
self.produce(0, len(outs[0]))
@@ -87,7 +87,7 @@ class TagSink(gras.Block):
return tuple(self._values)
def work(self, ins, outs):
- max_read = self.num_items_consumed(0) + len(ins[0])
+ max_read = self.get_consumed(0) + len(ins[0])
for tag in self.get_input_tags(0):
if tag.offset < max_read:
self._values.append(tag.value)