1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

Merge remote-tracking branch 'origin/dwillis/OP-646' into next

Conflicts:
	ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp
This commit is contained in:
James Cotton 2012-07-11 13:10:02 -05:00
commit 53be9e5fdb
4 changed files with 96 additions and 5 deletions

View File

@ -0,0 +1,13 @@
<html>
<head>
<title></title>
<meta content="">
<style></style>
</head>
<body>
<h1>Alarm: OK</h1>
<p>
There are no problems with this alarm.
</p>
</body>
</html>

View File

@ -3,5 +3,28 @@
<file>html/Actuator-Critical.html</file>
<file>html/ManualControl-Critical.html</file>
<file>html/ManualControl-Warning.html</file>
<file>html/CPU-Critical.html</file>
<file>html/CPU-Warning.html</file>
<file>html/FlightTime-Error.html</file>
<file>html/Battery-Warning.html</file>
<file>html/BootFault-Critical.html</file>
<file>html/EventSystem-Warning.html</file>
<file>html/FlightTime-Critical.html</file>
<file>html/AlarmOK.html</file>
<file>html/Attitude-Critical.html</file>
<file>html/Attitude-Error.html</file>
<file>html/Battery-Critical.html</file>
<file>html/Battery-Error.html</file>
<file>html/FlightTime-Warning.html</file>
<file>html/GPS-Critical.html</file>
<file>html/GPS-Error.html</file>
<file>html/GPS-Warning.html</file>
<file>html/Guidance-Warning.html</file>
<file>html/Memory-Critical.html</file>
<file>html/Memory-Warning.html</file>
<file>html/Sensors-Critical.html</file>
<file>html/Stabilization-Warning.html</file>
<file>html/Stack-Critical.html</file>
<file>html/Telemetry-Error.html</file>
</qresource>
</RCC>

View File

@ -63,6 +63,7 @@ SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsV
connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()));
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()));
setToolTip(tr("Displays flight system errors. Click on an alarm for more information."));
}
/**
@ -202,16 +203,67 @@ void SystemHealthGadgetWidget::mousePressEvent ( QMouseEvent * event )
QGraphicsScene *graphicsScene = scene();
if(graphicsScene){
QPoint point = event->pos();
bool haveAlarmItem = false;
foreach(QGraphicsItem* sceneItem, items(point)){
QGraphicsSvgItem *clickedItem = dynamic_cast<QGraphicsSvgItem*>(sceneItem);
if(clickedItem && (clickedItem != foreground) && clickedItem != background){
QFile alarmDescription(":/systemhealth/html/" + clickedItem->elementId() + ".html");
if(alarmDescription.open(QIODevice::ReadOnly | QIODevice::Text)){
QTextStream textStream(&alarmDescription);
QWhatsThis::showText(event->globalPos(), textStream.readAll());
if(clickedItem){
if((clickedItem != foreground) && (clickedItem != background)){
// Clicked an actual alarm. We need to set haveAlarmItem to true
// as two of the items in this loop will always be foreground and
// background. Without this flag, at some point in the loop we
// would always call showAllAlarmDescriptions...
haveAlarmItem = true;
QString itemId = clickedItem->elementId();
if(itemId.contains("OK")){
// No alarm set for this item
showAlarmDescriptionForItemId("AlarmOK", event->globalPos());
}else{
// Warning, error or critical alarm
showAlarmDescriptionForItemId(itemId, event->globalPos());
}
}else if(!haveAlarmItem){
// Clicked foreground or background
showAllAlarmDescriptions(event->globalPos());
}
}
}
}
}
void SystemHealthGadgetWidget::showAlarmDescriptionForItemId(const QString itemId, const QPoint& location){
QFile alarmDescription(":/systemhealth/html/" + itemId + ".html");
if(alarmDescription.open(QIODevice::ReadOnly | QIODevice::Text)){
QTextStream textStream(&alarmDescription);
QWhatsThis::showText(location, textStream.readAll());
}
}
void SystemHealthGadgetWidget::showAllAlarmDescriptions(const QPoint& location){
QGraphicsScene *graphicsScene = scene();
if(graphicsScene){
QString alarmsText;
// Loop through all items in the scene looking for svg items that represent alarms
foreach(QGraphicsItem* curItem, graphicsScene->items()){
QGraphicsSvgItem* curSvgItem = dynamic_cast<QGraphicsSvgItem*>(curItem);
if(curSvgItem && (curSvgItem != foreground) && (curSvgItem != background)){
QString elementId = curSvgItem->elementId();
if(!elementId.contains("OK")){
// Found an alarm, get its corresponding alarm html file contents
// and append to the cumulative string for all alarms.
QFile alarmDescription(":/systemhealth/html/" + elementId + ".html");
if(alarmDescription.open(QIODevice::ReadOnly | QIODevice::Text)){
QTextStream textStream(&alarmDescription);
alarmsText.append(textStream.readAll());
}
}
}
}
// Show alarms text if we have any
if(alarmsText.length() > 0){
QWhatsThis::showText(location, alarmsText);
}
}
}

View File

@ -69,5 +69,8 @@ private:
// Simple flag to skip rendering if the
bool fgenabled; // layer does not exist.
void showAlarmDescriptionForItemId(const QString itemId, const QPoint& location);
void showAllAlarmDescriptions(const QPoint &location);
};
#endif /* SYSTEMHEALTHGADGETWIDGET_H_ */