mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Merge remote-tracking branch 'origin/CC3D_Release' into pt/CC3D_Release
This commit is contained in:
commit
c673e5c586
@ -31,9 +31,9 @@
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <coreplugin/iconnection.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include "qextserialport/src/qextserialenumerator.h"
|
||||
#include "qextserialport/src/qextserialport.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
@ -59,6 +59,10 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidge
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
layout->setSpacing(5);
|
||||
layout->setContentsMargins(5,5,5,5);
|
||||
|
||||
m_monitor = new TelemetryMonitorWidget(this);
|
||||
layout->addWidget(m_monitor);
|
||||
|
||||
layout->addWidget(new QLabel(tr("Connections:")));
|
||||
|
||||
m_availableDevList = new QComboBox;
|
||||
@ -140,6 +144,10 @@ bool ConnectionManager::connectDevice()
|
||||
emit deviceConnected(m_ioDev);
|
||||
m_connectBtn->setText("Disconnect");
|
||||
m_availableDevList->setEnabled(false);
|
||||
|
||||
// tell the monitor we're connected
|
||||
m_monitor->connect();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -168,6 +176,9 @@ bool ConnectionManager::disconnectDevice()
|
||||
qDebug() << "Exception: m_connectionDevice.connection->closeDevice(" << m_connectionDevice.devName << ")";
|
||||
}
|
||||
|
||||
//tell the monitor we're disconnected
|
||||
m_monitor->disconnect();
|
||||
|
||||
m_connectionDevice.connection = NULL;
|
||||
m_ioDev = NULL;
|
||||
|
||||
@ -239,6 +250,14 @@ void ConnectionManager::onConnectClicked()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Slot called when the telemetry rates are updated
|
||||
*/
|
||||
void ConnectionManager::telemetryUpdated(double txRate, double rxRate)
|
||||
{
|
||||
m_monitor->updateTelemetry(txRate, rxRate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a device by its displayed (visible on screen) name
|
||||
*/
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include <QWidget>
|
||||
#include "mainwindow.h"
|
||||
#include "generalsettings.h"
|
||||
#include "telemetrymonitorwidget.h"
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QtCore/QLinkedList>
|
||||
@ -63,7 +65,6 @@ struct devListItem
|
||||
QString displayName;
|
||||
};
|
||||
|
||||
|
||||
class CORE_EXPORT ConnectionManager : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -89,6 +90,9 @@ signals:
|
||||
void deviceConnected(QIODevice *dev);
|
||||
void deviceAboutToDisconnect();
|
||||
|
||||
public slots:
|
||||
void telemetryUpdated(double txRate, double rxRate);
|
||||
|
||||
private slots:
|
||||
void objectAdded(QObject *obj);
|
||||
void aboutToRemoveObject(QObject *obj);
|
||||
@ -105,6 +109,9 @@ protected:
|
||||
QLinkedList<devListItem> m_devList;
|
||||
QList<IConnection*> m_connectionsList;
|
||||
|
||||
//tx/rx telemetry monitor
|
||||
TelemetryMonitorWidget* m_monitor;
|
||||
|
||||
//currently connected connection plugin
|
||||
devListItem m_connectionDevice;
|
||||
|
||||
|
@ -62,5 +62,6 @@
|
||||
<file>OpenPilotGCS.xml</file>
|
||||
<file>images/helpicon.svg</file>
|
||||
<file>images/cpu.png</file>
|
||||
<file>images/tx-rx.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -62,7 +62,8 @@ SOURCES += mainwindow.cpp \
|
||||
uavgadgetdecorator.cpp \
|
||||
workspacesettings.cpp \
|
||||
uavconfiginfo.cpp \
|
||||
authorsdialog.cpp
|
||||
authorsdialog.cpp \
|
||||
telemetrymonitorwidget.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
tabpositionindicator.h \
|
||||
fancyactionbar.h \
|
||||
@ -122,7 +123,8 @@ HEADERS += mainwindow.h \
|
||||
workspacesettings.h \
|
||||
uavconfiginfo.h \
|
||||
authorsdialog.h \
|
||||
iconfigurableplugin.h
|
||||
iconfigurableplugin.h \
|
||||
telemetrymonitorwidget.h
|
||||
FORMS += dialogs/settingsdialog.ui \
|
||||
dialogs/shortcutsettings.ui \
|
||||
generalsettings.ui \
|
||||
|
390
ground/openpilotgcs/src/plugins/coreplugin/images/tx-rx.svg
Normal file
390
ground/openpilotgcs/src/plugins/coreplugin/images/tx-rx.svg
Normal file
@ -0,0 +1,390 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="990"
|
||||
height="765"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.2 r9819"
|
||||
sodipodi:docname="tx-rx.svg">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.58"
|
||||
inkscape:cx="243.88087"
|
||||
inkscape:cy="482.05004"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="txrxBackground"
|
||||
showgrid="false"
|
||||
showguides="false"
|
||||
inkscape:guide-bbox="true"
|
||||
inkscape:window-width="1463"
|
||||
inkscape:window-height="686"
|
||||
inkscape:window-x="200"
|
||||
inkscape:window-y="200"
|
||||
inkscape:window-maximized="0">
|
||||
<sodipodi:guide
|
||||
orientation="1,0"
|
||||
position="159.7561,421.95122"
|
||||
id="guide3775" />
|
||||
<sodipodi:guide
|
||||
orientation="0,1"
|
||||
position="339.02439,473.17073"
|
||||
id="guide3912" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="bg"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-287.36218)"
|
||||
style="display:inline">
|
||||
<g
|
||||
id="g3963">
|
||||
<g
|
||||
id="txrxBackground"
|
||||
inkscape:label="#g3983">
|
||||
<rect
|
||||
style="fill:#333333;fill-rule:evenodd;stroke:#646464;stroke-width:2.57372737;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="rect2985"
|
||||
width="617.53455"
|
||||
height="80.003769"
|
||||
x="155.99559"
|
||||
y="503.89172"
|
||||
ry="12.840112" />
|
||||
<rect
|
||||
style="fill:#4d4d4d;stroke:none"
|
||||
id="rect3755-8"
|
||||
width="53.658535"
|
||||
height="25.938581"
|
||||
x="222.97562"
|
||||
y="512.58765"
|
||||
ry="12.969291" />
|
||||
<rect
|
||||
style="fill:#4d4d4d;stroke:none"
|
||||
id="rect3755-1-2"
|
||||
width="53.658535"
|
||||
height="25.169617"
|
||||
x="222.09756"
|
||||
y="548.42963"
|
||||
ry="12.584808" />
|
||||
<rect
|
||||
style="fill:#4d4d4d;stroke:none"
|
||||
id="rect3755-7-4"
|
||||
width="53.658535"
|
||||
height="25.938581"
|
||||
x="282.97562"
|
||||
y="512.58765"
|
||||
ry="12.969291" />
|
||||
<rect
|
||||
style="fill:#4d4d4d;stroke:none"
|
||||
id="rect3755-1-4-5"
|
||||
width="53.658535"
|
||||
height="25.169617"
|
||||
x="282.09756"
|
||||
y="548.42963"
|
||||
ry="12.584808" />
|
||||
<rect
|
||||
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3755-5"
|
||||
width="53.658535"
|
||||
height="25.938581"
|
||||
x="342.78049"
|
||||
y="512.58765"
|
||||
ry="12.969291" />
|
||||
<rect
|
||||
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3755-1-1"
|
||||
width="53.658535"
|
||||
height="25.169617"
|
||||
x="341.90244"
|
||||
y="548.42963"
|
||||
ry="12.584808" />
|
||||
<rect
|
||||
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3755-7-7"
|
||||
width="53.658535"
|
||||
height="25.938581"
|
||||
x="402.78049"
|
||||
y="512.58765"
|
||||
ry="12.969291" />
|
||||
<rect
|
||||
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3755-1-4-1"
|
||||
width="53.658535"
|
||||
height="25.169617"
|
||||
x="401.90244"
|
||||
y="548.42963"
|
||||
ry="12.584808" />
|
||||
<rect
|
||||
style="fill:#4d4d4d;stroke:none"
|
||||
id="rect3755-8-1"
|
||||
width="53.658535"
|
||||
height="25.938581"
|
||||
x="462.78049"
|
||||
y="512.58765"
|
||||
ry="12.969291" />
|
||||
<rect
|
||||
style="fill:#4d4d4d;stroke:none"
|
||||
id="rect3755-1-2-5"
|
||||
width="53.658535"
|
||||
height="25.169617"
|
||||
x="461.90244"
|
||||
y="548.42963"
|
||||
ry="12.584808" />
|
||||
<rect
|
||||
style="fill:#4d4d4d;stroke:none"
|
||||
id="rect3755-7-4-2"
|
||||
width="53.658535"
|
||||
height="25.938581"
|
||||
x="522.78052"
|
||||
y="512.58765"
|
||||
ry="12.969291" />
|
||||
<rect
|
||||
style="fill:#4d4d4d;stroke:none"
|
||||
id="rect3755-1-4-5-7"
|
||||
width="53.658535"
|
||||
height="25.169617"
|
||||
x="521.90247"
|
||||
y="548.42963"
|
||||
ry="12.584808" />
|
||||
<rect
|
||||
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3755-7-7-4"
|
||||
width="53.658535"
|
||||
height="25.938581"
|
||||
x="581.80487"
|
||||
y="513.30939"
|
||||
ry="12.969291" />
|
||||
<rect
|
||||
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3755-1-4-1-2"
|
||||
width="53.658535"
|
||||
height="25.169617"
|
||||
x="580.92682"
|
||||
y="549.13"
|
||||
ry="12.584808" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#b3b3b3;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
|
||||
x="164.82353"
|
||||
y="538.24451"
|
||||
id="text3093"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3038"
|
||||
x="164.82353"
|
||||
y="538.24451">Tx</tspan></text>
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3040"
|
||||
y="538.24451"
|
||||
x="164.82353"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
|
||||
xml:space="preserve"><tspan
|
||||
y="538.24451"
|
||||
x="164.82353"
|
||||
id="tspan3042"
|
||||
sodipodi:role="line">Tx</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold;font-stretch:normal;font-variant:normal;text-anchor:start;text-align:start;writing-mode:lr"
|
||||
x="163.79311"
|
||||
y="572.0863"
|
||||
id="text3044"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3046"
|
||||
x="163.79311"
|
||||
y="572.0863">Rx</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer3"
|
||||
inkscape:label="tx"
|
||||
style="display:inline">
|
||||
<rect
|
||||
style="fill:#00c200;fill-opacity:1;stroke:none;display:inline"
|
||||
id="tx0"
|
||||
width="53.658535"
|
||||
height="26.385658"
|
||||
x="222.90944"
|
||||
y="225.09811"
|
||||
ry="13.192829"
|
||||
inkscape:label="#rect3755-1-2-9" />
|
||||
<rect
|
||||
style="fill:#00c200;fill-opacity:1;stroke:none;display:inline"
|
||||
id="tx1"
|
||||
width="53.658535"
|
||||
height="26.385658"
|
||||
x="282.90942"
|
||||
y="225.09811"
|
||||
ry="13.192829"
|
||||
inkscape:label="#rect3755-1-4-5-3" />
|
||||
<rect
|
||||
style="color:#000000;fill:#00c200;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="tx2"
|
||||
width="53.658535"
|
||||
height="26.385658"
|
||||
x="342.71429"
|
||||
y="225.09811"
|
||||
ry="13.192829"
|
||||
inkscape:label="#rect3755-1-1-19" />
|
||||
<rect
|
||||
style="color:#000000;fill:#00c200;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="tx3"
|
||||
width="53.658535"
|
||||
height="26.385658"
|
||||
x="402.71429"
|
||||
y="225.09811"
|
||||
ry="13.192829"
|
||||
inkscape:label="#rect3755-1-4-1-8" />
|
||||
<rect
|
||||
style="fill:#ffd800;fill-opacity:1;stroke:none;display:inline"
|
||||
id="tx4"
|
||||
width="53.658535"
|
||||
height="26.385658"
|
||||
x="462.71429"
|
||||
y="225.09811"
|
||||
ry="13.192829"
|
||||
inkscape:label="#rect3755-1-2-5-6" />
|
||||
<rect
|
||||
style="fill:#ffd800;fill-opacity:1;stroke:none;display:inline"
|
||||
id="tx5"
|
||||
width="53.658535"
|
||||
height="26.385658"
|
||||
x="522.71436"
|
||||
y="225.09811"
|
||||
ry="13.192829"
|
||||
inkscape:label="#rect3755-1-4-5-7-5" />
|
||||
<rect
|
||||
style="color:#000000;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="tx6"
|
||||
width="53.658535"
|
||||
height="26.385658"
|
||||
x="581.73871"
|
||||
y="225.83234"
|
||||
ry="13.192829"
|
||||
inkscape:label="#rect3755-1-4-1-2-2" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;display:inline;font-family:Sans;-inkscape-font-specification:Sans"
|
||||
x="647.0033"
|
||||
y="245.35291"
|
||||
id="txSpeed"
|
||||
sodipodi:linespacing="125%"
|
||||
inkscape:label="#text3167"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3169"
|
||||
x="647.0033"
|
||||
y="245.35291">0 b/s</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="rx"
|
||||
style="display:inline">
|
||||
<rect
|
||||
style="fill:#00c200;fill-opacity:1;stroke:none;display:inline"
|
||||
id="rx0"
|
||||
width="53.658535"
|
||||
height="24.722538"
|
||||
x="222.35068"
|
||||
y="261.28473"
|
||||
ry="12.361269"
|
||||
inkscape:label="#rect3755-8-12" />
|
||||
<rect
|
||||
style="fill:#00c200;fill-opacity:1;stroke:none;display:inline"
|
||||
id="rx1"
|
||||
width="53.658535"
|
||||
height="24.722538"
|
||||
x="282.35068"
|
||||
y="261.28473"
|
||||
ry="12.361269"
|
||||
inkscape:label="#rect3755-7-4-3" />
|
||||
<rect
|
||||
style="color:#000000;fill:#00c200;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rx2"
|
||||
width="53.658535"
|
||||
height="24.722538"
|
||||
x="342.15555"
|
||||
y="261.28473"
|
||||
ry="12.361269"
|
||||
inkscape:label="#rect3755-5-3" />
|
||||
<rect
|
||||
style="color:#000000;fill:#00c200;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rx3"
|
||||
width="53.658535"
|
||||
height="24.722538"
|
||||
x="402.15555"
|
||||
y="261.28473"
|
||||
ry="12.361269"
|
||||
inkscape:label="#rect3755-7-7-41" />
|
||||
<rect
|
||||
style="fill:#ffd800;fill-opacity:1;stroke:none;display:inline"
|
||||
id="rx4"
|
||||
width="53.658535"
|
||||
height="24.722538"
|
||||
x="462.15555"
|
||||
y="261.28473"
|
||||
ry="12.361269"
|
||||
inkscape:label="#rect3755-8-1-1" />
|
||||
<rect
|
||||
style="fill:#ffd800;fill-opacity:1;stroke:none;display:inline"
|
||||
id="rx5"
|
||||
width="53.658535"
|
||||
height="24.722538"
|
||||
x="522.15552"
|
||||
y="261.28473"
|
||||
ry="12.361269"
|
||||
inkscape:label="#rect3755-7-4-2-3" />
|
||||
<rect
|
||||
style="color:#000000;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rx6"
|
||||
width="53.658535"
|
||||
height="24.722538"
|
||||
x="581.17987"
|
||||
y="261.97269"
|
||||
ry="12.361269"
|
||||
inkscape:label="#rect3755-7-7-4-7" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
|
||||
x="646.22638"
|
||||
y="281.98114"
|
||||
id="rxSpeed"
|
||||
sodipodi:linespacing="125%"
|
||||
inkscape:label="#text3959"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3961"
|
||||
x="646.22638"
|
||||
y="281.98114">0 b/s</tspan></text>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 14 KiB |
@ -0,0 +1,171 @@
|
||||
#include "telemetrymonitorwidget.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QtGui>
|
||||
#include <QtGui/QFont>
|
||||
#include <QDebug>
|
||||
|
||||
TelemetryMonitorWidget::TelemetryMonitorWidget(QWidget *parent) : QGraphicsView(parent)
|
||||
{
|
||||
setMinimumSize(160,80);
|
||||
setMaximumSize(160,80);
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setFrameStyle(QFrame::NoFrame);
|
||||
setBackgroundBrush(Qt::transparent);
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene(0,0,160,80, this);
|
||||
scene->setBackgroundBrush(Qt::transparent);
|
||||
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
if (renderer->load(QString(":/core/images/tx-rx.svg"))) {
|
||||
graph = new QGraphicsSvgItem();
|
||||
graph->setSharedRenderer(renderer);
|
||||
graph->setElementId("txrxBackground");
|
||||
|
||||
QString name;
|
||||
QGraphicsSvgItem* pt;
|
||||
|
||||
for (int i=0; i<NODE_NUMELEM; i++) {
|
||||
name = QString("tx%0").arg(i);
|
||||
if (renderer->elementExists(name)) {
|
||||
pt = new QGraphicsSvgItem();
|
||||
pt->setSharedRenderer(renderer);
|
||||
pt->setElementId(name);
|
||||
pt->setParentItem(graph);
|
||||
txNodes.append(pt);
|
||||
}
|
||||
|
||||
name = QString("rx%0").arg(i);
|
||||
if (renderer->elementExists(name)) {
|
||||
pt = new QGraphicsSvgItem();
|
||||
pt->setSharedRenderer(renderer);
|
||||
pt->setElementId(name);
|
||||
pt->setParentItem(graph);
|
||||
rxNodes.append(pt);
|
||||
}
|
||||
}
|
||||
|
||||
scene->addItem(graph);
|
||||
|
||||
txSpeed = new QGraphicsTextItem();
|
||||
txSpeed->setDefaultTextColor(Qt::white);
|
||||
txSpeed->setFont(QFont("Helvetica",22,2));
|
||||
txSpeed->setParentItem(graph);
|
||||
scene->addItem(txSpeed);
|
||||
|
||||
rxSpeed = new QGraphicsTextItem();
|
||||
rxSpeed->setDefaultTextColor(Qt::white);
|
||||
rxSpeed->setFont(QFont("Helvetica",22,2));
|
||||
rxSpeed->setParentItem(graph);
|
||||
scene->addItem(rxSpeed);
|
||||
|
||||
scene->setSceneRect(graph->boundingRect());
|
||||
setScene(scene);
|
||||
}
|
||||
|
||||
connected = false;
|
||||
txValue = 0.0;
|
||||
rxValue = 0.0;
|
||||
|
||||
setMin(0.0);
|
||||
setMax(1200.0);
|
||||
|
||||
showTelemetry();
|
||||
}
|
||||
|
||||
TelemetryMonitorWidget::~TelemetryMonitorWidget()
|
||||
{
|
||||
while (!txNodes.isEmpty())
|
||||
delete txNodes.takeFirst();
|
||||
|
||||
while (!rxNodes.isEmpty())
|
||||
delete rxNodes.takeFirst();
|
||||
}
|
||||
|
||||
void TelemetryMonitorWidget::connect()
|
||||
{
|
||||
connected = true;
|
||||
|
||||
//flash the lights
|
||||
updateTelemetry(maxValue, maxValue);
|
||||
}
|
||||
|
||||
void TelemetryMonitorWidget::disconnect()
|
||||
{
|
||||
//flash the lights
|
||||
updateTelemetry(maxValue, maxValue);
|
||||
|
||||
connected = false;
|
||||
updateTelemetry(0.0,0.0);
|
||||
}
|
||||
/*!
|
||||
\brief Called by the UAVObject which got updated
|
||||
|
||||
Updates the numeric value and/or the icon if the dial wants this.
|
||||
*/
|
||||
void TelemetryMonitorWidget::updateTelemetry(double txRate, double rxRate)
|
||||
{
|
||||
txValue = txRate;
|
||||
rxValue = rxRate;
|
||||
|
||||
showTelemetry();
|
||||
}
|
||||
|
||||
// Converts the value into an percentage:
|
||||
// this enables smooth movement in moveIndex below
|
||||
void TelemetryMonitorWidget::showTelemetry()
|
||||
{
|
||||
txIndex = (txValue-minValue)/(maxValue-minValue) * NODE_NUMELEM;
|
||||
rxIndex = (rxValue-minValue)/(maxValue-minValue) * NODE_NUMELEM;
|
||||
|
||||
if (connected)
|
||||
this->setToolTip(QString("Tx: %0 bytes/sec\nRx: %1 bytes/sec").arg(txValue).arg(rxValue));
|
||||
else
|
||||
this->setToolTip(QString("Disconnected"));
|
||||
|
||||
int i;
|
||||
int nodeMargin = 8;
|
||||
int leftMargin = 60;
|
||||
QGraphicsItem* node;
|
||||
|
||||
for (i=0; i < txNodes.count(); i++) {
|
||||
node = txNodes.at(i);
|
||||
node->setPos((i*(node->boundingRect().width() + nodeMargin)) + leftMargin, (node->boundingRect().height()/2) - 2);
|
||||
node->setVisible(connected && i < txIndex);
|
||||
node->update();
|
||||
}
|
||||
|
||||
for (i=0; i < rxNodes.count(); i++) {
|
||||
node = rxNodes.at(i);
|
||||
node->setPos((i*(node->boundingRect().width() + nodeMargin)) + leftMargin, (node->boundingRect().height()*2) - 2);
|
||||
node->setVisible(connected && i < rxIndex);
|
||||
node->update();
|
||||
}
|
||||
|
||||
QRectF rect = graph->boundingRect();
|
||||
txSpeed->setPos(rect.right() - 110, rect.top());
|
||||
txSpeed->setPlainText(QString("%0").arg(connected ? txValue : 0.0));
|
||||
|
||||
rxSpeed->setPos(rect.right() - 110, rect.top() + (rect.height() / 2));
|
||||
rxSpeed->setPlainText(QString("%0").arg(connected ? rxValue : 0.0));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void TelemetryMonitorWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
fitInView(graph, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
void TelemetryMonitorWidget::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
graph->setPos(0,-100);
|
||||
fitInView(graph, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
#ifndef TELEMETRYMONITORWIDGET_H
|
||||
#define TELEMETRYMONITORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
#include <QGraphicsView>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QtSvg/QGraphicsSvgItem>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
class TelemetryMonitorWidget : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TelemetryMonitorWidget(QWidget *parent = 0);
|
||||
~TelemetryMonitorWidget();
|
||||
|
||||
void setMin(double min) { minValue = min;}
|
||||
double getMin() { return minValue; }
|
||||
void setMax(double max) { maxValue = max;}
|
||||
double getMax() { return maxValue; }
|
||||
|
||||
//number of tx/rx nodes in the graph
|
||||
static const int NODE_NUMELEM = 7;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void connect();
|
||||
void disconnect();
|
||||
|
||||
void updateTelemetry(double txRate, double rxRate);
|
||||
void showTelemetry();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
QGraphicsSvgItem *graph;
|
||||
QPointer<QGraphicsTextItem> txSpeed;
|
||||
QPointer<QGraphicsTextItem> rxSpeed;
|
||||
QList<QGraphicsSvgItem*> txNodes;
|
||||
QList<QGraphicsSvgItem*> rxNodes;
|
||||
|
||||
bool connected;
|
||||
double txIndex;
|
||||
double txValue;
|
||||
double rxIndex;
|
||||
double rxValue;
|
||||
double minValue;
|
||||
double maxValue;
|
||||
};
|
||||
|
||||
#endif // TELEMETRYMONITORWIDGET_H
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include "telemetrymonitor.h"
|
||||
#include "qxtlogger.h"
|
||||
#include "coreplugin/connectionmanager.h"
|
||||
#include "coreplugin/icore.h"
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -52,6 +54,9 @@ TelemetryMonitor::TelemetryMonitor(UAVObjectManager* objMngr, Telemetry* tel)
|
||||
statsTimer = new QTimer(this);
|
||||
connect(statsTimer, SIGNAL(timeout()), this, SLOT(processStatsUpdates()));
|
||||
statsTimer->start(STATS_CONNECT_PERIOD_MS);
|
||||
|
||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
connect(this,SIGNAL(telemetryUpdated(double,double)),cm,SLOT(telemetryUpdated(double,double)));
|
||||
}
|
||||
|
||||
TelemetryMonitor::~TelemetryMonitor() {
|
||||
@ -232,6 +237,8 @@ void TelemetryMonitor::processStatsUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
emit telemetryUpdated((double)gcsStats.TxDataRate, (double)gcsStats.RxDataRate);
|
||||
|
||||
// Set data
|
||||
gcsStatsObj->setData(gcsStats);
|
||||
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
signals:
|
||||
void connected();
|
||||
void disconnected();
|
||||
void telemetryUpdated(double txRate, double rxRate);
|
||||
|
||||
public slots:
|
||||
void transactionCompleted(UAVObject* obj, bool success);
|
||||
|
Loading…
x
Reference in New Issue
Block a user