Merge lp:~thomas-voss/location-service/dispatch-ubx-updates-on-runtime into lp:location-service

Proposed by Thomas Voß
Status: Merged
Approved by: Thomas Voß
Approved revision: 292
Merged at revision: 294
Proposed branch: lp:~thomas-voss/location-service/dispatch-ubx-updates-on-runtime
Merge into: lp:location-service
Diff against target: 77 lines (+26/-10)
2 files modified
src/location/cmds/run.cpp (+9/-0)
src/location/providers/ubx/provider.cpp (+17/-10)
To merge this branch: bzr merge lp:~thomas-voss/location-service/dispatch-ubx-updates-on-runtime
Reviewer Review Type Date Requested Status
Simon Fels (community) Approve
Thomas Voß Pending
Review via email: mp+319416@code.launchpad.net

Commit message

Dispatch ubx::Provider via the runtime.

This is a temporary measure until all required interface changes
for supporting out-of-process providers have been released to snapd.

Description of the change

Dispatch ubx::Provider via the runtime.

This is a temporary measure until all required interface changes
for supporting out-of-process providers have been released to snapd.

To post a comment you must log in.
Revision history for this message
Simon Fels (morphis) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/location/cmds/run.cpp'
2--- src/location/cmds/run.cpp 2017-03-07 10:01:34 +0000
3+++ src/location/cmds/run.cpp 2017-03-09 10:09:58 +0000
4@@ -70,6 +70,15 @@
5 engine->add_provider(std::make_shared<location::providers::dummy::Provider>());
6 }
7
8+ try
9+ {
10+ engine->add_provider(location::providers::ubx::Provider::create_instance(ProviderFactory::Configuration{}));
11+ }
12+ catch (...)
13+ {
14+ ctxt.cout << "Error adding UBX provider." << std::endl;
15+ }
16+
17 location::dbus::skeleton::Service::Configuration config
18 {
19 bus,
20
21=== modified file 'src/location/providers/ubx/provider.cpp'
22--- src/location/providers/ubx/provider.cpp 2017-03-04 21:43:23 +0000
23+++ src/location/providers/ubx/provider.cpp 2017-03-09 10:09:58 +0000
24@@ -20,6 +20,7 @@
25
26 #include <location/logging.h>
27 #include <location/runtime.h>
28+#include <location/glib/runtime.h>
29
30 #include <core/posix/this_process.h>
31
32@@ -72,7 +73,10 @@
33 if (gga.hdop)
34 position.accuracy().horizontal(gga.hdop.get() * 3. * units::meters);
35
36- provider->updates.position(location::Update<location::Position>{position});
37+ glib::Runtime::instance()->dispatch([this, position]()
38+ {
39+ provider->updates.position(location::Update<location::Position>{position});
40+ });
41 }
42 }
43
44@@ -103,14 +107,17 @@
45
46 void ubx::Provider::Monitor::operator()(const _8::nmea::Vtg& vtg) const
47 {
48- if (vtg.cog_true)
49- provider->updates.heading(
50- Update<units::Degrees>(
51- vtg.cog_true.get() * units::degrees));
52- if (vtg.sog_kmh)
53- provider->updates.velocity(
54- Update<units::MetersPerSecond>(
55- vtg.sog_kmh.get() * 1000./3600. * units::meters_per_second));
56+ glib::Runtime::instance()->dispatch([this, vtg]()
57+ {
58+ if (vtg.cog_true)
59+ provider->updates.heading(
60+ Update<units::Degrees>(
61+ vtg.cog_true.get() * units::degrees));
62+ if (vtg.sog_kmh)
63+ provider->updates.velocity(
64+ Update<units::MetersPerSecond>(
65+ vtg.sog_kmh.get() * 1000./3600. * units::meters_per_second));
66+ });
67 }
68
69 location::Provider::Ptr ubx::Provider::create_instance(const location::ProviderFactory::Configuration& config)
70@@ -127,7 +134,7 @@
71 : runtime{location::Runtime::create(1)},
72 monitor{std::make_shared<Monitor>(this)},
73 receiver{_8::SerialPortReceiver::create(runtime->service(), device, monitor)}
74-{
75+{
76 runtime->start();
77 }
78

Subscribers

People subscribed via source and target branches

to all changes: