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
8dd3148d
Commit
8dd3148d
authored
Dec 27, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2481 from DonLakeFlyer/AutoTranslation
Automatic raw->cooked translation based on units meta data
parents
de276119
1e613594
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
314 additions
and
161 deletions
+314
-161
Fact.cc
src/FactSystem/Fact.cc
+70
-23
Fact.h
src/FactSystem/Fact.h
+23
-18
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+150
-41
FactMetaData.h
src/FactSystem/FactMetaData.h
+43
-18
ParameterLoader.cc
src/FactSystem/ParameterLoader.cc
+1
-1
APMParameterMetaData.cc
src/FirmwarePlugin/APM/APMParameterMetaData.cc
+6
-6
PX4ParameterMetaData.cc
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
+9
-9
MavCmdInfo.json
src/MissionManager/MavCmdInfo.json
+3
-3
MissionCommands.cc
src/MissionManager/MissionCommands.cc
+0
-3
MissionCommands.h
src/MissionManager/MissionCommands.h
+0
-3
MissionItem.cc
src/MissionManager/MissionItem.cc
+9
-33
MissionItem.h
src/MissionManager/MissionItem.h
+0
-3
No files found.
src/FactSystem/Fact.cc
View file @
8dd3148d
...
...
@@ -80,7 +80,7 @@ void Fact::forceSetRawValue(const QVariant& value)
QVariant
typedValue
;
QString
errorString
;
if
(
_metaData
->
convertAndValidate
(
value
,
true
/* convertOnly */
,
typedValue
,
errorString
))
{
if
(
_metaData
->
convertAndValidate
Raw
(
value
,
true
/* convertOnly */
,
typedValue
,
errorString
))
{
_rawValue
.
setValue
(
typedValue
);
emit
valueChanged
(
cookedValue
());
emit
_containerRawValueChanged
(
rawValue
());
...
...
@@ -96,7 +96,7 @@ void Fact::setRawValue(const QVariant& value)
QVariant
typedValue
;
QString
errorString
;
if
(
_metaData
->
convertAndValidate
(
value
,
true
/* convertOnly */
,
typedValue
,
errorString
))
{
if
(
_metaData
->
convertAndValidate
Raw
(
value
,
true
/* convertOnly */
,
typedValue
,
errorString
))
{
if
(
typedValue
!=
_rawValue
)
{
_rawValue
.
setValue
(
typedValue
);
emit
valueChanged
(
cookedValue
());
...
...
@@ -242,27 +242,45 @@ QString Fact::_variantToString(const QVariant& variant) const
return
valueString
;
}
QString
Fact
::
valueString
(
void
)
const
QString
Fact
::
rawValueString
(
void
)
const
{
return
_variantToString
(
rawValue
());
}
QString
Fact
::
cookedValueString
(
void
)
const
{
return
_variantToString
(
cookedValue
());
}
QVariant
Fact
::
defaultValue
(
void
)
const
QVariant
Fact
::
rawDefaultValue
(
void
)
const
{
if
(
_metaData
)
{
if
(
!
_metaData
->
defaultValueAvailable
())
{
qDebug
()
<<
"Access to unavailable default value"
;
}
return
_metaData
->
rawDefaultValue
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QVariant
(
0
);
}
}
QVariant
Fact
::
cookedDefaultValue
(
void
)
const
{
if
(
_metaData
)
{
if
(
!
_metaData
->
defaultValueAvailable
())
{
qDebug
()
<<
"Access to unavailable default value"
;
}
return
_metaData
->
d
efaultValue
();
return
_metaData
->
cookedD
efaultValue
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QVariant
(
0
);
}
}
QString
Fact
::
d
efaultValueString
(
void
)
const
QString
Fact
::
cookedD
efaultValueString
(
void
)
const
{
return
_variantToString
(
d
efaultValue
());
return
_variantToString
(
cookedD
efaultValue
());
}
FactMetaData
::
ValueType_t
Fact
::
type
(
void
)
const
...
...
@@ -290,44 +308,74 @@ QString Fact::longDescription(void) const
}
}
QString
Fact
::
units
(
void
)
const
QString
Fact
::
rawUnits
(
void
)
const
{
if
(
_metaData
)
{
return
_metaData
->
rawUnits
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QString
();
}
}
QString
Fact
::
cookedUnits
(
void
)
const
{
if
(
_metaData
)
{
return
_metaData
->
u
nits
();
return
_metaData
->
cookedU
nits
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QString
();
}
}
QVariant
Fact
::
m
in
(
void
)
const
QVariant
Fact
::
rawM
in
(
void
)
const
{
if
(
_metaData
)
{
return
_metaData
->
m
in
();
return
_metaData
->
rawM
in
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QVariant
(
0
);
}
}
Q
String
Fact
::
minString
(
void
)
const
Q
Variant
Fact
::
cookedMin
(
void
)
const
{
return
_variantToString
(
min
());
if
(
_metaData
)
{
return
_metaData
->
cookedMin
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QVariant
(
0
);
}
}
QVariant
Fact
::
max
(
void
)
const
QString
Fact
::
cookedMinString
(
void
)
const
{
return
_variantToString
(
cookedMin
());
}
QVariant
Fact
::
rawMax
(
void
)
const
{
if
(
_metaData
)
{
return
_metaData
->
m
ax
();
return
_metaData
->
rawM
ax
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QVariant
(
0
);
}
}
Q
String
Fact
::
maxString
(
void
)
const
Q
Variant
Fact
::
cookedMax
(
void
)
const
{
return
_variantToString
(
max
());
if
(
_metaData
)
{
return
_metaData
->
cookedMax
();
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
return
QVariant
(
0
);
}
}
QString
Fact
::
cookedMaxString
(
void
)
const
{
return
_variantToString
(
cookedMax
());
}
bool
Fact
::
minIsDefaultForType
(
void
)
const
...
...
@@ -372,6 +420,8 @@ QString Fact::group(void) const
void
Fact
::
setMetaData
(
FactMetaData
*
metaData
)
{
// FIXME: Hack to stuff enums into APM parameters, wating on real APM metadata
static
QStringList
apmFlightModeParamList
;
static
QStringList
apmFlightModeEnumStrings
;
static
QVariantList
apmFlightModeEnumValues
;
...
...
@@ -380,8 +430,6 @@ void Fact::setMetaData(FactMetaData* metaData)
static
QStringList
apmChannelOptEnumStrings
;
static
QVariantList
apmChannelOptEnumValues
;
// FIXME: Hack to stuff enums into APM parameters, wating on real APM metadata
if
(
apmFlightModeEnumStrings
.
count
()
==
0
)
{
apmFlightModeParamList
<<
"FLTMODE1"
<<
"FLTMODE2"
<<
"FLTMODE3"
<<
"FLTMODE4"
<<
"FLTMODE5"
<<
"FLTMODE6"
;
apmFlightModeEnumStrings
<<
"Stabilize"
<<
"Acro"
<<
"AltHold"
<<
"Auto"
<<
"Guided"
<<
"Loiter"
<<
"RTL"
<<
"Circle"
...
...
@@ -415,7 +463,7 @@ bool Fact::valueEqualsDefault(void) const
{
if
(
_metaData
)
{
if
(
_metaData
->
defaultValueAvailable
())
{
return
_metaData
->
d
efaultValue
()
==
rawValue
();
return
_metaData
->
rawD
efaultValue
()
==
rawValue
();
}
else
{
return
false
;
}
...
...
@@ -435,14 +483,13 @@ bool Fact::defaultValueAvailable(void) const
}
}
QString
Fact
::
validate
(
const
QString
&
v
alue
,
bool
convertOnly
)
QString
Fact
::
validate
(
const
QString
&
cookedV
alue
,
bool
convertOnly
)
{
if
(
_metaData
)
{
QVariant
typedValue
;
QString
errorString
;
_metaData
->
convertAndValidate
(
v
alue
,
convertOnly
,
typedValue
,
errorString
);
_metaData
->
convertAndValidate
Cooked
(
cookedV
alue
,
convertOnly
,
typedValue
,
errorString
);
return
errorString
;
}
else
{
...
...
src/FactSystem/Fact.h
View file @
8dd3148d
...
...
@@ -48,8 +48,8 @@ public:
Q_PROPERTY
(
int
componentId
READ
componentId
CONSTANT
)
Q_PROPERTY
(
int
decimalPlaces
READ
decimalPlaces
CONSTANT
)
Q_PROPERTY
(
QVariant
defaultValue
READ
defaultValue
CONSTANT
)
Q_PROPERTY
(
QString
defaultValueString
READ
defaultValueString
CONSTANT
)
Q_PROPERTY
(
QVariant
defaultValue
READ
cookedDefaultValue
CONSTANT
)
Q_PROPERTY
(
QString
defaultValueString
READ
cookedDefaultValueString
CONSTANT
)
Q_PROPERTY
(
bool
defaultValueAvailable
READ
defaultValueAvailable
CONSTANT
)
Q_PROPERTY
(
int
enumIndex
READ
enumIndex
WRITE
setEnumIndex
NOTIFY
valueChanged
)
Q_PROPERTY
(
QStringList
enumStrings
READ
enumStrings
NOTIFY
enumStringsChanged
)
...
...
@@ -57,48 +57,53 @@ public:
Q_PROPERTY
(
QVariantList
enumValues
READ
enumValues
NOTIFY
enumValuesChanged
)
Q_PROPERTY
(
QString
group
READ
group
CONSTANT
)
Q_PROPERTY
(
QString
longDescription
READ
longDescription
CONSTANT
)
Q_PROPERTY
(
QVariant
max
READ
max
CONSTANT
)
Q_PROPERTY
(
QString
maxString
READ
maxString
CONSTANT
)
Q_PROPERTY
(
QVariant
max
READ
cookedMax
CONSTANT
)
Q_PROPERTY
(
QString
maxString
READ
cookedMaxString
CONSTANT
)
Q_PROPERTY
(
bool
maxIsDefaultForType
READ
maxIsDefaultForType
CONSTANT
)
Q_PROPERTY
(
QVariant
min
READ
min
CONSTANT
)
Q_PROPERTY
(
QString
minString
READ
minString
CONSTANT
)
Q_PROPERTY
(
QVariant
min
READ
cookedMin
CONSTANT
)
Q_PROPERTY
(
QString
minString
READ
cookedMinString
CONSTANT
)
Q_PROPERTY
(
bool
minIsDefaultForType
READ
minIsDefaultForType
CONSTANT
)
Q_PROPERTY
(
QString
name
READ
name
CONSTANT
)
Q_PROPERTY
(
QString
shortDescription
READ
shortDescription
CONSTANT
)
Q_PROPERTY
(
FactMetaData
::
ValueType_t
type
READ
type
CONSTANT
)
Q_PROPERTY
(
QString
units
READ
units
CONSTANT
)
Q_PROPERTY
(
QString
units
READ
cookedUnits
CONSTANT
)
Q_PROPERTY
(
QVariant
value
READ
cookedValue
WRITE
setCookedValue
NOTIFY
valueChanged
)
Q_PROPERTY
(
bool
valueEqualsDefault
READ
valueEqualsDefault
NOTIFY
valueChanged
)
Q_PROPERTY
(
QVariant
valueString
READ
valueString
NOTIFY
valueChanged
)
Q_PROPERTY
(
QVariant
valueString
READ
cookedValueString
NOTIFY
valueChanged
)
/// Convert and validate value
/// @param convertOnly true: validate type conversion only, false: validate against meta data as well
Q_INVOKABLE
QString
validate
(
const
QString
&
v
alue
,
bool
convertOnly
);
Q_INVOKABLE
QString
validate
(
const
QString
&
cookedV
alue
,
bool
convertOnly
);
QVariant
cookedValue
(
void
)
const
;
/// Value after translation
QVariant
rawValue
(
void
)
const
{
return
_rawValue
;
}
/// value prior to translation, careful
int
componentId
(
void
)
const
;
int
decimalPlaces
(
void
)
const
;
QVariant
defaultValue
(
void
)
const
;
QVariant
rawDefaultValue
(
void
)
const
;
QVariant
cookedDefaultValue
(
void
)
const
;
bool
defaultValueAvailable
(
void
)
const
;
QString
defaultValueString
(
void
)
const
;
QString
cookedDefaultValueString
(
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
QVariantList
enumValues
(
void
)
const
;
QString
group
(
void
)
const
;
QString
longDescription
(
void
)
const
;
QVariant
max
(
void
)
const
;
QString
maxString
(
void
)
const
;
QVariant
rawMax
(
void
)
const
;
QVariant
cookedMax
(
void
)
const
;
QString
cookedMaxString
(
void
)
const
;
bool
maxIsDefaultForType
(
void
)
const
;
QVariant
min
(
void
)
const
;
QString
minString
(
void
)
const
;
QVariant
rawMin
(
void
)
const
;
QVariant
cookedMin
(
void
)
const
;
QString
cookedMinString
(
void
)
const
;
bool
minIsDefaultForType
(
void
)
const
;
QString
name
(
void
)
const
;
QVariant
rawValue
(
void
)
const
{
return
_rawValue
;
}
/// value prior to translation, careful
QString
shortDescription
(
void
)
const
;
FactMetaData
::
ValueType_t
type
(
void
)
const
;
QString
units
(
void
)
const
;
QString
valueString
(
void
)
const
;
QString
cookedUnits
(
void
)
const
;
QString
rawUnits
(
void
)
const
;
QString
rawValueString
(
void
)
const
;
QString
cookedValueString
(
void
)
const
;
bool
valueEqualsDefault
(
void
)
const
;
void
setRawValue
(
const
QVariant
&
value
);
...
...
src/FactSystem/FactMetaData.cc
View file @
8dd3148d
...
...
@@ -31,20 +31,26 @@
#include <QDebug>
#include <limits>
#include <cmath>
const
FactMetaData
::
BuiltInTranslation_s
FactMetaData
::
_rgBuildInTranslations
[]
=
{
{
"centi-degrees"
,
"degrees"
,
FactMetaData
::
_centiDegreesToDegrees
,
FactMetaData
::
_degreesToCentiDegrees
},
{
"radians"
,
"degrees"
,
FactMetaData
::
_radiansToDegrees
,
FactMetaData
::
_degreesToRadians
},
};
FactMetaData
::
FactMetaData
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_type
(
valueTypeInt32
)
,
_decimalPlaces
(
defaultDecimalPlaces
)
,
_
d
efaultValue
(
0
)
,
_
rawD
efaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_group
(
"*Default Group"
)
,
_
m
ax
(
_maxForType
())
,
_
rawM
ax
(
_maxForType
())
,
_maxIsDefaultForType
(
true
)
,
_
m
in
(
_minForType
())
,
_
rawM
in
(
_minForType
())
,
_minIsDefaultForType
(
true
)
,
_rawTranslator
(
defaultTranslator
)
,
_cookedTranslator
(
defaultTranslator
)
,
_rawTranslator
(
_
defaultTranslator
)
,
_cookedTranslator
(
_
defaultTranslator
)
{
}
...
...
@@ -53,15 +59,15 @@ FactMetaData::FactMetaData(ValueType_t type, QObject* parent)
:
QObject
(
parent
)
,
_type
(
type
)
,
_decimalPlaces
(
defaultDecimalPlaces
)
,
_
d
efaultValue
(
0
)
,
_
rawD
efaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_group
(
"*Default Group"
)
,
_
m
ax
(
_maxForType
())
,
_
rawM
ax
(
_maxForType
())
,
_maxIsDefaultForType
(
true
)
,
_
m
in
(
_minForType
())
,
_
rawM
in
(
_minForType
())
,
_minIsDefaultForType
(
true
)
,
_rawTranslator
(
defaultTranslator
)
,
_cookedTranslator
(
defaultTranslator
)
,
_rawTranslator
(
_
defaultTranslator
)
,
_cookedTranslator
(
_
defaultTranslator
)
{
}
...
...
@@ -75,66 +81,67 @@ FactMetaData::FactMetaData(const FactMetaData& other, QObject* parent)
const
FactMetaData
&
FactMetaData
::
operator
=
(
const
FactMetaData
&
other
)
{
_decimalPlaces
=
other
.
_decimalPlaces
;
_
defaultValue
=
other
.
_d
efaultValue
;
_
rawDefaultValue
=
other
.
_rawD
efaultValue
;
_defaultValueAvailable
=
other
.
_defaultValueAvailable
;
_enumStrings
=
other
.
_enumStrings
;
_enumValues
=
other
.
_enumValues
;
_group
=
other
.
_group
;
_longDescription
=
other
.
_longDescription
;
_
max
=
other
.
_m
ax
;
_
rawMax
=
other
.
_rawM
ax
;
_maxIsDefaultForType
=
other
.
_maxIsDefaultForType
;
_
min
=
other
.
_m
in
;
_
rawMin
=
other
.
_rawM
in
;
_minIsDefaultForType
=
other
.
_minIsDefaultForType
;
_name
=
other
.
_name
;
_shortDescription
=
other
.
_shortDescription
;
_type
=
other
.
_type
;
_units
=
other
.
_units
;
_rawUnits
=
other
.
_rawUnits
;
_cookedUnits
=
other
.
_cookedUnits
;
_rawTranslator
=
other
.
_rawTranslator
;
_cookedTranslator
=
other
.
_cookedTranslator
;
return
*
this
;
}
QVariant
FactMetaData
::
d
efaultValue
(
void
)
const
QVariant
FactMetaData
::
rawD
efaultValue
(
void
)
const
{
if
(
_defaultValueAvailable
)
{
return
_
d
efaultValue
;
return
_
rawD
efaultValue
;
}
else
{
qWarning
()
<<
"Attempt to access unavailable default value"
;
return
QVariant
(
0
);
}
}
void
FactMetaData
::
set
DefaultValue
(
const
QVariant
&
d
efaultValue
)
void
FactMetaData
::
set
RawDefaultValue
(
const
QVariant
&
rawD
efaultValue
)
{
if
(
_
min
<=
defaultValue
&&
defaultValue
<=
_m
ax
)
{
_
defaultValue
=
d
efaultValue
;
if
(
_
rawMin
<=
rawDefaultValue
&&
rawDefaultValue
<=
_rawM
ax
)
{
_
rawDefaultValue
=
rawD
efaultValue
;
_defaultValueAvailable
=
true
;
}
else
{
qWarning
()
<<
"Attempt to set default value which is outside min/max range"
;
}
}
void
FactMetaData
::
set
Min
(
const
QVariant
&
m
in
)
void
FactMetaData
::
set
RawMin
(
const
QVariant
&
rawM
in
)
{
if
(
m
in
>
_minForType
())
{
_
min
=
m
in
;
if
(
rawM
in
>
_minForType
())
{
_
rawMin
=
rawM
in
;
_minIsDefaultForType
=
false
;
}
else
{
qWarning
()
<<
"Attempt to set min below allowable value for fact: "
<<
name
()
<<
", value attempted: "
<<
m
in
<<
", value attempted: "
<<
rawM
in
<<
", type: "
<<
type
()
<<
", min for type: "
<<
_minForType
();
_
m
in
=
_minForType
();
_
rawM
in
=
_minForType
();
}
}
void
FactMetaData
::
set
Max
(
const
QVariant
&
m
ax
)
void
FactMetaData
::
set
RawMax
(
const
QVariant
&
rawM
ax
)
{
if
(
m
ax
>
_maxForType
())
{
if
(
rawM
ax
>
_maxForType
())
{
qWarning
()
<<
"Attempt to set max above allowable value"
;
_
m
ax
=
_maxForType
();
_
rawM
ax
=
_maxForType
();
}
else
{
_
max
=
m
ax
;
_
rawMax
=
rawM
ax
;
_maxIsDefaultForType
=
false
;
}
}
...
...
@@ -189,7 +196,7 @@ QVariant FactMetaData::_maxForType(void) const
return
QVariant
();
}
bool
FactMetaData
::
convertAndValidate
(
const
QVariant
&
v
alue
,
bool
convertOnly
,
QVariant
&
typedValue
,
QString
&
errorString
)
bool
FactMetaData
::
convertAndValidate
Raw
(
const
QVariant
&
rawV
alue
,
bool
convertOnly
,
QVariant
&
typedValue
,
QString
&
errorString
)
{
bool
convertOk
=
false
;
...
...
@@ -199,10 +206,10 @@ bool FactMetaData::convertAndValidate(const QVariant& value, bool convertOnly, Q
case
FactMetaData
:
:
valueTypeInt8
:
case
FactMetaData
:
:
valueTypeInt16
:
case
FactMetaData
:
:
valueTypeInt32
:
typedValue
=
QVariant
(
v
alue
.
toInt
(
&
convertOk
));
typedValue
=
QVariant
(
rawV
alue
.
toInt
(
&
convertOk
));
if
(
!
convertOnly
&&
convertOk
)
{
if
(
min
()
>
typedValue
||
typedValue
>
m
ax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
min
().
toInt
()).
arg
(
m
ax
().
toInt
());
if
(
rawMin
()
>
typedValue
||
typedValue
>
rawM
ax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
cookedMin
().
toInt
()).
arg
(
cookedM
ax
().
toInt
());
}
}
break
;
...
...
@@ -210,28 +217,28 @@ bool FactMetaData::convertAndValidate(const QVariant& value, bool convertOnly, Q
case
FactMetaData
:
:
valueTypeUint8
:
case
FactMetaData
:
:
valueTypeUint16
:
case
FactMetaData
:
:
valueTypeUint32
:
typedValue
=
QVariant
(
v
alue
.
toUInt
(
&
convertOk
));
typedValue
=
QVariant
(
rawV
alue
.
toUInt
(
&
convertOk
));
if
(
!
convertOnly
&&
convertOk
)
{
if
(
min
()
>
typedValue
||
typedValue
>
m
ax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
min
().
toUInt
()).
arg
(
m
ax
().
toUInt
());
if
(
rawMin
()
>
typedValue
||
typedValue
>
rawM
ax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
cookedMin
().
toUInt
()).
arg
(
cookedM
ax
().
toUInt
());
}
}
break
;
case
FactMetaData
:
:
valueTypeFloat
:
typedValue
=
QVariant
(
v
alue
.
toFloat
(
&
convertOk
));
typedValue
=
QVariant
(
rawV
alue
.
toFloat
(
&
convertOk
));
if
(
!
convertOnly
&&
convertOk
)
{
if
(
min
()
>
typedValue
||
typedValue
>
m
ax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
min
().
toFloat
()).
arg
(
m
ax
().
toFloat
());
if
(
rawMin
()
>
typedValue
||
typedValue
>
rawM
ax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
cookedMin
().
toFloat
()).
arg
(
cookedM
ax
().
toFloat
());
}
}
break
;
case
FactMetaData
:
:
valueTypeDouble
:
typedValue
=
QVariant
(
v
alue
.
toDouble
(
&
convertOk
));
typedValue
=
QVariant
(
rawV
alue
.
toDouble
(
&
convertOk
));
if
(
!
convertOnly
&&
convertOk
)
{
if
(
min
()
>
typedValue
||
typedValue
>
m
ax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
min
().
toDouble
()).
arg
(
m
ax
().
toDouble
());
if
(
rawMin
()
>
typedValue
||
typedValue
>
rawM
ax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
cookedMin
().
toDouble
()).
arg
(
cookedM
ax
().
toDouble
());
}
}
break
;
...
...
@@ -244,6 +251,61 @@ bool FactMetaData::convertAndValidate(const QVariant& value, bool convertOnly, Q
return
convertOk
&&
errorString
.
isEmpty
();
}
bool
FactMetaData
::
convertAndValidateCooked
(
const
QVariant
&
cookedValue
,
bool
convertOnly
,
QVariant
&
typedValue
,
QString
&
errorString
)
{
bool
convertOk
=
false
;
errorString
.
clear
();
switch
(
type
())
{
case
FactMetaData
:
:
valueTypeInt8
:
case
FactMetaData
:
:
valueTypeInt16
:
case
FactMetaData
:
:
valueTypeInt32
:
typedValue
=
QVariant
(
cookedValue
.
toInt
(
&
convertOk
));
if
(
!
convertOnly
&&
convertOk
)
{
if
(
cookedMin
()
>
typedValue
||
typedValue
>
cookedMax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
cookedMin
().
toInt
()).
arg
(
cookedMax
().
toInt
());
}
}
break
;
case
FactMetaData
:
:
valueTypeUint8
:
case
FactMetaData
:
:
valueTypeUint16
:
case
FactMetaData
:
:
valueTypeUint32
:
typedValue
=
QVariant
(
cookedValue
.
toUInt
(
&
convertOk
));
if
(
!
convertOnly
&&
convertOk
)
{
if
(
cookedMin
()
>
typedValue
||
typedValue
>
cookedMax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
cookedMin
().
toUInt
()).
arg
(
cookedMax
().
toUInt
());
}
}
break
;
case
FactMetaData
:
:
valueTypeFloat
:
typedValue
=
QVariant
(
cookedValue
.
toFloat
(
&
convertOk
));
if
(
!
convertOnly
&&
convertOk
)
{
if
(
cookedMin
()
>
typedValue
||
typedValue
>
cookedMax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
cookedMin
().
toFloat
()).
arg
(
cookedMax
().
toFloat
());
}
}
break
;
case
FactMetaData
:
:
valueTypeDouble
:
typedValue
=
QVariant
(
cookedValue
.
toDouble
(
&
convertOk
));
if
(
!
convertOnly
&&
convertOk
)
{
if
(
cookedMin
()
>
typedValue
||
typedValue
>
cookedMax
())
{
errorString
=
QString
(
"Value must be within %1 and %2"
).
arg
(
cookedMin
().
toDouble
()).
arg
(
cookedMax
().
toDouble
());
}
}
break
;
}
if
(
!
convertOk
)
{
errorString
+=
"Invalid number"
;
}
return
convertOk
&&
errorString
.
isEmpty
();
}
void
FactMetaData
::
setEnumInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
)
{
if
(
strings
.
count
()
!=
values
.
count
())
{
...
...
@@ -253,6 +315,7 @@ void FactMetaData::setEnumInfo(const QStringList& strings, const QVariantList& v
_enumStrings
=
strings
;
_enumValues
=
values
;
_setBuiltInTranslator
();
}
void
FactMetaData
::
setTranslators
(
Translator
rawTranslator
,
Translator
cookedTranslator
)
...
...
@@ -261,8 +324,54 @@ void FactMetaData::setTranslators(Translator rawTranslator, Translator cookedTra
_cookedTranslator
=
cookedTranslator
;
}
void
FactMetaData
::
_setBuiltInTranslator
(
void
)
{
if
(
_enumStrings
.
count
())
{
// No translation if enum
setTranslators
(
_defaultTranslator
,
_defaultTranslator
);
_cookedUnits
=
_rawUnits
;
}
else
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgBuildInTranslations
)
/
sizeof
(
_rgBuildInTranslations
[
0
]);
i
++
)
{
const
BuiltInTranslation_s
*
pBuiltInTranslation
=
&
_rgBuildInTranslations
[
i
];
if
(
pBuiltInTranslation
->
rawUnits
==
_rawUnits
.
toLower
())
{
_cookedUnits
=
pBuiltInTranslation
->
cookedUnits
;
setTranslators
(
pBuiltInTranslation
->
rawTranslator
,
pBuiltInTranslation
->
cookedTranslator
);
}
}
}
}
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
));
}
QVariant
FactMetaData
::
_radiansToDegrees
(
const
QVariant
&
radians
)
{
return
QVariant
(
radians
.
toDouble
()
*
(
180
/
M_PI
));
}
QVariant
FactMetaData
::
_centiDegreesToDegrees
(
const
QVariant
&
centiDegrees
)
{
return
QVariant
(
centiDegrees
.
toFloat
()
/
100.0
f
);
}
QVariant
FactMetaData
::
_degreesToCentiDegrees
(
const
QVariant
&
degrees
)
{
return
QVariant
((
unsigned
int
)(
degrees
.
toFloat
()
*
100.0
f
));
}
void
FactMetaData
::
setRawUnits
(
const
QString
&
rawUnits
)
{
_rawUnits
=
rawUnits
;
_cookedUnits
=
rawUnits
;
_setBuiltInTranslator
();
}
src/FactSystem/FactMetaData.h
View file @
8dd3148d
...
...
@@ -61,20 +61,24 @@ public:
const
FactMetaData
&
operator
=
(
const
FactMetaData
&
other
);
int
decimalPlaces
(
void
)
const
{
return
_decimalPlaces
;
}
QVariant
defaultValue
(
void
)
const
;
QVariant
rawDefaultValue
(
void
)
const
;
QVariant
cookedDefaultValue
(
void
)
const
{
return
_rawTranslator
(
rawDefaultValue
());
}
bool
defaultValueAvailable
(
void
)
const
{
return
_defaultValueAvailable
;
}
QStringList
enumStrings
(
void
)
const
{
return
_enumStrings
;
}
QVariantList
enumValues
(
void
)
const
{
return
_enumValues
;
}
QString
group
(
void
)
const
{
return
_group
;
}
QString
longDescription
(
void
)
const
{
return
_longDescription
;}
QVariant
max
(
void
)
const
{
return
_max
;
}
QVariant
rawMax
(
void
)
const
{
return
_rawMax
;
}
QVariant
cookedMax
(
void
)
const
{
return
_rawTranslator
(
_rawMax
);
}
bool
maxIsDefaultForType
(
void
)
const
{
return
_maxIsDefaultForType
;
}
QVariant
min
(
void
)
const
{
return
_min
;
}
QVariant
rawMin
(
void
)
const
{
return
_rawMin
;
}
QVariant
cookedMin
(
void
)
const
{
return
_rawTranslator
(
_rawMin
);
}
bool
minIsDefaultForType
(
void
)
const
{
return
_minIsDefaultForType
;
}
QString
name
(
void
)
const
{
return
_name
;
}
QString
shortDescription
(
void
)
const
{
return
_shortDescription
;
}
ValueType_t
type
(
void
)
const
{
return
_type
;
}
QString
units
(
void
)
const
{
return
_units
;
}
QString
rawUnits
(
void
)
const
{
return
_rawUnits
;
}
QString
cookedUnits
(
void
)
const
{
return
_cookedUnits
;
}
Translator
rawTranslator
(
void
)
const
{
return
_rawTranslator
;
}
Translator
cookedTranslator
(
void
)
const
{
return
_cookedTranslator
;
}
...
...
@@ -83,50 +87,71 @@ public:
void
addEnumInfo
(
const
QString
&
name
,
const
QVariant
&
value
);
void
setDecimalPlaces
(
int
decimalPlaces
)
{
_decimalPlaces
=
decimalPlaces
;
}
void
set
DefaultValue
(
const
QVariant
&
d
efaultValue
);
void
set
RawDefaultValue
(
const
QVariant
&
rawD
efaultValue
);
void
setEnumInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
);
void
setGroup
(
const
QString
&
group
)
{
_group
=
group
;
}
void
setLongDescription
(
const
QString
&
longDescription
)
{
_longDescription
=
longDescription
;}
void
set
Max
(
const
QVariant
&
m
ax
);
void
set
Min
(
const
QVariant
&
max
);
void
set
RawMax
(
const
QVariant
&
rawM
ax
);
void
set
RawMin
(
const
QVariant
&
rawMin
);
void
setName
(
const
QString
&
name
)
{
_name
=
name
;
}
void
setShortDescription
(
const
QString
&
shortDescription
)
{
_shortDescription
=
shortDescription
;
}
void
set
Units
(
const
QString
&
units
)
{
_units
=
units
;
}
void
set
RawUnits
(
const
QString
&
rawUnits
);
void
setTranslators
(
Translator
rawTranslator
,
Translator
cookedTranslator
);
static
QVariant
defaultTranslator
(
const
QVariant
&
from
)
{
return
from
;
}
/// Converts the specified value, validating against meta data
/// @param
v
alue Value to convert, can be string
/// Converts the specified
raw
value, validating against meta data
/// @param
rawV
alue Value to convert, can be string
/// @param convertOnly true: convert to correct type only, do not validate against meta data
/// @param typeValue Converted value, correctly typed
/// @param errorString Error string if convert fails
/// @param errorString Error string if convert fails
, values are cooked values since user visible
/// @returns false: Convert failed, errorString set
bool
convertAndValidate
(
const
QVariant
&
value
,
bool
convertOnly
,
QVariant
&
typedValue
,
QString
&
errorString
);
bool
convertAndValidateRaw
(
const
QVariant
&
rawValue
,
bool
convertOnly
,
QVariant
&
typedValue
,
QString
&
errorString
);
/// Same as convertAndValidateRaw except for cookedValue input
bool
convertAndValidateCooked
(
const
QVariant
&
cookedValue
,
bool
convertOnly
,
QVariant
&
typedValue
,
QString
&
errorString
);
static
const
int
defaultDecimalPlaces
=
3
;
private:
QVariant
_minForType
(
void
)
const
;
QVariant
_maxForType
(
void
)
const
;
void
_setBuiltInTranslator
(
void
);
// Built in translators
static
QVariant
_defaultTranslator
(
const
QVariant
&
from
)
{
return
from
;
}
static
QVariant
_degreesToRadians
(
const
QVariant
&
degrees
);
static
QVariant
_radiansToDegrees
(
const
QVariant
&
radians
);
static
QVariant
_centiDegreesToDegrees
(
const
QVariant
&
centiDegrees
);
static
QVariant
_degreesToCentiDegrees
(
const
QVariant
&
degrees
);
ValueType_t
_type
;
// must be first for correct constructor init
int
_decimalPlaces
;
QVariant
_
d
efaultValue
;
QVariant
_
rawD
efaultValue
;
bool
_defaultValueAvailable
;
QStringList
_enumStrings
;
QVariantList
_enumValues
;
QString
_group
;
QString
_longDescription
;
QVariant
_
m
ax
;
QVariant
_
rawM
ax
;
bool
_maxIsDefaultForType
;
QVariant
_
m
in
;
QVariant
_
rawM
in
;
bool
_minIsDefaultForType
;
QString
_name
;
QString
_shortDescription
;
QString
_units
;
QString
_rawUnits
;
QString
_cookedUnits
;
Translator
_rawTranslator
;
Translator
_cookedTranslator
;
struct
BuiltInTranslation_s
{
const
char
*
rawUnits
;
const
char
*
cookedUnits
;
Translator
rawTranslator
;
Translator
cookedTranslator
;
};
static
const
BuiltInTranslation_s
_rgBuildInTranslations
[];
};
#endif
src/FactSystem/ParameterLoader.cc
View file @
8dd3148d
...
...
@@ -721,7 +721,7 @@ void ParameterLoader::writeParametersToStream(QTextStream &stream)
Fact
*
fact
=
_mapParameterName2Variant
[
componentId
][
paramName
].
value
<
Fact
*>
();
Q_ASSERT
(
fact
);
stream
<<
_vehicle
->
id
()
<<
"
\t
"
<<
componentId
<<
"
\t
"
<<
paramName
<<
"
\t
"
<<
fact
->
v
alueString
()
<<
"
\t
"
<<
QString
(
"%1"
).
arg
(
_factTypeToMavType
(
fact
->
type
()))
<<
"
\n
"
;
stream
<<
_vehicle
->
id
()
<<
"
\t
"
<<
componentId
<<
"
\t
"
<<
paramName
<<
"
\t
"
<<
fact
->
rawV
alueString
()
<<
"
\t
"
<<
QString
(
"%1"
).
arg
(
_factTypeToMavType
(
fact
->
type
()))
<<
"
\n
"
;
}
}
...
...
src/FirmwarePlugin/APM/APMParameterMetaData.cc
View file @
8dd3148d
...
...
@@ -434,14 +434,14 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType)
}
if
(
!
rawMetaData
->
units
.
isEmpty
())
{
metaData
->
setUnits
(
rawMetaData
->
units
);
metaData
->
set
Raw
Units
(
rawMetaData
->
units
);
}
if
(
!
rawMetaData
->
min
.
isEmpty
())
{
QVariant
varMin
;
QString
errorString
;
if
(
metaData
->
convertAndValidate
(
rawMetaData
->
min
,
false
/* validate as well */
,
varMin
,
errorString
))
{
metaData
->
setMin
(
varMin
);
if
(
metaData
->
convertAndValidate
Raw
(
rawMetaData
->
min
,
false
/* validate as well */
,
varMin
,
errorString
))
{
metaData
->
set
Raw
Min
(
varMin
);
}
else
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"Invalid min value, name:"
<<
metaData
->
name
()
<<
" type:"
<<
metaData
->
type
()
<<
" min:"
<<
rawMetaData
->
min
...
...
@@ -452,8 +452,8 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType)
if
(
!
rawMetaData
->
max
.
isEmpty
())
{
QVariant
varMax
;
QString
errorString
;
if
(
metaData
->
convertAndValidate
(
rawMetaData
->
max
,
false
/* validate as well */
,
varMax
,
errorString
))
{
metaData
->
setMax
(
varMax
);
if
(
metaData
->
convertAndValidate
Raw
(
rawMetaData
->
max
,
false
/* validate as well */
,
varMax
,
errorString
))
{
metaData
->
set
Raw
Max
(
varMax
);
}
else
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"Invalid max value, name:"
<<
metaData
->
name
()
<<
" type:"
<<
metaData
->
type
()
<<
" max:"
<<
rawMetaData
->
max
...
...
@@ -470,7 +470,7 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType)
QString
errorString
;
QPair
<
QString
,
QString
>
enumPair
=
rawMetaData
->
values
[
i
];
if
(
metaData
->
convertAndValidate
(
enumPair
.
first
,
false
/* validate */
,
enumValue
,
errorString
))
{
if
(
metaData
->
convertAndValidate
Raw
(
enumPair
.
first
,
false
/* validate */
,
enumValue
,
errorString
))
{
enumValues
<<
enumValue
;
enumStrings
<<
enumPair
.
second
;
}
else
{
...
...
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
View file @
8dd3148d
...
...
@@ -239,8 +239,8 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
if
(
xml
.
attributes
().
hasAttribute
(
"default"
)
&&
!
strDefault
.
isEmpty
())
{
QVariant
varDefault
;
if
(
metaData
->
convertAndValidate
(
strDefault
,
false
,
varDefault
,
errorString
))
{
metaData
->
setDefaultValue
(
varDefault
);
if
(
metaData
->
convertAndValidate
Raw
(
strDefault
,
false
,
varDefault
,
errorString
))
{
metaData
->
set
Raw
DefaultValue
(
varDefault
);
}
else
{
qCWarning
(
PX4ParameterMetaDataLog
)
<<
"Invalid default value, name:"
<<
name
<<
" type:"
<<
type
<<
" default:"
<<
strDefault
<<
" error:"
<<
errorString
;
}
...
...
@@ -275,8 +275,8 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
qCDebug
(
PX4ParameterMetaDataLog
)
<<
"Min:"
<<
text
;
QVariant
varMin
;
if
(
metaData
->
convertAndValidate
(
text
,
true
/* convertOnly */
,
varMin
,
errorString
))
{
metaData
->
setMin
(
varMin
);
if
(
metaData
->
convertAndValidate
Raw
(
text
,
true
/* convertOnly */
,
varMin
,
errorString
))
{
metaData
->
set
Raw
Min
(
varMin
);
}
else
{
qCWarning
(
PX4ParameterMetaDataLog
)
<<
"Invalid min value, name:"
<<
metaData
->
name
()
<<
" type:"
<<
metaData
->
type
()
<<
" min:"
<<
text
<<
" error:"
<<
errorString
;
}
...
...
@@ -287,8 +287,8 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
qCDebug
(
PX4ParameterMetaDataLog
)
<<
"Max:"
<<
text
;
QVariant
varMax
;
if
(
metaData
->
convertAndValidate
(
text
,
true
/* convertOnly */
,
varMax
,
errorString
))
{
metaData
->
setMax
(
varMax
);
if
(
metaData
->
convertAndValidate
Raw
(
text
,
true
/* convertOnly */
,
varMax
,
errorString
))
{
metaData
->
set
Raw
Max
(
varMax
);
}
else
{
qCWarning
(
PX4ParameterMetaDataLog
)
<<
"Invalid max value, name:"
<<
metaData
->
name
()
<<
" type:"
<<
metaData
->
type
()
<<
" max:"
<<
text
<<
" error:"
<<
errorString
;
}
...
...
@@ -297,7 +297,7 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
Q_ASSERT
(
metaData
);
QString
text
=
xml
.
readElementText
();
qCDebug
(
PX4ParameterMetaDataLog
)
<<
"Unit:"
<<
text
;
metaData
->
setUnits
(
text
);
metaData
->
set
Raw
Units
(
text
);
}
else
if
(
elementName
==
"decimal"
)
{
Q_ASSERT
(
metaData
);
...
...
@@ -325,8 +325,8 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
if
(
metaData
->
defaultValueAvailable
())
{
QVariant
var
;
if
(
!
metaData
->
convertAndValidate
(
metaData
->
d
efaultValue
(),
false
/* convertOnly */
,
var
,
errorString
))
{
qCWarning
(
PX4ParameterMetaDataLog
)
<<
"Invalid default value, name:"
<<
metaData
->
name
()
<<
" type:"
<<
metaData
->
type
()
<<
" default:"
<<
metaData
->
d
efaultValue
()
<<
" error:"
<<
errorString
;
if
(
!
metaData
->
convertAndValidate
Raw
(
metaData
->
rawD
efaultValue
(),
false
/* convertOnly */
,
var
,
errorString
))
{
qCWarning
(
PX4ParameterMetaDataLog
)
<<
"Invalid default value, name:"
<<
metaData
->
name
()
<<
" type:"
<<
metaData
->
type
()
<<
" default:"
<<
metaData
->
rawD
efaultValue
()
<<
" error:"
<<
errorString
;
}
}
...
...
src/MissionManager/MavCmdInfo.json
View file @
8dd3148d
...
...
@@ -113,7 +113,7 @@
},
"param4"
:
{
"label"
:
"Heading:"
,
"units"
:
"
degreesConvert
"
,
"units"
:
"
radians
"
,
"default"
:
0.0
,
"decimalPlaces"
:
2
}
...
...
@@ -128,13 +128,13 @@
"category"
:
"Basic"
,
"param1"
:
{
"label"
:
"Pitch:"
,
"units"
:
"
degreesConvert
"
,
"units"
:
"
radians
"
,
"default"
:
0.26179939
,
"decimalPlaces"
:
2
},
"param4"
:
{
"label"
:
"Heading:"
,
"units"
:
"
degreesConvert
"
,
"units"
:
"
radians
"
,
"default"
:
0.0
,
"decimalPlaces"
:
2
}
...
...
src/MissionManager/MissionCommands.cc
View file @
8dd3148d
...
...
@@ -58,9 +58,6 @@ const QString MissionCommands::_specifiesCoordinateJsonKey (QStringLiteral("spe
const
QString
MissionCommands
::
_unitsJsonKey
(
QStringLiteral
(
"units"
));
const
QString
MissionCommands
::
_versionJsonKey
(
QStringLiteral
(
"version"
));
const
QString
MissionCommands
::
_degreesConvertUnits
(
QStringLiteral
(
"degreesConvert"
));
const
QString
MissionCommands
::
_degreesUnits
(
QStringLiteral
(
"degrees"
));
MissionCommands
::
MissionCommands
(
QGCApplication
*
app
)
:
QGCTool
(
app
)
{
...
...
src/MissionManager/MissionCommands.h
View file @
8dd3148d
...
...
@@ -139,9 +139,6 @@ public:
// Overrides from QGCTool
virtual
void
setToolbox
(
QGCToolbox
*
toolbox
);
static
const
QString
_degreesUnits
;
static
const
QString
_degreesConvertUnits
;
signals:
private:
...
...
src/MissionManager/MissionItem.cc
View file @
8dd3148d
...
...
@@ -309,7 +309,7 @@ void MissionItem::_setupMetaData(void)
if
(
!
_altitudeMetaData
)
{
_altitudeMetaData
=
new
FactMetaData
(
FactMetaData
::
valueTypeDouble
);
_altitudeMetaData
->
setUnits
(
"meters"
);
_altitudeMetaData
->
set
Raw
Units
(
"meters"
);
_altitudeMetaData
->
setDecimalPlaces
(
3
);
enumStrings
.
clear
();
...
...
@@ -336,11 +336,11 @@ void MissionItem::_setupMetaData(void)
_frameMetaData
->
setEnumInfo
(
enumStrings
,
enumValues
);
_latitudeMetaData
=
new
FactMetaData
(
FactMetaData
::
valueTypeDouble
);
_latitudeMetaData
->
setUnits
(
"deg"
);
_latitudeMetaData
->
set
Raw
Units
(
"deg"
);
_latitudeMetaData
->
setDecimalPlaces
(
7
);
_longitudeMetaData
=
new
FactMetaData
(
FactMetaData
::
valueTypeDouble
);
_longitudeMetaData
->
setUnits
(
"deg"
);
_longitudeMetaData
->
set
Raw
Units
(
"deg"
);
_longitudeMetaData
->
setDecimalPlaces
(
7
);
}
...
...
@@ -516,18 +516,14 @@ QString MissionItem::commandDescription(void) const
void
MissionItem
::
_clearParamMetaData
(
void
)
{
_param1MetaData
.
setUnits
(
""
);
_param1MetaData
.
set
Raw
Units
(
""
);
_param1MetaData
.
setDecimalPlaces
(
FactMetaData
::
defaultDecimalPlaces
);
_param1MetaData
.
setTranslators
(
FactMetaData
::
defaultTranslator
,
FactMetaData
::
defaultTranslator
);
_param2MetaData
.
setUnits
(
""
);
_param2MetaData
.
setRawUnits
(
""
);
_param2MetaData
.
setDecimalPlaces
(
FactMetaData
::
defaultDecimalPlaces
);
_param2MetaData
.
setTranslators
(
FactMetaData
::
defaultTranslator
,
FactMetaData
::
defaultTranslator
);
_param3MetaData
.
setUnits
(
""
);
_param3MetaData
.
setRawUnits
(
""
);
_param3MetaData
.
setDecimalPlaces
(
FactMetaData
::
defaultDecimalPlaces
);
_param3MetaData
.
setTranslators
(
FactMetaData
::
defaultTranslator
,
FactMetaData
::
defaultTranslator
);
_param4MetaData
.
setUnits
(
""
);
_param4MetaData
.
setRawUnits
(
""
);
_param4MetaData
.
setDecimalPlaces
(
FactMetaData
::
defaultDecimalPlaces
);
_param4MetaData
.
setTranslators
(
FactMetaData
::
defaultTranslator
,
FactMetaData
::
defaultTranslator
);
}
QmlObjectListModel
*
MissionItem
::
textFieldFacts
(
void
)
...
...
@@ -575,12 +571,7 @@ QmlObjectListModel* MissionItem::textFieldFacts(void)
paramFact
->
_setName
(
paramInfo
->
label
());
paramMetaData
->
setDecimalPlaces
(
paramInfo
->
decimalPlaces
());
paramMetaData
->
setEnumInfo
(
paramInfo
->
enumStrings
(),
paramInfo
->
enumValues
());
if
(
paramInfo
->
units
()
==
MissionCommands
::
_degreesConvertUnits
)
{
paramMetaData
->
setTranslators
(
_radiansToDegrees
,
_degreesToRadians
);
paramMetaData
->
setUnits
(
MissionCommands
::
_degreesUnits
);
}
else
{
paramMetaData
->
setUnits
(
paramInfo
->
units
());
}
paramMetaData
->
setRawUnits
(
paramInfo
->
units
());
paramFact
->
setMetaData
(
paramMetaData
);
model
->
append
(
paramFact
);
}
...
...
@@ -634,12 +625,7 @@ QmlObjectListModel* MissionItem::comboboxFacts(void)
paramFact
->
_setName
(
paramInfo
->
label
());
paramMetaData
->
setDecimalPlaces
(
paramInfo
->
decimalPlaces
());
paramMetaData
->
setEnumInfo
(
paramInfo
->
enumStrings
(),
paramInfo
->
enumValues
());
if
(
paramInfo
->
units
()
==
MissionCommands
::
_degreesConvertUnits
)
{
paramMetaData
->
setTranslators
(
_radiansToDegrees
,
_degreesToRadians
);
paramMetaData
->
setUnits
(
MissionCommands
::
_degreesUnits
);
}
else
{
paramMetaData
->
setUnits
(
paramInfo
->
units
());
}
paramMetaData
->
setRawUnits
(
paramInfo
->
units
());
paramFact
->
setMetaData
(
paramMetaData
);
model
->
append
(
paramFact
);
}
...
...
@@ -804,16 +790,6 @@ QString MissionItem::commandName(void) const
}
}
QVariant
MissionItem
::
_degreesToRadians
(
const
QVariant
&
degrees
)
{
return
QVariant
(
degrees
.
toDouble
()
*
(
M_PI
/
180.0
));
}
QVariant
MissionItem
::
_radiansToDegrees
(
const
QVariant
&
radians
)
{
return
QVariant
(
radians
.
toDouble
()
*
(
180
/
M_PI
));
}
void
MissionItem
::
_sendFriendlyEditAllowedChanged
(
void
)
{
emit
friendlyEditAllowedChanged
(
friendlyEditAllowed
());
...
...
src/MissionManager/MissionItem.h
View file @
8dd3148d
...
...
@@ -211,9 +211,6 @@ private:
void
_connectSignals
(
void
);
void
_setupMetaData
(
void
);
static
QVariant
_degreesToRadians
(
const
QVariant
&
degrees
);
static
QVariant
_radiansToDegrees
(
const
QVariant
&
radians
);
private:
bool
_rawEdit
;
bool
_dirty
;
...
...
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