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
b6b24a16
Commit
b6b24a16
authored
Apr 13, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New naming scheme for non-default component
parent
4787a4fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
12 deletions
+104
-12
FactBinder.cc
src/FactSystem/FactBinder.cc
+83
-3
FactBinder.h
src/FactSystem/FactBinder.h
+19
-7
FactSystem.cc
src/FactSystem/FactSystem.cc
+1
-1
FactSystemTest.qml
src/FactSystem/FactSystemTest.qml
+1
-1
No files found.
src/FactSystem/FactBinder.cc
View file @
b6b24a16
...
...
@@ -51,6 +51,11 @@ QString FactBinder::name(void) const
}
}
int
FactBinder
::
componentId
(
void
)
const
{
return
_componentId
;
}
void
FactBinder
::
setName
(
const
QString
&
name
)
{
if
(
_fact
)
{
...
...
@@ -59,13 +64,25 @@ void FactBinder::setName(const QString& name)
}
if
(
!
name
.
isEmpty
())
{
if
(
_autopilotPlugin
->
factExists
(
FactSystem
::
ParameterProvider
,
_componentId
,
name
))
{
_fact
=
_autopilotPlugin
->
getFact
(
FactSystem
::
ParameterProvider
,
_componentId
,
name
);
QString
parsedName
=
name
;
// Component id + name combination?
if
(
name
.
contains
(
":"
))
{
QStringList
parts
=
name
.
split
(
":"
);
if
(
parts
.
count
()
==
2
)
{
parsedName
=
parts
[
0
];
_componentId
=
parts
[
1
].
toInt
();
}
}
if
(
_autopilotPlugin
->
factExists
(
FactSystem
::
ParameterProvider
,
_componentId
,
parsedName
))
{
_fact
=
_autopilotPlugin
->
getFact
(
FactSystem
::
ParameterProvider
,
_componentId
,
parsedName
);
connect
(
_fact
,
&
Fact
::
valueChanged
,
this
,
&
FactBinder
::
valueChanged
);
emit
valueChanged
();
emit
nameChanged
();
}
else
{
emit
metaDataChanged
();
}
else
{
qWarning
()
<<
"FAILED BINDING PARAM"
<<
name
<<
": PARAM DOES NOT EXIST ON SYSTEM!"
;
Q_ASSERT
(
false
);
}
...
...
@@ -108,3 +125,66 @@ QString FactBinder::units(void) const
return
QString
();
}
}
QVariant
FactBinder
::
defaultValue
(
void
)
{
if
(
_fact
)
{
return
_fact
->
defaultValue
();
}
else
{
return
QVariant
(
0
);
}
}
FactMetaData
::
ValueType_t
FactBinder
::
type
(
void
)
{
if
(
_fact
)
{
return
_fact
->
type
();
}
else
{
return
FactMetaData
::
valueTypeUint32
;
}
}
QString
FactBinder
::
shortDescription
(
void
)
{
if
(
_fact
)
{
return
_fact
->
shortDescription
();
}
else
{
return
QString
();
}
}
QString
FactBinder
::
longDescription
(
void
)
{
if
(
_fact
)
{
return
_fact
->
longDescription
();
}
else
{
return
QString
();
}
}
QVariant
FactBinder
::
min
(
void
)
{
if
(
_fact
)
{
return
_fact
->
min
();
}
else
{
return
QVariant
(
0
);
}
}
QVariant
FactBinder
::
max
(
void
)
{
if
(
_fact
)
{
return
_fact
->
max
();
}
else
{
return
QVariant
(
0
);
}
}
QString
FactBinder
::
group
(
void
)
{
if
(
_fact
)
{
return
_fact
->
group
();
}
else
{
return
QString
();
}
}
src/FactSystem/FactBinder.h
View file @
b6b24a16
...
...
@@ -38,17 +38,23 @@ class FactBinder : public QObject
{
Q_OBJECT
Q_PROPERTY
(
int
componentId
MEMBER
_componentId
NOTIFY
componentId
Changed
)
Q_PROPERTY
(
int
componentId
READ
componentId
NOTIFY
name
Changed
)
Q_PROPERTY
(
QString
name
READ
name
WRITE
setName
NOTIFY
nameChanged
)
Q_PROPERTY
(
QVariant
value
READ
value
WRITE
setValue
NOTIFY
valueChanged
USER
true
)
Q_PROPERTY
(
QVariant
valueString
READ
valueString
NOTIFY
valueChanged
)
Q_PROPERTY
(
QString
units
READ
units
CONSTANT
)
Q_PROPERTY
(
QString
units
READ
units
NOTIFY
metaDataChanged
)
Q_PROPERTY
(
QVariant
defaultValue
READ
defaultValue
NOTIFY
metaDataChanged
)
Q_PROPERTY
(
FactMetaData
::
ValueType_t
type
READ
type
NOTIFY
metaDataChanged
)
Q_PROPERTY
(
QString
shortDescription
READ
shortDescription
NOTIFY
metaDataChanged
)
Q_PROPERTY
(
QString
longDescription
READ
longDescription
NOTIFY
metaDataChanged
)
Q_PROPERTY
(
QVariant
min
READ
min
NOTIFY
metaDataChanged
)
Q_PROPERTY
(
QVariant
max
READ
max
NOTIFY
metaDataChanged
)
Q_PROPERTY
(
QString
group
READ
group
NOTIFY
metaDataChanged
)
public:
FactBinder
(
void
);
int
componentId
(
void
)
const
;
void
setComponentId
(
int
componentId
);
QString
name
(
void
)
const
;
void
setName
(
const
QString
&
name
);
...
...
@@ -58,13 +64,19 @@ public:
QString
valueString
(
void
)
const
;
/// Read accesor for units property
QString
units
(
void
)
const
;
QVariant
defaultValue
(
void
);
FactMetaData
::
ValueType_t
type
(
void
);
QString
shortDescription
(
void
);
QString
longDescription
(
void
);
QVariant
min
(
void
);
QVariant
max
(
void
);
QString
group
(
void
);
signals:
void
componentIdChanged
(
void
);
void
nameChanged
(
void
);
void
valueChanged
(
void
);
void
metaDataChanged
(
void
);
private:
AutoPilotPlugin
*
_autopilotPlugin
;
...
...
src/FactSystem/FactSystem.cc
View file @
b6b24a16
...
...
@@ -40,7 +40,7 @@ FactSystem::FactSystem(QObject* parent) :
QGCSingleton
(
parent
)
{
qmlRegisterType
<
FactBinder
>
(
_factSystemQmlUri
,
1
,
0
,
"Fact"
);
qmlRegisterUncreatableType
<
VehicleComponent
>
(
_factSystemQmlUri
,
1
,
0
,
"VehicleComponent"
,
"Can only reference
VehicleComponent
"
);
qmlRegisterUncreatableType
<
VehicleComponent
>
(
_factSystemQmlUri
,
1
,
0
,
"VehicleComponent"
,
"Can only reference
, cannot create
"
);
}
FactSystem
::~
FactSystem
()
...
...
src/FactSystem/FactSystemTest.qml
View file @
b6b24a16
...
...
@@ -37,7 +37,7 @@ Item {
// Use specific component id
TextInput
{
objectName
:
"
testControl
"
Fact
{
id
:
fact2
;
name
:
"
COMPONENT_51
"
;
componentId
:
51
}
Fact
{
id
:
fact2
;
name
:
"
COMPONENT_51:51
"
}
text
:
fact2
.
value
onAccepted
:
{
fact2
.
value
=
text
;
}
}
...
...
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