1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 01:18:38 -05:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Edouard Griffiths
31330cc14f
Merge pull request #1060 from srcejon/aprs_dark_theme
Use dark theme for APRS Feature charts
2021-11-25 23:55:16 +01:00
Edouard Griffiths
c90c999091
Merge pull request #1059 from srcejon/feature_worker_thread
Move Feature workers to thread
2021-11-25 23:00:27 +01:00
Jon Beniston
61aef0e17c Use dark theme for APRS charts 2021-11-25 13:05:04 +00:00
Jon Beniston
d5857c3878 Move Feature workers to thread 2021-11-25 09:28:59 +00:00
25 changed files with 116 additions and 18 deletions

View File

@ -52,6 +52,7 @@ AFC::AFC(WebAPIAdapterInterface *webAPIAdapterInterface) :
{
setObjectName(m_featureId);
m_worker = new AFCWorker(webAPIAdapterInterface);
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "AFC error";
m_networkManager = new QNetworkAccessManager();

View File

@ -46,6 +46,7 @@ AFCWorker::AFCWorker(WebAPIAdapterInterface *webAPIAdapterInterface) :
m_freqTracker(nullptr),
m_trackerDeviceFrequency(0),
m_trackerChannelOffset(0),
m_updateTimer(this),
m_mutex(QMutex::Recursive)
{
qDebug("AFCWorker::AFCWorker");

View File

@ -46,6 +46,7 @@ APRS::APRS(WebAPIAdapterInterface *webAPIAdapterInterface) :
qDebug("APRS::APRS: webAPIAdapterInterface: %p", webAPIAdapterInterface);
setObjectName(m_featureId);
m_worker = new APRSWorker(this, webAPIAdapterInterface);
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "APRS error";
connect(&m_updatePipesTimer, SIGNAL(timeout()), this, SLOT(updatePipes()));

View File

@ -522,6 +522,7 @@ APRSGUI::APRSGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feat
connect(ui->motionTable->horizontalHeader(), SIGNAL(sectionMoved(int, int, int)), SLOT(motionTable_sectionMoved(int, int, int)));
connect(ui->motionTable->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), SLOT(motionTable_sectionResized(int, int, int)));
m_weatherChart.setTheme(QChart::ChartThemeDark);
m_weatherChart.legend()->hide();
ui->weatherChart->setChart(&m_weatherChart);
ui->weatherChart->setRenderHint(QPainter::Antialiasing);
@ -530,6 +531,7 @@ APRSGUI::APRSGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feat
m_weatherChart.layout()->setContentsMargins(0, 0, 0, 0);
m_weatherChart.setMargins(QMargins(1, 1, 1, 1));
m_telemetryChart.setTheme(QChart::ChartThemeDark);
m_telemetryChart.legend()->hide();
ui->telemetryChart->setChart(&m_telemetryChart);
ui->telemetryChart->setRenderHint(QPainter::Antialiasing);
@ -538,6 +540,7 @@ APRSGUI::APRSGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feat
m_telemetryChart.layout()->setContentsMargins(0, 0, 0, 0);
m_telemetryChart.setMargins(QMargins(1, 1, 1, 1));
m_motionChart.setTheme(QChart::ChartThemeDark);
m_motionChart.legend()->hide();
ui->motionChart->setChart(&m_motionChart);
ui->motionChart->setRenderHint(QPainter::Antialiasing);

View File

@ -38,7 +38,8 @@ APRSWorker::APRSWorker(APRS *aprs, WebAPIAdapterInterface *webAPIAdapterInterfac
m_msgQueueToFeature(nullptr),
m_msgQueueToGUI(nullptr),
m_running(false),
m_mutex(QMutex::Recursive)
m_mutex(QMutex::Recursive),
m_socket(this)
{
connect(&m_socket, SIGNAL(readyRead()),this, SLOT(recv()));
connect(&m_socket, SIGNAL(connected()), this, SLOT(connected()));
@ -65,19 +66,33 @@ bool APRSWorker::startWork()
{
QMutexLocker mutexLocker(&m_mutex);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
connect(thread(), SIGNAL(started()), this, SLOT(started()));
connect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_running = true;
return m_running;
}
// startWork() is called from main thread. Timers need to be started on worker thread
void APRSWorker::started()
{
disconnect(thread(), SIGNAL(started()), this, SLOT(started()));
}
void APRSWorker::stopWork()
{
QMutexLocker mutexLocker(&m_mutex);
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
m_running = false;
}
void APRSWorker::finished()
{
// Close any existing connection
if (m_socket.isOpen())
if (m_socket.isOpen()) {
m_socket.close();
}
m_running = false;
disconnect(thread(), SIGNAL(finished()), this, SLOT(finished()));
}
void APRSWorker::handleInputMessages()
{

View File

@ -20,7 +20,6 @@
#define INCLUDE_FEATURE_APRSWORKER_H_
#include <QObject>
#include <QTimer>
#include <QTcpSocket>
#include "util/message.h"
@ -87,6 +86,8 @@ private:
void send(const char *data, int length);
private slots:
void started();
void finished();
void handleInputMessages();
void connected();
void disconnected();

View File

@ -55,6 +55,7 @@ DemodAnalyzer::DemodAnalyzer(WebAPIAdapterInterface *webAPIAdapterInterface) :
qDebug("DemodAnalyzer::DemodAnalyzer: webAPIAdapterInterface: %p", webAPIAdapterInterface);
setObjectName(m_featureId);
m_worker = new DemodAnalyzerWorker();
m_worker->moveToThread(&m_thread);
m_worker->setScopeVis(&m_scopeVis);
m_state = StIdle;
m_errorMessage = "DemodAnalyzer error";

View File

@ -52,6 +52,7 @@ GS232Controller::GS232Controller(WebAPIAdapterInterface *webAPIAdapterInterface)
qDebug("GS232Controller::GS232Controller: webAPIAdapterInterface: %p", webAPIAdapterInterface);
setObjectName(m_featureId);
m_worker = new GS232ControllerWorker();
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "GS232Controller error";
m_selectedPipe = nullptr;

View File

@ -20,7 +20,6 @@
#include <cmath>
#include <QDebug>
#include <QTimer>
#include <QSerialPort>
#include <QRegularExpression>
@ -36,6 +35,9 @@ GS232ControllerWorker::GS232ControllerWorker() :
m_running(false),
m_mutex(QMutex::Recursive),
m_device(nullptr),
m_serialPort(this),
m_socket(this),
m_pollTimer(this),
m_lastAzimuth(-1.0f),
m_lastElevation(-1.0f),
m_spidSetOutstanding(false),

View File

@ -52,6 +52,7 @@ PERTester::PERTester(WebAPIAdapterInterface *webAPIAdapterInterface) :
qDebug("PERTester::PERTester: webAPIAdapterInterface: %p", webAPIAdapterInterface);
setObjectName(m_featureId);
m_worker = new PERTesterWorker();
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "PERTester error";
m_networkManager = new QNetworkAccessManager();
@ -130,7 +131,9 @@ bool PERTester::handleMessage(const Message& cmd)
{
MsgReportWorker& report = (MsgReportWorker&) cmd;
if (report.getMessage() == "Complete")
m_state = StIdle;
{
stop();
}
else
{
m_state = StError;

View File

@ -42,6 +42,8 @@ PERTesterWorker::PERTesterWorker() :
m_running(false),
m_mutex(QMutex::Recursive),
m_rxUDPSocket(nullptr),
m_txUDPSocket(this),
m_txTimer(this),
m_tx(0),
m_rxMatched(0),
m_rxUnmatched(0)
@ -66,22 +68,35 @@ bool PERTesterWorker::startWork()
{
qDebug() << "PERTesterWorker::startWork";
QMutexLocker mutexLocker(&m_mutex);
connect(thread(), SIGNAL(started()), this, SLOT(started()));
connect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_running = true;
return m_running;
}
// startWork() is called from main thread. Timers/sockets need to be started on worker thread
void PERTesterWorker::started()
{
openUDP(m_settings);
// Automatically restart if previous run had finished, otherwise continue
if (m_tx >= m_settings.m_packetCount)
resetStats();
connect(&m_txTimer, SIGNAL(timeout()), this, SLOT(tx()));
m_txTimer.start(m_settings.m_interval * 1000.0);
m_running = true;
return m_running;
disconnect(thread(), SIGNAL(started()), this, SLOT(started()));
}
void PERTesterWorker::stopWork()
{
QMutexLocker mutexLocker(&m_mutex);
qDebug() << "PERTesterWorker::stopWork";
}
void PERTesterWorker::finished()
{
m_txTimer.stop();
closeUDP();
disconnect(&m_txTimer, SIGNAL(timeout()), this, SLOT(tx()));
disconnect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_running = false;
}
@ -314,7 +329,6 @@ void PERTesterWorker::tx()
void PERTesterWorker::testComplete()
{
stopWork();
if (m_msgQueueToFeature != nullptr)
m_msgQueueToFeature->push(PERTester::MsgReportWorker::create("Complete"));
qDebug() << "PERTesterWorker::tx: Test complete";

View File

@ -89,6 +89,8 @@ private:
void resetStats();
private slots:
void started();
void finished();
void handleInputMessages();
void rx();
void tx();

View File

@ -43,6 +43,7 @@ RigCtlServer::RigCtlServer(WebAPIAdapterInterface *webAPIAdapterInterface) :
qDebug("RigCtlServer::RigCtlServer: webAPIAdapterInterface: %p", webAPIAdapterInterface);
setObjectName(m_featureId);
m_worker = new RigCtlServerWorker(webAPIAdapterInterface);
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "RigCtlServer error";
m_networkManager = new QNetworkAccessManager();

View File

@ -20,7 +20,6 @@
#define INCLUDE_FEATURE_RIGCTLSERVERWORKER_H_
#include <QObject>
#include <QTimer>
#include "util/message.h"
#include "util/messagequeue.h"

View File

@ -51,6 +51,7 @@ SatelliteTracker::SatelliteTracker(WebAPIAdapterInterface *webAPIAdapterInterfac
qDebug("SatelliteTracker::SatelliteTracker: webAPIAdapterInterface: %p", webAPIAdapterInterface);
setObjectName(m_featureId);
m_worker = new SatelliteTrackerWorker(this, webAPIAdapterInterface);
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "SatelliteTracker error";
m_networkManager = new QNetworkAccessManager();

View File

@ -57,6 +57,7 @@ SatelliteTrackerWorker::SatelliteTrackerWorker(SatelliteTracker* satelliteTracke
m_msgQueueToGUI(nullptr),
m_running(false),
m_mutex(QMutex::Recursive),
m_pollTimer(this),
m_recalculatePasses(true),
m_flipRotation(false),
m_extendedAzRotation(false)
@ -79,6 +80,16 @@ bool SatelliteTrackerWorker::startWork()
{
QMutexLocker mutexLocker(&m_mutex);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
connect(thread(), SIGNAL(started()), this, SLOT(started()));
connect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_recalculatePasses = true;
m_running = true;
return m_running;
}
// startWork() is called from main thread. Timers need to be started on worker thread
void SatelliteTrackerWorker::started()
{
m_pollTimer.start((int)round(m_settings.m_updatePeriod*1000.0));
// Resume doppler timers
QHashIterator<QString, SatWorkerState *> itr(m_workerState);
@ -89,15 +100,17 @@ bool SatelliteTrackerWorker::startWork()
if (satWorkerState->m_dopplerTimer.interval() > 0)
satWorkerState->m_dopplerTimer.start();
}
m_recalculatePasses = true;
m_running = true;
return m_running;
disconnect(thread(), SIGNAL(started()), this, SLOT(started()));
}
void SatelliteTrackerWorker::stopWork()
{
QMutexLocker mutexLocker(&m_mutex);
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
void SatelliteTrackerWorker::finished()
{
m_pollTimer.stop();
// Stop doppler timers
QHashIterator<QString, SatWorkerState *> itr(m_workerState);
@ -107,6 +120,7 @@ void SatelliteTrackerWorker::stopWork()
itr.value()->m_dopplerTimer.stop();
}
m_running = false;
disconnect(thread(), SIGNAL(finished()), this, SLOT(finished()));
}
void SatelliteTrackerWorker::handleInputMessages()

View File

@ -130,6 +130,8 @@ private:
void calculateRotation(SatWorkerState *satWorkerState);
private slots:
void started();
void finished();
void handleInputMessages();
void update();
void aos(SatWorkerState *satWorkerState);

View File

@ -44,6 +44,7 @@ SimplePTT::SimplePTT(WebAPIAdapterInterface *webAPIAdapterInterface) :
{
setObjectName(m_featureId);
m_worker = new SimplePTTWorker(webAPIAdapterInterface);
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "SimplePTT error";
m_networkManager = new QNetworkAccessManager();

View File

@ -34,6 +34,7 @@ SimplePTTWorker::SimplePTTWorker(WebAPIAdapterInterface *webAPIAdapterInterface)
m_msgQueueToGUI(nullptr),
m_running(false),
m_tx(false),
m_updateTimer(this),
m_mutex(QMutex::Recursive)
{
qDebug("SimplePTTWorker::SimplePTTWorker");

View File

@ -49,6 +49,7 @@ StarTracker::StarTracker(WebAPIAdapterInterface *webAPIAdapterInterface) :
qDebug("StarTracker::StarTracker: webAPIAdapterInterface: %p", webAPIAdapterInterface);
setObjectName(m_featureId);
m_worker = new StarTrackerWorker(this, webAPIAdapterInterface);
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "StarTracker error";
connect(&m_updatePipesTimer, SIGNAL(timeout()), this, SLOT(updatePipes()));

View File

@ -52,6 +52,7 @@ StarTrackerWorker::StarTrackerWorker(StarTracker* starTracker, WebAPIAdapterInte
m_msgQueueToGUI(nullptr),
m_running(false),
m_mutex(QMutex::Recursive),
m_pollTimer(this),
m_tcpServer(nullptr),
m_clientConnection(nullptr),
m_solarFlux(0.0f)
@ -74,17 +75,30 @@ bool StarTrackerWorker::startWork()
{
QMutexLocker mutexLocker(&m_mutex);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
m_pollTimer.start((int)round(m_settings.m_updatePeriod*1000.0));
connect(thread(), SIGNAL(started()), this, SLOT(started()));
connect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_running = true;
return m_running;
}
// startWork() is called from main thread. Timers/sockets need to be started on worker thread
void StarTrackerWorker::started()
{
m_pollTimer.start((int)round(m_settings.m_updatePeriod*1000.0));
disconnect(thread(), SIGNAL(started()), this, SLOT(started()));
}
void StarTrackerWorker::stopWork()
{
QMutexLocker mutexLocker(&m_mutex);
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
void StarTrackerWorker::finished()
{
restartServer(false, 0);
m_pollTimer.stop();
disconnect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_running = false;
}

View File

@ -97,6 +97,8 @@ private:
void sendToMap(QList<MessageQueue*> *mapMessageQueues, QString id, QString image, QString text, double lat, double lon, double rotation=0.0);
private slots:
void started();
void finished();
void handleInputMessages();
void update();
void acceptConnection();

View File

@ -51,6 +51,7 @@ VORLocalizer::VORLocalizer(WebAPIAdapterInterface *webAPIAdapterInterface) :
{
setObjectName(m_featureId);
m_worker = new VorLocalizerWorker(webAPIAdapterInterface);
m_worker->moveToThread(&m_thread);
m_state = StIdle;
m_errorMessage = "VORLocalizer error";
m_networkManager = new QNetworkAccessManager();

View File

@ -42,7 +42,9 @@ VorLocalizerWorker::VorLocalizerWorker(WebAPIAdapterInterface *webAPIAdapterInte
m_msgQueueToFeature(nullptr),
m_availableChannels(nullptr),
m_running(false),
m_mutex(QMutex::Recursive)
m_updateTimer(this),
m_mutex(QMutex::Recursive),
m_rrTimer(this)
{
qDebug("VorLocalizerWorker::VorLocalizerWorker");
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
@ -64,17 +66,29 @@ bool VorLocalizerWorker::startWork()
QMutexLocker mutexLocker(&m_mutex);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
connect(&m_rrTimer, SIGNAL(timeout()), this, SLOT(rrNextTurn()));
m_rrTimer.start(m_settings.m_rrTime * 1000);
connect(thread(), SIGNAL(started()), this, SLOT(started()));
connect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_running = true;
return m_running;
}
// startWork() is called from main thread. Timers/sockets need to be started on worker thread
void VorLocalizerWorker::started()
{
m_rrTimer.start(m_settings.m_rrTime * 1000);
disconnect(thread(), SIGNAL(started()), this, SLOT(started()));
}
void VorLocalizerWorker::stopWork()
{
QMutexLocker mutexLocker(&m_mutex);
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
void VorLocalizerWorker::finished()
{
m_rrTimer.stop();
disconnect(&m_rrTimer, SIGNAL(timeout()), this, SLOT(rrNextTurn()));
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
disconnect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_running = false;
}

View File

@ -167,6 +167,8 @@ private:
static void getChannelsByDevice(const QHash<ChannelAPI*, VORLocalizerSettings::AvailableChannel> *availableChannels, std::vector<RRTurnPlan>& m_deviceChannels);
private slots:
void started();
void finished();
void handleInputMessages();
void updateHardware();
void rrNextTurn();