1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 23:55:13 -05:00

Move Feature workers to thread

This commit is contained in:
Jon Beniston 2021-11-25 09:28:59 +00:00
parent ad74a9294e
commit d5857c3878
24 changed files with 113 additions and 18 deletions

View File

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

View File

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

View File

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

View File

@ -38,7 +38,8 @@ APRSWorker::APRSWorker(APRS *aprs, WebAPIAdapterInterface *webAPIAdapterInterfac
m_msgQueueToFeature(nullptr), m_msgQueueToFeature(nullptr),
m_msgQueueToGUI(nullptr), m_msgQueueToGUI(nullptr),
m_running(false), 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(readyRead()),this, SLOT(recv()));
connect(&m_socket, SIGNAL(connected()), this, SLOT(connected())); connect(&m_socket, SIGNAL(connected()), this, SLOT(connected()));
@ -65,18 +66,32 @@ bool APRSWorker::startWork()
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); 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; m_running = true;
return m_running; 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() void APRSWorker::stopWork()
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
m_running = false; }
void APRSWorker::finished()
{
// Close any existing connection // Close any existing connection
if (m_socket.isOpen()) if (m_socket.isOpen()) {
m_socket.close(); m_socket.close();
}
m_running = false;
disconnect(thread(), SIGNAL(finished()), this, SLOT(finished()));
} }
void APRSWorker::handleInputMessages() void APRSWorker::handleInputMessages()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,6 +52,7 @@ StarTrackerWorker::StarTrackerWorker(StarTracker* starTracker, WebAPIAdapterInte
m_msgQueueToGUI(nullptr), m_msgQueueToGUI(nullptr),
m_running(false), m_running(false),
m_mutex(QMutex::Recursive), m_mutex(QMutex::Recursive),
m_pollTimer(this),
m_tcpServer(nullptr), m_tcpServer(nullptr),
m_clientConnection(nullptr), m_clientConnection(nullptr),
m_solarFlux(0.0f) m_solarFlux(0.0f)
@ -74,17 +75,30 @@ bool StarTrackerWorker::startWork()
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); 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; m_running = true;
return m_running; 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() void StarTrackerWorker::stopWork()
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
void StarTrackerWorker::finished()
{
restartServer(false, 0); restartServer(false, 0);
m_pollTimer.stop(); m_pollTimer.stop();
disconnect(thread(), SIGNAL(finished()), this, SLOT(finished()));
m_running = false; 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); void sendToMap(QList<MessageQueue*> *mapMessageQueues, QString id, QString image, QString text, double lat, double lon, double rotation=0.0);
private slots: private slots:
void started();
void finished();
void handleInputMessages(); void handleInputMessages();
void update(); void update();
void acceptConnection(); void acceptConnection();

View File

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

View File

@ -42,7 +42,9 @@ VorLocalizerWorker::VorLocalizerWorker(WebAPIAdapterInterface *webAPIAdapterInte
m_msgQueueToFeature(nullptr), m_msgQueueToFeature(nullptr),
m_availableChannels(nullptr), m_availableChannels(nullptr),
m_running(false), m_running(false),
m_mutex(QMutex::Recursive) m_updateTimer(this),
m_mutex(QMutex::Recursive),
m_rrTimer(this)
{ {
qDebug("VorLocalizerWorker::VorLocalizerWorker"); qDebug("VorLocalizerWorker::VorLocalizerWorker");
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
@ -64,17 +66,29 @@ bool VorLocalizerWorker::startWork()
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
connect(&m_rrTimer, SIGNAL(timeout()), this, SLOT(rrNextTurn())); 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; m_running = true;
return m_running; 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() void VorLocalizerWorker::stopWork()
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
void VorLocalizerWorker::finished()
{
m_rrTimer.stop(); m_rrTimer.stop();
disconnect(&m_rrTimer, SIGNAL(timeout()), this, SLOT(rrNextTurn())); 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; m_running = false;
} }

View File

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