Commit 6a55b6cd authored by LM's avatar LM

Introduced persistence in RGBDview, needs debugging, fixed a bug in param...

Introduced persistence in RGBDview, needs debugging, fixed a bug in param reading in the simulator, pushed message sender a bit forward, not working yet
parent eea6afda
......@@ -836,7 +836,7 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
streampointer+=bufferlength;
//qDebug() << "Sending PARAM" << key;
}
else if (read.param_index < onboardParams.size())
else if (read.param_index >= 0 && read.param_index < onboardParams.keys().size())
{
key = onboardParams.keys().at(read.param_index);
float paramValue = onboardParams.value(key);
......
......@@ -1066,7 +1066,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
{
unknownPackets.append(message.msgid);
QString errString = tr("UNABLE TO DECODE MESSAGE NUMBER %1").arg(message.msgid);
GAudioOutput::instance()->say(errString+tr(", please check console for details."));
//GAudioOutput::instance()->say(errString+tr(", please check console for details."));
emit textMessageReceived(uasId, message.compid, 255, errString);
std::cout << "Unable to decode message from system " << std::dec << static_cast<int>(message.sysid) << " with message id:" << static_cast<int>(message.msgid) << std::endl;
//qDebug() << std::cerr << "Unable to decode message from system " << std::dec << static_cast<int>(message.acid) << " with message id:" << static_cast<int>(message.msgid) << std::endl;
......
#include <QMenu>
#include <QContextMenuEvent>
#include <QSettings>
#include "QGCRGBDView.h"
#include "UASManager.h"
......@@ -24,6 +25,32 @@ QGCRGBDView::QGCRGBDView(int width, int height, QWidget *parent) :
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
clearData();
loadSettings();
}
QGCRGBDView::~QGCRGBDView()
{
storeSettings();
}
void QGCRGBDView::storeSettings()
{
QSettings settings;
settings.beginGroup("QGC_RGBDWIDGET");
settings.setValue("STREAM_RGB_ON", rgbEnabled);
settings.setValue("STREAM_DEPTH_ON", depthEnabled);
settings.endGroup();
settings.sync();
}
void QGCRGBDView::loadSettings()
{
QSettings settings;
settings.beginGroup("QGC_RGBDWIDGET");
rgbEnabled = settings.value("STREAM_RGB_ON", rgbEnabled).toBool();
// Only enable depth if RGB is not on
if (!rgbEnabled) depthEnabled = settings.value("STREAM_DEPTH_ON", depthEnabled).toBool();
settings.endGroup();
}
void QGCRGBDView::setActiveUAS(UASInterface* uas)
......
......@@ -8,6 +8,7 @@ class QGCRGBDView : public HUD
Q_OBJECT
public:
explicit QGCRGBDView(int width=640, int height=480, QWidget *parent = 0);
~QGCRGBDView();
signals:
......@@ -26,6 +27,10 @@ protected:
QAction* enableDepthAction;
void contextMenuEvent (QContextMenuEvent* event);
/** @brief Store current configuration of widget */
void storeSettings();
/** @brief Load configuration of widget */
void loadSettings();
};
#endif // QGCRGBDVIEW_H
......@@ -18,7 +18,9 @@ QGCMAVLinkMessageSender::QGCMAVLinkMessageSender(MAVLinkProtocol* mavlink, QWidg
ui->treeWidget->setHeaderLabels(header);
createTreeView();
connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
refreshTimer.start(1000); // Refresh at 1 Hz interval
//refreshTimer.start(1000); // Refresh at 1 Hz interval
connect(ui->sendButton, SIGNAL(pressed()), this, SLOT(sendMessage()));
}
void QGCMAVLinkMessageSender::refresh()
......@@ -35,8 +37,17 @@ void QGCMAVLinkMessageSender::refresh()
// ui->treeWidget->topLevelItem(0)->children();
}
bool QGCMAVLinkMessageSender::sendMessage()
{
sendMessage(ui->messageIdSpinBox->value());
}
bool QGCMAVLinkMessageSender::sendMessage(unsigned int msgid)
{
if (msgid == 0 || msgid > 255 || messageInfo[msgid].name == "" || messageInfo[msgid].name == "EMPTY")
{
return false;
}
bool result = true;
if (treeWidgetItems.contains(msgid))
......@@ -91,6 +102,44 @@ bool QGCMAVLinkMessageSender::sendMessage(unsigned int msgid)
*u = field->data(1, Qt::DisplayRole).toChar().toAscii();
}
break;
case MAVLINK_TYPE_INT8_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
int8_t* nums = reinterpret_cast<int8_t*>((m+messageInfo[msgid].fields[fieldid].wire_offset));
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toInt();
}
}
}
else
{
// Single value
int8_t* u = reinterpret_cast<int8_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toChar().toAscii();
}
break;
case MAVLINK_TYPE_UINT16_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
uint16_t* nums = reinterpret_cast<uint16_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toUInt();
}
}
}
else
{
// Single value
uint16_t* u = reinterpret_cast<uint16_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toUInt();
}
break;
// case MAVLINK_TYPE_INT8_T:
// if (messageInfo[msgid].fields[fieldid].array_length > 0)
// {
......@@ -292,6 +341,9 @@ bool QGCMAVLinkMessageSender::sendMessage(unsigned int msgid)
// break;
}
}
// Send message
protocol->sendMessage(msg);
}
else
{
......
......@@ -20,6 +20,10 @@ class QGCMAVLinkMessageSender : public QWidget
public:
explicit QGCMAVLinkMessageSender(MAVLinkProtocol* mavlink, QWidget *parent = 0);
~QGCMAVLinkMessageSender();
public slots:
/** @brief Send message currently selected in ui, taking values from tree view */
bool sendMessage();
protected:
mavlink_message_info_t messageInfo[256]; ///< Meta information about all messages
......
......@@ -26,6 +26,16 @@
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QSpinBox" name="messageIdSpinBox"/>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send Message</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
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