SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
iq_sink.h
1#pragma once
2
3#include "common/dsp/block.h"
4#include "common/dsp/complex.h"
5#include "dsp/block.h"
6#include "iq_types.h"
7#include <cstdint>
8#include <cstdio>
9
10namespace satdump
11{
12 namespace ndsp
13 {
14 class IQSinkBlock : public Block
15 {
16 public:
17 size_t total_written_raw;
18 size_t total_written_bytes_compressed;
19
20 private:
21 int buffer_size = 1024 * 1024; // TODOREWORK
22 std::string filepath;
23 IQType format;
24 bool autogen = false;
25 double samplerate = 1e6;
26 double frequency = 100e6;
27 double timestamp = 0;
28
29 FILE *file_stream = nullptr;
30 void *buffer_convert = nullptr;
31
32 bool work();
33
34 public:
35 void start();
36 void stop(bool stop_now = false);
37
38 public:
39 IQSinkBlock();
40 ~IQSinkBlock();
41
42 void init() {}
43
44 nlohmann::json get_cfg(std::string key)
45 {
46 if (key == "buffer_size")
47 return filepath;
48 else if (key == "path")
49 return filepath;
50 else if (key == "format")
51 return format;
52 else if (key == "autogen")
53 return autogen;
54 else if (key == "samplerate")
55 return samplerate;
56 else if (key == "frequency")
57 return frequency;
58 else if (key == "timestamp")
59 return timestamp;
60 else
61 throw satdump_exception(key);
62 }
63
64 cfg_res_t set_cfg(std::string key, nlohmann::json v)
65 {
66 if (key == "buffer_size")
67 buffer_size = v;
68 else if (key == "filepath")
69 filepath = v;
70 else if (key == "format")
71 format = v.get<std::string>();
72 else if (key == "samplerate")
73 samplerate = v;
74 else if (key == "autogen")
75 autogen = v;
76 else if (key == "frequency")
77 frequency = v;
78 else if (key == "timestamp")
79 timestamp = v;
80 else
81 throw satdump_exception(key);
82 return RES_OK;
83 }
84
85 public:
86 static std::string prepareBasebandFileName(double timeValue_precise, uint64_t samplerate, uint64_t frequency);
87 };
88 } // namespace ndsp
89} // namespace satdump
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
nlohmann::json get_cfg(std::string key)
Get parameters of the block as JSON.
Definition iq_sink.h:44
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 iq_sink.h:64
void start()
Starts this block's internal thread and loop.
Definition iq_sink.cpp:20
void stop(bool stop_now=false)
Stops the block, or rather tells the internal loop it should exit & joins the thread to wait....
Definition iq_sink.cpp:46
void init()
Applies current parameters to the block. This is called automatically once in start(),...
Definition iq_sink.h:42
Definition iq_types.h:26