Additiona PSK thread hardening, for Joe

This commit is contained in:
Allan Bazinet
2024-11-09 19:09:42 -08:00
parent 6bf5dc3556
commit aaae6a9aad
3 changed files with 57 additions and 30 deletions

View File

@@ -284,6 +284,7 @@ public:
quint32 sequence_number_ = 0u;
unsigned send_descriptors_ = 0u;
unsigned flush_counter_ = 0u;
bool once_ = false;
// Constructor
@@ -296,6 +297,31 @@ public:
, prog_id_ {program_info}
, report_timer_ {this}
, descriptor_timer_ {this}
{
// Attempt to load up the eclipse dates. Not a big deal if this fails;
// just means that we won't bypass the spot cache during eclipse periods.
if (auto file = QFile(config->data_dir().absoluteFilePath("eclipse.txt"));
file.open(QIODevice::ReadOnly))
{
auto text = QTextStream(&file);
for (QString line; text.readLineInto(&line);)
{
if (line.isEmpty()) continue;
if (line[0] == '#') continue;
if (auto const date = QDateTime::fromString(line, Qt::ISODate);
date.isValid())
{
eclipseDates_.append(date);
}
}
}
}
void
start()
{
// This timer sets the interval to check for spots to send.
@@ -319,27 +345,6 @@ public:
send_descriptors_ = 3; // Send format descriptors again, 3 times.
}
});
// Attempt to load up the eclipse dates. Not a big deal if this fails;
// just means that we won't bypass the spot cache during eclipse periods.
if (auto file = QFile(config->data_dir().absoluteFilePath("eclipse.txt"));
file.open(QIODevice::ReadOnly))
{
auto text = QTextStream(&file);
for (QString line; text.readLineInto(&line);)
{
if (line.isEmpty()) continue;
if (line[0] == '#') continue;
if (auto const date = QDateTime::fromString(line, Qt::ISODate);
date.isValid())
{
eclipseDates_.append(date);
}
}
}
}
void
@@ -641,7 +646,18 @@ PSKReporter::PSKReporter(Configuration const * config,
PSKReporter::~PSKReporter() = default;
void PSKReporter::reconnect()
void
PSKReporter::start()
{
if (!m_->once_)
{
m_->once_ = true;
m_->start();
}
}
void
PSKReporter::reconnect()
{
m_->reconnect();
}

View File

@@ -8,25 +8,35 @@
class QString;
class Configuration;
class PSKReporter final
: public QObject
class PSKReporter final : public QObject
{
Q_OBJECT
public:
explicit PSKReporter (Configuration const *, QString const& program_info);
~PSKReporter ();
void reconnect ();
explicit PSKReporter(Configuration const *,
QString const & program_info);
void setLocalStation (QString const& call, QString const& grid, QString const& antenna);
~PSKReporter();
void addRemoteStation (QString const& call, QString const& grid, Radio::Frequency freq, QString const& mode, int snr);
void start();
void reconnect();
void setLocalStation(QString const & call,
QString const & grid,
QString const & antenna);
void addRemoteStation(QString const & call,
QString const & grid,
Radio::Frequency freq,
QString const & mode,
int snr);
//
// Flush any pending spots to PSK Reporter
//
void sendReport (bool last = false);
void sendReport(bool last = false);
Q_SIGNAL void errorOccurred (QString const& reason);

View File

@@ -498,6 +498,7 @@ MainWindow::MainWindow(QString const & program_info,
connect (this, &MainWindow::pskReporterSendReport, m_pskReporter, &PSKReporter::sendReport);
connect (this, &MainWindow::pskReporterAddRemoteStation, m_pskReporter, &PSKReporter::addRemoteStation);
connect (this, &MainWindow::pskReporterSetLocalStation, m_pskReporter, &PSKReporter::setLocalStation);
connect (&m_networkThread, &QThread::started, m_pskReporter, &PSKReporter::start);
connect (&m_networkThread, &QThread::finished, m_pskReporter, &QObject::deleteLater);
// hook up the spot client signals and disposal