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
2baf67ae
Commit
2baf67ae
authored
Dec 11, 2019
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
c133b717
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
20 deletions
+21
-20
Fact.cc
src/FactSystem/Fact.cc
+1
-1
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+18
-17
FactMetaData.h
src/FactSystem/FactMetaData.h
+2
-2
No files found.
src/FactSystem/Fact.cc
View file @
2baf67ae
...
@@ -519,7 +519,7 @@ int Fact::decimalPlaces(void) const
...
@@ -519,7 +519,7 @@ int Fact::decimalPlaces(void) const
return
_metaData
->
decimalPlaces
();
return
_metaData
->
decimalPlaces
();
}
else
{
}
else
{
qWarning
()
<<
kMissingMetadata
<<
name
();
qWarning
()
<<
kMissingMetadata
<<
name
();
return
FactMetaData
::
d
efaultDecimalPlaces
;
return
FactMetaData
::
kD
efaultDecimalPlaces
;
}
}
}
}
...
...
src/FactSystem/FactMetaData.cc
View file @
2baf67ae
...
@@ -88,7 +88,7 @@ const char* FactMetaData::_qgcRebootRequiredJsonKey = "qgcRebootRequired";
...
@@ -88,7 +88,7 @@ const char* FactMetaData::_qgcRebootRequiredJsonKey = "qgcRebootRequired";
FactMetaData
::
FactMetaData
(
QObject
*
parent
)
FactMetaData
::
FactMetaData
(
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
_type
(
valueTypeInt32
)
,
_type
(
valueTypeInt32
)
,
_decimalPlaces
(
u
nknownDecimalPlaces
)
,
_decimalPlaces
(
kU
nknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
,
_rawDefaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_defaultValueAvailable
(
false
)
,
_rawMax
(
_maxForType
())
,
_rawMax
(
_maxForType
())
...
@@ -112,7 +112,7 @@ FactMetaData::FactMetaData(QObject* parent)
...
@@ -112,7 +112,7 @@ FactMetaData::FactMetaData(QObject* parent)
FactMetaData
::
FactMetaData
(
ValueType_t
type
,
QObject
*
parent
)
FactMetaData
::
FactMetaData
(
ValueType_t
type
,
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
_type
(
type
)
,
_type
(
type
)
,
_decimalPlaces
(
u
nknownDecimalPlaces
)
,
_decimalPlaces
(
kU
nknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
,
_rawDefaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_defaultValueAvailable
(
false
)
,
_rawMax
(
_maxForType
())
,
_rawMax
(
_maxForType
())
...
@@ -142,7 +142,7 @@ FactMetaData::FactMetaData(const FactMetaData& other, QObject* parent)
...
@@ -142,7 +142,7 @@ FactMetaData::FactMetaData(const FactMetaData& other, QObject* parent)
FactMetaData
::
FactMetaData
(
ValueType_t
type
,
const
QString
name
,
QObject
*
parent
)
FactMetaData
::
FactMetaData
(
ValueType_t
type
,
const
QString
name
,
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
_type
(
type
)
,
_type
(
type
)
,
_decimalPlaces
(
u
nknownDecimalPlaces
)
,
_decimalPlaces
(
kU
nknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
,
_rawDefaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_defaultValueAvailable
(
false
)
,
_rawMax
(
_maxForType
())
,
_rawMax
(
_maxForType
())
...
@@ -1023,8 +1023,8 @@ double FactMetaData::cookedIncrement(void) const
...
@@ -1023,8 +1023,8 @@ double FactMetaData::cookedIncrement(void) const
int
FactMetaData
::
decimalPlaces
(
void
)
const
int
FactMetaData
::
decimalPlaces
(
void
)
const
{
{
int
actualDecimalPlaces
=
d
efaultDecimalPlaces
;
int
actualDecimalPlaces
=
kD
efaultDecimalPlaces
;
int
incrementDecimalPlaces
=
u
nknownDecimalPlaces
;
int
incrementDecimalPlaces
=
kU
nknownDecimalPlaces
;
// First determine decimal places from increment
// First determine decimal places from increment
double
increment
=
_rawTranslator
(
this
->
rawIncrement
()).
toDouble
();
double
increment
=
_rawTranslator
(
this
->
rawIncrement
()).
toDouble
();
...
@@ -1041,20 +1041,21 @@ int FactMetaData::decimalPlaces(void) const
...
@@ -1041,20 +1041,21 @@ int FactMetaData::decimalPlaces(void) const
}
}
}
}
// Correct decimal places is the larger of the two, increment or meta data value
if
(
_decimalPlaces
==
kUnknownDecimalPlaces
)
{
if
(
incrementDecimalPlaces
!=
unknownDecimalPlaces
&&
_decimalPlaces
==
unknownDecimalPlaces
)
{
if
(
incrementDecimalPlaces
!=
kUnknownDecimalPlaces
)
{
actualDecimalPlaces
=
incrementDecimalPlaces
;
actualDecimalPlaces
=
incrementDecimalPlaces
;
}
else
{
}
else
{
// Adjust decimal places for cooked translation
// Adjust decimal places for cooked translation
int
settingsDecimalPlaces
=
_decimalPlaces
==
unknownDecimalPlaces
?
defaultDecimalPlaces
:
_decimalPlaces
;
int
settingsDecimalPlaces
=
_decimalPlaces
==
kUnknownDecimalPlaces
?
kDefaultDecimalPlaces
:
_decimalPlaces
;
double
ctest
=
_rawTranslator
(
1.0
).
toDouble
();
double
ctest
=
_rawTranslator
(
1.0
).
toDouble
();
settingsDecimalPlaces
+=
-
log10
(
ctest
);
settingsDecimalPlaces
=
qMin
(
25
,
settingsDecimalPlaces
);
settingsDecimalPlaces
+=
-
log10
(
ctest
);
settingsDecimalPlaces
=
qMax
(
0
,
settingsDecimalPlaces
);
actualDecimalPlaces
=
qMax
(
settingsDecimalPlaces
,
incrementDecimalPlaces
);
settingsDecimalPlaces
=
qMin
(
25
,
settingsDecimalPlaces
);
settingsDecimalPlaces
=
qMax
(
0
,
settingsDecimalPlaces
);
}
}
else
{
actualDecimalPlaces
=
_decimalPlaces
;
}
}
return
actualDecimalPlaces
;
return
actualDecimalPlaces
;
...
...
src/FactSystem/FactMetaData.h
View file @
2baf67ae
...
@@ -166,8 +166,8 @@ public:
...
@@ -166,8 +166,8 @@ public:
/// @returns false: Convertion failed
/// @returns false: Convertion failed
bool
clampValue
(
const
QVariant
&
cookedValue
,
QVariant
&
typedValue
);
bool
clampValue
(
const
QVariant
&
cookedValue
,
QVariant
&
typedValue
);
static
const
int
d
efaultDecimalPlaces
=
3
;
///< Default value for decimal places if not specified/known
static
const
int
kD
efaultDecimalPlaces
=
3
;
///< Default value for decimal places if not specified/known
static
const
int
u
nknownDecimalPlaces
=
-
1
;
///< Number of decimal places to specify is not known
static
const
int
kU
nknownDecimalPlaces
=
-
1
;
///< Number of decimal places to specify is not known
static
ValueType_t
stringToType
(
const
QString
&
typeString
,
bool
&
unknownType
);
static
ValueType_t
stringToType
(
const
QString
&
typeString
,
bool
&
unknownType
);
static
size_t
typeToSize
(
ValueType_t
type
);
static
size_t
typeToSize
(
ValueType_t
type
);
...
...
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