mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +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:
parent
8c0c5b0e4d
commit
765d4f729b
@ -30,6 +30,13 @@
|
|||||||
|
|
||||||
FlightGearBridge::FlightGearBridge()
|
FlightGearBridge::FlightGearBridge()
|
||||||
{
|
{
|
||||||
|
// start thread
|
||||||
|
start(QThread::TimeCriticalPriority);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlightGearBridge::run()
|
||||||
|
{
|
||||||
|
|
||||||
// Init fields
|
// Init fields
|
||||||
fgHost = QHostAddress("127.0.0.1");
|
fgHost = QHostAddress("127.0.0.1");
|
||||||
inPort = 5500;
|
inPort = 5500;
|
||||||
@ -62,26 +69,30 @@ FlightGearBridge::FlightGearBridge()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup local ports
|
// Setup local ports
|
||||||
inSocket = new QUdpSocket(this);
|
inSocket = new QUdpSocket();
|
||||||
outSocket = new QUdpSocket(this);
|
outSocket = new QUdpSocket();
|
||||||
inSocket->bind(QHostAddress::Any, inPort);
|
inSocket->bind(QHostAddress::Any, inPort);
|
||||||
connect(inSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()));
|
connect(inSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate()),Qt::DirectConnection);
|
||||||
|
|
||||||
// Setup transmit timer
|
// Setup transmit timer
|
||||||
txTimer = new QTimer(this);
|
txTimer = new QTimer();
|
||||||
connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()));
|
connect(txTimer, SIGNAL(timeout()), this, SLOT(transmitUpdate()),Qt::DirectConnection);
|
||||||
txTimer->setInterval(updatePeriod);
|
txTimer->setInterval(updatePeriod);
|
||||||
txTimer->start();
|
txTimer->start();
|
||||||
|
|
||||||
// Setup FG connection timer
|
// Setup FG connection timer
|
||||||
fgTimer = new QTimer(this);
|
fgTimer = new QTimer();
|
||||||
connect(fgTimer, SIGNAL(timeout()), this, SLOT(onFGConnectionTimeout()));
|
connect(fgTimer, SIGNAL(timeout()), this, SLOT(onFGConnectionTimeout()),Qt::DirectConnection);
|
||||||
fgTimer->setInterval(fgTimeout);
|
fgTimer->setInterval(fgTimeout);
|
||||||
fgTimer->start();
|
fgTimer->start();
|
||||||
|
|
||||||
|
exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
FlightGearBridge::~FlightGearBridge()
|
FlightGearBridge::~FlightGearBridge()
|
||||||
{
|
{
|
||||||
|
quit();
|
||||||
|
wait();
|
||||||
delete inSocket;
|
delete inSocket;
|
||||||
delete outSocket;
|
delete outSocket;
|
||||||
delete txTimer;
|
delete txTimer;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define FLIGHTGEARBRIDGE_H
|
#define FLIGHTGEARBRIDGE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QThread>
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -40,7 +41,7 @@
|
|||||||
#include "uavobjects/positionactual.h"
|
#include "uavobjects/positionactual.h"
|
||||||
#include "uavobjects/gcstelemetrystats.h"
|
#include "uavobjects/gcstelemetrystats.h"
|
||||||
|
|
||||||
class FlightGearBridge: public QObject
|
class FlightGearBridge: public QThread
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -50,6 +51,7 @@ public:
|
|||||||
|
|
||||||
bool isAutopilotConnected();
|
bool isAutopilotConnected();
|
||||||
bool isFGConnected();
|
bool isFGConnected();
|
||||||
|
void run();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void autopilotConnected();
|
void autopilotConnected();
|
||||||
|
@ -130,6 +130,7 @@ void Il2Bridge::run() {
|
|||||||
Il2Bridge::~Il2Bridge()
|
Il2Bridge::~Il2Bridge()
|
||||||
{
|
{
|
||||||
quit();
|
quit();
|
||||||
|
wait();
|
||||||
delete outSocket;
|
delete outSocket;
|
||||||
delete txTimer;
|
delete txTimer;
|
||||||
delete il2Timer;
|
delete il2Timer;
|
||||||
|
@ -30,19 +30,36 @@
|
|||||||
|
|
||||||
TelemetryManager::TelemetryManager()
|
TelemetryManager::TelemetryManager()
|
||||||
{
|
{
|
||||||
|
QThread::start(QThread::TimeCriticalPriority);
|
||||||
|
moveToThread(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryManager::run() {
|
||||||
// Get UAVObjectManager instance
|
// Get UAVObjectManager instance
|
||||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||||
objMngr = pm->getObject<UAVObjectManager>();
|
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()
|
TelemetryManager::~TelemetryManager()
|
||||||
{
|
{
|
||||||
|
quit();
|
||||||
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryManager::start(QIODevice *dev)
|
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);
|
telemetry = new Telemetry(utalk, objMngr);
|
||||||
telemetryMon = new TelemetryMonitor(objMngr, telemetry);
|
telemetryMon = new TelemetryMonitor(objMngr, telemetry);
|
||||||
connect(telemetryMon, SIGNAL(connected()), this, SLOT(onConnect()));
|
connect(telemetryMon, SIGNAL(connected()), this, SLOT(onConnect()));
|
||||||
@ -50,6 +67,11 @@ void TelemetryManager::start(QIODevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryManager::stop()
|
void TelemetryManager::stop()
|
||||||
|
{
|
||||||
|
emit myStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryManager::onStop()
|
||||||
{
|
{
|
||||||
telemetryMon->disconnect(this);
|
telemetryMon->disconnect(this);
|
||||||
delete telemetryMon;
|
delete telemetryMon;
|
||||||
|
@ -35,8 +35,9 @@
|
|||||||
#include "uavobjects/uavobjectmanager.h"
|
#include "uavobjects/uavobjectmanager.h"
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
class UAVTALK_EXPORT TelemetryManager: public QObject
|
class UAVTALK_EXPORT TelemetryManager: public QThread
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -46,20 +47,26 @@ public:
|
|||||||
|
|
||||||
void start(QIODevice *dev);
|
void start(QIODevice *dev);
|
||||||
void stop();
|
void stop();
|
||||||
|
void run();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connected();
|
void connected();
|
||||||
void disconnected();
|
void disconnected();
|
||||||
|
void myStart();
|
||||||
|
void myStop();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onConnect();
|
void onConnect();
|
||||||
void onDisconnect();
|
void onDisconnect();
|
||||||
|
void onStart();
|
||||||
|
void onStop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UAVObjectManager* objMngr;
|
UAVObjectManager* objMngr;
|
||||||
UAVTalk* utalk;
|
UAVTalk* utalk;
|
||||||
Telemetry* telemetry;
|
Telemetry* telemetry;
|
||||||
TelemetryMonitor* telemetryMon;
|
TelemetryMonitor* telemetryMon;
|
||||||
|
QIODevice *device;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TELEMETRYMANAGER_H
|
#endif // TELEMETRYMANAGER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user