SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
testremote_backend.h
1#pragma once
2
3#include "base/remote_handler_backend.h"
4#include "core/exception.h"
5#include "nlohmann/json.hpp"
6#include <cstddef>
7#include <cstdint>
8#include <functional>
9#include <mutex>
10#include <string>
11
12namespace satdump
13{
14 namespace handlers
15 {
16 class TestRemoteHandlerBackend : public RemoteHandlerBackend
17 {
18 private:
19 double val = 0;
20
21 public:
22 TestRemoteHandlerBackend() {}
23 ~TestRemoteHandlerBackend() {}
24
25 nlohmann::ordered_json _get_cfg_list()
26 {
27 nlohmann::ordered_json p;
28 p["val"]["type"] = "float";
29 return p;
30 }
31
32 nlohmann::ordered_json _get_cfg(std::string key)
33 {
34 if (key == "val")
35 return val;
36 else
37 throw satdump_exception("Oops");
38 }
39
40 cfg_res_t _set_cfg(std::string key, nlohmann::ordered_json v)
41 {
42 if (key == "val")
43 {
44 if (v < 0)
45 v = -100;
46
47 val = v;
48 }
49 else
50 throw satdump_exception("Oops");
51
52 return RES_OK;
53 }
54 };
55 } // namespace handlers
56} // namespace satdump