SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
dev.h
1#pragma once
2
3#include "dsp/block.h"
4#include <cstdint>
5
6// TODOREWORK DOCUMENT
7namespace satdump
8{
9 namespace ndsp
10 {
12 {
13 std::string type; // SDR Type ID string
14 std::string name; // Display name
15 nlohmann::json cfg; // Default parameters for the block to use THIS device (eg, Serial). Applied with set_cfg
16 nlohmann::json params; // List of additional parameters that may be device-specific (eg, Airspy Mini vs Airspy R2)
17
18 bool operator==(const DeviceInfo &b) { return ((type == b.type) && (name == b.type) && (cfg == b.cfg) && (params == b.params)); }
19
20 NLOHMANN_DEFINE_TYPE_INTRUSIVE(DeviceInfo, type, name, cfg, params)
21 };
22
23 class DeviceBlock : public Block
24 {
25 private:
26 bool work() { throw satdump_exception("Device Source and/or Sync does not implement work. Should NOT have been called!"); }
27
28 public:
29 // TODOREWORK?
30 enum device_mode_t
31 {
32 MODE_NORMAL = 0,
33 MODE_SINGLE_RX = 1,
34 MODE_SINGLE_TX = 2,
35 };
36
37 protected:
38 DeviceInfo devInfo;
39 device_mode_t devMode = MODE_NORMAL;
40
41 public:
42 DeviceBlock(std::string id, std::vector<BlockIO> in = {}, std::vector<BlockIO> out = {}) : Block(id, in, out) {}
43
44 virtual void setDevInfo(DeviceInfo i, device_mode_t m)
45 {
46 devInfo = i, devMode = m;
47 set_cfg(devInfo.cfg);
48 }
49
50 // TODOREWORK helper functions for basic functions
51 virtual double getStreamSamplerate(int id, bool output) = 0;
52 virtual void setStreamSamplerate(int id, bool output, double samplerate) = 0;
53 virtual double getStreamFrequency(int id, bool output) = 0;
54 virtual void setStreamFrequency(int id, bool output, double frequency) = 0;
55 };
56
58 {
59 std::vector<DeviceInfo> &i;
60 DeviceBlock::device_mode_t m;
61 };
62
63 std::vector<DeviceInfo> getDeviceList(DeviceBlock::device_mode_t m);
64
66 {
67 DeviceInfo info;
68 std::vector<std::shared_ptr<DeviceBlock>> &i;
69 };
70
71 std::shared_ptr<DeviceBlock> getDeviceInstanceFromInfo(DeviceInfo i, DeviceBlock::device_mode_t m);
72 } // namespace ndsp
73} // namespace satdump
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 ha...
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
Definition dev.h:12