SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
throttle.h
1#pragma once
2
3#include "dsp/block.h"
4#include "dsp/block_simple.h"
5#include <cstdint>
6
7namespace satdump
8{
9 namespace ndsp
10 {
11
12 template <typename T>
13 class ThrottleBlock : public BlockSimple<T, T>
14 {
15 private:
16 bool needs_reinit = true;
17 double samplerate = 1e6;
18
19 std::chrono::steady_clock::time_point start_time_point;
20 std::chrono::duration<double> sample_time_period;
21 unsigned long long total_samples = 0;
22
23 public:
24 ThrottleBlock();
25 ~ThrottleBlock();
26
27 uint32_t process(T *input, uint32_t nsamples, T *output);
28
29 void init() {}
30
31 nlohmann::ordered_json get_cfg_list()
32 {
33 nlohmann::ordered_json p;
34 add_param_simple(p, "samplerate", "float", "Samplerate");
35 return p;
36 }
37
38 nlohmann::json get_cfg(std::string key)
39 {
40 if (key == "samplerate")
41 return samplerate;
42 else
43 throw satdump_exception(key);
44 }
45
46 Block::cfg_res_t set_cfg(std::string key, nlohmann::json v)
47 {
48 if (key == "samplerate")
49 {
50 samplerate = v;
51 needs_reinit = true;
52 }
53 else
54 throw satdump_exception(key);
55 return Block::RES_OK;
56 }
57 };
58 } // namespace ndsp
59} // namespace satdump
cfg_res_t
set_cfg status.
Definition block.h:241
nlohmann::json get_cfg(std::string key)
Get parameters of the block as JSON.
Definition throttle.h:38
nlohmann::ordered_json get_cfg_list()
Get parameters LIST of the block's parameters. This does not contain actual values,...
Definition throttle.h:31
uint32_t process(T *input, uint32_t nsamples, T *output)
Simplified "work" function, called automatically by work(). This takes away all boilerplate work usua...
Definition throttle.cpp:22
void init()
Applies current parameters to the block. This is called automatically once in start(),...
Definition throttle.h:29
Block::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 throttle.h:46