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
1f618979
Commit
1f618979
authored
Dec 12, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1120 from DonLakeFlyer/FSVariantArray
Switch parameter facts to QVariantMap
parents
277c1618
a9e3af1e
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
46 additions
and
480 deletions
+46
-480
AutoPilotPlugin.h
src/AutoPilotPlugins/AutoPilotPlugin.h
+3
-4
GenericAutoPilotPlugin.cc
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc
+6
-5
GenericAutoPilotPlugin.h
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h
+1
-1
PX4AutoPilotPlugin.cc
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
+1
-1
PX4AutoPilotPlugin.h
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h
+1
-1
PX4ParameterFacts.cc
src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc
+18
-15
PX4ParameterFacts.h
src/AutoPilotPlugins/PX4/PX4ParameterFacts.h
+9
-442
FactSystemTest.cc
src/FactSystem/FactSystemTest.cc
+4
-8
FactSystemTest.qml
src/FactSystem/FactSystemTest.qml
+2
-2
FactValidator.h
src/FactSystem/FactValidator.h
+1
-1
No files found.
src/AutoPilotPlugins/AutoPilotPlugin.h
View file @
1f618979
...
...
@@ -53,10 +53,9 @@ public:
/// Returns the parameter facts for the specified UAS.
///
/// Access to parameter properties is done through QObject::property or the full
/// QMetaObject methods. The property name is the parameter name. You should not
/// request parameter facts until the plugin reports that it is ready.
virtual
QObject
*
parameterFacts
(
void
)
const
=
0
;
/// Key is parameter name. Get Fact object like this: _mapParameterName2Variant["RC_MAP_THROTTLE"].value<Fact*>().
/// You should not request parameter facts until the plugin reports that it is ready.
virtual
const
QVariantMap
&
parameterFacts
(
void
)
const
=
0
;
/// Adds the FactSystem properties to the Qml context. You should not call
/// this method until the plugin reports that it is ready.
...
...
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc
View file @
1f618979
...
...
@@ -86,14 +86,15 @@ QString GenericAutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t cust
void
GenericAutoPilotPlugin
::
addFactsToQmlContext
(
QQmlContext
*
context
)
const
{
Q_UNUSED
(
context
);
// Qml not yet supported for Generic
Q_ASSERT
(
false
);
Q_ASSERT_X
(
false
,
"Not yet implemented"
,
""
);
}
QObject
*
GenericAutoPilotPlugin
::
parameterFacts
(
void
)
const
const
QVariantMap
&
GenericAutoPilotPlugin
::
parameterFacts
(
void
)
const
{
return
NULL
;
static
QVariantMap
staticMap
;
Q_ASSERT_X
(
false
,
"Not yet implemented"
,
""
);
return
staticMap
;
}
void
GenericAutoPilotPlugin
::
clearStaticData
(
void
)
...
...
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h
View file @
1f618979
...
...
@@ -42,7 +42,7 @@ public:
// Overrides from AutoPilotPlugin
virtual
QList
<
VehicleComponent
*>
getVehicleComponents
(
void
)
const
;
virtual
void
addFactsToQmlContext
(
QQmlContext
*
context
)
const
;
virtual
QObject
*
parameterFacts
(
void
)
const
;
virtual
const
QVariantMap
&
parameterFacts
(
void
)
const
;
virtual
bool
pluginIsReady
(
void
)
const
{
return
true
;
}
static
QList
<
AutoPilotPluginManager
::
FullMode_t
>
getModes
(
void
);
...
...
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
View file @
1f618979
...
...
@@ -212,7 +212,7 @@ void PX4AutoPilotPlugin::addFactsToQmlContext(QQmlContext* context) const
Q_ASSERT
(
_parameterFacts
->
factsAreReady
());
context
->
setContextProperty
(
"parameter
Facts"
,
_parameterFacts
);
context
->
setContextProperty
(
"parameter
s"
,
_parameterFacts
->
factMap
()
);
}
void
PX4AutoPilotPlugin
::
clearStaticData
(
void
)
...
...
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h
View file @
1f618979
...
...
@@ -44,7 +44,7 @@ public:
// Overrides from AutoPilotPlugin
virtual
QList
<
VehicleComponent
*>
getVehicleComponents
(
void
)
const
;
virtual
void
addFactsToQmlContext
(
QQmlContext
*
context
)
const
;
virtual
QObject
*
parameterFacts
(
void
)
const
{
return
_parameterFacts
;
}
virtual
const
QVariantMap
&
parameterFacts
(
void
)
const
{
return
_parameterFacts
->
factMap
()
;
}
virtual
bool
pluginIsReady
(
void
)
const
;
static
QList
<
AutoPilotPluginManager
::
FullMode_t
>
getModes
(
void
);
...
...
src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc
View file @
1f618979
...
...
@@ -64,7 +64,7 @@ PX4ParameterFacts::~PX4ParameterFacts()
foreach
(
Fact
*
fact
,
_mapFact2ParameterName
.
keys
())
{
delete
fact
;
}
_mapParameterName2
Fac
t
.
clear
();
_mapParameterName2
Varian
t
.
clear
();
_mapFact2ParameterName
.
clear
();
}
...
...
@@ -93,28 +93,31 @@ void PX4ParameterFacts::_parameterChanged(int uas, int component, QString parame
Q_ASSERT
(
component
==
_lastSeenComponent
);
}
// If we don't have meta data for the parameter it can't be part of the FactSystem
if
(
!
_mapParameterName2FactMetaData
.
contains
(
parameterName
))
{
// FIXME: Debug or Warning. Warning will fail TC
qDebug
()
<<
"FactSystem meta data out of date. Missing parameter:"
<<
parameterName
;
return
;
}
if
(
!
_mapParameterName2Fact
.
contains
(
parameterName
))
{
if
(
!
_mapParameterName2Variant
.
contains
(
parameterName
))
{
Fact
*
fact
=
new
Fact
(
this
);
fact
->
setMetaData
(
_mapParameterName2FactMetaData
[
parameterName
]);
if
(
_mapParameterName2FactMetaData
.
contains
(
parameterName
))
{
fact
->
setMetaData
(
_mapParameterName2FactMetaData
[
parameterName
]);
}
else
{
qDebug
()
<<
"FactSystem meta data out of date. Missing parameter:"
<<
parameterName
;
}
_mapParameterName2
Fact
[
parameterName
]
=
fact
;
_mapParameterName2
Variant
[
parameterName
]
=
QVariant
::
fromValue
(
fact
)
;
_mapFact2ParameterName
[
fact
]
=
parameterName
;
// We need to know when the fact changes so that we can send the new value to the parameter manager
connect
(
fact
,
&
Fact
::
_containerValueChanged
,
this
,
&
PX4ParameterFacts
::
_valueUpdated
);
//qDebug(
) << "Adding new fact" << parameterName;
qCDebug
(
PX4ParameterFactsLog
)
<<
"Adding new fact"
<<
parameterName
;
}
//qDebug() << "Updating fact value" << parameterName << value;
_mapParameterName2Fact
[
parameterName
]
->
_containerSetValue
(
value
);
Q_ASSERT
(
_mapParameterName2Variant
.
contains
(
parameterName
));
qCDebug
(
PX4ParameterFactsLog
)
<<
"Updating fact value"
<<
parameterName
<<
value
;
Fact
*
fact
=
_mapParameterName2Variant
[
parameterName
].
value
<
Fact
*>
();
Q_ASSERT
(
fact
);
fact
->
_containerSetValue
(
value
);
}
/// Connected to Fact::valueUpdated
...
...
src/AutoPilotPlugins/PX4/PX4ParameterFacts.h
View file @
1f618979
This diff is collapsed.
Click to expand it.
src/FactSystem/FactSystemTest.cc
View file @
1f618979
...
...
@@ -96,13 +96,11 @@ void FactSystemTest::_parameter_test(void)
AutoPilotPlugin
*
plugin
=
pluginMgr
->
getInstanceForAutoPilotPlugin
(
_uas
);
Q_ASSERT
(
plugin
);
QObject
*
parameterFacts
=
plugin
->
parameterFacts
();
QVERIFY
(
parameterFacts
!=
NULL
);
const
QVariantMap
&
parameterFacts
=
plugin
->
parameterFacts
();
// Compare the value in the Parameter Manager with the value from the FactSystem
QVariant
factVariant
=
parameterFacts
->
property
(
"RC_MAP_THROTTLE"
);
Fact
*
fact
=
factVariant
.
value
<
Fact
*>
();
Fact
*
fact
=
parameterFacts
[
"RC_MAP_THROTTLE"
].
value
<
Fact
*>
();
QVERIFY
(
fact
!=
NULL
);
QVariant
factValue
=
fact
->
value
();
QCOMPARE
(
factValue
.
isValid
(),
true
);
...
...
@@ -142,11 +140,9 @@ void FactSystemTest::_paramMgrSignal_test(void)
AutoPilotPlugin
*
plugin
=
pluginMgr
->
getInstanceForAutoPilotPlugin
(
_uas
);
Q_ASSERT
(
plugin
);
QObject
*
parameterFacts
=
plugin
->
parameterFacts
();
QVERIFY
(
parameterFacts
!=
NULL
);
const
QVariantMap
&
parameterFacts
=
plugin
->
parameterFacts
();
QVariant
factVariant
=
parameterFacts
->
property
(
"RC_MAP_THROTTLE"
);
Fact
*
fact
=
factVariant
.
value
<
Fact
*>
();
Fact
*
fact
=
parameterFacts
[
"RC_MAP_THROTTLE"
].
value
<
Fact
*>
();
QVERIFY
(
fact
!=
NULL
);
// Setting a new value into the parameter should trigger a valueChanged signal on the Fact
...
...
src/FactSystem/FactSystemTest.qml
View file @
1f618979
...
...
@@ -6,11 +6,11 @@ import QGroundControlFactControls 1.0
Item
{
TextInput
{
objectName
:
"
testControl
"
text
:
parameter
Facts
.
RC_MAP_THROTTLE
.
value
text
:
parameter
s
[
"
RC_MAP_THROTTLE
"
]
.
value
font.family
:
"
Helvetica
"
font.pointSize
:
24
color
:
"
red
"
focus
:
true
onAccepted
:
{
parameter
Facts
.
RC_MAP_THROTTLE
.
value
=
text
;
}
onAccepted
:
{
parameter
s
[
"
RC_MAP_THROTTLE
"
]
.
value
=
text
;
}
}
}
\ No newline at end of file
src/FactSystem/FactValidator.h
View file @
1f618979
...
...
@@ -36,7 +36,7 @@ class Fact;
/// The validator uses the FactMetaData to impose restrictions on the input. It is used as follows:
/// @code{.unparsed}
/// TextInput {
/// validator: FactValidator { fact: parameter
Facts.RC_MAP_THROTTLE
; }
/// validator: FactValidator { fact: parameter
s["RC_MAP_THROTTLE"]
; }
/// }
/// @endcode
class
FactValidator
:
public
QValidator
...
...
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