Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
12a43c79
Commit
12a43c79
authored
Sep 18, 2011
by
lm
Browse files
Mainwindow cleanup, fixed short value filter in Linechart, working on Python XML parser support
parent
c2c05fbc
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
src/apps/mavlinkgen/generator/MAVLinkXMLParserV10.cc
View file @
12a43c79
This diff is collapsed.
Click to expand it.
src/apps/mavlinkgen/generator/MAVLinkXMLParserV10.h
View file @
12a43c79
...
...
@@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project
#include
<QObject>
#include
<QDomDocument>
#include
<QString>
#include
<QProcess>
#include
<inttypes.h>
...
...
@@ -55,20 +56,24 @@ public slots:
/** @brief Parse XML and generate C files */
bool
generate
();
/** @brief Handle process errors */
void
processError
(
QProcess
::
ProcessError
err
);
signals:
/** @brief Status message on the parsing */
void
parseState
(
QString
message
);
protected:
/** @brief Accumulate the X.25 CRC by adding one char at a time. */
void
crcAccumulate
(
uint8_t
data
,
uint16_t
*
crcAccum
);
//
/** @brief Accumulate the X.25 CRC by adding one char at a time. */
//
void crcAccumulate(uint8_t data, uint16_t *crcAccum);
/** @brief Initialize the buffer for the X.25 CRC */
void
crcInit
(
uint16_t
*
crcAccum
);
//
/** @brief Initialize the buffer for the X.25 CRC */
//
void crcInit(uint16_t* crcAccum);
QDomDocument
*
doc
;
QString
outputDirName
;
QString
fileName
;
QProcess
*
process
;
};
#endif // MAVLINKXMLPARSERV10_H
src/ui/MAVLinkDecoder.cc
View file @
12a43c79
...
...
@@ -8,6 +8,18 @@ MAVLinkDecoder::MAVLinkDecoder(MAVLinkProtocol* protocol, QObject *parent) :
memcpy
(
messageInfo
,
msg
,
sizeof
(
mavlink_message_info_t
)
*
256
);
memset
(
receivedMessages
,
0
,
sizeof
(
mavlink_message_t
)
*
256
);
// Fill filter
messageFilter
.
insert
(
MAVLINK_MSG_ID_HEARTBEAT
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_SYS_STATUS
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_STATUSTEXT
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_COMMAND
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_COMMAND_ACK
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_PARAM_SET
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_PARAM_VALUE
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_MISSION_ITEM
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_MISSION_COUNT
,
false
);
messageFilter
.
insert
(
MAVLINK_MSG_ID_MISSION_ACK
,
false
);
connect
(
protocol
,
SIGNAL
(
messageReceived
(
LinkInterface
*
,
mavlink_message_t
)),
this
,
SLOT
(
receiveMessage
(
LinkInterface
*
,
mavlink_message_t
)));
}
...
...
@@ -24,20 +36,21 @@ void MAVLinkDecoder::receiveMessage(LinkInterface* link,mavlink_message_t messag
quint64
time
=
0
;
uint8_t
fieldid
=
0
;
uint8_t
*
m
=
((
uint8_t
*
)(
receivedMessages
+
msgid
))
+
8
;
if
(
messageInfo
[
msgid
].
fields
[
fieldid
].
name
==
"time_boot_ms"
&&
messageInfo
[
msgid
].
fields
[
fieldid
].
type
==
MAVLINK_TYPE_UINT32_T
)
if
(
QString
(
messageInfo
[
msgid
].
fields
[
fieldid
].
name
)
==
QString
(
"time_boot_ms"
)
&&
messageInfo
[
msgid
].
fields
[
fieldid
].
type
==
MAVLINK_TYPE_UINT32_T
)
{
time
=
*
((
quint32
*
)(
m
+
messageInfo
[
msgid
].
fields
[
fieldid
].
wire_offset
));
}
else
if
(
messageInfo
[
msgid
].
fields
[
fieldid
].
name
==
"time_usec"
&&
messageInfo
[
msgid
].
fields
[
fieldid
].
type
==
MAVLINK_TYPE_UINT64_T
)
else
if
(
QString
(
messageInfo
[
msgid
].
fields
[
fieldid
].
name
)
==
QString
(
"time_usec"
)
&&
messageInfo
[
msgid
].
fields
[
fieldid
].
type
==
MAVLINK_TYPE_UINT64_T
)
{
time
=
*
((
quint64
*
)(
m
+
messageInfo
[
msgid
].
fields
[
fieldid
].
wire_offset
));
}
else
{
// First value is not time, send out value 0
emitFieldValue
(
&
message
,
fieldid
,
time
);
}
// Send out field values
// Send out field values
from 1..n
for
(
unsigned
int
i
=
1
;
i
<
messageInfo
[
msgid
].
num_fields
;
++
i
)
{
emitFieldValue
(
&
message
,
i
,
time
);
...
...
@@ -51,6 +64,7 @@ void MAVLinkDecoder::emitFieldValue(mavlink_message_t* msg, int fieldid, quint64
{
// Add field tree widget item
uint8_t
msgid
=
msg
->
msgid
;
if
(
messageFilter
.
contains
(
msgid
))
return
;
QString
fieldName
(
messageInfo
[
msgid
].
fields
[
fieldid
].
name
);
QString
fieldType
;
uint8_t
*
m
=
((
uint8_t
*
)(
receivedMessages
+
msgid
))
+
8
;
...
...
src/ui/MAVLinkDecoder.h
View file @
12a43c79
...
...
@@ -27,7 +27,8 @@ protected:
void
emitFieldValue
(
mavlink_message_t
*
msg
,
int
fieldid
,
quint64
time
);
mavlink_message_t
receivedMessages
[
256
];
///< Available / known messages
mavlink_message_info_t
messageInfo
[
256
];
mavlink_message_info_t
messageInfo
[
256
];
///< Message information
QMap
<
uint16_t
,
bool
>
messageFilter
;
///< Message/field names not to emit
};
...
...
src/ui/MainWindow.cc
View file @
12a43c79
...
...
@@ -91,8 +91,8 @@ MainWindow::MainWindow(QWidget *parent):
styleFileName
(
QCoreApplication
::
applicationDirPath
()
+
"/style-indoor.css"
),
autoReconnect
(
false
),
currentStyle
(
QGC_MAINWINDOW_STYLE_INDOOR
),
lowPowerMode
(
false
),
centerStackActionGroup
(
this
)
centerStackActionGroup
(
this
),
lowPowerMode
(
false
)
{
loadSettings
();
if
(
!
settings
.
contains
(
"CURRENT_VIEW"
))
...
...
@@ -115,12 +115,20 @@ MainWindow::MainWindow(QWidget *parent):
settings
.
sync
();
// Setup UI state machines
centerStackActionGroup
.
setExclusive
(
true
);
loadStyle
(
currentStyle
);
// Setup user interface
ui
.
setupUi
(
this
);
// Set dock options
setDockOptions
(
AnimatedDocks
|
AllowTabbedDocks
|
AllowNestedDocks
);
statusBar
()
->
setSizeGripEnabled
(
true
);
configureWindowName
();
// Setup UI state machines
centerStackActionGroup
.
setExclusive
(
true
);
centerStack
=
new
QStackedWidget
(
this
);
setCentralWidget
(
centerStack
);
...
...
@@ -131,22 +139,14 @@ MainWindow::MainWindow(QWidget *parent):
toolBar
->
addPerspectiveChangeAction
(
ui
.
actionOperatorsView
);
toolBar
->
addPerspectiveChangeAction
(
ui
.
actionEngineersView
);
toolBar
->
addPerspectiveChangeAction
(
ui
.
actionPilotsView
);
// toolBar->addPerspectiveChangeAction(ui.actionUnconnectedView);
buildCommonWidgets
();
connectCommonWidgets
();
configureWindowName
();
loadStyle
(
currentStyle
);
// Create actions
connectCommonActions
();
// Set dock options
setDockOptions
(
AnimatedDocks
|
AllowTabbedDocks
|
AllowNestedDocks
);
statusBar
()
->
setSizeGripEnabled
(
true
);
// Restore the window setup
if
(
settings
.
contains
(
getWindowStateKey
()))
...
...
@@ -179,14 +179,6 @@ MainWindow::MainWindow(QWidget *parent):
joystickWidget
=
0
;
joystick
=
new
JoystickInput
();
// Load Toolbar
toolBar
=
new
QGCToolBar
(
this
);
this
->
addToolBar
(
toolBar
);
// Add actions
toolBar
->
addPerspectiveChangeAction
(
ui
.
actionOperatorsView
);
toolBar
->
addPerspectiveChangeAction
(
ui
.
actionEngineersView
);
toolBar
->
addPerspectiveChangeAction
(
ui
.
actionPilotsView
);
// Connect link
if
(
autoReconnect
)
{
...
...
@@ -204,6 +196,9 @@ MainWindow::MainWindow(QWidget *parent):
windowStateVal
=
windowState
();
show
();
connect
(
&
windowNameUpdateTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
configureWindowName
()));
windowNameUpdateTimer
.
start
(
15000
);
}
MainWindow
::~
MainWindow
()
...
...
src/ui/MainWindow.h
View file @
12a43c79
...
...
@@ -213,6 +213,9 @@ public slots:
*/
void
showCentralWidget
();
/** @brief Update the window name */
void
configureWindowName
();
public:
QGCMAVLinkLogPlayer
*
getLogPlayer
()
{
...
...
@@ -283,7 +286,6 @@ protected:
void
connectCommonWidgets
();
void
connectCommonActions
();
void
configureWindowName
();
void
loadSettings
();
void
storeSettings
();
...
...
@@ -369,6 +371,7 @@ protected:
Qt
::
WindowStates
windowStateVal
;
bool
lowPowerMode
;
///< If enabled, QGC reduces the update rates of all widgets
QGCFlightGearLink
*
fgLink
;
QTimer
windowNameUpdateTimer
;
private:
Ui
::
MainWindow
ui
;
...
...
src/ui/linechart/LinechartWidget.cc
View file @
12a43c79
...
...
@@ -641,7 +641,7 @@ void LinechartWidget::addCurve(const QString& curve, const QString& unit)
curvesWidgetLayout
->
addWidget
(
label
,
labelRow
,
2
);
//checkBox->setText(QString());
label
->
setText
(
curve
);
label
->
setText
(
getCurveName
(
curve
+
unit
,
ui
.
shortNameCheckBox
->
isChecked
())
);
QColor
color
(
Qt
::
gray
);
// = plot->getColorForCurve(curve+unit);
QString
colorstyle
;
colorstyle
=
colorstyle
.
sprintf
(
"QWidget { background-color: #%X%X%X; }"
,
color
.
red
(),
color
.
green
(),
color
.
blue
());
...
...
@@ -770,54 +770,70 @@ void LinechartWidget::recolor()
}
}
void
LinechartWidget
::
s
et
ShortNames
(
bool
e
nable
)
QString
LinechartWidget
::
g
et
CurveName
(
const
QString
&
key
,
bool
shortE
nable
d
)
{
foreach
(
QString
key
,
curveNames
.
keys
()
)
if
(
shortEnabled
)
{
QString
name
;
if
(
enable
)
QStringList
parts
=
curveNames
.
value
(
key
).
split
(
"."
);
if
(
parts
.
length
()
>
1
)
{
QStringList
parts
=
curveNames
.
value
(
key
).
split
(
"."
);
if
(
parts
.
length
()
>
1
)
{
name
=
parts
.
at
(
1
);
}
else
{
name
=
parts
.
at
(
0
);
}
const
unsigned
int
sizeLimit
=
10
;
name
=
parts
.
at
(
1
);
}
else
{
name
=
parts
.
at
(
0
);
}
// Replace known words with abbreviations
if
(
name
.
length
()
>
sizeLimit
)
{
name
.
replace
(
"gyroscope"
,
"gyro"
);
name
.
replace
(
"accelerometer"
,
"acc"
);
name
.
replace
(
"magnetometer"
,
"mag"
);
name
.
replace
(
"distance"
,
"dist"
);
name
.
replace
(
"altitude"
,
"alt"
);
name
.
replace
(
"waypoint"
,
"wp"
);
name
.
replace
(
"error"
,
"err"
);
name
.
replace
(
"message"
,
"msg"
);
name
.
replace
(
"source"
,
"src"
);
}
const
int
sizeLimit
=
20
;
// Check if sub-part is still exceeding N chars
if
(
name
.
length
()
>
sizeLimit
)
{
name
.
replace
(
"a"
,
""
);
name
.
replace
(
"e"
,
""
);
name
.
replace
(
"i"
,
""
);
name
.
replace
(
"o"
,
""
);
name
.
replace
(
"u"
,
""
);
}
// Replace known words with abbreviations
if
(
name
.
length
()
>
sizeLimit
)
{
name
.
replace
(
"gyroscope"
,
"gyro"
);
name
.
replace
(
"accelerometer"
,
"acc"
);
name
.
replace
(
"magnetometer"
,
"mag"
);
name
.
replace
(
"distance"
,
"dist"
);
name
.
replace
(
"ailerons"
,
"ail"
);
name
.
replace
(
"altitude"
,
"alt"
);
name
.
replace
(
"waypoint"
,
"wp"
);
name
.
replace
(
"throttle"
,
"thr"
);
name
.
replace
(
"elevator"
,
"elev"
);
name
.
replace
(
"rudder"
,
"rud"
);
name
.
replace
(
"error"
,
"err"
);
name
.
replace
(
"version"
,
"ver"
);
name
.
replace
(
"message"
,
"msg"
);
name
.
replace
(
"count"
,
"cnt"
);
name
.
replace
(
"value"
,
"val"
);
name
.
replace
(
"source"
,
"src"
);
name
.
replace
(
"index"
,
"idx"
);
name
.
replace
(
"type"
,
"typ"
);
name
.
replace
(
"mode"
,
"mod"
);
}
else
// Check if sub-part is still exceeding N chars
if
(
name
.
length
()
>
sizeLimit
)
{
name
=
curveNames
.
value
(
key
);
name
.
replace
(
"a"
,
""
);
name
.
replace
(
"e"
,
""
);
name
.
replace
(
"i"
,
""
);
name
.
replace
(
"o"
,
""
);
name
.
replace
(
"u"
,
""
);
}
curveNameLabels
.
value
(
key
)
->
setText
(
name
);
return
name
;
}
else
{
return
curveNames
.
value
(
key
);
}
}
void
LinechartWidget
::
setShortNames
(
bool
enable
)
{
foreach
(
QString
key
,
curveNames
.
keys
())
{
curveNameLabels
.
value
(
key
)
->
setText
(
getCurveName
(
key
,
enable
));
}
}
...
...
src/ui/linechart/LinechartWidget.h
View file @
12a43c79
...
...
@@ -124,6 +124,8 @@ protected:
QToolButton
*
createButton
(
QWidget
*
parent
);
void
createCurveItem
(
QString
curve
);
void
createLayout
();
/** @brief Get the name for a curve key */
QString
getCurveName
(
const
QString
&
key
,
bool
shortEnabled
);
int
sysid
;
///< ID of the unmanned system this plot belongs to
LinechartPlot
*
activePlot
;
///< Plot for this system
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment