mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
First connection of System Health plugin to system alarms. Only debug code for now.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@601 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
bc9f3f72ec
commit
e965ee0771
@ -6,5 +6,6 @@
|
|||||||
<url>http://www.openpilot.org</url>
|
<url>http://www.openpilot.org</url>
|
||||||
<dependencyList>
|
<dependencyList>
|
||||||
<dependency name="Core" version="1.0.0"/>
|
<dependency name="Core" version="1.0.0"/>
|
||||||
|
<dependency name="UAVObjects" version="0.0.1"/>
|
||||||
</dependencyList>
|
</dependencyList>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -3,6 +3,7 @@ TARGET = SystemHealthGadget
|
|||||||
QT += svg
|
QT += svg
|
||||||
include(../../openpilotgcsplugin.pri)
|
include(../../openpilotgcsplugin.pri)
|
||||||
include(../../plugins/coreplugin/coreplugin.pri)
|
include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
|
include(systemhealth_dependencies.pri)
|
||||||
include(../../libs/qwt/qwt.pri)
|
include(../../libs/qwt/qwt.pri)
|
||||||
HEADERS += systemhealthplugin.h
|
HEADERS += systemhealthplugin.h
|
||||||
HEADERS += systemhealthgadget.h
|
HEADERS += systemhealthgadget.h
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
include(../../plugins/uavobjects/uavobjects.pri)
|
||||||
|
#include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
|
#include(../../libs/utils/utils.pri)
|
@ -26,11 +26,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "systemhealthgadgetwidget.h"
|
#include "systemhealthgadgetwidget.h"
|
||||||
|
#include "extensionsystem/pluginmanager.h"
|
||||||
|
#include "uavobjects/uavobjectmanager.h"
|
||||||
|
#include "uavobjects/systemalarms.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the widget
|
||||||
|
*/
|
||||||
SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsView(parent)
|
SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
setMinimumSize(128,128);
|
setMinimumSize(128,128);
|
||||||
@ -43,6 +49,12 @@ SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsV
|
|||||||
|
|
||||||
paint();
|
paint();
|
||||||
|
|
||||||
|
// Now connect the widget to the SystemAlarms UAVObject
|
||||||
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
|
|
||||||
|
SystemAlarms* obj = dynamic_cast<SystemAlarms*>(objManager->getObject(QString("SystemAlarms")));
|
||||||
|
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateAlarms(UAVObject*)));
|
||||||
|
|
||||||
// Test code for timer to move the index
|
// Test code for timer to move the index
|
||||||
testValue=0;
|
testValue=0;
|
||||||
@ -50,6 +62,34 @@ SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsV
|
|||||||
m_testTimer.start(1000);
|
m_testTimer.start(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SystemHealthGadgetWidget::updateAlarms(UAVObject* systemAlarm)
|
||||||
|
{
|
||||||
|
QString alarm = systemAlarm->getName();
|
||||||
|
std::cout << "System Alarm: " << alarm.toStdString() << std::endl;
|
||||||
|
std::cout << "Object Name: " << systemAlarm->objectName().toStdString() << std::endl;
|
||||||
|
std::cout << "Object Elements: " << std::endl;
|
||||||
|
foreach (UAVObjectField *field, systemAlarm->getFields()) {
|
||||||
|
std::cout << "Field Name: " << field->getName().toStdString() << std::endl;
|
||||||
|
for (uint i = 0; i < field->getNumElements(); ++i) {
|
||||||
|
std::cout << " Option: " << field->getElementNames()[i].toStdString() << std::endl;
|
||||||
|
QString element = field->getElementNames()[i];
|
||||||
|
if (m_renderer->elementExists(element)) {
|
||||||
|
QMatrix blockMatrix = m_renderer->matrixForElement(element);
|
||||||
|
qreal startX = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).x();
|
||||||
|
qreal startY = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).y();
|
||||||
|
std::cout << " StartX: " << startX << std::endl;
|
||||||
|
std::cout << " StartY: " << startY << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << " Element not found in SVG" << std::endl;
|
||||||
|
}
|
||||||
|
std::cout << " Option value: " << field->getValue(i).toString().toStdString() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SystemHealthGadgetWidget::~SystemHealthGadgetWidget()
|
SystemHealthGadgetWidget::~SystemHealthGadgetWidget()
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
@ -86,13 +126,10 @@ void SystemHealthGadgetWidget::setSystemFile(QString dfn)
|
|||||||
|
|
||||||
void SystemHealthGadgetWidget::paint()
|
void SystemHealthGadgetWidget::paint()
|
||||||
{
|
{
|
||||||
|
|
||||||
QGraphicsScene *l_scene = scene();
|
QGraphicsScene *l_scene = scene();
|
||||||
l_scene->clear();
|
l_scene->clear();
|
||||||
|
|
||||||
l_scene->addItem(background);
|
l_scene->addItem(background);
|
||||||
l_scene->addItem(foreground);
|
l_scene->addItem(foreground);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define SYSTEMHEALTHGADGETWIDGET_H_
|
#define SYSTEMHEALTHGADGETWIDGET_H_
|
||||||
|
|
||||||
#include "systemhealthgadgetconfiguration.h"
|
#include "systemhealthgadgetconfiguration.h"
|
||||||
|
#include "uavobjects/uavobject.h"
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QtSvg/QSvgRenderer>
|
#include <QtSvg/QSvgRenderer>
|
||||||
#include <QtSvg/QGraphicsSvgItem>
|
#include <QtSvg/QGraphicsSvgItem>
|
||||||
@ -47,17 +48,14 @@ public:
|
|||||||
void setIndicator(QString indicator);
|
void setIndicator(QString indicator);
|
||||||
void paint();
|
void paint();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// Test function
|
// Test function
|
||||||
void test();
|
void test();
|
||||||
|
void updateAlarms(UAVObject *systemAlarm); // Called by the systemalarms UAVObject
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSvgRenderer *m_renderer;
|
QSvgRenderer *m_renderer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user