SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
satdump::ndsp::Block Class Referenceabstract

Base Block class. More...

#include <block.h>

Inheritance diagram for satdump::ndsp::Block:
satdump::ndsp::BlockSimple< T, T > satdump::ndsp::BlockSimple< complex_t, complex_t > satdump::ndsp::BlockSimple< complex_t, float > satdump::ndsp::BlockSimple< float, complex_t > satdump::ndsp::BlockSimple< Ti, To > satdump::ndsp::ConstellationDisplayBlock satdump::ndsp::CostasBlock satdump::ndsp::CyclostationaryAnalysis satdump::ndsp::DeviceBlock satdump::ndsp::FFTPanBlock satdump::ndsp::FIRBlock< T > satdump::ndsp::FileSourceBlock satdump::ndsp::HilbertBlock satdump::ndsp::HistogramDisplayBlock satdump::ndsp::IQSinkBlock satdump::ndsp::MMClockRecoveryBlock< T > satdump::ndsp::SplitterBlock< T >

Public Types

enum  cfg_res_t { RES_OK = 0 , RES_LISTUPD = 1 , RES_IOUPD = 2 , RES_ERR = 3 }
 set_cfg status. More...

Public Member Functions

std::vector< BlockIOget_inputs ()
 Get the block's input configurations and streams. You should not modify them.
std::vector< BlockIOget_outputs ()
 Get the block's output configurations and streams. You should not modify them.
void set_input (BlockIO f, int i)
 Link an input to an output stream of some sort. This also checks the type of the BlockIO to ensure (some level of) compatibility.
BlockIO get_output (int i, int nbuf)
 Get one of the block's outputs, creating the fifo it if nbuf != 0.
void link (Block *ptr, int output_index, int input_index, int nbuf)
 Link a block's output to another input, more or less just a warper around set_input and set_output.
 Block (std::string id, std::vector< BlockIO > in={}, std::vector< BlockIO > out={})
 Generic constructor, to be overloaded.
virtual nlohmann::ordered_json get_cfg_list ()
 Get parameters LIST of the block's parameters. This does not contain actual values, only a description of what is available. This will contains a name, optionally description, its type and range if applicable, string options and so on. This must be re-pulled in several cases :
virtual nlohmann::json get_cfg (std::string key)=0
 Get parameters of the block as JSON.
nlohmann::json get_cfg ()
 Get parameters of the block as JSON. Unlike get_cfg(key), this returns every single available parameter as declared by get_cfg_list().
virtual cfg_res_t set_cfg (std::string key, nlohmann::json v)=0
 Set parameters of the block from JSON, including potentially IO configurations for blocks that may have variable output sizes. However, you likely should implemenet that in a separate function as well (eg, addVFO or such) for it to be easy to be done in C++ directly, and using said function here. Optionally, this can also be made to be functional while the block is running!
cfg_res_t set_cfg (nlohmann::json v)
 Set parameters of the block from JSON. Essentially the same as set_cfg(key, v), except this will set any number of them at once.
virtual void start ()
 Starts this block's internal thread and loop.
virtual void stop (bool stop_now=false)
 Stops the block, or rather tells the internal loop it should exit & joins the thread to wait. TODOREWORK, potentially allow sending the terminator as well to force-quit.

Public Attributes

const std::string d_id

Protected Member Functions

virtual bool work ()=0
 The actual looping work function meant to handle all the DSP (well, in most blocks)
bool is_work_running ()
template<typename T>
void setValFromJSONIfExists (T &v, nlohmann::json p)
virtual void init ()
 Applies current parameters to the block. This is called automatically once in start(), but may also be called manually by the block as needed.

Protected Attributes

std::vector< BlockIOinputs
std::vector< BlockIOoutputs
bool work_should_exit
 Used to signal to a block it should exit in order to stop(). Usually only needed in sources.

Detailed Description

Base Block class.

This has several goals :

  • First this simply provides an easy-to-use base to implement most DSP blocks, with inputs/outputs passing pointers around, as well as an internal thread to run the actual loop,
  • Secondly, unlike the previous system this class' interface alone is meant to be enough to perform ALL block functions, from configurations to starting/stopping and so on, as well as entirely abstracting types used in IO streams.

See each function's documentation for more information!

Parameters
d_idthe block's ID
inputsthe block's inputs
outputsthe block's outputs

Member Enumeration Documentation

◆ cfg_res_t

set_cfg status.

Parameters
RES_OKApplied fine
RES_LISTUPDget_cfg_list must be pulled again
RES_IOUPDIO Configuration changed (must ALSO re-pull get_cfg_list!!!)
RES_ERRConfig option not applied

Constructor & Destructor Documentation

◆ Block()

satdump::ndsp::Block::Block ( std::string id,
std::vector< BlockIO > in = {},
std::vector< BlockIO > out = {} )
inline

Generic constructor, to be overloaded.

Parameters
idof the block, meant to be a short identifier (eg, agc_cc)
inInputs configurations, optional
outOutput configurations, optional

Member Function Documentation

◆ get_cfg() [1/2]

nlohmann::json satdump::ndsp::Block::get_cfg ( )
inline

