Skip to content
Snippets Groups Projects
Commit 81640a1e authored by Davide Rosato's avatar Davide Rosato Committed by Davide Mor
Browse files

[RefuelingButton] Added messages waiting for Pigna

Couple of things need to be fixed in the message sent
parent 77d54c0a
Branches
No related tags found
No related merge requests found
......@@ -262,13 +262,18 @@ void MessageFormElementRefButton::removeFromGridLayout(QGridLayout* layout)
Message MessageFormElementRefButton::prepareMessage(const QString& messageId)
{
Message message(Topic{SkywardHubStrings::commandsTopic + "/" + messageId});
Message message;
for (auto key : comboBoxMap.keys())
{
auto comboBox = comboBoxMap[key].second;
auto msg = Field{(uint64_t)comboBox->currentData().toInt()};
message.setField(key, msg);
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())
......
......@@ -21,48 +21,73 @@
#include <Modules/Mavlink/MavlinkVersionHeader.h>
#include <Modules/RefuelingButton/MessageFormElementRefButton.h>
#include <QList>
#include <QMap>
#include <QString>
namespace MessagesListRefButton
{
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 QStringList messagesList{
"MOTOR_TM_FLOAT",
"MOTOR_TM_INTEGER",
"GSE_TM_FLOAT",
"GSE_TM_INTEGER",
};
// Groundstation labels
static const QList<QString> messagesList{
"INIT", "TEST_MODE", "SENSORS_CALIBRATION", "DISARMED", "ARMED",
"ASCENDING", "DROGUE_DESCENT", "TERMINAL_DESCENT", "LANDED",
static const QMap<QString, int> MOTORcommandFloat{
{"top_tank_pressure", MAV_CMD_ARM},
{"bottom_tank_pressure", MAV_CMD_DISARM},
{"estimated_mass", MAV_CMD_FORCE_LAUNCH},
};
static const QMap<QString, int> MOTORcommandInteger{
{"timestamp", MAV_CMD_ARM},
{"floating_level", MAV_CMD_CALIBRATE},
{"tank_temperature", MAV_CMD_FORCE_INIT},
};
static const QMap<QString, int> GSEcommandFloat{
{"loadcell_tank", MAV_CMD_DISARM},
{"loadcell_vessel", MAV_CMD_CALIBRATE},
{"filling_pressure", MAV_CMD_FORCE_INIT},
{"vessel_pressure ", MAV_CMD_STOP_LOGGING},
};
// 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},
static const QMap<QString, int> GSEcommandInteger{
{"timestamp", MAV_CMD_ARM},
{"arming_state", MAV_CMD_FORCE_LAUNCH},
{"filling_valve_state", MAV_CMD_FORCE_LANDING},
{"venting_valve_state", MAV_CMD_FORCE_APOGEE},
{"release_vlave_state", MAV_CMD_FORCE_EXPULSION},
{"ignition_state", MAV_CMD_FORCE_MAIN},
{"tars_state", MAV_CMD_START_LOGGING},
};
inline void fillMessagesMap(
QMap<QString, MessageFormElementRefButton *> &formElements)
{
MessageFormElementRefButton *element;
element = new MessageFormElementRefButton();
element->addComboBox("motor_id", "Command:", MOTORcommandFloat);
element->addFloat("value", "Value:", 0, 180, 2);
formElements["MOTOR_TM_FLOAT"] = element;
element = new MessageFormElementRefButton();
element->addComboBox("timestamp", "Command:", MOTORcommandInteger);
element->addInteger("value", "Value:", 0, 180);
formElements["MOTOR_TM_INTEGER"] = element;
element = new MessageFormElementRefButton();
element->addComboBox("gse_id", "Command:", GSEcommandFloat);
element->addFloat("value", "Value:", 0, 180, 2);
formElements["GSE_TM_FLOAT"] = element;
element = new MessageFormElementRefButton();
element->addComboBox("gse_id", "Command:", GSEcommandInteger);
element->addInteger("value", "Value:", 0, 180);
formElements["GSE_TM_INTEGER"] = element;
}
} // namespace MessagesListRefButton
......@@ -18,6 +18,7 @@
#include "RefuelingButton.h"
#include <Core/Message/Message.h>
#include <Modules/RefuelingButton/MessagesListRefButton.h>
#include <QVBoxLayout>
......@@ -84,10 +85,14 @@ void RefuelingButton::setupUi()
setLayout(outerLayout);
// Set default value
currentMessage = "PING_TC";
MessagesListRefButton::fillMessagesMap(formElements);
// NUOVO ----------------------------------------------------------
currentMessage = "MOTOR_TM_FLOAT";
messagesListComboBox->setCurrentText(currentMessage);
// PRECEDENTE -----------------------------------------------------
connect(messagesListComboBox, &QComboBox::currentTextChanged, this,
[=](QString key)
{
......@@ -104,9 +109,20 @@ void RefuelingButton::setupUi()
[=]()
{
auto key = messagesListComboBox->currentText();
if (formElements.contains(key))
{
uint64_t keyN = messagesListComboBox->currentIndex();
auto message = formElements[key]->prepareMessage(key);
if (messagesListComboBox->currentIndex() == 0 ||
messagesListComboBox->currentIndex() == 1)
message.setTopic(Topic{"Mav/MOTOR_TM"});
if (messagesListComboBox->currentIndex() == 2 ||
messagesListComboBox->currentIndex() == 3)
message.setTopic(Topic{"Mav/GSE_TM"});
getCore()->getMessageBroker()->publish(message);
}
});
......
......@@ -18,6 +18,7 @@
#pragma once
#include <Core/Message/Message.h>
#include <Modules/DefaultModule/DefaultModule.h>
#include <Modules/RefuelingButton/MessageFormElementRefButton.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment