diff --git a/CMakeLists.txt b/CMakeLists.txt index eb70d9bc1f5cee2c6288386f1d856da7157a542b..7f0927286803bab1cd4165c9a0399b002c8f8351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,8 @@ add_executable(groundstation src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.cpp src/shared/Modules/Splitter/Splitter.cpp src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp - src/shared/Modules/StateViewer/StateViewer.cpp + src/shared/Modules/MainStateViewer/MainStateViewer.cpp + src/shared/Modules/PayloadStateViewer/PayloadStateViewer.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 e90dd506652058b423dcd769af49a60310b81c54..75586e3acd370012e552723c727c851447da4786 100644 --- a/SkywardHub.pro +++ b/SkywardHub.pro @@ -27,7 +27,8 @@ SOURCES += \ src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.cpp \ src/shared/Modules/TimerController/TimerControllerModule.cpp \ src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp \ - src/shared/Modules/StateViewer/StateViewer.cpp \ + src/shared/Modules/MainStateViewer/MainStateViewer.cpp \ + src/shared/Modules/PayloadStateViewer/PayloadStateViewer.cpp \ src/shared/Modules/FileStream/FileStreamModule.cpp \ src/shared/Modules/Graph/Graph.cpp \ src/shared/Modules/Test/TestModule.cpp \ @@ -82,8 +83,10 @@ HEADERS += \ src/shared/Modules/TimerController/TimerControllerModule.h \ src/shared/Modules/ModuleInfo.h \ src/shared/Modules/OrientationVisualizer/OrientationVisualizer.h \ - src/shared/Modules/StateViewer/StatesList.h \ - src/shared/Modules/StateViewer/StateViewer.h \ + src/shared/Modules/MainStateViewer/MainStatesList.h \ + src/shared/Modules/MainStateViewer/MainStateViewer.h \ + src/shared/Modules/PayloadStateViewer/PayloadStatesList.h \ + src/shared/Modules/PayloadStateViewer/PayloadStateViewer.h \ src/shared/Modules/FileStream/FileStreamModule.h \ src/shared/Modules/Graph/Graph.h \ src/shared/Modules/Test/TestModule.h \ diff --git a/scripts/udp_gs_tester.py b/scripts/udp_gs_tester.py index 68c9afe0b1734ba2d13559e954523d270d8117f5..87fb0a141a1fea046c3267efeec1790271469104 100755 --- a/scripts/udp_gs_tester.py +++ b/scripts/udp_gs_tester.py @@ -47,7 +47,7 @@ def fake_data(i): return MAVLink_rocket_flight_tm_message( get_timestamp(), # timestamp 0, # ada_state - 0, # fmm_state + i % 15, # fmm_state 0, # dpl_state 0, # abk_state 0, # nas_state @@ -87,6 +87,7 @@ def fake_data(i): 0.0, # nas_bias_x 0.0, # nas_bias_y 0.0, # nas_bias_z + 0, # pin_quick_connector 0, # pin_launch 0, # pin_nosecone 0, # pin_expulsion @@ -96,6 +97,7 @@ def fake_data(i): 0.0, # cam_battery_voltage 0.0, # temperature 0, # logger_error + ) def build_ack(msg): diff --git a/src/shared/Modules/StateViewer/StateViewer.cpp b/src/shared/Modules/MainStateViewer/MainStateViewer.cpp similarity index 65% rename from src/shared/Modules/StateViewer/StateViewer.cpp rename to src/shared/Modules/MainStateViewer/MainStateViewer.cpp index c95519289357735af4a32abc8d2e8305f226cd1c..c9648a2315df862e411a7ea5876e4d5dc4497cd3 100644 --- a/src/shared/Modules/StateViewer/StateViewer.cpp +++ b/src/shared/Modules/MainStateViewer/MainStateViewer.cpp @@ -16,49 +16,50 @@ * */ -#include "StateViewer.h" +#include "MainStateViewer.h" #include <Components/FilterSelector/FilterSelector.h> #include <Core/MessageBroker/MessageBroker.h> -StateViewerModule::StateViewerModule(QWidget* parent) : DefaultModule(parent) +MainStateViewerModule::MainStateViewerModule(QWidget* parent) + : DefaultModule(parent) { setupUi(); defaultContextMenuSetup(); } -StateViewerModule::~StateViewerModule() +MainStateViewerModule::~MainStateViewerModule() { getCore()->getMessageBroker()->unsubscribe(filter, this); } -QWidget* StateViewerModule::toWidget() { return this; } +QWidget* MainStateViewerModule::toWidget() { return this; } -XmlObject StateViewerModule::toXmlObject() +XmlObject MainStateViewerModule::toXmlObject() { - XmlObject obj(getName(ModuleId::STATEVIEWER)); + XmlObject obj(getName(ModuleId::MAINSTATEVIEWER)); obj.addAttribute("filter", filter.toString()); return obj; } -void StateViewerModule::fromXmlObject(const XmlObject& xmlObject) +void MainStateViewerModule::fromXmlObject(const XmlObject& xmlObject) { - if (xmlObject.getObjectName() == getName(ModuleId::STATEVIEWER)) + if (xmlObject.getObjectName() == getName(ModuleId::MAINSTATEVIEWER)) { auto filter = Filter::fromString(xmlObject.getAttribute("filter")); setFilter(filter); } } -void StateViewerModule::setupUi() +void MainStateViewerModule::setupUi() { outerLayout = new QHBoxLayout; outerLayout->setContentsMargins(0, 0, 0, 0); outerLayout->setSpacing(0); - for (auto labelText : StatesList::statesLabels) + for (auto labelText : MainStatesList::statesLabels) { QLabel* label = new QLabel; label->setText(labelText); @@ -70,22 +71,22 @@ void StateViewerModule::setupUi() setLayout(outerLayout); } -void StateViewerModule::addCustomActionsToMenu() +void MainStateViewerModule::addCustomActionsToMenu() { QAction* action = new QAction("Choose topic and field"); connect(action, &QAction::triggered, this, - &StateViewerModule::onConfigureClicked); + &MainStateViewerModule::onConfigureClicked); addActionToMenu(action); } -void StateViewerModule::onConfigureClicked() +void MainStateViewerModule::onConfigureClicked() { FilterSelector::selectFilter( filter, [this](const Filter& newFilter) { setFilter(newFilter); }); } -void StateViewerModule::setFilter(const Filter& newFilter) +void MainStateViewerModule::setFilter(const Filter& newFilter) { getCore()->getMessageBroker()->unsubscribe(filter, this); getCore()->getMessageBroker()->subscribe( @@ -95,19 +96,23 @@ void StateViewerModule::setFilter(const Filter& newFilter) filter = newFilter; } -void StateViewerModule::onMsgReceived(const Message& msg) +void MainStateViewerModule::onMsgReceived(const Message& msg) { Field field = msg.getField("fmm_state"); - StatesList::State state = - static_cast<StatesList::State>(field.getUnsignedInteger()); + MainStatesList::State state = + static_cast<MainStatesList::State>(field.getUnsignedInteger()); - if (state == StatesList::State::INVALID) + // Skip invalid and macro states + if (state == MainStatesList::State::INVALID || + state == MainStatesList::State::ON_GROUND || + state == MainStatesList::State::IGNITION || + state == MainStatesList::State::FLYING) return; if (state != currentState) { - currentState = static_cast<StatesList::State>(state); + currentState = static_cast<MainStatesList::State>(state); QString baseStyle = "border-bottom-width:1px;border-left-width:1px;border-top-width:" @@ -117,10 +122,10 @@ void StateViewerModule::onMsgReceived(const Message& msg) QString completedStyle = "background-color:green;" + baseStyle; QString errorStyle = "background-color:red;" + baseStyle; - int index = StatesList::statesIndexes[currentState]; + int index = MainStatesList::statesIndexes[currentState]; auto label = outerLayout->itemAt(index)->widget(); - if (currentState == StatesList::State::INIT_ERROR) + if (currentState == MainStatesList::State::INIT_ERROR) label->setStyleSheet(errorStyle); else label->setStyleSheet(currentStateStyle); @@ -130,13 +135,13 @@ void StateViewerModule::onMsgReceived(const Message& msg) outerLayout->itemAt(i)->widget()->setStyleSheet(completedStyle); // Reset every state after the current - for (int i = index + 1; i < StatesList::statesLabels.count(); i++) + for (int i = index + 1; i < MainStatesList::statesLabels.count(); i++) outerLayout->itemAt(i)->widget()->setStyleSheet(baseStyle); - auto tmp = outerLayout->itemAt(StatesList::statesLabels.count() - 1) + auto tmp = outerLayout->itemAt(MainStatesList::statesLabels.count() - 1) ->widget() ->styleSheet(); - outerLayout->itemAt(StatesList::statesLabels.count() - 1) + outerLayout->itemAt(MainStatesList::statesLabels.count() - 1) ->widget() ->setStyleSheet(tmp + "border-right-width:1px;"); } diff --git a/src/shared/Modules/StateViewer/StateViewer.h b/src/shared/Modules/MainStateViewer/MainStateViewer.h similarity index 85% rename from src/shared/Modules/StateViewer/StateViewer.h rename to src/shared/Modules/MainStateViewer/MainStateViewer.h index a9ed415aea86d39048d0c14d4bf3f6dc68c6b5e1..20d85b68e0458ca0b59fc3ab1cefab3435fb7410 100644 --- a/src/shared/Modules/StateViewer/StateViewer.h +++ b/src/shared/Modules/MainStateViewer/MainStateViewer.h @@ -25,15 +25,15 @@ #include <QLabel> #include <QWidget> -#include "StatesList.h" +#include "MainStatesList.h" -class StateViewerModule : public DefaultModule +class MainStateViewerModule : public DefaultModule { Q_OBJECT public: - explicit StateViewerModule(QWidget* parent = nullptr); - ~StateViewerModule(); + explicit MainStateViewerModule(QWidget* parent = nullptr); + ~MainStateViewerModule(); QWidget* toWidget() override; @@ -50,5 +50,5 @@ private: QHBoxLayout* outerLayout; Filter filter; - StatesList::State currentState; + MainStatesList::State currentState; }; diff --git a/src/shared/Modules/MainStateViewer/MainStatesList.h b/src/shared/Modules/MainStateViewer/MainStatesList.h new file mode 100644 index 0000000000000000000000000000000000000000..d5ec9a4efff2d36a3308556bef7b58ff64a8dee7 --- /dev/null +++ b/src/shared/Modules/MainStateViewer/MainStatesList.h @@ -0,0 +1,84 @@ +/* + * 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 <QList> +#include <QMap> +#include <QString> + +namespace MainStatesList +{ + +// Rockets states +enum class State : int +{ + ON_GROUND = 0, + INIT, + INIT_ERROR, + INIT_DONE, + CALIBRATE_SENSORS, + CALIBRATE_ALGORITHMS, + DISARMED, + TEST_MODE, + ARMED, + IGNITION, + FLYING, + POWERED_ASCENT, + UNPOWERED_ASCENT, + DROGUE_DESCENT, + TERMINAL_DESCENT, + LANDED, + INVALID, +}; + +// Groundstation labels +static const QList<QString> statesLabels{ + "INIT", + "CALIBRATE\nSENSORS", + "CALIBRATE\nALGORITHMS", + "DISARMED", + "TEST\nMODE", + "ARMED", + "POWERED\nASCENT", + "UNPOWERED\nASCENT", + "DROGUE\nDESCENT", + "TERMINAL\nDESCENT", + "LANDED", +}; + +// Map from rocket states to groundstation labels +static const QMap<State, int> statesIndexes{{State::INVALID, -1}, + {State::ON_GROUND, -1}, + {State::IGNITION, -1}, + {State::FLYING, -1}, + {State::INIT, 0}, + {State::INIT_ERROR, 0}, + {State::INIT_DONE, 0}, + {State::CALIBRATE_SENSORS, 1}, + {State::CALIBRATE_ALGORITHMS, 2}, + {State::DISARMED, 3}, + {State::TEST_MODE, 4}, + {State::ARMED, 5}, + {State::POWERED_ASCENT, 6}, + {State::UNPOWERED_ASCENT, 7}, + {State::DROGUE_DESCENT, 8}, + {State::TERMINAL_DESCENT, 9}, + {State::LANDED, 10}}; + +} // namespace MainStatesList \ No newline at end of file diff --git a/src/shared/Modules/ModuleInfo.h b/src/shared/Modules/ModuleInfo.h index 57771cc8a9935ca8cc64fab3d37334c7ee1727ae..c28dad47fb0c41e500fbc41f172326d46c3577f1 100644 --- a/src/shared/Modules/ModuleInfo.h +++ b/src/shared/Modules/ModuleInfo.h @@ -36,7 +36,8 @@ enum ModuleId UDP_MAVLINK, FILESTREAM, ORIENTATION_VISUALIZER, - STATEVIEWER, + MAINSTATEVIEWER, + PAYLOADSTATEVIEWER, VALUESCONVERTERVIEWER, TIMER_CONTROLLER, MODULETEST, diff --git a/src/shared/Modules/ModulesList.cpp b/src/shared/Modules/ModulesList.cpp index 0d2cb47234a766d6bc6cd17881f879097c55a818..904428063fc4faa9bf8486393510bb3b86904ce0 100644 --- a/src/shared/Modules/ModulesList.cpp +++ b/src/shared/Modules/ModulesList.cpp @@ -26,12 +26,13 @@ #include <Modules/FileStream/FileStreamModule.h> #include <Modules/Graph/Graph.h> #include <Modules/IncomingMessagesViewer/IncomingMessagesViewerModule.h> +#include <Modules/MainStateViewer/MainStateViewer.h> #include <Modules/Mavlink/SerialMavlinkModule.h> #include <Modules/Mavlink/UdpMavlinkModule.h> #include <Modules/OrientationVisualizer/OrientationVisualizer.h> #include <Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.h> +#include <Modules/PayloadStateViewer/PayloadStateViewer.h> #include <Modules/Splitter/Splitter.h> -#include <Modules/StateViewer/StateViewer.h> #include <Modules/Tabs/TabsModule.h> #include <Modules/Test/TestModule.h> #include <Modules/TimerController/TimerControllerModule.h> @@ -110,10 +111,17 @@ void ModulesList::createModuleList() fileStream.setFactory([]() { return new FileStreamModule(); }); addModuleInfo(fileStream); - ModuleInfo stateViewer(ModuleId::STATEVIEWER, "StateViewer", - ModuleCategory::DATAVISUAL); - stateViewer.setFactory([]() { return new StateViewerModule(); }); - addModuleInfo(stateViewer); + ModuleInfo mainStateViewer(ModuleId::MAINSTATEVIEWER, "MainStateViewer", + ModuleCategory::DATAVISUAL); + mainStateViewer.setFactory([]() { return new MainStateViewerModule(); }); + addModuleInfo(mainStateViewer); + + ModuleInfo payloadStateViewer(ModuleId::PAYLOADSTATEVIEWER, + "PayloadStateViewer", + ModuleCategory::DATAVISUAL); + payloadStateViewer.setFactory([]() + { return new PayloadStateViewerModule(); }); + addModuleInfo(payloadStateViewer); ModuleInfo valuesConverterViewer(ModuleId::VALUESCONVERTERVIEWER, "ValuesConverterViewer", diff --git a/src/shared/Modules/PayloadStateViewer/PayloadStateViewer.cpp b/src/shared/Modules/PayloadStateViewer/PayloadStateViewer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8202a4970ec12f6baff1df7988c6ff9902e07451 --- /dev/null +++ b/src/shared/Modules/PayloadStateViewer/PayloadStateViewer.cpp @@ -0,0 +1,147 @@ +/* + * 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 "PayloadStateViewer.h" + +#include <Components/FilterSelector/FilterSelector.h> +#include <Core/MessageBroker/MessageBroker.h> + +PayloadStateViewerModule::PayloadStateViewerModule(QWidget* parent) + : DefaultModule(parent) +{ + setupUi(); + defaultContextMenuSetup(); +} + +PayloadStateViewerModule::~PayloadStateViewerModule() +{ + getCore()->getMessageBroker()->unsubscribe(filter, this); +} + +QWidget* PayloadStateViewerModule::toWidget() { return this; } + +XmlObject PayloadStateViewerModule::toXmlObject() +{ + XmlObject obj(getName(ModuleId::PAYLOADSTATEVIEWER)); + + obj.addAttribute("filter", filter.toString()); + + return obj; +} + +void PayloadStateViewerModule::fromXmlObject(const XmlObject& xmlObject) +{ + if (xmlObject.getObjectName() == getName(ModuleId::PAYLOADSTATEVIEWER)) + { + auto filter = Filter::fromString(xmlObject.getAttribute("filter")); + setFilter(filter); + } +} + +void PayloadStateViewerModule::setupUi() +{ + outerLayout = new QHBoxLayout; + outerLayout->setContentsMargins(0, 0, 0, 0); + outerLayout->setSpacing(0); + + for (auto labelText : PayloadStatesList::statesLabels) + { + QLabel* label = new QLabel; + label->setText(labelText); + label->setAlignment(Qt::AlignCenter); + label->setContentsMargins(4, 4, 4, 4); + outerLayout->addWidget(label); + } + + setLayout(outerLayout); +} + +void PayloadStateViewerModule::addCustomActionsToMenu() +{ + QAction* action = new QAction("Choose topic and field"); + connect(action, &QAction::triggered, this, + &PayloadStateViewerModule::onConfigureClicked); + + addActionToMenu(action); +} + +void PayloadStateViewerModule::onConfigureClicked() +{ + FilterSelector::selectFilter( + filter, [this](const Filter& newFilter) { setFilter(newFilter); }); +} + +void PayloadStateViewerModule::setFilter(const Filter& newFilter) +{ + getCore()->getMessageBroker()->unsubscribe(filter, this); + getCore()->getMessageBroker()->subscribe( + newFilter, this, + [this](const Message& message, const Filter& filter) + { onMsgReceived(message); }); + filter = newFilter; +} + +void PayloadStateViewerModule::onMsgReceived(const Message& msg) +{ + Field field = msg.getField("fmm_state"); + + PayloadStatesList::State state = + static_cast<PayloadStatesList::State>(field.getUnsignedInteger()); + + // Skip invalid and macro states + if (state == PayloadStatesList::State::INVALID) + return; + + if (state != currentState) + { + currentState = static_cast<PayloadStatesList::State>(state); + + QString baseStyle = + "border-bottom-width:1px;border-left-width:1px;border-top-width:" + "1px;border-radius:0;"; + QString currentStateStyle = + "background-color:yellow; color:black;" + baseStyle; + QString completedStyle = "background-color:green;" + baseStyle; + QString errorStyle = "background-color:red;" + baseStyle; + + int index = PayloadStatesList::statesIndexes[currentState]; + auto label = outerLayout->itemAt(index)->widget(); + + if (currentState == PayloadStatesList::State::INIT_ERROR) + label->setStyleSheet(errorStyle); + else + label->setStyleSheet(currentStateStyle); + + // Set as completed every state before the current + for (int i = index - 1; i >= 0; i--) + outerLayout->itemAt(i)->widget()->setStyleSheet(completedStyle); + + // Reset every state after the current + for (int i = index + 1; i < PayloadStatesList::statesLabels.count(); + i++) + outerLayout->itemAt(i)->widget()->setStyleSheet(baseStyle); + + auto tmp = + outerLayout->itemAt(PayloadStatesList::statesLabels.count() - 1) + ->widget() + ->styleSheet(); + outerLayout->itemAt(PayloadStatesList::statesLabels.count() - 1) + ->widget() + ->setStyleSheet(tmp + "border-right-width:1px;"); + } +} diff --git a/src/shared/Modules/PayloadStateViewer/PayloadStateViewer.h b/src/shared/Modules/PayloadStateViewer/PayloadStateViewer.h new file mode 100644 index 0000000000000000000000000000000000000000..790387f95e0982a562c28c5960e47f1aa0bbf345 --- /dev/null +++ b/src/shared/Modules/PayloadStateViewer/PayloadStateViewer.h @@ -0,0 +1,54 @@ +/* + * 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/Filter.h> +#include <Core/Message/Message.h> +#include <Modules/DefaultModule/DefaultModule.h> + +#include <QLabel> +#include <QWidget> + +#include "PayloadStatesList.h" + +class PayloadStateViewerModule : public DefaultModule +{ + Q_OBJECT + +public: + explicit PayloadStateViewerModule(QWidget* parent = nullptr); + ~PayloadStateViewerModule(); + + QWidget* toWidget() override; + + XmlObject toXmlObject() override; + void fromXmlObject(const XmlObject& xmlObject) override; + +private: + void setupUi(); + void addCustomActionsToMenu() override; + void onConfigureClicked(); + void setFilter(const Filter& filter); + void onMsgReceived(const Message& msg); + + QHBoxLayout* outerLayout; + + Filter filter; + PayloadStatesList::State currentState; +}; diff --git a/src/shared/Modules/PayloadStateViewer/PayloadStatesList.h b/src/shared/Modules/PayloadStateViewer/PayloadStatesList.h new file mode 100644 index 0000000000000000000000000000000000000000..a822eefd15e319ce89646f76e10d98de7c7a0fe3 --- /dev/null +++ b/src/shared/Modules/PayloadStateViewer/PayloadStatesList.h @@ -0,0 +1,69 @@ +/* + * 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 <QList> +#include <QMap> +#include <QString> + +namespace PayloadStatesList +{ + +// Rockets states +enum class State : int +{ + INVALID = 0, + INIT, + INIT_ERROR, + INIT_DONE, + SENSORS_CALIBRATION, + ALGOS_CALIBRATION, + DISARMED, + TEST_MODE, + ARMED, + ASCENDING, + DROGUE_DESCENT, + WING_DESCENT, + LANDED, +}; + +// Groundstation labels +static const QList<QString> statesLabels{ + "INIT", "CALIBRATE\nSENSORS", "CALIBRATE\nALGORITHMS", + "DISARMED", "TEST\nMODE", "ARMED", + "ASCENDING", "DROGUE\nDESCENT", "WING\nDESCENT", + "LANDED", +}; + +// Map from rocket states to groundstation labels +static const QMap<State, int> statesIndexes{{State::INVALID, -1}, + {State::INIT, 0}, + {State::INIT_ERROR, 0}, + {State::INIT_DONE, 0}, + {State::SENSORS_CALIBRATION, 1}, + {State::ALGOS_CALIBRATION, 2}, + {State::DISARMED, 3}, + {State::TEST_MODE, 4}, + {State::ARMED, 5}, + {State::ASCENDING, 6}, + {State::DROGUE_DESCENT, 7}, + {State::WING_DESCENT, 8}, + {State::LANDED, 9}}; + +} // namespace PayloadStatesList \ No newline at end of file diff --git a/src/shared/Modules/StateViewer/StatesList.h b/src/shared/Modules/StateViewer/StatesList.h deleted file mode 100644 index 2ff26e40919487f91e4d8de08d14e328caeec535..0000000000000000000000000000000000000000 --- a/src/shared/Modules/StateViewer/StatesList.h +++ /dev/null @@ -1,66 +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 <QList> -#include <QMap> -#include <QString> - -namespace StatesList -{ - -// Rockets states -enum class State : int -{ - INVALID = 0, - INIT, - INIT_ERROR, - SENSORS_CALIBRATION, - ALGOS_CALIBRATION, - DISARMED, - TEST_MODE, - ARMED, - ASCENDING, - DROGUE_DESCENT, - TERMINAL_DESCENT, - LANDED, -}; - -// Groundstation labels -static const QList<QString> statesLabels{ - "INIT", "TEST\nMODE", "SENSORS\nCALIBRATION", "DISARMED", "ARMED", - "ASCENDING", "DROGUE\nDESCENT", "TERMINAL\nDESCENT", "LANDED", -}; - -// Map from rocket states to groundstation labels -static const QMap<State, int> statesIndexes{ - {State::INIT, 0}, - {State::INIT_ERROR, 0}, - {State::TEST_MODE, 1}, - {State::SENSORS_CALIBRATION, 2}, - {State::ALGOS_CALIBRATION, 2}, - {State::DISARMED, 3}, - {State::ARMED, 4}, - {State::ASCENDING, 5}, - {State::DROGUE_DESCENT, 6}, - {State::TERMINAL_DESCENT, 7}, - {State::LANDED, 8}, -}; - -} // namespace StatesList \ No newline at end of file