Commit dd455b95 authored by tstellanova's avatar tstellanova

start moving comms mgmt code to a separate class

parent 189135d4
......@@ -469,7 +469,8 @@ HEADERS += src/MG.h \
src/ui/configuration/terminalconsole.h \
src/ui/configuration/ApmHighlighter.h \
src/ui/configuration/ApmFirmwareConfig.h \
src/uas/UASParameterDataModel.h
src/uas/UASParameterDataModel.h \
src/uas/UASParameterCommsMgr.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
......@@ -685,7 +686,8 @@ SOURCES += src/main.cc \
src/ui/configuration/SerialSettingsDialog.cc \
src/ui/configuration/ApmHighlighter.cc \
src/ui/configuration/ApmFirmwareConfig.cc \
src/uas/UASParameterDataModel.cc
src/uas/UASParameterDataModel.cc \
src/uas/UASParameterCommsMgr.cc
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -66,37 +66,6 @@ void QGCUASParamManager::requestParameterList()
}
/**
* Enabling the retransmission guard enables the parameter widget to track
* dropped parameters and to re-request them. This works for both individual
* parameter reads as well for whole list requests.
*
* @param enabled True if retransmission checking should be enabled, false else
*/
void QGCUASParamManager::setRetransmissionGuardEnabled(bool enabled)
{
// qDebug() << "setRetransmissionGuardEnabled: " << enabled;
if (enabled) {
retransmissionTimer.start(retransmissionTimeout);
} else {
retransmissionTimer.stop();
}
}
void QGCUASParamManager::setParameterStatusMsg(const QString& msg)
{
qDebug() << "parameterStatusMsg: " << msg;
parameterStatusMsg = msg;
}
void QGCUASParamManager::setParamDescriptions(const QMap<QString,QString>& paramInfo) {
paramDataModel->setParamDescriptions(paramInfo);
}
void QGCUASParamManager::retransmissionGuardTick()
{
if (transmissionActive) {
......@@ -199,3 +168,35 @@ void QGCUASParamManager::retransmissionGuardTick()
setRetransmissionGuardEnabled(false);
}
}
/**
* Enabling the retransmission guard enables the parameter widget to track
* dropped parameters and to re-request them. This works for both individual
* parameter reads as well for whole list requests.
*
* @param enabled True if retransmission checking should be enabled, false else
*/
void QGCUASParamManager::setRetransmissionGuardEnabled(bool enabled)
{
// qDebug() << "setRetransmissionGuardEnabled: " << enabled;
if (enabled) {
retransmissionTimer.start(retransmissionTimeout);
} else {
retransmissionTimer.stop();
}
}
void QGCUASParamManager::setParameterStatusMsg(const QString& msg)
{
qDebug() << "parameterStatusMsg: " << msg;
parameterStatusMsg = msg;
}
void QGCUASParamManager::setParamDescriptions(const QMap<QString,QString>& paramInfo) {
paramDataModel->setParamDescriptions(paramInfo);
}
This diff is collapsed.
#ifndef UASPARAMETERCOMMSMGR_H
#define UASPARAMETERCOMMSMGR_H
#include <QObject>
#include <QMap>
#include <QTimer>
#include <QVariant>
#include <QVector>
class UASInterface;
class UASParameterDataModel;
class UASParameterCommsMgr : public QObject
{
Q_OBJECT
public:
explicit UASParameterCommsMgr(QObject *parent = 0, UASInterface* uas = NULL);
protected:
/** @brief Activate / deactivate parameter retransmission */
virtual void setRetransmissionGuardEnabled(bool enabled);
virtual void setParameterStatusMsg(const QString& msg);
signals:
void parameterChanged(int component, QString parameter, QVariant value);
void parameterChanged(int component, int parameterIndex, QVariant value);
void parameterValueConfirmed(int component, QString parameter, QVariant value);
void parameterListUpToDate(int component);
void parameterUpdateRequested(int component, const QString& parameter);
void parameterUpdateRequestedById(int componentId, int paramId);
public slots:
/** @brief Write one parameter to the MAV */
virtual void setParameter(int component, QString parameterName, QVariant value);
/** @brief Request list of parameters from MAV */
virtual void requestParameterList();
/** @brief Check for missing parameters */
virtual void retransmissionGuardTick();
/** @brief Request a single parameter update by name */
virtual void requestParameterUpdate(int component, const QString& parameter);
protected:
UASInterface* mav; ///< The MAV we're talking to
UASParameterDataModel* paramDataModel;
// Communications management
QVector<bool> receivedParamsList; ///< Successfully received parameters
QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
QMap<int, QMap<QString, QVariant>* > transmissionMissingWriteAckPackets; ///< Missing write ACK packets
bool transmissionListMode; ///< Currently requesting list
QMap<int, bool> transmissionListSizeKnown; ///< List size initialized?
bool transmissionActive; ///< Missing packets, working on list?
quint64 transmissionTimeout; ///< Timeout
QTimer retransmissionTimer; ///< Timer handling parameter retransmission
int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds
int rewriteTimeout; ///< Write request timeout, in milliseconds
int retransmissionBurstRequestSize; ///< Number of packets requested for retransmission per burst
// Status
QString parameterStatusMsg;
};
#endif // UASPARAMETERCOMMSMGR_H
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