mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +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;
|
||||
model: logManager.logEntries
|
||||
|
||||
rowDelegate: Rectangle {
|
||||
height: 22
|
||||
color: styleData.selected ? "#ccc" : (styleData.alternate ? "#fff" : "#eee")
|
||||
}
|
||||
|
||||
itemDelegate: Text {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
anchors.leftMargin: 5
|
||||
font.pixelSize: 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: styleData.value
|
||||
}
|
||||
|
||||
@ -46,33 +48,24 @@ Rectangle {
|
||||
role: "Flight"; title: qsTr("Flight"); width: 50;
|
||||
delegate:
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
anchors.leftMargin: 5
|
||||
font.pixelSize: 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: styleData.value + 1
|
||||
}
|
||||
|
||||
}
|
||||
TableViewColumn {
|
||||
role: "FlightTime"; title: qsTr("Time"); width: 80;
|
||||
role: "FlightTime"; title: qsTr("Time"); width: 100;
|
||||
delegate:
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
anchors.leftMargin: 5
|
||||
font.pixelSize: 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: Functions.millisToTime(styleData.value)
|
||||
}
|
||||
}
|
||||
TableViewColumn {
|
||||
role: "Type"; title: "Type"; width: 50;
|
||||
role: "Type"; title: "Type"; width: 60;
|
||||
delegate:
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
anchors.leftMargin: 5
|
||||
font.pixelSize: 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: {
|
||||
switch(styleData.value) {
|
||||
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 {
|
||||
@ -177,7 +174,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: "<b>" + qsTr("Log entries") + "</b>"
|
||||
text: "<b>" + qsTr("Log settings") + "</b>"
|
||||
}
|
||||
TableView {
|
||||
Layout.fillWidth: true
|
||||
@ -185,29 +182,37 @@ Rectangle {
|
||||
Layout.preferredHeight: 1000;
|
||||
model: logManager.uavoEntries
|
||||
|
||||
rowDelegate: Rectangle {
|
||||
height: 22
|
||||
color: styleData.selected ? "#ccc" : (styleData.alternate ? "#fff" : "#eee")
|
||||
}
|
||||
|
||||
TableViewColumn {
|
||||
role: "Name";
|
||||
role: "name";
|
||||
title: qsTr("UAVObject");
|
||||
width: 150;
|
||||
width: 200;
|
||||
delegate:
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.leftMargin: 5
|
||||
font.pixelSize: 12
|
||||
text: styleData.value
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
TableViewColumn {
|
||||
role: "Setting"; title: qsTr("Settings"); width: 150;
|
||||
role: "setting";
|
||||
title: qsTr("Settings");
|
||||
width: 200;
|
||||
delegate:
|
||||
ComboBox {
|
||||
anchors.leftMargin: 5
|
||||
model: logManager.logSettings
|
||||
currentIndex: styleData.value
|
||||
//onCurrentIndexChanged:
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,10 @@
|
||||
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
|
||||
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", "");
|
||||
qRegisterMetaType<UAVOLogSettingsWrapper::UAVLogSetting>("UAVOLogSettingsWrapper::UAVLogSetting");
|
||||
|
||||
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
||||
setWindowTitle(tr("Manage flight side logs"));
|
||||
|
@ -58,7 +58,9 @@ FlightLogManager::FlightLogManager(QObject *parent) :
|
||||
|
||||
updateFlightEntries(m_flightLogStatus->getFlight());
|
||||
|
||||
updateUAVOS();
|
||||
setupUAVOWrappers();
|
||||
|
||||
setupLogSettings();
|
||||
}
|
||||
|
||||
FlightLogManager::~FlightLogManager()
|
||||
@ -94,30 +96,30 @@ QQmlListProperty<ExtendedDebugLogEntry> FlightLogManager::logEntries()
|
||||
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(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()
|
||||
@ -302,18 +304,24 @@ void FlightLogManager::updateFlightEntries(quint16 currentFlight)
|
||||
}
|
||||
}
|
||||
|
||||
void FlightLogManager::updateUAVOS()
|
||||
void FlightLogManager::setupUAVOWrappers()
|
||||
{
|
||||
foreach(QList<UAVObject*> objectList , m_objectManager->getObjects()) {
|
||||
UAVObject* object = objectList.at(0);
|
||||
if (!object->isMetaDataObject() && !object->isSettingsObject()) {
|
||||
m_uavoEntries.append(object);
|
||||
m_uavoEntries.append(new UAVOLogSettingsWrapper(object));
|
||||
qDebug() << objectList.at(0)->getName();
|
||||
}
|
||||
}
|
||||
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(),
|
||||
m_object(0)
|
||||
{}
|
||||
@ -348,3 +356,14 @@ void ExtendedDebugLogEntry::setData(const DebugLogEntry::DataFields &data, UAVOb
|
||||
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 "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 {
|
||||
Q_OBJECT
|
||||
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 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)
|
||||
|
||||
|
||||
@ -85,10 +127,14 @@ public:
|
||||
~FlightLogManager();
|
||||
|
||||
QQmlListProperty<ExtendedDebugLogEntry> logEntries();
|
||||
QQmlListProperty<UAVObject> uavoEntries();
|
||||
QQmlListProperty<UAVOLogSettingsWrapper> uavoEntries();
|
||||
|
||||
QStringList flightEntries();
|
||||
|
||||
QStringList logSettings() {
|
||||
return m_logSettings;
|
||||
}
|
||||
|
||||
DebugLogStatus *flightLogStatus() const
|
||||
{
|
||||
return m_flightLogStatus;
|
||||
@ -111,17 +157,12 @@ public:
|
||||
return m_adjustExportedTimestamps;
|
||||
}
|
||||
|
||||
QStringList logSettings() const
|
||||
{
|
||||
return m_logSettings;
|
||||
}
|
||||
|
||||
signals:
|
||||
void logEntriesChanged();
|
||||
void flightEntriesChanged();
|
||||
void logSettingsChanged();
|
||||
|
||||
void uavoEntriesChanged();
|
||||
void logSettingsChanged();
|
||||
|
||||
void disableControlsChanged(bool arg);
|
||||
void disableExportChanged(bool arg);
|
||||
@ -160,7 +201,8 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void updateFlightEntries(quint16 currentFlight);
|
||||
void updateUAVOS();
|
||||
void setupUAVOWrappers();
|
||||
void setupLogSettings();
|
||||
|
||||
private:
|
||||
UAVObjectManager *m_objectManager;
|
||||
@ -170,10 +212,10 @@ private:
|
||||
|
||||
QList<ExtendedDebugLogEntry *> m_logEntries;
|
||||
QStringList m_flightEntries;
|
||||
|
||||
QList<UAVObject *> m_uavoEntries;
|
||||
QStringList m_logSettings;
|
||||
|
||||
QList<UAVOLogSettingsWrapper *> m_uavoEntries;
|
||||
|
||||
static const int UAVTALK_TIMEOUT = 4000;
|
||||
bool m_disableControls;
|
||||
bool m_disableExport;
|
||||
@ -181,4 +223,6 @@ private:
|
||||
bool m_adjustExportedTimestamps;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(UAVOLogSettingsWrapper::UAVLogSetting)
|
||||
|
||||
#endif // FLIGHTLOGMANAGER_H
|
||||
|
Loading…
Reference in New Issue
Block a user