1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#ifndef FT8_MTD_DECODE_COORDINATOR_HPP
#define FT8_MTD_DECODE_COORDINATOR_HPP
#include <functional>
#include <memory>
#include <QtGlobal>
#include "DecodeOperatingContext.hpp"
#include "DecoderIpc.hpp"
#include "Ft8MtdDecodeScheduler.hpp"
class Ft8MtdDecodeCoordinator
{
public:
using Stage = Ft8MtdDecodeScheduler::Stage;
using Action = Ft8MtdDecodeScheduler::Action;
using Decision = Ft8MtdDecodeScheduler::Decision;
struct PendingMtdDecode
{
DecoderIpc::Ft8MtdPayload payload;
DecodeOperatingContext context;
qint64 period {0};
};
enum class PendingPublishResult
{
Published,
Unavailable,
Failed
};
enum class DrainResult
{
NoPending,
Published,
Retained,
Obsolete,
Failed
};
struct DrainOutcome
{
DrainResult result {DrainResult::NoPending};
qint64 period {0};
bool recovered {false};
};
using PendingValidator = std::function<bool (PendingMtdDecode const&)>;
using PendingPublisher =
std::function<PendingPublishResult (PendingMtdDecode const&)>;
Decision request (Stage stage, qint64 period, int earlyStageCount,
bool decoderBusy);
bool published (Stage stage, qint64 period);
void completed (Stage stage, qint64 period);
void publicationFailed (Stage stage, qint64 period);
Action deferFinal (std::unique_ptr<PendingMtdDecode> pending);
DrainOutcome drainPending (PendingValidator const& validator,
PendingPublisher const& publisher);
void cancel ();
bool hasPending () const {return bool {pending_};}
bool degraded () const {return scheduler_.degraded ();}
int skippedPeriods () const {return scheduler_.skippedPeriods ();}
qint64 nextProbePeriod () const {return scheduler_.nextProbePeriod ();}
private:
Ft8MtdDecodeScheduler scheduler_;
std::unique_ptr<PendingMtdDecode> pending_;
};
#endif
|