Commit 5f00489f authored by tstellanova's avatar tstellanova

clear guard timer when list mode done

parent 7037ca90
......@@ -106,16 +106,16 @@ void UASParameterCommsMgr::clearRetransmissionLists(int& missingReadCount, int&
missingReadCount = 0;
QList<int> readKeys = transmissionMissingPackets.keys();
foreach (int component, readKeys) {
missingReadCount += transmissionMissingPackets.value(component)->count();
transmissionMissingPackets.value(component)->clear();
foreach (int compId, readKeys) {
missingReadCount += transmissionMissingPackets.value(compId)->count();
transmissionMissingPackets.value(compId)->clear();
}
missingWriteCount = 0;
QList<int> writeKeys = transmissionMissingWriteAckPackets.keys();
foreach (int component, writeKeys) {
missingWriteCount += transmissionMissingWriteAckPackets.value(component)->count();
transmissionMissingWriteAckPackets.value(component)->clear();
foreach (int compId, writeKeys) {
missingWriteCount += transmissionMissingWriteAckPackets.value(compId)->count();
transmissionMissingWriteAckPackets.value(compId)->clear();
}
}
......@@ -209,10 +209,26 @@ void UASParameterCommsMgr::resendReadWriteRequests()
if ((0 == requestedWriteCount) && (0 == requestedReadCount) ) {
qDebug() << __FILE__ << __LINE__ << "NO re-read or rewrite requests??";
//setRetransmissionGuardEnabled(false);
if (!transmissionListMode) {
setRetransmissionGuardEnabled(false);
transmissionActive = false;
}
}
}
void UASParameterCommsMgr::resetAfterListReceive()
{
transmissionListMode = false;
transmissionListSizeKnown.clear();
//TODO we shouldn't clear missingPackets because other transactions might be using them?
//for list reception we only clear receive packets?
// foreach (int key, transmissionMissingPackets.keys()) {
// transmissionMissingPackets.value(key)->clear();
// }
}
void UASParameterCommsMgr::retransmissionGuardTick()
{
if (transmissionActive) {
......@@ -233,8 +249,8 @@ void UASParameterCommsMgr::retransmissionGuardTick()
// stop retransmission attempts on timeout
if (QGC::groundTimeMilliseconds() > transmissionTimeout) {
setRetransmissionGuardEnabled(false);
transmissionActive = false;
transmissionListMode = false;
resetAfterListReceive();
int missingReadCount, missingWriteCount;
clearRetransmissionLists(missingReadCount,missingWriteCount);
if ((missingReadCount > 0) || (missingWriteCount > 0)) {
......@@ -491,13 +507,7 @@ void UASParameterCommsMgr::receivedParameterUpdate(int uas, int compId, int para
// Check if last parameter was received
if (missCount == 0 && missWriteCount == 0) {
this->transmissionActive = false;
this->transmissionListMode = false;
transmissionListSizeKnown.clear();
foreach (int key, transmissionMissingPackets.keys()) {
transmissionMissingPackets.value(key)->clear();
}
resetAfterListReceive();
setRetransmissionGuardEnabled(false);
//all parameters have been received, broadcast to UI
emit parameterListUpToDate();
......
......@@ -42,6 +42,7 @@ protected:
void clearRetransmissionLists(int& missingReadCount, int& missingWriteCount );
void resendReadWriteRequests();
void resetAfterListReceive();
void emitParameterChanged(int compId, const QString& key, QVariant& value);
......
......@@ -245,6 +245,9 @@ void QGCParamWidget::updateParameterDisplay(int compId, QString parameterName, Q
addComponentItem(compId, componentName);
}
//default parent item for this parameter widget item will be the top level component item
QTreeWidgetItem* parentItem = componentItems->value(compId);
QString splitToken = "_";
// Check if auto-grouping can work
if (parameterName.contains(splitToken)) {
......@@ -265,8 +268,75 @@ void QGCParamWidget::updateParameterDisplay(int compId, QString parameterName, Q
}
// Append child to group
//bool found = false;
//parent item for this tree widget item will be a group widget item
parentItem = compParamGroups->value(parentStr);
// for (int i = 0; i < parentItem->childCount(); i++) {
// QTreeWidgetItem* child = parentItem->child(i);
// QString key = child->data(0, Qt::DisplayRole).toString();
// if (key == parameterName) {
// //qDebug() << "UPDATED CHILD";
// parameterItem = child;
// if (value.type() == QVariant::Char) {
// parameterItem->setData(1, Qt::DisplayRole, value.toUInt());
// }
// else {
// parameterItem->setData(1, Qt::DisplayRole, value);
// }
// found = true;
// }
// }
// if (!found) {
// // Insert parameter into map
// QStringList plist;
// plist.append(parameterName);
// // CREATE PARAMETER ITEM
// parameterItem = new QTreeWidgetItem(plist);
// // CONFIGURE PARAMETER ITEM
// if (value.type() == QVariant::Char) {
// parameterItem->setData(1, Qt::DisplayRole, value.toUInt());
// }
// else {
// parameterItem->setData(1, Qt::DisplayRole, value);
// }
// parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable);
// parentItem->addChild(parameterItem);
// }
}
else {
//bool found = false;
parentItem = componentItems->value(compId);
// for (int i = 0; i < parent->childCount(); i++) {
// QTreeWidgetItem* child = parent->child(i);
// QString key = child->data(0, Qt::DisplayRole).toString();
// if (key == parameterName) {
// //qDebug() << "UPDATED CHILD";
// parameterItem = child;
// parameterItem->setData(1, Qt::DisplayRole, value);
// found = true;
// }
// }
// if (!found) {
// // Insert parameter into map
// QStringList plist;
// plist.append(parameterName);
// // CREATE PARAMETER ITEM
// parameterItem = new QTreeWidgetItem(plist);
// // CONFIGURE PARAMETER ITEM
// parameterItem->setData(1, Qt::DisplayRole, value);
// componentItems->value(compId)->addChild(parameterItem);
// parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable);
// }
}
if (parentItem) {
bool found = false;
QTreeWidgetItem* parentItem = compParamGroups->value(parentStr);
for (int i = 0; i < parentItem->childCount(); i++) {
QTreeWidgetItem* child = parentItem->child(i);
QString key = child->data(0, Qt::DisplayRole).toString();
......@@ -296,36 +366,9 @@ void QGCParamWidget::updateParameterDisplay(int compId, QString parameterName, Q
else {
parameterItem->setData(1, Qt::DisplayRole, value);
}
compParamGroups->value(parentStr)->addChild(parameterItem);
parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable);
}
}
else {
bool found = false;
QTreeWidgetItem* parent = componentItems->value(compId);
for (int i = 0; i < parent->childCount(); i++) {
QTreeWidgetItem* child = parent->child(i);
QString key = child->data(0, Qt::DisplayRole).toString();
if (key == parameterName) {
//qDebug() << "UPDATED CHILD";
parameterItem = child;
parameterItem->setData(1, Qt::DisplayRole, value);
found = true;
}
}
if (!found) {
// Insert parameter into map
QStringList plist;
plist.append(parameterName);
// CREATE PARAMETER ITEM
parameterItem = new QTreeWidgetItem(plist);
// CONFIGURE PARAMETER ITEM
parameterItem->setData(1, Qt::DisplayRole, value);
componentItems->value(compId)->addChild(parameterItem);
parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable);
parentItem->addChild(parameterItem);
}
}
......
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