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
df569bcf
Commit
df569bcf
authored
Oct 23, 2018
by
Patrick José Pereira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FactSystem: Change from foreach to c++11 for
Signed-off-by:
Patrick José Pereira
<
patrickelectric@gmail.com
>
parent
583da803
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
27 deletions
+27
-27
Fact.cc
src/FactSystem/Fact.cc
+1
-1
FactGroup.cc
src/FactSystem/FactGroup.cc
+1
-1
ParameterManager.cc
src/FactSystem/ParameterManager.cc
+25
-25
No files found.
src/FactSystem/Fact.cc
View file @
df569bcf
...
@@ -221,7 +221,7 @@ int Fact::enumIndex(void)
...
@@ -221,7 +221,7 @@ int Fact::enumIndex(void)
//-- Only enums have an index
//-- Only enums have an index
if
(
_metaData
->
enumValues
().
count
())
{
if
(
_metaData
->
enumValues
().
count
())
{
int
index
=
0
;
int
index
=
0
;
for
each
(
QVariant
enumValue
,
_metaData
->
enumValues
())
{
for
(
QVariant
enumValue
:
_metaData
->
enumValues
())
{
if
(
enumValue
==
rawValue
())
{
if
(
enumValue
==
rawValue
())
{
return
index
;
return
index
;
}
}
...
...
src/FactSystem/FactGroup.cc
View file @
df569bcf
...
@@ -120,7 +120,7 @@ void FactGroup::_addFactGroup(FactGroup* factGroup, const QString& name)
...
@@ -120,7 +120,7 @@ void FactGroup::_addFactGroup(FactGroup* factGroup, const QString& name)
void
FactGroup
::
_updateAllValues
(
void
)
void
FactGroup
::
_updateAllValues
(
void
)
{
{
for
each
(
Fact
*
fact
,
_nameToFactMap
)
{
for
(
Fact
*
fact
:
_nameToFactMap
)
{
fact
->
sendDeferredValueChangedSignal
();
fact
->
sendDeferredValueChangedSignal
();
}
}
}
}
src/FactSystem/ParameterManager.cc
View file @
df569bcf
...
@@ -228,21 +228,21 @@ void ParameterManager::_parameterUpdate(int vehicleId, int componentId, QString
...
@@ -228,21 +228,21 @@ void ParameterManager::_parameterUpdate(int vehicleId, int componentId, QString
int
waitingReadParamNameCount
=
0
;
int
waitingReadParamNameCount
=
0
;
int
waitingWriteParamNameCount
=
0
;
int
waitingWriteParamNameCount
=
0
;
for
each
(
int
waitingComponentId
,
_waitingReadParamIndexMap
.
keys
())
{
for
(
int
waitingComponentId
:
_waitingReadParamIndexMap
.
keys
())
{
waitingReadParamIndexCount
+=
_waitingReadParamIndexMap
[
waitingComponentId
].
count
();
waitingReadParamIndexCount
+=
_waitingReadParamIndexMap
[
waitingComponentId
].
count
();
}
}
if
(
waitingReadParamIndexCount
)
{
if
(
waitingReadParamIndexCount
)
{
qCDebug
(
ParameterManagerVerbose1Log
)
<<
_logVehiclePrefix
(
componentId
)
<<
"waitingReadParamIndexCount:"
<<
waitingReadParamIndexCount
;
qCDebug
(
ParameterManagerVerbose1Log
)
<<
_logVehiclePrefix
(
componentId
)
<<
"waitingReadParamIndexCount:"
<<
waitingReadParamIndexCount
;
}
}
for
each
(
int
waitingComponentId
,
_waitingReadParamNameMap
.
keys
())
{
for
(
int
waitingComponentId
:
_waitingReadParamNameMap
.
keys
())
{
waitingReadParamNameCount
+=
_waitingReadParamNameMap
[
waitingComponentId
].
count
();
waitingReadParamNameCount
+=
_waitingReadParamNameMap
[
waitingComponentId
].
count
();
}
}
if
(
waitingReadParamNameCount
)
{
if
(
waitingReadParamNameCount
)
{
qCDebug
(
ParameterManagerVerbose1Log
)
<<
_logVehiclePrefix
(
componentId
)
<<
"waitingReadParamNameCount:"
<<
waitingReadParamNameCount
;
qCDebug
(
ParameterManagerVerbose1Log
)
<<
_logVehiclePrefix
(
componentId
)
<<
"waitingReadParamNameCount:"
<<
waitingReadParamNameCount
;
}
}
for
each
(
int
waitingComponentId
,
_waitingWriteParamNameMap
.
keys
())
{
for
(
int
waitingComponentId
:
_waitingWriteParamNameMap
.
keys
())
{
waitingWriteParamNameCount
+=
_waitingWriteParamNameMap
[
waitingComponentId
].
count
();
waitingWriteParamNameCount
+=
_waitingWriteParamNameMap
[
waitingComponentId
].
count
();
}
}
if
(
waitingWriteParamNameCount
)
{
if
(
waitingWriteParamNameCount
)
{
...
@@ -418,7 +418,7 @@ void ParameterManager::refreshAllParameters(uint8_t componentId)
...
@@ -418,7 +418,7 @@ void ParameterManager::refreshAllParameters(uint8_t componentId)
}
}
// Reset index wait lists
// Reset index wait lists
for
each
(
int
cid
,
_paramCountMap
.
keys
())
{
for
(
int
cid
:
_paramCountMap
.
keys
())
{
// Add/Update all indices to the wait list, parameter index is 0-based
// Add/Update all indices to the wait list, parameter index is 0-based
if
(
componentId
!=
MAV_COMP_ID_ALL
&&
componentId
!=
cid
)
if
(
componentId
!=
MAV_COMP_ID_ALL
&&
componentId
!=
cid
)
continue
;
continue
;
...
@@ -486,7 +486,7 @@ void ParameterManager::refreshParametersPrefix(int componentId, const QString& n
...
@@ -486,7 +486,7 @@ void ParameterManager::refreshParametersPrefix(int componentId, const QString& n
componentId
=
_actualComponentId
(
componentId
);
componentId
=
_actualComponentId
(
componentId
);
qCDebug
(
ParameterManagerLog
)
<<
_logVehiclePrefix
(
componentId
)
<<
"refreshParametersPrefix - name:"
<<
namePrefix
<<
")"
;
qCDebug
(
ParameterManagerLog
)
<<
_logVehiclePrefix
(
componentId
)
<<
"refreshParametersPrefix - name:"
<<
namePrefix
<<
")"
;
for
each
(
const
QString
&
name
,
_mapParameterName2Variant
[
componentId
].
keys
())
{
for
(
const
QString
&
name
:
_mapParameterName2Variant
[
componentId
].
keys
())
{
if
(
name
.
startsWith
(
namePrefix
))
{
if
(
name
.
startsWith
(
namePrefix
))
{
refreshParameter
(
componentId
,
name
);
refreshParameter
(
componentId
,
name
);
}
}
...
@@ -522,7 +522,7 @@ QStringList ParameterManager::parameterNames(int componentId)
...
@@ -522,7 +522,7 @@ QStringList ParameterManager::parameterNames(int componentId)
{
{
QStringList
names
;
QStringList
names
;
for
each
(
const
QString
&
paramName
,
_mapParameterName2Variant
[
_actualComponentId
(
componentId
)].
keys
())
{
for
(
const
QString
&
paramName
:
_mapParameterName2Variant
[
_actualComponentId
(
componentId
)].
keys
())
{
names
<<
paramName
;
names
<<
paramName
;
}
}
...
@@ -534,7 +534,7 @@ void ParameterManager::_setupCategoryMap(void)
...
@@ -534,7 +534,7 @@ void ParameterManager::_setupCategoryMap(void)
// Must be able to handle being called multiple times
// Must be able to handle being called multiple times
_categoryMap
.
clear
();
_categoryMap
.
clear
();
for
each
(
const
QString
&
name
,
_mapParameterName2Variant
[
_vehicle
->
defaultComponentId
()].
keys
())
{
for
(
const
QString
&
name
:
_mapParameterName2Variant
[
_vehicle
->
defaultComponentId
()].
keys
())
{
Fact
*
fact
=
_mapParameterName2Variant
[
_vehicle
->
defaultComponentId
()][
name
].
value
<
Fact
*>
();
Fact
*
fact
=
_mapParameterName2Variant
[
_vehicle
->
defaultComponentId
()][
name
].
value
<
Fact
*>
();
_categoryMap
[
fact
->
category
()][
fact
->
group
()]
+=
name
;
_categoryMap
[
fact
->
category
()][
fact
->
group
()]
+=
name
;
}
}
...
@@ -564,13 +564,13 @@ bool ParameterManager::_fillIndexBatchQueue(bool waitingParamTimeout)
...
@@ -564,13 +564,13 @@ bool ParameterManager::_fillIndexBatchQueue(bool waitingParamTimeout)
qCDebug
(
ParameterManagerLog
)
<<
"Refilling index based batch queue due to received parameter"
;
qCDebug
(
ParameterManagerLog
)
<<
"Refilling index based batch queue due to received parameter"
;
}
}
for
each
(
int
componentId
,
_waitingReadParamIndexMap
.
keys
())
{
for
(
int
componentId
:
_waitingReadParamIndexMap
.
keys
())
{
if
(
_waitingReadParamIndexMap
[
componentId
].
count
())
{
if
(
_waitingReadParamIndexMap
[
componentId
].
count
())
{
qCDebug
(
ParameterManagerLog
)
<<
_logVehiclePrefix
()
<<
"_waitingReadParamIndexMap count"
<<
_waitingReadParamIndexMap
[
componentId
].
count
();
qCDebug
(
ParameterManagerLog
)
<<
_logVehiclePrefix
()
<<
"_waitingReadParamIndexMap count"
<<
_waitingReadParamIndexMap
[
componentId
].
count
();
qCDebug
(
ParameterManagerVerbose1Log
)
<<
_logVehiclePrefix
()
<<
"_waitingReadParamIndexMap"
<<
_waitingReadParamIndexMap
[
componentId
];
qCDebug
(
ParameterManagerVerbose1Log
)
<<
_logVehiclePrefix
()
<<
"_waitingReadParamIndexMap"
<<
_waitingReadParamIndexMap
[
componentId
];
}
}
for
each
(
int
paramIndex
,
_waitingReadParamIndexMap
[
componentId
].
keys
())
{
for
(
int
paramIndex
:
_waitingReadParamIndexMap
[
componentId
].
keys
())
{
if
(
_indexBatchQueue
.
contains
(
paramIndex
))
{
if
(
_indexBatchQueue
.
contains
(
paramIndex
))
{
// Don't add more than once
// Don't add more than once
continue
;
continue
;
...
@@ -629,8 +629,8 @@ void ParameterManager::_waitingParamTimeout(void)
...
@@ -629,8 +629,8 @@ void ParameterManager::_waitingParamTimeout(void)
_checkInitialLoadComplete
();
_checkInitialLoadComplete
();
if
(
!
paramsRequested
)
{
if
(
!
paramsRequested
)
{
for
each
(
int
componentId
,
_waitingWriteParamNameMap
.
keys
())
{
for
(
int
componentId
:
_waitingWriteParamNameMap
.
keys
())
{
for
each
(
const
QString
&
paramName
,
_waitingWriteParamNameMap
[
componentId
].
keys
())
{
for
(
const
QString
&
paramName
:
_waitingWriteParamNameMap
[
componentId
].
keys
())
{
paramsRequested
=
true
;
paramsRequested
=
true
;
_waitingWriteParamNameMap
[
componentId
][
paramName
]
++
;
// Bump retry count
_waitingWriteParamNameMap
[
componentId
][
paramName
]
++
;
// Bump retry count
if
(
_waitingWriteParamNameMap
[
componentId
][
paramName
]
<=
_maxReadWriteRetry
)
{
if
(
_waitingWriteParamNameMap
[
componentId
][
paramName
]
<=
_maxReadWriteRetry
)
{
...
@@ -651,8 +651,8 @@ void ParameterManager::_waitingParamTimeout(void)
...
@@ -651,8 +651,8 @@ void ParameterManager::_waitingParamTimeout(void)
}
}
if
(
!
paramsRequested
)
{
if
(
!
paramsRequested
)
{
for
each
(
int
componentId
,
_waitingReadParamNameMap
.
keys
())
{
for
(
int
componentId
:
_waitingReadParamNameMap
.
keys
())
{
for
each
(
const
QString
&
paramName
,
_waitingReadParamNameMap
[
componentId
].
keys
())
{
for
(
const
QString
&
paramName
:
_waitingReadParamNameMap
[
componentId
].
keys
())
{
paramsRequested
=
true
;
paramsRequested
=
true
;
_waitingReadParamNameMap
[
componentId
][
paramName
]
++
;
// Bump retry count
_waitingReadParamNameMap
[
componentId
][
paramName
]
++
;
// Bump retry count
if
(
_waitingReadParamNameMap
[
componentId
][
paramName
]
<=
_maxReadWriteRetry
)
{
if
(
_waitingReadParamNameMap
[
componentId
][
paramName
]
<=
_maxReadWriteRetry
)
{
...
@@ -759,7 +759,7 @@ void ParameterManager::_writeLocalParamCache(int vehicleId, int componentId)
...
@@ -759,7 +759,7 @@ void ParameterManager::_writeLocalParamCache(int vehicleId, int componentId)
{
{
CacheMapName2ParamTypeVal
cacheMap
;
CacheMapName2ParamTypeVal
cacheMap
;
for
each
(
const
QString
&
name
,
_mapParameterName2Variant
[
componentId
].
keys
())
{
for
(
const
QString
&
name
:
_mapParameterName2Variant
[
componentId
].
keys
())
{
const
Fact
*
fact
=
_mapParameterName2Variant
[
componentId
][
name
].
value
<
Fact
*>
();
const
Fact
*
fact
=
_mapParameterName2Variant
[
componentId
][
name
].
value
<
Fact
*>
();
cacheMap
[
name
]
=
ParamTypeVal
(
fact
->
type
(),
fact
->
rawValue
());
cacheMap
[
name
]
=
ParamTypeVal
(
fact
->
type
(),
fact
->
rawValue
());
}
}
...
@@ -810,7 +810,7 @@ void ParameterManager::_tryCacheHashLoad(int vehicleId, int componentId, QVarian
...
@@ -810,7 +810,7 @@ void ParameterManager::_tryCacheHashLoad(int vehicleId, int componentId, QVarian
/* compute the crc of the local cache to check against the remote */
/* compute the crc of the local cache to check against the remote */
FirmwarePlugin
*
firmwarePlugin
=
_vehicle
->
firmwarePlugin
();
FirmwarePlugin
*
firmwarePlugin
=
_vehicle
->
firmwarePlugin
();
for
each
(
const
QString
&
name
,
cacheMap
.
keys
())
{
for
(
const
QString
&
name
:
cacheMap
.
keys
())
{
bool
volatileValue
=
false
;
bool
volatileValue
=
false
;
FactMetaData
*
metaData
=
firmwarePlugin
->
getMetaDataForFact
(
_parameterMetaData
,
name
,
_vehicle
->
vehicleType
());
FactMetaData
*
metaData
=
firmwarePlugin
->
getMetaDataForFact
(
_parameterMetaData
,
name
,
_vehicle
->
vehicleType
());
...
@@ -836,7 +836,7 @@ void ParameterManager::_tryCacheHashLoad(int vehicleId, int componentId, QVarian
...
@@ -836,7 +836,7 @@ void ParameterManager::_tryCacheHashLoad(int vehicleId, int componentId, QVarian
int
count
=
cacheMap
.
count
();
int
count
=
cacheMap
.
count
();
int
index
=
0
;
int
index
=
0
;
for
each
(
const
QString
&
name
,
cacheMap
.
keys
())
{
for
(
const
QString
&
name
:
cacheMap
.
keys
())
{
const
ParamTypeVal
&
paramTypeVal
=
cacheMap
[
name
];
const
ParamTypeVal
&
paramTypeVal
=
cacheMap
[
name
];
const
FactMetaData
::
ValueType_t
fact_type
=
static_cast
<
FactMetaData
::
ValueType_t
>
(
paramTypeVal
.
first
);
const
FactMetaData
::
ValueType_t
fact_type
=
static_cast
<
FactMetaData
::
ValueType_t
>
(
paramTypeVal
.
first
);
const
int
mavType
=
_factTypeToMavType
(
fact_type
);
const
int
mavType
=
_factTypeToMavType
(
fact_type
);
...
@@ -888,7 +888,7 @@ void ParameterManager::_tryCacheHashLoad(int vehicleId, int componentId, QVarian
...
@@ -888,7 +888,7 @@ void ParameterManager::_tryCacheHashLoad(int vehicleId, int componentId, QVarian
if
(
ParameterManagerDebugCacheFailureLog
().
isDebugEnabled
())
{
if
(
ParameterManagerDebugCacheFailureLog
().
isDebugEnabled
())
{
_debugCacheCRC
[
componentId
]
=
true
;
_debugCacheCRC
[
componentId
]
=
true
;
_debugCacheMap
[
componentId
]
=
cacheMap
;
_debugCacheMap
[
componentId
]
=
cacheMap
;
for
each
(
const
QString
&
name
,
cacheMap
.
keys
())
{
for
(
const
QString
&
name
:
cacheMap
.
keys
())
{
_debugCacheParamSeen
[
componentId
][
name
]
=
false
;
_debugCacheParamSeen
[
componentId
][
name
]
=
false
;
}
}
qgcApp
()
->
showMessage
(
tr
(
"Parameter cache CRC match failed"
));
qgcApp
()
->
showMessage
(
tr
(
"Parameter cache CRC match failed"
));
...
@@ -958,8 +958,8 @@ void ParameterManager::writeParametersToStream(QTextStream &stream)
...
@@ -958,8 +958,8 @@ void ParameterManager::writeParametersToStream(QTextStream &stream)
stream
<<
"#
\n
"
;
stream
<<
"#
\n
"
;
stream
<<
"# Vehicle-Id Component-Id Name Value Type
\n
"
;
stream
<<
"# Vehicle-Id Component-Id Name Value Type
\n
"
;
for
each
(
int
componentId
,
_mapParameterName2Variant
.
keys
())
{
for
(
int
componentId
:
_mapParameterName2Variant
.
keys
())
{
for
each
(
const
QString
&
paramName
,
_mapParameterName2Variant
[
componentId
].
keys
())
{
for
(
const
QString
&
paramName
:
_mapParameterName2Variant
[
componentId
].
keys
())
{
Fact
*
fact
=
_mapParameterName2Variant
[
componentId
][
paramName
].
value
<
Fact
*>
();
Fact
*
fact
=
_mapParameterName2Variant
[
componentId
][
paramName
].
value
<
Fact
*>
();
if
(
fact
)
{
if
(
fact
)
{
stream
<<
_vehicle
->
id
()
<<
"
\t
"
<<
componentId
<<
"
\t
"
<<
paramName
<<
"
\t
"
<<
fact
->
rawValueStringFullPrecision
()
<<
"
\t
"
<<
QString
(
"%1"
).
arg
(
_factTypeToMavType
(
fact
->
type
()))
<<
"
\n
"
;
stream
<<
_vehicle
->
id
()
<<
"
\t
"
<<
componentId
<<
"
\t
"
<<
paramName
<<
"
\t
"
<<
fact
->
rawValueStringFullPrecision
()
<<
"
\t
"
<<
QString
(
"%1"
).
arg
(
_factTypeToMavType
(
fact
->
type
()))
<<
"
\n
"
;
...
@@ -1084,7 +1084,7 @@ void ParameterManager::_addMetaDataToDefaultComponent(void)
...
@@ -1084,7 +1084,7 @@ void ParameterManager::_addMetaDataToDefaultComponent(void)
// Loop over all parameters in default component adding meta data
// Loop over all parameters in default component adding meta data
QVariantMap
&
factMap
=
_mapParameterName2Variant
[
_vehicle
->
defaultComponentId
()];
QVariantMap
&
factMap
=
_mapParameterName2Variant
[
_vehicle
->
defaultComponentId
()];
for
each
(
const
QString
&
key
,
factMap
.
keys
())
{
for
(
const
QString
&
key
:
factMap
.
keys
())
{
_vehicle
->
firmwarePlugin
()
->
addMetaDataToFact
(
_parameterMetaData
,
factMap
[
key
].
value
<
Fact
*>
(),
_vehicle
->
vehicleType
());
_vehicle
->
firmwarePlugin
()
->
addMetaDataToFact
(
_parameterMetaData
,
factMap
[
key
].
value
<
Fact
*>
(),
_vehicle
->
vehicleType
());
}
}
}
}
...
@@ -1096,7 +1096,7 @@ void ParameterManager::_checkInitialLoadComplete(void)
...
@@ -1096,7 +1096,7 @@ void ParameterManager::_checkInitialLoadComplete(void)
return
;
return
;
}
}
for
each
(
int
componentId
,
_waitingReadParamIndexMap
.
keys
())
{
for
(
int
componentId
:
_waitingReadParamIndexMap
.
keys
())
{
if
(
_waitingReadParamIndexMap
[
componentId
].
count
())
{
if
(
_waitingReadParamIndexMap
[
componentId
].
count
())
{
// We are still waiting on some parameters, not done yet
// We are still waiting on some parameters, not done yet
return
;
return
;
...
@@ -1112,9 +1112,9 @@ void ParameterManager::_checkInitialLoadComplete(void)
...
@@ -1112,9 +1112,9 @@ void ParameterManager::_checkInitialLoadComplete(void)
_initialLoadComplete
=
true
;
_initialLoadComplete
=
true
;
// Parameter cache crc failure debugging
// Parameter cache crc failure debugging
for
each
(
int
componentId
,
_debugCacheParamSeen
.
keys
())
{
for
(
int
componentId
:
_debugCacheParamSeen
.
keys
())
{
if
(
!
_logReplay
&&
_debugCacheCRC
.
contains
(
componentId
)
&&
_debugCacheCRC
[
componentId
])
{
if
(
!
_logReplay
&&
_debugCacheCRC
.
contains
(
componentId
)
&&
_debugCacheCRC
[
componentId
])
{
for
each
(
const
QString
&
paramName
,
_debugCacheParamSeen
[
componentId
].
keys
())
{
for
(
const
QString
&
paramName
:
_debugCacheParamSeen
[
componentId
].
keys
())
{
if
(
!
_debugCacheParamSeen
[
componentId
][
paramName
])
{
if
(
!
_debugCacheParamSeen
[
componentId
][
paramName
])
{
qDebug
()
<<
"Parameter in cache but not on vehicle componentId:Name"
<<
componentId
<<
paramName
;
qDebug
()
<<
"Parameter in cache but not on vehicle componentId:Name"
<<
componentId
<<
paramName
;
}
}
...
@@ -1128,8 +1128,8 @@ void ParameterManager::_checkInitialLoadComplete(void)
...
@@ -1128,8 +1128,8 @@ void ParameterManager::_checkInitialLoadComplete(void)
// Check for index based load failures
// Check for index based load failures
QString
indexList
;
QString
indexList
;
bool
initialLoadFailures
=
false
;
bool
initialLoadFailures
=
false
;
for
each
(
int
componentId
,
_failedReadParamIndexMap
.
keys
())
{
for
(
int
componentId
:
_failedReadParamIndexMap
.
keys
())
{
for
each
(
int
paramIndex
,
_failedReadParamIndexMap
[
componentId
])
{
for
(
int
paramIndex
:
_failedReadParamIndexMap
[
componentId
])
{
if
(
initialLoadFailures
)
{
if
(
initialLoadFailures
)
{
indexList
+=
", "
;
indexList
+=
", "
;
}
}
...
...
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