diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c873aeb4447281ce43b7c82c2a5864b3853ea54..cdced9497a899e63618444537e844238a525619a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,8 +84,6 @@ add_executable(groundstation src/shared/Modules/MainStateViewer/MainStateViewer.cpp src/shared/Modules/PayloadStateViewer/PayloadStateViewer.cpp src/shared/Modules/RefuelingVisualizer/RefuelingVisualizer.cpp - src/shared/Modules/RefuelingButton/RefuelingButton.cpp - src/shared/Modules/RefuelingButton/MessageFormElementRefButton.cpp src/shared/Modules/Tabs/TabsModule.cpp src/shared/Modules/Test/TestModule.cpp src/shared/Modules/TimerController/TimerControllerModule.cpp diff --git a/SkywardHub.pro b/SkywardHub.pro index 21d94b7df67b4edf1285a1f8653ce611f62d0483..86e4802f7a267a011edb983005b64aac824aac77 100644 --- a/SkywardHub.pro +++ b/SkywardHub.pro @@ -92,8 +92,6 @@ HEADERS += \ src/shared/Modules/PayloadStateViewer/PayloadStatesList.h \ src/shared/Modules/PayloadStateViewer/PayloadStateViewer.h \ src/shared/Modules/RefuelingVisualizer/RefuelingVisualizer.h \ - src/shared/Modules/RefuelingButton/RefuelingButton.h \ - src/shared/Modules/RefuelingButton/MessageFormElementRefButton.h \ src/shared/Modules/FileStream/FileStreamModule.h \ src/shared/Modules/Graph/Graph.h \ src/shared/Modules/Test/TestModule.h \ diff --git a/src/shared/Modules/ModuleInfo.h b/src/shared/Modules/ModuleInfo.h index be517f6e2c37a0c31ced7ca70d2a82aaad9b20f6..9788430b0c285ebe76ac828fffc0383da32cf503 100644 --- a/src/shared/Modules/ModuleInfo.h +++ b/src/shared/Modules/ModuleInfo.h @@ -43,7 +43,6 @@ enum ModuleId VALUESCONVERTERVIEWER, TIMER_CONTROLLER, MODULETEST, - REFUELING_BUTTON, TABS, FILTER_SELECTOR, VALVESVIEWER, diff --git a/src/shared/Modules/ModulesList.cpp b/src/shared/Modules/ModulesList.cpp index 103cf06f5d0e2356331141c75db1acd032c57ad0..52cbfe38abe459d5ba551df7e9ddb11e484a215d 100644 --- a/src/shared/Modules/ModulesList.cpp +++ b/src/shared/Modules/ModulesList.cpp @@ -33,7 +33,6 @@ #include <Modules/OrientationVisualizer/OrientationVisualizer.h> #include <Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.h> #include <Modules/PayloadStateViewer/PayloadStateViewer.h> -#include <Modules/RefuelingButton/RefuelingButton.h> #include <Modules/RefuelingVisualizer/RefuelingVisualizer.h> #include <Modules/Splitter/Splitter.h> #include <Modules/Tabs/TabsModule.h> @@ -168,12 +167,6 @@ void ModulesList::createModuleList() refuelingVisualizer.setFactory([]() { return new RefuelingVisualizer(); }); tabs.addModuleSourceFiles("Modules/RefuelingVisualizer/"); modulesInfo.append(refuelingVisualizer); - - ModuleInfo refuelingButton(ModuleId::REFUELING_BUTTON, "RefuelingButton", - ModuleCategory::UTILITY); - refuelingButton.setFactory([]() { return new RefuelingButton(); }); - tabs.addModuleSourceFiles("Modules/RefuelingButton/"); - addModuleInfo(refuelingButton); } // ____________________________________________________________________________________________ diff --git a/src/shared/Modules/RefuelingButton/MessageFormElementRefButton.cpp b/src/shared/Modules/RefuelingButton/MessageFormElementRefButton.cpp deleted file mode 100644 index cc3d7d5851ebdba2ddc1834b9d2b9efd6426568f..0000000000000000000000000000000000000000 --- a/src/shared/Modules/RefuelingButton/MessageFormElementRefButton.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "MessageFormElementRefButton.h" - -#include <Modules/SkywardHubStrings.h> - -MessageFormElementRefButton::MessageFormElementRefButton() {} - -MessageFormElementRefButton::~MessageFormElementRefButton() -{ - for (auto key : comboBoxMap.keys()) - { - delete comboBoxMap[key].first; - delete comboBoxMap[key].second; - } - - for (auto key : floatMap.keys()) - { - delete std::get<0>(floatMap[key]); - delete std::get<1>(floatMap[key]); - } - - for (auto key : integerMap.keys()) - { - delete std::get<0>(integerMap[key]); - delete std::get<1>(integerMap[key]); - } -} - -bool MessageFormElementRefButton::addComboBox(QString id, QString label, - const QMap<QString, int>& options) -{ - if (!comboBoxMap.contains(id) && !floatMap.contains(id) && - !integerMap.contains(id)) - { - auto* comboBox = new QComboBox; - comboBox->setSizePolicy( - QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); - - for (auto key : options.keys()) - comboBox->addItem(key, options[key]); - - comboBoxMap[id] = {new QLabel(label), comboBox}; - return true; - } - else - { - return false; - } -} - -bool MessageFormElementRefButton::addFloat(QString id, QString label, float min, - float max, int decimals) -{ - if (!comboBoxMap.contains(id) && !floatMap.contains(id) && - !integerMap.contains(id)) - { - auto* lineEdit = new QLineEdit; - lineEdit->setSizePolicy( - QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); - lineEdit->setValidator(new QDoubleValidator(min, max, decimals)); - floatMap[id] = {new QLabel(label), lineEdit, min, max, decimals}; - return true; - } - else - { - return false; - } -} - -bool MessageFormElementRefButton::addInteger(QString id, QString label, int min, - int max) -{ - if (!comboBoxMap.contains(id) && !floatMap.contains(id) && - !integerMap.contains(id)) - { - auto* lineEdit = new QLineEdit; - lineEdit->setSizePolicy( - QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); - lineEdit->setValidator(new QIntValidator(min, max)); - integerMap[id] = {new QLabel(label), lineEdit, min, max}; - return true; - } - else - { - return false; - } -} - -XmlObject MessageFormElementRefButton::toXmlObject(XmlObject& obj) -{ - for (auto key : comboBoxMap.keys()) - { - auto comboBox = comboBoxMap[key]; - XmlObject comboBoxXml("combo_box"); - comboBoxXml.addAttribute("id", key); - comboBoxXml.addAttribute("text", comboBox.second->currentText()); - obj.addChild(comboBoxXml); - } - - for (auto key : floatMap.keys()) - { - auto floatField = floatMap[key]; - XmlObject floatFieldXml("float_field"); - floatFieldXml.addAttribute("id", key); - floatFieldXml.addAttribute("text", std::get<1>(floatField)->text()); - floatFieldXml.addAttribute("min", std::get<2>(floatField)); - floatFieldXml.addAttribute("max", std::get<3>(floatField)); - floatFieldXml.addAttribute("decimals", std::get<4>(floatField)); - obj.addChild(floatFieldXml); - } - - for (auto key : floatMap.keys()) - { - auto integerField = floatMap[key]; - XmlObject integerFieldXml("integer_field"); - integerFieldXml.addAttribute("id", key); - integerFieldXml.addAttribute("text", std::get<1>(integerField)->text()); - integerFieldXml.addAttribute("min", std::get<2>(integerField)); - integerFieldXml.addAttribute("max", std::get<3>(integerField)); - obj.addChild(integerFieldXml); - } - - return obj; -} - -void MessageFormElementRefButton::fromXmlObject(const XmlObject& obj) -{ - for (int i = 0; i < obj.childCount(); i++) - { - auto child = obj.childAt(i); - auto key = child.getAttribute("id"); - - if (child.getObjectName() == "combo_box" && comboBoxMap.contains(key)) - { - auto comboBox = comboBoxMap[key]; - comboBox.second->setCurrentText(child.getAttribute("text")); - } - else if (child.getObjectName() == "float_field" && - floatMap.contains(key)) - { - auto floatField = floatMap[key]; - std::get<1>(floatField)->setText(child.getAttribute("text")); - child.getAttribute("min", std::get<2>(floatField)); - child.getAttribute("max", std::get<3>(floatField)); - child.getAttribute("decimals", std::get<4>(floatField)); - std::get<1>(floatField) - ->setValidator(new QDoubleValidator(std::get<2>(floatField), - std::get<3>(floatField), - std::get<4>(floatField))); - } - else if (child.getObjectName() == "integer_field" && - integerMap.contains(key)) - { - auto integerField = integerMap[key]; - std::get<1>(integerField)->setText(child.getAttribute("text")); - child.getAttribute("min", std::get<2>(integerField)); - child.getAttribute("max", std::get<3>(integerField)); - std::get<1>(integerField) - ->setValidator(new QIntValidator(std::get<2>(integerField), - std::get<3>(integerField))); - } - } -} - -void MessageFormElementRefButton::applyToGridLayout(QGridLayout* layout) -{ - for (auto key : comboBoxMap.keys()) - { - auto label = comboBoxMap[key].first; - auto comboBox = comboBoxMap[key].second; - - int rows = layout->rowCount(); - layout->addWidget(label, rows, 0, Qt::AlignRight); - layout->addWidget(comboBox, rows, 1); - - label->show(); - comboBox->show(); - } - - for (auto key : floatMap.keys()) - { - auto label = std::get<0>(floatMap[key]); - auto floatField = std::get<1>(floatMap[key]); - - int rows = layout->rowCount(); - layout->addWidget(label, rows, 0, Qt::AlignRight); - layout->addWidget(floatField, rows, 1); - - label->show(); - floatField->show(); - } - - for (auto key : integerMap.keys()) - { - auto label = std::get<0>(integerMap[key]); - auto integerField = std::get<1>(integerMap[key]); - - int rows = layout->rowCount(); - layout->addWidget(label, rows, 0, Qt::AlignRight); - layout->addWidget(integerField, rows, 1); - - label->show(); - integerField->show(); - } -} - -void MessageFormElementRefButton::removeFromGridLayout(QGridLayout* layout) -{ - for (auto key : comboBoxMap.keys()) - { - auto label = comboBoxMap[key].first; - auto comboBox = comboBoxMap[key].second; - - layout->removeWidget(label); - layout->removeWidget(comboBox); - - label->hide(); - comboBox->hide(); - } - - for (auto key : floatMap.keys()) - { - auto label = std::get<0>(floatMap[key]); - auto floatField = std::get<1>(floatMap[key]); - - layout->removeWidget(label); - layout->removeWidget(floatField); - - label->hide(); - floatField->hide(); - } - - for (auto key : integerMap.keys()) - { - auto label = std::get<0>(integerMap[key]); - auto integerField = std::get<1>(integerMap[key]); - - layout->removeWidget(label); - layout->removeWidget(integerField); - - label->hide(); - integerField->hide(); - } -} - -Message MessageFormElementRefButton::prepareMessage(const QString& messageId) -{ - Message message; - - for (auto key : comboBoxMap.keys()) - { - auto comboBox = comboBoxMap[key].second; - auto msg = Field{(uint64_t)comboBox->currentData().toInt()}; - if (comboBox->currentIndex() == 0) - message.setField("floating_level", msg); - if (comboBox->currentIndex() == 1) - message.setField("tank_temperature", msg); - if (comboBox->currentIndex() == 2) - message.setField("timestamp", msg); - } - - for (auto key : floatMap.keys()) - { - auto floatField = std::get<1>(floatMap[key]); - auto msg = Field{floatField->text().toDouble()}; - message.setField(key, msg); - } - - for (auto key : integerMap.keys()) - { - auto integerField = std::get<1>(integerMap[key]); - auto msg = Field{(uint64_t)integerField->text().toInt()}; - message.setField(key, msg); - } - - return message; -} \ No newline at end of file diff --git a/src/shared/Modules/RefuelingButton/MessageFormElementRefButton.h b/src/shared/Modules/RefuelingButton/MessageFormElementRefButton.h deleted file mode 100644 index 74d5de5af67f2bc2da3f19244cf84c397e1fa68f..0000000000000000000000000000000000000000 --- a/src/shared/Modules/RefuelingButton/MessageFormElementRefButton.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <Core/Message/Message.h> -#include <Core/XmlObject.h> - -#include <QComboBox> -#include <QGridLayout> -#include <QLabel> -#include <QLineEdit> -#include <QMap> -#include <QString> - -class MessageFormElementRefButton -{ -public: - MessageFormElementRefButton(); - - ~MessageFormElementRefButton(); - - /** - * @brief Adds a new combo box field to the form. - * - * @return false if there is already a field with the given id. - */ - bool addComboBox(QString id, QString label, - const QMap<QString, int>& options); - - /** - * @brief Adds a new float field to the form. - * - * @return false if there is already a field with the given id. - */ - bool addFloat(QString id, QString label, - float min = std::numeric_limits<float>::min(), - float max = std::numeric_limits<float>::max(), - int decimals = 2); - - /** - * @brief Adds a new integer field to the form. - * - * @return false if there is already a field with the given id. - */ - bool addInteger(QString id, QString label, - int min = std::numeric_limits<int>::min(), - int max = std::numeric_limits<int>::max()); - - XmlObject toXmlObject(XmlObject& obj); - - void fromXmlObject(const XmlObject& obj); - - void applyToGridLayout(QGridLayout* layout); - - void removeFromGridLayout(QGridLayout* layout); - - Message prepareMessage(const QString& messageId); - -private: - QMap<QString, QPair<QLabel*, QComboBox*>> comboBoxMap; - QMap<QString, std::tuple<QLabel*, QLineEdit*, float, float, int>> floatMap; - QMap<QString, std::tuple<QLabel*, QLineEdit*, int, int>> integerMap; -}; diff --git a/src/shared/Modules/RefuelingButton/MessagesListRefButton.h b/src/shared/Modules/RefuelingButton/MessagesListRefButton.h deleted file mode 100644 index d67b73f0f6cb266bd5720beafa24cae003be5639..0000000000000000000000000000000000000000 --- a/src/shared/Modules/RefuelingButton/MessagesListRefButton.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <Modules/Mavlink/MavlinkVersionHeader.h> -#include <Modules/RefuelingButton/MessageFormElementRefButton.h> - -#include <QMap> -#include <QString> - -namespace MessagesListRefButton -{ - -// Groundstation labels -static const QStringList messagesList{ - "MOTOR_TM", - "GSE_TM", -}; - -inline void fillMessagesMap( - QMap<QString, MessageFormElementRefButton *> &formElements) -{ - MessageFormElementRefButton *element; -} - -} // namespace MessagesListRefButton diff --git a/src/shared/Modules/RefuelingButton/RefuelingButton.cpp b/src/shared/Modules/RefuelingButton/RefuelingButton.cpp deleted file mode 100644 index 165e5285e2a1beeadf1d5bc49e3aee240a3047a0..0000000000000000000000000000000000000000 --- a/src/shared/Modules/RefuelingButton/RefuelingButton.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "RefuelingButton.h" - -#include <Core/Message/Message.h> -#include <Modules/Mavlink/MavlinkCommandAdapter.h> -#include <Modules/RefuelingButton/MessagesListRefButton.h> -#include <Modules/SkywardHubStrings.h> - -#include <QString> -#include <QVBoxLayout> - -RefuelingButton::RefuelingButton(QWidget *parent) : DefaultModule(parent) -{ - setupUi(); - defaultContextMenuSetup(); -} - -RefuelingButton::~RefuelingButton() -{ - delete messagesListComboBox; - for (auto key : formElements.keys()) - delete formElements[key]; -} - -QWidget *RefuelingButton::toWidget() { return this; } - -XmlObject RefuelingButton::toXmlObject() -{ - XmlObject obj = XmlObject(getName(ModuleId::REFUELING_BUTTON)); - - auto key = messagesListComboBox->currentText(); - if (formElements.contains(key)) - { - obj.addAttribute("message_id", key); - formElements[key]->toXmlObject(obj); - } - - return obj; -} - -void RefuelingButton::fromXmlObject(const XmlObject &obj) -{ - if (obj.getObjectName() == getName(ModuleId::REFUELING_BUTTON)) - { - auto key = obj.getAttribute("message_id"); - - if (formElements.contains(key)) - { - formElements[key]->fromXmlObject(obj); - messagesListComboBox->setCurrentText(key); - } - } -} - -Field RefuelingButton::decodeArrayElement(const mavlink_message_t &msg, - const mavlink_field_info_t &field, - int idx) -{ - switch (field.type) - { - case MAVLINK_TYPE_CHAR: - { - return Field(static_cast<uint64_t>( - _MAV_RETURN_char(&msg, field.wire_offset + idx * 1))); - } - case MAVLINK_TYPE_UINT8_T: - { - return Field(static_cast<uint64_t>( - _MAV_RETURN_uint8_t(&msg, field.wire_offset + idx * 1))); - } - case MAVLINK_TYPE_INT8_T: - { - return Field(static_cast<int64_t>( - _MAV_RETURN_int8_t(&msg, field.wire_offset + idx * 1))); - } - case MAVLINK_TYPE_UINT16_T: - { - return Field(static_cast<uint64_t>( - _MAV_RETURN_uint16_t(&msg, field.wire_offset + idx * 2))); - } - case MAVLINK_TYPE_INT16_T: - { - return Field(static_cast<int64_t>( - _MAV_RETURN_int16_t(&msg, field.wire_offset + idx * 2))); - } - case MAVLINK_TYPE_UINT32_T: - { - return Field(static_cast<uint64_t>( - _MAV_RETURN_uint32_t(&msg, field.wire_offset + idx * 4))); - } - case MAVLINK_TYPE_INT32_T: - { - return Field(static_cast<int64_t>( - _MAV_RETURN_int32_t(&msg, field.wire_offset + idx * 4))); - } - case MAVLINK_TYPE_UINT64_T: - { - return Field(static_cast<uint64_t>( - _MAV_RETURN_uint64_t(&msg, field.wire_offset + idx * 8))); - } - case MAVLINK_TYPE_INT64_T: - { - return Field(static_cast<int64_t>( - _MAV_RETURN_int64_t(&msg, field.wire_offset + idx * 8))); - } - case MAVLINK_TYPE_FLOAT: - { - return Field(static_cast<double>( - _MAV_RETURN_float(&msg, field.wire_offset + idx * 4))); - } - case MAVLINK_TYPE_DOUBLE: - { - return Field(static_cast<double>( - _MAV_RETURN_double(&msg, field.wire_offset + idx * 8))); - } - default: - { - // Unsupported: return EMPTY - return Field(); - } - } -} - -Field RefuelingButton::decodeField(const mavlink_message_t &msg, - const mavlink_field_info_t &field) -{ - if (field.array_length == 0) - { - return decodeArrayElement(msg, field, 0); - } - else - { - if (field.type == MAVLINK_TYPE_CHAR) - { - QString str; - - for (unsigned i = 0; i < field.array_length; i++) - { - str.append(_MAV_RETURN_char(&msg, field.wire_offset + i)); - - if (_MAV_RETURN_char(&msg, field.wire_offset + i) == '\0') - break; - } - - return Field(str); - } - else - { - return Field(); - } - } -} - -void RefuelingButton::setupUi() -{ - QVBoxLayout *outerLayout = new QVBoxLayout; - outerLayout->addStretch(); - - messagesListComboBox = new QComboBox; - messagesListComboBox->setSizePolicy( - QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - messagesListComboBox->addItems(MessagesListRefButton::messagesList); - outerLayout->addWidget(messagesListComboBox); - - QGridLayout *formGridLayout = new QGridLayout; - outerLayout->addLayout(formGridLayout); - - QPushButton *sendButton = new QPushButton("Send"); - outerLayout->addWidget(sendButton); - - setLayout(outerLayout); - - // NUOVO ---------------------------------------------------------- - currentMessage = "MOTOR_TM"; - messagesListComboBox->setCurrentText(currentMessage); - - // PRECEDENTE ----------------------------------------------------- - - connect(messagesListComboBox, &QComboBox::currentTextChanged, this, - [=](QString key) - { - if (formElements.contains(key)) - { - formElements[currentMessage]->removeFromGridLayout( - formGridLayout); - formElements[key]->applyToGridLayout(formGridLayout); - currentMessage = key; - } - }); - - connect(sendButton, &QPushButton::clicked, - [=]() - { - mavlink_message_t msg; - - if (messagesListComboBox->currentIndex() == 0) - { - mavlink_motor_tm_t motor; - motor.bottom_tank_pressure = 0; - motor.combustion_chamber_pressure = 0; - motor.floating_level = 0; - motor.tank_temperature = 0; - motor.timestamp = 0; - motor.top_tank_pressure = 0; - - mavlink_msg_motor_tm_encode(171, 96, &msg, &motor); - } - if (messagesListComboBox->currentIndex() == 1) - { - mavlink_gse_tm_t gse; - gse.timestamp = 0; - gse.loadcell_tank = 0; - gse.loadcell_vessel = 0; - gse.filling_pressure = 0; - gse.vessel_pressure = 0; - gse.arming_state = 0; - gse.filling_valve_state = 1; - gse.venting_valve_state = 0; - gse.release_valve_state = 0; - gse.ignition_state = 0; - gse.tars_state = 1; - - mavlink_msg_gse_tm_encode(171, 96, &msg, &gse); - } - - // Once the message is created we can fill the fields - // according to the struct defined before - static const mavlink_message_info_t infos[256] = - MAVLINK_MESSAGE_INFO; - mavlink_message_info_t info = infos[msg.msgid]; - - QMap<QString, Field> fields; - for (unsigned int i = 0; i < info.num_fields; i++) - { - fields[QString(info.fields[i].name)] = - decodeField(msg, info.fields[i]); - } - - Message output; - output.setTopic( - Topic(SkywardHubStrings::mavlink_received_msg_topic + "/" + - info.name)); - output.setFields(std::move(fields)); - - getCore()->getMessageBroker()->publish(output); - }); -} diff --git a/src/shared/Modules/RefuelingButton/RefuelingButton.h b/src/shared/Modules/RefuelingButton/RefuelingButton.h deleted file mode 100644 index 0db12d96bd0847a01fa8a9c23ae63a95aebd279e..0000000000000000000000000000000000000000 --- a/src/shared/Modules/RefuelingButton/RefuelingButton.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <Core/Message/Message.h> -#include <Modules/DefaultModule/DefaultModule.h> -#include <Modules/Mavlink/MavlinkModule.h> -#include <Modules/RefuelingButton/MessageFormElementRefButton.h> - -#include <tuple> - -class RefuelingButton : public DefaultModule -{ - Q_OBJECT - -public: - explicit RefuelingButton(QWidget* parent = nullptr); - ~RefuelingButton(); - - QWidget* toWidget() override; - - XmlObject toXmlObject() override; - void fromXmlObject(const XmlObject& xmlObject) override; - -private: - void setupUi(); - Field decodeField(const mavlink_message_t& msg, - const mavlink_field_info_t& field); - Field decodeArrayElement(const mavlink_message_t& msg, - const mavlink_field_info_t& field, int idx); - - QString currentMessage; - QComboBox* messagesListComboBox; - QMap<QString, MessageFormElementRefButton*> formElements; -};