Get parameters of the block as JSON. Unlike get_cfg(key), this returns every single available parameter as declared by get_cfg_list().

Returns
All parameters values

◆ get_cfg() [2/2]

◆ get_cfg_list()

virtual nlohmann::ordered_json satdump::ndsp::Block::get_cfg_list ( )
inlinevirtual

Get parameters LIST of the block's parameters. This does not contain actual values, only a description of what is available. This will contains a name, optionally description, its type and range if applicable, string options and so on. This must be re-pulled in several cases :

  • If set_cfg returns RES_LISTUPD or higher
  • If the block is started
  • If the block is stopped
Returns
parameters description

Reimplemented in satdump::ndsp::AGCBlock< T >, satdump::ndsp::FileSourceBlock, satdump::ndsp::FreqShiftBlock, satdump::ndsp::HilbertBlock, satdump::ndsp::MMClockRecoveryBlock< T >, satdump::ndsp::QuadratureDemodBlock, satdump::ndsp::RRC_FIRBlock< T >, and satdump::ndsp::SplitterBlock< T >.

◆ get_inputs()

std::vector< BlockIO > satdump::ndsp::Block::get_inputs ( )
inline

Get the block's input configurations and streams. You should not modify them.

Returns
The block's input BlockIOs.

◆ get_output()

BlockIO satdump::ndsp::Block::get_output ( int i,
int nbuf )
inline

Get one of the block's outputs, creating the fifo it if nbuf != 0.

Parameters
iindex of the output
nbufof buffers to setup in the output
Returns
BlockIO struct of the output

◆ get_outputs()

std::vector< BlockIO > satdump::ndsp::Block::get_outputs ( )
inline

Get the block's output configurations and streams. You should not modify them.

Returns
The block's output BlockIOs.

◆ init()

◆ link()

void satdump::ndsp::Block::link ( Block * ptr,
int output_index,
int input_index,
int nbuf )
inline

Link a block's output to another input, more or less just a warper around set_input and set_output.

Parameters
ptrblock to get the output from
output_indexindex of the output to use, from ptr
input_indexindex of the input to asign no (this block, NOT ptr)
nbufof buffers to setup in the output (see set_input for more info)
Returns
BlockIO struct of the output

◆ set_cfg() [1/2]

cfg_res_t satdump::ndsp::Block::set_cfg ( nlohmann::json v)
inline

Set parameters of the block from JSON. Essentially the same as set_cfg(key, v), except this will set any number of them at once.

Parameters
vvalues to set
Returns
highest error code or status

◆ set_cfg() [2/2]

virtual cfg_res_t satdump::ndsp::Block::set_cfg ( std::string key,
nlohmann::json v )
pure virtual

Set parameters of the block from JSON, including potentially IO configurations for blocks that may have variable output sizes. However, you likely should implemenet that in a separate function as well (eg, addVFO or such) for it to be easy to be done in C++ directly, and using said function here. Optionally, this can also be made to be functional while the block is running!

Parameters
keyparameter to set
vvalue to set
Returns
error code or status.

Implemented in satdump::ndsp::AGCBlock< T >, satdump::ndsp::ConstellationDisplayBlock, satdump::ndsp::CorrectIQBlock< T >, satdump::ndsp::CostasBlock, satdump::ndsp::CyclostationaryAnalysis, satdump::ndsp::DelayOneImagBlock, satdump::ndsp::FFTPanBlock, satdump::ndsp::FileSourceBlock, satdump::ndsp::FIRBlock< T >, satdump::ndsp::FreqShiftBlock, satdump::ndsp::HilbertBlock, satdump::ndsp::HistogramDisplayBlock, satdump::ndsp::IQSinkBlock, satdump::ndsp::MMClockRecoveryBlock< T >, satdump::ndsp::QuadratureDemodBlock, satdump::ndsp::RealToComplexBlock, satdump::ndsp::RRC_FIRBlock< T >, and satdump::ndsp::SplitterBlock< T >.

◆ set_input()

void satdump::ndsp::Block::set_input ( BlockIO f,
int i )
inline

Link an input to an output stream of some sort. This also checks the type of the BlockIO to ensure (some level of) compatibility.

Parameters
finput BlockIO to link to an input
iindex of the input (probably quite often 0)

◆ start()

virtual void satdump::ndsp::Block::start ( )
inlinevirtual

Starts this block's internal thread and loop.

Reimplemented in satdump::ndsp::IQSinkBlock.

◆ stop()

virtual void satdump::ndsp::Block::stop ( bool stop_now = false)
inlinevirtual

Stops the block, or rather tells the internal loop it should exit & joins the thread to wait. TODOREWORK, potentially allow sending the terminator as well to force-quit.

Reimplemented in satdump::ndsp::IQSinkBlock.

◆ work()

virtual bool satdump::ndsp::Block::work ( )
protectedpure virtual

The actual looping work function meant to handle all the DSP (well, in most blocks)

Returns
true if block's thread should exit, usually upon receiving a terminator in the input stream

Implemented in satdump::ndsp::ConstellationDisplayBlock, and satdump::ndsp::HistogramDisplayBlock.


The documentation for this class was generated from the following file: