-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmulateSplitTransceiver.cpp
65 lines (56 loc) · 2.19 KB
/
EmulateSplitTransceiver.cpp
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
#include "EmulateSplitTransceiver.hpp"
EmulateSplitTransceiver::EmulateSplitTransceiver (std::unique_ptr<Transceiver> wrapped, QObject * parent)
: Transceiver {parent}
, wrapped_ {std::move (wrapped)}
, rx_frequency_ {0}
, tx_frequency_ {0}
, split_ {false}
{
// Connect update signal of wrapped Transceiver object instance to ours.
connect (wrapped_.get (), &Transceiver::update, this, &EmulateSplitTransceiver::handle_update);
// Connect other signals of wrapped Transceiver object to our
// parent matching signals.
connect (wrapped_.get (), &Transceiver::resolution, this, &Transceiver::resolution);
connect (wrapped_.get (), &Transceiver::finished, this, &Transceiver::finished);
connect (wrapped_.get (), &Transceiver::failure, this, &Transceiver::failure);
}
void EmulateSplitTransceiver::set (TransceiverState const& s, unsigned sequence_number) noexcept
{
#if WSJT_TRACE_CAT
qDebug () << "EmulateSplitTransceiver::set: state:" << s << "#:" << sequence_number;
#endif
// save for use in updates
rx_frequency_ = s.frequency ();
tx_frequency_ = s.tx_frequency ();
split_ = s.split ();
TransceiverState emulated_state {s};
if (s.ptt () && split_) emulated_state.frequency (s.tx_frequency ());
emulated_state.split (false);
emulated_state.tx_frequency (0);
wrapped_->set (emulated_state, sequence_number);
}
void EmulateSplitTransceiver::handle_update (TransceiverState const& state,
unsigned sequence_number)
{
#if WSJT_TRACE_CAT
qDebug () << "EmulateSplitTransceiver::handle_update: from wrapped:" << state;
#endif
if (state.split ())
{
Q_EMIT failure (tr ("Emulated split mode requires rig to be in simplex mode"));
}
else
{
TransceiverState new_state {state};
// Follow the rig if in RX mode.
if (state.ptt ()) new_state.frequency (rx_frequency_);
// These are always what was requested in prior set state operation
new_state.tx_frequency (tx_frequency_);
new_state.split (split_);
#if WSJT_TRACE_CAT
qDebug () << "EmulateSplitTransceiver::handle_update: signalling:" << state;
#endif
// signal emulated state
Q_EMIT update (new_state, sequence_number);
}
}