Commit 70692347 authored by lm's avatar lm

Drop rate view works

parent fdc487ba
......@@ -139,20 +139,37 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link)
}
else
{
if (lastIndex[message.sysid][message.compid] == 255)
{
lastIndex[message.sysid][message.compid] = 0;
}
else
{
lastIndex[message.sysid][message.compid]++;
}
int safeguard = 0;
while(lastIndex[message.sysid][message.compid]+1 != message.seq && safeguard < 100)
//qDebug() << "SYSID" << message.sysid << "COMPID" << message.compid << "LASTINDEX" << lastIndex[message.sysid][message.compid] << "SEQ" << message.seq;
while(lastIndex[message.sysid][message.compid] != message.seq && safeguard < 1)
{
lastIndex[message.sysid][message.compid] += 1;
if (lastIndex[message.sysid][message.compid] == 255)
{
lastIndex[message.sysid][message.compid] = 0;
}
else
{
lastIndex[message.sysid][message.compid]++;
}
totalLossCounter++;
safeguard++;
}
}
// if (lastIndex.contains(message.sysid))
// {
// QMap<int, int>* lastCompIndex = lastIndex.value(message.sysid);
// if (lastCompIndex->contains(message.compid))
// while (lastCompIndex->value(message.compid, 0)+1 )
// }
// if (lastIndex.contains(message.sysid))
// {
// QMap<int, int>* lastCompIndex = lastIndex.value(message.sysid);
// if (lastCompIndex->contains(message.compid))
// while (lastCompIndex->value(message.compid, 0)+1 )
// }
//if ()
if (lastLoss != totalLossCounter)
{
......@@ -160,6 +177,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link)
// Receive loss
float receiveLoss = (double)totalLossCounter/(double)(totalReceiveCounter+totalLossCounter);
receiveLoss *= 100.0f;
qDebug() << "LOSS" << receiveLoss;
emit receiveLossChanged(receiveLoss);
}
......
......@@ -87,7 +87,7 @@ protected:
int heartbeatRate; ///< Heartbeat rate, controls the timer interval
bool m_heartbeatsEnabled; ///< Enabled/disable heartbeat emission
QMutex receiveMutex; ///< Mutex to protect receiveBytes function
qint64 lastIndex[256][256];
int lastIndex[256][256];
int totalReceiveCounter;
int totalLossCounter;
......
......@@ -67,6 +67,8 @@ UASInfoWidget::UASInfoWidget(QWidget *parent, QString name) : QWidget(parent)
this->voltage = 0;
this->chargeLevel = 0;
this->load = 0;
receiveLoss = 0;
sendLoss = 0;
updateTimer = new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(refresh()));
......@@ -117,17 +119,12 @@ void UASInfoWidget::updateCPULoad(UASInterface* uas, double load)
void UASInfoWidget::updateReceiveLoss(float receiveLoss)
{
ui.receiveLossBar->setValue(receiveLoss);
ui.receiveLossLabel->setText(QString::number(receiveLoss,'f', 2));
this->receiveLoss = this->receiveLoss * 0.8f + receiveLoss * 0.2f;
}
void UASInfoWidget::updateDropRate(int sysId, float receiveDrop, float sendDrop)
void UASInfoWidget::updateSendLoss(float sendLoss)
{
Q_UNUSED(sysId);
ui.receiveLossBar->setValue(receiveDrop);
ui.receiveLossLabel->setText(QString::number(receiveDrop) + "%");
ui.sendLossBar->setValue(sendDrop);
ui.sendLossLabel->setText(QString::number(receiveDrop) + "%");
this->sendLoss = this->sendLoss * 0.8f + sendLoss * 0.2f;
}
void UASInfoWidget::setVoltage(UASInterface* uas, double voltage)
......@@ -159,4 +156,10 @@ void UASInfoWidget::refresh()
ui.loadLabel->setText(QString::number(this->load, 'f', loadDecimals));
ui.loadBar->setValue(static_cast<int>(this->load));
ui.receiveLossBar->setValue(receiveLoss);
ui.receiveLossLabel->setText(QString::number(receiveLoss,'f', 2));
ui.sendLossBar->setValue(sendLoss);
ui.sendLossLabel->setText(QString::number(sendLoss, 'f', 2));
}
......@@ -57,7 +57,7 @@ public slots:
void updateBattery(UASInterface* uas, double voltage, double percent, int seconds);
void updateCPULoad(UASInterface* uas, double load);
void updateReceiveLoss(float receiveLoss);
void updateDropRate(int sysId, float receiveDrop, float sendDrop);
void updateSendLoss(float sendLoss);
void setVoltage(UASInterface* uas, double voltage);
void setChargeLevel(UASInterface* uas, double chargeLevel);
......@@ -83,6 +83,8 @@ protected:
double chargeLevel;
double timeRemaining;
double load;
float receiveLoss;
float sendLoss;
QTimer* updateTimer;
QString name;
quint64 startTime;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment