Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
b8f1fb0b
Commit
b8f1fb0b
authored
Dec 23, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1141 from DonLakeFlyer/FactControls
Fact controls
parents
6b1383fe
8e3f1375
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
129 additions
and
11 deletions
+129
-11
qgroundcontrol.qrc
qgroundcontrol.qrc
+8
-0
FactLabel.qml
qml/QGroundControl/FactControls/FactLabel.qml
+13
-0
FactTextField.qml
qml/QGroundControl/FactControls/FactTextField.qml
+14
-0
qmldir
qml/QGroundControl/FactControls/qmldir
+2
-1
PX4ParameterFacts.cc
src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc
+12
-1
PX4ParameterFacts.h
src/AutoPilotPlugins/PX4/PX4ParameterFacts.h
+4
-0
SafetyComponent.qml
src/AutoPilotPlugins/PX4/SafetyComponent.qml
+4
-1
Fact.cc
src/FactSystem/Fact.cc
+5
-3
Fact.h
src/FactSystem/Fact.h
+6
-1
FactLoader.cc
src/FactSystem/FactLoader.cc
+44
-3
FactLoader.h
src/FactSystem/FactLoader.h
+5
-0
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+7
-0
FactMetaData.h
src/FactSystem/FactMetaData.h
+5
-1
No files found.
qgroundcontrol.qrc
View file @
b8f1fb0b
...
...
@@ -237,12 +237,20 @@
</qresource>
<qresource prefix="/qml">
<file alias="test.qml">src/test.qml</file>
<file alias="QGroundControl/FactControls/qmldir">qml/QGroundControl/FactControls/qmldir</file>
<file alias="QGroundControl/FactControls/SetupButton.qml">qml/QGroundControl/FactControls/SetupButton.qml</file>
<file alias="QGroundControl/FactControls/FactLabel.qml">qml/QGroundControl/FactControls/FactLabel.qml</file>
<file alias="QGroundControl/FactControls/FactTextField.qml">qml/QGroundControl/FactControls/FactTextField.qml</file>
<file alias="octo_x.png">files/images/px4/airframes/octo_x.png</file>
<file alias="px4fmu_2.x.png">files/images/px4/boards/px4fmu_2.x.png</file>
<file alias="SetupViewConnected.qml">src/VehicleSetup/SetupViewConnected.qml</file>
<file alias="SetupViewDisconnected.qml">src/VehicleSetup/SetupViewDisconnected.qml</file>
<file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
...
...
qml/QGroundControl/FactControls/FactLabel.qml
0 → 100644
View file @
b8f1fb0b
import
QtQuick
2.2
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Controls
.
Styles
1.2
import
QGroundControl
.
FactSystem
1.0
Label
{
property
Fact
fact
:
Fact
{
value
:
"
FactLabel
"
}
QGCPalette
{
id
:
palette
;
colorGroup
:
QGCPalette
.
Active
}
color
:
palette
.
windowText
text
:
fact
.
value
}
qml/QGroundControl/FactControls/FactTextField.qml
0 → 100644
View file @
b8f1fb0b
import
QtQuick
2.2
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Controls
.
Styles
1.2
import
QGroundControl
.
FactSystem
1.0
TextField
{
property
Fact
fact
:
Fact
{
value
:
0
}
QGCPalette
{
id
:
palette
;
colorGroup
:
QGCPalette
.
Active
}
text
:
fact
.
value
onAccepted
:
fact
.
value
=
text
}
qml/QGroundControl/FactControls/qmldir
View file @
b8f1fb0b
Module QGroundControl.FactControls
SetupButton 1.0 SetupButton.qml
\ No newline at end of file
FactLabel 1.0 FactLabel.qml
FactTextField 1.0 FactTextField.qml
\ No newline at end of file
src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc
View file @
b8f1fb0b
...
...
@@ -264,3 +264,14 @@ void PX4ParameterFacts::clearStaticData(void)
_mapParameterName2FactMetaData
.
clear
();
_parameterMetaDataLoaded
=
false
;
}
/// Override from FactLoad which connects the meta data to the fact
void
PX4ParameterFacts
::
_addMetaDataToFact
(
Fact
*
fact
)
{
if
(
_mapParameterName2FactMetaData
.
contains
(
fact
->
name
()))
{
fact
->
setMetaData
(
_mapParameterName2FactMetaData
[
fact
->
name
()]);
}
else
{
// Use generic meta data
FactLoader
::
_addMetaDataToFact
(
fact
);
}
}
src/AutoPilotPlugins/PX4/PX4ParameterFacts.h
View file @
b8f1fb0b
...
...
@@ -52,6 +52,10 @@ public:
static
void
clearStaticData
(
void
);
private:
// Overrides from FactLoader
virtual
void
_addMetaDataToFact
(
Fact
*
fact
);
// Class methods
static
FactMetaData
*
_parseParameter
(
QXmlStreamReader
&
xml
,
const
QString
&
group
);
static
void
_initMetaData
(
FactMetaData
*
metaData
);
static
QVariant
_stringToTypedVariant
(
const
QString
&
string
,
FactMetaData
::
ValueType_t
type
,
bool
failOk
=
false
);
...
...
src/AutoPilotPlugins/PX4/SafetyComponent.qml
View file @
b8f1fb0b
...
...
@@ -2,6 +2,7 @@ import QtQuick 2.2
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Controls
.
Styles
1.2
import
QGroundControl
.
FactSystem
1.0
import
QGroundControl
.
FactControls
1.0
Rectangle
{
QGCPalette
{
id
:
palette
;
colorGroup
:
QGCPalette
.
Active
}
...
...
@@ -12,6 +13,8 @@ Rectangle {
Column
{
Label
{
text
:
"
Work in Progress
"
;
color
:
palette
.
windowText
}
Label
{
text
:
autopilot
.
parameters
[
"
RTL_RETURN_ALT
"
].
value
;
color
:
palette
.
windowText
}
Label
{
text
:
"
Return to Land Altitude
"
;
color
:
palette
.
windowText
}
FactLabel
{
fact
:
autopilot
.
parameters
[
"
RTL_RETURN_ALT
"
]
}
FactTextField
{
fact
:
autopilot
.
parameters
[
"
RTL_RETURN_ALT
"
]
}
}
}
src/FactSystem/Fact.cc
View file @
b8f1fb0b
...
...
@@ -28,10 +28,12 @@
#include <QtQml>
Fact
::
Fact
(
QObject
*
parent
)
:
QObject
(
parent
)
Fact
::
Fact
(
QString
name
,
QObject
*
parent
)
:
QObject
(
parent
),
_name
(
name
),
_metaData
(
NULL
)
{
_value
=
""
;
}
void
Fact
::
setValue
(
const
QVariant
&
value
)
...
...
src/FactSystem/Fact.h
View file @
b8f1fb0b
...
...
@@ -42,6 +42,7 @@ class Fact : public QObject
{
Q_OBJECT
Q_PROPERTY
(
QString
name
READ
name
CONSTANT
)
Q_PROPERTY
(
QVariant
value
READ
value
WRITE
setValue
NOTIFY
valueChanged
USER
true
)
Q_PROPERTY
(
QVariant
defaultValue
READ
defaultValue
CONSTANT
)
Q_PROPERTY
(
FactMetaData
::
ValueType_t
type
READ
type
CONSTANT
)
...
...
@@ -54,10 +55,13 @@ class Fact : public QObject
Q_ENUMS
(
FactMetaData
::
ValueType_t
)
public:
Fact
(
QObject
*
parent
=
NULL
);
Fact
(
Q
String
name
=
""
,
Q
Object
*
parent
=
NULL
);
// Property system methods
/// Read accessor or name property
QString
name
(
void
)
const
{
return
_name
;
}
/// Read accessor for value property
QVariant
value
(
void
)
const
{
return
_value
;
}
...
...
@@ -102,6 +106,7 @@ signals:
void
_containerValueChanged
(
QVariant
&
value
);
private:
QString
_name
;
///< Fact name
QVariant
_value
;
///< Fact value
FactMetaData
*
_metaData
;
///< FactMetaData object for Fact
};
...
...
src/FactSystem/FactLoader.cc
View file @
b8f1fb0b
...
...
@@ -83,7 +83,9 @@ void FactLoader::_parameterChanged(int uas, int component, QString parameterName
}
if
(
!
_mapParameterName2Variant
.
contains
(
parameterName
))
{
Fact
*
fact
=
new
Fact
(
this
);
qCDebug
(
FactLoaderLog
)
<<
"Adding new fact"
<<
parameterName
;
Fact
*
fact
=
new
Fact
(
parameterName
,
this
);
_mapParameterName2Variant
[
parameterName
]
=
QVariant
::
fromValue
(
fact
);
_mapFact2ParameterName
[
fact
]
=
parameterName
;
...
...
@@ -91,7 +93,7 @@ void FactLoader::_parameterChanged(int uas, int component, QString parameterName
// We need to know when the fact changes from QML so that we can send the new value to the parameter manager
connect
(
fact
,
&
Fact
::
_containerValueChanged
,
this
,
&
FactLoader
::
_valueUpdated
);
qCDebug
(
FactLoaderLog
)
<<
"Adding new fact"
<<
parameterName
;
_addMetaDataToFact
(
fact
)
;
}
Q_ASSERT
(
_mapParameterName2Variant
.
contains
(
parameterName
));
...
...
@@ -105,7 +107,7 @@ void FactLoader::_parameterChanged(int uas, int component, QString parameterName
/// Connected to Fact::valueUpdated
///
/// Sets the new value into the Parameter Manager. Paramter is persisted after send.
/// Sets the new value into the Parameter Manager. Param
e
ter is persisted after send.
void
FactLoader
::
_valueUpdated
(
QVariant
value
)
{
Fact
*
fact
=
qobject_cast
<
Fact
*>
(
sender
());
...
...
@@ -157,3 +159,42 @@ void FactLoader::_paramMgrParameterListUpToDate(void)
emit
factsReady
();
}
}
void
FactLoader
::
_addMetaDataToFact
(
Fact
*
fact
)
{
// Create generic meta data based on value variant type
FactMetaData
::
ValueType_t
factType
=
FactMetaData
::
valueTypeInt32
;
// init to in32 to silence compiler warning
switch
((
QMetaType
::
Type
)
fact
->
value
().
type
())
{
case
QMetaType
:
:
Int
:
factType
=
FactMetaData
::
valueTypeInt32
;
break
;
case
QMetaType
:
:
UInt
:
factType
=
FactMetaData
::
valueTypeUint32
;
break
;
case
QMetaType
:
:
Double
:
factType
=
FactMetaData
::
valueTypeDouble
;
case
QMetaType
:
:
Short
:
factType
=
FactMetaData
::
valueTypeInt16
;
break
;
case
QMetaType
:
:
UShort
:
factType
=
FactMetaData
::
valueTypeUint16
;
break
;
case
QMetaType
:
:
Float
:
factType
=
FactMetaData
::
valueTypeFloat
;
break
;
default:
qCWarning
(
FactLoaderLog
)
<<
"Invalid variant type"
<<
fact
->
value
().
type
();
break
;
}
FactMetaData
*
metaData
=
new
FactMetaData
(
this
);
metaData
->
initFromTypeOnly
(
factType
);
}
src/FactSystem/FactLoader.h
View file @
b8f1fb0b
...
...
@@ -66,6 +66,11 @@ signals:
/// Signalled when the full set of facts are ready
void
factsReady
(
void
);
protected:
/// Base implementation adds generic meta data based on variant type. Derived class can override to provide
/// more details meta data.
virtual
void
_addMetaDataToFact
(
Fact
*
fact
);
private
slots
:
void
_parameterChanged
(
int
uas
,
int
component
,
QString
parameterName
,
QVariant
value
);
void
_valueUpdated
(
QVariant
value
);
...
...
src/FactSystem/FactMetaData.cc
View file @
b8f1fb0b
...
...
@@ -31,5 +31,12 @@
FactMetaData
::
FactMetaData
(
QObject
*
parent
)
:
QObject
(
parent
)
{
initFromTypeOnly
(
valueTypeInt32
);
}
void
FactMetaData
::
initFromTypeOnly
(
ValueType_t
initType
)
{
type
=
initType
;
// FIXME: NYI
}
src/FactSystem/FactMetaData.h
View file @
b8f1fb0b
...
...
@@ -54,8 +54,12 @@ public:
valueTypeDouble
}
ValueType_t
;
QVariant
defaultValue
;
/// Initialize the meta data given only the type.
void
initFromTypeOnly
(
ValueType_t
initType
);
// FIXME: This needs to switch over to Q_PROPERTY mechanism
ValueType_t
type
;
QVariant
defaultValue
;
QString
shortDescription
;
QString
longDescription
;
QString
units
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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