Commit 9af04635 authored by Lorenz Meier's avatar Lorenz Meier

Merge branch 'config' of github.com:mavlink/qgroundcontrol into config

parents 98936a41 2db1d024
......@@ -285,6 +285,7 @@ class BandMatrixWrapper : public BandMatrixBase<BandMatrixWrapper<_CoefficientsT
m_rows(rows), m_supers(supers), m_subs(subs)
{
//internal::assert(coeffs.cols()==cols() && (supers()+subs()+1)==coeffs.rows());
cols=0; //workaround for compiler warning
}
/** \returns the number of columns */
......
......@@ -468,7 +468,11 @@ HEADERS += src/MG.h \
src/ui/configuration/SerialSettingsDialog.h \
src/ui/configuration/terminalconsole.h \
src/ui/configuration/ApmHighlighter.h \
src/ui/configuration/ApmFirmwareConfig.h
src/ui/configuration/ApmFirmwareConfig.h \
src/uas/UASParameterDataModel.h \
src/uas/UASParameterCommsMgr.h \
src/ui/QGCPendingParamWidget.h \
src/ui/QGCBaseParamWidget.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
......@@ -683,7 +687,11 @@ SOURCES += src/main.cc \
src/ui/configuration/console.cpp \
src/ui/configuration/SerialSettingsDialog.cc \
src/ui/configuration/ApmHighlighter.cc \
src/ui/configuration/ApmFirmwareConfig.cc
src/ui/configuration/ApmFirmwareConfig.cc \
src/uas/UASParameterDataModel.cc \
src/uas/UASParameterCommsMgr.cc \
src/ui/QGCPendingParamWidget.cc \
src/ui/QGCBaseParamWidget.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
......
......@@ -176,7 +176,9 @@ void SerialLink::run()
}
if (isConnected() && (linkErrorCount > 100)) {
qDebug() << "linkErrorCount too high: disconnecting!";
linkErrorCount = 0;
communicationError("SerialLink", tr("Disconnecting on too many link errors"));
disconnect();
}
......@@ -210,7 +212,7 @@ void SerialLink::run()
}
} else {
linkErrorCount++;
qDebug() << "Wait read response timeout" << QTime::currentTime().toString();
//qDebug() << "Wait read response timeout" << QTime::currentTime().toString();
}
if (bytes != m_bytesRead) // i.e things are good and data is being read.
......@@ -370,6 +372,8 @@ bool SerialLink::disconnect()
return true;
}
m_transmitBuffer.clear(); //clear the output buffer to avoid sending garbage at next connect
qDebug() << "already disconnected";
return true;
}
......
#include "QGCUASParamManager.h"
#include <QApplication>
#include <QDir>
#include <QMessageBox>
#include "UASInterface.h"
#include "UASParameterCommsMgr.h"
QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) :
QWidget(parent),
mav(uas),
transmissionListMode(false),
transmissionActive(false),
transmissionTimeout(0),
retransmissionTimeout(350),
rewriteTimeout(500),
retransmissionBurstRequestSize(5)
QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QObject(parent),
mav(NULL),
paramDataModel(this),
paramCommsMgr(NULL)
{
uas->setParamManager(this);
}
QGCUASParamManager* QGCUASParamManager::initWithUAS(UASInterface* uas)
{
mav = uas;
// Load default values and tooltips for data model
loadParamMetaInfoCSV();
paramCommsMgr = new UASParameterCommsMgr(this);
paramCommsMgr->initWithUAS(uas);
connectToModelAndComms();
return this;
}
void QGCUASParamManager::connectToModelAndComms()
{
// Pass along comms mgr status msgs
connect(paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SIGNAL(parameterStatusMsgUpdated(QString,int)));
connect(paramCommsMgr, SIGNAL(parameterListUpToDate()),
this, SIGNAL(parameterListUpToDate()));
}
void QGCUASParamManager::clearAllPendingParams()
{
paramDataModel.clearAllPendingParams();
}
bool QGCUASParamManager::getParameterValue(int component, const QString& parameter, QVariant& value) const
{
return paramDataModel.getOnboardParamValue(component,parameter,value);
}
void QGCUASParamManager::requestParameterUpdate(int component, const QString& parameter)
{
if (mav) {
paramCommsMgr->requestParameterUpdate(component,parameter);
}
}
/**
* The .. signal is emitted
* Send a request to deliver the list of onboard parameters
* to the MAV.
*/
void QGCUASParamManager::requestParameterListUpdate(int component)
void QGCUASParamManager::requestParameterList()
{
if (mav) {
emit parameterStatusMsgUpdated(tr("Requested param list.. waiting"), UASParameterCommsMgr::ParamCommsStatusLevel_OK);
paramCommsMgr->requestParameterList();
}
}
void QGCUASParamManager::requestParameterListIfEmpty()
{
if (mav) {
int totalOnboard = paramDataModel.countOnboardParams();
if (totalOnboard < 2) { //TODO arbitrary constant, maybe 0 is OK?
requestParameterList();
}
}
}
void QGCUASParamManager::setParamDescriptions(const QMap<QString,QString>& paramInfo) {
paramDataModel.setParamDescriptions(paramInfo);
}
void QGCUASParamManager::setParameter(int compId, QString paramName, QVariant value)
{
paramDataModel.updatePendingParamWithValue(compId,paramName,value);
}
void QGCUASParamManager::sendPendingParameters()
{
paramCommsMgr->sendPendingParameters();
}
void QGCUASParamManager::setPendingParam(int compId, QString& paramName, const QVariant& value)
{
Q_UNUSED(component);
paramDataModel.updatePendingParamWithValue(compId,paramName,value);
}
void QGCUASParamManager::loadParamMetaInfoCSV()
{
// Load default values and tooltips
QString autopilot(mav->getAutopilotTypeName());
QDir appDir = QApplication::applicationDirPath();
appDir.cd("files");
QString fileName = QString("%1/%2/parameter_tooltips/tooltips.txt").arg(appDir.canonicalPath()).arg(autopilot.toLower());
QFile paramMetaFile(fileName);
qDebug() << "loadParamMetaInfoCSV for autopilot: " << autopilot << " from file: " << fileName;
if (!paramMetaFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qWarning() << "loadParamMetaInfoCSV couldn't open:" << fileName;
return;
}
QTextStream in(&paramMetaFile);
paramDataModel.loadParamMetaInfoFromStream(in);
paramMetaFile.close();
}
UASInterface* QGCUASParamManager::getUAS()
{
return mav;
}
UASParameterDataModel* QGCUASParamManager::dataModel()
{
return &paramDataModel;
}
void QGCUASParamManager::writeOnboardParamsToStream(QTextStream &stream, const QString& uasName)
{
paramDataModel.writeOnboardParamsToStream(stream,uasName);
}
void QGCUASParamManager::readPendingParamsFromStream(QTextStream &stream)
{
paramDataModel.readUpdateParamsFromStream(stream);
}
void QGCUASParamManager::copyVolatileParamsToPersistent()
{
int changedParamCount = paramDataModel.countPendingParams();
if (changedParamCount > 0) {
QMessageBox msgBox;
msgBox.setText(tr("There are locally changed parameters. Please transmit them first (<TRANSMIT>) or update them with the onboard values (<REFRESH>) before storing onboard from RAM to ROM."));
msgBox.exec();
}
else {
paramCommsMgr->writeParamsToPersistentStorage();
}
}
void QGCUASParamManager::copyPersistentParamsToVolatile()
{
if (mav) {
mav->readParametersFromStorage(); //TODO use comms mgr instead?
}
}
void QGCUASParamManager::requestRcCalibrationParamsUpdate() {
paramCommsMgr->requestRcCalibrationParamsUpdate();
}
......@@ -6,76 +6,89 @@
#include <QTimer>
#include <QVariant>
#include "UASParameterDataModel.h"
//forward declarations
class QTextStream;
class UASInterface;
class UASParameterCommsMgr;
class QGCUASParamManager : public QWidget
class QGCUASParamManager : public QObject
{
Q_OBJECT
public:
QGCUASParamManager(UASInterface* uas, QWidget *parent = 0);
QList<QString> getParameterNames(int component) const {
return parameters.value(component)->keys();
}
QList<QVariant> getParameterValues(int component) const {
return parameters.value(component)->values();
}
bool getParameterValue(int component, const QString& parameter, QVariant& value) const {
if (!parameters.contains(component))
{
return false;
}
if (!parameters.value(component)->contains(parameter))
{
return false;
}
value = parameters.value(component)->value(parameter);
return true;
}
virtual bool isParamMinKnown(const QString& param) = 0;
virtual bool isParamMaxKnown(const QString& param) = 0;
virtual bool isParamDefaultKnown(const QString& param) = 0;
virtual double getParamMin(const QString& param) = 0;
virtual double getParamMax(const QString& param) = 0;
virtual double getParamDefault(const QString& param) = 0;
virtual QString getParamInfo(const QString& param) = 0;
virtual void setParamInfo(const QMap<QString,QString>& param) = 0;
/** @brief Request an update for the parameter list */
void requestParameterListUpdate(int component = 0);
/** @brief Request an update for this specific parameter */
virtual void requestParameterUpdate(int component, const QString& parameter) = 0;
QGCUASParamManager(QObject* parent = 0);
QGCUASParamManager* initWithUAS(UASInterface* uas);
/** @brief Get the known, confirmed value of a parameter */
virtual bool getParameterValue(int component, const QString& parameter, QVariant& value) const;
/** @brief Provide tooltips / user-visible descriptions for parameters */
virtual void setParamDescriptions(const QMap<QString,QString>& paramDescs);
/** @brief Get the UAS of this widget
* @return The MAV of this mgr. Unless the MAV object has been destroyed, this is never null.
*/
UASInterface* getUAS();
/** @return The data model managed by this class */
virtual UASParameterDataModel* dataModel();
protected:
/** @brief Load parameter meta information from appropriate CSV file */
virtual void loadParamMetaInfoCSV();
void connectToModelAndComms();
signals:
void parameterChanged(int component, QString parameter, QVariant value);
void parameterChanged(int component, int parameterIndex, QVariant value);
void parameterListUpToDate(int component);
/** @brief We updated the parameter status message */
void parameterStatusMsgUpdated(QString msg, int level);
/** @brief We have received a complete list of all parameters onboard the MAV */
void parameterListUpToDate();
public slots:
/** @brief Write one parameter to the MAV */
virtual void setParameter(int component, QString parameterName, QVariant value) = 0;
/** @brief Send one parameter to the MAV: changes value in transient memory of MAV */
virtual void setParameter(int component, QString parameterName, QVariant value);
/** @brief Send all pending parameters to the MAV, for storage in transient (RAM) memory */
virtual void sendPendingParameters();
/** @brief Request list of parameters from MAV */
virtual void requestParameterList() = 0;
virtual void requestParameterList();
/** @brief Request a list of params onboard the MAV if the onboard param list we have is empty */
virtual void requestParameterListIfEmpty();
virtual void setPendingParam(int componentId, QString& key, const QVariant& value);
/** @brief remove all params from the pending list */
virtual void clearAllPendingParams();
/** @brief Request a single parameter by name from the MAV */
virtual void requestParameterUpdate(int component, const QString& parameter);
virtual void writeOnboardParamsToStream(QTextStream &stream, const QString& uasName);
virtual void readPendingParamsFromStream(QTextStream &stream);
virtual void requestRcCalibrationParamsUpdate();
/** @brief Copy the current parameters in volatile RAM to persistent storage (EEPROM/HDD) */
virtual void copyVolatileParamsToPersistent();
/** @brief Copy the parameters from persistent storage to volatile RAM */
virtual void copyPersistentParamsToVolatile();
protected:
UASInterface* mav; ///< The MAV this widget is controlling
QMap<int, QMap<QString, QVariant>* > changedValues; ///< Changed values
QMap<int, QMap<QString, QVariant>* > parameters; ///< All parameters
QVector<bool> received; ///< 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
// Parameter data model
UASInterface* mav; ///< The MAV this manager is controlling
UASParameterDataModel paramDataModel;///< Shared data model of parameters
UASParameterCommsMgr* paramCommsMgr; ///< Shared comms mgr for parameters
};
......
This diff is collapsed.
......@@ -41,6 +41,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCJSBSimLink.h"
#include "QGCXPlaneLink.h"
/**
* @brief A generic MAVLINK-connected MAV/UAV
*
......@@ -491,7 +492,7 @@ protected: //COMMENTS FOR TEST UNIT
/// PARAMETERS
QMap<int, QMap<QString, QVariant>* > parameters; ///< All parameters
bool paramsOnceRequested; ///< If the parameter list has been read at least once
QGCUASParamManager* paramManager; ///< Parameter manager class
QGCUASParamManager paramMgr; ///< Parameter manager for this UAS
/// SIMULATION
QGCHilLink* simulation; ///< Hardware in the loop simulation link
......@@ -512,22 +513,22 @@ public:
/** @brief Check if vehicle is armed */
bool isArmed() const { return systemIsArmed; }
/** @brief Get reference to the waypoint manager **/
UASWaypointManager* getWaypointManager() {
return &waypointManager;
}
/** @brief Get reference to the param manager **/
QGCUASParamManager* getParamManager() const {
return paramManager;
virtual QGCUASParamManager* getParamManager() {
return &paramMgr;
}
/** @brief Get the HIL simulation */
QGCHilLink* getHILSimulation() const {
return simulation;
}
// TODO Will be removed
/** @brief Set reference to the param manager **/
void setParamManager(QGCUASParamManager* manager) {
paramManager = manager;
}
int getSystemType();
/**
......@@ -936,6 +937,8 @@ protected:
/** @brief Get the UNIX timestamp in milliseconds, ignore attitudeStamped mode */
quint64 getUnixReferenceTime(quint64 time);
virtual void processParamValueMsg(mavlink_message_t& msg, const QString& paramName,const mavlink_param_value_t& rawValue, mavlink_param_union_t& paramValue);
int componentID[256];
bool componentMulti[256];
bool connectionLost; ///< Flag indicates a timed out connection
......@@ -949,6 +952,7 @@ protected:
quint64 lastSendTimeSensors;
QList<QAction*> actions; ///< A list of actions that this UAS can perform.
protected slots:
/** @brief Write settings to disk */
void writeSettings();
......
......@@ -40,6 +40,7 @@ This file is part of the QGROUNDCONTROL project
#include "LinkInterface.h"
#include "ProtocolInterface.h"
#include "UASParameterDataModel.h"
#include "UASWaypointManager.h"
#include "QGCUASParamManager.h"
#include "RadioCalibration/RadioCalibrationData.h"
......@@ -152,11 +153,9 @@ public:
/** @brief Get reference to the waypoint manager **/
virtual UASWaypointManager* getWaypointManager(void) = 0;
/** @brief Get reference to the param manager **/
virtual QGCUASParamManager* getParamManager() const = 0;
// TODO Will be removed
/** @brief Set reference to the param manager **/
virtual void setParamManager(QGCUASParamManager* manager) = 0;
virtual QGCUASParamManager* getParamManager() = 0;
/* COMMUNICATION FLAGS */
......
......@@ -280,6 +280,7 @@ void UASManager::addUAS(UASInterface* uas)
// Only execute if there is no UAS at this index
if (!systems.contains(uas))
{
qDebug() << "Add new UAS: " << uas->getUASID();
systems.append(uas);
// Set home position on UAV if set in UI
// - this is done on a per-UAV basis
......
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);
UASParameterCommsMgr* initWithUAS(UASInterface* model);///< Two-stage constructor
~UASParameterCommsMgr();
typedef enum ParamCommsStatusLevel {
ParamCommsStatusLevel_OK = 0,
ParamCommsStatusLevel_Warning = 2,
ParamCommsStatusLevel_Error = 4,
ParamCommsStatusLevel_Count
} ParamCommsStatusLevel_t;
protected:
/** @brief Activate / deactivate parameter retransmission */
virtual void setRetransmissionGuardEnabled(bool enabled);
virtual void setParameterStatusMsg(const QString& msg, ParamCommsStatusLevel_t level=ParamCommsStatusLevel_OK);
/** @brief Load settings that control eg retransmission timeouts */
void loadParamCommsSettings();
/** @brief clear transmissionMissingPackets and transmissionMissingWriteAckPackets */
void clearRetransmissionLists(int& missingReadCount, int& missingWriteCount );
void resendReadWriteRequests();
void resetAfterListReceive();
void emitPendingParameterCommit(int compId, const QString& key, QVariant& value);
signals:
void commitPendingParameter(int component, QString parameter, QVariant value);
void parameterChanged(int component, int parameterIndex, QVariant value);
void parameterValueConfirmed(int uas, int component,int paramCount, int paramId, QString parameter, QVariant value);
/** @brief We have received a complete list of all parameters onboard the MAV */
void parameterListUpToDate();
void parameterUpdateRequested(int component, const QString& parameter);
void parameterUpdateRequestedById(int componentId, int paramId);
/** @brief We updated the parameter status message */
void parameterStatusMsgUpdated(QString msg, int level);
public slots:
/** @brief Iterate through all components, through all pending parameters and send them to UAS */
virtual void sendPendingParameters();
/** @brief Write the current onboard parameters from transient RAM into persistent storage, e.g. EEPROM or harddisk */
virtual void writeParamsToPersistentStorage();
/** @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);
/** @brief Request an update of RC parameters */
virtual void requestRcCalibrationParamsUpdate();
virtual void receivedParameterUpdate(int uas, int compId, int paramCount, int paramId, QString paramName, QVariant value);
protected:
UASInterface* mav; ///< The MAV we're talking to
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?
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;
};
#endif // UASPARAMETERCOMMSMGR_H
This diff is collapsed.
#ifndef UASPARAMETERDATAMODEL_H
#define UASPARAMETERDATAMODEL_H
#include <QMap>
#include <QObject>
#include <QVariant>
class QTextStream;
class UASParameterDataModel : public QObject
{
Q_OBJECT
public:
explicit UASParameterDataModel(QObject *parent = 0);
//Parameter meta info
bool isParamMinKnown(const QString& param) { return paramMin.contains(param); }
virtual bool isValueLessThanParamMin(const QString& param, double dblVal);
bool isParamMaxKnown(const QString& param) { return paramMax.contains(param); }
virtual bool isValueGreaterThanParamMax(const QString& param, double dblVal);
bool isParamDefaultKnown(const QString& param) { return paramDefault.contains(param); }
double getParamMin(const QString& param) { return paramMin.value(param, 0.0f); }
double getParamMax(const QString& param) { return paramMax.value(param, 0.0f); }
double getParamDefault(const QString& param) { return paramDefault.value(param, 0.0f); }
virtual QString getParamDescription(const QString& param) { return paramDescriptions.value(param, ""); }
virtual void setParamDescriptions(const QMap<QString,QString>& paramInfo);
//TODO make this method protected?
/** @brief Ensure that the data model is aware of this component
* @param compId Id of the component
*/
virtual void addComponent(int compId);
/** @brief Save the onboard parameter with a the type specified in the QVariant as fixed */
virtual void setOnboardParamWithType(int componentId, QString& key, QVariant& value);
/** @brief clears every parameter for every loaded component */
virtual void forgetAllOnboardParams();
/** @brief add this parameter to pending list iff it has changed from onboard value
* @return true if the parameter is now pending
*/
virtual bool updatePendingParamWithValue(int componentId, QString& key, const QVariant &value);
virtual void handleParamUpdate(int componentId, QString& key, QVariant& value);
virtual bool getOnboardParamValue(int componentId, const QString& key, QVariant& value) const;
virtual bool isParamChangePending(int componentId,const QString& key);
QMap<QString , QVariant>* getPendingParamsForComponent(int componentId) {
return pendingParameters.value(componentId);
}
QMap<QString , QVariant>* getOnboardParamsForComponent(int componentId) {
return onboardParameters.value(componentId);
}
QMap<int, QMap<QString, QVariant>* >* getAllPendingParams() {
return &pendingParameters;
}
QMap<int, QMap<QString, QVariant>* >* getAllOnboardParams() {
return &onboardParameters;
}
/** @brief return a count of all pending parameters */
virtual int countPendingParams();
/** @brief return a count of all onboard parameters we've received */
virtual int countOnboardParams();
virtual void writeOnboardParamsToStream(QTextStream &stream, const QString& uasName);
virtual void readUpdateParamsFromStream(QTextStream &stream);
virtual void loadParamMetaInfoFromStream(QTextStream& stream);
void setUASID(int anId) { this->uasId = anId; }
protected:
/** @brief set the confirmed value of a parameter in the onboard params list */
virtual void setOnboardParam(int componentId, QString& key, const QVariant& value);
/** @brief Write a new pending parameter value that may be eventually sent to the UAS */
virtual void setPendingParam(int componentId, QString& key, const QVariant& value);
/** @brief remove a parameter from the pending list */
virtual void removePendingParam(int compId, const QString &key);
signals:
/** @brief We've received an update of a parameter's value */
void parameterUpdated(int compId, QString paramName, QVariant value);
/** @brief Notifies listeners that a param was added to or removed from the pending list */
void pendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending);
void allPendingParamsCommitted(); ///< All pending params have been committed to the MAV
public slots:
virtual void clearAllPendingParams();
protected:
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
// Tooltip data structures
QMap<QString, QString> paramDescriptions; ///< Tooltip values
// Min / Default / Max data structures
QMap<QString, double> paramMin; ///< Minimum param values
QMap<QString, double> paramDefault; ///< Default param values
QMap<QString, double> paramMax; ///< Minimum param values
};
#endif // UASPARAMETERDATAMODEL_H
......@@ -975,7 +975,9 @@ void UASWaypointManager::sendWaypointRequestList()
wprl.target_system = uasid;
wprl.target_component = MAV_COMP_ID_MISSIONPLANNER;
emit updateStatusString(QString("Requesting waypoint list..."));
QString statusMsg(tr("Requesting waypoint list..."));
qDebug() << __FILE__ << __LINE__ << statusMsg;
emit updateStatusString(statusMsg);
mavlink_msg_mission_request_list_encode(uas->mavlink->getSystemId(), uas->mavlink->getComponentId(), &message, &wprl);
uas->sendMessage(message);
......
......@@ -950,35 +950,60 @@ void HSIDisplay::setActiveUAS(UASInterface* uas)
if (uas)
{
connect(uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)), this, SLOT(updateSatellite(int,int,float,float,float,bool)));
connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeThrustSetPointChanged(UASInterface*,double,double,double,double,quint64)), this, SLOT(updateAttitudeSetpoints(UASInterface*,double,double,double,double,quint64)));
connect(uas, SIGNAL(positionSetPointsChanged(int,float,float,float,float,quint64)), this, SLOT(updatePositionSetpoints(int,float,float,float,float,quint64)));
connect(uas, SIGNAL(userPositionSetPointsChanged(int,float,float,float,float)), this, SLOT(updateUserPositionSetpoints(int,float,float,float,float)));
connect(uas, SIGNAL(speedChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateSpeed(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeControlEnabled(bool)), this, SLOT(updateAttitudeControllerEnabled(bool)));
connect(uas, SIGNAL(positionXYControlEnabled(bool)), this, SLOT(updatePositionXYControllerEnabled(bool)));
connect(uas, SIGNAL(positionZControlEnabled(bool)), this, SLOT(updatePositionZControllerEnabled(bool)));
connect(uas, SIGNAL(positionYawControlEnabled(bool)), this, SLOT(updatePositionYawControllerEnabled(bool)));
connect(uas, SIGNAL(localizationChanged(UASInterface*,int)), this, SLOT(updateLocalization(UASInterface*,int)));
connect(uas, SIGNAL(visionLocalizationChanged(UASInterface*,int)), this, SLOT(updateVisionLocalization(UASInterface*,int)));
connect(uas, SIGNAL(gpsLocalizationChanged(UASInterface*,int)), this, SLOT(updateGpsLocalization(UASInterface*,int)));
connect(uas, SIGNAL(irUltraSoundLocalizationChanged(UASInterface*,int)), this, SLOT(updateInfraredUltrasoundLocalization(UASInterface*,int)));
connect(uas, SIGNAL(objectDetected(uint,int,int,QString,int,float,float)), this, SLOT(updateObjectPosition(uint,int,int,QString,int,float,float)));
connect(uas, SIGNAL(gyroStatusChanged(bool,bool,bool)), this, SLOT(updateGyroStatus(bool,bool,bool)));
connect(uas, SIGNAL(accelStatusChanged(bool,bool,bool)), this, SLOT(updateAccelStatus(bool,bool,bool)));
connect(uas, SIGNAL(magSensorStatusChanged(bool,bool,bool)), this, SLOT(updateMagSensorStatus(bool,bool,bool)));
connect(uas, SIGNAL(baroStatusChanged(bool,bool,bool)), this, SLOT(updateBaroStatus(bool,bool,bool)));
connect(uas, SIGNAL(airspeedStatusChanged(bool,bool,bool)), this, SLOT(updateAirspeedStatus(bool,bool,bool)));
connect(uas, SIGNAL(opticalFlowStatusChanged(bool,bool,bool)), this, SLOT(updateOpticalFlowStatus(bool,bool,bool)));
connect(uas, SIGNAL(laserStatusChanged(bool,bool,bool)), this, SLOT(updateLaserStatus(bool,bool,bool)));
connect(uas, SIGNAL(groundTruthSensorStatusChanged(bool,bool,bool)), this, SLOT(updateGroundTruthSensorStatus(bool,bool,bool)));
connect(uas, SIGNAL(actuatorStatusChanged(bool,bool,bool)), this, SLOT(updateActuatorStatus(bool,bool,bool)));
connect(uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)),
this, SLOT(updateSatellite(int,int,float,float,float,bool)));
connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)),
this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)),
this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeThrustSetPointChanged(UASInterface*,double,double,double,double,quint64)),
this, SLOT(updateAttitudeSetpoints(UASInterface*,double,double,double,double,quint64)));
connect(uas, SIGNAL(positionSetPointsChanged(int,float,float,float,float,quint64)),
this, SLOT(updatePositionSetpoints(int,float,float,float,float,quint64)));
connect(uas, SIGNAL(userPositionSetPointsChanged(int,float,float,float,float)),
this, SLOT(updateUserPositionSetpoints(int,float,float,float,float)));
connect(uas, SIGNAL(velocityChanged_NED(UASInterface*,double,double,double,quint64)),
this, SLOT(updateSpeed(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)),
this, SLOT(updateAttitude(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeControlEnabled(bool)),
this, SLOT(updateAttitudeControllerEnabled(bool)));
connect(uas, SIGNAL(positionXYControlEnabled(bool)),
this, SLOT(updatePositionXYControllerEnabled(bool)));
connect(uas, SIGNAL(positionZControlEnabled(bool)),
this, SLOT(updatePositionZControllerEnabled(bool)));
connect(uas, SIGNAL(positionYawControlEnabled(bool)),
this, SLOT(updatePositionYawControllerEnabled(bool)));
connect(uas, SIGNAL(localizationChanged(UASInterface*,int)),
this, SLOT(updateLocalization(UASInterface*,int)));
connect(uas, SIGNAL(visionLocalizationChanged(UASInterface*,int)),
this, SLOT(updateVisionLocalization(UASInterface*,int)));
connect(uas, SIGNAL(gpsLocalizationChanged(UASInterface*,int)),
this, SLOT(updateGpsLocalization(UASInterface*,int)));
connect(uas, SIGNAL(irUltraSoundLocalizationChanged(UASInterface*,int)),
this, SLOT(updateInfraredUltrasoundLocalization(UASInterface*,int)));
connect(uas, SIGNAL(objectDetected(uint,int,int,QString,int,float,float)),
this, SLOT(updateObjectPosition(uint,int,int,QString,int,float,float)));
connect(uas, SIGNAL(gyroStatusChanged(bool,bool,bool)),
this, SLOT(updateGyroStatus(bool,bool,bool)));
connect(uas, SIGNAL(accelStatusChanged(bool,bool,bool)),
this, SLOT(updateAccelStatus(bool,bool,bool)));
connect(uas, SIGNAL(magSensorStatusChanged(bool,bool,bool)),
this, SLOT(updateMagSensorStatus(bool,bool,bool)));
connect(uas, SIGNAL(baroStatusChanged(bool,bool,bool)),
this, SLOT(updateBaroStatus(bool,bool,bool)));
connect(uas, SIGNAL(airspeedStatusChanged(bool,bool,bool)),
this, SLOT(updateAirspeedStatus(bool,bool,bool)));
connect(uas, SIGNAL(opticalFlowStatusChanged(bool,bool,bool)),
this, SLOT(updateOpticalFlowStatus(bool,bool,bool)));
connect(uas, SIGNAL(laserStatusChanged(bool,bool,bool)),
this, SLOT(updateLaserStatus(bool,bool,bool)));
connect(uas, SIGNAL(groundTruthSensorStatusChanged(bool,bool,bool)),
this, SLOT(updateGroundTruthSensorStatus(bool,bool,bool)));
connect(uas, SIGNAL(actuatorStatusChanged(bool,bool,bool)),
this, SLOT(updateActuatorStatus(bool,bool,bool)));
statusClearTimer.start(3000);
}
else
......
......@@ -72,6 +72,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
ParameterInterface::~ParameterInterface()
{
delete paramWidgets;
delete m_ui;
}
......@@ -89,9 +90,22 @@ void ParameterInterface::selectUAS(int index)
*/
void ParameterInterface::addUAS(UASInterface* uas)
{
QGCParamWidget* param = new QGCParamWidget(uas, this);
paramWidgets->insert(uas->getUASID(), param);
m_ui->stackedWidget->addWidget(param);
int uasId = uas->getUASID();
qDebug() << "ParameterInterface::addUAS : " << uasId ;
if (paramWidgets->contains(uasId) ) {
return;
}
QGCParamWidget* paramWidget = new QGCParamWidget(this);
paramWidget = (QGCParamWidget*)paramWidget->initWithUAS(uas);
QString ptrStr;
ptrStr.sprintf("QGCParamWidget %8p (parent %8p)", paramWidget,this);
qDebug() << "Created " << ptrStr << " for UAS id: " << uasId << " count: " << paramWidgets->count();
paramWidgets->insert(uasId, paramWidget);
m_ui->stackedWidget->addWidget(paramWidget);
QGCSensorSettingsWidget* sensor = NULL;
......@@ -106,7 +120,7 @@ void ParameterInterface::addUAS(UASInterface* uas)
// Clear
if (m_ui->sensorSettings && sensor)
m_ui->sensorSettings->setCurrentWidget(sensor);
m_ui->stackedWidget->setCurrentWidget(param);
m_ui->stackedWidget->setCurrentWidget(paramWidget);
curr = 0;
}
}
......
......@@ -267,15 +267,24 @@ void PrimaryFlightDisplay::forgetUAS(UASInterface* uas)
{
if (this->uas != NULL && this->uas == uas) {
// Disconnect any previously connected active MAV
disconnect(this->uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*, double, double, double, quint64)));
disconnect(this->uas, SIGNAL(attitudeChanged(UASInterface*,int,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,int,double, double, double, quint64)));
disconnect(this->uas, SIGNAL(waypointSelected(int,int)), this, SLOT(selectWaypoint(int, int)));
disconnect(this->uas, SIGNAL(primarySpeedChanged(UASInterface*, double, quint64)), this, SLOT(updatePrimarySpeed(UASInterface*,double,quint64)));
disconnect(this->uas, SIGNAL(gpsSpeedChanged(UASInterface*, double, quint64)), this, SLOT(updateGPSSpeed(UASInterface*,double,quint64)));
disconnect(this->uas, SIGNAL(climbRateChanged(UASInterface*, double, quint64)), this, SLOT(updateClimbRate(UASInterface*, AltitudeMeasurementSource, double, quint64)));
disconnect(this->uas, SIGNAL(primaryAltitudeChanged(UASInterface*, double, quint64)), this, SLOT(updatePrimaryAltitude(UASInterface*, double, quint64)));
disconnect(this->uas, SIGNAL(gpsAltitudeChanged(UASInterface*, double, quint64)), this, SLOT(updateGPSAltitude(UASInterface*, double, quint64)));
disconnect(this->uas, SIGNAL(navigationControllerErrorsChanged(UASInterface*, double, double, double)), this, SLOT(updateNavigationControllerErrors(UASInterface*, double, double, double)));
disconnect(this->uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)),
this, SLOT(updateAttitude(UASInterface*, double, double, double, quint64)));
disconnect(this->uas, SIGNAL(attitudeChanged(UASInterface*,int,double,double,double,quint64)),
this, SLOT(updateAttitude(UASInterface*,int,double, double, double, quint64)));
//disconnect(this->uas, SIGNAL(waypointSelected(int,int)),
// this, SLOT(selectWaypoint(int, int)));
disconnect(this->uas, SIGNAL(primarySpeedChanged(UASInterface*, double, quint64)),
this, SLOT(updatePrimarySpeed(UASInterface*,double,quint64)));
disconnect(this->uas, SIGNAL(gpsSpeedChanged(UASInterface*, double, quint64)),
this, SLOT(updateGPSSpeed(UASInterface*,double,quint64)));
disconnect(this->uas, SIGNAL(climbRateChanged(UASInterface*, double, quint64)),
this,SLOT(updateClimbRate(UASInterface*, double, quint64)));
disconnect(this->uas, SIGNAL(primaryAltitudeChanged(UASInterface*, double, quint64)),
this, SLOT(updatePrimaryAltitude(UASInterface*, double, quint64)));
disconnect(this->uas, SIGNAL(gpsAltitudeChanged(UASInterface*, double, quint64)),
this, SLOT(updateGPSAltitude(UASInterface*, double, quint64)));
disconnect(this->uas, SIGNAL(navigationControllerErrorsChanged(UASInterface*, double, double, double)),
this, SLOT(updateNavigationControllerErrors(UASInterface*, double, double, double)));
//disconnect(this->uas, SIGNAL(batteryChanged(UASInterface*, double, double, double, int)), this, SLOT(updateBattery(UASInterface*, double, double, double, int)));
//disconnect(this->uas, SIGNAL(statusChanged(UASInterface*,QString,QString)), this, SLOT(updateState(UASInterface*,QString)));
......@@ -314,10 +323,12 @@ void PrimaryFlightDisplay::setActiveUAS(UASInterface* uas)
//connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64)));
//connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(waypointSelected(int,int)), this, SLOT(selectWaypoint(int, int)));
//connect(uas, SIGNAL(waypointSelected(int,int)), this,
// SLOT(selectWaypoint(int, int)));
connect(uas, SIGNAL(primarySpeedChanged(UASInterface*, double, quint64)), this, SLOT(updatePrimarySpeed(UASInterface*,double,quint64)));
connect(uas, SIGNAL(gpsSpeedChanged(UASInterface*, double, quint64)), this, SLOT(updateGPSSpeed(UASInterface*,double,quint64)));
connect(uas, SIGNAL(climbRateChanged(UASInterface*, double, quint64)), this, SLOT(updateClimbRate(UASInterface*, AltitudeMeasurementSource, double, quint64)));
connect(uas, SIGNAL(climbRateChanged(UASInterface*, double, quint64)), this,
SLOT(updateClimbRate(UASInterface*, double, quint64)));
connect(uas, SIGNAL(primaryAltitudeChanged(UASInterface*, double, quint64)), this, SLOT(updatePrimaryAltitude(UASInterface*, double, quint64)));
connect(uas, SIGNAL(gpsAltitudeChanged(UASInterface*, double, quint64)), this, SLOT(updateGPSAltitude(UASInterface*, double, quint64)));
connect(uas, SIGNAL(navigationControllerErrorsChanged(UASInterface*, double, double, double)), this, SLOT(updateNavigationControllerErrors(UASInterface*, double, double, double)));
......
#include "QGCBaseParamWidget.h"
#include <QFileDialog>
#include <QFile>
#include <QVariant>
#include <QTextStream>>
#include "QGCUASParamManager.h"
#include "UASInterface.h"
QGCBaseParamWidget::QGCBaseParamWidget(QWidget *parent) :
QWidget(parent),
mav(NULL),
paramMgr(NULL),
updatingParamNameLock("")
{
}
QGCBaseParamWidget* QGCBaseParamWidget::initWithUAS(UASInterface *uas)
{
setUAS(uas);
return this;
}
void QGCBaseParamWidget::setUAS(UASInterface* uas)
{
if (uas != mav) {
if (mav) {
//TODO disconnect any connections as needed
disconnectViewSignalsAndSlots();
disconnectFromParamManager();
clearOnboardParamDisplay();
clearPendingParamDisplay();
}
mav = uas;
if (mav) {
connectToParamManager();
connectViewSignalsAndSlots();
layoutWidget();
paramMgr->requestParameterListIfEmpty();
}
}
}
void QGCBaseParamWidget::connectToParamManager()
{
paramMgr = mav->getParamManager();
//TODO route via paramManager instead?
// Listen to updated param signals from the data model
connect(paramMgr->dataModel(), SIGNAL(parameterUpdated(int, QString , QVariant )),
this, SLOT(handleOnboardParamUpdate(int,QString,QVariant)));
connect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
// Listen for param list reload finished
connect(paramMgr, SIGNAL(parameterListUpToDate()),
this, SLOT(handleOnboardParameterListUpToDate()));
// Listen to communications status messages so we can display them
connect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
}
void QGCBaseParamWidget::disconnectFromParamManager()
{
disconnect(paramMgr->dataModel(), SIGNAL(parameterUpdated(int, QString , QVariant )),
this, SLOT(handleOnboardParamUpdate(int,QString,QVariant)));
disconnect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
disconnect(paramMgr, SIGNAL(parameterListUpToDate()),
this, SLOT(handleOnboardParameterListUpToDate()));
// Listen to communications status messages so we can display them
disconnect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
paramMgr = NULL;
}
void QGCBaseParamWidget::requestOnboardParamsUpdate()
{
paramMgr->requestParameterList();
}
void QGCBaseParamWidget::saveParametersToFile()
{
if (!mav)
return;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "./parameters.txt", tr("Parameter File (*.txt)"));
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
return;
}
QTextStream outstream(&file);
paramMgr->writeOnboardParamsToStream(outstream,mav->getUASName());
file.close();
}
void QGCBaseParamWidget::loadParametersFromFile()
{
if (!mav)
return;
QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"), ".", tr("Parameter file (*.txt)"));
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream in(&file);
paramMgr->readPendingParamsFromStream(in);
file.close();
}
#ifndef QGCBASEPARAMWIDGET_H
#define QGCBASEPARAMWIDGET_H
#include <QVariant>
#include <QWidget>
//forward declarations
class QGCUASParamManager;
class UASInterface;
class QGCBaseParamWidget : public QWidget
{
Q_OBJECT
public:
explicit QGCBaseParamWidget(QWidget *parent = 0);
virtual QGCBaseParamWidget* initWithUAS(UASInterface* uas);///< Two-stage construction: initialize this object
virtual void setUAS(UASInterface* uas);///< Allows swapping the underlying UAS
protected:
virtual void setParameterStatusMsg(const QString& msg) = 0;
virtual void layoutWidget() = 0;///< Layout the appearance of this widget
virtual void connectViewSignalsAndSlots() = 0;///< Connect view signals/slots as needed
virtual void disconnectViewSignalsAndSlots() = 0;///< Disconnect view signals/slots as needed
virtual void connectToParamManager(); ///>Connect to any required param manager signals
virtual void disconnectFromParamManager(); ///< Disconnect from any connected param manager signals
signals:
public slots:
virtual void handleOnboardParamUpdate(int component,const QString& parameterName, QVariant value) = 0;
virtual void handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending) = 0;
virtual void handleOnboardParameterListUpToDate() = 0;
virtual void handleParamStatusMsgUpdate(QString msg, int level) = 0;
/** @brief Clear the rendering of onboard parameters */
virtual void clearOnboardParamDisplay() = 0;
/** @brief Clear the rendering of pending parameters */
virtual void clearPendingParamDisplay() = 0;
/** @brief Request list of parameters from MAV */
virtual void requestOnboardParamsUpdate();
/** @brief Store parameters to a file */
virtual void saveParametersToFile();
/** @brief Load parameters from a file */
virtual void loadParametersFromFile();
protected:
QGCUASParamManager* paramMgr;
UASInterface* mav;
QString updatingParamNameLock; ///< Name of param currently being updated-- used for reducing echo on param change
};
#endif // QGCBASEPARAMWIDGET_H
......@@ -8,7 +8,7 @@
QGCConfigView::QGCConfigView(QWidget *parent) :
QWidget(parent),
ui(new Ui::QGCConfigView),
currUAS(NULL)
mav(NULL)
{
ui->setupUi(this);
......@@ -26,7 +26,7 @@ QGCConfigView::~QGCConfigView()
void QGCConfigView::activeUASChanged(UASInterface* uas)
{
if (currUAS == uas)
if (mav == uas)
return;
//remove all child widgets since they could contain stale data
......@@ -41,11 +41,13 @@ void QGCConfigView::activeUASChanged(UASInterface* uas)
}
}
if (NULL != uas) {
mav = uas;
if (NULL != mav) {
ui->gridLayout->removeWidget(ui->waitingLabel);
ui->waitingLabel->setVisible(false);
switch (uas->getAutopilotType()) {
int autopilotType = mav->getAutopilotType();
switch (autopilotType) {
case MAV_AUTOPILOT_PX4:
ui->gridLayout->addWidget(new QGCPX4VehicleConfig());
break;
......
......@@ -21,7 +21,7 @@ public slots:
private:
Ui::QGCConfigView *ui;
UASInterface* currUAS;
UASInterface* mav;
};
......
......@@ -13,9 +13,12 @@
#include <QMessageBox>
#include "QGCPX4VehicleConfig.h"
#include "UASManager.h"
#include "QGC.h"
#include "QGCPendingParamWidget.h"
#include "QGCToolWidget.h"
#include "UASManager.h"
#include "UASParameterCommsMgr.h"
#include "ui_QGCPX4VehicleConfig.h"
......@@ -76,11 +79,22 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
ui->rcCalibrationButton->setCheckable(true);
connect(ui->rcCalibrationButton, SIGNAL(clicked(bool)), this, SLOT(toggleCalibrationRC(bool)));
connect(ui->setButton, SIGNAL(clicked()), this, SLOT(writeParameters()));
connect(ui->writeButton, SIGNAL(clicked()),
this, SLOT(writeParameters()));
connect(ui->rcModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRCModeIndex(int)));
//connect(ui->setTrimButton, SIGNAL(clicked()), this, SLOT(setTrimPositions()));
//TODO connect buttons here to save/clear actions?
UASInterface* tmpMav = UASManager::instance()->getActiveUAS();
if (tmpMav) {
ui->pendingCommitsWidget->initWithUAS(tmpMav);
ui->pendingCommitsWidget->update();
setActiveUAS(tmpMav);
}
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
this, SLOT(setActiveUAS(UASInterface*)));
//TODO the following methods are not yet implemented
......@@ -104,9 +118,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
// connect(ui->invertCheckBox_7, SIGNAL(clicked(bool)), this, SLOT(setAux2Inverted(bool)));
// connect(ui->invertCheckBox_8, SIGNAL(clicked(bool)), this, SLOT(setAux3Inverted(bool)));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
setActiveUAS(UASManager::instance()->getActiveUAS());
for (unsigned int i = 0; i < chanMax; i++) {
rcValue[i] = UINT16_MAX;
......@@ -299,7 +313,6 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary)
}
// Generate widgets for the Advanced tab.
left = true;
foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot))
{
if (file.toLower().endsWith(".qgw")) {
......@@ -793,23 +806,28 @@ void QGCPX4VehicleConfig::loadConfig()
xml.readNext();
}
mav->getParamManager()->setParamInfo(paramTooltips);
if (!paramTooltips.isEmpty()) {
paramMgr->setParamDescriptions(paramTooltips);
}
doneLoadingConfig = true;
mav->requestParameters(); //Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished.
//Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished.
paramMgr->requestParameterListIfEmpty();
}
void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
{
// Hide items if NULL and abort
if (!active) {
ui->setButton->setEnabled(false);
ui->refreshButton->setEnabled(false);
ui->readButton->show();
ui->refreshButton->show();
ui->readButton->setEnabled(false);
ui->writeButton->show();
ui->readButton->show();
ui->writeButton->setEnabled(false);
ui->writeButton->show();
ui->loadFileButton->setEnabled(false);
ui->loadFileButton->show();
ui->saveFileButton->setEnabled(false);
ui->saveFileButton->show();
return;
}
......@@ -821,34 +839,32 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
if (mav)
{
// Disconnect old system
disconnect(mav, SIGNAL(remoteControlChannelRawChanged(int,float)), this,
SLOT(remoteControlChannelRawChanged(int,float)));
//TODO use paramCommsMgr instead
disconnect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant)));
disconnect(ui->refreshButton,SIGNAL(clicked()),mav,SLOT(requestParameters()));
disconnect(ui->refreshButton,SIGNAL(clicked()),
paramMgr,SLOT(requestParameterList()));
// Delete all children from all fixed tabs.
foreach(QWidget* child, ui->generalLeftContents->findChildren<QWidget*>())
{
foreach(QWidget* child, ui->generalLeftContents->findChildren<QWidget*>()) {
child->deleteLater();
}
foreach(QWidget* child, ui->generalRightContents->findChildren<QWidget*>())
{
foreach(QWidget* child, ui->generalRightContents->findChildren<QWidget*>()) {
child->deleteLater();
}
foreach(QWidget* child, ui->advanceColumnContents->findChildren<QWidget*>())
{
foreach(QWidget* child, ui->advanceColumnContents->findChildren<QWidget*>()) {
child->deleteLater();
}
foreach(QWidget* child, ui->sensorContents->findChildren<QWidget*>())
{
foreach(QWidget* child, ui->sensorContents->findChildren<QWidget*>()) {
child->deleteLater();
}
// And then delete any custom tabs
foreach(QWidget* child, additionalTabs)
{
foreach(QWidget* child, additionalTabs) {
child->deleteLater();
}
additionalTabs.clear();
......@@ -864,35 +880,37 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
// Connect new system
mav = active;
paramMgr = mav->getParamManager();
ui->pendingCommitsWidget->setUAS(mav);
// Reset current state
resetCalibrationRC();
requestCalibrationRC();
//TODO eliminate the separate RC_TYPE call
mav->requestParameter(0, "RC_TYPE");
chanCount = 0;
//TODO get parameter changes via Param Mgr instead
// Connect new system
connect(active, SIGNAL(remoteControlChannelRawChanged(int,float)), this,
connect(mav, SIGNAL(remoteControlChannelRawChanged(int,float)), this,
SLOT(remoteControlChannelRawChanged(int,float)));
connect(active, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
connect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant)));
connect(ui->refreshButton, SIGNAL(clicked()), active, SLOT(requestParameters()));
connect(ui->refreshButton, SIGNAL(clicked()),
paramMgr,SLOT(requestParameterList()));
if (systemTypeToParamMap.contains(mav->getSystemTypeName()))
{
if (systemTypeToParamMap.contains(mav->getSystemTypeName())) {
paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()];
}
else
{
else {
//Indication that we have no meta data for this system type.
qDebug() << "No parameters defined for system type:" << mav->getSystemTypeName();
paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()];
}
if (!paramTooltips.isEmpty())
{
mav->getParamManager()->setParamInfo(paramTooltips);
if (!paramTooltips.isEmpty()) {
mav->getParamManager()->setParamDescriptions(paramTooltips);
}
qDebug() << "CALIBRATION!! System Type Name:" << mav->getSystemTypeName();
......@@ -904,14 +922,19 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
updateStatus(QString("Reading from system %1").arg(mav->getUASName()));
// Since a system is now connected, enable the VehicleConfig UI.
ui->setButton->setEnabled(true);
ui->refreshButton->setEnabled(true);
ui->refreshButton->show();
ui->readButton->setEnabled(true);
ui->readButton->show();
ui->writeButton->setEnabled(true);
ui->writeButton->show();
ui->loadFileButton->setEnabled(true);
ui->loadFileButton->show();
ui->saveFileButton->setEnabled(true);
if (mav->getAutopilotTypeName() == "ARDUPILOTMEGA")
{
ui->saveFileButton->show();
//TODO never true?
if (mav->getAutopilotTypeName() == "ARDUPILOTMEGA") {
ui->readButton->hide();
ui->writeButton->hide();
}
......@@ -941,6 +964,7 @@ void QGCPX4VehicleConfig::writeCalibrationRC()
// Do not write the RC type, as these values depend on this
// active onboard parameter
//TODO consolidate RC param sending in the UAS comms mgr
for (unsigned int i = 0; i < chanCount; ++i)
{
//qDebug() << "SENDING" << minTpl.arg(i+1) << rcMin[i];
......@@ -975,27 +999,7 @@ void QGCPX4VehicleConfig::writeCalibrationRC()
void QGCPX4VehicleConfig::requestCalibrationRC()
{
if (!mav) return;
QString minTpl("RC%1_MIN");
QString maxTpl("RC%1_MAX");
QString trimTpl("RC%1_TRIM");
QString revTpl("RC%1_REV");
// Do not request the RC type, as these values depend on this
// active onboard parameter
for (unsigned int i = 0; i < chanMax; ++i)
{
mav->requestParameter(0, minTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, trimTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, maxTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, revTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
}
paramMgr->requestRcCalibrationParamsUpdate();
}
void QGCPX4VehicleConfig::writeParameters()
......@@ -1249,14 +1253,13 @@ void QGCPX4VehicleConfig::handleRcParameterChange(QString parameterName, QVarian
void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
Q_UNUSED(uas);
Q_UNUSED(component);
if (!doneLoadingConfig) {
//We do not want to attempt to generate any UI elements until loading of the config file is complete.
//We should re-request params later if needed, that is not implemented yet.
return;
}
//TODO this may introduce a bug with param editor widgets not receiving param updates
if (parameterName.startsWith("RC")) {
handleRcParameterChange(parameterName,value);
return;
......
......@@ -10,6 +10,8 @@
#include "QGCToolWidget.h"
#include "UASInterface.h"
class UASParameterCommsMgr;
namespace Ui {
class QGCPX4VehicleConfig;
}
......@@ -159,6 +161,7 @@ protected slots:
protected:
bool doneLoadingConfig;
UASInterface* mav; ///< The current MAV
QGCUASParamManager* paramMgr; ///< params mgr for the mav
static const unsigned int chanMax = 8; ///< Maximum number of channels
unsigned int chanCount; ///< Actual channels
int rcType; ///< Type of the remote control
......@@ -184,6 +187,7 @@ protected:
QTimer updateTimer; ///< Controls update intervals
enum RC_MODE rc_mode; ///< Mode of the remote control, according to usual convention
QList<QGCToolWidget*> toolWidgets; ///< Configurable widgets
QMap<QString,QGCToolWidget*> toolWidgetsByName; ///<
bool calibrationEnabled; ///< calibration mode on / off
QMap<QString,QGCToolWidget*> paramToWidgetMap; ///< Holds the current active MAV's parameter widgets.
......
......@@ -138,7 +138,7 @@ Config</string>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="rcTab">
<layout class="QVBoxLayout" name="verticalLayout_17">
......@@ -817,8 +817,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>26</width>
<height>26</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
......@@ -906,8 +906,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>16</width>
<height>16</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
......@@ -943,8 +943,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>16</width>
<height>16</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
......@@ -1035,8 +1035,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>16</width>
<height>16</height>
<width>597</width>
<height>569</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
......@@ -1103,6 +1103,13 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadFileButton">
<property name="text">
<string>Load File</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveFileButton">
<property name="enabled">
......@@ -1163,58 +1170,20 @@ p, li { white-space: pre-wrap; }
<height>601</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1,1">
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QTreeView" name="pendingCommitsTreeView"/>
</item>
<item>
<widget class="QPushButton" name="setButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Set current parameters in non-permanent onboard memory.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Commit to UAS</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="setButton_2">
<property name="enabled">
<bool>false</bool>
<widget class="QGCPendingParamWidget" name="pendingCommitsWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Set current parameters in non-permanent onboard memory.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadFileButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Load parameters from a file on this computer in the view. To write them to the aircraft, use transmit after loading them.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Load from File</string>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
......@@ -1259,6 +1228,12 @@ p, li { white-space: pre-wrap; }
<header>ui/designer/QGCRadioChannelDisplay.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QGCPendingParamWidget</class>
<extends>QWidget</extends>
<header>ui/QGCPendingParamWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
This diff is collapsed.
......@@ -37,87 +37,66 @@ This file is part of the QGROUNDCONTROL project
#include <QLabel>
#include <QTimer>
#include "QGCUASParamManager.h"
#include "UASInterface.h"
#include "QGCBaseParamWidget.h"
//forward declarations
class QGridLayout;
class UASInterface;
/**
* @brief Widget to read/set onboard parameters
*/
class QGCParamWidget : public QGCUASParamManager
class QGCParamWidget : public QGCBaseParamWidget
{
Q_OBJECT
public:
QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
/** @brief Get the UAS of this widget */
UASInterface* getUAS();
bool isParamMinKnown(const QString& param) { return paramMin.contains(param); }
bool isParamMaxKnown(const QString& param) { return paramMax.contains(param); }
bool isParamDefaultKnown(const QString& param) { return paramDefault.contains(param); }
double getParamMin(const QString& param) { return paramMin.value(param, 0.0f); }
double getParamMax(const QString& param) { return paramMax.value(param, 0.0f); }
double getParamDefault(const QString& param) { return paramDefault.value(param, 0.0f); }
QString getParamInfo(const QString& param) { return paramToolTips.value(param, ""); }
void setParamInfo(const QMap<QString,QString>& param) { paramToolTips = param; }
QGCParamWidget(QWidget *parent = 0);
protected:
virtual void setParameterStatusMsg(const QString& msg);
virtual void layoutWidget();///< Layout the appearance of this widget
virtual void connectViewSignalsAndSlots();///< Connect view signals/slots as needed
virtual void disconnectViewSignalsAndSlots();///< Connect view signals/slots as needed
virtual QTreeWidgetItem* getParentWidgetItemForParam(int compId, const QString& paramName);
virtual QTreeWidgetItem* findChildWidgetItemForParam(QTreeWidgetItem* parentItem, const QString& paramName);
/** @brief Add a component item as a child of this widget
* @param compId Component id of the component
* @param compName Human friendly name of the component
*/
void addComponentItem(int compId, QString compName);
virtual void addActionButtonsToLayout(QGridLayout* layout);
signals:
/** @brief A parameter was changed in the widget, NOT onboard */
//void parameterChanged(int component, QString parametername, float value); // defined in QGCUASParamManager already
/** @brief Request a single parameter */
void requestParameter(int component, int parameter);
/** @brief Request a single parameter by name */
void requestParameter(int component, const QString& parameter);
public slots:
/** @brief Add a component to the list */
void addComponent(int uas, int component, QString componentName);
/** @brief Add a parameter to the list with retransmission / safety checks */
void addParameter(int uas, int component, int paramCount, int paramId, QString parameterName, QVariant value);
/** @brief Add a parameter to the list */
void addParameter(int uas, int component, QString parameterName, QVariant value);
/** @brief Request list of parameters from MAV */
void requestParameterList();
/** @brief Request one single parameter */
void requestParameterUpdate(int component, const QString& parameter);
/** @brief Set one parameter, changes value in RAM of MAV */
void setParameter(int component, QString parameterName, QVariant value);
/** @brief Set all parameters, changes the value in RAM of MAV */
void setParameters();
/** @brief Write the current parameters to permanent storage (EEPROM/HDD) */
void writeParameters();
/** @brief Read the parameters from permanent storage to RAM */
void readParameters();
/** @brief Clear the parameter list */
void clear();
virtual void handleOnboardParamUpdate(int component,const QString& parameterName, QVariant value);
virtual void handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending);
virtual void handleOnboardParameterListUpToDate();
virtual void handleParamStatusMsgUpdate(QString msg, int level);
virtual void clearOnboardParamDisplay();
virtual void clearPendingParamDisplay();
/** @brief Ensure that view of parameter matches data in the model */
QTreeWidgetItem* updateParameterDisplay(int component, QString parameterName, QVariant value);
/** @brief Update when user changes parameters */
void parameterItemChanged(QTreeWidgetItem* prev, int column);
/** @brief Store parameters to a file */
void saveParameters();
/** @brief Load parameters from a file */
void loadParameters();
/** @brief Check for missing parameters */
void retransmissionGuardTick();
protected:
QMap<int, QTreeWidgetItem*>* componentItems; ///< The tree of component items, stored by component ID
QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups to organize component items
QLabel* statusLabel; ///< User-facing parameter status label
QTreeWidget* tree; ///< The parameter tree
QLabel* statusLabel; ///< Parameter transmission label
QMap<int, QTreeWidgetItem*>* components; ///< The list of components
QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups
// Tooltip data structures
QMap<QString, QString> paramToolTips; ///< Tooltip values
// Min / Default / Max data structures
QMap<QString, double> paramMin; ///< Minimum param values
QMap<QString, double> paramDefault; ///< Default param values
QMap<QString, double> paramMax; ///< Minimum param values
/** @brief Activate / deactivate parameter retransmission */
void setRetransmissionGuardEnabled(bool enabled);
/** @brief Load settings */
void loadSettings();
/** @brief Load meta information from CSV */
void loadParameterInfoCSV(const QString& autopilot, const QString& airframe);
};
#endif // QGCPARAMWIDGET_H
#include "QGCPendingParamWidget.h"
#include <QGridLayout>
#include <QPushButton>
#include "UASManager.h"
#include "UASParameterCommsMgr.h"
QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) :
QGCParamWidget((QWidget*)parent)
{
}
void QGCPendingParamWidget::connectToParamManager()
{
paramMgr = mav->getParamManager();
//TODO route via paramManager instead?
// Listen to updated param signals from the data model
connect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
// Listen to communications status messages so we can display them
connect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
}
void QGCPendingParamWidget::disconnectFromParamManager()
{
//TODO route via paramManager instead?
// Listen to updated param signals from the data model
disconnect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
// Listen to communications status messages so we can display them
disconnect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
paramMgr = NULL;
}
void QGCPendingParamWidget::disconnectViewSignalsAndSlots()
{
//we ignore edits from the tree view
}
void QGCPendingParamWidget::connectViewSignalsAndSlots()
{
//we ignore edits from the tree view
}
void QGCPendingParamWidget::handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending)
{
// qDebug() << "handlePendingParamUpdate:" << paramName << "with updatingParamNameLock:" << updatingParamNameLock;
if (updatingParamNameLock == paramName) {
//qDebug() << "ignoring bounce from " << paramName;
return;
}
else {
updatingParamNameLock = paramName;
}
QTreeWidgetItem* paramItem = updateParameterDisplay(compId,paramName,value);
if (isPending) {
QTreeWidgetItem* paramItem = updateParameterDisplay(compId,paramName,value);
paramItem->setFlags(paramItem->flags() & ~Qt::ItemIsEditable); //disallow editing
paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange)));
paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange)));
tree->expandAll();
}
else {
//we don't display non-pending items
paramItem->parent()->removeChild(paramItem);
}
updatingParamNameLock.clear();
}
void QGCPendingParamWidget::addActionButtonsToLayout(QGridLayout* layout)
{
QPushButton* setButton = new QPushButton(tr("Set"));
setButton->setToolTip(tr("Send pending parameters to volatile onboard memory"));
setButton->setWhatsThis(tr("Send pending parameters to volatile onboard memory"));
connect(setButton, SIGNAL(clicked()),
paramMgr, SLOT(sendPendingParameters()));
layout->addWidget(setButton, 2, 0);
QPushButton* clearButton = new QPushButton(tr("Clear"));
clearButton->setToolTip(tr("Clear pending parameters without sending"));
clearButton->setWhatsThis(tr("Clear pending parameters without sending"));
connect(clearButton, SIGNAL(clicked()),
paramMgr, SLOT(clearAllPendingParams()));
layout->addWidget(clearButton, 2, 1);
}
#ifndef QGCPENDINGPARAMWIDGET_H
#define QGCPENDINGPARAMWIDGET_H
#include "QGCParamWidget.h"
class QGridLayout;
class QGCPendingParamWidget : public QGCParamWidget
{
Q_OBJECT
public:
explicit QGCPendingParamWidget(QObject* parent);
protected:
virtual void connectToParamManager();
virtual void disconnectFromParamManager();
virtual void connectViewSignalsAndSlots();
virtual void disconnectViewSignalsAndSlots();
virtual void addActionButtonsToLayout(QGridLayout* layout);
signals:
public slots:
virtual void handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending);
};
#endif // QGCPENDINGPARAMWIDGET_H
......@@ -4,18 +4,18 @@ QGCTabbedInfoView::QGCTabbedInfoView(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
messageView = new QGCMessageView(this);
actionsWidget = new UASActionsWidget(this);
//actionsWidget = new UASActionsWidget(this);
quickView = new UASQuickView(this);
rawView = new UASRawStatusView(this);
//rawView = new UASRawStatusView(this);
ui.tabWidget->addTab(quickView,"Quick");
ui.tabWidget->addTab(actionsWidget,"Actions");
ui.tabWidget->addTab(rawView,"Status");
//ui.tabWidget->addTab(actionsWidget,"Actions");
//ui.tabWidget->addTab(rawView,"Status");
ui.tabWidget->addTab(messageView,"Messages");
}
void QGCTabbedInfoView::addSource(MAVLinkDecoder *decoder)
{
m_decoder = decoder;
rawView->addSource(decoder);
//rawView->addSource(decoder);
quickView->addSource(decoder);
}
......
......@@ -13,9 +13,11 @@
#include <QMessageBox>
#include "QGCVehicleConfig.h"
#include "UASManager.h"
#include "QGC.h"
#include "QGCToolWidget.h"
#include "UASManager.h"
#include "UASParameterCommsMgr.h"
#include "ui_QGCVehicleConfig.h"
QGCVehicleConfig::QGCVehicleConfig(QWidget *parent) :
......@@ -786,9 +788,12 @@ void QGCVehicleConfig::loadConfig()
xml.readNext();
}
mav->getParamManager()->setParamInfo(paramTooltips);
if (!paramTooltips.isEmpty()) {
paramMgr->setParamDescriptions(paramTooltips);
}
doneLoadingConfig = true;
mav->requestParameters(); //Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished.
//Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished.
paramMgr->requestParameterListIfEmpty();
}
void QGCVehicleConfig::setActiveUAS(UASInterface* active)
......@@ -859,6 +864,7 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active)
// Connect new system
mav = active;
paramMgr = mav->getParamManager();
// Reset current state
resetCalibrationRC();
......@@ -888,7 +894,7 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active)
if (!paramTooltips.isEmpty())
{
mav->getParamManager()->setParamInfo(paramTooltips);
mav->getParamManager()->setParamDescriptions(paramTooltips);
}
qDebug() << "CALIBRATION!! System Type Name:" << mav->getSystemTypeName();
......@@ -929,6 +935,8 @@ void QGCVehicleConfig::writeCalibrationRC()
{
if (!mav) return;
setTrimPositions();
QString minTpl("RC%1_MIN");
QString maxTpl("RC%1_MAX");
QString trimTpl("RC%1_TRIM");
......@@ -937,6 +945,7 @@ void QGCVehicleConfig::writeCalibrationRC()
// Do not write the RC type, as these values depend on this
// active onboard parameter
//TODO consolidate RC param sending in the UAS comms mgr
for (unsigned int i = 0; i < chanCount; ++i)
{
//qDebug() << "SENDING" << minTpl.arg(i+1) << rcMin[i];
......@@ -971,33 +980,14 @@ void QGCVehicleConfig::writeCalibrationRC()
void QGCVehicleConfig::requestCalibrationRC()
{
if (!mav) return;
QString minTpl("RC%1_MIN");
QString maxTpl("RC%1_MAX");
QString trimTpl("RC%1_TRIM");
QString revTpl("RC%1_REV");
// Do not request the RC type, as these values depend on this
// active onboard parameter
for (unsigned int i = 0; i < chanMax; ++i)
{
mav->requestParameter(0, minTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, trimTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, maxTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
mav->requestParameter(0, revTpl.arg(i+1));
QGC::SLEEP::usleep(5000);
}
paramMgr->requestRcCalibrationParamsUpdate();
}
void QGCVehicleConfig::writeParameters()
{
updateStatus(tr("Writing all onboard parameters."));
writeCalibrationRC();
mav->writeParametersToStorage();
}
......
......@@ -158,6 +158,7 @@ protected slots:
protected:
bool doneLoadingConfig;
UASInterface* mav; ///< The current MAV
QGCUASParamManager* paramMgr; ///< params mgr for the mav
static const unsigned int chanMax = 8; ///< Maximum number of channels
unsigned int chanCount; ///< Actual channels
int rcType; ///< Type of the remote control
......
This diff is collapsed.
......@@ -7,6 +7,8 @@
#include "QGCToolWidgetItem.h"
class QGCUASParamManager;
namespace Ui
{
class QGCComboBox;
......@@ -23,14 +25,15 @@ public:
public slots:
void startEditMode();
void endEditMode();
/** @brief Send the parameter to the MAV */
void sendParameter();
/** @brief Queue parameter for sending to the MAV (add to pending list)*/
void setParamPending();
/** @brief Update the UI with the new parameter value */
void setParameterValue(int uas, int component, int paramCount, int paramIndex, QString parameterName, const QVariant value);
void setParameterValue(int uas, int componentId, int paramCount, int paramIndex, QString parameterName, const QVariant value);
void writeSettings(QSettings& settings);
void readSettings(const QString& pre,const QVariantMap& settings);
void readSettings(const QSettings& settings);
void refreshParamList();
/** @brief request that the parameter for this widget be refreshed */
void refreshParameter();
void setActiveUAS(UASInterface *uas);
void selectComponent(int componentIndex);
void selectParameter(int paramIndex);
......@@ -49,6 +52,7 @@ protected slots:
/** @brief Updates current parameter based on new combobox value */
void comboBoxIndexChanged(QString val);
protected:
QGCUASParamManager *paramMgr; ///< Access to parameter manager
bool visibleEnabled;
QString visibleParam;
int visibleVal;
......@@ -61,7 +65,7 @@ protected:
float parameterMin;
bool isDisabled;
float parameterMax;
int component; ///< ID of the MAV component to address
int componentId; ///< ID of the MAV component to address
//double scaledInt;
void changeEvent(QEvent *e);
......
This diff is collapsed.
......@@ -23,12 +23,12 @@ public:
public slots:
void startEditMode();
void endEditMode();
/** @brief Send the parameter to the MAV */
void sendParameter();
/** @brief Queue parameter for sending to the MAV (add to pending list)*/
void setParamPending();
/** @brief Set the slider value as parameter value */
void setSliderValue(int sliderValue);
/** @brief Update the UI with the new parameter value */
void setParameterValue(int uas, int component, int paramCount, int paramIndex, QString parameterName, const QVariant value);
void setParameterValue(int uas, int componentId, int paramCount, int paramIndex, QString parameterName, const QVariant value);
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
void readSettings(const QString& pre,const QVariantMap& settings);
......@@ -62,7 +62,7 @@ protected:
double parameterScalingFactor; ///< Factor to scale the parameter between slider and true value
float parameterMin;
float parameterMax;
int component; ///< ID of the MAV component to address
int componentId; ///< ID of the MAV component to address
double scaledInt;
void changeEvent(QEvent *e);
......
......@@ -25,7 +25,7 @@ public slots:
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
void readSettings(const QString& pre,const QVariantMap& settings);
void textMessageReceived(int uasid, int component, int severity, QString message);
void textMessageReceived(int uasid, int componentId, int severity, QString message);
private:
int enabledNum;
Ui::QGCTextLabel *ui;
......
......@@ -14,7 +14,7 @@ public:
QGCToolWidgetItem(const QString& name, QWidget *parent = 0);
~QGCToolWidgetItem();
int component() {
int componentId() {
return _component;
}
......
......@@ -47,13 +47,3 @@ QGCWelcomeMainWindow::~QGCWelcomeMainWindow()
delete ui;
delete viewModeSelection;
}
enum MainWindow::CUSTOM_MODE QGCWelcomeMainWindow::getCustomMode()
{
// QGCViewModeSelection* s = new QGCViewModeSelection(this);
// setCentralWidget(s);
// show();
// enum MainWindow::CUSTOM_MODE mode = MainWindow::CUSTOM_MODE_WIFI;// = s->waitForInput();
// delete s;
// return mode;
}
......@@ -17,7 +17,6 @@ public:
explicit QGCWelcomeMainWindow(QWidget *parent = 0);
~QGCWelcomeMainWindow();
enum MainWindow::CUSTOM_MODE getCustomMode();
bool getStoreSettings()
{
return storeSettings;
......
This diff is collapsed.
......@@ -46,6 +46,8 @@ public slots:
void guidedActionTriggered();
/** @brief Action triggered when guided action is selected from the context menu, allows for altitude selection */
bool guidedAltActionTriggered();
/** @brief Action triggered when set home action is selected from the context menu. */
bool setHomeActionTriggered();
/** @brief Add system to map view */
void addUAS(UASInterface* uas);
/** @brief Update the global position of a system */
......@@ -136,6 +138,8 @@ protected:
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent* event);
//void contextMenuEvent(QContextMenuEvent *);
UASWaypointManager* currWPManager; ///< The current waypoint manager
bool offlineMode;
QMap<Waypoint* , mapcontrol::WayPointItem*> waypointsToIcons;
......@@ -160,6 +164,7 @@ protected:
bool mapInitialized; ///< Map initialized?
float homeAltitude; ///< Home altitude
QPoint mousePressPos; ///< Mouse position when the button is released.
QPoint contextMousePressPos; ///< Mouse position when context menu activated.
int defaultGuidedAlt; ///< Default altitude for guided mode
UASInterface *uas; ///< Currently selected UAS.
......
This diff is collapsed.
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