mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-26 22:28:41 -05:00
cbd4f109a8
RIGCTRL is defined as a log channel for rig control messages and the appropriate logger is made available to children of the Transceiver class. Use Transceiver::logger() to access the logger. Switched existing rig control QDebug messages to Boost logging.
70 lines
2.4 KiB
C++
70 lines
2.4 KiB
C++
#include "EmulateSplitTransceiver.hpp"
|
|
|
|
#include "moc_EmulateSplitTransceiver.cpp"
|
|
|
|
EmulateSplitTransceiver::EmulateSplitTransceiver (logger_type * logger,
|
|
std::unique_ptr<Transceiver> wrapped,
|
|
QObject * parent)
|
|
: Transceiver {logger, 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);
|
|
}
|
|
}
|