mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
OP-1245 Added debuglog settings wrapper and GUI.
This commit is contained in:
parent
0c61fd35c8
commit
e533215786
@ -34,11 +34,13 @@ Rectangle {
|
|||||||
Layout.preferredHeight: 1000;
|
Layout.preferredHeight: 1000;
|
||||||
model: logManager.logEntries
|
model: logManager.logEntries
|
||||||
|
|
||||||
|
rowDelegate: Rectangle {
|
||||||
|
height: 22
|
||||||
|
color: styleData.selected ? "#ccc" : (styleData.alternate ? "#fff" : "#eee")
|
||||||
|
}
|
||||||
|
|
||||||
itemDelegate: Text {
|
itemDelegate: Text {
|
||||||
anchors.fill: parent
|
verticalAlignment: Text.AlignVCenter
|
||||||
anchors.margins: 2
|
|
||||||
anchors.leftMargin: 5
|
|
||||||
font.pixelSize: 12
|
|
||||||
text: styleData.value
|
text: styleData.value
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,33 +48,24 @@ Rectangle {
|
|||||||
role: "Flight"; title: qsTr("Flight"); width: 50;
|
role: "Flight"; title: qsTr("Flight"); width: 50;
|
||||||
delegate:
|
delegate:
|
||||||
Text {
|
Text {
|
||||||
anchors.fill: parent
|
verticalAlignment: Text.AlignVCenter
|
||||||
anchors.margins: 2
|
|
||||||
anchors.leftMargin: 5
|
|
||||||
font.pixelSize: 12
|
|
||||||
text: styleData.value + 1
|
text: styleData.value + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
TableViewColumn {
|
TableViewColumn {
|
||||||
role: "FlightTime"; title: qsTr("Time"); width: 80;
|
role: "FlightTime"; title: qsTr("Time"); width: 100;
|
||||||
delegate:
|
delegate:
|
||||||
Text {
|
Text {
|
||||||
anchors.fill: parent
|
verticalAlignment: Text.AlignVCenter
|
||||||
anchors.margins: 2
|
|
||||||
anchors.leftMargin: 5
|
|
||||||
font.pixelSize: 12
|
|
||||||
text: Functions.millisToTime(styleData.value)
|
text: Functions.millisToTime(styleData.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TableViewColumn {
|
TableViewColumn {
|
||||||
role: "Type"; title: "Type"; width: 50;
|
role: "Type"; title: "Type"; width: 60;
|
||||||
delegate:
|
delegate:
|
||||||
Text {
|
Text {
|
||||||
anchors.fill: parent
|
verticalAlignment: Text.AlignVCenter
|
||||||
anchors.margins: 2
|
|
||||||
anchors.leftMargin: 5
|
|
||||||
font.pixelSize: 12
|
|
||||||
text: {
|
text: {
|
||||||
switch(styleData.value) {
|
switch(styleData.value) {
|
||||||
case 0 : text: qsTr("Empty"); break;
|
case 0 : text: qsTr("Empty"); break;
|
||||||
@ -84,7 +77,11 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
TableViewColumn { role: "LogString"; title: qsTr("Data"); width: 280}
|
TableViewColumn {
|
||||||
|
role: "LogString";
|
||||||
|
title: qsTr("Data");
|
||||||
|
width: 280
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@ -177,7 +174,7 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
Text {
|
Text {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: "<b>" + qsTr("Log entries") + "</b>"
|
text: "<b>" + qsTr("Log settings") + "</b>"
|
||||||
}
|
}
|
||||||
TableView {
|
TableView {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -185,29 +182,37 @@ Rectangle {
|
|||||||
Layout.preferredHeight: 1000;
|
Layout.preferredHeight: 1000;
|
||||||
model: logManager.uavoEntries
|
model: logManager.uavoEntries
|
||||||
|
|
||||||
|
rowDelegate: Rectangle {
|
||||||
|
height: 22
|
||||||
|
color: styleData.selected ? "#ccc" : (styleData.alternate ? "#fff" : "#eee")
|
||||||
|
}
|
||||||
|
|
||||||
TableViewColumn {
|
TableViewColumn {
|
||||||
role: "Name";
|
role: "name";
|
||||||
title: qsTr("UAVObject");
|
title: qsTr("UAVObject");
|
||||||
width: 150;
|
width: 200;
|
||||||
delegate:
|
delegate:
|
||||||
Text {
|
Text {
|
||||||
anchors.fill: parent
|
verticalAlignment: Text.AlignVCenter
|
||||||
anchors.margins: 2
|
|
||||||
anchors.leftMargin: 5
|
anchors.leftMargin: 5
|
||||||
font.pixelSize: 12
|
|
||||||
text: styleData.value
|
text: styleData.value
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
TableViewColumn {
|
TableViewColumn {
|
||||||
role: "Setting"; title: qsTr("Settings"); width: 150;
|
role: "setting";
|
||||||
|
title: qsTr("Settings");
|
||||||
|
width: 200;
|
||||||
delegate:
|
delegate:
|
||||||
ComboBox {
|
ComboBox {
|
||||||
|
anchors.leftMargin: 5
|
||||||
model: logManager.logSettings
|
model: logManager.logSettings
|
||||||
|
currentIndex: styleData.value
|
||||||
|
//onCurrentIndexChanged:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,10 @@
|
|||||||
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
|
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
|
||||||
QDialog(parent)
|
QDialog(parent)
|
||||||
{
|
{
|
||||||
qmlRegisterType<ExtendedDebugLogEntry>("org.openpilot", 1, 0, "DebugLogEntry");
|
qmlRegisterType<ExtendedDebugLogEntry>("org.openpilot", 1, 0, "DebugLogEntry");
|
||||||
|
qmlRegisterType<UAVOLogSettingsWrapper>("org.openpilot", 1, 0, "UAVOLogSettingsWrapper");
|
||||||
qmlRegisterUncreatableType<UAVObject>("org.openpilot", 1, 0, "UAVObject", "");
|
qmlRegisterUncreatableType<UAVObject>("org.openpilot", 1, 0, "UAVObject", "");
|
||||||
|
qRegisterMetaType<UAVOLogSettingsWrapper::UAVLogSetting>("UAVOLogSettingsWrapper::UAVLogSetting");
|
||||||
|
|
||||||
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
||||||
setWindowTitle(tr("Manage flight side logs"));
|
setWindowTitle(tr("Manage flight side logs"));
|
||||||
|
@ -58,7 +58,9 @@ FlightLogManager::FlightLogManager(QObject *parent) :
|
|||||||
|
|
||||||
updateFlightEntries(m_flightLogStatus->getFlight());
|
updateFlightEntries(m_flightLogStatus->getFlight());
|
||||||
|
|
||||||
updateUAVOS();
|
setupUAVOWrappers();
|
||||||
|
|
||||||
|
setupLogSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
FlightLogManager::~FlightLogManager()
|
FlightLogManager::~FlightLogManager()
|
||||||
@ -94,30 +96,30 @@ QQmlListProperty<ExtendedDebugLogEntry> FlightLogManager::logEntries()
|
|||||||
return QQmlListProperty<ExtendedDebugLogEntry>(this, &m_logEntries, &addLogEntries, &countLogEntries, &logEntryAt, &clearLogEntries);
|
return QQmlListProperty<ExtendedDebugLogEntry>(this, &m_logEntries, &addLogEntries, &countLogEntries, &logEntryAt, &clearLogEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addUAVOEntries(QQmlListProperty<UAVObject> *list, UAVObject *entry)
|
void addUAVOEntries(QQmlListProperty<UAVOLogSettingsWrapper> *list, UAVOLogSettingsWrapper *entry)
|
||||||
{
|
{
|
||||||
Q_UNUSED(list);
|
Q_UNUSED(list);
|
||||||
Q_UNUSED(entry);
|
Q_UNUSED(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
int countUAVOEntries(QQmlListProperty<UAVObject> *list)
|
int countUAVOEntries(QQmlListProperty<UAVOLogSettingsWrapper> *list)
|
||||||
{
|
{
|
||||||
return static_cast< QList<UAVObject *> *>(list->data)->size();
|
return static_cast< QList<UAVOLogSettingsWrapper *> *>(list->data)->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
UAVObject *uavoEntryAt(QQmlListProperty<UAVObject> *list, int index)
|
UAVOLogSettingsWrapper *uavoEntryAt(QQmlListProperty<UAVOLogSettingsWrapper> *list, int index)
|
||||||
{
|
{
|
||||||
return static_cast< QList<UAVObject *> *>(list->data)->at(index);
|
return static_cast< QList<UAVOLogSettingsWrapper *> *>(list->data)->at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearUAVOEntries(QQmlListProperty<UAVObject> *list)
|
void clearUAVOEntries(QQmlListProperty<UAVOLogSettingsWrapper> *list)
|
||||||
{
|
{
|
||||||
return static_cast< QList<UAVObject *> *>(list->data)->clear();
|
return static_cast< QList<UAVOLogSettingsWrapper *> *>(list->data)->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QQmlListProperty<UAVObject> FlightLogManager::uavoEntries()
|
QQmlListProperty<UAVOLogSettingsWrapper> FlightLogManager::uavoEntries()
|
||||||
{
|
{
|
||||||
return QQmlListProperty<UAVObject>(this, &m_uavoEntries, &addUAVOEntries, &countUAVOEntries, &uavoEntryAt, &clearUAVOEntries);
|
return QQmlListProperty<UAVOLogSettingsWrapper>(this, &m_uavoEntries, &addUAVOEntries, &countUAVOEntries, &uavoEntryAt, &clearUAVOEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList FlightLogManager::flightEntries()
|
QStringList FlightLogManager::flightEntries()
|
||||||
@ -302,18 +304,24 @@ void FlightLogManager::updateFlightEntries(quint16 currentFlight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlightLogManager::updateUAVOS()
|
void FlightLogManager::setupUAVOWrappers()
|
||||||
{
|
{
|
||||||
foreach(QList<UAVObject*> objectList , m_objectManager->getObjects()) {
|
foreach(QList<UAVObject*> objectList , m_objectManager->getObjects()) {
|
||||||
UAVObject* object = objectList.at(0);
|
UAVObject* object = objectList.at(0);
|
||||||
if (!object->isMetaDataObject() && !object->isSettingsObject()) {
|
if (!object->isMetaDataObject() && !object->isSettingsObject()) {
|
||||||
m_uavoEntries.append(object);
|
m_uavoEntries.append(new UAVOLogSettingsWrapper(object));
|
||||||
qDebug() << objectList.at(0)->getName();
|
qDebug() << objectList.at(0)->getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit uavoEntriesChanged();
|
emit uavoEntriesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlightLogManager::setupLogSettings()
|
||||||
|
{
|
||||||
|
m_logSettings << tr("Disabled") << tr("When updated") << tr("Every 10ms") << tr("Every 50ms") << tr("Every 100ms")
|
||||||
|
<< tr("Every 500ms") << tr("Every second") << tr("Every 5s") << tr("Every 10s") << tr("Every 30s") << tr("Every minute");
|
||||||
|
}
|
||||||
|
|
||||||
ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(),
|
ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(),
|
||||||
m_object(0)
|
m_object(0)
|
||||||
{}
|
{}
|
||||||
@ -348,3 +356,14 @@ void ExtendedDebugLogEntry::setData(const DebugLogEntry::DataFields &data, UAVOb
|
|||||||
m_object->unpack(getData().Data);
|
m_object->unpack(getData().Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UAVOLogSettingsWrapper::UAVOLogSettingsWrapper() : QObject()
|
||||||
|
{}
|
||||||
|
|
||||||
|
UAVOLogSettingsWrapper::UAVOLogSettingsWrapper(UAVObject *object) : QObject(),
|
||||||
|
m_object(object), m_setting(EVERY_5S)
|
||||||
|
{}
|
||||||
|
|
||||||
|
UAVOLogSettingsWrapper::~UAVOLogSettingsWrapper()
|
||||||
|
{}
|
||||||
|
@ -38,6 +38,48 @@
|
|||||||
#include "debuglogstatus.h"
|
#include "debuglogstatus.h"
|
||||||
#include "debuglogcontrol.h"
|
#include "debuglogcontrol.h"
|
||||||
|
|
||||||
|
class UAVOLogSettingsWrapper : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_ENUMS(UAVLogSetting)
|
||||||
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||||
|
Q_PROPERTY(UAVOLogSettingsWrapper::UAVLogSetting setting READ setting WRITE setSetting NOTIFY settingChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum UAVLogSetting {DISABLED = 0, ON_CHANGE, EVERY_10MS, EVERY_50MS, EVERY_100MS,
|
||||||
|
EVERY_500MS, EVERY_1S, EVERY_5S, EVERY_10S, EVERY_30S, EVERY_1M};
|
||||||
|
|
||||||
|
explicit UAVOLogSettingsWrapper();
|
||||||
|
explicit UAVOLogSettingsWrapper(UAVObject* object);
|
||||||
|
~UAVOLogSettingsWrapper();
|
||||||
|
|
||||||
|
QString name() const
|
||||||
|
{
|
||||||
|
return m_object->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
UAVOLogSettingsWrapper::UAVLogSetting setting() const
|
||||||
|
{
|
||||||
|
return m_setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setSetting(UAVOLogSettingsWrapper::UAVLogSetting arg)
|
||||||
|
{
|
||||||
|
if (m_setting != arg) {
|
||||||
|
m_setting = arg;
|
||||||
|
emit settingChanged(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void settingChanged(UAVLogSetting arg);
|
||||||
|
void nameChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
UAVObject *m_object;
|
||||||
|
UAVLogSetting m_setting;
|
||||||
|
};
|
||||||
|
|
||||||
class ExtendedDebugLogEntry : public DebugLogEntry {
|
class ExtendedDebugLogEntry : public DebugLogEntry {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated)
|
Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated)
|
||||||
@ -76,7 +118,7 @@ class FlightLogManager : public QObject {
|
|||||||
Q_PROPERTY(bool disableExport READ disableExport WRITE setDisableExport NOTIFY disableExportChanged)
|
Q_PROPERTY(bool disableExport READ disableExport WRITE setDisableExport NOTIFY disableExportChanged)
|
||||||
Q_PROPERTY(bool adjustExportedTimestamps READ adjustExportedTimestamps WRITE setAdjustExportedTimestamps NOTIFY adjustExportedTimestampsChanged)
|
Q_PROPERTY(bool adjustExportedTimestamps READ adjustExportedTimestamps WRITE setAdjustExportedTimestamps NOTIFY adjustExportedTimestampsChanged)
|
||||||
|
|
||||||
Q_PROPERTY(QQmlListProperty<UAVObject> uavoEntries READ uavoEntries NOTIFY uavoEntriesChanged)
|
Q_PROPERTY(QQmlListProperty<UAVOLogSettingsWrapper> uavoEntries READ uavoEntries NOTIFY uavoEntriesChanged)
|
||||||
Q_PROPERTY(QStringList logSettings READ logSettings NOTIFY logSettingsChanged)
|
Q_PROPERTY(QStringList logSettings READ logSettings NOTIFY logSettingsChanged)
|
||||||
|
|
||||||
|
|
||||||
@ -85,10 +127,14 @@ public:
|
|||||||
~FlightLogManager();
|
~FlightLogManager();
|
||||||
|
|
||||||
QQmlListProperty<ExtendedDebugLogEntry> logEntries();
|
QQmlListProperty<ExtendedDebugLogEntry> logEntries();
|
||||||
QQmlListProperty<UAVObject> uavoEntries();
|
QQmlListProperty<UAVOLogSettingsWrapper> uavoEntries();
|
||||||
|
|
||||||
QStringList flightEntries();
|
QStringList flightEntries();
|
||||||
|
|
||||||
|
QStringList logSettings() {
|
||||||
|
return m_logSettings;
|
||||||
|
}
|
||||||
|
|
||||||
DebugLogStatus *flightLogStatus() const
|
DebugLogStatus *flightLogStatus() const
|
||||||
{
|
{
|
||||||
return m_flightLogStatus;
|
return m_flightLogStatus;
|
||||||
@ -111,17 +157,12 @@ public:
|
|||||||
return m_adjustExportedTimestamps;
|
return m_adjustExportedTimestamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList logSettings() const
|
|
||||||
{
|
|
||||||
return m_logSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void logEntriesChanged();
|
void logEntriesChanged();
|
||||||
void flightEntriesChanged();
|
void flightEntriesChanged();
|
||||||
|
void logSettingsChanged();
|
||||||
|
|
||||||
void uavoEntriesChanged();
|
void uavoEntriesChanged();
|
||||||
void logSettingsChanged();
|
|
||||||
|
|
||||||
void disableControlsChanged(bool arg);
|
void disableControlsChanged(bool arg);
|
||||||
void disableExportChanged(bool arg);
|
void disableExportChanged(bool arg);
|
||||||
@ -160,7 +201,8 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateFlightEntries(quint16 currentFlight);
|
void updateFlightEntries(quint16 currentFlight);
|
||||||
void updateUAVOS();
|
void setupUAVOWrappers();
|
||||||
|
void setupLogSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UAVObjectManager *m_objectManager;
|
UAVObjectManager *m_objectManager;
|
||||||
@ -170,10 +212,10 @@ private:
|
|||||||
|
|
||||||
QList<ExtendedDebugLogEntry *> m_logEntries;
|
QList<ExtendedDebugLogEntry *> m_logEntries;
|
||||||
QStringList m_flightEntries;
|
QStringList m_flightEntries;
|
||||||
|
|
||||||
QList<UAVObject *> m_uavoEntries;
|
|
||||||
QStringList m_logSettings;
|
QStringList m_logSettings;
|
||||||
|
|
||||||
|
QList<UAVOLogSettingsWrapper *> m_uavoEntries;
|
||||||
|
|
||||||
static const int UAVTALK_TIMEOUT = 4000;
|
static const int UAVTALK_TIMEOUT = 4000;
|
||||||
bool m_disableControls;
|
bool m_disableControls;
|
||||||
bool m_disableExport;
|
bool m_disableExport;
|
||||||
@ -181,4 +223,6 @@ private:
|
|||||||
bool m_adjustExportedTimestamps;
|
bool m_adjustExportedTimestamps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(UAVOLogSettingsWrapper::UAVLogSetting)
|
||||||
|
|
||||||
#endif // FLIGHTLOGMANAGER_H
|
#endif // FLIGHTLOGMANAGER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user