Commit 39bb543e authored by tstellanova's avatar tstellanova

fix build

parent 74f1acf5
#include "QGCUASParamManager.h" #include "QGCUASParamManager.h"
#include "UASInterface.h"
#include <QApplication>>
#include <QDir>
#include "UASInterface.h"
#include "UASParameterCommsMgr.h" #include "UASParameterCommsMgr.h"
QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) : QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) :
...@@ -28,15 +31,15 @@ QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) : ...@@ -28,15 +31,15 @@ QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) :
void parameterUpdated(int compId, int paramId, QString paramName, QVariant value); void parameterUpdated(int compId, int paramId, QString paramName, QVariant value);
connect(paramDataModel, SIGNAL(parameterUpdated(int, int, QString , QVariant )), connect(paramDataModel, SIGNAL(parameterUpdated(int, int, QString , QVariant )),
this, SLOT(handleParameterUpdate(int,int,int,QString,QVariant)); this, SLOT(handleParameterUpdate(int,int,int,QString,QVariant)));
// connect(uas, SIGNAL(parameterChanged(int,int,int,int,QString,QVariant)), // connect(uas, SIGNAL(parameterChanged(int,int,int,int,QString,QVariant)),
// this, SLOT(receivedParameterUpdate(int,int,int,int,QString,QVariant))); // this, SLOT(receivedParameterUpdate(int,int,int,int,QString,QVariant)));
// Listen for param list reload finished // Listen for param list reload finished
connect(paramCommsMgr, SIGNAL(parameterListUpToDate(int)), connect(paramCommsMgr, SIGNAL(parameterListUpToDate()),
this, SLOT(handleParameterListUpToDate(int)))); this, SLOT(handleParameterListUpToDate()));
...@@ -206,6 +209,10 @@ void QGCUASParamManager::setParamDescriptions(const QMap<QString,QString>& param ...@@ -206,6 +209,10 @@ void QGCUASParamManager::setParamDescriptions(const QMap<QString,QString>& param
} }
void QGCUASParamManager::setParameter(int component, QString parameterName, QVariant value)
{
paramCommsMgr->setParameter(component,parameterName,value);
}
void QGCUASParamManager::loadParamMetaInfoCSV() void QGCUASParamManager::loadParamMetaInfoCSV()
......
...@@ -43,16 +43,17 @@ signals: ...@@ -43,16 +43,17 @@ signals:
public slots: public slots:
/** @brief Write one parameter to the MAV */ /** @brief Send one parameter to the MAV: changes value in transient memory of MAV */
virtual void setParameter(int component, QString parameterName, QVariant value) = 0; virtual void setParameter(int component, QString parameterName, QVariant value);
/** @brief Request list of parameters from MAV */ /** @brief Request list of parameters from MAV */
virtual void requestParameterList(); virtual void requestParameterList();
/** @brief Request a single parameter by name */ /** @brief Request a single parameter by name from the MAV */
virtual void requestParameterUpdate(int component, const QString& parameter); virtual void requestParameterUpdate(int component, const QString& parameter);
virtual void handleParameterUpdate(int component, int paramCount, int paramId, const QString& parameterName, QVariant value) = 0; virtual void handleParameterUpdate(int component, int paramCount, int paramId, const QString& parameterName, QVariant value) = 0;
virtual void handleParameterListUpToDate(int component) = 0; virtual void handleParameterListUpToDate() = 0;
protected: protected:
......
#include "UASParameterCommsMgr.h" #include "UASParameterCommsMgr.h"
#include <QSettings>
#include "QGCUASParamManager.h" #include "QGCUASParamManager.h"
#include "UASInterface.h" #include "UASInterface.h"
...@@ -38,14 +40,14 @@ void UASParameterCommsMgr::loadParamCommsSettings() ...@@ -38,14 +40,14 @@ void UASParameterCommsMgr::loadParamCommsSettings()
{ {
QSettings settings; QSettings settings;
settings.beginGroup("QGC_MAVLINK_PROTOCOL"); settings.beginGroup("QGC_MAVLINK_PROTOCOL");
bool valid; bool ok;
int val = settings.value("PARAMETER_RETRANSMISSION_TIMEOUT", retransmissionTimeout).toInt(&ok); int val = settings.value("PARAMETER_RETRANSMISSION_TIMEOUT", retransmissionTimeout).toInt(&ok);
if (valid) { if (ok) {
retransmissionTimeout = temp; retransmissionTimeout = val;
} }
val = settings.value("PARAMETER_REWRITE_TIMEOUT", rewriteTimeout).toInt(&ok); val = settings.value("PARAMETER_REWRITE_TIMEOUT", rewriteTimeout).toInt(&ok);
if (valid) { if (ok) {
rewriteTimeout = temp; rewriteTimeout = val;
} }
settings.endGroup(); settings.endGroup();
} }
...@@ -224,17 +226,23 @@ void UASParameterCommsMgr::setParameter(int component, QString parameterName, QV ...@@ -224,17 +226,23 @@ void UASParameterCommsMgr::setParameter(int component, QString parameterName, QV
double dblValue = value.toDouble(); double dblValue = value.toDouble();
if (paramDataModel->isValueLessThanParamMin(parameterName,dblValue)) { if (paramDataModel->isValueLessThanParamMin(parameterName,dblValue)) {
setParameterStatusMsg(tr("REJ. %1, %2 < min").arg(parameterName).arg(dblValue)); setParameterStatusMsg(tr("REJ. %1, %2 < min").arg(parameterName).arg(dblValue),
ParamCommsStatusLevel_Error
);
return; return;
} }
if (paramDataModel->isValueGreaterThanParamMax(parameterName,dblValue)) { if (paramDataModel->isValueGreaterThanParamMax(parameterName,dblValue)) {
setParameterStatusMsg(tr("REJ. %1, %2 > max").arg(parameterName).arg(dblValue)); setParameterStatusMsg(tr("REJ. %1, %2 > max").arg(parameterName).arg(dblValue),
ParamCommsStatusLevel_Error
);
return; return;
} }
QVariant onboardVal; QVariant onboardVal;
paramDataModel->getOnboardParameterValue(component,parameterName,onboardVal); paramDataModel->getOnboardParameterValue(component,parameterName,onboardVal);
if (onboardVal == value) { if (onboardVal == value) {
setParameterStatusMsg(tr("REJ. %1 already %2").arg(parameterName).arg(dblValue)); setParameterStatusMsg(tr("REJ. %1 already %2").arg(parameterName).arg(dblValue),
ParamCommsStatusLevel_Warning
);
return; return;
} }
...@@ -246,28 +254,24 @@ void UASParameterCommsMgr::setParameter(int component, QString parameterName, QV ...@@ -246,28 +254,24 @@ void UASParameterCommsMgr::setParameter(int component, QString parameterName, QV
{ {
QVariant fixedValue(QChar((unsigned char)value.toInt())); QVariant fixedValue(QChar((unsigned char)value.toInt()));
emit parameterChanged(component, parameterName, fixedValue); emit parameterChanged(component, parameterName, fixedValue);
//qDebug() << "PARAM WIDGET SENT:" << fixedValue;
} }
break; break;
case QVariant::Int: case QVariant::Int:
{ {
QVariant fixedValue(value.toInt()); QVariant fixedValue(value.toInt());
emit parameterChanged(component, parameterName, fixedValue); emit parameterChanged(component, parameterName, fixedValue);
//qDebug() << "PARAM WIDGET SENT:" << fixedValue;
} }
break; break;
case QVariant::UInt: case QVariant::UInt:
{ {
QVariant fixedValue(value.toUInt()); QVariant fixedValue(value.toUInt());
emit parameterChanged(component, parameterName, fixedValue); emit parameterChanged(component, parameterName, fixedValue);
//qDebug() << "PARAM WIDGET SENT:" << fixedValue;
} }
break; break;
case QMetaType::Float: case QMetaType::Float:
{ {
QVariant fixedValue(value.toFloat()); QVariant fixedValue(value.toFloat());
emit parameterChanged(component, parameterName, fixedValue); emit parameterChanged(component, parameterName, fixedValue);
//qDebug() << "PARAM WIDGET SENT:" << fixedValue;
} }
break; break;
default: default:
...@@ -309,6 +313,8 @@ void UASParameterCommsMgr::setParameterStatusMsg(const QString& msg, ParamCommsS ...@@ -309,6 +313,8 @@ void UASParameterCommsMgr::setParameterStatusMsg(const QString& msg, ParamCommsS
qDebug() << "parameterStatusMsg: " << msg; qDebug() << "parameterStatusMsg: " << msg;
parameterStatusMsg = msg; parameterStatusMsg = msg;
emit parameterStatusMsgUpdated(msg,level);
//TODO indicate OK status somehow (eg color) //TODO indicate OK status somehow (eg color)
// QPalette pal = statusLabel->palette(); // QPalette pal = statusLabel->palette();
// pal.setColor(backgroundRole(), QGC::colorGreen); // pal.setColor(backgroundRole(), QGC::colorGreen);
...@@ -360,7 +366,7 @@ void UASParameterCommsMgr::receivedParameterUpdate(int uas, int compId, int para ...@@ -360,7 +366,7 @@ void UASParameterCommsMgr::receivedParameterUpdate(int uas, int compId, int para
// Start retransmission guard // Start retransmission guard
// or reset timer // or reset timer
paramCommsMgr->setRetransmissionGuardEnabled(true); //TODO setRetransmissionGuardEnabled(true); //TODO
} }
// Mark this parameter as received in read list // Mark this parameter as received in read list
......
...@@ -16,16 +16,16 @@ class UASParameterCommsMgr : public QObject ...@@ -16,16 +16,16 @@ class UASParameterCommsMgr : public QObject
{ {
Q_OBJECT Q_OBJECT
typedef enum ParamCommsStatusLevel {
ParamCommsStatusLevel_OK = 0,
ParamCommsStatusLevel_Warning = 2,
ParamCommsStatusLevel_Error = 4,
ParamCommsStatusLevel_Count
} ParamCommsStatusLevel_t;
public: public:
explicit UASParameterCommsMgr(QObject *parent = 0, UASInterface* uas = NULL); explicit UASParameterCommsMgr(QObject *parent = 0, UASInterface* uas = NULL);
typedef enum ParamCommsStatusLevel {
ParamCommsStatusLevel_OK = 0,
ParamCommsStatusLevel_Warning = 2,
ParamCommsStatusLevel_Error = 4,
ParamCommsStatusLevel_Count
} ParamCommsStatusLevel_t;
protected: protected:
/** @brief Activate / deactivate parameter retransmission */ /** @brief Activate / deactivate parameter retransmission */
...@@ -41,7 +41,9 @@ signals: ...@@ -41,7 +41,9 @@ signals:
void parameterChanged(int component, int parameterIndex, QVariant value); void parameterChanged(int component, int parameterIndex, QVariant value);
void parameterValueConfirmed(int uas, int component,int paramCount, int paramId, QString parameter, QVariant value); void parameterValueConfirmed(int uas, int component,int paramCount, int paramId, QString parameter, QVariant value);
void parameterListUpToDate(int component); /** @brief We have received a complete list of all parameters onboard the MAV */
void parameterListUpToDate();
void parameterUpdateRequested(int component, const QString& parameter); void parameterUpdateRequested(int component, const QString& parameter);
void parameterUpdateRequestedById(int componentId, int paramId); void parameterUpdateRequestedById(int componentId, int paramId);
...@@ -57,6 +59,7 @@ public slots: ...@@ -57,6 +59,7 @@ public slots:
/** @brief Write one parameter to the MAV */ /** @brief Write one parameter to the MAV */
virtual void setParameter(int component, QString parameterName, QVariant value); virtual void setParameter(int component, QString parameterName, QVariant value);
/** @brief Request list of parameters from MAV */ /** @brief Request list of parameters from MAV */
virtual void requestParameterList(); virtual void requestParameterList();
/** @brief Check for missing parameters */ /** @brief Check for missing parameters */
...@@ -67,9 +70,9 @@ public slots: ...@@ -67,9 +70,9 @@ public slots:
virtual void receivedParameterUpdate(int uas, int compId, int paramCount, int paramId, QString paramName, QVariant value); virtual void receivedParameterUpdate(int uas, int compId, int paramCount, int paramId, QString paramName, QVariant value);
protected slots: //protected slots:
void receivedParameterChange(int uas, int component, QString parameterName, QVariant value); // void receivedParameterChange(int uas, int component, QString parameterName, QVariant value);
void receivedParameterListChange(int uas, int component, int parameterCount, int parameterId, QString parameterName, QVariant value); // void receivedParameterListChange(int uas, int component, int parameterCount, int parameterId, QString parameterName, QVariant value);
protected: protected:
......
...@@ -27,16 +27,17 @@ This file is part of the QGROUNDCONTROL project ...@@ -27,16 +27,17 @@ This file is part of the QGROUNDCONTROL project
*/ */
#include <cmath> #include <cmath>
#include <float.h> #include <float.h>
#include <QGridLayout> #include <QApplication>
#include <QPushButton> #include <QDebug>
#include <QFileDialog>
#include <QFile> #include <QFile>
#include <QFileDialog>
#include <QGridLayout>
#include <QList> #include <QList>
#include <QTime>
#include <QSettings>
#include <QMessageBox> #include <QMessageBox>
#include <QApplication> #include <QPushButton>
#include <QDebug> #include <QSettings>
#include <QTime>
#include "MainWindow.h" #include "MainWindow.h"
#include "QGC.h" #include "QGC.h"
...@@ -338,7 +339,7 @@ void QGCParamWidget::handleParameterUpdate(int componentId, int paramCount, int ...@@ -338,7 +339,7 @@ void QGCParamWidget::handleParameterUpdate(int componentId, int paramCount, int
} }
void QGCParamWidget::handleParameterListUpToDate(int component) void QGCParamWidget::handleParameterListUpToDate()
{ {
// Expand visual tree // Expand visual tree
tree->expandItem(tree->topLevelItem(0)); tree->expandItem(tree->topLevelItem(0));
...@@ -593,94 +594,95 @@ void QGCParamWidget::writeParameters() ...@@ -593,94 +594,95 @@ void QGCParamWidget::writeParameters()
* @param parameterName name of the parameter, as delivered by the system * @param parameterName name of the parameter, as delivered by the system
* @param value value of the parameter * @param value value of the parameter
*/ */
void QGCParamWidget::setParameter(int component, QString parameterName, QVariant value) //void QGCParamWidget::setParameter(int component, QString parameterName, QVariant value)
{ //{
if (parameterName.isEmpty()) {
return;
}
double dblValue = value.toDouble(); // if (parameterName.isEmpty()) {
// return;
// }
if (paramDataModel->isValueLessThanParamMin(parameterName,dblValue)) { // double dblValue = value.toDouble();
statusLabel->setText(tr("REJ. %1, %2 < min").arg(parameterName).arg(dblValue));
return;
}
if (paramDataModel->isValueGreaterThanParamMax(parameterName,dblValue)) {
statusLabel->setText(tr("REJ. %1, %2 > max").arg(parameterName).arg(dblValue));
return;
}
QVariant onboardVal;
paramDataModel->getOnboardParameterValue(component,parameterName,onboardVal);
if (onboardVal == value) {
statusLabel->setText(tr("REJ. %1 already %2").arg(parameterName).arg(dblValue));
return;
}
//int paramType = (int)onboardParameters.value(component)->value(parameterName).type(); // if (paramDataModel->isValueLessThanParamMin(parameterName,dblValue)) {
int paramType = (int)value.type(); // statusLabel->setText(tr("REJ. %1, %2 < min").arg(parameterName).arg(dblValue));
switch (paramType) // return;
{ // }
case QVariant::Char: // if (paramDataModel->isValueGreaterThanParamMax(parameterName,dblValue)) {
{ // statusLabel->setText(tr("REJ. %1, %2 > max").arg(parameterName).arg(dblValue));
QVariant fixedValue(QChar((unsigned char)value.toInt())); // return;
emit parameterChanged(component, parameterName, fixedValue); // }
//qDebug() << "PARAM WIDGET SENT:" << fixedValue; // QVariant onboardVal;
} // paramDataModel->getOnboardParameterValue(component,parameterName,onboardVal);
break; // if (onboardVal == value) {
case QVariant::Int: // statusLabel->setText(tr("REJ. %1 already %2").arg(parameterName).arg(dblValue));
{ // return;
QVariant fixedValue(value.toInt()); // }
emit parameterChanged(component, parameterName, fixedValue);
//qDebug() << "PARAM WIDGET SENT:" << fixedValue;
}
break;
case QVariant::UInt:
{
QVariant fixedValue(value.toUInt());
emit parameterChanged(component, parameterName, fixedValue);
//qDebug() << "PARAM WIDGET SENT:" << fixedValue;
}
break;
case QMetaType::Float:
{
QVariant fixedValue(value.toFloat());
emit parameterChanged(component, parameterName, fixedValue);
//qDebug() << "PARAM WIDGET SENT:" << fixedValue;
}
break;
default:
qCritical() << "ABORTED PARAM SEND, NO VALID QVARIANT TYPE";
return;
}
// Wait for parameter to be written back // //int paramType = (int)onboardParameters.value(component)->value(parameterName).type();
// mark it therefore as missing // int paramType = (int)value.type();
if (!transmissionMissingWriteAckPackets.contains(component)) // switch (paramType)
{ // {
transmissionMissingWriteAckPackets.insert(component, new QMap<QString, QVariant>()); // case QVariant::Char:
} // {
// QVariant fixedValue(QChar((unsigned char)value.toInt()));
// emit parameterChanged(component, parameterName, fixedValue);
// //qDebug() << "PARAM WIDGET SENT:" << fixedValue;
// }
// break;
// case QVariant::Int:
// {
// QVariant fixedValue(value.toInt());
// emit parameterChanged(component, parameterName, fixedValue);
// //qDebug() << "PARAM WIDGET SENT:" << fixedValue;
// }
// break;
// case QVariant::UInt:
// {
// QVariant fixedValue(value.toUInt());
// emit parameterChanged(component, parameterName, fixedValue);
// //qDebug() << "PARAM WIDGET SENT:" << fixedValue;
// }
// break;
// case QMetaType::Float:
// {
// QVariant fixedValue(value.toFloat());
// emit parameterChanged(component, parameterName, fixedValue);
// //qDebug() << "PARAM WIDGET SENT:" << fixedValue;
// }
// break;
// default:
// qCritical() << "ABORTED PARAM SEND, NO VALID QVARIANT TYPE";
// return;
// }
// Insert it in missing write ACK list // // Wait for parameter to be written back
transmissionMissingWriteAckPackets.value(component)->insert(parameterName, value); // // mark it therefore as missing
// if (!transmissionMissingWriteAckPackets.contains(component))
// {
// transmissionMissingWriteAckPackets.insert(component, new QMap<QString, QVariant>());
// }
// Set timeouts // // Insert it in missing write ACK list
if (transmissionActive) // transmissionMissingWriteAckPackets.value(component)->insert(parameterName, value);
{
transmissionTimeout += rewriteTimeout;
}
else
{
quint64 newTransmissionTimeout = QGC::groundTimeMilliseconds() + rewriteTimeout;
if (newTransmissionTimeout > transmissionTimeout)
{
transmissionTimeout = newTransmissionTimeout;
}
transmissionActive = true;
}
// Enable guard / reset timeouts // // Set timeouts
paramCommsMgr->setRetransmissionGuardEnabled(true); //TODO // if (transmissionActive)
} // {
// transmissionTimeout += rewriteTimeout;
// }
// else
// {
// quint64 newTransmissionTimeout = QGC::groundTimeMilliseconds() + rewriteTimeout;
// if (newTransmissionTimeout > transmissionTimeout)
// {
// transmissionTimeout = newTransmissionTimeout;
// }
// transmissionActive = true;
// }
// // Enable guard / reset timeouts
// paramCommsMgr->setRetransmissionGuardEnabled(true); //TODO
//}
void QGCParamWidget::readParameters() void QGCParamWidget::readParameters()
{ {
...@@ -696,3 +698,20 @@ void QGCParamWidget::clear() ...@@ -696,3 +698,20 @@ void QGCParamWidget::clear()
tree->clear(); tree->clear();
componentItems->clear(); componentItems->clear();
} }
void QGCParamWidget::handleParamStatusMsgUpdate(QString msg, int level)
{
QColor bgColor = QGC::colorGreen;
if ((int)UASParameterCommsMgr::ParamCommsStatusLevel_Warning == level) {
bgColor = QGC::colorOrange;
}
else if ((int)UASParameterCommsMgr::ParamCommsStatusLevel_Error == level) {
bgColor = QGC::colorRed;
}
QPalette pal = statusLabel->palette();
pal.setColor(backgroundRole(), bgColor);
statusLabel->setPalette(pal);
statusLabel->setText(msg);
}
...@@ -68,14 +68,16 @@ public slots: ...@@ -68,14 +68,16 @@ public slots:
// void receivedParameterUpdate(int uas, int component, int paramCount, int paramId, QString parameterName, QVariant value); // void receivedParameterUpdate(int uas, int component, int paramCount, int paramId, QString parameterName, QVariant value);
virtual void handleParameterUpdate(int component, int paramCount, int paramId, const QString& parameterName, QVariant value); virtual void handleParameterUpdate(int component, int paramCount, int paramId, const QString& parameterName, QVariant value);
virtual void handleParameterListUpToDate(int component); virtual void handleParameterListUpToDate();
virtual void handleParamStatusMsgUpdate(QString msg, int level);
/** @brief Ensure that view of parameter matches data in the model */ /** @brief Ensure that view of parameter matches data in the model */
void updateParameterDisplay(int component, QString parameterName, QVariant value); void updateParameterDisplay(int component, QString parameterName, QVariant value);
/** @brief Request list of parameters from MAV */ /** @brief Request list of parameters from MAV */
void requestAllParamsUpdate(); void requestAllParamsUpdate();
/** @brief Set one parameter, changes value in RAM of MAV */ /** @brief Set one parameter, changes value in RAM of MAV */
virtual void setParameter(int component, QString parameterName, QVariant value); // virtual void setParameter(int component, QString parameterName, QVariant value);
/** @brief Set all parameters, changes the value in RAM of MAV */ /** @brief Set all parameters, changes the value in RAM of MAV */
void setParameters(); void setParameters();
/** @brief Write the current parameters to permanent storage (EEPROM/HDD) */ /** @brief Write the current parameters to permanent storage (EEPROM/HDD) */
......
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