1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

OP-101 : Put Low level telemetry and HiTL into high priority threads - detached from the user interface.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1139 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
corvus 2010-07-19 16:47:06 +00:00 committed by corvus
parent 8c0c5b0e4d
commit 765d4f729b
5 changed files with 54 additions and 11 deletions

View File

@ -30,6 +30,13 @@
FlightGearBridge::FlightGearBridge()
{
// start thread
start(QThread::TimeCriticalPriority);
}
void FlightGearBridge::run()
{
// Init fields
fgHost = QHostAddress("127.0.0.1");
inPort = 5500;
@ -62,26 +69,30 @@ FlightGearBridge::FlightGearBridge()
}
// Setup local ports
inSocket = new QUdpSocket(this);
outSocket = new QUdpSocket(this);
inSocket = new QUdpSocket();
outSocket = new QUdpSocket();
inSocket->bind(QHostAddress::Any, inPort);
connect(inSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()));
connect(inSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()),Qt::DirectConnection);
// Setup transmit timer
txTimer = new QTimer(this);
connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()));
txTimer = new QTimer();
connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()),Qt::DirectConnection);
txTimer->setInterval(updatePeriod);
txTimer->start();
// Setup FG connection timer
fgTimer = new QTimer(this);
connect(fgTimer, SIGNAL(timeout()), this, SLOT(onFGConnectionTimeout()));
fgTimer = new QTimer();
connect(fgTimer, SIGNAL(timeout()), this, SLOT(onFGConnectionTimeout()),Qt::DirectConnection);
fgTimer->setInterval(fgTimeout);
fgTimer->start();
exec();
}
FlightGearBridge::~FlightGearBridge()
{
quit();
wait();
delete inSocket;
delete outSocket;
delete txTimer;

View File

@ -29,6 +29,7 @@
#define FLIGHTGEARBRIDGE_H
#include <QObject>
#include <QThread>
#include <QUdpSocket>
#include <QTimer>
#include <math.h>
@ -40,7 +41,7 @@
#include "uavobjects/positionactual.h"
#include "uavobjects/gcstelemetrystats.h"
class FlightGearBridge: public QObject
class FlightGearBridge: public QThread
{
Q_OBJECT
@ -50,6 +51,7 @@ public:
bool isAutopilotConnected();
bool isFGConnected();
void run();
signals:
void autopilotConnected();

View File

@ -130,6 +130,7 @@ void Il2Bridge::run() {
Il2Bridge::~Il2Bridge()
{
quit();
wait();
delete outSocket;
delete txTimer;
delete il2Timer;

View File

@ -30,19 +30,36 @@
TelemetryManager::TelemetryManager()
{
QThread::start(QThread::TimeCriticalPriority);
moveToThread(this);
}
void TelemetryManager::run() {
// Get UAVObjectManager instance
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
objMngr = pm->getObject<UAVObjectManager>();
// connect to start stop signals
connect(this, SIGNAL(myStart()), this, SLOT(onStart()),Qt::QueuedConnection);
connect(this, SIGNAL(myStop()), this, SLOT(onStop()),Qt::QueuedConnection);
exec();
}
TelemetryManager::~TelemetryManager()
{
quit();
wait();
}
void TelemetryManager::start(QIODevice *dev)
{
utalk = new UAVTalk(dev, objMngr);
device=dev;
emit myStart();
}
void TelemetryManager::onStart()
{
utalk = new UAVTalk(device, objMngr);
telemetry = new Telemetry(utalk, objMngr);
telemetryMon = new TelemetryMonitor(objMngr, telemetry);
connect(telemetryMon, SIGNAL(connected()), this, SLOT(onConnect()));
@ -50,6 +67,11 @@ void TelemetryManager::start(QIODevice *dev)
}
void TelemetryManager::stop()
{
emit myStop();
}
void TelemetryManager::onStop()
{
telemetryMon->disconnect(this);
delete telemetryMon;

View File

@ -35,8 +35,9 @@
#include "uavobjects/uavobjectmanager.h"
#include <QIODevice>
#include <QObject>
#include <QThread>
class UAVTALK_EXPORT TelemetryManager: public QObject
class UAVTALK_EXPORT TelemetryManager: public QThread
{
Q_OBJECT
@ -46,20 +47,26 @@ public:
void start(QIODevice *dev);
void stop();
void run();
signals:
void connected();
void disconnected();
void myStart();
void myStop();
private slots:
void onConnect();
void onDisconnect();
void onStart();
void onStop();
private:
UAVObjectManager* objMngr;
UAVTalk* utalk;
Telemetry* telemetry;
TelemetryMonitor* telemetryMon;
QIODevice *device;
};
#endif // TELEMETRYMANAGER_H