JS8Call-Improved master
Loading...
Searching...
No Matches
JS8.h
1#ifndef __JS8
2#define __JS8
3
4#include <QObject>
5#include <QSemaphore>
6#include <QThread>
7#include <array>
8#include <functional>
9#include <string>
10#include <variant>
11
12namespace JS8 {
13Q_NAMESPACE
14
15namespace Costas {
16// JS8 originally used the same Costas arrays as FT8 did, and so
17// that's still the array in use by 'normal' mode. All the other
18// modes use the modified arrays.
19
20enum class Type { ORIGINAL, MODIFIED };
21
22using Array = std::array<std::array<int, 7>, 3>;
23
24constexpr auto array = [] {
25 constexpr auto COSTAS =
26 std::array{std::array{std::array{4, 2, 5, 6, 1, 3, 0},
27 std::array{4, 2, 5, 6, 1, 3, 0},
28 std::array{4, 2, 5, 6, 1, 3, 0}},
29 std::array{std::array{0, 6, 2, 3, 5, 4, 1},
30 std::array{1, 5, 0, 2, 3, 6, 4},
31 std::array{2, 5, 0, 6, 4, 1, 3}}};
32
33 return [COSTAS](Type type) -> Array const & {
34 return COSTAS[static_cast<std::underlying_type_t<Type>>(type)];
35 };
36}();
37} // namespace Costas
38
39void encode(int type, Costas::Array const &costas, const char *message,
40 int *tones);
41
42namespace Event {
44 int submodes;
45};
46
47struct SyncStart {
48 int position;
49 int size;
50};
51
52struct SyncState {
53 enum class Type { CANDIDATE, DECODED } type;
54 int mode;
55 float frequency;
56 float dt;
57 union {
58 int candidate;
59 float decoded;
60 } sync;
61};
62
63struct Decoded {
64 int utc; // you can use the output of code_time() from commons.h here.
65 int snr;
66 float xdt;
67 float frequency;
68 std::string data;
69 int type;
70 float quality;
71 int mode;
72};
73
75 std::size_t decoded;
76};
77
78using Variant =
79 std::variant<DecodeStarted, SyncStart, SyncState, Decoded, DecodeFinished>;
80
81using Emitter = std::function<void(Variant const &)>;
82} // namespace Event
83
84class Worker;
85
86class Decoder : public QObject {
87 Q_OBJECT
88
89 QSemaphore m_semaphore;
90 QThread m_thread;
91 Worker *m_worker;
92
93 public:
94 Decoder(QObject *parent = nullptr);
95
96 signals:
97
98 void decodeEvent(Event::Variant const &);
99
100 public slots:
101
102 void start(QThread::Priority priority);
103 void quit();
104 void decode();
105};
106} // namespace JS8
107
108#endif
Definition JS8.cpp:2572
Definition JS8.h:74
Definition JS8.h:43
Definition JS8.h:63
Definition JS8.h:47
Definition JS8.h:52