diff --git a/src/uas/UASParameterCommsMgr.cc b/src/uas/UASParameterCommsMgr.cc index ec1395041ca8858527aa6cd8b7b86da0f8acd25a..27ee774faff260d54d74173afd45460e33aabe9d 100644 --- a/src/uas/UASParameterCommsMgr.cc +++ b/src/uas/UASParameterCommsMgr.cc @@ -50,6 +50,7 @@ void UASParameterCommsMgr::loadParamCommsSettings() int val = settings.value("PARAMETER_RETRANSMISSION_TIMEOUT", retransmissionTimeout).toInt(&ok); if (ok) { retransmissionTimeout = val; + qDebug() << "retransmissionTimeout" << retransmissionTimeout; } val = settings.value("PARAMETER_REWRITE_TIMEOUT", rewriteTimeout).toInt(&ok); if (ok) { @@ -240,6 +241,8 @@ void UASParameterCommsMgr::retransmissionGuardTick() setRetransmissionGuardEnabled(true); return; } + qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD ACTIVE after" << elapsed; + if (transmissionActive) { @@ -250,6 +253,8 @@ void UASParameterCommsMgr::retransmissionGuardTick() setParameterStatusMsg(tr("TIMEOUT: Re-requesting param list"),ParamCommsStatusLevel_Warning); listRecvTimeout = curTime + 10000; mav->requestParameters(); + //reset the timer + setRetransmissionGuardEnabled(true); } return; } @@ -270,7 +275,6 @@ void UASParameterCommsMgr::retransmissionGuardTick() return; } - qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD ACTIVE, CHECKING FOR DROPS.."; resendReadWriteRequests(); } else { @@ -443,7 +447,7 @@ void UASParameterCommsMgr::receivedParameterUpdate(int uas, int compId, int para // There is only one transmission timeout for all components // since components do not manage their transmission, // the longest timeout is safe for all components. - quint64 thisTransmissionTimeout = QGC::groundTimeMilliseconds() + ((paramCount)*retransmissionTimeout); + quint64 thisTransmissionTimeout = QGC::groundTimeMilliseconds() + (paramCount*retransmissionTimeout); if (thisTransmissionTimeout > transmissionTimeout) { transmissionTimeout = thisTransmissionTimeout; } diff --git a/src/ui/QGCParamWidget.cc b/src/ui/QGCParamWidget.cc index 52bfc208c117ca604d5111c7a85666723ed5c325..2f7f8ca5415b5935a05408fdeff7aa484f5042c5 100644 --- a/src/ui/QGCParamWidget.cc +++ b/src/ui/QGCParamWidget.cc @@ -202,7 +202,20 @@ void QGCParamWidget::addComponentItem(int compId, QString compName) void QGCParamWidget::handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending) { + qDebug() << "handlePendingParamUpdate:" << paramName << "with updatedLineItem_weak:" << updatedLineItem_weak; + + if (updatedLineItem_weak) { + QString key = updatedLineItem_weak->data(0, Qt::DisplayRole).toString(); + if (paramName == key) { + //debounce echo from data model + return; + } + } + QTreeWidgetItem* paramItem = updateParameterDisplay(compId,paramName,value); + if (updatedLineItem_weak == NULL) { + updatedLineItem_weak = paramItem; + } if (isPending) { paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange))); paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange))); @@ -327,6 +340,8 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para parameterItem->setData(1, Qt::DisplayRole, value); } parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable); + updatedLineItem_weak = parameterItem; //keep a temporary ref to the item that's being updated + //TODO insert alphabetically parentItem->addChild(parameterItem); @@ -347,8 +362,9 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para } } - //update the parameterItem's data updatedLineItem_weak = parameterItem; //keep a temporary ref to the item that's being updated + + //update the parameterItem's data if (value.type() == QVariant::Char) { parameterItem->setData(1, Qt::DisplayRole, value.toUInt()); } @@ -357,14 +373,16 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para } } - // Reset background color - parameterItem->setBackground(0, Qt::NoBrush); - parameterItem->setBackground(1, Qt::NoBrush); + if (parameterItem) { + // Reset background color + parameterItem->setBackground(0, Qt::NoBrush); + parameterItem->setBackground(1, Qt::NoBrush); - parameterItem->setTextColor(0, QGC::colorDarkWhite); - parameterItem->setTextColor(1, QGC::colorDarkWhite); + parameterItem->setTextColor(0, QGC::colorDarkWhite); + parameterItem->setTextColor(1, QGC::colorDarkWhite); - updatedLineItem_weak = NULL; + updatedLineItem_weak = NULL; + } return parameterItem; } @@ -374,7 +392,8 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column) { if (paramItem && column > 0) { - if (paramItem == updatedLineItem_weak) { + + if (!paramItem->isSelected() || (paramItem == updatedLineItem_weak)) { //ignore updates reflected back from the data model, to avoid infinite loop return; } diff --git a/src/ui/QGCParamWidget.h b/src/ui/QGCParamWidget.h index d0e6f96c3918e9beca245e4e96d9b457de23e8e8..5779b2e4b254677b8978ebf521ab61619fe3fa2d 100644 --- a/src/ui/QGCParamWidget.h +++ b/src/ui/QGCParamWidget.h @@ -101,6 +101,7 @@ protected: QMap* componentItems; ///< The tree of component items, stored by component ID QMap* > paramGroups; ///< Parameter groups to organize component items QTreeWidgetItem* updatedLineItem_weak;///< weak ref to user-edited line +// QTreeWidgetItem* updatedPendingItem_weak;///< weak ref to pending-modified line };