summaryrefslogtreecommitdiff
path: root/TxStartPolicy.hpp
blob: 2aef9a52f379c3f2f96588318200ad41b606b9d9 (plain)
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
#ifndef TXSTARTPOLICY_HPP__
#define TXSTARTPOLICY_HPP__

#include <QString>

constexpr double TxStartLatestPeriodFraction = 0.75;

inline bool requires_standard_tx_message (QString const& mode)
{
  // These modes synthesize their Tx payload outside the standard Tx1-Tx6 slots.
  return mode != "Echo" && mode != "WSPR" && mode != "FST4W" && mode != "JTTY";
}

inline bool tx_payload_ready (QString const& mode, int standard_message_length)
{
  return !requires_standard_tx_message (mode) || standard_message_length > 0;
}

inline bool should_stop_for_missing_tx_payload (QString const& mode,
                                                int standard_message_length,
                                                bool tuning)
{
  return !tuning && !tx_payload_ready (mode, standard_message_length);
}

inline bool tx_start_window_open (QString const& mode, bool tx_time, double period_fraction)
{
  return mode == "JTTY"
    || (tx_time && period_fraction < TxStartLatestPeriodFraction);
}

inline bool can_start_transmit (QString const& mode, bool tx_time,
                                double period_fraction, int standard_message_length,
                                bool tuning)
{
  return tuning || (tx_start_window_open (mode, tx_time, period_fraction)
                    && tx_payload_ready (mode, standard_message_length));
}

inline bool should_block_generated_transmit (QString const& generated_message, bool tuning)
{
  return !tuning
    && generated_message.trimmed () == QStringLiteral ("*** bad message ***");
}

#endif