1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

Made hitl-IL2 plugin multi threaded (separate thread for sim connection)

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1138 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
corvus 2010-07-19 15:16:21 +00:00 committed by corvus
parent ad74bb18c4
commit 8c0c5b0e4d
2 changed files with 22 additions and 8 deletions

View File

@ -74,7 +74,12 @@ Il2Bridge::Il2Bridge(QString il2HostName, int il2Port, QString il2Latitude, QStr
il2ConnectionStatus = false; il2ConnectionStatus = false;
latitude=il2Latitude.toFloat(); latitude=il2Latitude.toFloat();
longitude=il2Longitude.toFloat(); longitude=il2Longitude.toFloat();
// start thread
start(QThread::TimeCriticalPriority);
}
void Il2Bridge::run() {
// Get required UAVObjects // Get required UAVObjects
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>(); UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
@ -98,19 +103,19 @@ Il2Bridge::Il2Bridge(QString il2HostName, int il2Port, QString il2Latitude, QStr
} }
// Setup local ports // Setup local ports
outSocket = new QUdpSocket(this); outSocket = new QUdpSocket();
outSocket->connectToHost((const QString )il2HostName,il2Port); outSocket->connectToHost(il2Host,outPort);
connect(outSocket, SIGNAL(readyRead()), this, SLOT(receiveUpdate())); connect(outSocket, 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
il2Timer = new QTimer(this); il2Timer = new QTimer();
connect(il2Timer, SIGNAL(timeout()), this, SLOT(onIl2ConnectionTimeout())); connect(il2Timer, SIGNAL(timeout()), this, SLOT(onIl2ConnectionTimeout()),Qt::DirectConnection);
il2Timer->setInterval(il2Timeout); il2Timer->setInterval(il2Timeout);
il2Timer->start(); il2Timer->start();
@ -119,10 +124,12 @@ Il2Bridge::Il2Bridge(QString il2HostName, int il2Port, QString il2Latitude, QStr
time->start(); time->start();
current.T=0; current.T=0;
exec();
} }
Il2Bridge::~Il2Bridge() Il2Bridge::~Il2Bridge()
{ {
quit();
delete outSocket; delete outSocket;
delete txTimer; delete txTimer;
delete il2Timer; delete il2Timer;
@ -361,6 +368,11 @@ void Il2Bridge::processUpdate(QString& data)
gpsData.Satellites = 7; gpsData.Satellites = 7;
gpsData.Status = PositionActual::STATUS_FIX3D; gpsData.Status = PositionActual::STATUS_FIX3D;
posActual->setData(gpsData); posActual->setData(gpsData);
// issue manual update
attActual->updated();
altActual->updated();
posActual->updated();
} }
void Il2Bridge::telStatsUpdated(UAVObject* obj) void Il2Bridge::telStatsUpdated(UAVObject* obj)

View File

@ -29,6 +29,7 @@
#define IL2BRIDGE_H #define IL2BRIDGE_H
#include <QObject> #include <QObject>
#include <QThread>
#include <QUdpSocket> #include <QUdpSocket>
#include <QTimer> #include <QTimer>
#include <QTime> #include <QTime>
@ -75,7 +76,7 @@ struct flightParams {
}; };
class Il2Bridge: public QObject class Il2Bridge: public QThread
{ {
Q_OBJECT Q_OBJECT
@ -85,6 +86,7 @@ public:
bool isAutopilotConnected(); bool isAutopilotConnected();
bool isIl2Connected(); bool isIl2Connected();
void run();
signals: signals:
void autopilotConnected(); void autopilotConnected();