mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-29 21:44:14 -04:00
#1346: Update threading model in Star Tracker, PER Tester and APRS features
This commit is contained in:
@@ -39,7 +39,6 @@ MESSAGE_CLASS_DEFINITION(PERTesterReport::MsgReportStats, Message)
|
||||
PERTesterWorker::PERTesterWorker() :
|
||||
m_msgQueueToFeature(nullptr),
|
||||
m_msgQueueToGUI(nullptr),
|
||||
m_running(false),
|
||||
m_rxUDPSocket(nullptr),
|
||||
m_txUDPSocket(this),
|
||||
m_txTimer(this),
|
||||
@@ -57,46 +56,27 @@ PERTesterWorker::~PERTesterWorker()
|
||||
m_inputMessageQueue.clear();
|
||||
}
|
||||
|
||||
void PERTesterWorker::reset()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
m_inputMessageQueue.clear();
|
||||
}
|
||||
|
||||
bool PERTesterWorker::startWork()
|
||||
void 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()));
|
||||
connect(thread(), SIGNAL(finished()), this, SLOT(stopWork()));
|
||||
m_txTimer.start(m_settings.m_interval * 1000.0);
|
||||
disconnect(thread(), SIGNAL(started()), this, SLOT(started()));
|
||||
// Handle any messages already on the queue
|
||||
handleInputMessages();
|
||||
}
|
||||
|
||||
void PERTesterWorker::stopWork()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
void PERTesterWorker::handleInputMessages()
|
||||
|
||||
Reference in New Issue
Block a user