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
b33fb23e
Commit
b33fb23e
authored
Dec 29, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bit mask meta data support
parent
3756beb8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
7 deletions
+61
-7
Fact.cc
src/FactSystem/Fact.cc
+20
-0
Fact.h
src/FactSystem/Fact.h
+7
-1
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+26
-6
FactMetaData.h
src/FactSystem/FactMetaData.h
+8
-0
No files found.
src/FactSystem/Fact.cc
View file @
b33fb23e
...
...
@@ -223,6 +223,26 @@ QVariantList Fact::enumValues(void) const
}
}
QStringList
Fact
::
bitmaskStrings
(
void
)
const
{
if
(
_metaData
)
{
return
_metaData
->
bitmaskStrings
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QStringList
();
}
}
QVariantList
Fact
::
bitmaskValues
(
void
)
const
{
if
(
_metaData
)
{
return
_metaData
->
bitmaskValues
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QVariantList
();
}
}
QString
Fact
::
_variantToString
(
const
QVariant
&
variant
)
const
{
QString
valueString
;
...
...
src/FactSystem/Fact.h
View file @
b33fb23e
...
...
@@ -47,6 +47,8 @@ public:
const
Fact
&
operator
=
(
const
Fact
&
other
);
Q_PROPERTY
(
int
componentId
READ
componentId
CONSTANT
)
Q_PROPERTY
(
QStringList
bitmaskStrings
READ
bitmaskStrings
NOTIFY
bitmaskStringsChanged
)
Q_PROPERTY
(
QVariantList
bitmaskValues
READ
bitmaskValues
NOTIFY
bitmaskValuesChanged
)
Q_PROPERTY
(
int
decimalPlaces
READ
decimalPlaces
CONSTANT
)
Q_PROPERTY
(
QVariant
defaultValue
READ
cookedDefaultValue
CONSTANT
)
Q_PROPERTY
(
QString
defaultValueString
READ
cookedDefaultValueString
CONSTANT
)
...
...
@@ -74,7 +76,7 @@ public:
/// Convert and validate value
/// @param convertOnly true: validate type conversion only, false: validate against meta data as well
Q_INVOKABLE
QString
validate
(
const
QString
&
cookedValue
,
bool
convertOnly
);
QVariant
cookedValue
(
void
)
const
;
/// Value after translation
QVariant
rawValue
(
void
)
const
{
return
_rawValue
;
}
/// value prior to translation, careful
int
componentId
(
void
)
const
;
...
...
@@ -83,6 +85,8 @@ public:
QVariant
cookedDefaultValue
(
void
)
const
;
bool
defaultValueAvailable
(
void
)
const
;
QString
cookedDefaultValueString
(
void
)
const
;
QStringList
bitmaskStrings
(
void
)
const
;
QVariantList
bitmaskValues
(
void
)
const
;
int
enumIndex
(
void
);
// This is not const, since an unknown value can modify the enum lists
QStringList
enumStrings
(
void
)
const
;
QString
enumStringValue
(
void
);
// This is not const, since an unknown value can modify the enum lists
...
...
@@ -125,6 +129,8 @@ public:
void
_setName
(
const
QString
&
name
)
{
_name
=
name
;
}
signals:
void
bitmaskStringsChanged
(
void
);
void
bitmaskValuesChanged
(
void
);
void
enumStringsChanged
(
void
);
void
enumValuesChanged
(
void
);
...
...
src/FactSystem/FactMetaData.cc
View file @
b33fb23e
...
...
@@ -83,6 +83,8 @@ const FactMetaData& FactMetaData::operator=(const FactMetaData& other)
_decimalPlaces
=
other
.
_decimalPlaces
;
_rawDefaultValue
=
other
.
_rawDefaultValue
;
_defaultValueAvailable
=
other
.
_defaultValueAvailable
;
_bitmaskStrings
=
other
.
_bitmaskStrings
;
_bitmaskValues
=
other
.
_bitmaskValues
;
_enumStrings
=
other
.
_enumStrings
;
_enumValues
=
other
.
_enumValues
;
_group
=
other
.
_group
;
...
...
@@ -306,6 +308,24 @@ bool FactMetaData::convertAndValidateCooked(const QVariant& cookedValue, bool co
return
convertOk
&&
errorString
.
isEmpty
();
}
void
FactMetaData
::
setBitmaskInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
)
{
if
(
strings
.
count
()
!=
values
.
count
())
{
qWarning
()
<<
"Count mismatch strings:values"
<<
strings
.
count
()
<<
values
.
count
();
return
;
}
_bitmaskStrings
=
strings
;
_bitmaskValues
=
values
;
_setBuiltInTranslator
();
}
void
FactMetaData
::
addBitmaskInfo
(
const
QString
&
name
,
const
QVariant
&
value
)
{
_bitmaskStrings
<<
name
;
_bitmaskValues
<<
value
;
}
void
FactMetaData
::
setEnumInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
)
{
if
(
strings
.
count
()
!=
values
.
count
())
{
...
...
@@ -318,6 +338,12 @@ void FactMetaData::setEnumInfo(const QStringList& strings, const QVariantList& v
_setBuiltInTranslator
();
}
void
FactMetaData
::
addEnumInfo
(
const
QString
&
name
,
const
QVariant
&
value
)
{
_enumStrings
<<
name
;
_enumValues
<<
value
;
}
void
FactMetaData
::
setTranslators
(
Translator
rawTranslator
,
Translator
cookedTranslator
)
{
_rawTranslator
=
rawTranslator
;
...
...
@@ -342,12 +368,6 @@ void FactMetaData::_setBuiltInTranslator(void)
}
}
void
FactMetaData
::
addEnumInfo
(
const
QString
&
name
,
const
QVariant
&
value
)
{
_enumStrings
<<
name
;
_enumValues
<<
value
;
}
QVariant
FactMetaData
::
_degreesToRadians
(
const
QVariant
&
degrees
)
{
return
QVariant
(
degrees
.
toDouble
()
*
(
M_PI
/
180.0
));
...
...
src/FactSystem/FactMetaData.h
View file @
b33fb23e
...
...
@@ -64,6 +64,8 @@ public:
QVariant
rawDefaultValue
(
void
)
const
;
QVariant
cookedDefaultValue
(
void
)
const
{
return
_rawTranslator
(
rawDefaultValue
());
}
bool
defaultValueAvailable
(
void
)
const
{
return
_defaultValueAvailable
;
}
QStringList
bitmaskStrings
(
void
)
const
{
return
_bitmaskStrings
;
}
QVariantList
bitmaskValues
(
void
)
const
{
return
_bitmaskValues
;
}
QStringList
enumStrings
(
void
)
const
{
return
_enumStrings
;
}
QVariantList
enumValues
(
void
)
const
{
return
_enumValues
;
}
QString
group
(
void
)
const
{
return
_group
;
}
...
...
@@ -83,11 +85,15 @@ public:
Translator
rawTranslator
(
void
)
const
{
return
_rawTranslator
;
}
Translator
cookedTranslator
(
void
)
const
{
return
_cookedTranslator
;
}
/// Used to add new values to the bitmask lists after the meta data has been loaded
void
addBitmaskInfo
(
const
QString
&
name
,
const
QVariant
&
value
);
/// Used to add new values to the enum lists after the meta data has been loaded
void
addEnumInfo
(
const
QString
&
name
,
const
QVariant
&
value
);
void
setDecimalPlaces
(
int
decimalPlaces
)
{
_decimalPlaces
=
decimalPlaces
;
}
void
setRawDefaultValue
(
const
QVariant
&
rawDefaultValue
);
void
setBitmaskInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
);
void
setEnumInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
);
void
setGroup
(
const
QString
&
group
)
{
_group
=
group
;
}
void
setLongDescription
(
const
QString
&
longDescription
)
{
_longDescription
=
longDescription
;}
...
...
@@ -128,6 +134,8 @@ private:
int
_decimalPlaces
;
QVariant
_rawDefaultValue
;
bool
_defaultValueAvailable
;
QStringList
_bitmaskStrings
;
QVariantList
_bitmaskValues
;
QStringList
_enumStrings
;
QVariantList
_enumValues
;
QString
_group
;
...
...
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