3#include "common/dsp/complex.h"
13 class SplitterBlock :
public Block
23 bool forward_terminator;
37 nlohmann::ordered_json p;
38 add_param_simple(p,
"noutputs",
"int");
39 p[
"noutputs"][
"disable"] = is_work_running();
45 if (key ==
"noutputs")
47 throw satdump_exception(key);
52 std::lock_guard<std::mutex> lock_mtx(vfos_mtx);
54 if (key ==
"noutputs")
64 Block::outputs.clear();
65 for (
int i = 0; i < p_noutputs; i++)
67 BlockIO o = {{
"out" + std::to_string(i + 1), std::is_same_v<T, complex_t> ? DSP_SAMPLE_TYPE_CF32 : DSP_SAMPLE_TYPE_F32}};
68 o.blkdata = std::make_shared<IOInfo>(
IOInfo{std::to_string(i + 1),
true});
69 o.fifo = std::make_shared<DSPStream>(4);
70 Block::outputs.push_back(o);
76 throw satdump_exception(key);
81 BlockIO &add_output(std::string
id,
bool forward_terminator =
true)
83 std::lock_guard<std::mutex> lock_mtx(vfos_mtx);
85 BlockIO o = {{id, std::is_same_v<T, complex_t> ? DSP_SAMPLE_TYPE_CF32 : DSP_SAMPLE_TYPE_F32}};
86 o.blkdata = std::make_shared<IOInfo>(IOInfo{id, forward_terminator});
87 o.fifo = std::make_shared<DSPStream>(4);
88 Block::outputs.push_back(o);
89 return outputs[outputs.size() - 1];
92 void del_output(std::string
id,
bool send_terminator)
94 std::lock_guard<std::mutex> lock_mtx(vfos_mtx);
96 for (
int i = 0; i < outputs.size(); i++)
97 if (((
IOInfo *)outputs[i].blkdata.get())->id ==
id)
100 (outputs.begin() + i)->fifo->wait_enqueue((outputs.begin() + i)->fifo->newBufferTerminator());
101 outputs.erase(outputs.begin() + i);
cfg_res_t
set_cfg status.
Definition block.h:227
virtual bool work()=0
The actual looping work function meant to handle all the DSP (well, in most blocks)
Block(std::string id, std::vector< BlockIO > in={}, std::vector< BlockIO > out={})
Generic constructor, to be overloaded.
Definition block.h:206
void init()
Applies current parameters to the block. This is called automatically once in start(),...
Definition splitter.h:33
nlohmann::ordered_json get_cfg_list()
Get parameters LIST of the block's parameters. This does not contain actual values,...
Definition splitter.h:35
cfg_res_t set_cfg(std::string key, nlohmann::json v)
Set parameters of the block from JSON, including potentially IO configurations for blocks that may ha...
Definition splitter.h:50
nlohmann::json get_cfg(std::string key)
Get parameters of the block as JSON.
Definition splitter.h:43
Block IO helper class.
Definition block.h:42