SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
nng_iq_sink.h
1#pragma once
2
3#include "dsp/block.h"
4#include <nng/nng.h>
5
6namespace satdump
7{
8 namespace ndsp
9 {
10 class NNGIQSinkBlock : public Block
11 {
12
13 private:
14 std::string address = "0.0.0.0";
15 int port = 8888;
16
17 nng_socket sock;
18 nng_listener listener;
19
20 bool work();
21
22 public:
23 void start();
24 void stop(bool stop_now = false, bool force=false);
25
26 public:
27 NNGIQSinkBlock();
28 ~NNGIQSinkBlock();
29
30 nlohmann::ordered_json get_cfg_list()
31 {
32 nlohmann::ordered_json p;
33 add_param_simple(p, "address", "string");
34 p["address"]["disable"] = is_work_running();
35 add_param_simple(p, "port", "int");
36 p["port"]["disable"] = is_work_running();
37 return p;
38 }
39
40 nlohmann::json get_cfg(std::string key)
41 {
42 if (key == "address")
43 return address;
44 else if (key == "port")
45 return port;
46 else
47 throw satdump_exception(key);
48 }
49
50 cfg_res_t set_cfg(std::string key, nlohmann::json v)
51 {
52 if (key == "address")
53 address = v;
54 else if (key == "port")
55 port = v;
56 else
57 throw satdump_exception(key);
58 return RES_OK;
59 }
60 };
61 } // namespace ndsp
62} // namespace satdump
cfg_res_t
set_cfg status.
Definition block.h:241
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:208
nlohmann::json get_cfg(std::string key)
Get parameters of the block as JSON.
Definition nng_iq_sink.h:40
void stop(bool stop_now=false, bool force=false)
Stops the block, or rather tells the internal loop it should exit & joins the thread to wait....
Definition nng_iq_sink.cpp:27
void start()
Starts this block's internal thread and loop.
Definition nng_iq_sink.cpp:16
nlohmann::ordered_json get_cfg_list()
Get parameters LIST of the block's parameters. This does not contain actual values,...
Definition nng_iq_sink.h:30
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 nng_iq_sink.h:50