Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
4eea89bb
Commit
4eea89bb
authored
8 years ago
by
Beat Küng
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor replay: move topic publication into separate method
parent
45ffb190
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/replay/replay.hpp
+15
-5
15 additions, 5 deletions
src/modules/replay/replay.hpp
src/modules/replay/replay_main.cpp
+41
-28
41 additions, 28 deletions
src/modules/replay/replay_main.cpp
with
56 additions
and
33 deletions
src/modules/replay/replay.hpp
+
15
−
5
View file @
4eea89bb
...
...
@@ -61,11 +61,13 @@ public:
/// Destructor, also waits for task exit
~
Replay
();
/// Start task.
/// @param quiet silently fail if no log file found
/// @param apply_params_only if true, only apply parameters from definitions section of the file
/// and user-overridden parameters, then exit w/o replaying.
/// @return OK on success.
/**
* Start task.
* @param quiet silently fail if no log file found
* @param apply_params_only if true, only apply parameters from definitions section of the file
* and user-overridden parameters, then exit w/o replaying.
* @return OK on success.
*/
static
int
start
(
bool
quiet
,
bool
apply_params_only
);
static
void
task_main_trampoline
(
int
argc
,
char
*
argv
[]);
...
...
@@ -155,6 +157,14 @@ private:
void
setUserParams
(
const
char
*
filename
);
/**
* publish an orb topic
* @param sub
* @param data
* @return true if published, false otherwise
*/
bool
publishTopic
(
Subscription
&
sub
,
void
*
data
);
static
char
*
_replay_file
;
};
...
...
This diff is collapsed.
Click to expand it.
src/modules/replay/replay_main.cpp
+
41
−
28
View file @
4eea89bb
...
...
@@ -702,35 +702,8 @@ void Replay::task_main()
replay_file
.
read
((
char
*
)
_read_buffer
.
data
(),
msg_read_size
);
*
(
uint64_t
*
)(
_read_buffer
.
data
()
+
sub
.
timestamp_offset
)
=
publish_timestamp
;
if
(
sub
.
orb_advert
)
{
orb_publish
(
sub
.
orb_meta
,
sub
.
orb_advert
,
_read_buffer
.
data
());
if
(
publishTopic
(
sub
,
_read_buffer
.
data
()))
{
++
nr_published_messages
;
}
else
{
if
(
sub
.
multi_id
==
0
)
{
sub
.
orb_advert
=
orb_advertise
(
sub
.
orb_meta
,
_read_buffer
.
data
());
++
nr_published_messages
;
}
else
{
// make sure the other instances are advertised already so that we get the correct instance
bool
advertised
=
false
;
for
(
const
auto
&
subscription
:
_subscriptions
)
{
if
(
subscription
.
orb_meta
)
{
if
(
strcmp
(
sub
.
orb_meta
->
o_name
,
subscription
.
orb_meta
->
o_name
)
==
0
&&
subscription
.
orb_advert
&&
subscription
.
multi_id
==
sub
.
multi_id
-
1
)
{
advertised
=
true
;
}
}
}
if
(
advertised
)
{
int
instance
;
sub
.
orb_advert
=
orb_advertise_multi
(
sub
.
orb_meta
,
_read_buffer
.
data
(),
&
instance
,
ORB_PRIO_DEFAULT
);
++
nr_published_messages
;
}
}
}
...
...
@@ -754,6 +727,46 @@ void Replay::task_main()
}
}
bool
Replay
::
publishTopic
(
Subscription
&
sub
,
void
*
data
)
{
bool
published
=
false
;
if
(
sub
.
orb_advert
)
{
orb_publish
(
sub
.
orb_meta
,
sub
.
orb_advert
,
_read_buffer
.
data
());
published
=
true
;
}
else
{
if
(
sub
.
multi_id
==
0
)
{
sub
.
orb_advert
=
orb_advertise
(
sub
.
orb_meta
,
_read_buffer
.
data
());
published
=
true
;
}
else
{
// make sure the other instances are advertised already so that we get the correct instance
bool
advertised
=
false
;
for
(
const
auto
&
subscription
:
_subscriptions
)
{
if
(
subscription
.
orb_meta
)
{
if
(
strcmp
(
sub
.
orb_meta
->
o_name
,
subscription
.
orb_meta
->
o_name
)
==
0
&&
subscription
.
orb_advert
&&
subscription
.
multi_id
==
sub
.
multi_id
-
1
)
{
advertised
=
true
;
}
}
}
if
(
advertised
)
{
int
instance
;
sub
.
orb_advert
=
orb_advertise_multi
(
sub
.
orb_meta
,
_read_buffer
.
data
(),
&
instance
,
ORB_PRIO_DEFAULT
);
published
=
true
;
}
}
}
return
published
;
}
}
void
Replay
::
task_main_trampoline
(
int
argc
,
char
*
argv
[])
{
replay
::
instance
=
new
Replay
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment