From 87829b8cb87c166e7d569ad3d135285ea9d7ee95 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Tue, 18 Aug 2015 21:32:11 +0200 Subject: [PATCH] LP-98 Add logreplay layer to SystemHealth --- .../systemhealth/systemhealthgadgetwidget.cpp | 50 ++- .../systemhealth/systemhealthgadgetwidget.h | 5 + .../src/share/diagrams/default/system-health.svg | 409 ++++++++++++++++++--- 3 files changed, 404 insertions(+), 60 deletions(-) diff --git a/ground/gcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp b/ground/gcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp index 581b26f49..779dfd2b4 100644 --- a/ground/gcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp +++ b/ground/gcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp @@ -50,6 +50,8 @@ SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsV background = new QGraphicsSvgItem(); foreground = new QGraphicsSvgItem(); nolink = new QGraphicsSvgItem(); + logreplay = new QGraphicsSvgItem(); + logreplay2 = new QGraphicsSvgItem(); missingElements = new QStringList(); paint(); @@ -64,16 +66,46 @@ SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsV TelemetryManager *telMngr = pm->getObject(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); + connect(telMngr, SIGNAL(telemetryUpdated(double, double)), this, SLOT(onTelemetryUpdated(double, double))); setToolTip(tr("Displays flight system errors. Click on an alarm for more information.")); } /** + * Hide/Show the "Log Replay" overlay + */ +void SystemHealthGadgetWidget::onTelemetryUpdated(double txRate, double rxRate) +{ + // Return if a real board is connected or log file end (no telemetry) + if (boardConnected || ((txRate + rxRate) == 0)) { + return; + } + + logreplayDelay++; + // With real board not connected, display Logreplay after a little delay + // and avoid Logreplay display when real board is connected. + if (logreplayDelay > 3) { + // Blink sequence, tell user Log replay runs. + if ((logreplayDelay % 2) == 0) { + logreplay->setVisible(true); + logreplay2->setVisible(false); + } else { + logreplay->setVisible(false); + logreplay2->setVisible(true); + } + nolink->setVisible(false); + } +} + +/** * Hide the "No Link" overlay */ void SystemHealthGadgetWidget::onAutopilotConnect() { nolink->setVisible(false); + logreplay->setVisible(false); + logreplay2->setVisible(false); + boardConnected = true; } /** @@ -82,6 +114,10 @@ void SystemHealthGadgetWidget::onAutopilotConnect() void SystemHealthGadgetWidget::onAutopilotDisconnect() { nolink->setVisible(true); + logreplay->setVisible(false); + logreplay2->setVisible(false); + boardConnected = false; + logreplayDelay = 0; } void SystemHealthGadgetWidget::updateAlarms(UAVObject *systemAlarm) @@ -162,10 +198,20 @@ void SystemHealthGadgetWidget::setSystemFile(QString dfn) foreground->setZValue(99); fgenabled = true; } + if (m_renderer->elementExists("logreplay")) { + logreplay->setSharedRenderer(m_renderer); + logreplay->setElementId("logreplay"); + logreplay->setZValue(100); + } + if (m_renderer->elementExists("logreplay2")) { + logreplay2->setSharedRenderer(m_renderer); + logreplay2->setElementId("logreplay2"); + logreplay2->setZValue(100); + } if (m_renderer->elementExists("nolink")) { nolink->setSharedRenderer(m_renderer); nolink->setElementId("nolink"); - nolink->setZValue(100); + nolink->setZValue(101); } QGraphicsScene *l_scene = scene(); @@ -192,6 +238,8 @@ void SystemHealthGadgetWidget::paint() l_scene->clear(); l_scene->addItem(background); l_scene->addItem(foreground); + l_scene->addItem(logreplay); + l_scene->addItem(logreplay2); l_scene->addItem(nolink); update(); } diff --git a/ground/gcs/src/plugins/systemhealth/systemhealthgadgetwidget.h b/ground/gcs/src/plugins/systemhealth/systemhealthgadgetwidget.h index 42a316ae5..e291c6b24 100644 --- a/ground/gcs/src/plugins/systemhealth/systemhealthgadgetwidget.h +++ b/ground/gcs/src/plugins/systemhealth/systemhealthgadgetwidget.h @@ -58,15 +58,20 @@ private slots: void updateAlarms(UAVObject *systemAlarm); // Called by the systemalarms UAVObject void onAutopilotConnect(); void onAutopilotDisconnect(); + void onTelemetryUpdated(double txRate, double rxRate); private: QSvgRenderer *m_renderer; QGraphicsSvgItem *background; QGraphicsSvgItem *foreground; QGraphicsSvgItem *nolink; + QGraphicsSvgItem *logreplay; + QGraphicsSvgItem *logreplay2; QStringList *missingElements; // Simple flag to skip rendering if the bool fgenabled; // layer does not exist. + bool boardConnected; + int logreplayDelay; void showAlarmDescriptionForItemId(const QString itemId, const QPoint & location); void showAllAlarmDescriptions(const QPoint &location); diff --git a/ground/gcs/src/share/diagrams/default/system-health.svg b/ground/gcs/src/share/diagrams/default/system-health.svg index 8ebee3cc8..b8520aa22 100644 --- a/ground/gcs/src/share/diagrams/default/system-health.svg +++ b/ground/gcs/src/share/diagrams/default/system-health.svg @@ -14,7 +14,7 @@ height="79.57505" id="svg3604" version="1.1" - inkscape:version="0.48.5 r10040" + inkscape:version="0.91 r13725" sodipodi:docname="system-health.svg" inkscape:export-filename="C:\NoBackup\OpenPilot\mainboard-health.png" inkscape:export-xdpi="269.53" @@ -27,10 +27,10 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="6.5977991" - inkscape:cx="55.083588" - inkscape:cy="24.071773" - inkscape:current-layer="layer46" + inkscape:zoom="7.1926861" + inkscape:cx="56.515743" + inkscape:cy="39.787525" + inkscape:current-layer="background" id="namedview3608" showgrid="true" inkscape:window-width="1280" @@ -691,7 +691,7 @@ image/svg+xml - + @@ -709,10 +709,10 @@ height="78.967804" width="112.71937" id="Background" - style="fill:#918a6f;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + style="fill:#918a6f;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" rx="1.6" /> SYSTEM HEALTH SENSR AUTO MISC PWR SYS I/O + style="display:inline;fill:#28170b;fill-opacity:1;stroke:none" /> + style="display:inline;fill:#28170b;fill-opacity:1;stroke:none" /> + style="display:inline;fill:#28170b;stroke:none" /> + style="display:inline;fill:#28170b;fill-opacity:1;stroke:none" /> + style="fill:#ffffff;fill-opacity:1;stroke:#800000;stroke-width:0.57869613;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> @@ -3054,13 +3054,13 @@ id="g4267-4" style="display:inline"> + + -- 2.11.4.GIT