SatDump 2.0.0-alpha-520736c72
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 MODE_RX_TX = 3,
36 };
37
38 protected:
39 DeviceInfo devInfo;
40 device_mode_t devMode = MODE_NORMAL;
41
42 public:
43 DeviceBlock(std::string id, std::vector<BlockIO> in = {}, std::vector<BlockIO> out = {}) : Block(id, in, out) {}
44
45 virtual void setDevInfo(DeviceInfo i, device_mode_t m)
46 {
47 devInfo = i, devMode = m;
48 set_cfg(devInfo.cfg);
49 }
50
51 // TODOREWORK helper functions for basic functions
52 virtual double getStreamSamplerate(int id, bool output) = 0;
53 virtual void setStreamSamplerate(int id, bool output, double samplerate) = 0;
54 virtual double getStreamFrequency(int id, bool output) = 0;
55 virtual void setStreamFrequency(int id, bool output, double frequency) = 0;
56 };
57
59 {
60 std::vector<DeviceInfo> &i;
61 DeviceBlock::device_mode_t m;
62 };
63
64 std::vector<DeviceInfo> getDeviceList(DeviceBlock::device_mode_t m);
65
67 {
68 DeviceInfo info;
69 std::vector<std::shared_ptr<DeviceBlock>> &i;
70 };
71
72 std::shared_ptr<DeviceBlock> getDeviceInstanceFromInfo(DeviceInfo i, DeviceBlock::device_mode_t m);
73 } // namespace ndsp
74} // 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:208
Definition dev.h:12