mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-18 01:52:05 -05:00
28b4c31dee
Make WSPRnet.org spot uploads tolerant of network issues, spots still get discarded for any period that has problems but now uploading resumes on the next period. Ensure that decoded text starts with correct font by not using the base class append method directly. Fixed a major memory leak in the WSPRNet class which was not freeing processed request reply objects. Added some helpful debug prints in WSPRnet.org spot processing. Also tidied up a number of class implementations that were not including he MOC generated code. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5560 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
298 lines
5.1 KiB
C++
298 lines
5.1 KiB
C++
#include "TransceiverBase.hpp"
|
|
|
|
#include <exception>
|
|
|
|
#include <QString>
|
|
#include <QTimer>
|
|
#include <QThread>
|
|
#include <QDebug>
|
|
|
|
#include "moc_TransceiverBase.cpp"
|
|
|
|
namespace
|
|
{
|
|
auto const unexpected = TransceiverBase::tr ("Unexpected rig error");
|
|
}
|
|
|
|
void TransceiverBase::start () noexcept
|
|
{
|
|
QString message;
|
|
try
|
|
{
|
|
if (state_.online ())
|
|
{
|
|
try
|
|
{
|
|
// try and ensure PTT isn't left set
|
|
do_ptt (false);
|
|
do_post_ptt (false);
|
|
}
|
|
catch (...)
|
|
{
|
|
// don't care about exceptions
|
|
}
|
|
do_stop ();
|
|
do_post_stop ();
|
|
}
|
|
do_start ();
|
|
do_post_start ();
|
|
state_.online (true);
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = unexpected;
|
|
}
|
|
if (!message.isEmpty ())
|
|
{
|
|
offline (message);
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::stop () noexcept
|
|
{
|
|
QString message;
|
|
try
|
|
{
|
|
if (state_.online ())
|
|
{
|
|
try
|
|
{
|
|
// try and ensure PTT isn't left set
|
|
do_ptt (false);
|
|
do_post_ptt (false);
|
|
}
|
|
catch (...)
|
|
{
|
|
// don't care about exceptions
|
|
}
|
|
}
|
|
do_stop ();
|
|
do_post_stop ();
|
|
state_.online (false);
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = unexpected;
|
|
}
|
|
if (!message.isEmpty ())
|
|
{
|
|
offline (message);
|
|
}
|
|
else
|
|
{
|
|
Q_EMIT finished ();
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::frequency (Frequency f, MODE m) noexcept
|
|
{
|
|
QString message;
|
|
try
|
|
{
|
|
if (state_.online ())
|
|
{
|
|
do_frequency (f, m);
|
|
do_post_frequency (f, m);
|
|
}
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = unexpected;
|
|
}
|
|
if (!message.isEmpty ())
|
|
{
|
|
offline (message);
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::tx_frequency (Frequency tx, bool rationalise_mode) noexcept
|
|
{
|
|
QString message;
|
|
try
|
|
{
|
|
if (state_.online ())
|
|
{
|
|
do_tx_frequency (tx, rationalise_mode);
|
|
do_post_tx_frequency (tx, rationalise_mode);
|
|
}
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = unexpected;
|
|
}
|
|
if (!message.isEmpty ())
|
|
{
|
|
offline (message);
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::mode (MODE m, bool rationalise) noexcept
|
|
{
|
|
QString message;
|
|
try
|
|
{
|
|
if (state_.online ())
|
|
{
|
|
do_mode (m, rationalise);
|
|
do_post_mode (m, rationalise);
|
|
}
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = unexpected;
|
|
}
|
|
if (!message.isEmpty ())
|
|
{
|
|
offline (message);
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::ptt (bool on) noexcept
|
|
{
|
|
QString message;
|
|
try
|
|
{
|
|
if (state_.online ())
|
|
{
|
|
do_ptt (on);
|
|
do_post_ptt (on);
|
|
}
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = unexpected;
|
|
}
|
|
if (!message.isEmpty ())
|
|
{
|
|
offline (message);
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::sync (bool force_signal) noexcept
|
|
{
|
|
QString message;
|
|
try
|
|
{
|
|
if (state_.online ())
|
|
{
|
|
do_sync (force_signal);
|
|
}
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = unexpected;
|
|
}
|
|
if (!message.isEmpty ())
|
|
{
|
|
offline (message);
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::update_rx_frequency (Frequency rx)
|
|
{
|
|
state_.frequency (rx);
|
|
}
|
|
|
|
void TransceiverBase::update_other_frequency (Frequency tx)
|
|
{
|
|
state_.tx_frequency (tx);
|
|
}
|
|
|
|
void TransceiverBase::update_split (bool state)
|
|
{
|
|
state_.split (state);
|
|
}
|
|
|
|
void TransceiverBase::update_mode (MODE m)
|
|
{
|
|
state_.mode (m);
|
|
}
|
|
|
|
void TransceiverBase::update_PTT (bool state)
|
|
{
|
|
auto prior = state_.ptt ();
|
|
state_.ptt (state);
|
|
if (state != prior)
|
|
{
|
|
// always signal PTT changes because some MainWindow logic
|
|
// depends on it
|
|
update_complete ();
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::updated ()
|
|
{
|
|
if (do_pre_update ())
|
|
{
|
|
Q_EMIT update (state_);
|
|
}
|
|
}
|
|
|
|
void TransceiverBase::update_complete ()
|
|
{
|
|
// Use a timer to ensure that the calling function completes before
|
|
// the Transceiver::update signal is triggered.
|
|
QTimer::singleShot (0, this, SLOT (updated ()));
|
|
}
|
|
|
|
void TransceiverBase::offline (QString const& reason)
|
|
{
|
|
QString message;
|
|
try
|
|
{
|
|
if (state_.online ())
|
|
{
|
|
try
|
|
{
|
|
// try and ensure PTT isn't left set
|
|
do_ptt (false);
|
|
do_post_ptt (false);
|
|
}
|
|
catch (...)
|
|
{
|
|
// don't care about exceptions
|
|
}
|
|
}
|
|
do_stop ();
|
|
do_post_stop ();
|
|
state_.online (false);
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = unexpected;
|
|
}
|
|
Q_EMIT failure (reason + '\n' + message);
|
|
}
|