Commit de5fc6a5 authored by tstellanova's avatar tstellanova

Reimplement write and read timeout retransmission

Also move default component ID into data model
parent 1f76bbed
......@@ -11,8 +11,7 @@ QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QObject(parent),
mav(NULL),
paramDataModel(this),
paramCommsMgr(NULL),
defaultComponentId(-1)
paramCommsMgr(NULL)
{
......@@ -63,22 +62,7 @@ void QGCUASParamManager::clearAllPendingParams()
int QGCUASParamManager::getDefaultComponentId()
{
int result = 0;
if (-1 != defaultComponentId)
return defaultComponentId;
QList<int> components = getComponentForParam("SYS_AUTOSTART");//TODO is this the best way to find the right component?
// Guard against multiple components responding - this will never show in practice
if (1 == components.count()) {
result = components.first();
defaultComponentId = result;
}
qDebug() << "Default compId: " << result;
return result;
return paramDataModel.getDefaultComponentId();
}
QList<int> QGCUASParamManager::getComponentForParam(const QString& parameter) const
......@@ -119,7 +103,6 @@ void QGCUASParamManager::requestParameterListIfEmpty()
if (mav) {
int totalOnboard = paramDataModel.countOnboardParams();
if (totalOnboard < 2) { //TODO arbitrary constant, maybe 0 is OK?
defaultComponentId = -1; //reset this ...we have no idea what the default component ID is
requestParameterList();
}
}
......@@ -135,7 +118,7 @@ void QGCUASParamManager::setParameter(int compId, QString paramName, QVariant va
{
if ((0 == compId) || (-1 == compId)) {
//attempt to get an actual component ID
compId = getDefaultComponentId();
compId = paramDataModel.getDefaultComponentId();
}
paramDataModel.updatePendingParamWithValue(compId,paramName,value);
}
......@@ -152,7 +135,7 @@ void QGCUASParamManager::setPendingParam(int compId, const QString& paramName,
{
if ((0 == compId) || (-1 == compId)) {
//attempt to get an actual component ID
compId = getDefaultComponentId();
compId = paramDataModel.getDefaultComponentId();
}
paramDataModel.updatePendingParamWithValue(compId,paramName,value);
}
......
......@@ -125,7 +125,6 @@ protected:
UASInterface* mav; ///< The MAV this manager is controlling
UASParameterDataModel paramDataModel;///< Shared data model of parameters
UASParameterCommsMgr* paramCommsMgr; ///< Shared comms mgr for parameters
int defaultComponentId; ///< Cached default component ID
};
......
This diff is collapsed.
......@@ -32,8 +32,9 @@ public:
protected:
/** @brief Activate / deactivate parameter retransmission */
virtual void setRetransmissionGuardEnabled(bool enabled);
/** @brief activate the silence timer if there are unack'd reads or writes */
virtual void updateSilenceTimer();
virtual void setParameterStatusMsg(const QString& msg, ParamCommsStatusLevel_t level=ParamCommsStatusLevel_OK);
......@@ -43,6 +44,12 @@ protected:
/** @brief clear transmissionMissingPackets and transmissionMissingWriteAckPackets */
void clearRetransmissionLists(int& missingReadCount, int& missingWriteCount );
/** @brief we are waiting for a response to this read param request */
virtual void markReadParamWaiting(int compId, int paramId);
/** @brief we are waiting for a response to this write param request */
void markWriteParamWaiting(int compId, QString paramName, QVariant value);
void resendReadWriteRequests();
void resetAfterListReceive();
......@@ -75,8 +82,8 @@ public slots:
/** @brief Request list of parameters from MAV */
virtual void requestParameterList();
/** @brief Check for missing parameters */
virtual void retransmissionGuardTick();
/** @brief The max silence time expired */
virtual void silenceTimerExpired();
/** @brief Request a single parameter update by name */
virtual void requestParameterUpdate(int component, const QString& parameter);
......@@ -88,28 +95,24 @@ public slots:
protected:
QMap<int, int> knownParamListSize;///< The known param list size for each component, by component ID
quint64 lastReceiveTime; ///< The last time we received anything from our partner
quint64 lastSilenceTimerReset;
UASInterface* mav; ///< The MAV we're talking to
int maxSilenceTimeout; ///< If nothing received within this period of time, abandon resends
UASParameterDataModel* paramDataModel;
// Communications management
QVector<bool> receivedParamsList; ///< Successfully received parameters
QMap<int, QList<int>* > missingReadPackets; ///< Missing packets
QMap<int, QMap<QString, QVariant>* > missingWriteAckPackets; ///< Missing write ACK packets
bool transmissionListMode; ///< Currently requesting list
QMap<int, bool> transmissionListSizeKnown; ///< List size initialized?
bool transmissionActive; ///< Missing packets, working on list?
bool persistParamsAfterSend; ///< Copy all parameters to persistent storage after sending
quint64 transmissionTimeout; ///< Timeout
QTimer retransmissionTimer; ///< Timer handling parameter retransmission
quint64 lastTimerReset; ///< Last time the guard timer was reset, to prevent premature firing
int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds
int rewriteTimeout; ///< Write request timeout, in milliseconds
int retransmissionBurstRequestSize; ///< Number of packets requested for retransmission per burst
quint64 listRecvTimeout; ///< How long to wait for first parameter list response before re-requesting
// Status
QString parameterStatusMsg;
QMap<int, QSet<int>*> readsWaiting; ///< All reads that have not yet been received, by component ID
int retransmitBurstLimit; ///< Number of packets requested for retransmission per burst
int silenceTimeout; ///< If nothing received within this period of time, start resends
QTimer silenceTimer; ///< Timer handling parameter retransmission
bool transmissionListMode; ///< Currently requesting list
QMap<int, QMap<QString, QVariant>* > writesWaiting; ///< All writes that have not yet been ack'd, by component ID
};
......
......@@ -9,7 +9,8 @@
#include "QGCMAVLink.h"
UASParameterDataModel::UASParameterDataModel(QObject *parent) :
QObject(parent)
QObject(parent),
defaultComponentId(-1)
{
onboardParameters.clear();
pendingParameters.clear();
......@@ -199,6 +200,26 @@ bool UASParameterDataModel::getOnboardParamValue(int componentId, const QString&
return false;
}
int UASParameterDataModel::getDefaultComponentId()
{
int result = 0;
if (-1 != defaultComponentId)
return defaultComponentId;
QList<int> components = getComponentForOnboardParam("SYS_AUTOSTART");//TODO is this the best way to find the right component?
// Guard against multiple components responding - this will never show in practice
if (1 == components.count()) {
result = components.first();
defaultComponentId = result;
}
qDebug() << "Default compId: " << result;
return result;
}
QList<int> UASParameterDataModel::getComponentForOnboardParam(const QString& parameter) const
{
QList<int> components;
......
......@@ -28,6 +28,9 @@ public:
virtual QString getParamDescription(const QString& param) { return paramDescriptions.value(param, ""); }
virtual void setParamDescriptions(const QMap<QString,QString>& paramInfo);
/** @brief Get the default component ID for the UAS */
virtual int getDefaultComponentId();
//TODO make this method protected?
/** @brief Ensure that the data model is aware of this component
* @param compId Id of the component
......@@ -113,6 +116,8 @@ public slots:
virtual void clearAllPendingParams();
protected:
int defaultComponentId; ///< Cached default component ID
int uasId; ///< The UAS / MAV to which this data model pertains
QMap<int, QMap<QString, QVariant>* > pendingParameters; ///< Changed values that have not yet been transmitted to the UAS, by component ID
QMap<int, QMap<QString, QVariant>* > onboardParameters; ///< All parameters confirmed to be stored onboard the UAS, by component ID
......
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