-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cc94e4d
Showing
8 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "IvyQt"] | ||
path = IvyQt | ||
url = https://gitlab.com/ivybus/IvyQt.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(IvyQtExample LANGUAGES CXX) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
set(CMAKE_AUTOUIC ON) | ||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_AUTORCC ON) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
|
||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets Xml REQUIRED) | ||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS | ||
Widgets | ||
Network | ||
Xml | ||
REQUIRED) | ||
|
||
set(IvyQt_DIR "IvyQt/IvyQt/") | ||
add_subdirectory(${IvyQt_DIR} ivyqt) | ||
|
||
set(PROJECT_SOURCES | ||
main.cpp | ||
pprzlinkqt.cpp | ||
message_definition.cpp | ||
) | ||
|
||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) | ||
qt_add_executable(IvyQtExample ${PROJECT_SOURCES}) | ||
else() | ||
add_executable(IvyQtExample ${PROJECT_SOURCES}) | ||
endif() | ||
|
||
|
||
target_include_directories(IvyQtExample PRIVATE ${IvyQt_DIR}) | ||
|
||
target_link_libraries(IvyQtExample PRIVATE | ||
Qt${QT_VERSION_MAJOR}::Widgets | ||
Qt${QT_VERSION_MAJOR}::Network | ||
Qt${QT_VERSION_MAJOR}::Xml | ||
IvyQt | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <QApplication> | ||
#include "pprzlinkqt.h" | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QCoreApplication a(argc, argv); | ||
|
||
PprzlinkQt pp("/home/fabien/paparazzi/var/messages.xml"); | ||
|
||
return a.exec(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "message_definition.h" | ||
|
||
|
||
MessageDefinition::MessageDefinition(QDomElement msg_elt, QString class_name, uint8_t class_id): | ||
class_name(class_name), class_id(class_id) | ||
{ | ||
name = msg_elt.attribute("name"); | ||
id = msg_elt.attribute("id").toUInt(); | ||
|
||
for(auto elt = msg_elt.firstChildElement(); | ||
!elt.isNull(); | ||
elt = elt.nextSiblingElement()) { | ||
|
||
if(elt.tagName() == "description") { | ||
description = elt.text(); | ||
} else if(elt.tagName() == "field") { | ||
QString field_description = elt.text(); | ||
QString field_name = elt.attribute("name"); | ||
QString field_type = elt.attribute("type"); | ||
QString format = elt.attribute("format"); | ||
QString unit = elt.attribute("unit"); | ||
QString values = elt.attribute("values"); | ||
QString alt_unit = elt.attribute("alt_unit"); | ||
QString alt_unit_coef = elt.attribute("alt_unit_coef"); | ||
qDebug() << field_name << field_type << format << unit << values << alt_unit << alt_unit_coef; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef MESSAGEDEFINITION_H | ||
#define MESSAGEDEFINITION_H | ||
|
||
#include <QString> | ||
#include <QtXml> | ||
|
||
class MessageDefinition | ||
{ | ||
public: | ||
MessageDefinition(QDomElement msg_elt, QString class_name, uint8_t class_id); | ||
|
||
QString getName() {return name;} | ||
uint8_t getId() {return id;} | ||
QString getClassName() {return class_name;} | ||
uint8_t getClassId() {return class_id;} | ||
QString getDescription() {return description;} | ||
|
||
private: | ||
QString class_name; | ||
uint8_t class_id; | ||
QString name; | ||
uint8_t id; | ||
QString description; | ||
|
||
//fields | ||
|
||
}; | ||
|
||
#endif // MESSAGEDEFINITION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "pprzlinkqt.h" | ||
#include <QtXml> | ||
#include "message_definition.h" | ||
|
||
|
||
PprzlinkQt::PprzlinkQt(QString filename, QObject *parent) : QObject(parent) | ||
{ | ||
QDomDocument xmlMessages; | ||
QFile f(filename); | ||
if(!f.open(QIODevice::ReadOnly)) { | ||
throw std::runtime_error("Error while loading layout file"); | ||
} | ||
xmlMessages.setContent(&f); | ||
f.close(); | ||
|
||
QDomElement root = xmlMessages.documentElement(); | ||
|
||
QString rootTag = root.tagName(); | ||
|
||
if (rootTag != "protocol") { | ||
throw std::runtime_error("Root tag expected to be \"protocol\". Is this a messages file ?"); | ||
} | ||
|
||
for(auto class_elt = root.firstChildElement(); | ||
!class_elt.isNull(); | ||
class_elt = class_elt.nextSiblingElement()) { | ||
|
||
QString class_name = class_elt.attribute("name"); | ||
uint8_t class_id = class_elt.attribute("id").toUInt(); | ||
qDebug() << class_name << class_id; | ||
|
||
for(auto msg_elt = class_elt.firstChildElement(); | ||
!msg_elt.isNull(); | ||
msg_elt = msg_elt.nextSiblingElement()) { | ||
|
||
MessageDefinition def(msg_elt, class_name, class_id); | ||
qDebug() << def.getName() << def.getId() << def.getDescription(); | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef PPRZLINKQT_H | ||
#define PPRZLINKQT_H | ||
|
||
#include <QObject> | ||
|
||
class PprzlinkQt : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit PprzlinkQt(QString filename, QObject *parent = nullptr); | ||
|
||
signals: | ||
|
||
}; | ||
|
||
#endif // PPRZLINKQT_H |