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
8fc0149b
Commit
8fc0149b
authored
Oct 23, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add checkSignalsByMask and checkOnlySignalsByMask
Allows for signal count > 1
parent
00d395b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
9 deletions
+42
-9
MultiSignalSpy.cc
src/qgcunittest/MultiSignalSpy.cc
+24
-9
MultiSignalSpy.h
src/qgcunittest/MultiSignalSpy.h
+18
-0
No files found.
src/qgcunittest/MultiSignalSpy.cc
View file @
8fc0149b
...
...
@@ -85,17 +85,14 @@ bool MultiSignalSpy::init(
return
true
;
}
/// @param mask bit mask specifying which signals to check. The lowest order bit represents
/// index 0 into the rgSignals array and so on up the bit mask.
/// @return true if signal count = 1 for the specified signals
bool
MultiSignalSpy
::
checkSignalByMask
(
quint16
mask
)
bool
MultiSignalSpy
::
_checkSignalByMaskWorker
(
quint16
mask
,
bool
multipleSignalsAllowed
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
if
((
1
<<
i
)
&
mask
)
{
QSignalSpy
*
spy
=
_rgSpys
[
i
];
Q_ASSERT
(
spy
!=
NULL
);
if
(
spy
->
count
()
!=
1
)
{
if
(
(
multipleSignalsAllowed
&&
spy
->
count
()
==
0
)
||
spy
->
count
()
!=
1
)
{
_printSignalState
();
return
false
;
}
...
...
@@ -105,16 +102,14 @@ bool MultiSignalSpy::checkSignalByMask(quint16 mask)
return
true
;
}
/// @return true if signal count = 1 for specified signals and signal count of 0
/// for all other signals
bool
MultiSignalSpy
::
checkOnlySignalByMask
(
quint16
mask
)
bool
MultiSignalSpy
::
_checkOnlySignalByMaskWorker
(
quint16
mask
,
bool
multipleSignalsAllowed
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
QSignalSpy
*
spy
=
_rgSpys
[
i
];
Q_ASSERT
(
spy
!=
NULL
);
if
((
1
<<
i
)
&
mask
)
{
if
(
spy
->
count
()
!=
1
)
{
if
(
(
multipleSignalsAllowed
&&
spy
->
count
()
==
0
)
||
(
!
multipleSignalsAllowed
&&
spy
->
count
()
!=
1
)
)
{
_printSignalState
();
return
false
;
}
...
...
@@ -129,6 +124,26 @@ bool MultiSignalSpy::checkOnlySignalByMask(quint16 mask)
return
true
;
}
bool
MultiSignalSpy
::
checkSignalByMask
(
quint16
mask
)
{
return
_checkSignalByMaskWorker
(
mask
,
false
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkOnlySignalByMask
(
quint16
mask
)
{
return
_checkOnlySignalByMaskWorker
(
mask
,
false
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkSignalsByMask
(
quint16
mask
)
{
return
_checkSignalByMaskWorker
(
mask
,
true
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkOnlySignalsByMask
(
quint16
mask
)
{
return
_checkOnlySignalByMaskWorker
(
mask
,
true
/* multipleSignalsAllowed */
);
}
/// @return true if signal count = 0 for specified signals
bool
MultiSignalSpy
::
checkNoSignalByMask
(
quint16
mask
)
{
...
...
src/qgcunittest/MultiSignalSpy.h
View file @
8fc0149b
...
...
@@ -43,8 +43,24 @@ public:
bool
init
(
QObject
*
signalEmitter
,
const
char
**
rgSignals
,
size_t
cSignals
);
/// @param mask bit mask specifying which signals to check. The lowest order bit represents
/// index 0 into the rgSignals array and so on up the bit mask.
/// @return true if signal count = 1 for the specified signals
bool
checkSignalByMask
(
quint16
mask
);
/// @return true if signal count = 1 for specified signals and signal count of 0
/// for all other signals
bool
checkOnlySignalByMask
(
quint16
mask
);
/// @param mask bit mask specifying which signals to check. The lowest order bit represents
/// index 0 into the rgSignals array and so on up the bit mask.
/// @return true if signal count >= 1 for the specified signals
bool
checkSignalsByMask
(
quint16
mask
);
/// @return true if signal count >= 1 for specified signals and signal count of 0
/// for all other signals
bool
checkOnlySignalsByMask
(
quint16
mask
);
bool
checkNoSignalByMask
(
quint16
mask
);
bool
checkNoSignals
(
void
);
...
...
@@ -61,6 +77,8 @@ private:
void
timerEvent
(
QTimerEvent
*
event
);
void
_printSignalState
(
void
);
bool
_checkSignalByMaskWorker
(
quint16
mask
,
bool
multipleSignalsAllowed
);
bool
_checkOnlySignalByMaskWorker
(
quint16
mask
,
bool
multipleSignalsAllowed
);
QObject
*
_signalEmitter
;
const
char
**
_rgSignals
;
...
...
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