1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-4 GCS/Telemetry Flush telemetry queues while connection is not yet established (to remove stale data)

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@604 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-05-08 00:21:49 +00:00 committed by vassilis
parent dafdac14e2
commit 85e5d74710
3 changed files with 35 additions and 7 deletions

View File

@ -49,6 +49,8 @@ Telemetry::Telemetry(UAVTalk* utalk, UAVObjectManager* objMngr)
connect(objMngr, SIGNAL(newInstance(UAVObject*)), this, SLOT(newInstance(UAVObject*)));
// Listen to transaction completions
connect(utalk, SIGNAL(transactionCompleted(UAVObject*)), this, SLOT(transactionCompleted(UAVObject*)));
// Get GCS stats object
gcsStatsObj = GCSTelemetryStats::GetInstance(objMngr);
// Setup transaction timer
transPending = false;
transTimer = new QTimer(this);
@ -296,6 +298,7 @@ void Telemetry::processObjectUpdates(UAVObject* obj, EventMask event, bool allIn
else
{
++txErrors;
obj->emitTransactionCompleted(false);
qxtLog->warning(tr("Telemetry: priority event queue is full, event lost (%1)").arg(obj->getName()));
}
}
@ -308,6 +311,7 @@ void Telemetry::processObjectUpdates(UAVObject* obj, EventMask event, bool allIn
else
{
++txErrors;
obj->emitTransactionCompleted(false);
}
}
@ -345,6 +349,19 @@ void Telemetry::processObjectQueue()
return;
}
// Check if a connection has been established, only process GCSTelemetryStats updates
// (used to establish the connection)
GCSTelemetryStats::DataFields gcsStats = gcsStatsObj->getData();
if ( gcsStats.Status != GCSTelemetryStats::STATUS_CONNECTED )
{
objQueue.clear();
if ( objInfo.obj->getObjID() != GCSTelemetryStats::OBJID )
{
objInfo.obj->emitTransactionCompleted(false);
return;
}
}
// Setup transaction (skip if unpack event)
if ( objInfo.event != EV_UNPACKED )
{

View File

@ -31,6 +31,7 @@
#include "uavtalk.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/gcstelemetrystats.h"
#include <QMutex>
#include <QMutexLocker>
#include <QTimer>
@ -74,7 +75,7 @@ private slots:
private:
// Constants
static const int REQ_TIMEOUT_MS = 250;
static const int MAX_RETRIES = 3;
static const int MAX_RETRIES = 2;
static const int MAX_UPDATE_PERIOD_MS = 1000;
static const int MIN_UPDATE_PERIOD_MS = 1;
static const int MAX_QUEUE_SIZE = 20;
@ -113,6 +114,7 @@ private:
// Variables
UAVObjectManager* objMngr;
UAVTalk* utalk;
GCSTelemetryStats* gcsStatsObj;
QList<ObjectTimeInfo> objList;
QQueue<ObjectQueueInfo> objQueue;
QQueue<ObjectQueueInfo> objPriorityQueue;

View File

@ -186,12 +186,11 @@ void TelemetryMonitor::processStatsUpdates()
gcsStats.TxRetries += telStats.txRetries;
// Update connection state
int oldStatus = gcsStats.Status;
if ( gcsStats.Status == GCSTelemetryStats::STATUS_DISCONNECTED )
{
// Request connection
gcsStats.Status = GCSTelemetryStats::STATUS_HANDSHAKEREQ;
statsTimer->setInterval(STATS_CONNECT_PERIOD_MS);
qxtLog->info("Trying to connect to the autopilot");
}
else if ( gcsStats.Status == GCSTelemetryStats::STATUS_HANDSHAKEREQ )
{
@ -199,9 +198,6 @@ void TelemetryMonitor::processStatsUpdates()
if ( flightStats.Status == FlightTelemetryStats::STATUS_HANDSHAKEACK )
{
gcsStats.Status = GCSTelemetryStats::STATUS_CONNECTED;
statsTimer->setInterval(STATS_UPDATE_PERIOD_MS);
qxtLog->info("Connection with the autopilot established");
startRetrievingObjects();
}
}
else if ( gcsStats.Status == GCSTelemetryStats::STATUS_CONNECTED )
@ -210,7 +206,6 @@ void TelemetryMonitor::processStatsUpdates()
if (flightStats.Status == FlightTelemetryStats::STATUS_DISCONNECTED || telStats.rxBytes == 0)
{
gcsStats.Status = GCSTelemetryStats::STATUS_DISCONNECTED;
qxtLog->info("Connection with the autopilot lost");
}
}
@ -223,5 +218,19 @@ void TelemetryMonitor::processStatsUpdates()
{
gcsStatsObj->updated();
}
// Act on new connections or disconnections
if (gcsStats.Status == GCSTelemetryStats::STATUS_CONNECTED && gcsStats.Status != oldStatus)
{
statsTimer->setInterval(STATS_UPDATE_PERIOD_MS);
qxtLog->info("Connection with the autopilot established");
startRetrievingObjects();
}
if (gcsStats.Status == GCSTelemetryStats::STATUS_DISCONNECTED && gcsStats.Status != oldStatus)
{
statsTimer->setInterval(STATS_CONNECT_PERIOD_MS);
qxtLog->info("Connection with the autopilot lost");
qxtLog->info("Trying to connect to the autopilot");
}
}