diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 3a90f6060675dc0f996031bbc2b76710c7f4363b..bfe98d2167ae3e6798085d44fc830c106b058350 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -175,23 +175,23 @@ bool UAS::getSelected() const return (UASManager::instance()->getActiveUAS() == this); } -void UAS::receiveMessageNamedValue(const mavlink_message_t& message) -{ - if (message.msgid == MAVLINK_MSG_ID_NAMED_VALUE_FLOAT) - { - mavlink_named_value_float_t val; - mavlink_msg_named_value_float_decode(&message, &val); - QByteArray bytes(val.name, MAVLINK_MSG_NAMED_VALUE_FLOAT_FIELD_NAME_LEN); - emit valueChanged(this->getUASID(), QString(bytes), tr("raw"), val.value, getUnixTime()); - } - else if (message.msgid == MAVLINK_MSG_ID_NAMED_VALUE_INT) - { - mavlink_named_value_int_t val; - mavlink_msg_named_value_int_decode(&message, &val); - QByteArray bytes(val.name, MAVLINK_MSG_NAMED_VALUE_INT_FIELD_NAME_LEN); - emit valueChanged(this->getUASID(), QString(bytes), tr("raw"), val.value, getUnixTime()); - } -} +//void UAS::receiveMessageNamedValue(const mavlink_message_t& message) +//{ +// if (message.msgid == MAVLINK_MSG_ID_NAMED_VALUE_FLOAT) +// { +// mavlink_named_value_float_t val; +// mavlink_msg_named_value_float_decode(&message, &val); +// QByteArray bytes(val.name, MAVLINK_MSG_NAMED_VALUE_FLOAT_FIELD_NAME_LEN); +// emit valueChanged(this->getUASID(), QString(bytes), tr("raw"), val.value, getUnixTime()); +// } +// else if (message.msgid == MAVLINK_MSG_ID_NAMED_VALUE_INT) +// { +// mavlink_named_value_int_t val; +// mavlink_msg_named_value_int_decode(&message, &val); +// QByteArray bytes(val.name, MAVLINK_MSG_NAMED_VALUE_INT_FIELD_NAME_LEN); +// emit valueChanged(this->getUASID(), QString(bytes), tr("raw"), val.value, getUnixTime()); +// } +//} void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) { @@ -356,11 +356,11 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) } break; - case MAVLINK_MSG_ID_NAMED_VALUE_FLOAT: - case MAVLINK_MSG_ID_NAMED_VALUE_INT: - // Receive named value message - receiveMessageNamedValue(message); - break; +// case MAVLINK_MSG_ID_NAMED_VALUE_FLOAT: +// case MAVLINK_MSG_ID_NAMED_VALUE_INT: +// // Receive named value message +// receiveMessageNamedValue(message); +// break; case MAVLINK_MSG_ID_SYS_STATUS: { if (multiComponentSourceDetected && message.compid != MAV_COMP_ID_IMU_2) @@ -938,10 +938,10 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) case MAVLINK_MSG_ID_SCALED_PRESSURE: case MAVLINK_MSG_ID_SERVO_OUTPUT_RAW: case MAVLINK_MSG_ID_OPTICAL_FLOW: - break; case MAVLINK_MSG_ID_DEBUG_VECT: - break; case MAVLINK_MSG_ID_DEBUG: + case MAVLINK_MSG_ID_NAMED_VALUE_FLOAT: + case MAVLINK_MSG_ID_NAMED_VALUE_INT: break; default: { diff --git a/src/uas/UAS.h b/src/uas/UAS.h index 50291840300c8927623ee4b9facbd1b18136b7c6..1e89ed1d4082d6c3c76409a3282f706e7ab28af9 100644 --- a/src/uas/UAS.h +++ b/src/uas/UAS.h @@ -577,9 +577,9 @@ protected slots: /** @brief Read settings from disk */ void readSettings(); - // MESSAGE RECEPTION - /** @brief Receive a named value message */ - void receiveMessageNamedValue(const mavlink_message_t& message); +// // MESSAGE RECEPTION +// /** @brief Receive a named value message */ +// void receiveMessageNamedValue(const mavlink_message_t& message); private: // unsigned int mode; ///< The current mode of the MAV diff --git a/src/ui/MAVLinkDecoder.cc b/src/ui/MAVLinkDecoder.cc index aa077ae0d9fd4fdd2a37ffb35eb2741da5392948..712d06d16db886d118f27ded0b71ac3e85587255 100644 --- a/src/ui/MAVLinkDecoder.cc +++ b/src/ui/MAVLinkDecoder.cc @@ -27,8 +27,6 @@ MAVLinkDecoder::MAVLinkDecoder(MAVLinkProtocol* protocol, QObject *parent) : messageFilter.insert(MAVLINK_MSG_ID_MISSION_ITEM, false); messageFilter.insert(MAVLINK_MSG_ID_MISSION_COUNT, false); messageFilter.insert(MAVLINK_MSG_ID_MISSION_ACK, false); - messageFilter.insert(MAVLINK_MSG_ID_NAMED_VALUE_FLOAT, false); - messageFilter.insert(MAVLINK_MSG_ID_NAMED_VALUE_INT, false); textMessageFilter.insert(MAVLINK_MSG_ID_DEBUG, false); textMessageFilter.insert(MAVLINK_MSG_ID_DEBUG_VECT, false); @@ -177,6 +175,27 @@ void MAVLinkDecoder::emitFieldValue(mavlink_message_t* msg, int fieldid, quint64 name = name.arg(QString(debug.name), fieldName); time = debug.time_usec / 1000; } + else if (msgid == MAVLINK_MSG_ID_DEBUG) + { + mavlink_debug_t debug; + mavlink_msg_debug_decode(msg, &debug); + name = name.arg(QString("debug")).arg(debug.ind); + time = debug.time_boot_ms; + } + else if (msgid == MAVLINK_MSG_ID_NAMED_VALUE_FLOAT) + { + mavlink_named_value_float_t debug; + mavlink_msg_named_value_float_decode(msg, &debug); + name = name.arg(debug.name).arg(fieldName); + time = debug.time_boot_ms; + } + else if (msgid == MAVLINK_MSG_ID_NAMED_VALUE_INT) + { + mavlink_named_value_int_t debug; + mavlink_msg_named_value_int_decode(msg, &debug); + name = name.arg(debug.name).arg(fieldName); + time = debug.time_boot_ms; + } else { name = name.arg(messageInfo[msgid].name, fieldName); diff --git a/src/ui/linechart/LinechartPlot.cc b/src/ui/linechart/LinechartPlot.cc index 7697cce358d6385b5375daedf262810956e105dc..c8c6aee69b2d56761cd64c0c29bba6a4a2243c52 100644 --- a/src/ui/linechart/LinechartPlot.cc +++ b/src/ui/linechart/LinechartPlot.cc @@ -32,8 +32,10 @@ * @param interval The maximum interval for which data is stored (default: 30 minutes) in milliseconds **/ LinechartPlot::LinechartPlot(QWidget *parent, int plotid, quint64 interval): QwtPlot(parent), - minTime(QUINT64_MAX), - maxTime(QUINT64_MIN), + minTime(0), + lastTime(0), + maxTime(100), + plotPosition(0), maxInterval(MAX_STORAGE_INTERVAL), timeScaleStep(DEFAULT_SCALE_INTERVAL), // 10 seconds automaticScrollActive(false), @@ -84,8 +86,6 @@ LinechartPlot::LinechartPlot(QWidget *parent, int plotid, quint64 interval): Qwt colors.append(QColor(87,231,246)); colors.append(QColor(230,126,23)); - plotPosition = 0; - setAutoReplot(false); // Set grid @@ -257,12 +257,16 @@ void LinechartPlot::appendData(QString dataname, quint64 ms, double value) /* Check if dataset identifier already exists */ if(!data.contains(dataname)) { addCurve(dataname); + enforceGroundTime(m_groundTime); + qDebug() << "ADDING CURVE WITH" << dataname << ms << value; + qDebug() << "MINTIME:" << minTime << "MAXTIME:" << maxTime; + qDebug() << "LASTTIME:" << lastTime; } // Add new value TimeSeriesData* dataset = data.value(dataname); - quint64 time = QGC::groundTimeMilliseconds(); + quint64 time; // Append data if (!m_groundTime) @@ -270,6 +274,10 @@ void LinechartPlot::appendData(QString dataname, quint64 ms, double value) // Use timestamp from dataset time = ms; } + else + { + time = QGC::groundTimeMilliseconds(); + } dataset->append(time, value); lastUpdate.insert(dataname, time); @@ -302,7 +310,19 @@ void LinechartPlot::enforceGroundTime(bool enforce) { m_groundTime = enforce; - lastTime = QGC::groundTimeUsecs()/1000; + if (enforce) + { + lastTime = QGC::groundTimeMilliseconds(); + plotPosition = lastTime; + maxTime = lastTime; + } + else + { + lastTime = 0; + plotPosition = 0; + minTime = 0; + maxTime = 100; + } } /** diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index e721c67317159c23ea8d95a73799b90b619346c6..88b3fd6c88605c0a97f2647eaa6fde9d3207a493 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -184,6 +184,7 @@ void LinechartWidget::readSettings() if (activePlot) { timeButton->setChecked(settings.value("ENFORCE_GROUNDTIME", timeButton->isChecked()).toBool()); activePlot->enforceGroundTime(settings.value("ENFORCE_GROUNDTIME", timeButton->isChecked()).toBool()); + timeButton->setChecked(settings.value("ENFORCE_GROUNDTIME", timeButton->isChecked()).toBool()); } if (unitsCheckBox) unitsCheckBox->setChecked(settings.value("SHOW_UNITS", unitsCheckBox->isChecked()).toBool()); if (ui.shortNameCheckBox) ui.shortNameCheckBox->setChecked(settings.value("SHORT_NAMES", ui.shortNameCheckBox->isChecked()).toBool()); @@ -258,9 +259,6 @@ void LinechartWidget::createLayout() timeButton->setText(tr("Ground Time")); timeButton->setToolTip(tr("Overwrite timestamp of data from vehicle with ground receive time. Helps if the plots are not visible because of missing or invalid onboard time.")); timeButton->setWhatsThis(tr("Overwrite timestamp of data from vehicle with ground receive time. Helps if the plots are not visible because of missing or invalid onboard time.")); - bool gTimeDefault = true; - if (activePlot) activePlot->enforceGroundTime(gTimeDefault); - timeButton->setChecked(gTimeDefault); layout->addWidget(timeButton, 1, 4); layout->setColumnStretch(4, 0); connect(timeButton, SIGNAL(clicked(bool)), activePlot, SLOT(enforceGroundTime(bool)));