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
00e49321
Unverified
Commit
00e49321
authored
Apr 30, 2018
by
Don Gagne
Committed by
GitHub
Apr 30, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6388 from bluerobotics/units-fix-rebase
UnitsSettings: rework/bugfix metadata translators setup
parents
023d517a
fc86213a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
16 deletions
+50
-16
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+46
-12
FactMetaData.h
src/FactSystem/FactMetaData.h
+2
-2
BatteryFact.json
src/Vehicle/BatteryFact.json
+2
-2
No files found.
src/FactSystem/FactMetaData.cc
View file @
00e49321
...
...
@@ -616,7 +616,7 @@ void FactMetaData::setBuiltInTranslator(void)
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgBuiltInTranslations
)
/
sizeof
(
_rgBuiltInTranslations
[
0
]);
i
++
)
{
const
BuiltInTranslation_s
*
pBuiltInTranslation
=
&
_rgBuiltInTranslations
[
i
];
if
(
pBuiltInTranslation
->
rawUnits
==
_rawUnits
.
toLower
())
{
if
(
pBuiltInTranslation
->
rawUnits
.
toLower
()
==
_rawUnits
.
toLower
())
{
_cookedUnits
=
pBuiltInTranslation
->
cookedUnits
;
setTranslators
(
pBuiltInTranslation
->
rawTranslator
,
pBuiltInTranslation
->
cookedTranslator
);
return
;
...
...
@@ -875,13 +875,33 @@ void FactMetaData::_setAppSettingsTranslators(void)
if
(
!
_enumStrings
.
count
()
&&
(
type
()
==
valueTypeDouble
||
type
()
==
valueTypeFloat
))
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgAppSettingsTranslations
)
/
sizeof
(
_rgAppSettingsTranslations
[
0
]);
i
++
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
&
_rgAppSettingsTranslations
[
i
];
if
(
pAppSettingsTranslation
->
rawUnits
==
_rawUnits
.
toLower
()
&&
(
(
pAppSettingsTranslation
->
unitType
==
UnitTemperature
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
temperatureUnits
()
->
rawValue
().
toUInt
())
||
(
pAppSettingsTranslation
->
unitType
==
UnitSpeed
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
speedUnits
()
->
rawValue
().
toUInt
())
||
(
pAppSettingsTranslation
->
unitType
==
UnitDistance
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
distanceUnits
()
->
rawValue
().
toUInt
())
||
(
pAppSettingsTranslation
->
unitType
==
UnitArea
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
areaUnits
()
->
rawValue
().
toUInt
())))
{
_cookedUnits
=
pAppSettingsTranslation
->
cookedUnits
;
if
(
_rawUnits
.
toLower
()
!=
pAppSettingsTranslation
->
rawUnits
.
toLower
())
{
continue
;
}
UnitsSettings
*
settings
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
();
uint
settingsUnits
=
0
;
switch
(
pAppSettingsTranslation
->
unitType
)
{
case
UnitDistance
:
settingsUnits
=
settings
->
distanceUnits
()
->
rawValue
().
toUInt
();
break
;
case
UnitSpeed
:
settingsUnits
=
settings
->
speedUnits
()
->
rawValue
().
toUInt
();
break
;
case
UnitArea
:
settingsUnits
=
settings
->
areaUnits
()
->
rawValue
().
toUInt
();
break
;
case
UnitTemperature
:
settingsUnits
=
settings
->
temperatureUnits
()
->
rawValue
().
toUInt
();
break
;
default:
break
;
}
if
(
settingsUnits
==
pAppSettingsTranslation
->
unitOption
)
{
_cookedUnits
=
pAppSettingsTranslation
->
cookedUnits
;
setTranslators
(
pAppSettingsTranslation
->
rawTranslator
,
pAppSettingsTranslation
->
cookedTranslator
);
return
;
}
...
...
@@ -893,8 +913,15 @@ const FactMetaData::AppSettingsTranslation_s* FactMetaData::_findAppSettingsDist
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgAppSettingsTranslations
)
/
sizeof
(
_rgAppSettingsTranslations
[
0
]);
i
++
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
&
_rgAppSettingsTranslations
[
i
];
if
(
pAppSettingsTranslation
->
rawUnits
==
rawUnits
.
toLower
()
&&
(
pAppSettingsTranslation
->
unitType
==
UnitDistance
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
distanceUnits
()
->
rawValue
().
toUInt
()))
{
if
(
rawUnits
.
toLower
()
!=
pAppSettingsTranslation
->
rawUnits
.
toLower
())
{
continue
;
}
uint
settingsUnits
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
areaUnits
()
->
rawValue
().
toUInt
();
if
(
pAppSettingsTranslation
->
unitType
==
UnitDistance
&&
pAppSettingsTranslation
->
unitOption
==
settingsUnits
)
{
return
pAppSettingsTranslation
;
}
}
...
...
@@ -905,8 +932,15 @@ const FactMetaData::AppSettingsTranslation_s* FactMetaData::_findAppSettingsArea
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgAppSettingsTranslations
)
/
sizeof
(
_rgAppSettingsTranslations
[
0
]);
i
++
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
&
_rgAppSettingsTranslations
[
i
];
if
(
pAppSettingsTranslation
->
rawUnits
==
rawUnits
.
toLower
()
&&
(
pAppSettingsTranslation
->
unitType
==
UnitArea
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
areaUnits
()
->
rawValue
().
toUInt
()))
{
if
(
rawUnits
.
toLower
()
!=
pAppSettingsTranslation
->
rawUnits
.
toLower
())
{
continue
;
}
uint
settingsUnits
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
areaUnits
()
->
rawValue
().
toUInt
();
if
(
pAppSettingsTranslation
->
unitType
==
UnitArea
&&
pAppSettingsTranslation
->
unitOption
==
settingsUnits
)
{
return
pAppSettingsTranslation
;
}
}
...
...
src/FactSystem/FactMetaData.h
View file @
00e49321
...
...
@@ -216,7 +216,7 @@ private:
};
struct
AppSettingsTranslation_s
{
const
char
*
rawUnits
;
QString
rawUnits
;
const
char
*
cookedUnits
;
UnitTypes
unitType
;
uint32_t
unitOption
;
...
...
@@ -265,7 +265,7 @@ private:
}
constants
;
struct
BuiltInTranslation_s
{
const
char
*
rawUnits
;
QString
rawUnits
;
const
char
*
cookedUnits
;
Translator
rawTranslator
;
Translator
cookedTranslator
;
...
...
src/Vehicle/BatteryFact.json
View file @
00e49321
...
...
@@ -30,8 +30,8 @@
{
"name"
:
"temperature"
,
"shortDescription"
:
"Temperature"
,
"type"
:
"
int32
"
,
"decimalPlaces"
:
2
,
"type"
:
"
double
"
,
"decimalPlaces"
:
0
,
"units"
:
"C"
},
{
...
...
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