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
=== modified file 'src/location/cmds/run.cpp'
--- src/location/cmds/run.cpp 2017-03-07 10:01:34 +0000
+++ src/location/cmds/run.cpp 2017-03-09 10:09:58 +0000
@@ -70,6 +70,15 @@
70 engine->add_provider(std::make_shared<location::providers::dummy::Provider>());70 engine->add_provider(std::make_shared<location::providers::dummy::Provider>());
71 }71 }
7272
73 try
74 {
75 engine->add_provider(location::providers::ubx::Provider::create_instance(ProviderFactory::Configuration{}));
76 }
77 catch (...)
78 {
79 ctxt.cout << "Error adding UBX provider." << std::endl;
80 }
81
73 location::dbus::skeleton::Service::Configuration config82 location::dbus::skeleton::Service::Configuration config
74 {83 {
75 bus,84 bus,
7685
=== modified file 'src/location/providers/ubx/provider.cpp'
--- src/location/providers/ubx/provider.cpp 2017-03-04 21:43:23 +0000
+++ src/location/providers/ubx/provider.cpp 2017-03-09 10:09:58 +0000
@@ -20,6 +20,7 @@
2020
21#include <location/logging.h>21#include <location/logging.h>
22#include <location/runtime.h>22#include <location/runtime.h>
23#include <location/glib/runtime.h>
2324
24#include <core/posix/this_process.h>25#include <core/posix/this_process.h>
2526
@@ -72,7 +73,10 @@
72 if (gga.hdop)73 if (gga.hdop)
73 position.accuracy().horizontal(gga.hdop.get() * 3. * units::meters);74 position.accuracy().horizontal(gga.hdop.get() * 3. * units::meters);
7475
75 provider->updates.position(location::Update<location::Position>{position});76 glib::Runtime::instance()->dispatch([this, position]()
77 {
78 provider->updates.position(location::Update<location::Position>{position});
79 });
76 }80 }
77}81}
7882
@@ -103,14 +107,17 @@
103107
104void ubx::Provider::Monitor::operator()(const _8::nmea::Vtg& vtg) const108void ubx::Provider::Monitor::operator()(const _8::nmea::Vtg& vtg) const
105{109{
106 if (vtg.cog_true)110 glib::Runtime::instance()->dispatch([this, vtg]()
107 provider->updates.heading(111 {
108 Update<units::Degrees>(112 if (vtg.cog_true)
109 vtg.cog_true.get() * units::degrees));113 provider->updates.heading(
110 if (vtg.sog_kmh)114 Update<units::Degrees>(
111 provider->updates.velocity(115 vtg.cog_true.get() * units::degrees));
112 Update<units::MetersPerSecond>(116 if (vtg.sog_kmh)
113 vtg.sog_kmh.get() * 1000./3600. * units::meters_per_second));117 provider->updates.velocity(
118 Update<units::MetersPerSecond>(
119 vtg.sog_kmh.get() * 1000./3600. * units::meters_per_second));
120 });
114}121}
115122
116location::Provider::Ptr ubx::Provider::create_instance(const location::ProviderFactory::Configuration& config)123location::Provider::Ptr ubx::Provider::create_instance(const location::ProviderFactory::Configuration& config)
@@ -127,7 +134,7 @@
127 : runtime{location::Runtime::create(1)},134 : runtime{location::Runtime::create(1)},
128 monitor{std::make_shared<Monitor>(this)},135 monitor{std::make_shared<Monitor>(this)},
129 receiver{_8::SerialPortReceiver::create(runtime->service(), device, monitor)}136 receiver{_8::SerialPortReceiver::create(runtime->service(), device, monitor)}
130{137{
131 runtime->start();138 runtime->start();
132}139}
133140

Subscribers

People subscribed via source and target branches

to all changes: