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
6872ff0b
Commit
6872ff0b
authored
Feb 27, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fact type comes from mavlink parameter message
parent
04b5153b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
53 deletions
+48
-53
Fact.cc
src/FactSystem/Fact.cc
+4
-4
Fact.h
src/FactSystem/Fact.h
+5
-4
FactLoader.cc
src/FactSystem/FactLoader.cc
+38
-42
FactLoader.h
src/FactSystem/FactLoader.h
+1
-1
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+0
-2
No files found.
src/FactSystem/Fact.cc
View file @
6872ff0b
...
...
@@ -28,12 +28,13 @@
#include <QtQml>
Fact
::
Fact
(
QString
name
,
QObject
*
parent
)
:
Fact
::
Fact
(
QString
name
,
FactMetaData
::
ValueType_t
type
,
QObject
*
parent
)
:
QObject
(
parent
),
_name
(
name
),
_type
(
type
),
_metaData
(
NULL
)
{
_value
=
""
;
_value
=
0
;
}
void
Fact
::
setValue
(
const
QVariant
&
value
)
...
...
@@ -72,8 +73,7 @@ QVariant Fact::defaultValue(void)
FactMetaData
::
ValueType_t
Fact
::
type
(
void
)
{
Q_ASSERT
(
_metaData
);
return
_metaData
->
type
;
return
_type
;
}
QString
Fact
::
shortDescription
(
void
)
...
...
src/FactSystem/Fact.h
View file @
6872ff0b
...
...
@@ -57,7 +57,7 @@ class Fact : public QObject
Q_ENUMS
(
FactMetaData
::
ValueType_t
)
public:
Fact
(
QString
name
=
""
,
QObject
*
parent
=
NULL
);
Fact
(
QString
name
=
""
,
FactMetaData
::
ValueType_t
type
=
FactMetaData
::
valueTypeInt32
,
QObject
*
parent
=
NULL
);
// Property system methods
...
...
@@ -111,9 +111,10 @@ signals:
void
_containerValueChanged
(
QVariant
&
value
);
private:
QString
_name
;
///< Fact name
QVariant
_value
;
///< Fact value
FactMetaData
*
_metaData
;
///< FactMetaData object for Fact
QString
_name
;
QVariant
_value
;
FactMetaData
::
ValueType_t
_type
;
FactMetaData
*
_metaData
;
};
#endif
\ No newline at end of file
src/FactSystem/FactLoader.cc
View file @
6872ff0b
...
...
@@ -51,9 +51,8 @@ FactLoader::FactLoader(UASInterface* uas, QObject* parent) :
// We need to know when the param mgr is done sending the initial set of paramters
connect
(
_paramMgr
,
SIGNAL
(
parameterListUpToDate
()),
this
,
SLOT
(
_paramMgrParameterListUpToDate
()));
// We track parameters changes to keep Facts up to date. UASInterface::parameterChanged has multiple overrides so we need to
// use SIGNAL/SLOT style connect
connect
(
uas
,
SIGNAL
(
parameterChanged
(
int
,
int
,
QString
,
QVariant
)),
this
,
SLOT
(
_parameterChanged
(
int
,
int
,
QString
,
QVariant
)));
// We track parameters changes to keep Facts up to date.
connect
(
uas
,
&
UASInterface
::
parameterUpdate
,
this
,
&
FactLoader
::
_parameterUpdate
);
}
FactLoader
::~
FactLoader
()
...
...
@@ -65,10 +64,8 @@ FactLoader::~FactLoader()
_mapFact2ParameterName
.
clear
();
}
/// Connected to QGCUASParmManager::parameterChanged
///
/// When a new parameter is seen it is added to the system. If the parameter is already known it is updated.
void
FactLoader
::
_parameterChanged
(
int
uas
,
int
component
,
QString
parameterName
,
QVariant
value
)
/// Called whenever a parameter is updated or first seen.
void
FactLoader
::
_parameterUpdate
(
int
uas
,
int
component
,
QString
parameterName
,
int
mavType
,
QVariant
value
)
{
// Is this for our uas?
if
(
uas
!=
_uasId
)
{
...
...
@@ -86,7 +83,39 @@ void FactLoader::_parameterChanged(int uas, int component, QString parameterName
if
(
!
_mapParameterName2Variant
.
contains
(
parameterName
))
{
qCDebug
(
FactLoaderLog
)
<<
"Adding new fact"
<<
parameterName
;
Fact
*
fact
=
new
Fact
(
parameterName
,
this
);
FactMetaData
::
ValueType_t
factType
;
switch
(
mavType
)
{
case
MAV_PARAM_TYPE_UINT8
:
factType
=
FactMetaData
::
valueTypeUint8
;
break
;
case
MAV_PARAM_TYPE_INT8
:
factType
=
FactMetaData
::
valueTypeUint8
;
break
;
case
MAV_PARAM_TYPE_UINT16
:
factType
=
FactMetaData
::
valueTypeUint16
;
break
;
case
MAV_PARAM_TYPE_INT16
:
factType
=
FactMetaData
::
valueTypeInt16
;
break
;
case
MAV_PARAM_TYPE_UINT32
:
factType
=
FactMetaData
::
valueTypeUint32
;
break
;
case
MAV_PARAM_TYPE_INT32
:
factType
=
FactMetaData
::
valueTypeInt32
;
break
;
case
MAV_PARAM_TYPE_REAL32
:
factType
=
FactMetaData
::
valueTypeFloat
;
break
;
case
MAV_PARAM_TYPE_REAL64
:
factType
=
FactMetaData
::
valueTypeDouble
;
break
;
default:
factType
=
FactMetaData
::
valueTypeInt32
;
qCritical
()
<<
"Unsupported fact type"
<<
mavType
;
break
;
}
Fact
*
fact
=
new
Fact
(
parameterName
,
factType
,
this
);
setMetaData
=
true
;
_mapParameterName2Variant
[
parameterName
]
=
QVariant
::
fromValue
(
fact
);
...
...
@@ -169,39 +198,6 @@ void FactLoader::_paramMgrParameterListUpToDate(void)
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:
qWarning
()
<<
fact
->
name
()
<<
"Invalid variant type"
<<
fact
->
value
().
type
();
break
;
}
FactMetaData
*
metaData
=
new
FactMetaData
(
this
);
metaData
->
initFromTypeOnly
(
fact
Type
);
metaData
->
initFromTypeOnly
(
fact
->
type
()
);
}
src/FactSystem/FactLoader.h
View file @
6872ff0b
...
...
@@ -72,7 +72,7 @@ protected:
virtual
void
_addMetaDataToFact
(
Fact
*
fact
);
private
slots
:
void
_parameter
Changed
(
int
uas
,
int
component
,
QString
parameterNam
e
,
QVariant
value
);
void
_parameter
Update
(
int
uas
,
int
component
,
QString
parameterName
,
int
mavTyp
e
,
QVariant
value
);
void
_valueUpdated
(
QVariant
value
);
void
_paramMgrParameterListUpToDate
(
void
);
...
...
src/FactSystem/FactMetaData.cc
View file @
6872ff0b
...
...
@@ -37,6 +37,4 @@ FactMetaData::FactMetaData(QObject* parent) :
void
FactMetaData
::
initFromTypeOnly
(
ValueType_t
initType
)
{
type
=
initType
;
// FIXME: NYI
}
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