summaryrefslogtreecommitdiff
path: root/lib/block.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/block.cpp')
-rw-r--r--lib/block.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/lib/block.cpp b/lib/block.cpp
index 1581266..2d5b4af 100644
--- a/lib/block.cpp
+++ b/lib/block.cpp
@@ -35,6 +35,7 @@ Block::Block(const std::string &name)
(*this)->unique_id = ++unique_id_pool;
this->set_history(0);
this->set_output_multiple(1);
+ this->set_fixed_rate(true);
this->set_relative_rate(1.0);
this->set_tag_propagation_policy(TPP_ALL_TO_ALL);
@@ -44,7 +45,6 @@ Block::Block(const std::string &name)
//TODO other callbacks
(*this)->block = tsbe::Block(config);
-
}
@@ -120,6 +120,29 @@ void Block::set_output_multiple(const size_t multiple, const size_t which_output
vector_set((*this)->output_multiple_items, multiple, which_output);
}
+void Block::consume(const size_t which_input, const size_t how_many_items)
+{
+ (*this)->consume_items[which_input] = how_many_items;
+}
+
+void Block::consume_each(const size_t how_many_items)
+{
+ for (size_t i = 0; i < (*this)->consume_items.size(); i++)
+ {
+ (*this)->consume_items[i] = how_many_items;
+ }
+}
+
+void Block::produce(const size_t which_output, const size_t how_many_items)
+{
+ (*this)->produce_items[which_output] = how_many_items;
+}
+
+void Block::set_fixed_rate(const bool fixed_rate)
+{
+ (*this)->enble_fixed_rate = fixed_rate;
+}
+
void Block::set_relative_rate(double relative_rate)
{
(*this)->relative_rate = relative_rate;
@@ -209,3 +232,30 @@ void Block::get_tags_in_range(
}
}
}
+
+static int mylround(double x)
+{
+ return int(x + 0.5);
+}
+
+void Block::forecast(
+ int noutput_items,
+ std::vector<size_t> &ninput_items_required
+){
+ for (size_t i = 0; i < ninput_items_required.size(); i++)
+ {
+ ninput_items_required[i] =
+ (*this)->input_history_items[i] +
+ mylround((noutput_items/(*this)->relative_rate));
+ }
+}
+
+bool Block::start(void)
+{
+ return true;
+}
+
+bool Block::stop(void)
+{
+ return true;
+}