mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
OP-1245 Added table with UAVOs. Re-factored some UAVObject code.
This commit is contained in:
parent
749703d187
commit
0c61fd35c8
@ -20,8 +20,10 @@ Rectangle {
|
||||
border.width: 1
|
||||
radius: 4
|
||||
ColumnLayout {
|
||||
id: exportTab
|
||||
anchors.margins: 10
|
||||
anchors.fill: parent
|
||||
visible: true
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: "<b>" + qsTr("Log entries") + "</b>"
|
||||
@ -168,11 +170,64 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
id: settingsTab
|
||||
visible: false
|
||||
anchors.margins: 10
|
||||
anchors.fill: parent
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: "<b>" + qsTr("Log entries") + "</b>"
|
||||
}
|
||||
TableView {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredHeight: 1000;
|
||||
model: logManager.uavoEntries
|
||||
|
||||
TableViewColumn {
|
||||
role: "Name";
|
||||
title: qsTr("UAVObject");
|
||||
width: 150;
|
||||
delegate:
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
anchors.leftMargin: 5
|
||||
font.pixelSize: 12
|
||||
text: styleData.value
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
TableViewColumn {
|
||||
role: "Setting"; title: qsTr("Settings"); width: 150;
|
||||
delegate:
|
||||
ComboBox {
|
||||
model: logManager.logSettings
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
height: 40
|
||||
Button {
|
||||
id: settingsButton
|
||||
enabled: !logManager.disableControls
|
||||
text: qsTr("Log settings...")
|
||||
activeFocusOnPress: true
|
||||
property bool showSettings: false
|
||||
onClicked: {
|
||||
showSettings = !showSettings;
|
||||
settingsTab.visible = showSettings;
|
||||
exportTab.visible = !showSettings;
|
||||
text = (showSettings ? qsTr("View logs...") : qsTr("Log settings..."));
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
@ -35,11 +35,13 @@
|
||||
#include <QQmlContext>
|
||||
|
||||
#include "flightlogmanager.h"
|
||||
#include "uavobject.h"
|
||||
|
||||
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
|
||||
QDialog(parent)
|
||||
{
|
||||
qmlRegisterType<ExtendedDebugLogEntry>("org.openpilot", 1, 0, "DebugLogEntry");
|
||||
qmlRegisterUncreatableType<UAVObject>("org.openpilot", 1, 0, "UAVObject", "");
|
||||
|
||||
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
||||
setWindowTitle(tr("Manage flight side logs"));
|
||||
|
@ -57,6 +57,8 @@ FlightLogManager::FlightLogManager(QObject *parent) :
|
||||
Q_ASSERT(m_flightLogEntry);
|
||||
|
||||
updateFlightEntries(m_flightLogStatus->getFlight());
|
||||
|
||||
updateUAVOS();
|
||||
}
|
||||
|
||||
FlightLogManager::~FlightLogManager()
|
||||
@ -92,6 +94,32 @@ QQmlListProperty<ExtendedDebugLogEntry> FlightLogManager::logEntries()
|
||||
return QQmlListProperty<ExtendedDebugLogEntry>(this, &m_logEntries, &addLogEntries, &countLogEntries, &logEntryAt, &clearLogEntries);
|
||||
}
|
||||
|
||||
void addUAVOEntries(QQmlListProperty<UAVObject> *list, UAVObject *entry)
|
||||
{
|
||||
Q_UNUSED(list);
|
||||
Q_UNUSED(entry);
|
||||
}
|
||||
|
||||
int countUAVOEntries(QQmlListProperty<UAVObject> *list)
|
||||
{
|
||||
return static_cast< QList<UAVObject *> *>(list->data)->size();
|
||||
}
|
||||
|
||||
UAVObject *uavoEntryAt(QQmlListProperty<UAVObject> *list, int index)
|
||||
{
|
||||
return static_cast< QList<UAVObject *> *>(list->data)->at(index);
|
||||
}
|
||||
|
||||
void clearUAVOEntries(QQmlListProperty<UAVObject> *list)
|
||||
{
|
||||
return static_cast< QList<UAVObject *> *>(list->data)->clear();
|
||||
}
|
||||
|
||||
QQmlListProperty<UAVObject> FlightLogManager::uavoEntries()
|
||||
{
|
||||
return QQmlListProperty<UAVObject>(this, &m_uavoEntries, &addUAVOEntries, &countUAVOEntries, &uavoEntryAt, &clearUAVOEntries);
|
||||
}
|
||||
|
||||
QStringList FlightLogManager::flightEntries()
|
||||
{
|
||||
return m_flightEntries;
|
||||
@ -274,6 +302,18 @@ void FlightLogManager::updateFlightEntries(quint16 currentFlight)
|
||||
}
|
||||
}
|
||||
|
||||
void FlightLogManager::updateUAVOS()
|
||||
{
|
||||
foreach(QList<UAVObject*> objectList , m_objectManager->getObjects()) {
|
||||
UAVObject* object = objectList.at(0);
|
||||
if (!object->isMetaDataObject() && !object->isSettingsObject()) {
|
||||
m_uavoEntries.append(object);
|
||||
qDebug() << objectList.at(0)->getName();
|
||||
}
|
||||
}
|
||||
emit uavoEntriesChanged();
|
||||
}
|
||||
|
||||
ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(),
|
||||
m_object(0)
|
||||
{}
|
||||
|
@ -39,7 +39,8 @@
|
||||
#include "debuglogcontrol.h"
|
||||
|
||||
class ExtendedDebugLogEntry : public DebugLogEntry {
|
||||
Q_OBJECT Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated)
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated)
|
||||
|
||||
public:
|
||||
explicit ExtendedDebugLogEntry();
|
||||
@ -67,18 +68,25 @@ private:
|
||||
};
|
||||
|
||||
class FlightLogManager : public QObject {
|
||||
Q_OBJECT Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus)
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus)
|
||||
Q_PROPERTY(QQmlListProperty<ExtendedDebugLogEntry> logEntries READ logEntries NOTIFY logEntriesChanged)
|
||||
Q_PROPERTY(QStringList flightEntries READ flightEntries NOTIFY flightEntriesChanged)
|
||||
Q_PROPERTY(bool disableControls READ disableControls WRITE setDisableControls NOTIFY disableControlsChanged)
|
||||
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(QStringList logSettings READ logSettings NOTIFY logSettingsChanged)
|
||||
|
||||
|
||||
public:
|
||||
explicit FlightLogManager(QObject *parent = 0);
|
||||
~FlightLogManager();
|
||||
|
||||
QQmlListProperty<ExtendedDebugLogEntry> logEntries();
|
||||
QQmlListProperty<UAVObject> uavoEntries();
|
||||
|
||||
QStringList flightEntries();
|
||||
|
||||
DebugLogStatus *flightLogStatus() const
|
||||
@ -103,9 +111,18 @@ public:
|
||||
return m_adjustExportedTimestamps;
|
||||
}
|
||||
|
||||
QStringList logSettings() const
|
||||
{
|
||||
return m_logSettings;
|
||||
}
|
||||
|
||||
signals:
|
||||
void logEntriesChanged();
|
||||
void flightEntriesChanged();
|
||||
|
||||
void uavoEntriesChanged();
|
||||
void logSettingsChanged();
|
||||
|
||||
void disableControlsChanged(bool arg);
|
||||
void disableExportChanged(bool arg);
|
||||
|
||||
@ -143,15 +160,20 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void updateFlightEntries(quint16 currentFlight);
|
||||
void updateUAVOS();
|
||||
|
||||
private:
|
||||
UAVObjectManager *m_objectManager;
|
||||
DebugLogControl *m_flightLogControl;
|
||||
DebugLogStatus *m_flightLogStatus;
|
||||
DebugLogEntry *m_flightLogEntry;
|
||||
|
||||
QList<ExtendedDebugLogEntry *> m_logEntries;
|
||||
QStringList m_flightEntries;
|
||||
|
||||
QList<UAVObject *> m_uavoEntries;
|
||||
QStringList m_logSettings;
|
||||
|
||||
static const int UAVTALK_TIMEOUT = 4000;
|
||||
bool m_disableControls;
|
||||
bool m_disableExport;
|
||||
|
@ -230,7 +230,7 @@ void LoggingThread::retrieveSettings()
|
||||
QList< QList<UAVDataObject *> > objs = objMngr->getDataObjects();
|
||||
for (int n = 0; n < objs.length(); ++n) {
|
||||
UAVDataObject *obj = objs[n][0];
|
||||
if (obj->isSettings()) {
|
||||
if (obj->isSettingsObject()) {
|
||||
queue.enqueue(obj);
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ bool VehicleConfigurationHelper::saveChangesToController(bool save)
|
||||
m_transactionOK = false;
|
||||
UAVDataObject *obj = objPair->first;
|
||||
QString objDescription = objPair->second;
|
||||
if (UAVObject::GetGcsAccess(obj->getMetadata()) != UAVObject::ACCESS_READONLY && obj->isSettings()) {
|
||||
if (UAVObject::GetGcsAccess(obj->getMetadata()) != UAVObject::ACCESS_READONLY && obj->isSettingsObject()) {
|
||||
emit saveProgress(m_modifiedObjects.count() + 1, ++m_progress, objDescription);
|
||||
|
||||
m_currentTransactionObjectID = obj->getObjID();
|
||||
|
@ -99,7 +99,7 @@ void UAVObjectTreeModel::newObject(UAVObject *obj)
|
||||
|
||||
void UAVObjectTreeModel::addDataObject(UAVDataObject *obj)
|
||||
{
|
||||
TopTreeItem *root = obj->isSettings() ? m_settingsTree : m_nonSettingsTree;
|
||||
TopTreeItem *root = obj->isSettingsObject() ? m_settingsTree : m_nonSettingsTree;
|
||||
|
||||
TreeItem *parent = root;
|
||||
|
||||
@ -461,7 +461,7 @@ ObjectTreeItem *UAVObjectTreeModel::findObjectTreeItem(UAVObject *object)
|
||||
|
||||
DataObjectTreeItem *UAVObjectTreeModel::findDataObjectTreeItem(UAVDataObject *obj)
|
||||
{
|
||||
TopTreeItem *root = obj->isSettings() ? m_settingsTree : m_nonSettingsTree;
|
||||
TopTreeItem *root = obj->isSettingsObject() ? m_settingsTree : m_nonSettingsTree;
|
||||
|
||||
return root->findDataObjectTreeItemByObjectId(obj->getObjID());
|
||||
}
|
||||
@ -471,7 +471,7 @@ MetaObjectTreeItem *UAVObjectTreeModel::findMetaObjectTreeItem(UAVMetaObject *ob
|
||||
UAVDataObject *dataObject = qobject_cast<UAVDataObject *>(obj->getParentObject());
|
||||
|
||||
Q_ASSERT(dataObject);
|
||||
TopTreeItem *root = dataObject->isSettings() ? m_settingsTree : m_nonSettingsTree;
|
||||
TopTreeItem *root = dataObject->isSettingsObject() ? m_settingsTree : m_nonSettingsTree;
|
||||
return root->findMetaObjectTreeItemByObjectId(obj->getObjID());
|
||||
}
|
||||
|
||||
|
@ -30,40 +30,40 @@
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
UAVDataObject::UAVDataObject(quint32 objID, bool isSingleInst, bool isSet, const QString & name) :
|
||||
UAVDataObject::UAVDataObject(quint32 objID, bool isSingleInst, bool isSettings, const QString & name) :
|
||||
UAVObject(objID, isSingleInst, name)
|
||||
{
|
||||
mobj = NULL;
|
||||
this->isSet = isSet;
|
||||
m_metaObject = NULL;
|
||||
this->m_isSettings = isSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize instance ID and assign a metaobject
|
||||
*/
|
||||
void UAVDataObject::initialize(quint32 instID, UAVMetaObject *mobj)
|
||||
void UAVDataObject::initialize(quint32 instID, UAVMetaObject *metaObject)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
this->mobj = mobj;
|
||||
this->m_metaObject = metaObject;
|
||||
UAVObject::initialize(instID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a metaobject
|
||||
*/
|
||||
void UAVDataObject::initialize(UAVMetaObject *mobj)
|
||||
void UAVDataObject::initialize(UAVMetaObject *metaObject)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
this->mobj = mobj;
|
||||
this->m_metaObject = metaObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a data object holding module settings
|
||||
*/
|
||||
bool UAVDataObject::isSettings()
|
||||
bool UAVDataObject::isSettingsObject()
|
||||
{
|
||||
return isSet;
|
||||
return m_isSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,8 +71,8 @@ bool UAVDataObject::isSettings()
|
||||
*/
|
||||
void UAVDataObject::setMetadata(const Metadata & mdata)
|
||||
{
|
||||
if (mobj != NULL) {
|
||||
mobj->setData(mdata);
|
||||
if (m_metaObject != NULL) {
|
||||
m_metaObject->setData(mdata);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ void UAVDataObject::setMetadata(const Metadata & mdata)
|
||||
*/
|
||||
UAVObject::Metadata UAVDataObject::getMetadata(void)
|
||||
{
|
||||
if (mobj != NULL) {
|
||||
return mobj->getData();
|
||||
if (m_metaObject != NULL) {
|
||||
return m_metaObject->getData();
|
||||
} else {
|
||||
return getDefaultMetadata();
|
||||
}
|
||||
@ -93,5 +93,10 @@ UAVObject::Metadata UAVDataObject::getMetadata(void)
|
||||
*/
|
||||
UAVMetaObject *UAVDataObject::getMetaObject()
|
||||
{
|
||||
return mobj;
|
||||
return m_metaObject;
|
||||
}
|
||||
|
||||
bool UAVDataObject::isDataObject()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -38,19 +38,21 @@ class UAVOBJECTS_EXPORT UAVDataObject : public UAVObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UAVDataObject(quint32 objID, bool isSingleInst, bool isSet, const QString & name);
|
||||
void initialize(quint32 instID, UAVMetaObject *mobj);
|
||||
void initialize(UAVMetaObject *mobj);
|
||||
bool isSettings();
|
||||
UAVDataObject(quint32 objID, bool isSingleInst, bool isSettingsObject, const QString & name);
|
||||
void initialize(quint32 instID, UAVMetaObject *metaObject);
|
||||
void initialize(UAVMetaObject *metaObject);
|
||||
void setMetadata(const Metadata & mdata);
|
||||
Metadata getMetadata();
|
||||
UAVMetaObject *getMetaObject();
|
||||
virtual UAVDataObject *clone(quint32 instID = 0) = 0;
|
||||
virtual UAVDataObject *dirtyClone() = 0;
|
||||
|
||||
bool isSettingsObject();
|
||||
bool isDataObject();
|
||||
|
||||
private:
|
||||
UAVMetaObject *mobj;
|
||||
bool isSet;
|
||||
UAVMetaObject *m_metaObject;
|
||||
bool m_isSettings;
|
||||
};
|
||||
|
||||
#endif // UAVDATAOBJECT_H
|
||||
|
@ -107,3 +107,8 @@ UAVObject::Metadata UAVMetaObject::getData()
|
||||
|
||||
return parentMetadata;
|
||||
}
|
||||
|
||||
bool UAVMetaObject::isMetaDataObject()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ public:
|
||||
void setData(const Metadata & mdata);
|
||||
Metadata getData();
|
||||
|
||||
bool isMetaDataObject();
|
||||
|
||||
private:
|
||||
UAVObject *parent;
|
||||
Metadata ownMetadata;
|
||||
|
@ -535,6 +535,21 @@ void UAVObject::emitNewInstance(UAVObject *obj)
|
||||
emit newInstance(obj);
|
||||
}
|
||||
|
||||
bool UAVObject::isSettingsObject()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UAVObject::isDataObject()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UAVObject::isMetaDataObject()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a UAVObjMetadata object.
|
||||
* \param[in] metadata The metadata object
|
||||
|
@ -54,6 +54,7 @@ class UAVOBJECTS_EXPORT UAVObject : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_PROPERTY(QString Name READ getName)
|
||||
|
||||
/**
|
||||
* Object update mode
|
||||
@ -130,6 +131,10 @@ public:
|
||||
void emitTransactionCompleted(bool success);
|
||||
void emitNewInstance(UAVObject *);
|
||||
|
||||
virtual bool isSettingsObject();
|
||||
virtual bool isDataObject();
|
||||
virtual bool isMetaDataObject();
|
||||
|
||||
// Metadata accessors
|
||||
static void MetadataInitialize(Metadata & meta);
|
||||
static AccessMode GetFlightAccess(const Metadata & meta);
|
||||
|
@ -114,7 +114,7 @@ void SmartSaveButton::processOperation(QPushButton *button, bool save)
|
||||
|
||||
sv_result = false;
|
||||
current_objectID = obj->getObjID();
|
||||
if (save && (obj->isSettings())) {
|
||||
if (save && (obj->isSettingsObject())) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
qDebug() << "Saving" << obj->getName() << "to board.";
|
||||
connect(utilMngr, SIGNAL(saveCompleted(int, bool)), this, SLOT(saving_finished(int, bool)));
|
||||
|
@ -276,8 +276,8 @@ QString UAVSettingsImportExportFactory::createXMLDocument(const enum storedData
|
||||
QList< QList<UAVDataObject *> > objList = objManager->getDataObjects();
|
||||
foreach(QList<UAVDataObject *> list, objList) {
|
||||
foreach(UAVDataObject * obj, list) {
|
||||
if (((what == Settings) && obj->isSettings()) ||
|
||||
((what == Data) && !obj->isSettings()) ||
|
||||
if (((what == Settings) && obj->isSettingsObject()) ||
|
||||
((what == Data) && !obj->isSettingsObject()) ||
|
||||
(what == Both)) {
|
||||
// add each object to the XML
|
||||
QDomElement o = doc.createElement("object");
|
||||
@ -319,7 +319,7 @@ QString UAVSettingsImportExportFactory::createXMLDocument(const enum storedData
|
||||
}
|
||||
|
||||
// append to the settings or data element
|
||||
if (obj->isSettings()) {
|
||||
if (obj->isSettingsObject()) {
|
||||
settings.appendChild(o);
|
||||
} else {
|
||||
data.appendChild(o);
|
||||
|
@ -78,7 +78,7 @@ void TelemetryMonitor::startRetrievingObjects()
|
||||
if (mobj != NULL) {
|
||||
queue.enqueue(obj);
|
||||
} else if (dobj != NULL) {
|
||||
if (dobj->isSettings()) {
|
||||
if (dobj->isSettingsObject()) {
|
||||
queue.enqueue(obj);
|
||||
} else {
|
||||
if (UAVObject::GetFlightTelemetryUpdateMode(mdata) == UAVObject::UPDATEMODE_ONCHANGE) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user